mirror of
https://github.com/openbabel/openbabel.git
synced 2026-08-26 21:27:29 -05:00
Merge pull request #1970 from e-kwsm/improve-python
Improve python script
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
from __future__ import print_function
|
||||
import openbabel as ob
|
||||
|
||||
# Initialize the OBConversion object
|
||||
conv = ob.OBConversion()
|
||||
if not conv.SetInFormat('smi'):
|
||||
print 'could not find smiles format'
|
||||
print('could not find smiles format')
|
||||
|
||||
# Read the smiles string
|
||||
mol = ob.OBMol()
|
||||
if not conv.ReadString(mol, 'CCCC'):
|
||||
print 'could not read the smiles string'
|
||||
print('could not read the smiles string')
|
||||
|
||||
# ... Use OBMol object ...
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
||||
#
|
||||
######################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
import openbabel
|
||||
import sys
|
||||
|
||||
@@ -11,7 +12,7 @@ import sys
|
||||
try:
|
||||
filename = sys.argv[1]
|
||||
except:
|
||||
print "Usage: python energy.py filename"
|
||||
print("Usage: python energy.py filename")
|
||||
sys.exit(1)
|
||||
|
||||
# Read the file.
|
||||
@@ -24,19 +25,19 @@ conv.ReadFile(mol, filename)
|
||||
# Find the MMFF94 force field.
|
||||
ff = openbabel.OBForceField.FindForceField("MMFF94")
|
||||
if ff == 0:
|
||||
print "Could not find forcefield"
|
||||
print("Could not find forcefield")
|
||||
|
||||
# Set the log level to high since we want to print out individual
|
||||
# interactions.
|
||||
ff.SetLogLevel(openbabel.OBFF_LOGLVL_HIGH)
|
||||
ff.SetLogLevel(openbabel.OBFF_LOGLVL_HIGH)
|
||||
# python specific, python doesn't have std::ostream so the SetLogFile()
|
||||
# function is replaced by SetLogToStdOut and SetLogToStdErr in the SWIG
|
||||
# interface file
|
||||
ff.SetLogToStdErr()
|
||||
ff.SetLogToStdErr()
|
||||
|
||||
# Setup the molecule. This assigns atoms types, charges and parameters
|
||||
# Setup the molecule. This assigns atoms types, charges and parameters
|
||||
if ff.Setup(mol) == 0:
|
||||
print "Could not setup forcefield"
|
||||
print("Could not setup forcefield")
|
||||
|
||||
# Calculate the energy
|
||||
ff.Energy()
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
from __future__ import print_function
|
||||
import openbabel
|
||||
|
||||
mol = openbabel.OBMol()
|
||||
print 'Should print 0 (atoms)'
|
||||
print mol.NumAtoms()
|
||||
print('Should print 0 (atoms)')
|
||||
print(mol.NumAtoms())
|
||||
|
||||
a = mol.NewAtom()
|
||||
b = mol.NewAtom()
|
||||
mol.AddBond(1, 2, 1)
|
||||
print 'Should print 2 (atoms)'
|
||||
print mol.NumAtoms()
|
||||
print 'Should print 1 (bond)'
|
||||
print mol.NumBonds()
|
||||
print('Should print 2 (atoms)')
|
||||
print(mol.NumAtoms())
|
||||
print('Should print 1 (bond)')
|
||||
print(mol.NumBonds())
|
||||
|
||||
obConversion = openbabel.OBConversion()
|
||||
obConversion.SetInAndOutFormats("smi", "mdl")
|
||||
@@ -18,12 +19,12 @@ obConversion.SetInAndOutFormats("smi", "mdl")
|
||||
mol.Clear()
|
||||
obConversion.ReadString(mol, "C1=CC=CS1")
|
||||
|
||||
print 'Should print 5 (atoms)'
|
||||
print mol.NumAtoms()
|
||||
print('Should print 5 (atoms)')
|
||||
print(mol.NumAtoms())
|
||||
|
||||
mol.AddHydrogens()
|
||||
print 'Should print 9 (atoms) after adding hydrogens'
|
||||
print mol.NumAtoms()
|
||||
print('Should print 9 (atoms) after adding hydrogens')
|
||||
print(mol.NumAtoms())
|
||||
|
||||
outMDL = obConversion.WriteString(mol)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
######################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
import openbabel
|
||||
import sys
|
||||
|
||||
@@ -11,7 +12,7 @@ import sys
|
||||
try:
|
||||
filename = sys.argv[1]
|
||||
except:
|
||||
print "Usage: python energy.py filename"
|
||||
print("Usage: python energy.py filename")
|
||||
sys.exit(1)
|
||||
|
||||
# Read the file.
|
||||
@@ -24,19 +25,19 @@ conv.ReadFile(mol, filename)
|
||||
# Find the MMFF94 force field.
|
||||
ff = openbabel.OBForceField.FindForceField("MMFF94")
|
||||
if ff == 0:
|
||||
print "Could not find forcefield"
|
||||
print("Could not find forcefield")
|
||||
|
||||
# Set the log level to low since we only want to print out the minimization
|
||||
# Set the log level to low since we only want to print out the minimization
|
||||
# steps and not all individual interactions for each call to Energy()
|
||||
ff.SetLogLevel(openbabel.OBFF_LOGLVL_LOW)
|
||||
ff.SetLogLevel(openbabel.OBFF_LOGLVL_LOW)
|
||||
# python specific, python doesn't have std::ostream so the SetLogFile()
|
||||
# function is replaced by SetLogToStdOut and SetLogToStdErr in the SWIG
|
||||
# interface file
|
||||
ff.SetLogToStdErr()
|
||||
ff.SetLogToStdErr()
|
||||
|
||||
# Setup the molecule. This assigns atoms types, charges and parameters
|
||||
# Setup the molecule. This assigns atoms types, charges and parameters
|
||||
if ff.Setup(mol) == 0:
|
||||
print "Could not setup forcefield"
|
||||
print("Could not setup forcefield")
|
||||
|
||||
# Minimize using steepest descent for 2000 steps
|
||||
ff.SteepestDescent(2000)
|
||||
|
||||
@@ -62,8 +62,8 @@ class TestToolkit(myTestCase):
|
||||
def testattributes(self):
|
||||
"""Test attributes like informats, descs and so on"""
|
||||
informats, outformats = self.toolkit.informats, self.toolkit.outformats
|
||||
self.assertNotEqual(len(self.toolkit.informats.keys()), 0)
|
||||
self.assertNotEqual(len(self.toolkit.outformats.keys()), 0)
|
||||
self.assertNotEqual(len(list(self.toolkit.informats.keys())), 0)
|
||||
self.assertNotEqual(len(list(self.toolkit.outformats.keys())), 0)
|
||||
self.assertNotEqual(len(self.toolkit.descs), 0)
|
||||
self.assertNotEqual(len(self.toolkit.forcefields), 0)
|
||||
self.assertNotEqual(len(self.toolkit.fps), 0)
|
||||
@@ -278,7 +278,7 @@ M END
|
||||
def testMDglobalaccess(self):
|
||||
"""Check out the keys"""
|
||||
data = self.head[0].data
|
||||
self.assertFalse(data.has_key('Noel'))
|
||||
self.assertFalse('Noel' in data)
|
||||
self.assertEqual(len(data), len(self.datakeys))
|
||||
for key in data:
|
||||
self.assertEqual(key in self.datakeys, True)
|
||||
@@ -288,9 +288,9 @@ M END
|
||||
def testMDdelete(self):
|
||||
"""Delete some keys"""
|
||||
data = self.head[0].data
|
||||
self.assertTrue(data.has_key('NSC'))
|
||||
self.assertTrue('NSC' in data)
|
||||
del data['NSC']
|
||||
self.assertFalse(data.has_key('NSC'))
|
||||
self.assertFalse('NSC' in data)
|
||||
data.clear()
|
||||
self.assertEqual(len(data), 0)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
######################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
import openbabel
|
||||
import sys
|
||||
|
||||
@@ -11,7 +12,7 @@ import sys
|
||||
try:
|
||||
filename = sys.argv[1]
|
||||
except:
|
||||
print "Usage: python energy.py filename"
|
||||
print("Usage: python energy.py filename")
|
||||
sys.exit(1)
|
||||
|
||||
# Read the file.
|
||||
@@ -24,21 +25,21 @@ conv.ReadFile(mol, filename)
|
||||
# Find the MMFF94 force field.
|
||||
ff = openbabel.OBForceField.FindForceField("MMFF94")
|
||||
if ff == 0:
|
||||
print "Could not find forcefield"
|
||||
print("Could not find forcefield")
|
||||
|
||||
# Set the log level to low since we only want to print out the conformer search
|
||||
# steps and not all individual interactions for each call to Energy()
|
||||
ff.SetLogLevel(openbabel.OBFF_LOGLVL_LOW)
|
||||
ff.SetLogLevel(openbabel.OBFF_LOGLVL_LOW)
|
||||
# python specific, python doesn't have std::ostream so the SetLogFile()
|
||||
# function is replaced by SetLogToStdOut and SetLogToStdErr in the SWIG
|
||||
# interface file
|
||||
ff.SetLogToStdErr()
|
||||
ff.SetLogToStdErr()
|
||||
|
||||
# Setup the molecule. This assigns atoms types, charges and parameters
|
||||
# Setup the molecule. This assigns atoms types, charges and parameters
|
||||
if ff.Setup(mol) == 0:
|
||||
print "Could not setup forcefield"
|
||||
print("Could not setup forcefield")
|
||||
|
||||
# Weighted rotor search: generate 25 conformers, optimize each conformer for
|
||||
# Weighted rotor search: generate 25 conformers, optimize each conformer for
|
||||
# 500 steps.
|
||||
ff.WeightedRotorSearch(25, 500)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ def locate_ob():
|
||||
ob_ver = StrictVersion(pkgconfig('openbabel-2.0', '--modversion'))
|
||||
py_ver = StrictVersion(find_version())
|
||||
if not ob_ver.version[:2] == py_ver.version[:2]:
|
||||
print('Warning: Open Babel %s.%s.x is required. Your version (%s) may not be compatible.'
|
||||
print('Warning: Open Babel %s.%s.x is required. Your version (%s) may not be compatible.'
|
||||
% (py_ver.version[0], py_ver.version[1], ob_ver))
|
||||
include_dirs = pkgconfig('openbabel-2.0', '--variable=pkgincludedir')
|
||||
library_dirs = pkgconfig('openbabel-2.0', '--variable=libdir')
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class TestReactionInChIWriter(BaseTest):
|
||||
# Example: esterification of acetic acid
|
||||
("OCC.CC(=O)O>S(=O)(=O)(O)O>CC(=O)OCC.O", "RInChI=1.00.1S/C2H4O2/c1-2(3)4/h1H3,(H,3,4)!C2H6O/c1-2-3/h3H,2H2,1H3<>C4H8O2/c1-3-6-4(2)5/h3H2,1-2H3!H2O/h1H2<>H2O4S/c1-5(2,3)4/h(H2,1,2,3,4)/d+"),
|
||||
# Example: alkaline ring opening
|
||||
("CC[C@]1(C)O[C@H]1C.[OH-]>>CC[C@](C)(O)[C@@H](C)O", "RInChI=1.00.1S/C6H12O/c1-4-6(3)5(2)7-6/h5H,4H2,1-3H3/t5-,6-/m0/s1!H2O/h1H2/p-1<>C6H14O2/c1-4-6(3,8)5(2)7/h5,7-8H,4H2,1-3H3/t5-,6+/m1/s1/d+"),
|
||||
("CC[C@]1(C)O[C@H]1C.[OH-]>>CC[C@](C)(O)[C@@H](C)O", "RInChI=1.00.1S/C6H12O/c1-4-6(3)5(2)7-6/h5H,4H2,1-3H3/t5-,6-/m0/s1!H2O/h1H2/p-1<>C6H14O2/c1-4-6(3,8)5(2)7/h5,7-8H,4H2,1-3H3/t5-,6+/m1/s1/d+"),
|
||||
# Partial reactions
|
||||
(">>C1CC=C(O)CC1", "RInChI=1.00.1S/<>C6H10O/c7-6-4-2-1-3-5-6/h4,7H,1-3,5H2/d+"),
|
||||
("C1CC=C(O)CC1>>", "RInChI=1.00.1S/<>C6H10O/c7-6-4-2-1-3-5-6/h4,7H,1-3,5H2/d-"),
|
||||
|
||||
+3
-4
@@ -71,9 +71,8 @@ def log(text):
|
||||
|
||||
The log file (log.txt) is created in build/test
|
||||
"""
|
||||
output = open("log.txt", "a")
|
||||
print >> output, text
|
||||
output.close()
|
||||
with open("log.txt", "a") as output:
|
||||
output.write(text + "\n")
|
||||
|
||||
class BaseTest(unittest.TestCase):
|
||||
"""A base class for test classes that adds additional
|
||||
@@ -269,7 +268,7 @@ TORSDOF 5
|
||||
'O=[S@@](c1nc2c([nH]1)cccc2)Cc1nccc(c1C)OCC(F)(F)F',
|
||||
'C#C[C@]1(O)CC[C@@H]2[C@]1(C)CC[C@H]1[C@H]2CCc2c1ccc(c2)O',
|
||||
]
|
||||
for cofname, CAN in zip(listCOFnames, listCANexpected):
|
||||
for cofname, CAN in zip(listCOFnames, listCANexpected):
|
||||
coffilename = cofname + '.cof'
|
||||
if(cofname == 'culgi_06'):
|
||||
cofname = 'mol24' # Special case: 'internal name' not the same as file name
|
||||
|
||||
@@ -19,7 +19,6 @@ and so you can quickly develop the tests and try them out.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
import itertools
|
||||
|
||||
@@ -14,7 +14,6 @@ In both cases, the test file is run directly from the source folder,
|
||||
and so you can quickly develop the tests and try them out.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from testbabel import run_exec, BaseTest
|
||||
@@ -38,22 +37,22 @@ S(N1[CH](c2ccccc2C=C1)C#N)(c1ccc(cc1)C)(=O)=O
|
||||
c12c(c(OC)c3c(c1OC)occ3)ccc(o2)=O
|
||||
c12c(O[CH](C1=O)C(C)C)cc1c(c2)ccc(=O)o1
|
||||
c12[C]3([C@H]4([N@@](CCc1c1ccccc1[nH]2)C[C@H](C=C4CC)C3))C(=O)OC"""
|
||||
|
||||
|
||||
outputfile = open("ten.smi", "w")
|
||||
outputfile.write(smiles)
|
||||
outputfile.close()
|
||||
|
||||
|
||||
output, error = run_exec("babel ten.smi ten.fs")
|
||||
self.canFindFile("ten.fs")
|
||||
self.assertConverted(error, 10)
|
||||
|
||||
|
||||
query = "Nc2nc(c1ccccc1)nc3ccccc23"
|
||||
output, error = run_exec("babel ten.fs -ifs -s %s -osmi" % query)
|
||||
self.assertConverted(error, 1)
|
||||
|
||||
output, error = run_exec("babel ten.fs -ifs -s %s -at 0.5 -aa -osmi" % query)
|
||||
self.assertConverted(error, 1)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ and so you can quickly develop the tests and try them out.
|
||||
|
||||
import unittest
|
||||
|
||||
from testbabel import run_exec, executable, log, BaseTest
|
||||
from testbabel import run_exec, executable, BaseTest
|
||||
|
||||
class TestKekuleAssignment(BaseTest):
|
||||
"""A series of tests relating to aromaticity/kekule"""
|
||||
|
||||
+71
-71
@@ -17,7 +17,7 @@ and so you can quickly develop the tests and try them out.
|
||||
|
||||
import unittest
|
||||
|
||||
from testbabel import run_exec, executable, log, BaseTest
|
||||
from testbabel import run_exec, executable, BaseTest
|
||||
|
||||
class TestPDBFormat(BaseTest):
|
||||
"""A series of tests relating to PDB"""
|
||||
@@ -29,76 +29,76 @@ class TestPDBFormat(BaseTest):
|
||||
"""
|
||||
self.canFindExecutable("babel")
|
||||
|
||||
self.entryPDBwithInsertioncodes="""ATOM 406 N VAL L 29 58.041 17.797 48.254 1.00 0.00 N
|
||||
ATOM 407 CA VAL L 29 57.124 18.088 47.170 1.00 0.00 C
|
||||
ATOM 408 C VAL L 29 55.739 17.571 47.538 1.00 0.00 C
|
||||
ATOM 409 O VAL L 29 55.535 16.362 47.550 1.00 0.00 O
|
||||
ATOM 410 CB VAL L 29 57.580 17.456 45.842 1.00 0.00 C
|
||||
ATOM 411 CG1 VAL L 29 56.571 17.743 44.741 1.00 0.00 C
|
||||
ATOM 412 CG2 VAL L 29 58.957 17.973 45.450 1.00 0.00 C
|
||||
ATOM 413 H VAL L 29 58.603 16.959 48.212 1.00 0.00 H
|
||||
ATOM 414 HA VAL L 29 57.012 19.163 47.024 1.00 0.00 H
|
||||
ATOM 415 HB VAL L 29 57.674 16.378 45.977 1.00 0.00 H
|
||||
ATOM 416 1HG1 VAL L 29 56.909 17.289 43.809 1.00 0.00 H
|
||||
ATOM 417 2HG1 VAL L 29 55.603 17.327 45.016 1.00 0.00 H
|
||||
ATOM 418 3HG1 VAL L 29 56.479 18.821 44.604 1.00 0.00 H
|
||||
ATOM 419 1HG2 VAL L 29 59.263 17.515 44.510 1.00 0.00 H
|
||||
ATOM 420 2HG2 VAL L 29 58.917 19.055 45.331 1.00 0.00 H
|
||||
ATOM 421 3HG2 VAL L 29 59.676 17.719 46.229 1.00 0.00 H
|
||||
ATOM 422 N SER L 30 54.838 18.500 47.837 1.00 0.00 N
|
||||
ATOM 423 CA SER L 30 53.494 18.162 48.273 1.00 0.00 C
|
||||
ATOM 424 C SER L 30 52.725 17.364 47.221 1.00 0.00 C
|
||||
ATOM 425 O SER L 30 52.723 17.697 46.056 1.00 0.00 O
|
||||
ATOM 426 CB SER L 30 52.734 19.429 48.610 1.00 0.00 C
|
||||
ATOM 427 OG SER L 30 51.403 19.143 48.941 1.00 0.00 O
|
||||
ATOM 428 H SER L 30 55.100 19.472 47.757 1.00 0.00 H
|
||||
ATOM 429 HA SER L 30 53.471 17.585 49.199 1.00 0.00 H
|
||||
ATOM 430 1HB SER L 30 53.219 19.934 49.445 1.00 0.00 H
|
||||
ATOM 431 2HB SER L 30 52.761 20.107 47.758 1.00 0.00 H
|
||||
ATOM 432 HG SER L 30 50.919 19.965 48.828 1.00 0.00 H
|
||||
ATOM 433 N SER L 30A 52.170 16.303 47.698 1.00 0.00 N
|
||||
ATOM 434 CA SER L 30A 51.329 15.409 46.920 1.00 0.00 C
|
||||
ATOM 435 C SER L 30A 52.015 14.812 45.685 1.00 0.00 C
|
||||
ATOM 436 O SER L 30A 51.350 14.366 44.764 1.00 0.00 O
|
||||
ATOM 437 CB SER L 30A 50.082 16.156 46.488 1.00 0.00 C
|
||||
ATOM 438 OG SER L 30A 49.348 16.592 47.599 1.00 0.00 O
|
||||
ATOM 439 H SER L 30A 52.421 16.046 48.642 1.00 0.00 H
|
||||
ATOM 440 HA SER L 30A 50.943 14.567 47.497 1.00 0.00 H
|
||||
ATOM 441 1HB SER L 30A 50.364 17.013 45.876 1.00 0.00 H
|
||||
ATOM 442 2HB SER L 30A 49.463 15.505 45.873 1.00 0.00 H
|
||||
ATOM 443 HG SER L 30A 49.931 17.176 48.090 1.00 0.00 H
|
||||
ATOM 444 N SER L 31 53.347 14.792 45.683 1.00 0.00 N
|
||||
ATOM 445 CA SER L 31 54.094 14.259 44.549 1.00 0.00 C
|
||||
ATOM 446 C SER L 31 53.734 14.959 43.242 1.00 0.00 C
|
||||
ATOM 447 O SER L 31 53.703 14.356 42.179 1.00 0.00 O
|
||||
ATOM 448 CB SER L 31 53.835 12.771 44.418 1.00 0.00 C
|
||||
ATOM 449 OG SER L 31 54.240 12.087 45.572 1.00 0.00 O
|
||||
ATOM 450 H SER L 31 53.852 15.150 46.480 1.00 0.00 H
|
||||
ATOM 451 HA SER L 31 55.175 14.292 44.689 1.00 0.00 H
|
||||
ATOM 452 1HB SER L 31 52.774 12.600 44.243 1.00 0.00 H
|
||||
ATOM 453 2HB SER L 31 54.375 12.383 43.555 1.00 0.00 H
|
||||
ATOM 454 HG SER L 31 53.773 11.248 45.560 1.00 0.00 H
|
||||
ATOM 455 N TYR L 32 53.460 16.259 43.402 1.00 0.00 N
|
||||
ATOM 456 CA TYR L 32 53.176 17.161 42.301 1.00 0.00 C
|
||||
ATOM 457 C TYR L 32 54.489 17.641 41.668 1.00 0.00 C
|
||||
ATOM 458 O TYR L 32 54.910 18.762 41.892 1.00 0.00 O
|
||||
ATOM 459 CB TYR L 32 52.342 18.352 42.780 1.00 0.00 C
|
||||
ATOM 460 CG TYR L 32 50.880 18.031 42.990 1.00 0.00 C
|
||||
ATOM 461 CD1 TYR L 32 50.294 16.936 42.371 1.00 0.00 C
|
||||
ATOM 462 CD2 TYR L 32 50.089 18.824 43.807 1.00 0.00 C
|
||||
ATOM 463 CE1 TYR L 32 48.958 16.639 42.559 1.00 0.00 C
|
||||
ATOM 464 CE2 TYR L 32 48.751 18.535 44.002 1.00 0.00 C
|
||||
ATOM 465 CZ TYR L 32 48.190 17.441 43.376 1.00 0.00 C
|
||||
ATOM 466 OH TYR L 32 46.859 17.150 43.569 1.00 0.00 O
|
||||
ATOM 467 H TYR L 32 53.456 16.618 44.347 1.00 0.00 H
|
||||
ATOM 468 HA TYR L 32 52.651 16.625 41.509 1.00 0.00 H
|
||||
ATOM 469 1HB TYR L 32 52.778 18.693 43.721 1.00 0.00 H
|
||||
ATOM 470 2HB TYR L 32 52.439 19.136 42.030 1.00 0.00 H
|
||||
ATOM 471 HD1 TYR L 32 50.908 16.305 41.727 1.00 0.00 H
|
||||
ATOM 472 HD2 TYR L 32 50.537 19.687 44.299 1.00 0.00 H
|
||||
ATOM 473 HE1 TYR L 32 48.512 15.775 42.066 1.00 0.00 H
|
||||
ATOM 474 HE2 TYR L 32 48.145 19.172 44.648 1.00 0.00 H
|
||||
ATOM 475 HH TYR L 32 46.462 17.658 44.280 1.00 0.00 H
|
||||
self.entryPDBwithInsertioncodes="""ATOM 406 N VAL L 29 58.041 17.797 48.254 1.00 0.00 N
|
||||
ATOM 407 CA VAL L 29 57.124 18.088 47.170 1.00 0.00 C
|
||||
ATOM 408 C VAL L 29 55.739 17.571 47.538 1.00 0.00 C
|
||||
ATOM 409 O VAL L 29 55.535 16.362 47.550 1.00 0.00 O
|
||||
ATOM 410 CB VAL L 29 57.580 17.456 45.842 1.00 0.00 C
|
||||
ATOM 411 CG1 VAL L 29 56.571 17.743 44.741 1.00 0.00 C
|
||||
ATOM 412 CG2 VAL L 29 58.957 17.973 45.450 1.00 0.00 C
|
||||
ATOM 413 H VAL L 29 58.603 16.959 48.212 1.00 0.00 H
|
||||
ATOM 414 HA VAL L 29 57.012 19.163 47.024 1.00 0.00 H
|
||||
ATOM 415 HB VAL L 29 57.674 16.378 45.977 1.00 0.00 H
|
||||
ATOM 416 1HG1 VAL L 29 56.909 17.289 43.809 1.00 0.00 H
|
||||
ATOM 417 2HG1 VAL L 29 55.603 17.327 45.016 1.00 0.00 H
|
||||
ATOM 418 3HG1 VAL L 29 56.479 18.821 44.604 1.00 0.00 H
|
||||
ATOM 419 1HG2 VAL L 29 59.263 17.515 44.510 1.00 0.00 H
|
||||
ATOM 420 2HG2 VAL L 29 58.917 19.055 45.331 1.00 0.00 H
|
||||
ATOM 421 3HG2 VAL L 29 59.676 17.719 46.229 1.00 0.00 H
|
||||
ATOM 422 N SER L 30 54.838 18.500 47.837 1.00 0.00 N
|
||||
ATOM 423 CA SER L 30 53.494 18.162 48.273 1.00 0.00 C
|
||||
ATOM 424 C SER L 30 52.725 17.364 47.221 1.00 0.00 C
|
||||
ATOM 425 O SER L 30 52.723 17.697 46.056 1.00 0.00 O
|
||||
ATOM 426 CB SER L 30 52.734 19.429 48.610 1.00 0.00 C
|
||||
ATOM 427 OG SER L 30 51.403 19.143 48.941 1.00 0.00 O
|
||||
ATOM 428 H SER L 30 55.100 19.472 47.757 1.00 0.00 H
|
||||
ATOM 429 HA SER L 30 53.471 17.585 49.199 1.00 0.00 H
|
||||
ATOM 430 1HB SER L 30 53.219 19.934 49.445 1.00 0.00 H
|
||||
ATOM 431 2HB SER L 30 52.761 20.107 47.758 1.00 0.00 H
|
||||
ATOM 432 HG SER L 30 50.919 19.965 48.828 1.00 0.00 H
|
||||
ATOM 433 N SER L 30A 52.170 16.303 47.698 1.00 0.00 N
|
||||
ATOM 434 CA SER L 30A 51.329 15.409 46.920 1.00 0.00 C
|
||||
ATOM 435 C SER L 30A 52.015 14.812 45.685 1.00 0.00 C
|
||||
ATOM 436 O SER L 30A 51.350 14.366 44.764 1.00 0.00 O
|
||||
ATOM 437 CB SER L 30A 50.082 16.156 46.488 1.00 0.00 C
|
||||
ATOM 438 OG SER L 30A 49.348 16.592 47.599 1.00 0.00 O
|
||||
ATOM 439 H SER L 30A 52.421 16.046 48.642 1.00 0.00 H
|
||||
ATOM 440 HA SER L 30A 50.943 14.567 47.497 1.00 0.00 H
|
||||
ATOM 441 1HB SER L 30A 50.364 17.013 45.876 1.00 0.00 H
|
||||
ATOM 442 2HB SER L 30A 49.463 15.505 45.873 1.00 0.00 H
|
||||
ATOM 443 HG SER L 30A 49.931 17.176 48.090 1.00 0.00 H
|
||||
ATOM 444 N SER L 31 53.347 14.792 45.683 1.00 0.00 N
|
||||
ATOM 445 CA SER L 31 54.094 14.259 44.549 1.00 0.00 C
|
||||
ATOM 446 C SER L 31 53.734 14.959 43.242 1.00 0.00 C
|
||||
ATOM 447 O SER L 31 53.703 14.356 42.179 1.00 0.00 O
|
||||
ATOM 448 CB SER L 31 53.835 12.771 44.418 1.00 0.00 C
|
||||
ATOM 449 OG SER L 31 54.240 12.087 45.572 1.00 0.00 O
|
||||
ATOM 450 H SER L 31 53.852 15.150 46.480 1.00 0.00 H
|
||||
ATOM 451 HA SER L 31 55.175 14.292 44.689 1.00 0.00 H
|
||||
ATOM 452 1HB SER L 31 52.774 12.600 44.243 1.00 0.00 H
|
||||
ATOM 453 2HB SER L 31 54.375 12.383 43.555 1.00 0.00 H
|
||||
ATOM 454 HG SER L 31 53.773 11.248 45.560 1.00 0.00 H
|
||||
ATOM 455 N TYR L 32 53.460 16.259 43.402 1.00 0.00 N
|
||||
ATOM 456 CA TYR L 32 53.176 17.161 42.301 1.00 0.00 C
|
||||
ATOM 457 C TYR L 32 54.489 17.641 41.668 1.00 0.00 C
|
||||
ATOM 458 O TYR L 32 54.910 18.762 41.892 1.00 0.00 O
|
||||
ATOM 459 CB TYR L 32 52.342 18.352 42.780 1.00 0.00 C
|
||||
ATOM 460 CG TYR L 32 50.880 18.031 42.990 1.00 0.00 C
|
||||
ATOM 461 CD1 TYR L 32 50.294 16.936 42.371 1.00 0.00 C
|
||||
ATOM 462 CD2 TYR L 32 50.089 18.824 43.807 1.00 0.00 C
|
||||
ATOM 463 CE1 TYR L 32 48.958 16.639 42.559 1.00 0.00 C
|
||||
ATOM 464 CE2 TYR L 32 48.751 18.535 44.002 1.00 0.00 C
|
||||
ATOM 465 CZ TYR L 32 48.190 17.441 43.376 1.00 0.00 C
|
||||
ATOM 466 OH TYR L 32 46.859 17.150 43.569 1.00 0.00 O
|
||||
ATOM 467 H TYR L 32 53.456 16.618 44.347 1.00 0.00 H
|
||||
ATOM 468 HA TYR L 32 52.651 16.625 41.509 1.00 0.00 H
|
||||
ATOM 469 1HB TYR L 32 52.778 18.693 43.721 1.00 0.00 H
|
||||
ATOM 470 2HB TYR L 32 52.439 19.136 42.030 1.00 0.00 H
|
||||
ATOM 471 HD1 TYR L 32 50.908 16.305 41.727 1.00 0.00 H
|
||||
ATOM 472 HD2 TYR L 32 50.537 19.687 44.299 1.00 0.00 H
|
||||
ATOM 473 HE1 TYR L 32 48.512 15.775 42.066 1.00 0.00 H
|
||||
ATOM 474 HE2 TYR L 32 48.145 19.172 44.648 1.00 0.00 H
|
||||
ATOM 475 HH TYR L 32 46.462 17.658 44.280 1.00 0.00 H
|
||||
"""
|
||||
output, error = run_exec(self.entryPDBwithInsertioncodes,
|
||||
"babel -ipdb -ofasta")
|
||||
|
||||
@@ -14,11 +14,9 @@ In both cases, the test file is run directly from the source folder,
|
||||
and so you can quickly develop the tests and try them out.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import pdb
|
||||
|
||||
from testbabel import run_exec, executable, log, BaseTest
|
||||
from testbabel import run_exec, BaseTest
|
||||
|
||||
def checkmatch(query, molecules):
|
||||
result = []
|
||||
@@ -69,7 +67,7 @@ class TestSmartsSym(BaseTest):
|
||||
self.assertEqual(fastcheckmatch(data[2], data[0:6]),
|
||||
[False, True, True, False, False, False])
|
||||
self.assertEqual(fastcheckmatch(data[4], data[0:6]), [True]*6)
|
||||
|
||||
|
||||
def testTetStereoImplicitH(self):
|
||||
data = ['[C@H](Br)(Cl)I',
|
||||
'[C@@H](Br)(Cl)I',
|
||||
@@ -99,7 +97,7 @@ class TestSmartsSym(BaseTest):
|
||||
self.assertEqual(fastcheckmatch(data[2], data[0:6]),
|
||||
[False, True, True, False, False, False])
|
||||
self.assertEqual(fastcheckmatch(data[5], data[0:6]), [True]*6)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
testsuite = []
|
||||
|
||||
+12
-12
@@ -17,7 +17,7 @@ and so you can quickly develop the tests and try them out.
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from testbabel import run_exec, executable, log, BaseTest
|
||||
from testbabel import run_exec, BaseTest
|
||||
|
||||
class TestSym(BaseTest):
|
||||
"""Base class for a series of tests relating to symmetry"""
|
||||
@@ -95,7 +95,7 @@ class TestCisTransSym(TestSym):
|
||||
self.inchi = "InChI=1S/C4H4BrCl/c5-3-1-2-4-6/h1-4H/b3-1-,4-2+"
|
||||
self.smiles = [
|
||||
"C(=C\C=C/Br)/Cl",
|
||||
"Cl/C=C/C=C\Br",
|
||||
"Cl/C=C/C=C\Br",
|
||||
"Br/C=C\C=C\Cl",
|
||||
"C(=C\Cl)/C=C\Br",
|
||||
"C(=C\C=C\Cl)\Br",
|
||||
@@ -136,7 +136,7 @@ class TestRingBondCisTransSym(TestSym):
|
||||
|
||||
class TestConversions(BaseTest):
|
||||
"""A series of tests relating to file format conversions and symmetry"""
|
||||
|
||||
|
||||
def setUp(self):
|
||||
self.canFindExecutable("babel")
|
||||
self.data = [
|
||||
@@ -154,7 +154,7 @@ class TestConversions(BaseTest):
|
||||
(r"I/C=C\1/NC1", r"I/C=C/1\CN1", "InChI=1S/C3H4IN/c4-1-3-2-5-3/h1,5H,2H2/b3-1+"),
|
||||
(r"I/C=C/1\NC1", r"I/C=C\1/CN1", "InChI=1S/C3H4IN/c4-1-3-2-5-3/h1,5H,2H2/b3-1-"),
|
||||
]
|
||||
|
||||
|
||||
def testSMILEStoInChI(self):
|
||||
# Tests interconversions between the SMILES on the left versus
|
||||
# the InChI on the right.
|
||||
@@ -164,7 +164,7 @@ class TestConversions(BaseTest):
|
||||
self.assertEqual(output.rstrip(), inchi)
|
||||
output, error = run_exec(inchi, "babel -iinchi -ocan")
|
||||
self.assertEqual(output.rstrip(), can)
|
||||
|
||||
|
||||
def parseMDL(self, text):
|
||||
lines = text.split("\n")
|
||||
broken = lines[3].split()
|
||||
@@ -186,7 +186,7 @@ class TestConversions(BaseTest):
|
||||
output, error = run_exec(smi, "obabel -ismi --gen2d -omdl")
|
||||
output, error = run_exec(output.rstrip(), "obabel -imdl -ocan")
|
||||
self.assertEqual(can, output.rstrip())
|
||||
|
||||
|
||||
def testSMILESto3DMDL(self):
|
||||
"""Test interconversion between SMILES and 3D MDL"""
|
||||
data = [
|
||||
@@ -247,10 +247,10 @@ class TestConversions(BaseTest):
|
||||
|
||||
smiles, can = self.data[i][0:2]
|
||||
output, error = run_exec(smiles, "babel -ismi -oxyz --gen3d")
|
||||
|
||||
|
||||
canoutput, error = run_exec(output, "babel -ixyz -ocan")
|
||||
self.assertEqual(canoutput.rstrip(), can)
|
||||
|
||||
|
||||
sdfoutput, error = run_exec(output, "babel -ixyz -osdf")
|
||||
atoms, bonds = self.parseMDL(sdfoutput)
|
||||
parities = [atom['parity'] for atom in atoms]
|
||||
@@ -266,7 +266,7 @@ class TestConversions(BaseTest):
|
||||
# The following file was created using RDKit starting from
|
||||
# the SMILES strings in data[x][0] below.
|
||||
filename = self.getTestFile("testsym_2Dtests.sdf")
|
||||
|
||||
|
||||
output, error = run_exec("babel -isdf %s -ocan" % filename)
|
||||
for i, smiles in enumerate(output.rstrip().split("\n")):
|
||||
self.assertEqual(smiles.rstrip(), self.data[i][1])
|
||||
@@ -302,7 +302,7 @@ class TestConversions(BaseTest):
|
||||
finaloutput, error = run_exec(output, "obabel -isdf -ocan")
|
||||
for line in finaloutput.rstrip().split("\n"):
|
||||
result, correct_answer = line.split()
|
||||
self.assertEqual(result, correct_answer)
|
||||
self.assertEqual(result, correct_answer)
|
||||
|
||||
def testSMILESto0DMDL(self):
|
||||
"""Test interconversion between SMILES and 0D MDL"""
|
||||
@@ -339,7 +339,7 @@ class TestStereoConversion(BaseTest):
|
||||
test_inchi = 'InChI=1S/C10H10/c1-2-3-7-10-8-5-4-6-9-10/h2-9H,1H2/b7-3+'
|
||||
output, error = run_exec(test_inchi, "babel -iinchi -osmi")
|
||||
self.assertEqual(output.rstrip(), "C=C/C=C/c1ccccc1")
|
||||
|
||||
|
||||
test_smiles = "C=C\C=C/c1ccccc1"
|
||||
output, error = run_exec(test_smiles, "babel -ismi -oinchi")
|
||||
self.assertEqual(output.rstrip(), "InChI=1S/C10H10/c1-2-3-7-10-8-5-4-6-9-10/h2-9H,1H2/b7-3-")
|
||||
@@ -359,6 +359,6 @@ class TestStereoConversion(BaseTest):
|
||||
self.assertEqual(output.rstrip(), smi)
|
||||
|
||||
del TestSym # remove base class to avoid tests
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
+1
-2
@@ -14,7 +14,6 @@ In both cases, the test file is run directly from the source folder,
|
||||
and so you can quickly develop the tests and try them out.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from testbabel import run_exec, BaseTest
|
||||
@@ -52,6 +51,6 @@ C([2H])([2H])([2H])[2H] deuteromethane"""
|
||||
output, error = run_exec(self.smiles,
|
||||
"babel -ismi -osmi --unique %s" % param[0])
|
||||
self.assertConverted(error, param[1])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user