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

# HG changeset patch
# User boris
# Date 1287947535 -14400
# Node ID db9d116e979f563f11fb1239503702f7ed38e3f6
# Parent 8f1d8ece31afb112736dfcbdb8106121ef2ce05f
documentation improvements

diff -r 8f1d8ece31af -r db9d116e979f geometrical_core/geometrical_core.py
--- a/geometrical_core/geometrical_core.py Sun Oct 24 22:25:36 2010 +0400
+++ b/geometrical_core/geometrical_core.py Sun Oct 24 23:12:15 2010 +0400
@@ -15,9 +15,7 @@
c = config

def f_nng(string):
- """
- Validates nonnegative (>=0) float
- """
+ """ Validates nonnegative (>=0) float """
try:
value = float(string)
except:
@@ -29,9 +27,7 @@
return value

def part(string):
- """
- Validates 0.0 <= float <= 1.0
- """
+ """ Validates 0.0 <= float <= 1.0 """
try:
value = float(string)
except:
@@ -43,9 +39,7 @@
return value

def timeout(string):
- """
- Validates int >= -1
- """
+ """ Validates int >= -1 """
try:
value = int(string)
except:
@@ -57,9 +51,7 @@
return value

def pos(string):
- """
- Validates positive integer
- """
+ """ Validates positive integer """
try:
value = int(string)
except:
@@ -71,9 +63,7 @@
return value

def i_nng(string):
- """
- Validates int >= 0
- """
+ """ Validates int >= 0 """
try:
value = int(string)
except:
diff -r 8f1d8ece31af -r db9d116e979f lib/allpy_pdb.py
--- a/lib/allpy_pdb.py Sun Oct 24 22:25:36 2010 +0400
+++ b/lib/allpy_pdb.py Sun Oct 24 23:12:15 2010 +0400
@@ -1,8 +1,7 @@

import re

-"""
-Functions to get pdb information from fasta id
+""" Functions to get pdb information from fasta id
and to generate fasta id from pdb information

pdb information: code, chain, model
diff -r 8f1d8ece31af -r db9d116e979f lib/block.py
--- a/lib/block.py Sun Oct 24 22:25:36 2010 +0400
+++ b/lib/block.py Sun Oct 24 23:12:15 2010 +0400
@@ -10,7 +10,8 @@
from Bio.PDB import Superimposer

class Block(object):
- """
+ """ Block of alignment
+
Mandatory data:
* self.project -- project object, which the block belongs to
* self.sequences - set of sequence objects that contain monomers
@@ -28,8 +29,8 @@
"""

def __init__(self, project, sequences=None, positions=None):
- """
- Builds new block from project
+ """ Builds new block from project
+
if sequences==None, all sequences are used
if positions==None, all positions are used
"""
diff -r 8f1d8ece31af -r db9d116e979f lib/graph.py
--- a/lib/graph.py Sun Oct 24 22:25:36 2010 +0400
+++ b/lib/graph.py Sun Oct 24 23:12:15 2010 +0400
@@ -9,7 +9,8 @@


class Graph(object):
- """
+ """ Undirected weighted graph
+
Data:
nodes -- set of elements
lines -- {line: cost}.
@@ -56,22 +57,16 @@
return k1 == k2 or Graph.line(k1, k2) in self.lines

def count_one(self, node):
- """
- Returns number of connections of this node
- """
+ """ Returns number of connections of this node """
return len([node1 for node1 in self.nodes if self.bounded(node, node1)]) - 1

def cost_one(self, node):
- """
- Returns sum of costs of all connections of this node
- """
+ """ Returns sum of costs of all connections of this node """
return sum([self.lines.get(Graph.line(node, node1), 0)
for node1 in self.nodes if node != node1])

def count_all(self):
- """
- Returns {node: number of connections of this node}
- """
+ """ Returns {node: number of connections of this node} """
c = dict([(node, 0) for node in self.nodes])
for line in self.lines:
for node in line:
@@ -80,16 +75,14 @@


def drop_node(self, node):
- """
- Remove node and all involved lines
- """
+ """ Remove node and all involved lines """
for node1 in self.nodes:
self.lines.pop(Graph.line(node, node1), None)
self.nodes.discard(node)

def add_node(self, node, parent_graph):
- """
- Add node and corresponding lines from parent_graph
+ """ Add node and corresponding lines from parent_graph
+
Added lines should be contained in self graph
(takes care of hanging lines)
"""
@@ -100,8 +93,7 @@
self.lines[line] = parent_graph.lines[line]

def drop_nodes(self, nodes):
- """
- Run drop_node for each of given nodes
+ """ Run drop_node for each of given nodes
Returns if nodes was not empty (ugly beauty)
"""
for node in nodes:
@@ -109,16 +101,15 @@
return bool(nodes)

def drop_if_count(self, minsize):
- """
- Run drop_node for each node, that has less than minsize lines
- """
+ """ Run drop_node for each node, that has less than minsize lines """
while True:
if not self.drop_nodes([node for (node, count)
in self.count_all().items() if count < minsize]):
break

def bron_kerbosh(self, timeout=-1, minsize=1):
- """
+ """ Bron and Kerboch algorithm implementation
+
returns list of cliques
clique is frozenset
if timeout=-1, it means infinity
@@ -217,8 +208,8 @@


def fast_cliques(self, minsize=1):
- """
- returns list of cliques
+ """ returns list of cliques
+
clique is frozenset
"""
print 'Fast algorithm started'
@@ -270,8 +261,8 @@


def cliques(self, timeout=-1, minsize=1):
- """
- returns length-sorted list of cliques
+ """ returns length-sorted list of cliques
+
clique is frozenset

can change self!
diff -r 8f1d8ece31af -r db9d116e979f lib/monomer.py
--- a/lib/monomer.py Sun Oct 24 22:25:36 2010 +0400
+++ b/lib/monomer.py Sun Oct 24 23:12:15 2010 +0400
@@ -9,8 +9,8 @@


class MonomerType(object):
- """
- Monomer type
+ """ Monomer type
+
name -- string like "Valine"
code1 -- one-letter code (in upper case)
code3 -- three-letter code (in upper case)
@@ -45,7 +45,8 @@


class Monomer(object):
- """
+ """ Monomer
+
type -- link to MonomerType object
pdb_residues -- dictionary like {Bio.PDB.Chain: Bio.PDB.Residue}
"""
@@ -76,9 +77,7 @@


class AminoAcid(Monomer):
- """
- Amino acid
- """
+ """ Amino acid """
pass


diff -r 8f1d8ece31af -r db9d116e979f lib/project.py
--- a/lib/project.py Sun Oct 24 22:25:36 2010 +0400
+++ b/lib/project.py Sun Oct 24 23:12:15 2010 +0400
@@ -18,7 +18,8 @@
Block = block.Block

class Project(object):
- """
+ """ Alignment representing class
+
Mandatory data:
* sequences -- list of Sequence objects. Sequences don't contain gaps
- see sequence.py module
@@ -53,8 +54,7 @@
return max([len(line) for line in self.alignment.values()])

def thickness(self):
- """ The number of sequences in alignment (it's thickness).
- """
+ """ The number of sequences in alignment (it's thickness). """
return len(self.alignment)

def calc_identity(self):
@@ -98,7 +98,10 @@

@staticmethod
def from_fasta(file, monomer_kind=AminoAcidType):
- """
+ """ Import data from fasta file
+
+ monomer_kind is class, inherited from MonomerType
+
>>> import project
>>> sequences,alignment=project.Project.from_fasta(open("test.fasta"))
"""
@@ -150,9 +153,9 @@

@staticmethod
def from_sequences(*sequences):
- """
- Constructs new alignment from sequences
- Add gaps to right end to make equal lengthes of alignment sequences
+ """ Constructs new alignment from sequences
+
+ Add None's to right end to make equal lengthes of alignment sequences
"""
project = Project()
project.sequences = sequences
@@ -163,16 +166,16 @@
return project

def save_fasta(self, out_file, long_line=60, gap='-'):
- """
- Saves alignment to given file
+ """ Saves alignment to given file
+
Splits long lines to substrings of length=long_line
To prevent this, set long_line=None
"""
Block(self).save_fasta(out_file, long_line=long_line, gap=gap)

def muscle_align(self):
- """
- Simple align ths alignment using sequences (muscle)
+ """ Simple align ths alignment using sequences (muscle)
+
uses old Monomers and Sequences objects
"""
tmp_file, tmp_filename = mkstemp()
@@ -200,8 +203,8 @@
self.alignment[sequence].append(old_monomer)

def column(self, sequence=None, sequences=None, original=None):
- """
- returns list of columns of alignment
+ """ returns list of columns of alignment
+
sequence or sequences:
if sequence is given, then column is (original_monomer, monomer)
if sequences is given, then column is (original_monomer, {sequence: monomer})
@@ -224,8 +227,7 @@
dict([(s, column[indexes[s]]) for s in sequences]))

def pdb_auto_add(self, conformity_file=None):
- """
- Adds pdb information to each sequence
+ """ Adds pdb information to each sequence

TODO: conformity_file
"""
diff -r 8f1d8ece31af -r db9d116e979f lib/sequence.py
--- a/lib/sequence.py Sun Oct 24 22:25:36 2010 +0400
+++ b/lib/sequence.py Sun Oct 24 23:12:15 2010 +0400
@@ -11,7 +11,8 @@
cappbuilder = CaPPBuilder()

class Sequence(object):
- """
+ """ Sequence of Monomers
+
Mandatory data:
* name -- str with the name of sequence
* description -- str with description of the sequence
@@ -42,8 +43,8 @@
return not (self == other)

def pdb_chain_add(self, pdb_file, pdb_id, pdb_chain, pdb_model=0):
- """
- Reads Pdb chain from file
+ """ Reads Pdb chain from file
+
and align each Monomer with PDB.Residue (TODO)
"""
name = std_id(pdb_id, pdb_chain, pdb_model)
@@ -65,9 +66,9 @@

@staticmethod
def from_pdb_chain(chain):
- """
+ """ returns Sequence with Monomers with link to Bio.PDB.Residue
+
chain is Bio.PDB.Chain
- returns Sequence with Monomers with link to Bio.PDB.Residue
"""
peptide = cappbuilder.build_peptides(chain)[0]
sequence = Sequence()
@@ -80,10 +81,9 @@
return sequence

def pdb_auto_add(self, conformity_info=None):
- """
- Adds pdb information to each monomer
+ """ Adds pdb information to each monomer
+
Returns if information has been successfully added
-
TODO: conformity_file
"""
if not conformity_info: