From 78a8ace5f8591b481bcf964a3760fa39d3dfc3c9 Mon Sep 17 00:00:00 2001 From: ChayaSt Date: Mon, 27 May 2019 16:55:04 -0400 Subject: [PATCH] remove identifiers field from qcschema molecule --- cmiles/generator.py | 5 +++-- cmiles/tests/test_cmiles.py | 4 ++-- cmiles/tests/test_utils.py | 3 ++- cmiles/utils.py | 5 ++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmiles/generator.py b/cmiles/generator.py index e60f8ff..0801c8a 100755 --- a/cmiles/generator.py +++ b/cmiles/generator.py @@ -103,8 +103,9 @@ def get_molecule_ids(molecule_input, toolkit='openeye', strict=True, **kwargs): try: if kwargs['permute_xyz']: - permuted_json_mol = cmiles.utils.permute_qcschema(molecule_input, molecule_ids, toolkit=toolkit) - return permuted_json_mol + mapped_smiles = molecule_ids['canonical_isomeric_explicit_hydrogen_mapped_smiles'] + permuted_json_mol = cmiles.utils.permute_qcschema(molecule_input, mapped_smiles, toolkit=toolkit) + return molecule_ids, permuted_json_mol else: return molecule_ids diff --git a/cmiles/tests/test_cmiles.py b/cmiles/tests/test_cmiles.py index 0afe8bf..9bd9498 100755 --- a/cmiles/tests/test_cmiles.py +++ b/cmiles/tests/test_cmiles.py @@ -722,12 +722,12 @@ def test_permute_xyz(toolkit): 'molecular_multiplicity': 1 } - permuted_hooh = cmiles.get_molecule_ids(hooh, toolkit, permute_xyz=True) + mol_ids, permuted_hooh = cmiles.get_molecule_ids(hooh, toolkit, permute_xyz=True) assert hooh['geometry'] != permuted_hooh['geometry'] mol = cmiles.utils.mol_from_json(hooh, toolkit=toolkit) - atom_map = cmiles.utils.get_atom_map(mol, permuted_hooh['identifiers']['canonical_isomeric_explicit_hydrogen_mapped_smiles']) + atom_map = cmiles.utils.get_atom_map(molecule=mol, mapped_smiles=mol_ids['canonical_isomeric_explicit_hydrogen_mapped_smiles']) json_geom = np.asarray(hooh['geometry']).reshape(int(len(hooh['geometry'])/3), 3) permuted_geom = np.asarray(permuted_hooh['geometry']).reshape(int(len(hooh['geometry'])/3), 3) diff --git a/cmiles/tests/test_utils.py b/cmiles/tests/test_utils.py index dd89790..be8496f 100755 --- a/cmiles/tests/test_utils.py +++ b/cmiles/tests/test_utils.py @@ -334,9 +334,10 @@ def test_permute_json(toolkit): 'connectivity': [[0, 1, 1], [1, 2, 1], [2, 3, 1]], 'molecular_multiplicity': 1 } + mapped_smiles = molecule_ids['canonical_isomeric_explicit_hydrogen_mapped_smiles'] mol = utils.mol_from_json(hooh, toolkit=toolkit) atom_map = utils.get_atom_map(mol, '[H:3][O:1][O:2][H:4]') - permuted_hooh = utils.permute_qcschema(hooh, molecule_ids, toolkit=toolkit) + permuted_hooh = utils.permute_qcschema(hooh, mapped_smiles, toolkit=toolkit) json_geom = np.asarray(hooh['geometry']).reshape(int(len(hooh['geometry'])/3), 3) permuted_geom = np.asarray(permuted_hooh['geometry']).reshape(int(len(hooh['geometry'])/3), 3) diff --git a/cmiles/utils.py b/cmiles/utils.py index 3168b07..1a41440 100755 --- a/cmiles/utils.py +++ b/cmiles/utils.py @@ -237,7 +237,7 @@ def mol_to_hill_molecular_formula(molecule): return "".join(hill_sorted) -def mol_to_map_ordered_qcschema(molecule, molecule_ids, multiplicity=1, **kwargs): +def mol_to_map_ordered_qcschema(molecule, mapped_smiles, multiplicity=1, **kwargs): """ Genereate JSON serialize following `QCSchema specs `_ @@ -260,7 +260,6 @@ def mol_to_map_ordered_qcschema(molecule, molecule_ids, multiplicity=1, **kwargs """ toolkit = _set_toolkit(molecule) - mapped_smiles = molecule_ids['canonical_isomeric_explicit_hydrogen_mapped_smiles'] atom_map = toolkit.get_atom_map(molecule, mapped_smiles, **kwargs) connectivity = get_connectivity_table(molecule, atom_map) @@ -268,7 +267,7 @@ def mol_to_map_ordered_qcschema(molecule, molecule_ids, multiplicity=1, **kwargs charge = get_charge(molecule) qcschema_mol = {'symbols': symbols, 'geometry': geometry, 'connectivity': connectivity, - 'molecular_charge': charge, 'molecular_multiplicity': multiplicity, 'identifiers': molecule_ids} + 'molecular_charge': charge, 'molecular_multiplicity': multiplicity} return qcschema_mol