openff-toolkit 0.18.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- devtools/scripts/build_cookiecutter_json.py +22 -0
- docs/conf.py +296 -0
- docs/conftest.py +23 -0
- examples/conformer_energies/conformer_energies.py +143 -0
- examples/deprecated/SMIRNOFF_comparison/compare_molecule_energies.py +48 -0
- examples/deprecated/SMIRNOFF_comparison/compare_set_energies.py +58 -0
- examples/deprecated/liquid_box/create_mol2_pdb/create_mol2_pdb.py +193 -0
- examples/deprecated/liquid_box/openff_simulation.py +72 -0
- examples/deprecated/mixedFF_structure/generate_mixedFF_complex.py +56 -0
- examples/deprecated/testing/test_impropers/tleap_tools.py +120 -0
- examples/examples_helper.py +61 -0
- openff/toolkit/__init__.py +101 -0
- openff/toolkit/_tests/__init__.py +0 -0
- openff/toolkit/_tests/_stale_tests.py +146 -0
- openff/toolkit/_tests/conftest.py +108 -0
- openff/toolkit/_tests/create_molecules.py +494 -0
- openff/toolkit/_tests/mocking.py +145 -0
- openff/toolkit/_tests/molecule/__init__.py +1 -0
- openff/toolkit/_tests/molecule/test_state_enumeration.py +302 -0
- openff/toolkit/_tests/test_energies.py +136 -0
- openff/toolkit/_tests/test_examples.py +109 -0
- openff/toolkit/_tests/test_forcefield.py +3864 -0
- openff/toolkit/_tests/test_interchange.py +19 -0
- openff/toolkit/_tests/test_io.py +19 -0
- openff/toolkit/_tests/test_links.py +73 -0
- openff/toolkit/_tests/test_mm_molecule.py +404 -0
- openff/toolkit/_tests/test_molecule.py +4246 -0
- openff/toolkit/_tests/test_nagl.py +169 -0
- openff/toolkit/_tests/test_parameter_plugins.py +89 -0
- openff/toolkit/_tests/test_parameters.py +2898 -0
- openff/toolkit/_tests/test_toolkit_io.py +1088 -0
- openff/toolkit/_tests/test_toolkits.py +4418 -0
- openff/toolkit/_tests/test_topology.py +2485 -0
- openff/toolkit/_tests/test_utils.py +101 -0
- openff/toolkit/_tests/test_utils_callback.py +178 -0
- openff/toolkit/_tests/test_utils_collections.py +263 -0
- openff/toolkit/_tests/test_utils_serialization.py +168 -0
- openff/toolkit/_tests/utils.py +1747 -0
- openff/toolkit/data/README.md +8 -0
- openff/toolkit/data/molecules/AlkEthOH_test_filt1_ff.mol2 +2026 -0
- openff/toolkit/data/molecules/AlkEthOH_test_filt1_tripos.mol2 +2026 -0
- openff/toolkit/data/molecules/AlkEthOH_tripos.tar.gz +0 -0
- openff/toolkit/data/molecules/CID20742535_anion.sdf +50 -0
- openff/toolkit/data/molecules/CID20742535_neutral.sdf +51 -0
- openff/toolkit/data/molecules/FreeSolv.tar.gz +0 -0
- openff/toolkit/data/molecules/MiniDrugBank.sdf +33988 -0
- openff/toolkit/data/molecules/MiniDrugBank_tripos.mol2 +35462 -0
- openff/toolkit/data/molecules/PT2385.sdf +90 -0
- openff/toolkit/data/molecules/QL8.sdf +401 -0
- openff/toolkit/data/molecules/README.md +21 -0
- openff/toolkit/data/molecules/benzene.crd +8 -0
- openff/toolkit/data/molecules/benzene.mol2 +34 -0
- openff/toolkit/data/molecules/benzene.top +166 -0
- openff/toolkit/data/molecules/butane_multi.sdf +231 -0
- openff/toolkit/data/molecules/cyclohexane.mol2 +44 -0
- openff/toolkit/data/molecules/ethanol.mol2 +25 -0
- openff/toolkit/data/molecules/ethanol.sdf +23 -0
- openff/toolkit/data/molecules/ethanol_partial_charges.sdf +26 -0
- openff/toolkit/data/molecules/ethanol_reordered.mol2 +25 -0
- openff/toolkit/data/molecules/ethanol_reordered.sdf +23 -0
- openff/toolkit/data/molecules/ethene_rdkit.sdf +17 -0
- openff/toolkit/data/molecules/laromustine_ff.mol2 +71 -0
- openff/toolkit/data/molecules/laromustine_tripos.mol2 +71 -0
- openff/toolkit/data/molecules/methane_multiconformer.sdf +32 -0
- openff/toolkit/data/molecules/methane_multiconformer_properties.sdf +45 -0
- openff/toolkit/data/molecules/nh4.pdb +7 -0
- openff/toolkit/data/molecules/po4_phenylphosphate.pdb +46 -0
- openff/toolkit/data/molecules/ruxolitinib_conformers.sdf +910 -0
- openff/toolkit/data/molecules/toluene.mol2 +38 -0
- openff/toolkit/data/molecules/toluene.mol2.gz +0 -0
- openff/toolkit/data/molecules/toluene.pdb +30 -0
- openff/toolkit/data/molecules/toluene.sdf +36 -0
- openff/toolkit/data/molecules/toluene_charged.mol2 +38 -0
- openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf +23 -0
- openff/toolkit/data/proteins/5tbm_complex_solv.pdb +1928 -0
- openff/toolkit/data/proteins/5tbm_complex_solv_box.pdb +19563 -0
- openff/toolkit/data/proteins/CTerminal_ALA.pdb +20 -0
- openff/toolkit/data/proteins/CTerminal_ALA.sdf +43 -0
- openff/toolkit/data/proteins/CTerminal_ALA_ALA.pdb +30 -0
- openff/toolkit/data/proteins/CTerminal_ALA_ALA_misnamedH.pdb +30 -0
- openff/toolkit/data/proteins/CTerminal_ARG.pdb +34 -0
- openff/toolkit/data/proteins/CTerminal_TRP.pdb +34 -0
- openff/toolkit/data/proteins/MainChain_ALA.pdb +25 -0
- openff/toolkit/data/proteins/MainChain_ALA.sdf +52 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA.pdb +35 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA.sdf +69 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA_icodes.pdb +35 -0
- openff/toolkit/data/proteins/MainChain_ALA_ALA_no_hydrogens.pdb +17 -0
- openff/toolkit/data/proteins/MainChain_ARG.pdb +39 -0
- openff/toolkit/data/proteins/MainChain_ARG.sdf +81 -0
- openff/toolkit/data/proteins/MainChain_CYM.pdb +25 -0
- openff/toolkit/data/proteins/MainChain_CYS.pdb +26 -0
- openff/toolkit/data/proteins/MainChain_CYX.pdb +48 -0
- openff/toolkit/data/proteins/MainChain_CYX.sdf +96 -0
- openff/toolkit/data/proteins/MainChain_GLH.sdf +64 -0
- openff/toolkit/data/proteins/MainChain_GLU.sdf +63 -0
- openff/toolkit/data/proteins/MainChain_HID.pdb +32 -0
- openff/toolkit/data/proteins/MainChain_HIE.pdb +32 -0
- openff/toolkit/data/proteins/MainChain_HIE.sdf +67 -0
- openff/toolkit/data/proteins/MainChain_HIP.pdb +33 -0
- openff/toolkit/data/proteins/MainChain_HIP.sdf +70 -0
- openff/toolkit/data/proteins/MainChain_PRO.pdb +29 -0
- openff/toolkit/data/proteins/MainChain_TRP.pdb +39 -0
- openff/toolkit/data/proteins/NTerminal_ALA.pdb +21 -0
- openff/toolkit/data/proteins/NTerminal_ALA.sdf +45 -0
- openff/toolkit/data/proteins/NTerminal_ALA_ALA.pdb +31 -0
- openff/toolkit/data/proteins/NTerminal_ARG.pdb +35 -0
- openff/toolkit/data/proteins/NTerminal_TRP.pdb +35 -0
- openff/toolkit/data/proteins/T4-protein-unprocessed-4w51.pdb +1892 -0
- openff/toolkit/data/proteins/T4-protein.mol2 +5461 -0
- openff/toolkit/data/proteins/T4-protein.pdb +2637 -0
- openff/toolkit/data/proteins/T4-protein.sdf +5318 -0
- openff/toolkit/data/proteins/T4_protein_waters.pdb +2965 -0
- openff/toolkit/data/proteins/TwoMol_SER_CYS.pdb +50 -0
- openff/toolkit/data/proteins/aa_residues_substructures_explicit_bond_orders_with_caps.json +6435 -0
- openff/toolkit/data/proteins/aa_residues_substructures_explicit_bond_orders_with_caps_explicit_connectivity.json +6675 -0
- openff/toolkit/data/proteins/aa_residues_substructures_with_caps.json +6297 -0
- openff/toolkit/data/proteins/ace-ZZZ-gly-nme.pdb +78 -0
- openff/toolkit/data/proteins/ace-ZZZ-gly-nme.sdf +98 -0
- openff/toolkit/data/proteins/ace-a10-nme.sdf +229 -0
- openff/toolkit/data/proteins/ace-ala-nh2.pdb +21 -0
- openff/toolkit/data/proteins/fluoresceine_dyed_helix_capped.pdb +338 -0
- openff/toolkit/data/proteins/neutral_arginine.pdb +31 -0
- openff/toolkit/data/proteins/split_chain.pdb +74 -0
- openff/toolkit/data/proteins/split_chain_reordered.pdb +74 -0
- openff/toolkit/data/reference_energies/README.md +6 -0
- openff/toolkit/data/reference_energies/reference_0.8.0.json +1 -0
- openff/toolkit/data/reference_energies/reference_0.8.0.json.txt +180 -0
- openff/toolkit/data/reference_energies/reference_after_1007.json +1 -0
- openff/toolkit/data/reference_energies/reference_after_1007.json.txt +350 -0
- openff/toolkit/data/reference_energies/reference_after_802.json +1 -0
- openff/toolkit/data/reference_energies/reference_after_802.json.txt +291 -0
- openff/toolkit/data/systems/README.md +3 -0
- openff/toolkit/data/systems/amber/cyclohexane_ethanol_0.4_0.6.inpcrd +1511 -0
- openff/toolkit/data/systems/amber/cyclohexane_ethanol_0.4_0.6.prmtop +13367 -0
- openff/toolkit/data/systems/monomers/butanol.mol2 +38 -0
- openff/toolkit/data/systems/monomers/butanol.sdf +88 -0
- openff/toolkit/data/systems/monomers/cyclohexane.mol2 +45 -0
- openff/toolkit/data/systems/monomers/cyclohexane.sdf +105 -0
- openff/toolkit/data/systems/monomers/ethanol.mol2 +26 -0
- openff/toolkit/data/systems/monomers/ethanol.sdf +58 -0
- openff/toolkit/data/systems/monomers/methane.mol2 +18 -0
- openff/toolkit/data/systems/monomers/methane.sdf +38 -0
- openff/toolkit/data/systems/monomers/propane.mol2 +30 -0
- openff/toolkit/data/systems/monomers/propane.sdf +68 -0
- openff/toolkit/data/systems/monomers/tip3p_water.mol2 +14 -0
- openff/toolkit/data/systems/monomers/water.mol2 +14 -0
- openff/toolkit/data/systems/monomers/water.sdf +28 -0
- openff/toolkit/data/systems/packmol_boxes/cyclohexane_ethanol_0.4_0.6.pdb +6272 -0
- openff/toolkit/data/systems/packmol_boxes/cyclohexane_water.pdb +5524 -0
- openff/toolkit/data/systems/packmol_boxes/ethanol_water.pdb +5174 -0
- openff/toolkit/data/systems/packmol_boxes/propane_methane_butanol_0.2_0.3_0.5.pdb +7959 -0
- openff/toolkit/data/systems/test_systems/1_cyclohexane_1_ethanol.pdb +61 -0
- openff/toolkit/data/systems/test_systems/1_ethanol.pdb +24 -0
- openff/toolkit/data/systems/test_systems/1_ethanol_no_conect.pdb +15 -0
- openff/toolkit/data/systems/test_systems/1_ethanol_reordered.pdb +24 -0
- openff/toolkit/data/systems/test_systems/PE.pdb +67 -0
- openff/toolkit/data/systems/test_systems/README.md +3 -0
- openff/toolkit/data/systems/test_systems/T4_lysozyme_water_ions.pdb +29240 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH.offxml +61 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_GBSA.offxml +78 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_MDL.offxml +62 -0
- openff/toolkit/data/test_forcefields/Frosst_AlkEthOH_parmAtFrosst.offxml +64 -0
- openff/toolkit/data/test_forcefields/GBSA_HCT-1.0.offxml +21 -0
- openff/toolkit/data/test_forcefields/GBSA_OBC1-1.0.offxml +18 -0
- openff/toolkit/data/test_forcefields/GBSA_OBC2-1.0.offxml +18 -0
- openff/toolkit/data/test_forcefields/README.md +23 -0
- openff/toolkit/data/test_forcefields/ammonia_minimal.offxml +27 -0
- openff/toolkit/data/test_forcefields/benzene_minimal.offxml +29 -0
- openff/toolkit/data/test_forcefields/chargeincrement-test.offxml +16 -0
- openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs +85 -0
- openff/toolkit/data/test_forcefields/ion_charges.offxml +18 -0
- openff/toolkit/data/test_forcefields/mangled.offxml +9 -0
- openff/toolkit/data/test_forcefields/old/README.md +9 -0
- openff/toolkit/data/test_forcefields/old/hbonds.offxml +11 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_1.offxml +332 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_2.offxml +338 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml +329 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_1.offxml +342 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_2.offxml +348 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml +337 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_1.offxml +340 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_2.offxml +346 -0
- openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml +337 -0
- openff/toolkit/data/test_forcefields/smirff99Frosst_reference_0_1_spec.offxml +349 -0
- openff/toolkit/data/test_forcefields/smirnoff99Frosst_experimental.offxml +343 -0
- openff/toolkit/data/test_forcefields/smirnoff99Frosst_reference_0_1_spec.offxml +349 -0
- openff/toolkit/data/test_forcefields/smirnoff99Frosst_reference_0_2_spec.offxml +356 -0
- openff/toolkit/data/test_forcefields/test_forcefield.offxml +346 -0
- openff/toolkit/data/test_forcefields/tip3p.offxml +22 -0
- openff/toolkit/data/test_forcefields/unsupported_smirnoff_version.offxml +9 -0
- openff/toolkit/topology/__init__.py +43 -0
- openff/toolkit/topology/_mm_molecule.py +663 -0
- openff/toolkit/topology/molecule.py +6102 -0
- openff/toolkit/topology/topology.py +2555 -0
- openff/toolkit/typing/__init__.py +1 -0
- openff/toolkit/typing/engines/__init__.py +1 -0
- openff/toolkit/typing/engines/smirnoff/__init__.py +31 -0
- openff/toolkit/typing/engines/smirnoff/forcefield.py +1440 -0
- openff/toolkit/typing/engines/smirnoff/io.py +234 -0
- openff/toolkit/typing/engines/smirnoff/parameters.py +3839 -0
- openff/toolkit/typing/engines/smirnoff/plugins.py +91 -0
- openff/toolkit/utils/__init__.py +57 -0
- openff/toolkit/utils/_viz.py +104 -0
- openff/toolkit/utils/ambertools_wrapper.py +507 -0
- openff/toolkit/utils/base_wrapper.py +268 -0
- openff/toolkit/utils/builtin_wrapper.py +136 -0
- openff/toolkit/utils/callback.py +187 -0
- openff/toolkit/utils/collections.py +247 -0
- openff/toolkit/utils/constants.py +18 -0
- openff/toolkit/utils/exceptions.py +766 -0
- openff/toolkit/utils/nagl_wrapper.py +164 -0
- openff/toolkit/utils/openeye_wrapper.py +2750 -0
- openff/toolkit/utils/rdkit_wrapper.py +3302 -0
- openff/toolkit/utils/serialization.py +466 -0
- openff/toolkit/utils/toolkit_registry.py +509 -0
- openff/toolkit/utils/toolkits.py +217 -0
- openff/toolkit/utils/utils.py +805 -0
- openff_toolkit-0.18.0.dist-info/METADATA +109 -0
- openff_toolkit-0.18.0.dist-info/RECORD +231 -0
- openff_toolkit-0.18.0.dist-info/WHEEL +5 -0
- openff_toolkit-0.18.0.dist-info/licenses/LICENSE +21 -0
- openff_toolkit-0.18.0.dist-info/top_level.txt +5 -0
- utilities/deprecated/convert_frosst/convert_frcmod_0.1.py +251 -0
- utilities/deprecated/convert_frosst/convert_frcmod_0.2.py +249 -0
- utilities/deprecated/convert_frosst/convert_frcmod_0.3.py +249 -0
- utilities/make_substructure_dict/_cif_to_substructure_dict.py +955 -0
- utilities/make_substructure_dict/_make_chemical_substructures.py +46 -0
- utilities/make_substructure_dict/_make_metadata_assignment_substructures.py +35 -0
- utilities/test_plugins/custom_plugins/handler_plugins.py +48 -0
- utilities/test_plugins/setup.py +19 -0
|
@@ -0,0 +1,1088 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for I/O functionality of the toolkit wrappers
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import pathlib
|
|
7
|
+
import sys
|
|
8
|
+
import tempfile
|
|
9
|
+
from io import BytesIO, StringIO
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
import pytest
|
|
13
|
+
from numpy.testing import assert_allclose
|
|
14
|
+
|
|
15
|
+
from openff.toolkit import Quantity, unit
|
|
16
|
+
from openff.toolkit._tests import create_molecules
|
|
17
|
+
from openff.toolkit._tests.utils import requires_openeye, requires_rdkit
|
|
18
|
+
from openff.toolkit.topology.molecule import Molecule
|
|
19
|
+
from openff.toolkit.utils import OpenEyeToolkitWrapper, RDKitToolkitWrapper
|
|
20
|
+
from openff.toolkit.utils.exceptions import (
|
|
21
|
+
SMILESParseError,
|
|
22
|
+
UndefinedStereochemistryError,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
ETHANOL = create_molecules.create_ethanol()
|
|
26
|
+
ETHANOL.name = "ethanol"
|
|
27
|
+
|
|
28
|
+
# From https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL113/
|
|
29
|
+
CAFFEINE_2D_SDF = """\
|
|
30
|
+
caffeine
|
|
31
|
+
RDKit 2D
|
|
32
|
+
|
|
33
|
+
14 15 0 0 0 0 0 0 0 0999 V2000
|
|
34
|
+
-1.1875 -9.6542 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
35
|
+
-1.1875 -8.9625 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
36
|
+
-1.8125 -10.0292 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
37
|
+
-2.4167 -8.9625 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
38
|
+
-2.4167 -9.6542 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
39
|
+
-1.8125 -8.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
40
|
+
-0.5000 -9.8917 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
41
|
+
-0.5000 -8.7625 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
42
|
+
-0.1125 -9.3042 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
43
|
+
-3.0250 -10.0375 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
44
|
+
-1.8125 -7.8917 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
45
|
+
-1.8125 -10.7417 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
46
|
+
-3.0250 -8.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
47
|
+
-0.2917 -8.0750 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
48
|
+
2 1 2 0
|
|
49
|
+
3 1 1 0
|
|
50
|
+
4 5 1 0
|
|
51
|
+
5 3 1 0
|
|
52
|
+
6 2 1 0
|
|
53
|
+
7 1 1 0
|
|
54
|
+
8 2 1 0
|
|
55
|
+
9 7 2 0
|
|
56
|
+
10 5 2 0
|
|
57
|
+
11 6 2 0
|
|
58
|
+
12 3 1 0
|
|
59
|
+
13 4 1 0
|
|
60
|
+
14 8 1 0
|
|
61
|
+
9 8 1 0
|
|
62
|
+
4 6 1 0
|
|
63
|
+
M END
|
|
64
|
+
|
|
65
|
+
> <chembl_id>
|
|
66
|
+
CHEMBL113
|
|
67
|
+
|
|
68
|
+
> <chembl_pref_name>
|
|
69
|
+
CAFFEINE
|
|
70
|
+
|
|
71
|
+
$$$$
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
CAFFEINE_2D_COORDS = Quantity(
|
|
75
|
+
np.array(
|
|
76
|
+
[
|
|
77
|
+
(-1.1875, -9.6542, 0.0000),
|
|
78
|
+
(-1.1875, -8.9625, 0.0000),
|
|
79
|
+
(-1.8125, -10.0292, 0.0000),
|
|
80
|
+
(-2.4167, -8.9625, 0.0000),
|
|
81
|
+
(-2.4167, -9.6542, 0.0000),
|
|
82
|
+
(-1.8125, -8.6000, 0.0000),
|
|
83
|
+
(-0.5000, -9.8917, 0.0000),
|
|
84
|
+
(-0.5000, -8.7625, 0.0000),
|
|
85
|
+
(-0.1125, -9.3042, 0.0000),
|
|
86
|
+
(-3.0250, -10.0375, 0.0000),
|
|
87
|
+
(-1.8125, -7.8917, 0.0000),
|
|
88
|
+
(-1.8125, -10.7417, 0.0000),
|
|
89
|
+
(-3.0250, -8.6000, 0.0000),
|
|
90
|
+
(-0.2917, -8.0750, 0.0000),
|
|
91
|
+
],
|
|
92
|
+
np.double,
|
|
93
|
+
),
|
|
94
|
+
unit.angstrom,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# From https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL113/
|
|
99
|
+
CAFFEINE_SMI = "Cn1c(=O)c2c(ncn2C)n(C)c1=O CHEMBL113\n"
|
|
100
|
+
|
|
101
|
+
# From https://pubchem.ncbi.nlm.nih.gov/compound/2519#section=2D-Structure
|
|
102
|
+
CAFFEINE_3D_SDF = """\
|
|
103
|
+
2519
|
|
104
|
+
-OEChem-07012107543D
|
|
105
|
+
|
|
106
|
+
24 25 0 0 0 0 0 0 0999 V2000
|
|
107
|
+
0.4700 2.5688 0.0006 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
108
|
+
-3.1271 -0.4436 -0.0003 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
109
|
+
-0.9686 -1.3125 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
110
|
+
2.2182 0.1412 -0.0003 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
111
|
+
-1.3477 1.0797 -0.0001 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
112
|
+
1.4119 -1.9372 0.0002 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
113
|
+
0.8579 0.2592 -0.0008 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
114
|
+
0.3897 -1.0264 -0.0004 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
115
|
+
0.0307 1.4220 -0.0006 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
116
|
+
-1.9061 -0.2495 -0.0004 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
117
|
+
2.5032 -1.1998 0.0003 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
118
|
+
-1.4276 -2.6960 0.0008 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
119
|
+
3.1926 1.2061 0.0003 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
120
|
+
-2.2969 2.1881 0.0007 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
121
|
+
3.5163 -1.5787 0.0008 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
122
|
+
-1.0451 -3.1973 -0.8937 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
123
|
+
-2.5186 -2.7596 0.0011 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
124
|
+
-1.0447 -3.1963 0.8957 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
125
|
+
4.1992 0.7801 0.0002 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
126
|
+
3.0468 1.8092 -0.8992 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
127
|
+
3.0466 1.8083 0.9004 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
128
|
+
-1.8087 3.1651 -0.0003 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
129
|
+
-2.9322 2.1027 0.8881 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
130
|
+
-2.9346 2.1021 -0.8849 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
131
|
+
1 9 2 0 0 0 0
|
|
132
|
+
2 10 2 0 0 0 0
|
|
133
|
+
3 8 1 0 0 0 0
|
|
134
|
+
3 10 1 0 0 0 0
|
|
135
|
+
3 12 1 0 0 0 0
|
|
136
|
+
4 7 1 0 0 0 0
|
|
137
|
+
4 11 1 0 0 0 0
|
|
138
|
+
4 13 1 0 0 0 0
|
|
139
|
+
5 9 1 0 0 0 0
|
|
140
|
+
5 10 1 0 0 0 0
|
|
141
|
+
5 14 1 0 0 0 0
|
|
142
|
+
6 8 1 0 0 0 0
|
|
143
|
+
6 11 2 0 0 0 0
|
|
144
|
+
7 8 2 0 0 0 0
|
|
145
|
+
7 9 1 0 0 0 0
|
|
146
|
+
11 15 1 0 0 0 0
|
|
147
|
+
12 16 1 0 0 0 0
|
|
148
|
+
12 17 1 0 0 0 0
|
|
149
|
+
12 18 1 0 0 0 0
|
|
150
|
+
13 19 1 0 0 0 0
|
|
151
|
+
13 20 1 0 0 0 0
|
|
152
|
+
13 21 1 0 0 0 0
|
|
153
|
+
14 22 1 0 0 0 0
|
|
154
|
+
14 23 1 0 0 0 0
|
|
155
|
+
14 24 1 0 0 0 0
|
|
156
|
+
M END
|
|
157
|
+
> <PUBCHEM_COMPOUND_CID>
|
|
158
|
+
2519
|
|
159
|
+
|
|
160
|
+
> <PUBCHEM_CONFORMER_RMSD>
|
|
161
|
+
0.4
|
|
162
|
+
|
|
163
|
+
> <PUBCHEM_CONFORMER_DIVERSEORDER>
|
|
164
|
+
1
|
|
165
|
+
|
|
166
|
+
> <PUBCHEM_MMFF94_PARTIAL_CHARGES>
|
|
167
|
+
15
|
|
168
|
+
1 -0.57
|
|
169
|
+
10 0.69
|
|
170
|
+
11 0.04
|
|
171
|
+
12 0.3
|
|
172
|
+
13 0.26
|
|
173
|
+
14 0.3
|
|
174
|
+
15 0.15
|
|
175
|
+
2 -0.57
|
|
176
|
+
3 -0.42
|
|
177
|
+
4 0.05
|
|
178
|
+
5 -0.42
|
|
179
|
+
6 -0.57
|
|
180
|
+
7 -0.24
|
|
181
|
+
8 0.29
|
|
182
|
+
9 0.71
|
|
183
|
+
|
|
184
|
+
> <PUBCHEM_EFFECTIVE_ROTOR_COUNT>
|
|
185
|
+
0
|
|
186
|
+
|
|
187
|
+
> <PUBCHEM_PHARMACOPHORE_FEATURES>
|
|
188
|
+
5
|
|
189
|
+
1 1 acceptor
|
|
190
|
+
1 2 acceptor
|
|
191
|
+
3 4 6 11 cation
|
|
192
|
+
5 4 6 7 8 11 rings
|
|
193
|
+
6 3 5 7 8 9 10 rings
|
|
194
|
+
|
|
195
|
+
> <PUBCHEM_HEAVY_ATOM_COUNT>
|
|
196
|
+
14
|
|
197
|
+
|
|
198
|
+
> <PUBCHEM_ATOM_DEF_STEREO_COUNT>
|
|
199
|
+
0
|
|
200
|
+
|
|
201
|
+
> <PUBCHEM_ATOM_UDEF_STEREO_COUNT>
|
|
202
|
+
0
|
|
203
|
+
|
|
204
|
+
> <PUBCHEM_BOND_DEF_STEREO_COUNT>
|
|
205
|
+
0
|
|
206
|
+
|
|
207
|
+
> <PUBCHEM_BOND_UDEF_STEREO_COUNT>
|
|
208
|
+
0
|
|
209
|
+
|
|
210
|
+
> <PUBCHEM_ISOTOPIC_ATOM_COUNT>
|
|
211
|
+
0
|
|
212
|
+
|
|
213
|
+
> <PUBCHEM_COMPONENT_COUNT>
|
|
214
|
+
1
|
|
215
|
+
|
|
216
|
+
> <PUBCHEM_CACTVS_TAUTO_COUNT>
|
|
217
|
+
1
|
|
218
|
+
|
|
219
|
+
> <PUBCHEM_CONFORMER_ID>
|
|
220
|
+
000009D700000001
|
|
221
|
+
|
|
222
|
+
> <PUBCHEM_MMFF94_ENERGY>
|
|
223
|
+
22.901
|
|
224
|
+
|
|
225
|
+
> <PUBCHEM_FEATURE_SELFOVERLAP>
|
|
226
|
+
25.487
|
|
227
|
+
|
|
228
|
+
> <PUBCHEM_SHAPE_FINGERPRINT>
|
|
229
|
+
10967382 1 18338799025773621285
|
|
230
|
+
11132069 177 18339075025094499008
|
|
231
|
+
12524768 44 18342463625094026902
|
|
232
|
+
13140716 1 17978511158789908153
|
|
233
|
+
16945 1 18338517550775811621
|
|
234
|
+
193761 8 15816500986559935910
|
|
235
|
+
20588541 1 18339082691204868851
|
|
236
|
+
21501502 16 18338796715286957384
|
|
237
|
+
22802520 49 18128840606503503494
|
|
238
|
+
2334 1 18338516344016692929
|
|
239
|
+
23402539 116 18270382932679789735
|
|
240
|
+
23552423 10 18262240993325675966
|
|
241
|
+
23559900 14 18199193898169584358
|
|
242
|
+
241688 4 18266458702623303353
|
|
243
|
+
2748010 2 18266180539182415717
|
|
244
|
+
5084963 1 17698433339235542986
|
|
245
|
+
528886 8 18267580380709240570
|
|
246
|
+
53812653 166 18198902694142226312
|
|
247
|
+
66348 1 18339079396917369615
|
|
248
|
+
|
|
249
|
+
> <PUBCHEM_SHAPE_MULTIPOLES>
|
|
250
|
+
256.45
|
|
251
|
+
4.01
|
|
252
|
+
2.83
|
|
253
|
+
0.58
|
|
254
|
+
0.71
|
|
255
|
+
0.08
|
|
256
|
+
0
|
|
257
|
+
-0.48
|
|
258
|
+
0
|
|
259
|
+
-0.81
|
|
260
|
+
0
|
|
261
|
+
0.01
|
|
262
|
+
0
|
|
263
|
+
0
|
|
264
|
+
|
|
265
|
+
> <PUBCHEM_SHAPE_SELFOVERLAP>
|
|
266
|
+
550.88
|
|
267
|
+
|
|
268
|
+
> <PUBCHEM_SHAPE_VOLUME>
|
|
269
|
+
143.9
|
|
270
|
+
|
|
271
|
+
> <PUBCHEM_COORDINATE_TYPE>
|
|
272
|
+
2
|
|
273
|
+
5
|
|
274
|
+
10
|
|
275
|
+
|
|
276
|
+
$$$$
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
CAFFEINE_3D_COORDS = Quantity(
|
|
280
|
+
np.array(
|
|
281
|
+
[
|
|
282
|
+
(0.4700, 2.5688, 0.0006),
|
|
283
|
+
(-3.1271, -0.4436, -0.0003),
|
|
284
|
+
(-0.9686, -1.3125, 0.0000),
|
|
285
|
+
(2.2182, 0.1412, -0.0003),
|
|
286
|
+
(-1.3477, 1.0797, -0.0001),
|
|
287
|
+
(1.4119, -1.9372, 0.0002),
|
|
288
|
+
(0.8579, 0.2592, -0.0008),
|
|
289
|
+
(0.3897, -1.0264, -0.0004),
|
|
290
|
+
(0.0307, 1.4220, -0.0006),
|
|
291
|
+
(-1.9061, -0.2495, -0.0004),
|
|
292
|
+
(2.5032, -1.1998, 0.0003),
|
|
293
|
+
(-1.4276, -2.6960, 0.0008),
|
|
294
|
+
(3.1926, 1.2061, 0.0003),
|
|
295
|
+
(-2.2969, 2.1881, 0.0007),
|
|
296
|
+
(3.5163, -1.5787, 0.0008),
|
|
297
|
+
(-1.0451, -3.1973, -0.8937),
|
|
298
|
+
(-2.5186, -2.7596, 0.0011),
|
|
299
|
+
(-1.0447, -3.1963, 0.8957),
|
|
300
|
+
(4.1992, 0.7801, 0.0002),
|
|
301
|
+
(3.0468, 1.8092, -0.8992),
|
|
302
|
+
(3.0466, 1.8083, 0.9004),
|
|
303
|
+
(-1.8087, 3.1651, -0.0003),
|
|
304
|
+
(-2.9322, 2.1027, 0.8881),
|
|
305
|
+
(-2.9346, 2.1021, -0.8849),
|
|
306
|
+
],
|
|
307
|
+
np.double,
|
|
308
|
+
),
|
|
309
|
+
unit.angstrom,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
# From https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL25/
|
|
314
|
+
ASPIRIN_2D_SDF = """\
|
|
315
|
+
aspirin
|
|
316
|
+
RDKit 2D
|
|
317
|
+
|
|
318
|
+
13 13 0 0 0 0 0 0 0 0999 V2000
|
|
319
|
+
8.8810 -2.1206 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
320
|
+
8.8798 -2.9479 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
321
|
+
9.5946 -3.3607 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
322
|
+
10.3110 -2.9474 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
323
|
+
10.3081 -2.1170 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
324
|
+
9.5928 -1.7078 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
325
|
+
11.0210 -1.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
326
|
+
11.7369 -2.1116 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
327
|
+
11.0260 -3.3588 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
328
|
+
11.0273 -4.1837 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
329
|
+
11.7423 -4.5949 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
330
|
+
10.3136 -4.5972 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
331
|
+
11.0178 -0.8769 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
332
|
+
1 2 2 0
|
|
333
|
+
5 7 1 0
|
|
334
|
+
3 4 2 0
|
|
335
|
+
7 8 2 0
|
|
336
|
+
4 9 1 0
|
|
337
|
+
4 5 1 0
|
|
338
|
+
9 10 1 0
|
|
339
|
+
2 3 1 0
|
|
340
|
+
10 11 1 0
|
|
341
|
+
5 6 2 0
|
|
342
|
+
10 12 2 0
|
|
343
|
+
6 1 1 0
|
|
344
|
+
7 13 1 0
|
|
345
|
+
M END
|
|
346
|
+
|
|
347
|
+
> <chembl_id>
|
|
348
|
+
CHEMBL25
|
|
349
|
+
|
|
350
|
+
> <chembl_pref_name>
|
|
351
|
+
ASPIRIN
|
|
352
|
+
|
|
353
|
+
$$$$
|
|
354
|
+
"""
|
|
355
|
+
|
|
356
|
+
# From https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL25/
|
|
357
|
+
ASPIRIN_SMI = "CC(=O)Oc1ccccc1C(=O)O ASPIRIN\n"
|
|
358
|
+
|
|
359
|
+
# From https://pubchem.ncbi.nlm.nih.gov/compound/2244
|
|
360
|
+
ASPIRIN_3D_SDF = """\
|
|
361
|
+
2244
|
|
362
|
+
-OEChem-07012107583D
|
|
363
|
+
|
|
364
|
+
21 21 0 0 0 0 0 0 0999 V2000
|
|
365
|
+
1.2333 0.5540 0.7792 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
366
|
+
-0.6952 -2.7148 -0.7502 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
367
|
+
0.7958 -2.1843 0.8685 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
368
|
+
1.7813 0.8105 -1.4821 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
369
|
+
-0.0857 0.6088 0.4403 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
370
|
+
-0.7927 -0.5515 0.1244 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
371
|
+
-0.7288 1.8464 0.4133 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
372
|
+
-2.1426 -0.4741 -0.2184 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
373
|
+
-2.0787 1.9238 0.0706 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
374
|
+
-2.7855 0.7636 -0.2453 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
375
|
+
-0.1409 -1.8536 0.1477 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
376
|
+
2.1094 0.6715 -0.3113 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
377
|
+
3.5305 0.5996 0.1635 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
378
|
+
-0.1851 2.7545 0.6593 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
379
|
+
-2.7247 -1.3605 -0.4564 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
380
|
+
-2.5797 2.8872 0.0506 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
381
|
+
-3.8374 0.8238 -0.5090 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
382
|
+
3.7290 1.4184 0.8593 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
383
|
+
4.2045 0.6969 -0.6924 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
384
|
+
3.7105 -0.3659 0.6426 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
385
|
+
-0.2555 -3.5916 -0.7337 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
386
|
+
1 5 1 0 0 0 0
|
|
387
|
+
1 12 1 0 0 0 0
|
|
388
|
+
2 11 1 0 0 0 0
|
|
389
|
+
2 21 1 0 0 0 0
|
|
390
|
+
3 11 2 0 0 0 0
|
|
391
|
+
4 12 2 0 0 0 0
|
|
392
|
+
5 6 1 0 0 0 0
|
|
393
|
+
5 7 2 0 0 0 0
|
|
394
|
+
6 8 2 0 0 0 0
|
|
395
|
+
6 11 1 0 0 0 0
|
|
396
|
+
7 9 1 0 0 0 0
|
|
397
|
+
7 14 1 0 0 0 0
|
|
398
|
+
8 10 1 0 0 0 0
|
|
399
|
+
8 15 1 0 0 0 0
|
|
400
|
+
9 10 2 0 0 0 0
|
|
401
|
+
9 16 1 0 0 0 0
|
|
402
|
+
10 17 1 0 0 0 0
|
|
403
|
+
12 13 1 0 0 0 0
|
|
404
|
+
13 18 1 0 0 0 0
|
|
405
|
+
13 19 1 0 0 0 0
|
|
406
|
+
13 20 1 0 0 0 0
|
|
407
|
+
M END
|
|
408
|
+
> <PUBCHEM_COMPOUND_CID>
|
|
409
|
+
2244
|
|
410
|
+
|
|
411
|
+
> <PUBCHEM_CONFORMER_RMSD>
|
|
412
|
+
0.6
|
|
413
|
+
|
|
414
|
+
> <PUBCHEM_CONFORMER_DIVERSEORDER>
|
|
415
|
+
1
|
|
416
|
+
11
|
|
417
|
+
10
|
|
418
|
+
3
|
|
419
|
+
15
|
|
420
|
+
17
|
|
421
|
+
13
|
|
422
|
+
5
|
|
423
|
+
16
|
|
424
|
+
7
|
|
425
|
+
14
|
|
426
|
+
9
|
|
427
|
+
8
|
|
428
|
+
4
|
|
429
|
+
18
|
|
430
|
+
6
|
|
431
|
+
12
|
|
432
|
+
2
|
|
433
|
+
|
|
434
|
+
> <PUBCHEM_MMFF94_PARTIAL_CHARGES>
|
|
435
|
+
18
|
|
436
|
+
1 -0.23
|
|
437
|
+
10 -0.15
|
|
438
|
+
11 0.63
|
|
439
|
+
12 0.66
|
|
440
|
+
13 0.06
|
|
441
|
+
14 0.15
|
|
442
|
+
15 0.15
|
|
443
|
+
16 0.15
|
|
444
|
+
17 0.15
|
|
445
|
+
2 -0.65
|
|
446
|
+
21 0.5
|
|
447
|
+
3 -0.57
|
|
448
|
+
4 -0.57
|
|
449
|
+
5 0.08
|
|
450
|
+
6 0.09
|
|
451
|
+
7 -0.15
|
|
452
|
+
8 -0.15
|
|
453
|
+
9 -0.15
|
|
454
|
+
|
|
455
|
+
> <PUBCHEM_EFFECTIVE_ROTOR_COUNT>
|
|
456
|
+
3
|
|
457
|
+
|
|
458
|
+
> <PUBCHEM_PHARMACOPHORE_FEATURES>
|
|
459
|
+
5
|
|
460
|
+
1 2 acceptor
|
|
461
|
+
1 3 acceptor
|
|
462
|
+
1 4 acceptor
|
|
463
|
+
3 2 3 11 anion
|
|
464
|
+
6 5 6 7 8 9 10 rings
|
|
465
|
+
|
|
466
|
+
> <PUBCHEM_HEAVY_ATOM_COUNT>
|
|
467
|
+
13
|
|
468
|
+
|
|
469
|
+
> <PUBCHEM_ATOM_DEF_STEREO_COUNT>
|
|
470
|
+
0
|
|
471
|
+
|
|
472
|
+
> <PUBCHEM_ATOM_UDEF_STEREO_COUNT>
|
|
473
|
+
0
|
|
474
|
+
|
|
475
|
+
> <PUBCHEM_BOND_DEF_STEREO_COUNT>
|
|
476
|
+
0
|
|
477
|
+
|
|
478
|
+
> <PUBCHEM_BOND_UDEF_STEREO_COUNT>
|
|
479
|
+
0
|
|
480
|
+
|
|
481
|
+
> <PUBCHEM_ISOTOPIC_ATOM_COUNT>
|
|
482
|
+
0
|
|
483
|
+
|
|
484
|
+
> <PUBCHEM_COMPONENT_COUNT>
|
|
485
|
+
1
|
|
486
|
+
|
|
487
|
+
> <PUBCHEM_CACTVS_TAUTO_COUNT>
|
|
488
|
+
1
|
|
489
|
+
|
|
490
|
+
> <PUBCHEM_CONFORMER_ID>
|
|
491
|
+
000008C400000001
|
|
492
|
+
|
|
493
|
+
> <PUBCHEM_MMFF94_ENERGY>
|
|
494
|
+
39.5952
|
|
495
|
+
|
|
496
|
+
> <PUBCHEM_FEATURE_SELFOVERLAP>
|
|
497
|
+
25.432
|
|
498
|
+
|
|
499
|
+
> <PUBCHEM_SHAPE_FINGERPRINT>
|
|
500
|
+
1 1 18265615372930943622
|
|
501
|
+
100427 49 16967750034970055351
|
|
502
|
+
12138202 97 18271247217817981012
|
|
503
|
+
12423570 1 16692715976000295083
|
|
504
|
+
12524768 44 16753525617747228747
|
|
505
|
+
12716758 59 18341332292274886536
|
|
506
|
+
13024252 1 17968377969333732145
|
|
507
|
+
14181834 199 17830728755827362645
|
|
508
|
+
14614273 12 18262232214645093005
|
|
509
|
+
15207287 21 17703787037639964108
|
|
510
|
+
15775835 57 18340488876329928641
|
|
511
|
+
16945 1 18271533103414939405
|
|
512
|
+
193761 8 17907860604865584321
|
|
513
|
+
20645476 183 17677348215414174190
|
|
514
|
+
20871998 184 18198632231250704846
|
|
515
|
+
21040471 1 18411412921197846465
|
|
516
|
+
21501502 16 18123463883164380929
|
|
517
|
+
23402539 116 18271795865171824860
|
|
518
|
+
23419403 2 13539898140662769886
|
|
519
|
+
23552423 10 18048876295495619569
|
|
520
|
+
23559900 14 18272369794190581304
|
|
521
|
+
241688 4 16179044415907240795
|
|
522
|
+
257057 1 17478316999871287486
|
|
523
|
+
2748010 2 18339085878070479087
|
|
524
|
+
305870 269 18263645056784260212
|
|
525
|
+
528862 383 18117272558388284091
|
|
526
|
+
53812653 8 18410289211719108569
|
|
527
|
+
7364860 26 17910392788380644719
|
|
528
|
+
81228 2 18050568744116491203
|
|
529
|
+
|
|
530
|
+
> <PUBCHEM_SHAPE_MULTIPOLES>
|
|
531
|
+
244.06
|
|
532
|
+
3.86
|
|
533
|
+
2.45
|
|
534
|
+
0.89
|
|
535
|
+
1.95
|
|
536
|
+
1.58
|
|
537
|
+
0.15
|
|
538
|
+
-1.85
|
|
539
|
+
0.38
|
|
540
|
+
-0.61
|
|
541
|
+
-0.02
|
|
542
|
+
0.29
|
|
543
|
+
0.01
|
|
544
|
+
-0.33
|
|
545
|
+
|
|
546
|
+
> <PUBCHEM_SHAPE_SELFOVERLAP>
|
|
547
|
+
513.037
|
|
548
|
+
|
|
549
|
+
> <PUBCHEM_SHAPE_VOLUME>
|
|
550
|
+
136
|
|
551
|
+
|
|
552
|
+
> <PUBCHEM_COORDINATE_TYPE>
|
|
553
|
+
2
|
|
554
|
+
5
|
|
555
|
+
10
|
|
556
|
+
|
|
557
|
+
$$$$
|
|
558
|
+
"""
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
CHEBI_1148_SDF = """\
|
|
562
|
+
CHEBI:1148
|
|
563
|
+
Marvin 09120817212D
|
|
564
|
+
|
|
565
|
+
7 6 0 0 0 0 999 V2000
|
|
566
|
+
1.4289 -0.1650 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
567
|
+
0.7145 0.2475 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
568
|
+
0.0000 -0.1650 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
|
|
569
|
+
-0.7145 0.2475 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
570
|
+
-1.4289 -0.1650 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
571
|
+
0.7145 1.0725 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
572
|
+
0.0000 -0.9900 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
573
|
+
2 1 1 0 0 0 0
|
|
574
|
+
6 2 2 0 0 0 0
|
|
575
|
+
3 2 1 0 0 0 0
|
|
576
|
+
7 3 1 0 0 0 0
|
|
577
|
+
4 3 1 0 0 0 0
|
|
578
|
+
5 4 1 0 0 0 0
|
|
579
|
+
M END
|
|
580
|
+
> <ChEBI ID>
|
|
581
|
+
CHEBI:1148
|
|
582
|
+
|
|
583
|
+
> <ChEBI Name>
|
|
584
|
+
2-hydroxybutyric acid
|
|
585
|
+
|
|
586
|
+
> <Star>
|
|
587
|
+
3
|
|
588
|
+
|
|
589
|
+
$$$$
|
|
590
|
+
"""
|
|
591
|
+
|
|
592
|
+
TWO_MOLS_SDF = CAFFEINE_2D_SDF + ASPIRIN_2D_SDF
|
|
593
|
+
TWO_MOLS_SMI = CAFFEINE_SMI + ASPIRIN_SMI
|
|
594
|
+
|
|
595
|
+
# Force invalid records to ensure the invalid one is skipped
|
|
596
|
+
THREE_MOLS_SDF = CAFFEINE_2D_SDF + CAFFEINE_3D_SDF.replace("24 25", "20 29") + ASPIRIN_2D_SDF
|
|
597
|
+
THREE_MOLS_SMI = CAFFEINE_SMI + "Q" + CAFFEINE_SMI + ASPIRIN_SMI
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
class SingingMolecule(Molecule):
|
|
601
|
+
def sing(self):
|
|
602
|
+
return "The hills are alive with sound of music!"
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
# This code manages a temporary directory.
|
|
606
|
+
# Data files can be found inside that directory.
|
|
607
|
+
# They are created when needed, and stored for later use.
|
|
608
|
+
|
|
609
|
+
# These descriptors make it possible to ask for
|
|
610
|
+
# `file_manager.name_sdf' and get the path to the named file inside
|
|
611
|
+
# the directory.
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
class FilenameDescriptor:
|
|
615
|
+
def __init__(self, content):
|
|
616
|
+
self.content = content
|
|
617
|
+
|
|
618
|
+
def __set_name__(self, owner, name):
|
|
619
|
+
# Figure out the descriptor name, and
|
|
620
|
+
# the variable name used to store the filename.
|
|
621
|
+
self.private_name = f"_{name}_filename"
|
|
622
|
+
basename, _, ext = name.rpartition("_")
|
|
623
|
+
self.filename = f"{basename}.{ext}"
|
|
624
|
+
|
|
625
|
+
def __get__(self, obj, objtype=None):
|
|
626
|
+
# Have we been called before?
|
|
627
|
+
filename = getattr(obj, self.private_name, None)
|
|
628
|
+
if filename is None:
|
|
629
|
+
# No.
|
|
630
|
+
# Write the content to the named file in the manager's directory
|
|
631
|
+
file_path = obj.dir_path / self.filename
|
|
632
|
+
file_path.write_text(self.content)
|
|
633
|
+
# Save the filename to obj's private_name.
|
|
634
|
+
filename = str(file_path)
|
|
635
|
+
setattr(obj, self.private_name, filename)
|
|
636
|
+
|
|
637
|
+
# Return the path as a string
|
|
638
|
+
return filename
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
class FileManager:
|
|
642
|
+
def __init__(self, temporary_directory):
|
|
643
|
+
# Use Python's object lifetime to manage directory cleanup
|
|
644
|
+
self.temporary_directory = temporary_directory
|
|
645
|
+
|
|
646
|
+
self.dir_path = pathlib.Path(temporary_directory.name)
|
|
647
|
+
|
|
648
|
+
caffeine_2d_sdf = FilenameDescriptor(CAFFEINE_2D_SDF)
|
|
649
|
+
caffeine_3d_sdf = FilenameDescriptor(CAFFEINE_3D_SDF)
|
|
650
|
+
caffeine_smi = FilenameDescriptor(CAFFEINE_SMI)
|
|
651
|
+
|
|
652
|
+
# Used to test that file_format overrides any automatic file detection.
|
|
653
|
+
caffeine_not_smi = FilenameDescriptor(CAFFEINE_2D_SDF)
|
|
654
|
+
caffeine_not_sdf = FilenameDescriptor(CAFFEINE_SMI)
|
|
655
|
+
|
|
656
|
+
# aspirin_2d_sdf = FilenameDescriptor(ASPIRIN_2D_SDF)
|
|
657
|
+
# aspirin_3d_sdf = FilenameDescriptor(ASPIRIN_3D_SDF)
|
|
658
|
+
# aspirin_smi = FilenameDescriptor(ASPIRIN_SMI)
|
|
659
|
+
|
|
660
|
+
two_mols_sdf = FilenameDescriptor(TWO_MOLS_SDF)
|
|
661
|
+
two_mols_smi = FilenameDescriptor(TWO_MOLS_SMI)
|
|
662
|
+
|
|
663
|
+
three_mols_sdf = FilenameDescriptor(THREE_MOLS_SDF)
|
|
664
|
+
three_mols_smi = FilenameDescriptor(THREE_MOLS_SMI)
|
|
665
|
+
|
|
666
|
+
chebi_1148_sdf = FilenameDescriptor(CHEBI_1148_SDF)
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
file_manager = FileManager(tempfile.TemporaryDirectory())
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
# This is similar to the FilenameDescriptor excpet that it returns a
|
|
673
|
+
# BytesIO.
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
class FileobjDescriptor:
|
|
677
|
+
def __init__(self, content):
|
|
678
|
+
self.content = content.encode("utf8")
|
|
679
|
+
|
|
680
|
+
def __get__(self, obj, objtype=None):
|
|
681
|
+
# Have we been called before?
|
|
682
|
+
return BytesIO(self.content)
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
class FileObjManager:
|
|
686
|
+
caffeine_2d_sdf = FileobjDescriptor(CAFFEINE_2D_SDF)
|
|
687
|
+
caffeine_3d_sdf = FileobjDescriptor(CAFFEINE_3D_SDF)
|
|
688
|
+
caffeine_smi = FileobjDescriptor(CAFFEINE_SMI)
|
|
689
|
+
|
|
690
|
+
# aspirin_2d_sdf = FileobjDescriptor(ASPIRIN_2D_SDF)
|
|
691
|
+
# aspirin_3d_sdf = FileobjDescriptor(ASPIRIN_3D_SDF)
|
|
692
|
+
# aspirin_smi = FileobjDescriptor(ASPIRIN_SMI)
|
|
693
|
+
|
|
694
|
+
two_mols_sdf = FileobjDescriptor(TWO_MOLS_SDF)
|
|
695
|
+
two_mols_smi = FileobjDescriptor(TWO_MOLS_SMI)
|
|
696
|
+
|
|
697
|
+
three_mols_sdf = FileobjDescriptor(THREE_MOLS_SDF)
|
|
698
|
+
three_mols_smi = FileobjDescriptor(THREE_MOLS_SMI)
|
|
699
|
+
|
|
700
|
+
chebi_1148_sdf = FileobjDescriptor(CHEBI_1148_SDF)
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
file_obj_manager = FileObjManager()
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
class BaseFromFileIO:
|
|
707
|
+
@pytest.mark.parametrize("file_format", ("SDF", "sdf", "sdF", "MOL", "mol"))
|
|
708
|
+
def test_from_file_sdf_ignores_file_format_case(self, file_format):
|
|
709
|
+
mols = self.toolkit_wrapper.from_file(file_manager.caffeine_2d_sdf, file_format)
|
|
710
|
+
self._test_from_sdf_ignores_file_format_case(mols)
|
|
711
|
+
|
|
712
|
+
@pytest.mark.parametrize("file_format", ("SDF", "sdf", "sdF", "MOL", "mol"))
|
|
713
|
+
def test_from_file_obj_sdf_ignores_file_format_case(self, file_format):
|
|
714
|
+
mols = self.toolkit_wrapper.from_file_obj(file_obj_manager.caffeine_2d_sdf, file_format)
|
|
715
|
+
self._test_from_sdf_ignores_file_format_case(mols)
|
|
716
|
+
|
|
717
|
+
def _test_from_sdf_ignores_file_format_case(self, mols):
|
|
718
|
+
assert len(mols) == 1
|
|
719
|
+
mol = mols[0]
|
|
720
|
+
assert mol.name == "caffeine"
|
|
721
|
+
|
|
722
|
+
def test_from_file_sdf_two_molecules(self):
|
|
723
|
+
mols = self.toolkit_wrapper.from_file(file_manager.two_mols_sdf, "SDF")
|
|
724
|
+
self._test_from_sdf_two_molecules(mols)
|
|
725
|
+
|
|
726
|
+
def test_from_file_obj_sdf_two_molecules(self):
|
|
727
|
+
mols = self.toolkit_wrapper.from_file_obj(file_obj_manager.two_mols_sdf, "SDF")
|
|
728
|
+
self._test_from_sdf_two_molecules(mols)
|
|
729
|
+
|
|
730
|
+
def _test_from_sdf_two_molecules(self, mols):
|
|
731
|
+
assert len(mols) == 2
|
|
732
|
+
assert mols[0].name == "caffeine"
|
|
733
|
+
assert mols[1].name == "aspirin"
|
|
734
|
+
|
|
735
|
+
def test_from_file_sdf_three_molecules(self):
|
|
736
|
+
mols = self.toolkit_wrapper.from_file(file_manager.three_mols_sdf, "SDF")
|
|
737
|
+
self._test_from_sdf_two_molecules(mols)
|
|
738
|
+
|
|
739
|
+
def test_from_file_obj_sdf_three_molecules(self):
|
|
740
|
+
mols = self.toolkit_wrapper.from_file_obj(file_obj_manager.three_mols_sdf, "SDF")
|
|
741
|
+
self._test_from_sdf_two_molecules(mols)
|
|
742
|
+
|
|
743
|
+
@pytest.mark.parametrize("file_format", ("SMI", "smi", "sMi"))
|
|
744
|
+
def test_from_file_smi_ignores_file_format_case(self, file_format):
|
|
745
|
+
mols = self.toolkit_wrapper.from_file(file_manager.caffeine_smi, file_format)
|
|
746
|
+
self._test_from_smi_ignores_file_format_case(mols)
|
|
747
|
+
|
|
748
|
+
@pytest.mark.parametrize("file_format", ("SMI", "smi", "sMi"))
|
|
749
|
+
def test_from_fileobj_smi_ignores_file_format_case(self, file_format):
|
|
750
|
+
mols = self.toolkit_wrapper.from_file_obj(file_obj_manager.caffeine_smi, file_format)
|
|
751
|
+
self._test_from_smi_ignores_file_format_case(mols)
|
|
752
|
+
|
|
753
|
+
def _test_from_smi_ignores_file_format_case(self, mols):
|
|
754
|
+
assert len(mols) == 1
|
|
755
|
+
mol = mols[0]
|
|
756
|
+
assert mol.name == "CHEMBL113"
|
|
757
|
+
assert mol.n_atoms == 24
|
|
758
|
+
assert mol.n_bonds == 25
|
|
759
|
+
assert mol.n_conformers == 0
|
|
760
|
+
|
|
761
|
+
def test_from_file_smi_two_molecules(self):
|
|
762
|
+
mols = self.toolkit_wrapper.from_file(file_manager.two_mols_smi, "SMI")
|
|
763
|
+
self._test_from_smi_two_molecules(mols)
|
|
764
|
+
|
|
765
|
+
def test_from_file_obj_smi_two_molecules(self):
|
|
766
|
+
mols = self.toolkit_wrapper.from_file_obj(file_obj_manager.two_mols_smi, "SMI")
|
|
767
|
+
self._test_from_smi_two_molecules(mols)
|
|
768
|
+
|
|
769
|
+
def _test_from_smi_two_molecules(self, mols):
|
|
770
|
+
assert len(mols) == 2
|
|
771
|
+
assert mols[0].name == "CHEMBL113"
|
|
772
|
+
assert mols[1].name == "ASPIRIN"
|
|
773
|
+
|
|
774
|
+
def test_from_file_smi_three_molecules(self):
|
|
775
|
+
mols = self.toolkit_wrapper.from_file(file_manager.three_mols_smi, "SMI")
|
|
776
|
+
self._test_from_smi_two_molecules(mols)
|
|
777
|
+
|
|
778
|
+
def test_from_file_obj_smi_three_molecules(self):
|
|
779
|
+
mols = self.toolkit_wrapper.from_file_obj(file_obj_manager.three_mols_smi, "SMI")
|
|
780
|
+
self._test_from_smi_two_molecules(mols)
|
|
781
|
+
|
|
782
|
+
def test_from_file_sdf_ignores_filename_extension(self):
|
|
783
|
+
mols = self.toolkit_wrapper.from_file(file_manager.caffeine_not_smi, "sdf")
|
|
784
|
+
self._test_from_sdf_ignores_file_format_case(mols)
|
|
785
|
+
|
|
786
|
+
def test_from_file_smi_ignores_filename_extension(self):
|
|
787
|
+
mols = self.toolkit_wrapper.from_file(file_manager.caffeine_not_sdf, "smi")
|
|
788
|
+
self._test_from_smi_ignores_file_format_case(mols)
|
|
789
|
+
|
|
790
|
+
def test_from_file_qwe_format_raises_exception(self):
|
|
791
|
+
with pytest.raises(ValueError, match="Unsupported file format: QWE"):
|
|
792
|
+
self.toolkit_wrapper.from_file(file_manager.caffeine_2d_sdf, file_format="qwe")
|
|
793
|
+
|
|
794
|
+
def test_from_file_obj_qwe_format_raises_exception(self):
|
|
795
|
+
with pytest.raises(ValueError, match="Unsupported file format: QWE"):
|
|
796
|
+
self.toolkit_wrapper.from_file_obj(file_obj_manager.caffeine_2d_sdf, file_format="qwe")
|
|
797
|
+
|
|
798
|
+
@pytest.mark.parametrize("file_format", ["smi", "sdf", "mol"])
|
|
799
|
+
def test_from_file_when_the_filename_does_not_exist(self, file_format):
|
|
800
|
+
filename = f"/qwelkjpath/to/file/that/does/not/exist/asdflkjasdf.{file_format}"
|
|
801
|
+
with pytest.raises(OSError):
|
|
802
|
+
self.toolkit_wrapper.from_file(filename, file_format=file_format)
|
|
803
|
+
|
|
804
|
+
def test_from_file_2D_sdf_coords(self):
|
|
805
|
+
mol = self.toolkit_wrapper.from_file(file_manager.caffeine_2d_sdf, "sdf")[0]
|
|
806
|
+
self._test_2D_sdf_coords(mol)
|
|
807
|
+
|
|
808
|
+
def test_from_file_obj_2D_sdf_coords(self):
|
|
809
|
+
mol = self.toolkit_wrapper.from_file_obj(file_obj_manager.caffeine_2d_sdf, "sdf")[0]
|
|
810
|
+
self._test_2D_sdf_coords(mol)
|
|
811
|
+
|
|
812
|
+
def _test_2D_sdf_coords(self, mol):
|
|
813
|
+
assert mol.n_atoms == 24
|
|
814
|
+
assert mol.n_bonds == 25
|
|
815
|
+
assert mol.n_conformers == 1
|
|
816
|
+
conformer = mol.conformers[0]
|
|
817
|
+
assert conformer.shape == (24, 3)
|
|
818
|
+
assert conformer.units == unit.angstrom
|
|
819
|
+
|
|
820
|
+
# Beyond this are the hydrogens, which are added by algorithm.
|
|
821
|
+
assert_allclose(conformer[: CAFFEINE_2D_COORDS.shape[0]].m, CAFFEINE_2D_COORDS.m)
|
|
822
|
+
|
|
823
|
+
def test_from_file_3D_sdf_keeps_hydrogens(self):
|
|
824
|
+
mol = self.toolkit_wrapper.from_file(file_manager.caffeine_3d_sdf, "sdf")[0]
|
|
825
|
+
self._test_3D_sdf_keeps_hydrogens(mol)
|
|
826
|
+
|
|
827
|
+
def test_from_file_obj_3D_sdf_keeps_hydrogens(self):
|
|
828
|
+
mol = self.toolkit_wrapper.from_file_obj(file_obj_manager.caffeine_3d_sdf, "sdf")[0]
|
|
829
|
+
self._test_3D_sdf_keeps_hydrogens(mol)
|
|
830
|
+
|
|
831
|
+
def _test_3D_sdf_keeps_hydrogens(self, mol):
|
|
832
|
+
assert mol.n_atoms == 24
|
|
833
|
+
assert mol.n_bonds == 25
|
|
834
|
+
assert mol.n_conformers == 1
|
|
835
|
+
conformer = mol.conformers[0]
|
|
836
|
+
assert conformer.shape == (24, 3)
|
|
837
|
+
assert conformer.units == unit.angstrom
|
|
838
|
+
|
|
839
|
+
# All hydrogens are explicit in the file
|
|
840
|
+
assert_allclose(conformer.m, CAFFEINE_3D_COORDS.m)
|
|
841
|
+
|
|
842
|
+
def test_from_file_with_undefined_stereo(self):
|
|
843
|
+
with pytest.raises(
|
|
844
|
+
UndefinedStereochemistryError,
|
|
845
|
+
match=f"Unable to make OFFMol from {self.tk_mol_name}: {self.tk_mol_name} has unspecified stereochemistry",
|
|
846
|
+
):
|
|
847
|
+
self.toolkit_wrapper.from_file(file_manager.chebi_1148_sdf, "sdf")
|
|
848
|
+
|
|
849
|
+
def test_from_file_obj_with_undefined_stereo(self):
|
|
850
|
+
with pytest.raises(
|
|
851
|
+
UndefinedStereochemistryError,
|
|
852
|
+
match=f"Unable to make OFFMol from {self.tk_mol_name}: {self.tk_mol_name} has unspecified stereochemistry",
|
|
853
|
+
):
|
|
854
|
+
self.toolkit_wrapper.from_file_obj(file_obj_manager.chebi_1148_sdf, "sdf")
|
|
855
|
+
|
|
856
|
+
def test_from_file_with_undefined_stereo_allowed(self):
|
|
857
|
+
self.toolkit_wrapper.from_file(file_manager.chebi_1148_sdf, "sdf", allow_undefined_stereo=True)[0]
|
|
858
|
+
|
|
859
|
+
def test_from_file_obj_with_undefined_stereo_allowed(self):
|
|
860
|
+
self.toolkit_wrapper.from_file_obj(file_obj_manager.chebi_1148_sdf, "sdf", allow_undefined_stereo=True)[0]
|
|
861
|
+
|
|
862
|
+
@pytest.mark.parametrize("name,file_format", [("caffeine_2d_sdf", "SDF"), ("caffeine_smi", "SMI")])
|
|
863
|
+
def test_from_file_handles_cls(self, name, file_format):
|
|
864
|
+
filename = getattr(file_manager, name)
|
|
865
|
+
mol = self.toolkit_wrapper.from_file(filename, file_format, _cls=SingingMolecule)[0]
|
|
866
|
+
mol.sing()
|
|
867
|
+
|
|
868
|
+
@pytest.mark.parametrize("name,file_format", [("caffeine_2d_sdf", "SDF"), ("caffeine_smi", "SMI")])
|
|
869
|
+
def test_from_file_obj_handles_cls(self, name, file_format):
|
|
870
|
+
file_obj = getattr(file_obj_manager, name)
|
|
871
|
+
mol = self.toolkit_wrapper.from_file_obj(file_obj, file_format, _cls=SingingMolecule)[0]
|
|
872
|
+
mol.sing()
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
# Create the appropriate toolkit wrapper for each test class instance.
|
|
876
|
+
#
|
|
877
|
+
# We could create them at the module level, but this would require
|
|
878
|
+
# re-doing the license checks that @requires_openeye and
|
|
879
|
+
# @requires_rdkit already do. Instead, let those decorators handle the
|
|
880
|
+
# license check, and use pytest's fixture system to create the
|
|
881
|
+
# instance given the appropriate wrapper class defined in the
|
|
882
|
+
# subclass.
|
|
883
|
+
#
|
|
884
|
+
# The wrappers are stateless, so specify it as class fixture, instead
|
|
885
|
+
# of creating a new instance for each test
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
@pytest.fixture(scope="class")
|
|
889
|
+
def init_toolkit(request):
|
|
890
|
+
request.cls.toolkit_wrapper = request.cls.toolkit_wrapper_class()
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
@pytest.mark.usefixtures("init_toolkit")
|
|
894
|
+
@requires_openeye
|
|
895
|
+
class TestOpenEyeToolkitFromFileIO(BaseFromFileIO):
|
|
896
|
+
toolkit_wrapper_class = OpenEyeToolkitWrapper
|
|
897
|
+
tk_mol_name = "OEMol"
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
@pytest.mark.usefixtures("init_toolkit")
|
|
901
|
+
@requires_rdkit
|
|
902
|
+
class TestRDKitToolkitFromFileIO(BaseFromFileIO):
|
|
903
|
+
toolkit_wrapper_class = RDKitToolkitWrapper
|
|
904
|
+
tk_mol_name = "RDMol"
|
|
905
|
+
|
|
906
|
+
def test_from_file_obj_smi_supports_stringio(self):
|
|
907
|
+
# Test the backwards compatibility support for
|
|
908
|
+
# passing in file objects open in "t"ext mode.
|
|
909
|
+
with open(file_manager.caffeine_smi) as file_obj:
|
|
910
|
+
mol = self.toolkit_wrapper.from_file_obj(file_obj, "SMI")[0]
|
|
911
|
+
assert mol.name == "CHEMBL113"
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
def assert_is_ethanol_sdf(f):
|
|
915
|
+
assert f.readline() == "ethanol\n" # title line
|
|
916
|
+
f.readline() # ignore next two lines
|
|
917
|
+
f.readline()
|
|
918
|
+
assert f.readline()[:6] == " 9 8" # check 9 atoms, 8 bonds
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
def assert_is_ethanol_smi(f):
|
|
922
|
+
line = f.readline()
|
|
923
|
+
assert "ethanol" in line
|
|
924
|
+
assert_is_ethanol_smiles(line.split()[0])
|
|
925
|
+
assert not f.readline(), "should only have one line"
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
def assert_is_ethanol_smiles(smiles):
|
|
929
|
+
assert smiles.count("[H]") == 6
|
|
930
|
+
assert smiles.count("O") == 1
|
|
931
|
+
assert smiles.count("C") == 2
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
class BaseToFileIO:
|
|
935
|
+
@pytest.mark.parametrize("format_name", ["SDF", "sdf", "sDf", "mol", "MOL"])
|
|
936
|
+
def test_to_file_sdf(self, format_name, tmp_path):
|
|
937
|
+
filename = tmp_path / "abc.xyz"
|
|
938
|
+
self.toolkit_wrapper.to_file(ETHANOL, filename, format_name)
|
|
939
|
+
with open(filename) as f:
|
|
940
|
+
assert_is_ethanol_sdf(f)
|
|
941
|
+
|
|
942
|
+
@pytest.mark.parametrize("format_name", ["SDF", "sdf", "sDf", "mol", "MOL"])
|
|
943
|
+
def test_to_file_obj_sdf(self, format_name):
|
|
944
|
+
f = StringIO()
|
|
945
|
+
self.toolkit_wrapper.to_file_obj(ETHANOL, f, format_name)
|
|
946
|
+
f.seek(0)
|
|
947
|
+
assert_is_ethanol_sdf(f)
|
|
948
|
+
|
|
949
|
+
def test_to_file_obj_sdf_with_bytesio(self):
|
|
950
|
+
f = BytesIO()
|
|
951
|
+
with pytest.raises(
|
|
952
|
+
ValueError,
|
|
953
|
+
match="Need a text mode file object like StringIO or a file opened with mode 't'",
|
|
954
|
+
):
|
|
955
|
+
self.toolkit_wrapper.to_file_obj(ETHANOL, f, "sdf")
|
|
956
|
+
|
|
957
|
+
@pytest.mark.parametrize("format_name", ["SMI", "smi", "sMi"])
|
|
958
|
+
def test_to_file_smi(self, format_name, tmp_path):
|
|
959
|
+
filename = tmp_path / "abc.xyz"
|
|
960
|
+
self.toolkit_wrapper.to_file(ETHANOL, filename, format_name)
|
|
961
|
+
with open(filename) as f:
|
|
962
|
+
assert_is_ethanol_smi(f)
|
|
963
|
+
|
|
964
|
+
@pytest.mark.parametrize("format_name", ["SMI", "smi", "sMi"])
|
|
965
|
+
def test_to_file_obj_smi(self, format_name):
|
|
966
|
+
f = StringIO()
|
|
967
|
+
self.toolkit_wrapper.to_file_obj(ETHANOL, f, format_name)
|
|
968
|
+
f.seek(0)
|
|
969
|
+
assert_is_ethanol_smi(f)
|
|
970
|
+
|
|
971
|
+
def test_to_file_obj_smi_with_bytesio(self):
|
|
972
|
+
f = BytesIO()
|
|
973
|
+
with pytest.raises(
|
|
974
|
+
ValueError,
|
|
975
|
+
match="Need a text mode file object like StringIO or a file opened with mode 't'",
|
|
976
|
+
):
|
|
977
|
+
self.toolkit_wrapper.to_file_obj(ETHANOL, f, "smi")
|
|
978
|
+
|
|
979
|
+
def test_to_file_qwe_format_raises_exception(self):
|
|
980
|
+
with tempfile.NamedTemporaryFile(suffix=".smi") as fileobj:
|
|
981
|
+
with pytest.raises(ValueError, match="Unsupported file format: QWE"):
|
|
982
|
+
self.toolkit_wrapper.to_file(ETHANOL, fileobj.name, "QWE")
|
|
983
|
+
|
|
984
|
+
@pytest.mark.parametrize("format_name", ["smi", "sdf", "mol"])
|
|
985
|
+
def test_to_file_when_the_file_does_not_exist(self, format_name, tmp_path):
|
|
986
|
+
filename = tmp_path / "does/not/exist.smi"
|
|
987
|
+
with pytest.raises(OSError):
|
|
988
|
+
self.toolkit_wrapper.to_file(ETHANOL, filename, format_name)
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
@pytest.mark.usefixtures("init_toolkit")
|
|
992
|
+
@requires_openeye
|
|
993
|
+
class TestOpenEyeToolkitToFileIO(BaseToFileIO):
|
|
994
|
+
toolkit_wrapper_class = OpenEyeToolkitWrapper
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
@pytest.mark.usefixtures("init_toolkit")
|
|
998
|
+
@requires_rdkit
|
|
999
|
+
class TestRDKitToolkitToFileIO(BaseToFileIO):
|
|
1000
|
+
toolkit_wrapper_class = RDKitToolkitWrapper
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
class BaseSmiles:
|
|
1004
|
+
def test_parse_methane_with_implicit_Hs(self):
|
|
1005
|
+
mol = self.toolkit_wrapper.from_smiles("C")
|
|
1006
|
+
# adds hydrogens
|
|
1007
|
+
assert mol.n_atoms == 5
|
|
1008
|
+
assert mol.n_bonds == 4
|
|
1009
|
+
assert mol.partial_charges is None
|
|
1010
|
+
|
|
1011
|
+
def test_parse_methane_with_implicit_Hs_but_said_they_are_explicit(self):
|
|
1012
|
+
with pytest.raises(
|
|
1013
|
+
ValueError,
|
|
1014
|
+
match=(
|
|
1015
|
+
"'hydrogens_are_explicit' was specified as True, but (OpenEye|RDKit) [Tt]oolkit interpreted SMILES "
|
|
1016
|
+
"[^ ]+ as having implicit hydrogen. If this SMILES is intended to express all explicit hydrogens "
|
|
1017
|
+
f"in the molecule, then you should construct the desired molecule as an {self.tk_mol_name}"
|
|
1018
|
+
),
|
|
1019
|
+
):
|
|
1020
|
+
self.toolkit_wrapper.from_smiles("C", hydrogens_are_explicit=True)
|
|
1021
|
+
|
|
1022
|
+
def test_parse_methane_with_explicit_Hs(self):
|
|
1023
|
+
mol = self.toolkit_wrapper.from_smiles("[C]([H])([H])([H])([H])")
|
|
1024
|
+
# add hydrogens
|
|
1025
|
+
assert mol.n_atoms == 5
|
|
1026
|
+
assert mol.n_bonds == 4
|
|
1027
|
+
assert mol.partial_charges is None
|
|
1028
|
+
|
|
1029
|
+
def test_parse_methane_with_explicit_Hs_and_say_they_are_explicit(self):
|
|
1030
|
+
mol = self.toolkit_wrapper.from_smiles("[C]([H])([H])([H])([H])", hydrogens_are_explicit=True)
|
|
1031
|
+
# add hydrogens
|
|
1032
|
+
assert mol.n_atoms == 5
|
|
1033
|
+
assert mol.n_bonds == 4
|
|
1034
|
+
|
|
1035
|
+
def test_parse_bad_smiles(self):
|
|
1036
|
+
with pytest.raises(SMILESParseError, match="Unable to parse the SMILES string"):
|
|
1037
|
+
self.toolkit_wrapper.from_smiles("QWERT")
|
|
1038
|
+
|
|
1039
|
+
# Copied from test_toolkits.py
|
|
1040
|
+
@pytest.mark.parametrize(
|
|
1041
|
+
"title, smiles",
|
|
1042
|
+
[
|
|
1043
|
+
("unspec_chiral_smiles", r"C\C(F)=C(/F)CC(C)(Cl)Br"),
|
|
1044
|
+
("spec_chiral_smiles", r"C\C(F)=C(/F)C[C@@](C)(Cl)Br"),
|
|
1045
|
+
("unspec_db_smiles", r"CC(F)=C(F)C[C@@](C)(Cl)Br"),
|
|
1046
|
+
("spec_db_smiles", r"C\C(F)=C(/F)C[C@@](C)(Cl)Br"),
|
|
1047
|
+
],
|
|
1048
|
+
)
|
|
1049
|
+
def test_smiles_missing_stereochemistry(self, title, smiles):
|
|
1050
|
+
if "unspec" in title:
|
|
1051
|
+
with pytest.raises(UndefinedStereochemistryError):
|
|
1052
|
+
self.toolkit_wrapper.from_smiles(smiles)
|
|
1053
|
+
mol = self.toolkit_wrapper.from_smiles(smiles, allow_undefined_stereo=True)
|
|
1054
|
+
else:
|
|
1055
|
+
mol = self.toolkit_wrapper.from_smiles(smiles)
|
|
1056
|
+
assert mol.n_atoms == 18
|
|
1057
|
+
|
|
1058
|
+
@pytest.mark.parametrize("smiles, expected_map", [("[Cl:1][H]", {0: 1}), ("[Cl:1][H:2]", {0: 1, 1: 2})])
|
|
1059
|
+
def test_from_smiles_with_atom_map(self, smiles, expected_map):
|
|
1060
|
+
mol = self.toolkit_wrapper.from_smiles(smiles)
|
|
1061
|
+
assert mol.properties["atom_map"] == expected_map
|
|
1062
|
+
|
|
1063
|
+
def test_ethanol_to_smiles(self):
|
|
1064
|
+
smiles = self.toolkit_wrapper.to_smiles(ETHANOL)
|
|
1065
|
+
assert_is_ethanol_smiles(smiles)
|
|
1066
|
+
|
|
1067
|
+
def test_round_trip_ethanol_to_smiles_adds_hydrogens(self):
|
|
1068
|
+
mol = self.toolkit_wrapper.from_smiles("CCO")
|
|
1069
|
+
smiles = self.toolkit_wrapper.to_smiles(mol)
|
|
1070
|
+
assert_is_ethanol_smiles(smiles)
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
@pytest.mark.usefixtures("init_toolkit")
|
|
1074
|
+
@requires_openeye
|
|
1075
|
+
class TestOpenEyeToolkitSmiles(BaseSmiles):
|
|
1076
|
+
toolkit_wrapper_class = OpenEyeToolkitWrapper
|
|
1077
|
+
tk_mol_name = "OEMol"
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
@pytest.mark.usefixtures("init_toolkit")
|
|
1081
|
+
@requires_rdkit
|
|
1082
|
+
class TestRDKitToolkitSmiles(BaseSmiles):
|
|
1083
|
+
toolkit_wrapper_class = RDKitToolkitWrapper
|
|
1084
|
+
tk_mol_name = "RDMol"
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
if __name__ == "__main__":
|
|
1088
|
+
sys.exit(pytest.main([__file__, *sys.argv[1:]]))
|