Skip to content

Commit

Permalink
Merge pull request #2598 from DStarEpoch/bugfix/residue_obj_bug_on_re…
Browse files Browse the repository at this point in the history
…ading_gro_file

fix bug when read gro file as first residue idx is 0
  • Loading branch information
ghutchis committed Oct 24, 2023
2 parents f9efcc9 + e9f4c82 commit 2e11d9b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/formats/groformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ bool GROFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
string tempstr = "";
long int residx = 0;
OBAtom* atom;
OBResidue* res;
OBResidue* res = nullptr;
OBVectorData* velocity;

if (!ifs || ifs.peek() == EOF) {
Expand Down Expand Up @@ -275,6 +275,11 @@ bool GROFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)

if (resid == residx) {
// Add atom to an existing residue
if (res == nullptr) {
res = pmol->NewResidue();
res->SetName(resname);
res->SetNum(resid);
}
res->AddAtom(atom);
} else {
// Create new residue and use that
Expand Down

0 comments on commit 2e11d9b

Please sign in to comment.