~ubuntu-branches/ubuntu/vivid/cinfony/vivid

« back to all changes in this revision

Viewing changes to test/testall.py

  • Committer: Package Import Robot
  • Author(s): Debichem Team, Daniel Leidert
  • Date: 2013-05-20 14:25:39 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130520142539-c4eb3nnht3ghe02l
Tags: 1.2-1
* New upstream release.

[ Daniel Leidert ]
* debian/control: Added XB-Python-Version and Provides fields.
  (Standards-Version): Bumped to 3.9.4.
  (DM-Upload-Allowed): Dropped obsolete field.
  (Build-Depends): Replace python-support by python for dh_python2
  transition.
  (Recommends): Added python-imaging-tk.
  (Suggests): Added jython and ironpython.
* debian/copyright: Added and updated license and copyright information.
* debian/rules: Use dh_python2 module. Clean files via dh_clean.
* debian/watch: Added.
* debian/patches/testsuite_missing_datafiles.patch: Added header.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import sys
4
4
import unittest
5
5
 
6
 
pybel = indy = ironable = rdk = cdk = obabel = webel = opsin = None
 
6
pybel = indy = ironable = rdk = cdk = webel = opsin = jchem = None
7
7
try:
8
8
    import pybel # From Open Babel
9
9
except ImportError:
13
13
except (RuntimeError, ImportError, KeyError):
14
14
    pass
15
15
try:
16
 
    from cinfony import obabel
 
16
    from cinfony import pybel
17
17
except (ImportError, AttributeError, KeyError):
18
18
    pass
19
19
try:
32
32
    from cinfony import webel
33
33
except ImportError:
34
34
    pass
 
35
try:
 
36
    from cinfony import jchem
 
37
except (NameError, RuntimeError, ImportError, KeyError):
 
38
    pass
35
39
 
36
40
try: # Define next() for Jython 2.5
37
41
    next
102
106
        self.assertNotEqual(len(self.toolkit.forcefields), 0)
103
107
        self.assertNotEqual(len(self.toolkit.fps), 0)
104
108
 
 
109
    def testInChI(self):
 
110
        """Test InChI generation"""
 
111
        inchi = self.mols[0].write("inchi").rstrip()
 
112
        inchikey = self.mols[0].write("inchikey").rstrip()
 
113
        self.assertEqual(inchi, "InChI=1S/C4H10/c1-3-4-2/h3-4H2,1-2H3")
 
114
        self.assertEqual(inchikey, "IJDNQMDRQITEOD-UHFFFAOYSA-N")
 
115
        mol = self.toolkit.readstring("inchi", inchi)
 
116
        self.assertEqual("CCCC", mol.write("smi").rstrip())
 
117
 
105
118
    def FPaccesstest(self):
106
119
        # Should raise AttributeError
107
120
        return self.mols[0].calcfp().nosuchname
153
166
        newcoords = self.head[0].atoms[0].coords
154
167
        self.assertNotEqual(oldcoords, newcoords)
155
168
 
156
 
    def notestMake3D(self):
 
169
    def testMake3D(self):
157
170
        """Test that 3D coordinate generation does something"""
158
171
        mol = self.mols[0]
159
172
        mol.make3D()
354
367
        self.assertEqual(len(self.mols[0].atoms),4)
355
368
        
356
369
class TestOBabel(TestToolkit):
357
 
    toolkit = obabel
 
370
    toolkit = pybel
358
371
    tanimotoresult = 1/3.
359
372
    Natoms = 15
360
373
    tpsaname = "TPSA"
361
374
    Nfpbits = 32
362
 
    datakeys = ['NSC', 'Comment', 'OpenBabel Symmetry Classes']
 
375
    datakeys = ['NSC', 'Comment', 'OpenBabel Symmetry Classes',
 
376
                'MOL Chiral Flag']
363
377
 
364
378
    def testFP_FP3(self):
365
379
        "Checking the results from FP3"
370
384
        """Testing unit cell access"""
371
385
        mol = next(self.toolkit.readfile("cif", "hashizume.cif"))
372
386
        cell = mol.unitcell
373
 
        self.assertAlmostEqual(cell.GetAlpha(), 92.9, 1)
 
387
        self.assertAlmostEqual(cell.GetAlpha(), 93.0, 1)
374
388
 
375
389
    def testMDcomment(self):
376
390
        """Mess about with the comment field"""
439
453
    def testLocalOpt(self):
440
454
        """No forcefields"""
441
455
        pass
 
456
    def testMake3D(self):
 
457
        """No forcefields"""
 
458
        pass
442
459
 
443
460
 
444
461
class TestWebel(TestToolkit):
588
605
        self.assertEqual(len(self.mols[0].atoms), 4)
589
606
        self.assertRaises(AttributeError, self.RSaccesstest)
590
607
 
 
608
class TestJchem(TestToolkit):
 
609
    toolkit = jchem
 
610
    tanimotoresult = 0.444
 
611
    Natoms = 15
 
612
    tpsaname = "TPSA"
 
613
    Nfpbits = 5
 
614
    datakeys = ['NSC']
 
615
 
 
616
    def testLocalOpt(self):
 
617
        """No local opt testing done"""
 
618
        pass
 
619
    def testRSgetprops(self):
 
620
        """Get the values of the properties."""
 
621
        # self.assertAlmostEqual(self.mols[0].exactmass, 58.078, 3)
 
622
        # Only OpenBabel has a working exactmass
 
623
        self.assertAlmostEqual(self.mols[0].molwt, 58.12, 2)
 
624
        self.assertEqual(len(self.mols[0].atoms), 4)
 
625
        self.assertRaises(AttributeError, self.RSaccesstest)
 
626
 
591
627
class TestCDKJPype(TestCDK):
592
628
    def testDraw(self):
593
629
        """No depiction supported I'm afraid"""
599
635
 
600
636
    lookup = {'cdk': TestCDK, 'obabel':TestOBabel, 'rdk':TestRDKit,
601
637
              'webel': TestWebel, 'opsin': TestOpsin, 'indy': TestIndigo,
602
 
              'pybel':TestPybel}
 
638
              'pybel':TestPybel, 'jchem':TestJchem}
603
639
    if sys.platform[:4] == "java":
604
640
        lookup['obabel'] = TestJybel
605
641
        del lookup['rdk']
607
643
        lookup['obabel'] = TestIronable
608
644
        del lookup['rdk']
609
645
        del lookup['cdk']
 
646
        del lookup['jchem']
610
647
        del lookup['opsin']
611
648
    else:
612
649
        lookup['cdk'] = TestCDKJPype