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

allpy

view test/usecase1.py @ 488:81220300eef2

blocks3d-wt debianization: fixed urls for various resources (js & css)
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Sun, 20 Feb 2011 22:19:16 +0300
parents 0435d9cc18d3
children 07b5351b0b56
line source
1 from allpy import protein
2 from allpy import processors
4 # Create sequences from string representation of sequence body
5 sequence_1 = protein.Sequence.from_string("mkstf", name="E2E4")
6 sequence_2 = protein.Sequence.from_string("mstkfff", description="Longer sequence")
8 # Create alignment from sequences
9 alignment = protein.Alignment()
10 alignment.append_sequence(sequence_1)
11 alignment.append_sequence(sequence_2)
12 alignment.process(processors.Muscle())
14 # For each sequence, print number of gaps and non-gaps in alignment
15 for row in alignment.rows():
16 gaps = 0
17 monomers = 0
18 for column in alignment.columns:
19 if column in row:
20 monomers += 1
21 else:
22 gaps += 1
23 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
25 # Print number of gaps in each column
26 gaps = []
27 for column in alignment.columns:
28 column_gaps = 0
29 for sequence in alignment.sequences:
30 if sequence not in column:
31 column_gaps += 1
32 gaps.append(column_gaps)
33 print " ".join(map(str, gaps))
35 # Write alignment to file
36 alignment.to_file(open("new_file.fasta", "w"))