Skip to content

Commit

Permalink
two more checks, in align_sequence_to_polymer and superpose_positions
Browse files Browse the repository at this point in the history
calculate_superposition() segfaulted when called with empty ResidueSpan
  • Loading branch information
wojdyr committed Aug 31, 2024
1 parent cfd26e1 commit 389226b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/gemmi/align.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ inline std::vector<int> prepare_target_gapo(const ConstResidueSpan& polymer,
return gaps;
}

// pre: !!polymer
inline AlignmentResult align_sequence_to_polymer(
const std::vector<std::string>& full_seq,
const ConstResidueSpan& polymer,
PolymerType polymer_type,
const AlignmentScoring* scoring=nullptr) {
if (!polymer)
return AlignmentResult();
std::map<std::string, std::uint8_t> encoding;
if (!scoring)
scoring = AlignmentScoring::partial_model();
Expand Down
5 changes: 5 additions & 0 deletions include/gemmi/qcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ inline SupResult superpose_positions(const Position* pos1, const Position* pos2,
result.center1 = qcp_calculate_center(pos1, len, weight);
result.center2 = qcp_calculate_center(pos2, len, weight);

if (len == 0) {
result.rmsd = NAN;
return result;
}

double wsum = 0.0;
if (weight == nullptr)
wsum = (double) len;
Expand Down

0 comments on commit 389226b

Please sign in to comment.