primer3
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
Primer3 ¶
Bases:
Enables interaction with command line tool, primer3.
Attributes:
| Name | Type | Description |
|---|---|---|
|
file handle to the open reference genome file |
|
|
|
the sequence dictionary that corresponds to the provided reference genome file |
Source code in prymer/primer3/primer3.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
Functions¶
__init__ ¶
__init__(
genome_fasta: Path ,
executable: Optional [str ] = None,
variant_lookup: Optional [VariantLookup ] = None,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genome_fasta |
|
Path to reference genome .fasta file |
required |
executable |
|
string representation of the path to primer3_core |
None
|
variant_lookup |
|
VariantLookup object to facilitate hard-masking variants |
None
|
Assumes the sequence dictionary is located adjacent to the .fasta file and has the same base name with a .dict suffix.
Source code in prymer/primer3/primer3.py
close ¶
Closes fasta file regardless of underlying subprocess status. Logs an error if the underlying subprocess is not successfully closed.
Returns:
| Name | Type | Description |
|---|---|---|
True |
|
if the subprocess was terminated successfully |
False |
|
if the subprocess failed to terminate or was not already running |
Source code in prymer/primer3/primer3.py
design ¶
Designs primers, primer pairs, and/or internal probes given a target region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
design_input |
|
encapsulates the target region, design task, specifications, and scoring penalties |
required |
Returns:
| Type | Description |
|---|---|
|
Primer3Result containing both the valid and failed designs emitted by Primer3 |
Raises:
| Type | Description |
|---|---|
|
if underlying subprocess is not alive |
|
if Primer3 returns errors or does not return output |
|
if Primer3 output is malformed |
|
if an unknown design task is given |
Source code in prymer/primer3/primer3.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
get_design_sequences ¶
Extracts the reference sequence that corresponds to the design region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region |
|
the region of the genome to be extracted |
required |
Returns:
| Type | Description |
|---|---|
|
A tuple of two sequences: the sequence for the region, and the sequence for the region |
|
with variants hard-masked as Ns |
Source code in prymer/primer3/primer3.py
Primer3Failure
dataclass
¶
Bases:
Encapsulates how many designs failed for a given reason.
Extends the fgpyo.util.metric.Metric class, which will facilitate writing out results for
primer design QC etc.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
the reason the design failed |
|
|
how many designs failed |
Source code in prymer/primer3/primer3.py
Primer3FailureReason ¶
Bases:
Enum to represent the various reasons Primer3 removes primers and primer pairs.
https://github.com/bioinfo-ut/primer3_masker/blob/
6a40c4c408dc02b95ac02391457cda760092291a/src/libprimer3.c#L5581-L5605
This also contains custom failure values that are not generated by Primer3 but are convenient
to have so that post-processing failures can be tracked in the same way that Primer3 failures
are. These include LONG_DINUC, SECONDARY_STRUCTURE, and OFF_TARGET_AMPLIFICATION.
Source code in prymer/primer3/primer3_failure_reason.py
Functions¶
from_reason
classmethod
¶
Returns the first Primer3FailureReason with the given reason for failure.
If no failure exists, return None.
Source code in prymer/primer3/primer3_failure_reason.py
parse_failures
staticmethod
¶
When Primer3 encounters failures, extracts the reasons why designs that were considered by Primer3 failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
failures |
|
list of strings, with each string an "explanation" emitted by Primer3 about why the design failed. Each string may be a comma delimited of failures, or a single failure. |
()
|
Returns:
| Type | Description |
|---|---|
|
a |
Source code in prymer/primer3/primer3_failure_reason.py
Primer3Input
dataclass
¶
Assembles necessary inputs for Primer3 to orchestrate primer, primer pair, and/or internal probe design.
At least one set of design parameters (either PrimerAndAmpliconParameters
or ProbeParameters) must be specified.
If PrimerAndAmpliconParameters is provided but PrimerAndAmpliconWeights is not provided,
default PrimerAndAmpliconWeights will be used.
Similarly, if ProbeParameters is provided but ProbeWeights is not provided, default
ProbeWeights will be used.
Please see primer3_parameters.py for details on the defaults.
Raises:
| Type | Description |
|---|---|
|
if neither the primer or probe parameters are specified |
Source code in prymer/primer3/primer3_input.py
Functions¶
to_input_tags ¶
Assembles Primer3InputTag and values for input to Primer3
The target region must be wholly contained within design region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
design_region |
|
the design region, which wholly contains the target region, in which primers are to be designed. |
required |
Returns:
| Type | Description |
|---|---|
|
a mapping of |
Source code in prymer/primer3/primer3_input.py
Primer3InputTag ¶
Bases:
Enumeration of Primer3 input tags.
Please see the Primer3 manual for additional details
https://primer3.org/manual.html#commandLineTags
Source code in prymer/primer3/primer3_input_tag.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
Primer3Result
dataclass
¶
Bases:
Encapsulates Primer3 design results (both valid designs and failures).
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
filtered for out-of-spec characteristics and ordered (by objective function score) list of primer pairs or single oligos that were returned by Primer3 |
|
|
ordered list of Primer3Failures detailing design failure reasons and corresponding count |
Source code in prymer/primer3/primer3.py
Functions¶
as_primer_pair_result ¶
Returns this Primer3Result assuming the design results are of type PrimerPair.
Source code in prymer/primer3/primer3.py
as_primer_result ¶
Returns this Primer3Result assuming the design results are of type Primer.
Source code in prymer/primer3/primer3.py
primer_pairs ¶
Returns the design results as a list PrimerPairs
Source code in prymer/primer3/primer3.py
primers ¶
Returns the design results as a list Primers
PrimerAndAmpliconParameters
dataclass
¶
Holds common primer and amplicon design options that Primer3 uses to inform primer design.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
the min, optimal, and max amplicon size |
|
|
the min, optimal, and max amplicon melting temperatures |
|
|
the min, optimal, and max primer size |
|
|
the min, optimal, and max primer melting temperatures |
|
|
the min and maximal GC content for individual primers |
|
|
the min and max number of Gs and Cs in the 3' most N bases |
|
|
the max homopolymer length acceptable within a primer |
|
|
the max number of ambiguous bases acceptable within a primer |
|
|
the maximal number of bases in a dinucleotide run in a primer |
|
|
whether Primer3 should avoid designing primers in soft-masked regions |
|
|
the number of primers to return |
|
|
the max melting temperature acceptable for self-complementarity |
|
|
the max melting temperature acceptable for self-complementarity anchored at the 3' end |
|
|
the max melting temperature acceptable for secondary structure |
Please see the Primer3 manual for additional details: https://primer3.org/manual.html#globalTags
Each of primer_max_homodimer_tm, primer_max_3p_homodimer_tm, and primer_max_hairpin_tm is
optional. If these attributes are not provided, the default value will be set to 10 degrees
lower than the minimal melting temperature specified for the primer. This matches the Primer3
manual.
If these values are provided, users should provide the absolute value of the melting temperature threshold (i.e. when provided, values should be specified independent of primer design.)
Source code in prymer/primer3/primer3_parameters.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
Attributes¶
Functions¶
to_input_tags ¶
Converts input params to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_parameters.py
PrimerAndAmpliconWeights
dataclass
¶
Holds the primer-specific weights that Primer3 uses to adjust design penalties.
The weights that Primer3 uses when a parameter is less than optimal are labeled with "_lt". "_gt" weights are penalties applied when a parameter is greater than optimal.
Some of these settings depart from the default settings enumerated in the Primer3 manual. Please see the Primer3 manual for additional details: https://primer3.org/manual.html#globalTags
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
weight for products shorter than
|
|
|
weight for products longer than
|
|
|
weight for products with a Tm lower than
|
|
|
weight for products with a Tm greater than
|
|
|
penalty for the calculated maximum stability for the last five 3' bases of primer |
|
|
penalty for primers with GC percent lower than
|
|
|
weight for primers with GC percent higher than
|
|
|
penalty for the individual primer self binding value as specified
in |
|
|
weight for the 3'-anchored primer self binding value as specified in
|
|
|
penalty weight for the primer hairpin structure melting
temperature as defined in |
Source code in prymer/primer3/primer3_weights.py
Functions¶
to_input_tags ¶
Maps weights to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_weights.py
ProbeParameters
dataclass
¶
Holds common primer design options that Primer3 uses to inform internal probe design.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
the min, optimal, and max probe size |
|
|
the min, optimal, and max probe melting temperatures |
|
|
the min and max GC content for individual probes |
|
|
the number of probes to return |
|
|
the max number of bases in a dinucleotide run in a probe |
|
|
the max homopolymer length acceptable within a probe |
|
|
the max number of ambiguous bases acceptable within a probe |
|
|
the max melting temperature acceptable for self-complementarity |
|
|
the max melting temperature acceptable for self-complementarity anchored at the 3' end |
|
|
the max melting temperature acceptable for secondary structure |
The attributes that have default values specified take their default values from the Primer3 manual.
Please see the Primer3 manual for additional details: https://primer3.org/manual.html#globalTags
While Primer3 supports alignment based and thermodynamic methods for simulating hybridizations, prymer enforces the use of the thermodynamic approach. This is slightly more computationally expensive but superior in their ability to limit problematic oligo self-complementarity (e.g., primer-dimers, nonspecific binding of probes)
If they are not provided, probe_max_self_any_thermo, probe_max_self_end_thermo, and
probe_max_hairpin_thermo will be set to default values as specified in the Primer3 manual.
The default value is 10 degrees lower than the minimal melting temperature specified for
probe design (i.e. when not provided, values are specified relative to the probe design).
If these values are provided, users should provide the absolute value of the
melting temperature threshold (i.e. when provided, values should be specified as independent
of probe design.)
Source code in prymer/primer3/primer3_parameters.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
Functions¶
to_input_tags ¶
Converts input params to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_parameters.py
ProbeWeights
dataclass
¶
Holds the probe-specific weights that Primer3 uses to adjust design penalties.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
penalty for probes shorter than |
|
|
penalty for probes longer than |
|
|
penalty for probes with a Tm lower than |
|
|
penalty for probes with a Tm greater than |
|
|
penalty for probes with GC content lower than |
|
|
penalty for probes with GC content greater than |
|
|
penalty for probe self-complementarity as defined in
|
|
|
penalty for probe 3' complementarity as defined in
|
|
|
penalty for the most stable primer hairpin structure value as defined
in |
Each of these defaults are taken from the Primer3 manual. More details can be found here: https://primer3.org/manual.html
Source code in prymer/primer3/primer3_weights.py
Functions¶
to_input_tags ¶
Maps weights to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_weights.py
Modules¶
primer3 ¶
Primer3 Class and Methods¶
This module contains the Primer3 class, a class to
facilitate exchange of input and output data with Primer3, a command line tool.
Similar to the NtThermoAlign and
BwaAlnInteractive classes in the prymer
library, the Primer3 class extends the
ExecutableRunner base class to
initiate an underlying subprocess, read and write input and output data, and gracefully terminate
any remaining subprocesses.
Examples¶
The genome FASTA must be provided to the Primer3 constructor, such that design and target
nucleotide sequences can be retrieved. The full path to the primer3 executable can provided,
otherwise it is assumed to be on the PATH. Furthermore, optionally a
VariantLookup may be provided to
hard-mask the design and target regions as to avoid design primers over polymorphic sites.
>>> from pathlib import Path
>>> from prymer.api.variant_lookup import VariantLookup, VariantOverlapDetector
>>> genome_fasta = Path("./tests/primer3/data/miniref.fa")
>>> genome_vcf = Path("./tests/primer3/data/miniref.variants.vcf.gz")
>>> variant_lookup: VariantLookup = VariantOverlapDetector(vcf_paths=[genome_vcf], min_maf=0.01, include_missing_mafs=False)
>>> designer = Primer3(genome_fasta=genome_fasta, variant_lookup=variant_lookup)
The get_design_sequences() method on Primer3 is used to retrieve the soft and hard masked
sequences for a given region. The hard-masked sequence replaces bases with Ns that overlap
polymorphic sites found in the VariantLookup provided in the constructor.
>>> design_region = Span(refname="chr2", start=9095, end=9120)
>>> soft_masked, hard_masked = designer.get_design_sequences(region=design_region)
>>> soft_masked
'AGTTACATTACAAAAGGCAGATTTCA'
>>> hard_masked
'AGTTANNNTACAAAAGGCAGATTTCA'
The design() method on Primer3 is used to design the primers given a
Primer3Input. The latter includes all the
parameters and target region.
>>> from prymer.primer3.primer3_parameters import PrimerAndAmpliconParameters
>>> from prymer.api import MinOptMax
>>> target = Span(refname="chr1", start=201, end=250, strand=Strand.POSITIVE)
>>> params = PrimerAndAmpliconParameters( amplicon_sizes=MinOptMax(min=100, max=250, opt=200), amplicon_tms=MinOptMax(min=55.0, max=100.0, opt=70.0), primer_sizes=MinOptMax(min=29, max=31, opt=30), primer_tms=MinOptMax(min=63.0, max=67.0, opt=65.0), primer_gcs=MinOptMax(min=30.0, max=65.0, opt=45.0), )
>>> design_input = Primer3Input( target=target, primer_and_amplicon_params=params, task=DesignLeftPrimersTask(), )
>>> left_result = designer.design(design_input=design_input)
The left_result returns the Primer3Result
container class. It contains two attributes:
1. designs: filtered and ordered (by objective function score) list of primer pairs or
single primers that were returned by Primer3.
2. failures: ordered list of Primer3Failures
detailing design failure reasons and corresponding count.
In this case, there are two failures reasons:
>>> for failure in left_result.failures: print(failure)
Primer3Failure(reason=<Primer3FailureReason.HIGH_TM: 'high tm'>, count=406)
Primer3Failure(reason=<Primer3FailureReason.GC_CONTENT: 'GC content failed'>, count=91)
While the designs attribute on Primer3Result may be used to access the list of primers or
primer pairs, it is more convenient to use the primers() and primer_pairs() methods
to return the designed primers or primer pairs (use the method corresponding to the input task) so
that the proper type is returned (i.e. Primer or
PrimerPair).
>>> for primer in left_result.primers(): print(primer)
TCTGAACAGGACGAACTGGATTTCCTCAT 65.686 1.953897 chr1:163-191:+
CTCTGAACAGGACGAACTGGATTTCCTCAT 66.152 2.293213 chr1:162-191:+
TCTGAACAGGACGAACTGGATTTCCTCATG 66.33 2.514048 chr1:163-192:+
AACAGGACGAACTGGATTTCCTCATGGAA 66.099 2.524986 chr1:167-195:+
CTGAACAGGACGAACTGGATTTCCTCATG 65.47 2.556859 chr1:164-192:+
Finally, the designer should be closed to terminate the sub-process:
Primer3 is also context a manager, and so can be used with a with clause:
Attributes¶
OligoLikeType
module-attribute
¶
Type variable for a Primer3Result, which must implement OligoLike
Classes¶
Primer3 ¶
Bases:
Enables interaction with command line tool, primer3.
Attributes:
| Name | Type | Description |
|---|---|---|
|
file handle to the open reference genome file |
|
|
|
the sequence dictionary that corresponds to the provided reference genome file |
Source code in prymer/primer3/primer3.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
Functions¶
__init__(
genome_fasta: Path ,
executable: Optional [str ] = None,
variant_lookup: Optional [VariantLookup ] = None,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genome_fasta |
|
Path to reference genome .fasta file |
required |
executable |
|
string representation of the path to primer3_core |
None
|
variant_lookup |
|
VariantLookup object to facilitate hard-masking variants |
None
|
Assumes the sequence dictionary is located adjacent to the .fasta file and has the same base name with a .dict suffix.
Source code in prymer/primer3/primer3.py
Closes fasta file regardless of underlying subprocess status. Logs an error if the underlying subprocess is not successfully closed.
Returns:
| Name | Type | Description |
|---|---|---|
True |
|
if the subprocess was terminated successfully |
False |
|
if the subprocess failed to terminate or was not already running |
Source code in prymer/primer3/primer3.py
Designs primers, primer pairs, and/or internal probes given a target region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
design_input |
|
encapsulates the target region, design task, specifications, and scoring penalties |
required |
Returns:
| Type | Description |
|---|---|
|
Primer3Result containing both the valid and failed designs emitted by Primer3 |
Raises:
| Type | Description |
|---|---|
|
if underlying subprocess is not alive |
|
if Primer3 returns errors or does not return output |
|
if Primer3 output is malformed |
|
if an unknown design task is given |
Source code in prymer/primer3/primer3.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
Extracts the reference sequence that corresponds to the design region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region |
|
the region of the genome to be extracted |
required |
Returns:
| Type | Description |
|---|---|
|
A tuple of two sequences: the sequence for the region, and the sequence for the region |
|
with variants hard-masked as Ns |
Source code in prymer/primer3/primer3.py
Primer3Failure
dataclass
¶
Bases:
Encapsulates how many designs failed for a given reason.
Extends the fgpyo.util.metric.Metric class, which will facilitate writing out results for
primer design QC etc.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
the reason the design failed |
|
|
how many designs failed |
Source code in prymer/primer3/primer3.py
Primer3Result
dataclass
¶
Bases:
Encapsulates Primer3 design results (both valid designs and failures).
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
filtered for out-of-spec characteristics and ordered (by objective function score) list of primer pairs or single oligos that were returned by Primer3 |
|
|
ordered list of Primer3Failures detailing design failure reasons and corresponding count |
Source code in prymer/primer3/primer3.py
Functions¶
Returns this Primer3Result assuming the design results are of type PrimerPair.
Source code in prymer/primer3/primer3.py
Returns this Primer3Result assuming the design results are of type Primer.
Source code in prymer/primer3/primer3.py
Returns the design results as a list PrimerPairs
Source code in prymer/primer3/primer3.py
Returns the design results as a list Primers
primer3_failure_reason ¶
Primer3FailureReason Class¶
This module contains a Primer3FailureReason class. Based on user-specified criteria, Primer3 will disqualify primer designs if the characteristics of the design are outside an allowable range of parameters.
Failure reason strings are documented in the Primer3 source code, accessible here (at the time of Primer3FailureReason implementation): https://github.com/bioinfo-ut/primer3_masker/blob/master/src/libprimer3.c#L5581-L5604
Example Primer3 failure reasons emitted¶
Primer3 shall return a comma-delimited list of failure explanations. They will have key
PRIMER_LEFT_EXPLAIN for designing individual left primers, PRIMER_RIGHT_EXPLAIN for designing
individual right primers, and PRIMER_PAIR_EXPLAIN for designing primer pairs.
For individual primers:
>>> failure_string = 'considered 160, too many Ns 20, low tm 127, ok 13'
>>> Primer3FailureReason.parse_failures(failure_string)
Counter({<Primer3FailureReason.LOW_TM: 'low tm'>: 127, <Primer3FailureReason.TOO_MANY_NS: 'too many Ns'>: 20})
>>> failure_string = 'considered 238, low tm 164, high tm 12, high hairpin stability 23, ok 39'
>>> Primer3FailureReason.parse_failures(failure_string)
Counter({<Primer3FailureReason.LOW_TM: 'low tm'>: 164, <Primer3FailureReason.HAIRPIN_STABILITY: 'high hairpin stability'>: 23, <Primer3FailureReason.HIGH_TM: 'high tm'>: 12})
>>> failure_string = 'considered 166, unacceptable product size 161, ok 5'
>>> Primer3FailureReason.parse_failures(failure_string)
Counter({<Primer3FailureReason.PRODUCT_SIZE: 'unacceptable product size'>: 161})
Classes¶
Primer3FailureReason ¶
Bases:
Enum to represent the various reasons Primer3 removes primers and primer pairs.
https://github.com/bioinfo-ut/primer3_masker/blob/
6a40c4c408dc02b95ac02391457cda760092291a/src/libprimer3.c#L5581-L5605
This also contains custom failure values that are not generated by Primer3 but are convenient
to have so that post-processing failures can be tracked in the same way that Primer3 failures
are. These include LONG_DINUC, SECONDARY_STRUCTURE, and OFF_TARGET_AMPLIFICATION.
Source code in prymer/primer3/primer3_failure_reason.py
Functions¶
classmethod
¶Returns the first Primer3FailureReason with the given reason for failure.
If no failure exists, return None.
Source code in prymer/primer3/primer3_failure_reason.py
staticmethod
¶When Primer3 encounters failures, extracts the reasons why designs that were considered by Primer3 failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
failures |
|
list of strings, with each string an "explanation" emitted by Primer3 about why the design failed. Each string may be a comma delimited of failures, or a single failure. |
()
|
Returns:
| Type | Description |
|---|---|
|
a |
Source code in prymer/primer3/primer3_failure_reason.py
primer3_input ¶
Primer3Input Class and Methods¶
This module contains the Primer3Input class. The class
wraps together different helper classes to assemble user-specified criteria and parameters for
input to Primer3.
The module uses:
PrimerAndAmpliconParametersto specify user-specified criteria for primer designProbeParametersto specify user-specified criteria for probe designPrimerAndAmpliconWeightsto establish penalties based on those criteriaProbeWeightsto specify penalties based on probe design criteriaPrimer3Taskto organize task-specific logic.- [
Span](index.md#prymer.api.span.Span] to specify the target region.
The Primer3Input.to_input_tags(] method
The main purpose of this class is to generate the
Primer3InputTagss required by
Primer3 for specifying how to design the primers, returned by the to_input_tags(] method.
Examples¶
The following examples builds the Primer3 tags for designing left primers:
```python
from prymer.api import MinOptMax, Strand from prymer.primer3 import DesignLeftPrimersTask target = Span(refname="chr1", start=201, end=250, strand=Strand.POSITIVE) design_region = Span(refname="chr1", start=150, end=300, strand=Strand.POSITIVE) params = PrimerAndAmpliconParameters( amplicon_sizes=MinOptMax(min=100, max=250, opt=200), amplicon_tms=MinOptMax(min=55.0, max=100.0, opt=70.0), primer_sizes=MinOptMax(min=29, max=31, opt=30), primer_tms=MinOptMax(min=63.0, max=67.0, opt=65.0), primer_gcs=MinOptMax(min=30.0, max=65.0, opt=45.0), ) design_input = Primer3Input(target=target, primer_and_amplicon_params=params, task=DesignLeftPrimersTask() )
for tag, value in design_input.to_input_tags(design_region=design_region).items(): print(f"{tag.value} -> {value}") PRIMER_TASK -> pick_primer_list PRIMER_PICK_LEFT_PRIMER -> 1 PRIMER_PICK_RIGHT_PRIMER -> 0 PRIMER_PICK_INTERNAL_OLIGO -> 0 SEQUENCE_INCLUDED_REGION -> 1,51 PRIMER_PRODUCT_OPT_SIZE -> 200 PRIMER_PRODUCT_SIZE_RANGE -> 100-250 PRIMER_PRODUCT_MIN_TM -> 55.0 PRIMER_PRODUCT_OPT_TM -> 70.0 PRIMER_PRODUCT_MAX_TM -> 100.0 PRIMER_MIN_SIZE -> 29 PRIMER_OPT_SIZE -> 30 PRIMER_MAX_SIZE -> 31 PRIMER_MIN_TM -> 63.0 PRIMER_OPT_TM -> 65.0 PRIMER_MAX_TM -> 67.0 PRIMER_MIN_GC -> 30.0 PRIMER_OPT_GC_PERCENT -> 45.0 PRIMER_MAX_GC -> 65.0 PRIMER_GC_CLAMP -> 0 PRIMER_MAX_END_GC -> 5 PRIMER_MAX_POLY_X -> 5 PRIMER_MAX_NS_ACCEPTED -> 1 PRIMER_LOWERCASE_MASKING -> 1 PRIMER_NUM_RETURN -> 5 PRIMER_MAX_SELF_ANY_TH -> 53.0 PRIMER_MAX_SELF_END_TH -> 53.0 PRIMER_MAX_HAIRPIN_TH -> 53.0 PRIMER_PAIR_WT_PRODUCT_SIZE_LT -> 1.0 PRIMER_PAIR_WT_PRODUCT_SIZE_GT -> 1.0 PRIMER_PAIR_WT_PRODUCT_TM_LT -> 0.0 PRIMER_PAIR_WT_PRODUCT_TM_GT -> 0.0 PRIMER_WT_END_STABILITY -> 0.25 PRIMER_WT_GC_PERCENT_LT -> 0.25 PRIMER_WT_GC_PERCENT_GT -> 0.25 PRIMER_WT_SELF_ANY -> 0.1 PRIMER_WT_SELF_END -> 0.1 PRIMER_WT_SIZE_LT -> 0.5 PRIMER_WT_SIZE_GT -> 0.1 PRIMER_WT_TM_LT -> 1.0 PRIMER_WT_TM_GT -> 1.0 PRIMER_WT_SELF_ANY_TH -> 0.0 PRIMER_WT_SELF_END_TH -> 0.0 PRIMER_WT_HAIRPIN_TH -> 0.0
Attributes¶
Classes¶
Primer3Input
dataclass
¶
Assembles necessary inputs for Primer3 to orchestrate primer, primer pair, and/or internal probe design.
At least one set of design parameters (either PrimerAndAmpliconParameters
or ProbeParameters) must be specified.
If PrimerAndAmpliconParameters is provided but PrimerAndAmpliconWeights is not provided,
default PrimerAndAmpliconWeights will be used.
Similarly, if ProbeParameters is provided but ProbeWeights is not provided, default
ProbeWeights will be used.
Please see primer3_parameters.py for details on the defaults.
Raises:
| Type | Description |
|---|---|
|
if neither the primer or probe parameters are specified |
Source code in prymer/primer3/primer3_input.py
Functions¶
Assembles Primer3InputTag and values for input to Primer3
The target region must be wholly contained within design region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
design_region |
|
the design region, which wholly contains the target region, in which primers are to be designed. |
required |
Returns:
| Type | Description |
|---|---|
|
a mapping of |
Source code in prymer/primer3/primer3_input.py
primer3_input_tag ¶
Primer3InputTag Class and Methods¶
This module contains a class, Primer3InputTag, to standardize user input to Primer3. Settings that
are controlled here include general parameters that apply to a singular Primer3 session
as well as query-specific settings that can be changed in between primer queries.
Classes¶
Primer3InputTag ¶
Bases:
Enumeration of Primer3 input tags.
Please see the Primer3 manual for additional details
https://primer3.org/manual.html#commandLineTags
Source code in prymer/primer3/primer3_input_tag.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
primer3_parameters ¶
PrimerAndAmpliconParameters and ProbeParameters: Classes and Methods¶
The PrimerAndAmpliconParameters
class stores user input for primer design and maps it to the correct Primer3 fields.
Primer3 considers many criteria for primer design, including characteristics of candidate primers and the resultant amplicon product, as well as potential complications (off-target priming, primer dimer formation). Users can specify many of these constraints in Primer3, some of which are used to quantify a "score" for each primer design.
The PrimerAndAmpliconParameters class stores commonly used constraints for primer design:
GC content, melting temperature, and size of both primers and expected amplicon.
Additional criteria include the maximum homopolymer length, ambiguous bases, and bases in a
dinucleotide run within a primer. By default, primer design avoids masked bases, returns 5 primers,
and sets the GC clamp to be no larger than 5.
The to_input_tags() method in PrimerAndAmpliconParameters converts these parameters into
tag-values pairs for use when executing Primer3.
The ProbeParameters
class stores user input for internal probe design and maps it to the correct Primer3 fields.
Similar to the PrimerAndAmpliconParameters class, the ProbeParameters class can be used to
specify the acceptable ranges of probe sizes, melting temperatures, and GC content.
Examples¶
>>> params = PrimerAndAmpliconParameters( amplicon_sizes=MinOptMax(min=100, max=250, opt=200), amplicon_tms=MinOptMax(min=55.0, max=100.0, opt=70.0), primer_sizes=MinOptMax(min=29, max=31, opt=30), primer_tms=MinOptMax(min=63.0, max=67.0, opt=65.0), primer_gcs=MinOptMax(min=30.0, max=65.0, opt=45.0), )
>>> for tag, value in params.to_input_tags().items(): print(f"{tag.value} -> {value}")
PRIMER_PRODUCT_OPT_SIZE -> 200
PRIMER_PRODUCT_SIZE_RANGE -> 100-250
PRIMER_PRODUCT_MIN_TM -> 55.0
PRIMER_PRODUCT_OPT_TM -> 70.0
PRIMER_PRODUCT_MAX_TM -> 100.0
PRIMER_MIN_SIZE -> 29
PRIMER_OPT_SIZE -> 30
PRIMER_MAX_SIZE -> 31
PRIMER_MIN_TM -> 63.0
PRIMER_OPT_TM -> 65.0
PRIMER_MAX_TM -> 67.0
PRIMER_MIN_GC -> 30.0
PRIMER_OPT_GC_PERCENT -> 45.0
PRIMER_MAX_GC -> 65.0
PRIMER_GC_CLAMP -> 0
PRIMER_MAX_END_GC -> 5
PRIMER_MAX_POLY_X -> 5
PRIMER_MAX_NS_ACCEPTED -> 1
PRIMER_LOWERCASE_MASKING -> 1
PRIMER_NUM_RETURN -> 5
PRIMER_MAX_SELF_ANY_TH -> 53.0
PRIMER_MAX_SELF_END_TH -> 53.0
PRIMER_MAX_HAIRPIN_TH -> 53.0
Classes¶
Primer3Parameters
dataclass
¶
Bases:
A deprecated alias for PrimerAndAmpliconParameters intended to maintain backwards
compatibility with earlier releases of prymer.
Source code in prymer/primer3/primer3_parameters.py
PrimerAndAmpliconParameters
dataclass
¶
Holds common primer and amplicon design options that Primer3 uses to inform primer design.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
the min, optimal, and max amplicon size |
|
|
the min, optimal, and max amplicon melting temperatures |
|
|
the min, optimal, and max primer size |
|
|
the min, optimal, and max primer melting temperatures |
|
|
the min and maximal GC content for individual primers |
|
|
the min and max number of Gs and Cs in the 3' most N bases |
|
|
the max homopolymer length acceptable within a primer |
|
|
the max number of ambiguous bases acceptable within a primer |
|
|
the maximal number of bases in a dinucleotide run in a primer |
|
|
whether Primer3 should avoid designing primers in soft-masked regions |
|
|
the number of primers to return |
|
|
the max melting temperature acceptable for self-complementarity |
|
|
the max melting temperature acceptable for self-complementarity anchored at the 3' end |
|
|
the max melting temperature acceptable for secondary structure |
Please see the Primer3 manual for additional details: https://primer3.org/manual.html#globalTags
Each of primer_max_homodimer_tm, primer_max_3p_homodimer_tm, and primer_max_hairpin_tm is
optional. If these attributes are not provided, the default value will be set to 10 degrees
lower than the minimal melting temperature specified for the primer. This matches the Primer3
manual.
If these values are provided, users should provide the absolute value of the melting temperature threshold (i.e. when provided, values should be specified independent of primer design.)
Source code in prymer/primer3/primer3_parameters.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
Attributes¶
Functions¶
Converts input params to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_parameters.py
ProbeParameters
dataclass
¶
Holds common primer design options that Primer3 uses to inform internal probe design.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
the min, optimal, and max probe size |
|
|
the min, optimal, and max probe melting temperatures |
|
|
the min and max GC content for individual probes |
|
|
the number of probes to return |
|
|
the max number of bases in a dinucleotide run in a probe |
|
|
the max homopolymer length acceptable within a probe |
|
|
the max number of ambiguous bases acceptable within a probe |
|
|
the max melting temperature acceptable for self-complementarity |
|
|
the max melting temperature acceptable for self-complementarity anchored at the 3' end |
|
|
the max melting temperature acceptable for secondary structure |
The attributes that have default values specified take their default values from the Primer3 manual.
Please see the Primer3 manual for additional details: https://primer3.org/manual.html#globalTags
While Primer3 supports alignment based and thermodynamic methods for simulating hybridizations, prymer enforces the use of the thermodynamic approach. This is slightly more computationally expensive but superior in their ability to limit problematic oligo self-complementarity (e.g., primer-dimers, nonspecific binding of probes)
If they are not provided, probe_max_self_any_thermo, probe_max_self_end_thermo, and
probe_max_hairpin_thermo will be set to default values as specified in the Primer3 manual.
The default value is 10 degrees lower than the minimal melting temperature specified for
probe design (i.e. when not provided, values are specified relative to the probe design).
If these values are provided, users should provide the absolute value of the
melting temperature threshold (i.e. when provided, values should be specified as independent
of probe design.)
Source code in prymer/primer3/primer3_parameters.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
Functions¶
Converts input params to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_parameters.py
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¶
class-attribute
¶The tag returned by Primer3 that provides the number of primers returned
class-attribute
¶Tracks task type for downstream analysis
Functions¶
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.
Source code in prymer/primer3/primer3_task.py
primer3_weights ¶
Primer3Weights Class and Methods¶
The PrimerAndAmpliconWeights class holds the penalty weights that Primer3 uses to score primer designs.
The ProbeWeights class holds the penalty weights that Primer3 uses to score internal probe designs.
Primer3 considers the differential between user input (e.g., constraining the optimal primer size to be 18 bp) and the characteristics of a specific primer design (e.g., if the primer size is 19 bp). Depending on the "weight" of that characteristic, Primer3 uses an objective function to score a primer design and help define what an "optimal" design looks like.
By modifying these weights, users can prioritize specific primer design characteristics. Each of the defaults provided here are derived from the Primer3 manual: https://primer3.org/manual.html
Examples of interacting with the PrimerAndAmpliconWeights class¶
Example:
PrimerAndAmpliconWeights() # default implementation PrimerAndAmpliconWeights(product_size_lt=1.0, product_size_gt=1.0, product_tm_lt=0.0, product_tm_gt=0.0, primer_end_stability=0.25, primer_gc_lt=0.25, primer_gc_gt=0.25, primer_self_any=0.1, primer_self_end=0.1, primer_size_lt=0.5, primer_size_gt=0.1, primer_tm_lt=1.0, primer_tm_gt=1.0, primer_homodimer_wt=0.0, primer_3p_homodimer_wt=0.0, primer_secondary_structure_wt=0.0) PrimerAndAmpliconWeights(product_size_lt=5.0) PrimerAndAmpliconWeights(product_size_lt=5.0, product_size_gt=1.0, product_tm_lt=0.0, product_tm_gt=0.0, primer_end_stability=0.25, primer_gc_lt=0.25, primer_gc_gt=0.25, primer_self_any=0.1, primer_self_end=0.1, primer_size_lt=0.5, primer_size_gt=0.1, primer_tm_lt=1.0, primer_tm_gt=1.0, primer_homodimer_wt=0.0, primer_3p_homodimer_wt=0.0, primer_secondary_structure_wt=0.0)
Classes¶
PrimerAndAmpliconWeights
dataclass
¶
Holds the primer-specific weights that Primer3 uses to adjust design penalties.
The weights that Primer3 uses when a parameter is less than optimal are labeled with "_lt". "_gt" weights are penalties applied when a parameter is greater than optimal.
Some of these settings depart from the default settings enumerated in the Primer3 manual. Please see the Primer3 manual for additional details: https://primer3.org/manual.html#globalTags
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
weight for products shorter than
|
|
|
weight for products longer than
|
|
|
weight for products with a Tm lower than
|
|
|
weight for products with a Tm greater than
|
|
|
penalty for the calculated maximum stability for the last five 3' bases of primer |
|
|
penalty for primers with GC percent lower than
|
|
|
weight for primers with GC percent higher than
|
|
|
penalty for the individual primer self binding value as specified
in |
|
|
weight for the 3'-anchored primer self binding value as specified in
|
|
|
penalty weight for the primer hairpin structure melting
temperature as defined in |
Source code in prymer/primer3/primer3_weights.py
Functions¶
Maps weights to Primer3InputTag to feed directly into Primer3.
Source code in prymer/primer3/primer3_weights.py
ProbeWeights
dataclass
¶
Holds the probe-specific weights that Primer3 uses to adjust design penalties.
Attributes:
| Name | Type | Description |
|---|---|---|
|
|
penalty for probes shorter than |
|
|
penalty for probes longer than |
|
|
penalty for probes with a Tm lower than |
|
|
penalty for probes with a Tm greater than |
|
|
penalty for probes with GC content lower than |
|
|
penalty for probes with GC content greater than |
|
|
penalty for probe self-complementarity as defined in
|
|
|
penalty for probe 3' complementarity as defined in
|
|
|
penalty for the most stable primer hairpin structure value as defined
in |
Each of these defaults are taken from the Primer3 manual. More details can be found here: https://primer3.org/manual.html
Source code in prymer/primer3/primer3_weights.py
Functions¶
Maps weights to Primer3InputTag to feed directly into Primer3.