allpy
view lib/alignment.py @ 190:08494fb2c47a
repeats: visitors for visiting tree items (almost) completed
(tree from 10 Nov 2010 of
https://docs1.google.com/document/d/1-7kCo7cdYTpHOtPXGMdSG9wxoXh6sIvrNyYyZuCKECs/edit?hl=en#)
author | boris (netbook) <bnagaev@gmail.com> |
---|---|
date | Thu, 18 Nov 2010 00:01:07 +0300 |
parents | e4f3a2022b08 |
children |
line source
1 #!/usr/bin/python
3 """
4 "I will not use abbrev."
5 "I will always finish what I st"
6 - Bart Simpson
8 """
19 """ Alignment
21 Mandatory data:
22 * body -- dict
23 {<Sequence object>:[<Monomer object>,None,<Monomer object>]}
24 keys are the Sequence objects, values are the lists, which
25 contain monomers of those sequences or None for gaps in the
26 corresponding sequence of
27 alignment
29 """
30 # _sequences -- list of Sequence objects. Sequences don't contain gaps
31 # - see sequence.py module
34 """overloaded constructor
36 Alignment() -> new empty Alignment
37 Alignment(sequences, body) -> new Alignment with sequences and
38 body initialized from arguments
39 Alignment(fasta_file) -> new Alignment, read body and sequences
40 from fasta file
42 """
53 """ Returns width, ie length of each sequence with gaps """
57 """ The number of sequences in alignment (it's thickness). """
61 """ Calculate the identity of alignment positions for colouring.
63 For every (row, column) in alignment the percentage of the exactly
64 same residue in the same column in the alignment is calculated.
65 The data structure is just like the Alignment.body, but istead of
66 monomers it contains float percentages.
67 """
68 # Oh, God, that's awful! Absolutely not understandable.
69 # First, calculate percentages of amino acids in every column
85 # Second, map these percentages onto the alignment
99 @staticmethod
101 """ Import data from fasta file
103 monomer_kind is class, inherited from MonomerType
105 >>> import alignment
106 >>> sequences,body=alignment.Alignment.from_fasta(open("test.fasta"))
107 """
126 #if there is description
154 @staticmethod
156 """ Constructs new alignment from sequences
158 Add None's to right end to make equal lengthes of alignment sequences
159 """
169 """ Saves alignment to given file
171 Splits long lines to substrings of length=long_line
172 To prevent this, set long_line=None
173 """
177 """ Simple align ths alignment using sequences (muscle)
179 uses old Monomers and Sequences objects
180 """
206 """ returns list of columns of alignment
208 sequence or sequences:
209 if sequence is given, then column is (original_monomer, monomer)
210 if sequences is given, then column is (original_monomer, {sequence: monomer})
211 if both of them are given, it is an error
212 original (Sequence type):
213 if given, this filters only columns represented by original sequence
214 """
231 """ Returns string representing secondary structure """
238 """ Save secondary structure and name in fasta format """