Back to index

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

List of all members.

Public Member Functions

def setUp
def test_get_all
def test_get_random
def test_get_top_percentage
def test_get_top
def test_get_differing
def test_remove_polyA
def test_count

Public Attributes

 motifs
 repository

Detailed Description

Tests for retrieving info from a repository of patterns.

Definition at line 130 of file test_NNGene.py.


Member Function Documentation

Definition at line 133 of file test_NNGene.py.

00133 
00134     def setUp(self):
00135         self.motifs = {"GATC" : 30,
00136                        "GGGG" : 10,
00137                        "GTAG" : 0,
00138                        "AAAA" : -10,
00139                        "ATAT" : -20}
00140 
00141         self.repository = Pattern.PatternRepository(self.motifs)

Retrieve counts for particular patterns in the repository.

Definition at line 209 of file test_NNGene.py.

00209 
00210     def test_count(self):
00211         """Retrieve counts for particular patterns in the repository.
00212         """
00213         num_times = self.repository.count("GGGG")
00214         assert num_times == 10, \
00215                "Did not count item in the respository: %s" % num_times
00216 
00217         num_times = self.repository.count("NOT_IN_THERE")
00218         assert num_times == 0, \
00219                "Counted items not in repository: %s" % num_times
00220 
00221 # --- Tests for motifs

Retrieve all patterns from a repository.

Definition at line 142 of file test_NNGene.py.

00142 
00143     def test_get_all(self):
00144         """Retrieve all patterns from a repository.
00145         """
00146         all_motifs = self.repository.get_all()
00147 
00148         assert all_motifs == ["GATC", "GGGG", "GTAG", "AAAA", "ATAT"], \
00149                "Unexpected motifs returned %s" % all_motifs

Retrieve patterns from both sides of the list (top and bottom).

Definition at line 189 of file test_NNGene.py.

00189 
00190     def test_get_differing(self):
00191         """Retrieve patterns from both sides of the list (top and bottom).
00192         """
00193         patterns = self.repository.get_differing(2, 2)
00194         assert patterns == ["GATC", "GGGG", "AAAA", "ATAT"], \
00195                "Got unexpected patterns %s" % patterns

Retrieve random patterns from the repository.

Definition at line 150 of file test_NNGene.py.

00150 
00151     def test_get_random(self):
00152         """Retrieve random patterns from the repository.
00153         """
00154         for num_patterns in range(5):
00155             patterns = self.repository.get_random(num_patterns)
00156             assert len(patterns) == num_patterns, \
00157                    "Got unexpected number of patterns %s, expected %s" \
00158                    % (len(patterns), num_patterns)
00159 
00160             for pattern in patterns:
00161                 assert pattern in self.motifs.keys(), \
00162                        "Got unexpected pattern %s" % pattern

Retrieve a certain number of the top patterns.

Definition at line 176 of file test_NNGene.py.

00176 
00177     def test_get_top(self):
00178         """Retrieve a certain number of the top patterns.
00179         """
00180         for num_patterns in range(5):
00181             patterns = self.repository.get_top(num_patterns)
00182             assert len(patterns) == num_patterns, \
00183                    "Got unexpected number of patterns %s, expected %s" \
00184                    % (len(patterns), num_patterns)
00185 
00186             for pattern in patterns:
00187                 assert pattern in self.motifs.keys(), \
00188                        "Got unexpected pattern %s" % pattern       

Retrieve the top percentge of patterns from the repository.

Definition at line 163 of file test_NNGene.py.

00163 
00164     def test_get_top_percentage(self):
00165         """Retrieve the top percentge of patterns from the repository.
00166         """
00167         for num_patterns, percentage in ((1, 0.2), (2, .4), (5, 1.0)):
00168             patterns = self.repository.get_top_percentage(percentage)
00169             assert len(patterns) == num_patterns, \
00170                    "Got unexpected number of patterns %s, expected %s" \
00171                    % (len(patterns), num_patterns)
00172 
00173             for pattern in patterns:
00174                 assert pattern in self.motifs.keys(), \
00175                        "Got unexpected pattern %s" % pattern      

Test the ability to remove A rich patterns from the repository.

Definition at line 196 of file test_NNGene.py.

00196 
00197     def test_remove_polyA(self):
00198         """Test the ability to remove A rich patterns from the repository.
00199         """
00200         patterns = self.repository.get_all()
00201         assert len(patterns) == 5, "Unexpected starting: %s" % patterns
00202 
00203         self.repository.remove_polyA()
00204         
00205         patterns = self.repository.get_all()
00206         assert len(patterns) == 3, "Unexpected ending: %s" % patterns
00207         assert patterns == ["GATC", "GGGG", "GTAG"], \
00208                "Unexpected patterns: %s" % patterns


Member Data Documentation

Definition at line 134 of file test_NNGene.py.

Definition at line 140 of file test_NNGene.py.


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