File: test_SCOP_Astral.py

package info (click to toggle)
python-biopython 1.45-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 18,192 kB
  • ctags: 12,310
  • sloc: python: 83,505; xml: 13,834; ansic: 7,015; cpp: 1,855; sql: 1,144; makefile: 179
file content (92 lines) | stat: -rw-r--r-- 2,658 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 2001 by Gavin E. Crooks.  All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license.  Please see the LICENSE file that should have been included
# as part of this package.

"""Unit test for Astral"""

import unittest
from StringIO import *

from Bio.SCOP import *

import sys

def run_tests(argv):
    test_suite = testing_suite()
    runner = unittest.TextTestRunner(sys.stdout, verbosity = 2)
    runner.run(test_suite)

def testing_suite():
    test_suite = unittest.TestSuite()
    
    test_loader = unittest.TestLoader()
    test_loader.testMethodPrefix = 'test'
    tests = [AstralTests]
    
    for test in tests:
        cur_suite = test_loader.loadTestsFromTestCase(test)
        test_suite.addTest(cur_suite)
        
    return test_suite


class AstralTests(unittest.TestCase):


    def setUp(self):
        self.scop = Scop(dir_path="SCOP", version="test" )
        self.astral = Astral(scop=self.scop, dir_path="SCOP", version="test")
                

    def testGetSeq(self):
        assert self.astral.getSeqBySid('d3sdha_').data == "AAAAA"
        assert self.astral.getSeqBySid('d4hbib_').data == "KKKKK"

        dom = self.scop.getDomainBySid('d3sdha_')
        assert self.astral.getSeq(dom).data == "AAAAA"

        
        

    def testConstructWithCustomFile(self):
        scop = Scop(dir_path="SCOP", version="test" )
        astral = Astral(scop=scop, astral_file="SCOP/scopseq-test/astral-scopdom-seqres-all-test.fa")
        assert astral.getSeqBySid('d3sdha_').data == "AAAAA"
        assert astral.getSeqBySid('d4hbib_').data == "KKKKK"
                       
         
    def testGetDomainsFromFile(self):
        filename = "SCOP/scopseq-test/astral-scopdom-seqres-sel-gs-bib-20-test.id"
        domains = self.astral.getAstralDomainsFromFile(filename)

        assert len(domains)==3
        assert domains[0].sid == "d3sdha_"
        assert domains[1].sid == "d4hbib_"
        assert domains[2].sid == "d5hbia_"

    def testGetDomainsClustered(self):
        domains1 = self.astral.domainsClusteredById(20)
        assert len(domains1) == 3
        assert domains1[0].sid == "d3sdha_"
        assert domains1[1].sid == "d4hbib_"
        assert domains1[2].sid == "d5hbia_"
                        
        domains2 = self.astral.domainsClusteredByEv(1e-15)
        assert len(domains2) == 1

        #d1 = scop.getDomainBySid("d3sdha_")
        #assert d1.isIn(astral.getHashedDomainsClusteredByPercentId(20))
        #assert d1.isIn(astral.getHashedDomainsClusteredByEv(-15))
        
        
        


if __name__ == '__main__':
    unittest.main()