Skip to content

Commit de6a7f6

Browse files
committed
Use a valid XML output for a Molecule RigidGroup, writing atoms as Atom1, Atom2 etc... instead of repeating the Atom attribute. Fixes vincefn/objcryst#52.
The saved files will not be backwards-compatible (readable but the list of atoms in the rigid group will not be read)
1 parent 386de9a commit de6a7f6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ObjCryst/ObjCryst/Molecule.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <algorithm>
2626
#include <iomanip>
2727
#include <ctime>
28+
#include <boost/format.hpp>
2829

2930
#include "ObjCryst/Quirks/VFNStreamFormat.h"
3031
#include "ObjCryst/ObjCryst/Molecule.h"
@@ -2292,8 +2293,12 @@ void Molecule::XMLOutput(ostream &os,int indent)const
22922293
for(pos=mvRigidGroup.begin();pos!=mvRigidGroup.end();++pos)
22932294
{
22942295
XMLCrystTag tagg("RigidGroup",false,true);
2295-
for(set<MolAtom *>::const_iterator at=(*pos)->begin();at!=(*pos)->end();++at)
2296-
tagg.AddAttribute("Atom",(*at)->GetName());
2296+
// Need to use Atom1, Atom2 etc.. so a valid XML is produced
2297+
// See https://github.com/vincefn/objcryst/issues/52
2298+
// This won't be backwards-compatible
2299+
int idx = 0;
2300+
for (set<MolAtom*>::const_iterator at = (*pos)->begin(); at != (*pos)->end(); ++at)
2301+
tagg.AddAttribute((boost::format("Atom%d") %idx++).str(), (*at)->GetName());
22972302
/*
22982303
tagg.AddAttribute("Q0",(*pos)->mQuat.Q0());
22992304
tagg.AddAttribute("Q1",(*pos)->mQuat.Q1());
@@ -2384,7 +2389,7 @@ void Molecule::XMLInput(istream &is,const XMLCrystTag &tag)
23842389
{
23852390
RigidGroup s;
23862391
for(unsigned int i=0;i<tagg.GetNbAttribute();i++)
2387-
if("Atom"==tagg.GetAttributeName(i))
2392+
if(tagg.GetAttributeName(i).rfind("Atom", 0)==0)
23882393
s.insert(&(this->GetAtom(tagg.GetAttributeValue(i))));
23892394
this->AddRigidGroup(s);
23902395
}

0 commit comments

Comments
 (0)