view test/usecase1.py @ 642:a1307c0bb030
Added necessary hooks for monomer pickling [closes #35]
Current implementation is lazy and does not store all monomer classes
explicitly in some module. They are still generated on the fly.
Some monomer classes have the same name as per PDB database. In order to avoid
name clashes, we add underscores to classes, if same name class already exists.
WARNING.
This may and WILL cause trouble, if such clashes occur between different types
of monomers, in which case different names will be generated for the same class
depending on the order of loading modules.
The only example of such clash in the current database is dna monomer "0AV" and
rna "A2M", which both have name "2'-O-METHYLADENOSINE 5'-(DIHYDROGEN PHOSPHATE)"
author |
Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
date |
Fri, 03 Jun 2011 16:49:44 +0400 |
parents |
07b5351b0b56 |
children |
ddf85d0a8924 |
line source
2 from allpy import protein
3 from allpy import processors
5 # Create sequences from string representation of sequence body
6 sequence_1 = protein.Sequence.from_string("mkstf", name="E2E4")
7 sequence_2 = protein.Sequence.from_string("mstkfff", description="Longer sequence")
9 # Create alignment from sequences
10 alignment = protein.Alignment()
11 alignment.append_sequence(sequence_1)
12 alignment.append_sequence(sequence_2)
13 alignment.realign(processors.Muscle())
15 # For each sequence, print number of gaps and non-gaps in alignment
16 for row in alignment.rows():
19 for column in alignment.columns:
24 print "%s: %s gaps, %s non-gaps" % (row.sequence.name, gaps, monomers)
26 # Print number of gaps in each column
28 for column in alignment.columns:
30 for sequence in alignment.sequences:
31 if sequence not in column:
33 gaps.append(column_gaps)
34 print " ".join(map(str, gaps))
36 # Write alignment to file
37 alignment.to_file(sys.stdout)