Skip to content

Commit

Permalink
Merge pull request #727 from ghutchis/fix-sec-structure-crash
Browse files Browse the repository at this point in the history
Fix crash in 1qlz PDB file from 2nd Structure Assignment
  • Loading branch information
ghutchis committed Aug 13, 2021
2 parents 7dd4a58 + 3a538fd commit 7b73792
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions avogadro/core/secondarystructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,31 @@ void SecondaryStructureAssigner::assignBackboneHydrogenBonds()
continue;

auto oxygen = residue.getAtomByName("O");
hBondRecord* oRecord = new hBondRecord();
oRecord->atom = oxygen.index();
oRecord->atomZ = oxygen.position3d()[2];
oRecord->distSquared = std::numeric_limits<float>::max();
oRecord->residue = residueId;
oRecord->residuePair = residueId; // just a placeholder
m_hBonds.push_back(oRecord);
if (oxygen.isValid()) {
hBondRecord* oRecord = new hBondRecord();
oRecord->atom = oxygen.index();
oRecord->atomZ = oxygen.position3d()[2];
oRecord->distSquared = std::numeric_limits<float>::max();
oRecord->residue = residueId;
oRecord->residuePair = residueId; // just a placeholder
m_hBonds.push_back(oRecord);
}

auto nitrogen = residue.getAtomByName("N");
hBondRecord* nRecord = new hBondRecord();
nRecord->atom = nitrogen.index();
nRecord->atomZ = nitrogen.position3d()[2];
nRecord->distSquared = std::numeric_limits<float>::max();
nRecord->residue = residueId;
nRecord->residuePair = residueId;
m_hBonds.push_back(nRecord);
if (nitrogen.isValid()) {
hBondRecord* nRecord = new hBondRecord();
nRecord->atom = nitrogen.index();
nRecord->atomZ = nitrogen.position3d()[2];
nRecord->distSquared = std::numeric_limits<float>::max();
nRecord->residue = residueId;
nRecord->residuePair = residueId;
m_hBonds.push_back(nRecord);
}
}

if (m_hBonds.size() == 0)
return;

// sort by z-coordinate
std::sort(m_hBonds.begin(), m_hBonds.end(),
// lambda for sorting by z-coordinate [2]
Expand Down

0 comments on commit 7b73792

Please sign in to comment.