| Trees | Indices | Help |
|
|---|
|
|
Miscellaneous functions for dealing with sequences.
|
|||
| |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
_THREECODE =
|
|||
|
|||
Calculates G+C content, returns the percentage (float between 0 and 100).
Copes mixed case sequences, 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.
|
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.
|
Calculates GC skew (G-C)/(G+C) for multiple 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. |
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 |
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'
You can set a custom translation of the codon termination code using the
"custom_map" argument, e.g.
>>> seq3("MAIVMGRWKGAR*", custom_map={"*": "***"})
'MetAlaIleValMetGlyArgTrpLysGlyAlaArg***'
You can also set a custom translation for non-amino acid characters, such
as '-', using the "undef_code" argument, e.g.
>>> seq3("MAIVMGRWKGA--R*", undef_code='---')
'MetAlaIleValMetGlyArgTrpLysGlyAla------ArgTer'
If not given, "undef_code" defaults to "Xaa", e.g.
>>> seq3("MAIVMGRWKGA--R*")
'MetAlaIleValMetGlyArgTrpLysGlyAlaXaaXaaArgTer'
This function was inspired by BioPerl's seq3.
|
Turns a three-letter code protein sequence into one with single letter codes.
The single input argument 'seq' should be a protein sequence using three-
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 one
letter amino acid codes. Output follows the IUPAC standard (including
ambiguous characters "B" for "Asx", "J" for "Xle", "X" for "Xaa", "U" for
"Sel", and "O" for "Pyl") plus "*" for a terminator given the "Ter" code.
Any unknown character (including possible gap characters), is changed into
'-'.
e.g.
>>> from Bio.SeqUtils import seq3
>>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAlaArgTer")
'MAIVMGRWKGAR*'
The input is case insensitive, e.g.
>>> from Bio.SeqUtils import seq3
>>> seq1("METalaIlEValMetGLYArgtRplysGlyAlaARGTer")
'MAIVMGRWKGAR*'
You can set a custom translation of the codon termination code using the
"custom_map" argument, e.g.
>>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAlaArg***", custom_map={"***": "*"})
'MAIVMGRWKGAR*'
You can also set a custom translation for non-amino acid characters, such
as '-', using the "undef_code" argument, e.g.
>>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAla------ArgTer", undef_code='?')
'MAIVMGRWKGA??R*'
If not given, "undef_code" defaults to "X", e.g.
>>> seq1("MetAlaIleValMetGlyArgTrpLysGlyAla------ArgTer")
'MAIVMGRWKGAXXR*'
|
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
>>> from Bio.SeqUtils import six_frame_translations
>>> print six_frame_translations("AUGGCCAUUGUAAUGGGCCGCUGA")
GC_Frame: a:5 t:0 g:8 c:5
Sequence: auggccauug ... gggccgcuga, 24 nt, 54.17 %GC
<BLANKLINE>
<BLANKLINE>
1/1
G H C N G P L
W P L * W A A
M A I V M G R *
auggccauuguaaugggccgcuga 54 %
uaccgguaacauuacccggcgacu
A M T I P R Q
H G N Y H A A S
P W Q L P G S
<BLANKLINE>
<BLANKLINE>
|
Simple FASTA reader, returning a list of string tuples (OBSOLETE).
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).
>>> seqs = quick_FASTA_reader("Fasta/dups.fasta")
>>> for title, sequence in seqs:
... print title, sequence
alpha ACGTA
beta CGTC
gamma CCGCC
alpha (again - this is a duplicate entry to test the indexing code) ACGTA
delta CGCGC
This function was is fast, but because it returns the data as a single in
memory list, is unsuitable for large files where an iterator approach is
preferable.
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.
If you want to use simple strings, use the function SimpleFastaParser
added to Bio.SeqIO.FastaIO in Biopython 1.61 instead.
|
|
|||
_THREECODE
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Feb 5 17:59:48 2013 | http://epydoc.sourceforge.net |