Back to index

python-biopython  1.60
test_SCOP_Astral.py
Go to the documentation of this file.
00001 # Copyright 2001 by Gavin E. Crooks.  All rights reserved.
00002 # This code is part of the Biopython distribution and governed by its
00003 # license.  Please see the LICENSE file that should have been included
00004 # as part of this package.
00005 
00006 """Unit test for Astral"""
00007 
00008 import unittest
00009 from Bio.SCOP import *
00010 
00011 
00012 
00013 class AstralTests(unittest.TestCase):
00014 
00015 
00016     def setUp(self):
00017         self.scop = Scop(dir_path="SCOP", version="test")
00018         self.astral = Astral(scop=self.scop, dir_path="SCOP", version="test")
00019                 
00020 
00021     def testGetSeq(self):
00022         self.assertEqual(self.astral.getSeqBySid('d3sdha_').tostring(), "AAAAA")
00023         self.assertEqual(self.astral.getSeqBySid('d4hbib_').tostring(), "KKKKK")
00024 
00025         dom = self.scop.getDomainBySid('d3sdha_')
00026         self.assertEqual(self.astral.getSeq(dom).tostring(), "AAAAA")
00027 
00028         
00029         
00030 
00031     def testConstructWithCustomFile(self):
00032         scop = Scop(dir_path="SCOP", version="test")
00033         astral = Astral(scop=scop, astral_file="SCOP/scopseq-test/astral-scopdom-seqres-all-test.fa")
00034         self.assertEqual(astral.getSeqBySid('d3sdha_').tostring(), "AAAAA")
00035         self.assertEqual(astral.getSeqBySid('d4hbib_').tostring(), "KKKKK")
00036                        
00037          
00038     def testGetDomainsFromFile(self):
00039         filename = "SCOP/scopseq-test/astral-scopdom-seqres-sel-gs-bib-20-test.id"
00040         domains = self.astral.getAstralDomainsFromFile(filename)
00041 
00042         self.assertEqual(len(domains), 3)
00043         self.assertEqual(domains[0].sid, "d3sdha_")
00044         self.assertEqual(domains[1].sid, "d4hbib_")
00045         self.assertEqual(domains[2].sid, "d5hbia_")
00046 
00047     def testGetDomainsClustered(self):
00048         domains1 = self.astral.domainsClusteredById(20)
00049         self.assertEqual(len(domains1), 3)
00050         self.assertEqual(domains1[0].sid, "d3sdha_")
00051         self.assertEqual(domains1[1].sid, "d4hbib_")
00052         self.assertEqual(domains1[2].sid, "d5hbia_")
00053                         
00054         domains2 = self.astral.domainsClusteredByEv(1e-15)
00055         self.assertEqual(len(domains2), 1)
00056 
00057         #d1 = scop.getDomainBySid("d3sdha_")
00058         #self.assertEqual(d1.isIn(astral.getHashedDomainsClusteredByPercentId(20))
00059         #self.assertEqual(d1.isIn(astral.getHashedDomainsClusteredByEv(-15))
00060         
00061         
00062         
00063 
00064 
00065 if __name__=='__main__':
00066     runner = unittest.TextTestRunner(verbosity = 2)
00067     unittest.main(testRunner=runner)