Skip to content

Commit

Permalink
Merge pull request #28 from openforcefield/map
Browse files Browse the repository at this point in the history
remove identifiers field from qcschema molecule
  • Loading branch information
ChayaSt authored May 27, 2019
2 parents 1b43757 + 78a8ace commit b41a8d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cmiles/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cmiles/tests/test_cmiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cmiles/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions cmiles/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://molssi-qc-schema.readthedocs.io/en/latest/index.html#>`_
Expand All @@ -260,15 +260,14 @@ 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)
symbols, geometry = toolkit.get_map_ordered_geometry(molecule, atom_map)
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

Expand Down

0 comments on commit b41a8d8

Please sign in to comment.