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

allpy

view test/usecase1.py @ 1080:fdc2d3594a3e

allpy.base: Added decency verification function to alignments (closes #98) Currently, the verification function asserts that no two sequences in an alignment have the same identifier.
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Wed, 30 May 2012 12:43:09 +0400
parents af1de9132035
children 08d892230e8c
line source
1 #!/usr/bin/python
2 import sys
3 from allpy import protein
4 from allpy import processors
6 # Create sequences from string representation of sequence body
7 sequence_1 = protein.Sequence.from_string("mkstf", name="E2E4")
8 sequence_2 = protein.Sequence.from_string("mstkfff", description="Longer sequence")
10 # Create alignment from sequences
11 alignment = protein.Alignment()
12 alignment.append_sequence(sequence_1)
13 alignment.append_sequence(sequence_2)
14 alignment.realign(processors.Muscle())
16 # For each sequence, print number of gaps and non-gaps in alignment
17 for row in alignment.rows():
18 gaps = 0
19 monomers = 0
20 for column in alignment.columns:
21 if column in row:
22 monomers += 1
23 else:
24 gaps += 1
25 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
27 # Print number of gaps in each column
28 gaps = []
29 for column in alignment.columns:
30 column_gaps = 0
31 for sequence in alignment.sequences:
32 if sequence not in column:
33 column_gaps += 1
34 gaps.append(column_gaps)
35 print " ".join(map(str, gaps))
37 # Write alignment to file
38 alignment.to_file(sys.stdout)