root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/bx/seq/nib_tests.py

リビジョン 3, 1.7 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Tests for `bx.seq.nib`.
3"""
4
5import unittest
6import sys
7import os.path
8import nib
9
10test_nib = "test_data/seq_tests/test.nib"
11
12# Same sequence data as stored in test.nib
13
14valid_seq = "TGGAGGCATTTGTGATTCAATAGATGCAGAAAGAAACCTTCCTAGAGCTG" \
15          + "GCGTTCTCTAACTAAAAGTGGAAAGTTCTGAGGAATGAGGACTGTTATAA" \
16          + "ATCCCACCCCACACCGCACCTTCTCCAGGGAAGTTTCATGGCCGTGAAGA" \
17          + "GGACAGAAAGTGAGAACCAAGATggaactgaataaacaagcttcacactg" \
18          + "ttagtttccccatatgcttaccttcccacagatgccaaccttggaggcct" \
19          + "aagaggcctagaatattatcctttgtctgatcatttctctacaaatttat" \
20          + "tgttctttgttaagatgctacataagcccaaattctaaccacccctttga" \
21          + "gttacccatcatcaagtttctcccatgtg"
22
23valid_seq_len = len( valid_seq )
24
25class NIBTestCase( unittest.TestCase ):
26
27    def test_get( self ):
28        nibfile = nib.NibFile( file( test_nib ) )
29        # Try all combinations of even / odd boundaries
30        check_get( nibfile, 0, 10 )
31        check_get( nibfile, 1, 10 )
32        check_get( nibfile, 0, 11 )
33        check_get( nibfile, 1, 11 )
34        # Test near end of file also
35        check_get( nibfile, valid_seq_len - 10, 10 )
36        check_get( nibfile, valid_seq_len - 11, 11 )
37        # Test really short gets
38        check_get( nibfile, 0, 0 )
39        check_get( nibfile, 1, 0 )
40        check_get( nibfile, 0, 1 )
41        check_get( nibfile, 1, 1 )
42        # Test negative length
43        self.assertRaises( AssertionError, nibfile.get, 20, -1 )
44
45def check_get( nibfile, start, len ):
46    ## print "expect: |%r|" % valid_seq[start:start+len]
47    ## print "actual: |%r|" % nibfile.get( start, len )
48    assert nibfile.get( start, len ) == valid_seq[start:start+len]
49
50test_classes = [ NIBTestCase ]
51suite = unittest.TestSuite( [ unittest.makeSuite( c ) for c in test_classes ] )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。