Package Bio :: Package SeqUtils
[hide private]
[frames] | no frames]

Package SeqUtils

source code

Miscellaneous functions for dealing with sequences.

Submodules [hide private]

Classes [hide private]
  ProteinX
  MissingTable
Functions [hide private]
 
reverse(seq)
Reverse the sequence.
source code
 
GC(seq)
Calculates G+C content, returns the percentage (float between 0 and 100).
source code
 
GC123(seq)
Calculates total G+C content plus first, second and third positions.
source code
 
GC_skew(seq, window=100)
Calculates GC skew (G-C)/(G+C) for multuple windows along the sequence.
source code
 
xGC_skew(seq, window=1000, zoom=100, r=300, px=100, py=100)
Calculates and plots normal and accumulated GC skew (GRAPHICS !!!).
source code
 
molecular_weight(seq)
Calculate the molecular weight of a DNA sequence.
source code
 
nt_search(seq, subseq)
Search for a DNA subseq in sequence.
source code
 
makeTableX(table) source code
 
seq3(seq)
Turn a one letter code protein sequence into one with three letter codes.
source code
 
translate(seq, frame=1, genetic_code=1, translator=None)
Translation of DNA in one of the six different reading frames (DEPRECATED).
source code
 
GC_Frame(seq, genetic_code=1)
Just an alias for six_frame_translations (OBSOLETE).
source code
 
six_frame_translations(seq, genetic_code=1)
Formatted string showing the 6 frame translations and GC content.
source code
 
fasta_uniqids(file)
Checks and changes the name/ID's to be unique identifiers by adding numbers (OBSOLETE).
source code
 
quick_FASTA_reader(file)
Simple FASTA reader, returning a list of string tuples.
source code
 
apply_on_multi_fasta(file, function, *args)
Apply a function on each sequence in a multiple FASTA file (OBSOLETE).
source code
 
quicker_apply_on_multi_fasta(file, function, *args)
Apply a function on each sequence in a multiple FASTA file (OBSOLETE).
source code
Variables [hide private]
  proteinX = ProteinX()
Function Details [hide private]

reverse(seq)

source code 

Reverse the sequence. Works on string sequences.

e.g. >>> reverse("ACGGT") 'TGGCA'

GC(seq)

source code 

Calculates G+C content, returns the percentage (float between 0 and 100).

Copes mixed case seuqneces, and with the ambiguous nucleotide S (G or C) when counting the G and C content. The percentage is calculated against the full length, e.g.:

>>> from Bio.SeqUtils import GC
>>> GC("ACTGN")
40.0

Note that this will return zero for an empty sequence.

GC123(seq)

source code 

Calculates total G+C content plus first, second and third positions.

Returns a tuple of four floats (percentages between 0 and 100) for the entire sequence, and the three codon positions. e.g.

>>> from Bio.SeqUtils import GC123
>>> GC123("ACTGTN")
(40.0, 50.0, 50.0, 0.0)

Copes with mixed case sequences, but does NOT deal with ambiguous nucleotides.

GC_skew(seq, window=100)

source code 

Calculates GC skew (G-C)/(G+C) for multuple windows along the sequence.

Returns a list of ratios (floats), controlled by the length of the sequence and the size of the window.

Does NOT look at any ambiguous nucleotides.

nt_search(seq, subseq)

source code 

Search for a DNA subseq in sequence.

use ambiguous values (like N = A or T or C or G, R = A or G etc.) searches only on forward strand

seq3(seq)

source code 

Turn a one letter code protein sequence into one with three letter codes.

The single input argument 'seq' should be a protein sequence using single letter codes, either as a python string or as a Seq or MutableSeq object.

This function returns the amino acid sequence as a string using the three letter amino acid codes. Output follows the IUPAC standard (including ambiguous characters B for "Asx", J for "Xle" and X for "Xaa", and also U for "Sel" and O for "Pyl") plus "Ter" for a terminator given as an asterisk. Any unknown character (including possible gap characters), is changed into 'Xaa'.

e.g. >>> from Bio.SeqUtils import seq3 >>> seq3("MAIVMGRWKGAR*") 'MetAlaIleValMetGlyArgTrpLysGlyAlaArgTer'

This function was inspired by BioPerl's seq3.

translate(seq, frame=1, genetic_code=1, translator=None)

source code 

Translation of DNA in one of the six different reading frames (DEPRECATED).

Use the Bio.Seq.Translate function, or the Seq object's translate method instead:

>>> from Bio.Seq import Seq
>>> my_seq = Seq("AUGGCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGAUAG")
>>> my_seq = Seq("AUGGCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGAUAGUA")
>>> for frame in [0,1,2] :
...    print my_seq[frame:].translate()
... 
MAIVMGR*KGAR*
WPL*WAAERVPDS
GHCNGPLKGCPIV
>>> for frame in [0,1,2] :
...     print my_seq.reverse_complement()[frame:].translate()
... 
YYRAPFQRPITMA
TIGHPFSGPLQWP
LSGTLSAAHYNGH

GC_Frame(seq, genetic_code=1)

source code 

Just an alias for six_frame_translations (OBSOLETE).

Use six_frame_translation directly, as this function may be deprecated in a future release.

six_frame_translations(seq, genetic_code=1)

source code 

Formatted string showing the 6 frame translations and GC content.

nice looking 6 frame translation with GC content - code from xbbtools similar to DNA Striders six-frame translation

e.g. from Bio.SeqUtils import six_frame_translations print six_frame_translations("AUGGCCAUUGUAAUGGGCCGCUGA")

fasta_uniqids(file)

source code 

Checks and changes the name/ID's to be unique identifiers by adding numbers (OBSOLETE).

file - a FASTA format filename to read in.

No return value, the output is written to screen.

quick_FASTA_reader(file)

source code 

Simple FASTA reader, returning a list of string tuples.

The single argument 'file' should be the filename of a FASTA format file. This function will open and read in the entire file, constructing a list of all the records, each held as a tuple of strings (the sequence name or title, and its sequence).

This function was originally intended for use on large files, where its low overhead makes it very fast. However, because it returns the data as a single in memory list, this can require a lot of RAM on large files.

You are generally encouraged to use Bio.SeqIO.parse(handle, "fasta") which allows you to iterate over the records one by one (avoiding having all the records in memory at once). Using Bio.SeqIO also makes it easy to switch between different input file formats. However, please note that rather than simple strings, Bio.SeqIO uses SeqRecord objects for each record.

apply_on_multi_fasta(file, function, *args)

source code 

Apply a function on each sequence in a multiple FASTA file (OBSOLETE).

file - filename of a FASTA format file function - the function you wish to invoke on each record *args - any extra arguments you want passed to the function

This function will iterate over each record in a FASTA file as SeqRecord objects, calling your function with the record (and supplied args) as arguments.

This function returns a list. For those records where your function returns a value, this is taken as a sequence and used to construct a FASTA format string. If your function never has a return value, this means apply_on_multi_fasta will return an empty list.

quicker_apply_on_multi_fasta(file, function, *args)

source code 

Apply a function on each sequence in a multiple FASTA file (OBSOLETE).

file - filename of a FASTA format file function - the function you wish to invoke on each record *args - any extra arguments you want passed to the function

This function will use quick_FASTA_reader to load every record in the FASTA file into memory as a list of tuples. For each record, it will call your supplied function with the record as a tuple of the name and sequence as strings (plus any supplied args).

This function returns a list. For those records where your function returns a value, this is taken as a sequence and used to construct a FASTA format string. If your function never has a return value, this means quicker_apply_on_multi_fasta will return an empty list.