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

allpy

view test/usecase1.py @ 330:6ad74e2ba3d2

Fixed bug: fasta reader broke on files with Windows EOLs broke
author Daniil Alexeyevsky <me.dendik@gmail.com>
date Fri, 17 Dec 2010 20:54:35 +0300
parents 38888b46c342
children dd94230c6f08
line source
1 from allpy import protein
3 # Create sequences from string representation of sequence body
4 sequence_1 = protein.Sequence.from_string("mkstf", name="E2E4")
5 sequence_2 = protein.Sequence.from_string("mstkfff", description="Longer sequence")
7 # Create alignment from sequences
8 alignment = protein.Alignment()
9 alignment.append_sequence(sequence_1)
10 alignment.append_sequence(sequence_2)
11 alignment.realign("muscle")
13 # For each sequence, print number of gaps and non-gaps in alignment
14 for row in alignment.rows():
15 gaps = 0
16 monomers = 0
17 for column in alignment.columns:
18 if column in row:
19 monomers += 1
20 else:
21 gaps += 1
22 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
24 # Print number of gaps in each column
25 gaps = []
26 for column in alignment.columns:
27 column_gaps = 0
28 for sequence in alignment.sequences:
29 if sequence not in column:
30 column_gaps += 1
31 gaps.append(column_gaps)
32 print " ".join(map(str, gaps))
34 # Write alignment to file
35 alignment.to_fasta(open("new_file.fasta", "w"))