primer3.p3helpers
Contains Cython functions and classes that aid primer design
- primer3.p3helpers.ensure_acgt_uppercase(seq)
Convert sequence to uppercase and validate it contains only A, C, G, T bases. This is stricter than sanitize_sequence() as it only allows A, C, G, T bases.
If the sequence is already uppercase ACGT, returns the original string without any allocation or copying.
- Parameters:
seq – sequence to convert to uppercase and validate
- Returns:
uppercase version of seq containing only A, C, G, T bases
- Raises:
ValueError – If sequence contains any characters other than A, C, G, T (case insensitive)
- primer3.p3helpers.ensure_acgt_uppercase_b(seq)
Convert bytes sequence to uppercase and validate it contains only A, C, G, T bases. This is stricter than sanitize_sequence_b() as it only allows A, C, G, T bases.
If the sequence is already uppercase ACGT, returns the original bytes without any allocation or copying.
- Parameters:
seq – sequence to convert to uppercase and validate
- Returns:
uppercase version of seq containing only A, C, G, T bases
- Raises:
ValueError – If sequence contains any characters other than A, C, G, T (case insensitive)
OSError – malloc failure
- primer3.p3helpers.reverse_complement(seq, do_sanitize=False)
Compute reverse complement of the python string sequence
- Parameters:
seq – sequence string
do_sanitize – If True, convert non-IUPAC characters to N’s
- Returns:
Reverse complement of sequence string
- Raises:
ValueError – Invalid base in sequence
- primer3.p3helpers.reverse_complement_b(seq, do_sanitize=False)
Compute reverse complement of the bytes sequence
- Parameters:
seq – sequence in bytes
do_sanitize – If True, convert non-IUPAC characters to N’s
- Returns:
Reverse complement of sequence in bytes
- Raises:
ValueError – Invalid base in sequence
OSError –
malloc
failure
- primer3.p3helpers.sanitize_sequence(seq)
Sanitize sequence with non-standard bases with `N`s IUPAC {R,Y,M,K,S,W,H,D,B,V,r,y,m,k,s,w,h,d,b,v}
IUPAC non-{A,C,G,T,a,c,g,t} bases become {N, n}
NOTE: Consider keeping a copy of original
seq
argument for record keeping