Package BioSQL :: Module BioSeq :: Class DBSeq
[hide private]
[frames] | no frames]

Class DBSeq

source code

 object --+    
          |    
Bio.Seq.Seq --+
              |
             DBSeq

BioSQL equivalent of the Biopython Seq object.

Instance Methods [hide private]
 
__init__(self, primary_id, adaptor, alphabet, start, length)
Create a new DBSeq object referring to a BioSQL entry.
source code
 
__len__(self)
Returns the length of the sequence, use len(my_seq).
source code
 
__getitem__(self, index)
Returns a subsequence of single letter, use my_seq[index].
source code
 
tostring(self)
Returns the full sequence as a python string (DEPRECATED).
source code
 
__str__(self)
Returns the full sequence as a python string.
source code
 
toseq(self)
Returns the full sequence as a Seq object.
source code
 
__add__(self, other)
Add another sequence or string to this sequence.
source code
 
__radd__(self, other)
Adding a sequence on the left.
source code

Inherited from Bio.Seq.Seq: __contains__, __eq__, __hash__, __le__, __lt__, __ne__, __repr__, back_transcribe, complement, count, endswith, find, lower, lstrip, reverse_complement, rfind, rsplit, rstrip, split, startswith, strip, tomutable, transcribe, translate, ungap, upper

Inherited from Bio.Seq.Seq (private): _get_seq_str_and_check_alphabet

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  data
Sequence as string (DEPRECATED)

Inherited from object: __class__

Method Details [hide private]

__init__(self, primary_id, adaptor, alphabet, start, length)
(Constructor)

source code 
Create a new DBSeq object referring to a BioSQL entry.

You wouldn't normally create a DBSeq object yourself, this is done
for you when retreiving a DBSeqRecord object from the database.

Overrides: object.__init__

__len__(self)
(Length operator)

source code 
Returns the length of the sequence, use len(my_seq).
Overrides: Bio.Seq.Seq.__len__
(inherited documentation)

__getitem__(self, index)
(Indexing operator)

source code 
Returns a subsequence of single letter, use my_seq[index].
Overrides: Bio.Seq.Seq.__getitem__
(inherited documentation)

tostring(self)

source code 
Returns the full sequence as a python string (DEPRECATED).

You are now encouraged to use str(my_seq) instead of
my_seq.tostring().

Overrides: Bio.Seq.Seq.tostring

__str__(self)
(Informal representation operator)

source code 
Returns the full sequence as a python string.

Overrides: object.__str__

__add__(self, other)
(Addition operator)

source code 

Add another sequence or string to this sequence.

If adding a string to a Seq, the alphabet is preserved:

>>> from Bio.Seq import Seq
>>> from Bio.Alphabet import generic_protein
>>> Seq("MELKI", generic_protein) + "LV"
Seq('MELKILV', ProteinAlphabet())

When adding two Seq (like) objects, the alphabets are important. Consider this example:

>>> from Bio.Seq import Seq
>>> from Bio.Alphabet.IUPAC import unambiguous_dna, ambiguous_dna
>>> unamb_dna_seq = Seq("ACGT", unambiguous_dna)
>>> ambig_dna_seq = Seq("ACRGT", ambiguous_dna)
>>> unamb_dna_seq
Seq('ACGT', IUPACUnambiguousDNA())
>>> ambig_dna_seq
Seq('ACRGT', IUPACAmbiguousDNA())

If we add the ambiguous and unambiguous IUPAC DNA alphabets, we get the more general ambiguous IUPAC DNA alphabet:

>>> unamb_dna_seq + ambig_dna_seq
Seq('ACGTACRGT', IUPACAmbiguousDNA())

However, if the default generic alphabet is included, the result is a generic alphabet:

>>> Seq("") + ambig_dna_seq
Seq('ACRGT', Alphabet())

You can't add RNA and DNA sequences:

>>> from Bio.Alphabet import generic_dna, generic_rna
>>> Seq("ACGT", generic_dna) + Seq("ACGU", generic_rna)
Traceback (most recent call last):
   ...
TypeError: Incompatible alphabets DNAAlphabet() and RNAAlphabet()

You can't add nucleotide and protein sequences:

>>> from Bio.Alphabet import generic_dna, generic_protein
>>> Seq("ACGT", generic_dna) + Seq("MELKI", generic_protein)
Traceback (most recent call last):
   ...
TypeError: Incompatible alphabets DNAAlphabet() and ProteinAlphabet()
Overrides: Bio.Seq.Seq.__add__
(inherited documentation)

__radd__(self, other)
(Right-side addition operator)

source code 

Adding a sequence on the left.

If adding a string to a Seq, the alphabet is preserved:

>>> from Bio.Seq import Seq
>>> from Bio.Alphabet import generic_protein
>>> "LV" + Seq("MELKI", generic_protein)
Seq('LVMELKI', ProteinAlphabet())

Adding two Seq (like) objects is handled via the __add__ method.

Overrides: Bio.Seq.Seq.__radd__
(inherited documentation)

Property Details [hide private]

data

Sequence as string (DEPRECATED)

Get Method:
tostring(self) - Returns the full sequence as a python string (DEPRECATED).