Permalink
Browse files

Cleaning up the SCOP tests

  • Loading branch information...
1 parent d678911 commit 312245bee2dfaaa7b79a68ec3c0c8101975c81b5 mdehoon committed Jan 25, 2010
View
@@ -1,20 +0,0 @@
-# dir.cla.scop.txt
-# SCOP release 1.55 (July 2001) [File format version 1.00]
-# http://scop.mrc-lmb.cam.ac.uk/scop/
-# Copyright (c) 1994-2001 the scop authors; see http://scop.mrc-lmb.cam.ac.uk/scop/lic/copy.html
-d1dlwa_ 1dlw A: a.1.1.1 14982 cl=46456,cf=46457,sf=46458,fa=46459,dm=46460,sp=46461,px=14982
-d1dlya_ 1dly A: a.1.1.1 14983 cl=46456,cf=46457,sf=46458,fa=46459,dm=46460,sp=46462,px=14983
-d3sdha_ 3sdh A: a.1.1.2 14984 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14984
-d3sdhb_ 3sdh B: a.1.1.2 14985 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14985
-d3hbia_ 3hbi A: a.1.1.2 14986 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14986
-d3hbib_ 3hbi B: a.1.1.2 14987 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14987
-d4sdha_ 4sdh A: a.1.1.2 14988 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14988
-d4sdhb_ 4sdh B: a.1.1.2 14989 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14989
-d4hbia_ 4hbi A: a.1.1.2 14990 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14990
-d4hbib_ 4hbi B: a.1.1.2 14991 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14991
-d5hbia_ 5hbi A: a.1.1.2 14992 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14992
-d5hbib_ 5hbi B: a.1.1.2 14993 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14993
-d7hbia_ 7hbi A: a.1.1.2 14994 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14994
-d7hbib_ 7hbi B: a.1.1.2 14995 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14995
-d1hbia_ 1hbi A: a.1.1.2 14996 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14996
-d1hbib_ 1hbi B: a.1.1.2 14997 cl=46456,cf=46457,sf=46458,fa=46463,dm=46464,sp=46465,px=14997
View
@@ -6,8 +6,6 @@
"""Unit test for Astral"""
import unittest
-from StringIO import *
-
from Bio.SCOP import *
@@ -16,54 +14,54 @@ class AstralTests(unittest.TestCase):
def setUp(self):
- self.scop = Scop(dir_path="SCOP", version="test" )
+ 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"
+ self.assertEqual(self.astral.getSeqBySid('d3sdha_').data, "AAAAA")
+ self.assertEqual(self.astral.getSeqBySid('d4hbib_').data, "KKKKK")
dom = self.scop.getDomainBySid('d3sdha_')
- assert self.astral.getSeq(dom).data == "AAAAA"
+ self.assertEqual(self.astral.getSeq(dom).data, "AAAAA")
def testConstructWithCustomFile(self):
- scop = Scop(dir_path="SCOP", version="test" )
+ 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"
+ self.assertEqual(astral.getSeqBySid('d3sdha_').data, "AAAAA")
+ self.assertEqual(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_"
+ self.assertEqual(len(domains), 3)
+ self.assertEqual(domains[0].sid, "d3sdha_")
+ self.assertEqual(domains[1].sid, "d4hbib_")
+ self.assertEqual(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_"
+ self.assertEqual(len(domains1), 3)
+ self.assertEqual(domains1[0].sid, "d3sdha_")
+ self.assertEqual(domains1[1].sid, "d4hbib_")
+ self.assertEqual(domains1[2].sid, "d5hbia_")
domains2 = self.astral.domainsClusteredByEv(1e-15)
- assert len(domains2) == 1
+ self.assertEqual(len(domains2), 1)
#d1 = scop.getDomainBySid("d3sdha_")
- #assert d1.isIn(astral.getHashedDomainsClusteredByPercentId(20))
- #assert d1.isIn(astral.getHashedDomainsClusteredByEv(-15))
+ #self.assertEqual(d1.isIn(astral.getHashedDomainsClusteredByPercentId(20))
+ #self.assertEqual(d1.isIn(astral.getHashedDomainsClusteredByEv(-15))
-if __name__ == '__main__':
+if __name__=='__main__':
runner = unittest.TextTestRunner(verbosity = 2)
unittest.main(testRunner=runner)
View
@@ -9,7 +9,6 @@
import unittest
from Bio.SCOP import Cla
-from Bio.SCOP.Residues import Residues
@@ -20,60 +19,63 @@ def setUp(self):
self.filename = './SCOP/dir.cla.scop.txt_test'
def testParse(self):
- """Can we parse a CLA file?"""
+ """Test if all records in a CLA file are being read"""
f=open(self.filename)
try:
count = 0
records = Cla.parse(f)
for record in records:
count +=1
- assert count == 14, "Wrong number of records?!"
+ self.assertEqual(count, 14)
finally:
f.close()
def testStr(self):
+ """Test if we can convert each record to a string correctly"""
f = open(self.filename)
try:
for line in f:
record = Cla.Record(line)
#End of line is platform dependent. Strip it off
- assert str(record).rstrip() == line.rstrip()
+ self.assertEqual(str(record).rstrip(), line.rstrip())
finally:
f.close()
def testError(self):
+ """Test if a corrupt record raises the appropriate exception"""
corruptRec = "49268\tsp\tb.1.2.1\t-\n"
-
- try:
- record = Cla.Record(corruptRec)
- assert False, "Should never get here"
- except ValueError, e:
- pass
+ self.assertRaises(ValueError, Cla.Record, corruptRec)
def testRecord(self):
+ """Test one record in detail"""
recLine = 'd1dan.1\t1dan\tT:,U:91-106\tb.1.2.1\t21953\tcl=48724,cf=48725,sf=49265,fa=49266,dm=49267,sp=49268,px=21953'
record = Cla.Record(recLine)
- assert record.sid =='d1dan.1'
- assert record.residues.pdbid =='1dan'
- assert record.residues.fragments ==(('T','',''),('U','91','106'))
- assert record.sccs == 'b.1.2.1'
- assert record.sunid == 21953
- assert record.hierarchy == [['cl',48724],['cf',48725],['sf',49265],
- ['fa',49266],['dm',49267],['sp',49268],
- ['px',21953]], record.hierarchy
+ self.assertEqual(record.sid, 'd1dan.1')
+ self.assertEqual(record.residues.pdbid, '1dan')
+ self.assertEqual(record.residues.fragments, (('T','',''),('U','91','106')))
+ self.assertEqual(record.sccs, 'b.1.2.1')
+ self.assertEqual(record.sunid, 21953)
+ self.assertEqual(record.hierarchy, [['cl',48724],
+ ['cf',48725],
+ ['sf',49265],
+ ['fa',49266],
+ ['dm',49267],
+ ['sp',49268],
+ ['px',21953]])
def testIndex(self):
+ """Test CLA file indexing"""
index = Cla.Index(self.filename)
- assert len(index)==14
- assert index.has_key('d4hbia_')
+ self.assertEqual(len(index), 14)
+ self.assertTrue(index.has_key('d4hbia_'))
rec = index['d1hbia_']
- assert rec.sunid == 14996
+ self.assertEqual(rec.sunid, 14996)
-if __name__ == '__main__':
+if __name__=='__main__':
runner = unittest.TextTestRunner(verbosity = 2)
unittest.main(testRunner=runner)
View
@@ -9,7 +9,6 @@
import unittest
from Bio.SCOP import Des
-from Bio.SCOP.Residues import Residues
@@ -19,47 +18,47 @@ def setUp(self):
self.filename = './SCOP/dir.des.scop.txt_test'
def testParse(self):
- f = open(self.filename)
- try:
- count = 0
- records = Des.parse(f)
- for record in records:
- count +=1
- assert count == 20, "Wrong number of records?!"
- finally:
- f.close()
+ """Test if all records in a DES file are being read"""
+ f = open(self.filename)
+ try:
+ count = 0
+ records = Des.parse(f)
+ for record in records:
+ count +=1
+ self.assertEqual(count, 20)
+ finally:
+ f.close()
def testStr(self):
- f = open(self.filename)
- try:
- for line in f:
- record = Des.Record(line)
- #End of line is plateform dependant. Strip it off
- assert str(record).rstrip() == line.rstrip()
- finally:
- f.close()
+ """Test if we can convert each record to a string correctly"""
+ f = open(self.filename)
+ try:
+ for line in f:
+ record = Des.Record(line)
+ #End of line is platform dependent. Strip it off
+ self.assertEqual(str(record).rstrip(), line.rstrip())
+ finally:
+ f.close()
def testError(self):
+ """Test if a corrupt record raises the appropriate exception"""
corruptRec = "49268\tsp\tb.1.2.1\t-\n"
- try:
- record = Des.Record(corruptRec)
- assert False, "Should never get here"
- except ValueError, e:
- pass
+ self.assertRaises(ValueError, Des.Record, corruptRec)
def testRecord(self):
+ """Test one record in detail"""
recLine = '49268\tsp\tb.1.2.1\t-\tHuman (Homo sapiens) \n'
recFields = (49268,'sp','b.1.2.1','','Human (Homo sapiens)')
record = Des.Record(recLine)
- assert record.sunid == recFields[0]
- assert record.nodetype == recFields[1]
- assert record.sccs == recFields[2]
- assert record.name == recFields[3]
- assert record.description == recFields[4]
+ self.assertEqual(record.sunid, recFields[0])
+ self.assertEqual(record.nodetype, recFields[1])
+ self.assertEqual(record.sccs, recFields[2])
+ self.assertEqual(record.name, recFields[3])
+ self.assertEqual(record.description, recFields[4])
-if __name__ == '__main__':
+if __name__=='__main__':
runner = unittest.TextTestRunner(verbosity = 2)
unittest.main(testRunner=runner)
View
@@ -12,7 +12,6 @@
import unittest
from Bio.SCOP import Dom
-from Bio.SCOP.Residues import Residues
@@ -22,31 +21,35 @@ def setUp(self):
self.filename = './SCOP/testDom.txt'
def testParse(self):
- f = open(self.filename)
- try:
- count = 0
- for record in Dom.parse(f):
- count +=1
- self.assertEquals(count,10)
- finally:
- f.close()
+ """Test if all records in a DOM file are being read"""
+ f = open(self.filename)
+ try:
+ count = 0
+ for record in Dom.parse(f):
+ count +=1
+ self.assertEquals(count,10)
+ finally:
+ f.close()
def testStr(self):
- f = open(self.filename)
- try:
- for line in f:
- record = Dom.Record(line)
- #End of line is platform dependent. Strip it off
- self.assertEquals(str(record).rstrip(),line.rstrip())
- finally:
- f.close()
+ """Test if we can convert each record to a string correctly"""
+ f = open(self.filename)
+ try:
+ for line in f:
+ record = Dom.Record(line)
+ #End of line is platform dependent. Strip it off
+ self.assertEquals(str(record).rstrip(),line.rstrip())
+ finally:
+ f.close()
def testError(self):
+ """Test if a corrupt record raises the appropriate exception"""
corruptDom = "49xxx268\tsp\tb.1.2.1\t-\n"
self.assertRaises(ValueError, Dom.Record, corruptDom)
def testRecord(self):
+ """Test one record in detail"""
recLine = 'd7hbib_\t7hbi\tb:\t1.001.001.001.001.001'
rec = Dom.Record(recLine)
Oops, something went wrong.

0 comments on commit 312245b

Please sign in to comment.