view allpy/protein.py @ 322:696d314ad718
Added to base.Monomer missing properties: code1, code3, name, is_modified
author |
Daniil Alexeyevsky <me.dendik@gmail.com> |
date |
Fri, 17 Dec 2010 00:35:31 +0300 |
parents |
be9c3cacd009 |
children |
e3bcb9f8d7b0 |
line source
3 class MonomerType(base.MonomerType):
8 class Monomer(base.Monomer):
9 """Protein monomers: aminoacids."""
10 monomer_type = MonomerType
12 MonomerType._initialize('p')
13 MonomerType.instance_type = Monomer
16 """User defined protein; list of protein_sequences."""
19 class Sequence(base.Sequence):
20 monomer_type = Monomer
22 class Alignment(base.Alignment):
23 sequence_type = Sequence
25 def muscle_align(self):
26 """ Simple align ths alignment using sequences (muscle)
28 uses old Monomers and Sequences objects
30 tmp_file = NamedTemporaryFile(delete=False)
31 self.save_fasta(tmp_file)
33 os.system("muscle -in %(tmp)s -out %(tmp)s" % {'tmp': tmp_file.name})
34 sequences, body = Alignment.from_fasta(open(tmp_file.name))
35 for sequence in self.sequences:
37 new_sequence = [i for i in sequences if sequence==i][0]
39 raise Exception("Align: Cann't find sequence %s in muscle output" % \
41 old_monomers = iter(sequence.monomers)
42 self.body[sequence] = []
43 for monomer in body[new_sequence]:
45 self.body[sequence].append(monomer)
47 old_monomer = old_monomers.next()
48 if monomer != old_monomer:
49 raise Exception("Align: alignment errors")
50 self.body[sequence].append(old_monomer)
51 os.unlink(tmp_file.name)
53 class Block(Alignment, base.Block):
56 # vim: set ts=4 sts=4 sw=4 et: