primer3.p3helpers

Contains Cython functions and classes that aid primer design

primer3.p3helpers.reverse_complement(seq, do_sanitize=False)

Compute reverse complement of the python string sequence

Parameters:
  • seq (str) – sequence string

  • do_sanitize – If True, convert non-IUPAC characters to N’s

Return type:

str

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 (bytes) – sequence in bytes

  • do_sanitize – If True, convert non-IUPAC characters to N’s

Return type:

bytes

Returns:

Reverse complement of sequence in bytes

Raises:
  • ValueError – Invalid base in sequence

  • OSErrormalloc 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

Parameters:

seq (str) – sequence to sanitize nonstandard with `N`s or `n`s

Return type:

str

Returns:

sanitized version of seq

Raises:

ValueError – Invalid base in sequence

primer3.p3helpers.sanitize_sequence_b(seq)

Sanitize bytes 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

Parameters:

seq (bytes) – sequence to sanitize nonstandard with `N`s or `n`s

Return type:

bytes

Returns:

sanitized version of seq

Raises:
  • ValueError – Invalid base in sequence

  • OSErrormalloc failure