allpy
view allpy/pdb.py @ 368:57894fcb7792
Block.flush_left() -> Alignment.flush("left"); implemented flushing left, right and center. (see #25)
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Wed, 26 Jan 2011 21:17:01 +0300 |
parents | 3347b5f31477 |
children | d7fc6865ce58 |
line source
1 """ Functions to get pdb information from fasta id
2 and to generate fasta id from pdb information
4 pdb information: code, chain, model
6 TODO: same for local pdb files
7 """
23 # for pdb-codes
24 re1 = re.compile(r"(^|[^a-z0-9])(?P<code>[0-9][0-9a-z]{3})([^a-z0-9](?P<chain>[0-9a-z ]?)(?P<model>[^a-z0-9]([0-9]{1,3}))?)?", re.I)
26 #~ # for files
27 #~ re2 = re.compile(r"(^)([^^]+\.(ent|pdb))([^a-zA-Z0-9]([0-9A-Za-z ]?)([^a-zA-Z0-9]([0-9]{1,3}))?)?$")
52 #~ def std_id_parse(ID):
53 #~ """
54 #~ Parse standart ID to pdb_code, chain and model
55 #~ """
56 #~ if '.ent' in ID.lower() or '.pdb' in ID.lower():
57 #~ # it is file
58 #~ parseO = self.re2.search(ID) # files
59 #~ else:
60 #~ parseO = self.re1.search(ID.lower()) # pdb codes
61 #~ if not parseO:
62 #~ return None
63 #~ parse = parseO.groups()
64 #~ if len(parse) < 2:
65 #~ return None
66 #~ code = parse[1]
67 #~ chain = ''
68 #~ model = None
69 #~ if len(parse) >= 4:
70 #~ chain = parse[3]
71 #~ if chain:
72 #~ chain = chain.upper()
73 #~ if len(parse) >= 6:
74 #~ if parse[5]:
75 #~ model = parse[5]
76 #~ return code, chain, model
79 """Mixin for adding PDB data to a Sequence.
81 Please note: since this is a mixin, no objects of this class should be
82 created. This class is intended to be subclassed together with one of
83 Sequence classes.
85 Attributes:
87 * pdb_chain -- Bio.PDB.Chain
88 * pdb_file -- file object
90 * pdb_residues -- {Monomer: Bio.PDB.Residue}
91 * pdb_secstr -- {Monomer: 'Secondary structure'}
92 Code Secondary structure
93 H alpha-helix
94 B Isolated beta-bridge residue
95 E Strand
96 G 3-10 helix
97 I pi-helix
98 T Turn
99 S Bend
100 - Other
103 ?TODO: global pdb_structures
104 """
113 """ Reads Pdb chain from file
115 and align each Monomer with PDB.Residue (TODO)
116 """
133 """ Delete all pdb-connected links """
134 #~ gc.get_referrers(self.pdb_chains[0])
140 @staticmethod
142 """ Returns Sequence with Monomers with link to Bio.PDB.Residue
144 chain is Bio.PDB.Chain
145 """
161 """ Adds pdb information to each monomer
163 Returns if information has been successfully added
164 TODO: conformity_file
166 id-format lava flow
167 """
191 """ Saves pdb_chain to out_file """
205 """ Add secondary structure data """
229 """Mixin to add 3D properties to alignments.
231 Please note: since this is a mixin, no objects of this class should be
232 created. This class is intended to be subclassed together with one of
233 Alignment classes.
234 """
237 """ Returns string representing secondary structure """
243 """Mixin to add 3D properties to blocks.
245 Please note: since this is a mixin, no objects of this class should be
246 created. This class is intended to be subclassed together with one of
247 Block classes.
248 """
254 """ Returns length-sorted list of blocks, representing GCs
256 * max_delta -- threshold of distance spreading
257 * timeout -- Bron-Kerbosh timeout (then fast O(n ln n) algorithm)
258 * minsize -- min size of each core
259 * ac_new_atoms -- min part or new atoms in new alternative core
260 current GC is compared with each of already selected GCs if
261 difference is less then ac_new_atoms, current GC is skipped
262 difference = part of new atoms in current core
263 * ac_count -- max number of cores (including main core)
264 -1 means infinity
266 If more than one pdb chain for some sequence provided, consider all of them
267 cost is calculated as 1 / (delta + 1)
269 delta in [0, +inf) => cost in (0, 1]
270 """
298 break
301 """ Iterates Ca-atom of monomers of this sequence from this block """
305 """ Iterates pairs (sequence, chain) """
312 """ Superimpose all pdb_chains in this block """
321 # Apply rotation/translation to the moving atoms
325 """ Save all sequences
327 Returns {(sequence, chain): CHAIN}
328 CHAIN is chain letter in new file
329 """
335 # TODO: read from tmp_file.name
336 # change CHAIN
337 # add to out_file
341 # vim: set ts=4 sts=4 sw=4 et: