Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.NeuralNetwork.Gene.Schema.SchemaCoder Class Reference

List of all members.

Public Member Functions

def __init__
def representation

Private Attributes

 _schemas
 _converter

Detailed Description

Convert a sequence into a representation of ambiguous motifs (schemas).

This takes a sequence, and returns the number of times specified
motifs are found in the sequence. This lets you represent a sequence
as just a count of (possibly ambiguous) motifs.

Definition at line 477 of file Schema.py.


Constructor & Destructor Documentation

def Bio.NeuralNetwork.Gene.Schema.SchemaCoder.__init__ (   self,
  schemas,
  ambiguous_converter 
)
Initialize the coder to convert sequences

Arguments:

o schema - A list of all of the schemas we want to search for
in input sequences.

o ambiguous_converter - An Schema class which can be
used to convert motifs into regular expressions for searching.

Definition at line 484 of file Schema.py.

00484 
00485     def __init__(self, schemas, ambiguous_converter):
00486         """Initialize the coder to convert sequences
00487 
00488         Arguments:
00489 
00490         o schema - A list of all of the schemas we want to search for
00491         in input sequences.
00492 
00493         o ambiguous_converter - An Schema class which can be
00494         used to convert motifs into regular expressions for searching.
00495         """
00496         self._schemas = schemas
00497         self._converter = ambiguous_converter

Here is the caller graph for this function:


Member Function Documentation

Represent the given input sequence as a bunch of motif counts.

Arguments:

o sequence - A Bio.Seq object we are going to represent as schemas.

This takes the sequence, searches for the motifs within it, and then
returns counts specifying the relative number of times each motifs
was found. The frequencies are in the order the original motifs were
passed into the initializer.

Definition at line 498 of file Schema.py.

00498 
00499     def representation(self, sequence):
00500         """Represent the given input sequence as a bunch of motif counts.
00501 
00502         Arguments:
00503 
00504         o sequence - A Bio.Seq object we are going to represent as schemas.
00505 
00506         This takes the sequence, searches for the motifs within it, and then
00507         returns counts specifying the relative number of times each motifs
00508         was found. The frequencies are in the order the original motifs were
00509         passed into the initializer.
00510         """
00511         schema_counts = []
00512 
00513         for schema in self._schemas:
00514             num_counts = self._converter.num_matches(schema, sequence.tostring())
00515             schema_counts.append(num_counts)
00516 
00517         # normalize the counts to go between zero and one
00518         min_count = 0
00519         max_count = max(schema_counts)
00520 
00521         # only normalize if we've actually found something, otherwise
00522         # we'll just return 0 for everything
00523         if max_count > 0:
00524             for count_num in range(len(schema_counts)):
00525                 schema_counts[count_num] = (float(schema_counts[count_num]) -
00526                                            float(min_count)) / float(max_count)
00527 
00528         return schema_counts


Member Data Documentation

Definition at line 496 of file Schema.py.

Definition at line 495 of file Schema.py.


The documentation for this class was generated from the following file: