Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/df571a5233fb/allpy/protein.py
Дата изменения: Unknown
Дата индексирования: Mon Feb 4 04:22:31 2013
Кодировка:
allpy: df571a5233fb allpy/protein.py

allpy

view allpy/protein.py @ 382:df571a5233fb

Changed the way related types are stored for Alignment, Block, Sequence, Monomer Now each of them has attribute 'type', which is an object with four attributes: - Alignment - Block - Sequence - Monomer
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Tue, 01 Feb 2011 23:08:08 +0300
parents 5639138f619a
children 01f9e9c3493e
line source
1 import base
2 import data.codes
4 import protein
6 class Monomer(base.Monomer):
7 """Protein monomers: aminoacids."""
8 type = 'protein'
9 types = protein
10 by_code1 = {}
11 by_code3 = {}
12 by_name = {}
13 Monomer._initialize(data.codes.protein)
15 class Protein(list):
16 """User defined protein; list of protein_sequences."""
17 pass
19 class Sequence(base.Sequence):
20 types = protein
22 class Block(Alignment, base.Block):
23 pass
25 class Alignment(base.Alignment):
26 types = protein
28 def muscle_align(self):
29 """ Simple align ths alignment using sequences (muscle)
31 uses old Monomers and Sequences objects
32 """
33 tmp_file = NamedTemporaryFile(delete=False)
34 self.save_fasta(tmp_file)
35 tmp_file.close()
36 os.system("muscle -in %(tmp)s -out %(tmp)s" % {'tmp': tmp_file.name})
37 sequences, body = Alignment.from_file(open(tmp_file.name))
38 for sequence in self.sequences:
39 try:
40 new_sequence = [i for i in sequences if sequence==i][0]
41 except:
42 raise Exception("Align: Cann't find sequence %s in muscle output" % \
43 sequence.name)
44 old_monomers = iter(sequence.monomers)
45 self.body[sequence] = []
46 for monomer in body[new_sequence]:
47 if not monomer:
48 self.body[sequence].append(monomer)
49 else:
50 old_monomer = old_monomers.next()
51 if monomer != old_monomer:
52 raise Exception("Align: alignment errors")
53 self.body[sequence].append(old_monomer)
54 os.unlink(tmp_file.name)
56 # vim: set ts=4 sts=4 sw=4 et: