Back to index

python-biopython  1.60
Public Member Functions | Private Member Functions
test_SCOP_Scop.ScopTests Class Reference

List of all members.

Public Member Functions

def testParse
def testSccsOrder
def testParseDomain
def testConstructFromDirectory
def testGetAscendent
def test_get_descendents

Private Member Functions

def _compare_cla_lines

Detailed Description

Definition at line 17 of file test_SCOP_Scop.py.


Member Function Documentation

def test_SCOP_Scop.ScopTests._compare_cla_lines (   self,
  cla_line_1,
  cla_line_2 
) [private]
Compares the two specified Cla lines for equality.

The order of the key-value pairs in the sixth field of the lines does
not matter. For more information, see
http://scop.mrc-lmb.cam.ac.uk/scop/release-notes.html.

Definition at line 19 of file test_SCOP_Scop.py.

00019 
00020     def _compare_cla_lines(self, cla_line_1, cla_line_2):
00021         """Compares the two specified Cla lines for equality.
00022 
00023         The order of the key-value pairs in the sixth field of the lines does
00024         not matter. For more information, see
00025         http://scop.mrc-lmb.cam.ac.uk/scop/release-notes.html.
00026         """
00027         fields1 = cla_line_1.rstrip().split('\t')
00028         fields2 = cla_line_2.rstrip().split('\t')
00029         print fields1
00030         print fields2
00031         # compare the first five fields in a Cla line, which should be exactly
00032         # the same
00033         if fields1[:5] != fields2[:5]:
00034             return False
00035         # compare the hierarchy key-value pairs, which are unordered
00036         if set(fields1[5].split(',')) != set(fields2[5].split(',')):
00037             return False
00038         return True

Here is the caller graph for this function:

Test getDescendents method

Definition at line 151 of file test_SCOP_Scop.py.

00151 
00152     def test_get_descendents(self):
00153         """Test getDescendents method"""
00154         scop = Scop (dir_path="SCOP", version="test")
00155         fold = scop.getNodeBySunid(46457)
00156 
00157         # get px descendents
00158         domains = fold.getDescendents('px')
00159         self.assertEqual(len(domains), 14)
00160         for d in domains:
00161             self.assertEqual(d.type, 'px')
00162             
00163         sfs = fold.getDescendents('superfamily')
00164         self.assertEqual(len(sfs), 1)
00165         for d in sfs:
00166             self.assertEqual(d.type, 'sf')
00167 
00168         # cl has no cl descendent
00169         cl = fold.getDescendents('cl')
00170         self.assertEqual(cl, [])
00171         
00172         
00173 

Definition at line 123 of file test_SCOP_Scop.py.

00123 
00124     def testConstructFromDirectory(self):
00125         scop = Scop (dir_path="SCOP", version="test")
00126         self.assertTrue(isinstance(scop, Scop))
00127          
00128         domain = scop.getDomainBySid("d1hbia_")
00129         self.assertEqual(domain.sunid, 14996)
         

Definition at line 130 of file test_SCOP_Scop.py.

00130 
00131     def testGetAscendent(self):
00132         scop = Scop (dir_path="SCOP", version="test")
00133         domain = scop.getDomainBySid("d1hbia_")
00134 
00135         # get the fold
00136         fold = domain.getAscendent('cf')
00137         self.assertEqual(fold.sunid, 46457)
00138         
00139         #get the superfamily
00140         sf = domain.getAscendent('superfamily')
00141         self.assertEqual(sf.sunid, 46458)
00142 
00143         # px has no px ascendent
00144         px = domain.getAscendent('px')
00145         self.assertEqual(px, None)
00146 
00147         # an sf has no px ascendent
00148         px2 = sf.getAscendent('px')
00149         self.assertEqual(px2, None)
00150 

Definition at line 39 of file test_SCOP_Scop.py.

00039 
00040     def testParse(self):
00041   
00042         f = open("./SCOP/dir.cla.scop.txt_test")
00043         try:
00044             cla = f.read()
00045             f.close()
00046             
00047             f = open("./SCOP/dir.des.scop.txt_test")
00048             des = f.read()
00049             f.close()
00050 
00051             f = open("./SCOP/dir.hie.scop.txt_test")
00052             hie = f.read()
00053         finally:
00054             f.close()
00055 
00056         scop = Scop(StringIO(cla), StringIO(des), StringIO(hie))
00057 
00058         cla_out = StringIO()
00059         scop.write_cla(cla_out)
00060         lines = zip(cla.rstrip().split('\n'),
00061                     cla_out.getvalue().rstrip().split('\n'))
00062         for expected_line, line in lines:
00063             self.assertTrue(self._compare_cla_lines(expected_line, line))
00064         
00065         des_out = StringIO()
00066         scop.write_des(des_out)
00067         self.assertEqual(des_out.getvalue(), des)
00068 
00069         hie_out = StringIO()
00070         scop.write_hie(hie_out)
00071         self.assertEqual(hie_out.getvalue(), hie)
00072 
00073         domain = scop.getDomainBySid("d1hbia_")
00074         self.assertEqual(domain.sunid, 14996)
00075 
00076         domains = scop.getDomains()
00077         self.assertEqual(len(domains), 14)
00078         self.assertEqual(domains[4].sunid, 14988)
00079 
00080 
00081         dom = scop.getNodeBySunid(-111)
00082         self.assertEqual(dom, None)
00083         dom = scop.getDomainBySid("no such domain")
00084         self.assertEqual(dom, None)
00085                 
00086 

Here is the call graph for this function:

Definition at line 96 of file test_SCOP_Scop.py.

00096 
00097     def testParseDomain(self):
00098         s=">d1tpt_1 a.46.2.1 (1-70) Thymidine phosphorylase {Escherichia coli}"
00099         dom = parse_domain(s)
00100 
00101         self.assertEqual(dom.sid, 'd1tpt_1')
00102         self.assertEqual(dom.sccs, 'a.46.2.1')
00103         self.assertEqual(dom.residues.pdbid, '1tpt')
00104         self.assertEqual(dom.description, 'Thymidine phosphorylase {Escherichia coli}')
00105 
00106         s2="d1tpt_1 a.46.2.1 (1tpt 1-70) Thymidine phosphorylase {E. coli}"
00107         self.assertEqual(s2, str(parse_domain(s2)))
00108 
00109 
00110 
00111         #Genetic domains (See Astral release notes)
00112         s3="g1cph.1 g.1.1.1 (1cph B:,A:) Insulin {Cow (Bos taurus)}"
00113         self.assertEqual(s3, str(parse_domain(s3)))
00114 
00115         s4="e1cph.1a g.1.1.1 (1cph A:) Insulin {Cow (Bos taurus)}"
00116         self.assertEqual(s4, str(parse_domain(s4)))
00117 
00118         #Raw Astral header
00119         s5=">e1cph.1a g.1.1.1 (A:) Insulin {Cow (Bos taurus)}"
00120         self.assertEqual(s4,  str(parse_domain(s5)))
00121 
00122         self.assertRaises(ValueError, parse_domain, "Totally wrong")

Here is the call graph for this function:

Definition at line 87 of file test_SCOP_Scop.py.

00087 
00088     def testSccsOrder(self):
00089         self.assertEqual(cmp_sccs("a.1.1.1", "a.1.1.1"), 0)
00090         self.assertEqual(cmp_sccs("a.1.1.2", "a.1.1.1"), 1)
00091         self.assertEqual(cmp_sccs("a.1.1.2", "a.1.1.11"), -1)
00092         self.assertEqual(cmp_sccs("a.1.2.2", "a.1.1.11"), 1)
00093         self.assertEqual(cmp_sccs("a.1.2.2", "a.5.1.11"), -1)
00094         self.assertEqual(cmp_sccs("b.1.2.2", "a.5.1.11"), 1)
00095         self.assertEqual(cmp_sccs("b.1.2.2", "b.1.2"), 1)

Here is the call graph for this function:


The documentation for this class was generated from the following file: