Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/835efa2a8c71/test/usecase1.py
Дата изменения: Unknown
Дата индексирования: Mon Feb 4 05:38:12 2013
Кодировка:
allpy: 835efa2a8c71 test/usecase1.py

allpy

view test/usecase1.py @ 817:835efa2a8c71

optimization of rasmol_homology: keep structure loaded of two sequences only One of steps of this program is superimposition of all sequences with main sequence and saving of all structures to pdb file. Loaded structure of all sequences is not needed to do this. At every moment only structure of main sequence and of superimposing sequence. This optimization results in essential memory saving. Output files should be the same to previous revision. To implement this optimization methods supeimpose and save_pdb of alignment were replaced with methods with same names of sequence. So some code is same as code of methods of alignment. Note: behaves as before, with superimpose and save_pdb methods of alignment. Model was returned by these methods but never used while generating spt script. This can result in collisions of rasmol selections when number of sequences is greater than max number of chains of one model.
author boris (kodomo) <bnagaev@gmail.com>
date Fri, 15 Jul 2011 02:23:27 +0400
parents 07b5351b0b56
children ddf85d0a8924
line source
1 import sys
2 from allpy import protein
3 from allpy import processors
5 # Create sequences from string representation of sequence body
6 sequence_1 = protein.Sequence.from_string("mkstf", name="E2E4")
7 sequence_2 = protein.Sequence.from_string("mstkfff", description="Longer sequence")
9 # Create alignment from sequences
10 alignment = protein.Alignment()
11 alignment.append_sequence(sequence_1)
12 alignment.append_sequence(sequence_2)
13 alignment.realign(processors.Muscle())
15 # For each sequence, print number of gaps and non-gaps in alignment
16 for row in alignment.rows():
17 gaps = 0
18 monomers = 0
19 for column in alignment.columns:
20 if column in row:
21 monomers += 1
22 else:
23 gaps += 1
24 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
26 # Print number of gaps in each column
27 gaps = []
28 for column in alignment.columns:
29 column_gaps = 0
30 for sequence in alignment.sequences:
31 if sequence not in column:
32 column_gaps += 1
33 gaps.append(column_gaps)
34 print " ".join(map(str, gaps))
36 # Write alignment to file
37 alignment.to_file(sys.stdout)