Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_NNGene.SchemaTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_find_matches
def test_num_matches
def test_find_ambiguous
def test_num_ambiguous
def test_motif_cache
def test_all_unambiguous

Public Attributes

 motif_coder
 match_string
 match_info

Detailed Description

Matching ambiguous motifs with multiple ambiguity characters.

Definition at line 300 of file test_NNGene.py.


Member Function Documentation

Definition at line 303 of file test_NNGene.py.

00303 
00304     def setUp(self):
00305         ambiguity_chars = {"G" : "G",
00306                            "A" : "A",
00307                            "T" : "T",
00308                            "C" : "C",
00309                            "R" : "AG",
00310                            "*" : "AGTC"}
00311 
00312         self.motif_coder = Schema.Schema(ambiguity_chars)
00313 
00314         self.match_string = "GATAG"
00315         self.match_info = [("GA", ["GA"]),
00316                            ("GATAG", ["GATAG"]),
00317                            ("GA*AG", ["GATAG"]),
00318                            ("GATRG", ["GATAG"]),
00319                            ("*A", ["GA", "TA"])]

Return all unambiguous characters that can be in a motif.

Definition at line 378 of file test_NNGene.py.

00378 
00379     def test_all_unambiguous(self):
00380         """Return all unambiguous characters that can be in a motif.
00381         """
00382         found_unambig = self.motif_coder.all_unambiguous()
00383 
00384         expected = ["A", "C", "G", "T"]
00385         assert found_unambig == expected, \
00386                "Got %s, expected %s" % (found_unambig, expected)

Find the positions of ambiguous items in a sequence.

Definition at line 338 of file test_NNGene.py.

00338 
00339     def test_find_ambiguous(self):
00340         """Find the positions of ambiguous items in a sequence.
00341         """
00342         ambig_info = (("GATC", []),
00343                       ("G***", [1, 2, 3]),
00344                       ("GART", [2]),
00345                       ("*R*R", [0, 1, 2, 3]))
00346 
00347         for motif, expected in ambig_info:
00348             found_positions = self.motif_coder.find_ambiguous(motif)
00349             assert found_positions == expected, \
00350                    "Expected %s, got %s for %s" % (expected, found_positions,
00351                                                    motif)
        
Find all matches in a sequence.

Definition at line 320 of file test_NNGene.py.

00320 
00321     def test_find_matches(self):
00322         """Find all matches in a sequence.
00323         """
00324         for motif, expected in self.match_info:
00325             found_matches = self.motif_coder.find_matches(motif,
00326                                                           self.match_string)
00327             assert found_matches == expected, "Expected %s, got %s" \
00328                    % (expected, found_matches)

Make sure motif compiled regular expressions are cached properly.

Definition at line 365 of file test_NNGene.py.

00365 
00366     def test_motif_cache(self):
00367         """Make sure motif compiled regular expressions are cached properly.
00368         """
00369         test_motif = "GATC"
00370 
00371         self.motif_coder.find_matches(test_motif, "GATCGATC")
00372 
00373         self.assertTrue(test_motif in self.motif_coder._motif_cache,
00374                      "Did not find motif cached properly.")
00375 
00376         # make sure we don't bomb out if we use the same motif twice
00377         self.motif_coder.find_matches(test_motif, "GATCGATC")

Find the number of ambiguous items in a sequence.

Definition at line 352 of file test_NNGene.py.

00352 
00353     def test_num_ambiguous(self):
00354         """Find the number of ambiguous items in a sequence.
00355         """
00356         ambig_info = (("GATC", 0),
00357                       ("G***", 3),
00358                       ("GART", 1),
00359                       ("*R*R", 4))
00360 
00361         for motif, expected in ambig_info:
00362             found_num = self.motif_coder.num_ambiguous(motif)
00363             assert found_num == expected, \
00364                    "Expected %s, got %s for %s" % (expected, found_num, motif)

Find how many matches are present in a sequence.

Definition at line 329 of file test_NNGene.py.

00329 
00330     def test_num_matches(self):
00331         """Find how many matches are present in a sequence.
00332         """
00333         for motif, expected in self.match_info:
00334             num_matches = self.motif_coder.num_matches(motif,
00335                                                        self.match_string)
00336             assert num_matches == len(expected), \
00337                    "Expected %s, got %s" % (num_matches, len(expected))


Member Data Documentation

Definition at line 314 of file test_NNGene.py.

Definition at line 313 of file test_NNGene.py.

Definition at line 311 of file test_NNGene.py.


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