[3] | 1 | """ |
---|
| 2 | Tests for `bx.seq.fasta`. |
---|
| 3 | """ |
---|
| 4 | |
---|
| 5 | import unittest |
---|
| 6 | import sys |
---|
| 7 | import os.path |
---|
| 8 | import fasta |
---|
| 9 | |
---|
| 10 | test_fa = "test_data/seq_tests/test.fa" |
---|
| 11 | |
---|
| 12 | # Same sequence data as stored in test.fa |
---|
| 13 | |
---|
| 14 | valid_seq = "TGGAGGCATTTGTGATTCAATAGATGCAGAAAGAAACCTTCCTAGAGCTG" \ |
---|
| 15 | + "GCGTTCTCTAACTAAAAGTGGAAAGTTCTGAGGAATGAGGACTGTTATAA" \ |
---|
| 16 | + "ATCCCACCCCACACCGCACCTTCTCCAGGGAAGTTTCATGGCCGTGAAGA" \ |
---|
| 17 | + "GGACAGAAAGTGAGAACCAAGATggaactgaataaacaagcttcacactg" \ |
---|
| 18 | + "ttagtttccccatatgcttaccttcccacagatgccaaccttggaggcct" \ |
---|
| 19 | + "aagaggcctagaatattatcctttgtctgatcatttctctacaaatttat" \ |
---|
| 20 | + "tgttctttgttaagatgctacataagcccaaattctaaccacccctttga" \ |
---|
| 21 | + "gttacccatcatcaagtttctcccatgtg" |
---|
| 22 | |
---|
| 23 | valid_seq_len = len( valid_seq ) |
---|
| 24 | |
---|
| 25 | class FASTATestCase( unittest.TestCase ): |
---|
| 26 | |
---|
| 27 | def test_get( self ): |
---|
| 28 | fastafile = fasta.FastaFile( file(test_fa, "rb" ) ) |
---|
| 29 | check_get(fastafile, 0, valid_seq_len) |
---|
| 30 | check_get(fastafile, 0, 40) |
---|
| 31 | check_get(fastafile, valid_seq_len - 40, 40) |
---|
| 32 | |
---|
| 33 | def check_get( fastafile, start, len ): |
---|
| 34 | assert fastafile.get( start, len ) == valid_seq[start:start+len] |
---|
| 35 | |
---|
| 36 | test_classes = [ FASTATestCase ] |
---|
| 37 | suite = unittest.TestSuite( [ unittest.makeSuite( c ) for c in test_classes ] ) |
---|