Skip to content
Snippets Groups Projects
Commit a157470b authored by Studer Gabriel's avatar Studer Gabriel
Browse files

Force SDF writer to write elements with capital first char and rest lower case

parent 10cc7af0
No related branches found
No related tags found
No related merge requests found
...@@ -49,11 +49,23 @@ namespace { ...@@ -49,11 +49,23 @@ namespace {
ostr_ << format("%10.4f") % atom.GetPos()[0] ostr_ << format("%10.4f") % atom.GetPos()[0]
<< format("%10.4f") % atom.GetPos()[1] << format("%10.4f") % atom.GetPos()[1]
<< format("%10.4f ") % atom.GetPos()[2] << format("%10.4f ") % atom.GetPos()[2]
<< format("%-3s") % atom.GetElement() << format("%-3s") % SDFAtomWriter::FormatEle(atom.GetElement())
<< " 0 0 0 0 0 0" << " 0 0 0 0 0 0"
<< std::endl; << std::endl;
return true; return true;
} }
static String FormatEle(const String& ele) {
// OpenStructure has no strict requirements on lower or upper case
// for elements. However, some sdf readers (read: rdkit) want the first
// character to upper case, the rest in lower case.
String return_ele = ele;
if(!return_ele.empty()) return_ele[0] = toupper(return_ele[0]);
for(size_t i = 1; i < return_ele.size(); ++i) {
return_ele[i] = tolower(return_ele[i]);
}
return return_ele;
}
private: private:
std::ostream& ostr_; std::ostream& ostr_;
std::map<long, int>& atom_indices_; std::map<long, int>& atom_indices_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment