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

allpy

view lib/sequence.py @ 98:3d40d7b9a123

lib::project::muscle_align project::save_fasta sequence::operator== fixes test -- alignment done
author boris <bnagaev@gmail.com>
date Wed, 20 Oct 2010 23:33:29 +0400
parents a2f3926f5077
children 5091fef2ad88
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 pdb_chain_add(self, pdb_file, pdb_id, pdb_chain, pdb_model=0):
36 """
37 Reads Pdb chain from file
38 and align each Monomer with PDB.Residue (TODO)
39 """
40 name = Pdb.std_id(pdb_id, pdb_chain, pdb_model)
41 self.pdb_chain = PDBParser().get_structure(name, pdb_file)[pdb_model][pdb_chain]
42 peptide = cappbuilder.build_peptides(self.pdb_chain)
43 sequence = str(peptide[0].get_sequence()) # TRU?
44 print sequence
45 # FIXME: align and map