Skip to content
Snippets Groups Projects
Commit e6b1cf9f authored by Marco Biasini's avatar Marco Biasini
Browse files

rule-based-builder: override the atom element, if it is bogus

parent b34a477e
No related branches found
No related tags found
No related merge requests found
......@@ -318,6 +318,15 @@ Real Conopology::GetDefaultAtomRadius(const String& element) const
return it==ele_rad_map_.end() ? 1.5 : it->second;
}
bool Conopology::IsValidElement(const String& element) const
{
String upper_ele=element;
std::transform(upper_ele.begin(),upper_ele.end(),upper_ele.begin(),toupper);
std::map<String,Real>::const_iterator it = ele_mass_map_.find(upper_ele);
return it!=ele_mass_map_.end();
}
Real Conopology::GetDefaultAtomMass(const String& element) const
{
String upper_ele=element;
......
......@@ -53,6 +53,8 @@ public:
void RegisterBuilder(const BuilderP& b, const String& name);
void SetDefaultBuilder(const String& default_name);
bool IsValidElement(const String& element) const;
private:
Conopology();
Conopology(const Conopology&) {}
......
......@@ -83,11 +83,11 @@ bool RuleBasedBuilder::HasUnknownAtoms(mol::ResidueHandle res)
void RuleBasedBuilder::FillAtomProps(mol::AtomHandle atom, const AtomSpec& spec)
{
Conopology& conop_inst=Conopology::Instance();
mol::AtomProp props=atom.GetAtomProps();
if (props.element=="") {
if (!conop_inst.IsValidElement(props.element)) {
props.element=spec.element;
}
Conopology& conop_inst=Conopology::Instance();
if (props.radius==0.0) {
props.radius=conop_inst.GetDefaultAtomRadius(spec.element);
}
......@@ -331,10 +331,10 @@ void RuleBasedBuilder::FillAtomProps(mol::AtomHandle atom)
bool RuleBasedBuilder::OnUnknownAtom(mol::AtomHandle atom)
{
mol::AtomProp props=atom.GetAtomProps();
if (props.element=="") {
Conopology& conop_inst=Conopology::Instance();
if (!conop_inst.IsValidElement(props.element)) {
props.element=Builder::GuessAtomElement(atom.GetName(), props.is_hetatm);
}
Conopology& conop_inst=Conopology::Instance();
if (props.radius==0.0) {
props.radius=conop_inst.GetDefaultAtomRadius(props.element);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment