primer3_task
Primer3Task Class and Methods¶
This module contains a Primer3Task class to provide design-specific parameters to Primer3. The
classes are primarily used in Primer3Input.
Primer3 can design single primers ("left" and "right") as well as primer pairs. The design task "type" dictates which type of primers to pick and informs the design region. These parameters are aligned to the correct Primer3 settings and fed directly into Primer3.
Four types of tasks are available:
DesignPrimerPairsTask-- task for designing primer pairs.DesignLeftPrimersTask-- task for designing primers to the left (5') of the design region on the top/positive strand.DesignRightPrimersTask-- task for designing primers to the right (3') of the design region on the bottom/negative strand.PickHybProbeOnly-- task for designing an internal probe for hybridization-based technologies
The main purpose of these classes are to generate the
Primer3InputTagss required by
Primer3 for specifying how to design the primers, returned by the to_input_tags() method. The
target and design region are provided to this method, where the target region is wholly contained
within design region. This leaves a left and right primer region respectively, that are
the two regions that remain after removing the wholly contained (inner) target regions.
Therefore, the left primers shall be designed from the start of the design region to the start of the target region, while right primers shall be designed from the end of the target region through to the end of the design region.
In addition to the to_input_tags() method, each Primer3TaskType provides a task_type and
count_tag class property. The former is a TaskType enumeration that represents the type of
design task, while the latter is the tag returned by Primer3 that provides the number of primers
returned.
Examples¶
Suppose we have the following design and target regions:
>>> from prymer.api import Strand
>>> design_region = Span(refname="chr1", start=1, end=500, strand=Strand.POSITIVE)
>>> target = Span(refname="chr1", start=200, end=300, strand=Strand.POSITIVE)
>>> design_region.contains(target)
True
The task for designing primer pairs:
>>> task = DesignPrimerPairsTask()
>>> task.task_type.value
'PAIR'
>>> task.count_tag
'PRIMER_PAIR_NUM_RETURNED'
>>> [(tag.value, value) for tag, value in task.to_input_tags(target=target, design_region=design_region).items()]
[('PRIMER_TASK', 'generic'), ('PRIMER_PICK_LEFT_PRIMER', 1), ('PRIMER_PICK_RIGHT_PRIMER', 1), ('PRIMER_PICK_INTERNAL_OLIGO', 0), ('SEQUENCE_TARGET', '200,101')]
The tasks for designing left primers:
>>> task = DesignLeftPrimersTask()
>>> task.task_type.value
'LEFT'
>>> task.count_tag
'PRIMER_LEFT_NUM_RETURNED'
>>> [(tag.value, value) for tag, value in task.to_input_tags(target=target, design_region=design_region).items()]
[('PRIMER_TASK', 'pick_primer_list'), ('PRIMER_PICK_LEFT_PRIMER', 1), ('PRIMER_PICK_RIGHT_PRIMER', 0), ('PRIMER_PICK_INTERNAL_OLIGO', 0), ('SEQUENCE_INCLUDED_REGION', '1,199')]
The tasks for designing left primers:
>>> task = DesignRightPrimersTask()
>>> task.task_type.value
'RIGHT'
>>> task.count_tag
'PRIMER_RIGHT_NUM_RETURNED'
>>> [(tag.value, value) for tag, value in task.to_input_tags(target=target, design_region=design_region).items()]
[('PRIMER_TASK', 'pick_primer_list'), ('PRIMER_PICK_LEFT_PRIMER', 0), ('PRIMER_PICK_RIGHT_PRIMER', 1), ('PRIMER_PICK_INTERNAL_OLIGO', 0), ('SEQUENCE_INCLUDED_REGION', '300,200')]
Attributes¶
Primer3TaskType
module-attribute
¶
Primer3TaskType: TypeAlias = Union [
"DesignPrimerPairsTask",
"DesignLeftPrimersTask",
"DesignRightPrimersTask",
"PickHybProbeOnly",
]
Type alias for all Primer3Tasks, to enable exhaustiveness checking.
Classes¶
DesignLeftPrimersTask ¶
Bases:
Stores task-specific characteristics for designing left primers.
Source code in prymer/primer3/primer3_task.py
DesignPrimerPairsTask ¶
Bases:
Stores task-specific Primer3 settings for designing primer pairs
Source code in prymer/primer3/primer3_task.py
DesignRightPrimersTask ¶
Bases:
Stores task-specific characteristics for designing right primers
Source code in prymer/primer3/primer3_task.py
PickHybProbeOnly ¶
Bases:
Stores task-specific characteristics for designing an internal hybridization probe.
Source code in prymer/primer3/primer3_task.py
Primer3Task ¶
Bases:
Abstract base class from which the other classes derive.
Source code in prymer/primer3/primer3_task.py
Attributes¶
count_tag
class-attribute
¶
The tag returned by Primer3 that provides the number of primers returned
task_type
class-attribute
¶
Tracks task type for downstream analysis
Functions¶
to_input_tags ¶
Returns the input tags specific to this type of task for Primer3.
Ensures target region is wholly contained within design region. Subclass specific implementation aligns the set of input parameters specific to primer pair or single primer design.
This implementation mimics the Template method, a Behavioral Design Pattern in which the
abstract base class contains a rough skeleton of methods and the derived subclasses
implement the details of those methods. In this case, each of the derived subclasses
will first use the base class to_input_tags() method to check that the target region is
wholly contained within the design region. If so, they will implement task-specific logic
for the to_input_tags() method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target |
|
the target region (to be amplified) |
required |
design_region |
|
the design region, which wholly contains the target region, in which primers are to be designed |
required |
Raises:
| Type | Description |
|---|---|
|
if the target region is not contained within the design region |
Returns:
| Type | Description |
|---|---|
|
The input tags for Primer3 |
Source code in prymer/primer3/primer3_task.py
TaskType ¶
Bases:
Represents the type of design task: design primer pairs, individual primers (left or right), or an internal hybridization probe.