allpy
view allpy/base.py @ 251:9369dbad919d
Incompatible changes to Monomer interfaces.
This branch does not work!
- (!!) only changed allpy._monomer, not uses
- (!!) removed (temporarily) classes for specific monomer types (DNAMonomer, etc)
- refurbished allpy.data.AAcodes to allpy.data.codes with much cleaner
interface
- refurbished allpy._monomer for simplicity and more friendly interface
Now it will (someday) be possible to say:
a = Monomer.from_name("alanine")
b = protein.Monomer.from_code1("a")
c = protein.MonomerType.from_code3("ala")
d = dna.Monomer.from_code3("DA")
but impossible to say:
d = protein.Monomer.from_code3("DA")
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 13 Dec 2010 20:12:11 +0300 |
parents | 6507cd6808c7 |
children | aae821828b03 |
line source
5 """ Sequence of Monomers
7 list of monomer objects
9 Mandatory data:
10 * name -- str with the name of sequence
11 * description -- str with description of the sequence
12 """
13 pass
19 """ Alignment
21 {<Sequence object>:[<Monomer object>,None,<Monomer object>]}
22 keys are the Sequence objects, values are the lists, which
23 contain monomers of those sequences or None for gaps in the
24 corresponding sequence of alignment
25 """
26 # _sequences -- list of Sequence objects. Sequences don't contain gaps
27 # - see sequence.py module
30 """overloaded constructor
32 Alignment() -> new empty Alignment
33 Alignment(sequences, body) -> new Alignment with sequences and
34 body initialized from arguments
35 Alignment(fasta_file) -> new Alignment, read body and sequences
36 from fasta file
38 """
49 """ Returns width, ie length of each sequence with gaps """
53 """ The number of sequences in alignment (it's thickness). """
57 """ Calculate the identity of alignment positions for colouring.
59 For every (row, column) in alignment the percentage of the exactly
60 same residue in the same column in the alignment is calculated.
61 The data structure is just like the Alignment.body, but istead of
62 monomers it contains float percentages.
63 """
64 # Oh, God, that's awful! Absolutely not understandable.
65 # First, calculate percentages of amino acids in every column
81 # Second, map these percentages onto the alignment
95 @staticmethod
97 """ Import data from fasta file
99 monomer_kind is class, inherited from MonomerType
101 >>> import alignment
102 >>> sequences,body=alignment.Alignment.from_fasta(open("test.fasta"))
103 """
122 #if there is description
149 @staticmethod
151 """ Constructs new alignment from sequences
153 Add None's to right end to make equal lengthes of alignment sequences
154 """
164 """ Saves alignment to given file
166 Splits long lines to substrings of length=long_line
167 To prevent this, set long_line=None
168 """
172 """ Simple align ths alignment using sequences (muscle)
174 uses old Monomers and Sequences objects
175 """
200 """ returns list of columns of alignment
202 sequence or sequences:
203 if sequence is given, then column is (original_monomer, monomer)
204 if sequences is given, then column is (original_monomer, {sequence: monomer})
205 if both of them are given, it is an error
206 original (Sequence type):
207 if given, this filters only columns represented by original sequence
208 """
224 """ Returns string representing secondary structure """
230 """ """
231 pass