Trees | Indices | Help |
---|
|
object --+ | MutableSeq
An editable sequence object (with an alphabet).
Unlike normal python strings and our basic sequence object (the Seq class) which are immuatable, the MutableSeq lets you edit the sequence in place. However, this means you cannot use a MutableSeq object as a dictionary key.
>>> from Bio.Seq import MutableSeq >>> from Bio.Alphabet import generic_dna >>> my_seq = MutableSeq("ACTCGTCGTCG", generic_dna) >>> my_seq MutableSeq('ACTCGTCGTCG', DNAAlphabet()) >>> my_seq[5] 'T' >>> my_seq[5] = "A" >>> my_seq MutableSeq('ACTCGACGTCG', DNAAlphabet()) >>> my_seq[5] 'A' >>> my_seq[5:8] = "NNN" >>> my_seq MutableSeq('ACTCGNNNTCG', DNAAlphabet()) >>> len(my_seq) 11
Note that the MutableSeq object does not support as many string-like or biological methods as the Seq object.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
Returns a (truncated) representation of the sequence for debugging.
|
Returns the full sequence as a python string. Note that Biopython 1.44 and earlier would give a truncated version of repr(my_seq) for str(my_seq). If you are writing code which needs to be backwards compatible with old Biopython, you should continue to use my_seq.tostring() rather than str(my_seq).
|
Compare the sequence for to another sequence or a string. If compared to another sequence the alphabets must be compatible. Comparing DNA to RNA, or Nucleotide to Protein will raise an exception. Otherwise only the sequence itself is compared, not the precise alphabet. This method indirectly supports ==, < , etc. |
Add another sequence or string to this sequence. Returns a new MutableSeq object. |
Non-overlapping count method, like that of a python string. This behaves like the python string method of the same name, which does a non-overlapping count! Returns an integer, the number of occurrences of substring argument sub in the (sub)sequence given by [start:end]. Optional arguments start and end are interpreted as in slice notation. Arguments:
e.g. >>> from Bio.Seq import MutableSeq >>> my_mseq = MutableSeq("AAAATGA") >>> print my_mseq.count("A") 5 >>> print my_mseq.count("ATG") 1 >>> print my_mseq.count(Seq("AT")) 1 >>> print my_mseq.count("AT", 2, -1) 1 HOWEVER, please note because that python strings, Seq objects and MutableSeq objects do a non-overlapping search, this may not give the answer you expect: >>> "AAAA".count("AA") 2 >>> print MutableSeq("AAAA").count("AA") 2 A non-overlapping search would give the answer as three! |
Modify the mutable sequence to reverse itself. No return value. |
Modify the mutable sequence to take on its complement. Trying to complement a protein sequence raises an exception. No return value. |
Modify the mutable sequence to take on its reverse complement. Trying to reverse complement a protein sequence raises an exception. No return value. |
Returns the full sequence as a python string. Although not formally deprecated, you are now encouraged to use str(my_seq) instead of my_seq.tostring(). Because str(my_seq) will give you the full sequence as a python string, there is often no need to make an explicit conversion. For example, print "ID={%s}, sequence={%s}" % (my_name, my_seq) On Biopython 1.44 or older you would have to have done this: print "ID={%s}, sequence={%s}" % (my_name, my_seq.tostring()) |
Returns the full sequence as a new immutable Seq object. >>> from Bio.Seq import Seq >>> from Bio.Alphabet import IUPAC >>> my_mseq = MutableSeq("MKQHKAMIVALIVICITAVVAAL", IUPAC.protein) >>> my_mseq MutableSeq('MKQHKAMIVALIVICITAVVAAL', IUPACProtein()) >>> my_mseq.toseq() Seq('MKQHKAMIVALIVICITAVVAAL', IUPACProtein()) Note that the alphabet is preserved. |
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Dec 16 11:26:48 2009 | http://epydoc.sourceforge.net |