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
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():
20 for column in alignment.columns:
25 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
27 # Print number of gaps in each column
29 for column in alignment.columns:
31 for sequence in alignment.sequences:
32 if sequence not in column:
34 gaps.append(column_gaps)
35 print " ".join(map(str, gaps))
37 # Write alignment to file
38 alignment.to_file(sys.stdout)