view test/usecase1.py @ 326:01547d8d5c36
save_fasta: always prepend space before description, even if no name is given
author |
Daniil Alexeyevsky <me.dendik@gmail.com> |
date |
Fri, 17 Dec 2010 00:57:35 +0300 |
parents |
|
children |
0435d9cc18d3 |
line source
1 from allpy import protein
3 # Create sequences from string representation of sequence body
4 sequence_1 = allpy.protein.Sequence.from_string("mkstf", name="E2E4")
5 sequence_2 = allpy.protein.Sequence.from_string("mstkfff")
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():
17 for column in alignment.columns:
22 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
24 # Print number of gaps in each column
26 for column in alignment.columns:
28 for sequence in alignment.sequences:
29 if sequence not in column:
31 gaps.append(column_gaps)
32 print " ".join(map(str, gaps))
34 # Write alignment to file
35 alingment.to_fasta(open("new_file.fasta", "w"))