allpy
view allpy/block.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 | fb3164f03984 |
children | d60628e29b24 |
line source
1 #!usr/bin/python
16 """ Block of alignment
18 Mandatory data:
19 * self.alignment -- alignment object, which the block belongs to
20 * self.sequences - set of sequence objects that contain monomers
21 and/or gaps, that constitute the block
22 * self.positions -- list of positions of the alignment.body that
23 are included in the block; position[i+1] is always to the right from position[i]
25 Don't change self.sequences -- it may be a link to other block.sequences
27 How to create a new block:
28 >>> import alignment
29 >>> import block
30 >>> proj = alignment.Alignment(open("test.fasta"))
31 >>> block1 = block.Block(proj)
32 """
35 """ Builds new block from alignment
37 if sequences==None, all sequences are used
38 if positions==None, all positions are used
39 """
49 """ Saves alignment to given file in fasta-format
51 No changes in the names, descriptions or order of the sequences
52 are made.
53 """
64 """ Returns length-sorted list of blocks, representing GCs
66 max_delta -- threshold of distance spreading
67 timeout -- Bron-Kerbosh timeout (then fast O(n ln n) algorithm)
68 minsize -- min size of each core
69 ac_new_atoms -- min part or new atoms in new alternative core
70 current GC is compared with each of already selected GCs
71 if difference is less then ac_new_atoms, current GC is skipped
72 difference = part of new atoms in current core
73 ac_count -- max number of cores (including main core)
74 -1 means infinity
75 If more than one pdb chain for some sequence provided, consider all of them
76 cost is calculated as 1 / (delta + 1)
77 delta in [0, +inf) => cost in (0, 1]
78 """
106 break
110 break
114 """ Returns string consisting of gap chars and chars x at self.positions
116 Length of returning string = length of alignment
117 """
124 """ Save xstring and name in fasta format """
128 """ Iterates monomers of this sequence from this block """
133 """ Iterates Ca-atom of monomers of this sequence from this block """
137 """ Iterates pairs (sequence, chain) """
144 """ Superimpose all pdb_chains in this block """
153 # Apply rotation/translation to the moving atoms
157 """ Save all sequences
159 Returns {(sequence, chain): CHAIN}
160 CHAIN is chain letter in new file
161 """
167 # TODO: read from tmp_file.name
168 # change CHAIN
169 # add to out_file