Skip to content

Commit

Permalink
The datasets use 0-based indexing for explicit ordering via atom clas…
Browse files Browse the repository at this point in the history
…ses in SMILES strings, not 1-based
  • Loading branch information
ndickson-nvidia committed Aug 12, 2024
1 parent 26b85fb commit de55f7a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions graphium/graphium_cpp/graphium_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@ std::unique_ptr<RDKit::RWMol> parse_mol(
else {
atom_order[i] = (unsigned int)atom->getAtomMapNum();

// 1-based to 0-based, and must be in range
if (atom_order[i] < 1 || atom_order[i] > num_atoms) {
// 0-based, and must be in range
if (atom_order[i] >= num_atoms) {
ordered = false;
}
else {
--atom_order[i];
}


// Clear the property, so that any equivalent molecules will
// get the same canoncial order.
atom->clearProp(RDKit::common_properties::molAtomMapNumber);
Expand All @@ -93,7 +90,7 @@ std::unique_ptr<RDKit::RWMol> parse_mol(
}

if (ordered) {
// Reorder the atoms to the canonical order
// Reorder the atoms to the explicit order
mol.reset(static_cast<RDKit::RWMol*>(RDKit::MolOps::renumberAtoms(*mol, inverse_order)));
}
}
Expand Down

0 comments on commit de55f7a

Please sign in to comment.