Logo Search packages:      
Sourcecode: python-biopython version File versions

def Bio::NeuralNetwork::Gene::Schema::SchemaFactory::_get_unique_schema (   self,
  cur_schemas,
  motif_list,
  num_ambiguous 
) [private]

Retrieve a unique schema from a motif.

We don't want to end up with schema that match the same thing,
since this could lead to ambiguous results, and be messy. This
tries to create schema, and checks that they do not match any
currently existing schema.

Definition at line 634 of file Schema.py.

00634                                                                         :
        """Retrieve a unique schema from a motif.

        We don't want to end up with schema that match the same thing,
        since this could lead to ambiguous results, and be messy. This
        tries to create schema, and checks that they do not match any
        currently existing schema.
        """
        # create a schema starting with a random motif
        # we'll keep doing this until we get a completely new schema that
        # doesn't match any old schema
        num_tries = 0
        
        while 1:
            # pick a motif to work from and make a schema from it
            cur_motif = random.choice(motif_list)
            
            num_tries += 1
                
            new_schema, matching_motifs = \
                        self._schema_from_motif(cur_motif, motif_list,
                                                num_ambiguous)

            has_match = 0
            for old_schema in cur_schemas:
                if matches_schema(new_schema, old_schema,
                                  self._ambiguity_symbol):
                    has_match = 1

            # if the schema doesn't match any other schema we've got
            # a good one
            if not(has_match):
                break

            # check for big loops in which we can't find a new schema
            assert num_tries < 150, \
                   "Could not generate schema in %s tries from %s with %s" \
                   % (num_tries, motif_list, cur_schemas)

        return new_schema, matching_motifs

    def _schema_from_motif(self, motif, motif_list, num_ambiguous):


Generated by  Doxygen 1.6.0   Back to index