Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/5091fef2ad88/lib/sequence.py
Дата изменения: Unknown
Дата индексирования: Mon Feb 4 02:17:40 2013
Кодировка:
allpy: 5091fef2ad88 lib/sequence.py

allpy

view lib/sequence.py @ 101:5091fef2ad88

lib::MonomerType operator== consider only one letter code align -- additional check of monomer equality fix bug with missing __ne__ where __eq__ present
author boris <bnagaev@gmail.com>
date Thu, 21 Oct 2010 00:39:57 +0400
parents 3d40d7b9a123
children 7a87d55efc17 6e2152b2f286
line source
1 #!/usr/bin/python
2 import monomer
3 from Bio.PDB import PDBParser, CaPPBuilder
4 from Bio.Seq import Seq
5 from allpy_pdb import Pdb
7 cappbuilder = CaPPBuilder()
9 class Sequence(object):
10 """
11 Mandatory data:
12 * name -- str with the name of sequence
13 * description -- str with description of the sequence
14 * monomers -- list of monomer objects (aminoacids or nucleotides)
15 * pdb_chain -- list of Bio.PDB.Chain's
17 TODO: class Protein: container of multiple Sequences,
18 class ProteinMononer: container of multiple Monomers
19 """
20 def __init__(self, name, monomers, description=""):
21 self.name = name
22 self.description = description
23 self.monomers = monomers
25 def __len__(self):
26 return len(self.monomers)
28 def __str__(self):
29 return ''.join([monomer.monomer_type.code1 for monomer in self.monomers])
31 def __eq__(self, other):
32 return len(self) == len(other) and \
33 all([a==b for a, b in zip(self.monomers, other.monomers)])
35 def __ne__(self, other):
36 return not (self == other)
38 def pdb_chain_add(self, pdb_file, pdb_id, pdb_chain, pdb_model=0):
39 """
40 Reads Pdb chain from file
41 and align each Monomer with PDB.Residue (TODO)
42 """
43 name = Pdb.std_id(pdb_id, pdb_chain, pdb_model)
44 self.pdb_chain = PDBParser().get_structure(name, pdb_file)[pdb_model][pdb_chain]
45 peptide = cappbuilder.build_peptides(self.pdb_chain)
46 sequence = str(peptide[0].get_sequence()) # TRU?
47 print sequence
48 # FIXME: align and map