Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/raw-rev/237deca17963
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 07:26:59 2012
Кодировка:

# HG changeset patch
# User Daniil Alexeyevsky
# Date 1292521362 -10800
# Node ID 237deca179632c4284df36ab098b76dc64b116fa
# Parent 88631907f23daf178438cf9313ab1af0ed6f449d
Converted docstrings and init of base.Block to match our plan

diff -r 88631907f23d -r 237deca17963 allpy/base.py
--- a/allpy/base.py Thu Dec 16 19:24:22 2010 +0300
+++ b/allpy/base.py Thu Dec 16 20:42:42 2010 +0300
@@ -336,43 +336,43 @@
"""
pass

- ## Unclean code follows
+class Block(object):
+ """Block of alignment.

-class Block(object):
- """ Block of alignment
-
- Mandatory data:
-
- * self.alignment -- alignment object, which the block belongs to
- * self.sequences - set of sequence objects that contain monomers
- and/or gaps, that constitute the block
- * self.positions -- list of positions of the alignment.body that
- are included in the block; position[i+1] is always to the right from position[i]
-
- Don't change self.sequences -- it may be a link to other block.sequences
-
- How to create a new block:
-
- >>> import alignment
- >>> import block
- >>> proj = alignment.Alignment(open("test.fasta"))
- >>> block1 = block.Block(proj)
+ Block is intersection of a set of columns & a set of rows. Most of blocks
+ look like rectangular part of alignment if you shuffle alignment rows the
+ right way.
"""

- def __init__(self, alignment, sequences=None, positions=None):
- """ Builds new block from alignment
+ alignment = None
+ """Alignment the block belongs to."""

- if sequences==None, all sequences are used
- if positions==None, all positions are used
+ sequences = ()
+ """List of sequences in block."""
+
+ columns = ()
+ """List of columns in block."""
+
+ def __init__(self, alignment, sequences=None, columns=None):
+ """Build new block from alignment.
+
+ If sequences are not given, the block uses all sequences in alignment.
+
+ If columns are not given, the block uses all columns in alignment.
+
+ In both cases we use exactly the list used in alignment, thus, if new
+ sequences or columns are added to alignment, the block tracks this too.
"""
- if sequences == None:
- sequences = set(alignment.sequences) # copy
- if positions == None:
- positions = range(len(alignment))
+ if sequences is None:
+ sequences = alignment.sequences
+ if colums is None:
+ columns = alignment.columns
self.alignment = alignment
self.sequences = sequences
self.positions = positions

+ ## Unclean code follows
+
def save_fasta(self, out_file, long_line=70, gap='-'):
""" Saves alignment to given file in fasta-format