Skip to content
Snippets Groups Projects
Commit aeae320c authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

handle arbitrary MOL headers from OpenBabel in conversion tests

for #83


Former-commit-id: 4cfe727da7da6c926d681be67edfe780b3d14d73
parent 15810121
No related branches found
No related tags found
No related merge requests found
import re
from django.test import TestCase
from openbabel import vectorUnsignedInt
......@@ -5,16 +7,20 @@ from .models import Compound, CompoundTanimoto, create_tanimoto
from .utils import FingerPrinter, mol2smi, smi2mol
class MolSmiTestCase(TestCase):
"""
Test MOL to SMILES and SMILES to MOL format conversion functions
"""
def setUp(self):
self.smiles_str = "C"
self.mol_str = "\n OpenBabel09041811452D\n\n 1 0 0 0 0 0 0 0 0 0999 V2000\n 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\nM END\n"
# the MOL version is also a valid regexp to validate arbitrary name in the openbabel-generated version
self.mol_str = "\n OpenBabel[0-9]{11}D\n\n 1 0 0 0 0 0 0 0 0 0999 V2000\n 1.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\nM END\n"
def test_mol2smi(self):
self.assertEqual(mol2smi(self.mol_str), self.smiles_str)
def test_smi2mol(self):
self.assertEqual(smi2mol(self.smiles_str), self.mol_str)
def test_smi2mol2smi(self):
self.assertTrue(re.compile(self.mol_str).match(smi2mol(self.smiles_str)))
class FingerPrinterTestCase(TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment