Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If requested, supply atom index as atom classes #2539

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/formats/smilesformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ namespace OpenBabel {

if (atom->GetFormalCharge() != 0 // charged elements
|| (options.isomeric && atom->GetIsotope()) // isotopes
|| (options.showatomclass && atom->HasData("Atom Class")) ) // If the molecule has Atom Class data and -xa option set and atom has data
|| (options.showatomclass) ) // If the molecule has Atom Class data and -xa option set and atom has data
bracketElement = true;

const char* stereo = nullptr;
Expand Down Expand Up @@ -2897,6 +2897,12 @@ namespace OpenBabel {
buffer += tchar;
}
}
} else {
// If atom class is not set, use the atom index
buffer += ':';
char tchar[12]; // maxint has 10 digits
snprintf(tchar, 12, "%d", atom->GetIdx());
buffer += tchar;
}
}

Expand Down