Skip to content

Commit

Permalink
#1319 Directional bonds not work with SMART
Browse files Browse the repository at this point in the history
Use constatnts for Biovia values
  • Loading branch information
AliaksandrDziarkach committed Oct 13, 2023
1 parent 787ca28 commit f6ee266
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
9 changes: 9 additions & 0 deletions core/indigo-core/molecule/base_molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ namespace indigo
BOND_EITHER = 3
};

enum
{
BIOVIA_STEREO_NO = 0,
BIOVIA_STEREO_UP = 1,
BIOVIA_STEREO_DOUBLE_CISTRANS = 3,
BIOVIA_STEREO_ETHER = 4,
BIOVIA_STEREO_DOWN = 6,
}

enum layout_orientation_value
{
UNCPECIFIED,
Expand Down
10 changes: 5 additions & 5 deletions core/indigo-core/molecule/src/inchi_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ void InchiWrapper::parseInchiOutput(const InchiOutput& inchi_output, Molecule& m
throw Molecule::Error("Indigo-InChI: ALTERN-typed bonds are not supported");
int bond_idx = mol.addBond(atom_indices[i], atom_indices[nei], bond_order);

if (bond_stereo == 1)
if (bond_stereo == BIOVIA_STEREO_UP)
mol.setBondDirection(bond_idx, BOND_UP);
else if (bond_stereo == 6)
else if (bond_stereo == BIOVIA_STEREO_DOWN)
mol.setBondDirection(bond_idx, BOND_DOWN);
else if (bond_stereo == 4)
else if (bond_stereo == BIOVIA_STEREO_ETHER)
mol.setBondDirection(bond_idx, BOND_EITHER);
else if (bond_stereo == 3)
else if (bond_stereo == BIOVIA_STEREO_DOUBLE_CISTRANS)
mol.cis_trans.ignore(bond_idx);
else if (bond_stereo != 0)
else if (bond_stereo != BIOVIA_STEREO_NO)
throw Error("unknown number for bond stereo: %d", bond_stereo);
}
}
Expand Down
12 changes: 6 additions & 6 deletions core/indigo-core/molecule/src/molecule_json_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,26 +633,26 @@ void MoleculeJsonLoader::parseBonds(const rapidjson::Value& bonds, BaseMolecule&
int direction = 0;
if (_pqmol && stereo && order == BOND_SINGLE)
{
if (stereo == 1)
if (stereo == BIOVIA_STEREO_UP)
direction = BOND_UP;
else if (stereo == 6)
else if (stereo == BIOVIA_STEREO_DOWN)
direction = BOND_DOWN;
}
bond_idx = _pmol ? _pmol->addBond_Silent(a1, a2, order) : addBondToMoleculeQuery(a1, a2, order, topology, direction);
if (stereo)
{
switch (stereo)
{
case 1:
case BIOVIA_STEREO_UP:
mol.setBondDirection(bond_idx, BOND_UP);
break;
case 3:
case BIOVIA_STEREO_DOUBLE_CISTRANS:
mol.cis_trans.ignore(bond_idx);
break;
case 4:
case BIOVIA_STEREO_ETHER:
mol.setBondDirection(bond_idx, BOND_EITHER);
break;
case 6:
case BIOVIA_STEREO_DOWN:
mol.setBondDirection(bond_idx, BOND_DOWN);
break;
default:
Expand Down
14 changes: 7 additions & 7 deletions core/indigo-core/molecule/src/molfile_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,22 +587,22 @@ void MolfileLoader::_readCtab2000()
else
{
int direction = 0;
if (stereo == 1)
if (stereo == BIOVIA_STEREO_UP)
direction = BOND_UP;
else if (stereo == 6)
else if (stereo == BIOVIA_STEREO_DOWN)
direction = BOND_DOWN;
_qmol->addBond(beg - 1, end - 1, QueryMolecule::createQueryMoleculeBond(order, topology, direction));
}

if (stereo == 1)
if (stereo == BIOVIA_STEREO_UP)
_bmol->setBondDirection(bond_idx, BOND_UP);
else if (stereo == 6)
else if (stereo == BIOVIA_STEREO_DOWN)
_bmol->setBondDirection(bond_idx, BOND_DOWN);
else if (stereo == 4)
else if (stereo == BIOVIA_STEREO_ETHER)
_bmol->setBondDirection(bond_idx, BOND_EITHER);
else if (stereo == 3)
else if (stereo == BIOVIA_STEREO_DOUBLE_CISTRANS)
_ignore_cistrans[bond_idx] = 1;
else if (stereo != 0)
else if (stereo != BIOVIA_STEREO_NO)
throw Error("unknown number for bond stereo: %d", stereo);

_bmol->reaction_bond_reacting_center[bond_idx] = rcenter;
Expand Down

0 comments on commit f6ee266

Please sign in to comment.