Skip to content
Snippets Groups Projects
Verified Commit cf947eeb authored by Xavier Robin's avatar Xavier Robin
Browse files

fix: avoid writing invalid SDF files

SDF V2000 supports up to 999 atoms/bonds. For more we need to implement
the V3000 format. For now we throw an error.
parent 1645c2c9
No related branches found
No related tags found
No related merge requests found
......@@ -197,6 +197,21 @@ void SDFWriter::Write(const mol::EntityHandle& ent) {
}
bool SDFWriter::VisitChain(const mol::ChainView& chain) {
// Santiy check: only 999 atoms / bonds supported in SDF V2000
// If more are needed we need to implement V3000
if (chain.GetAtomCount() > 999) {
std::stringstream msg_at;
msg_at << "Can't write SDF file. Too many atoms (";
msg_at << chain.GetAtomCount() <<")";
throw IOException(msg_at.str());
}
if (chain.GetBondCount() > 999) {
std::stringstream msg_bo;
msg_bo << "Can't write SDF file. Too many bonds (";
msg_bo << chain.GetBondCount() <<")";
throw IOException(msg_bo.str());
}
// print end of molecule line
if(counter_ != 0) {
ostr_ << "$$$$" << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment