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

strip whitespace characters from SEQRES entries

parent afb762c1
No related branches found
No related tags found
No related merge requests found
......@@ -113,4 +113,17 @@ std::vector<StringRef> StringRef::split(char p) const
return result;
}
std::string StringRef::str_no_whitespace() const
{
std::string whitespaceless_string;
whitespaceless_string.reserve(this->size());
for (const char* s=begin_; s!=end_; ++s) {
if (isspace(*s)) {
continue;
}
whitespaceless_string.push_back(*s);
}
return whitespaceless_string;
}
}
......@@ -147,6 +147,10 @@ public:
/// \brief split string into chunks delimited by \p p
std::vector<StringRef> split(char p) const;
/// \brief returns a new string with all whitespace removed from
/// this StringRef
std::string str_no_whitespace() const;
private:
const char* begin_;
const char* end_;
......
......@@ -518,22 +518,23 @@ void MMCifParser::ParseEntityPoly(const std::vector<StringRef>& columns)
this->GetCurrentLinenum()));
}
if (read_seqres_) {
StringRef seqres;
if (seqres_can_) {
if (indices_[PDBX_SEQ_ONE_LETTER_CODE_CAN] != -1) {
edm_it->second.seqres =
columns[indices_[PDBX_SEQ_ONE_LETTER_CODE_CAN]].str();
seqres=columns[indices_[PDBX_SEQ_ONE_LETTER_CODE_CAN]];
} else {
throw IOException(this->FormatDiagnostic(STAR_DIAG_ERROR,
"'entity_poly.pdbx_seq_one_letter_code_can' not available.'",
this->GetCurrentLinenum()));
}
} else if (indices_[PDBX_SEQ_ONE_LETTER_CODE] != -1) {
edm_it->second.seqres = columns[indices_[PDBX_SEQ_ONE_LETTER_CODE]].str();
seqres=columns[indices_[PDBX_SEQ_ONE_LETTER_CODE]];
} else {
throw IOException(this->FormatDiagnostic(STAR_DIAG_ERROR,
"'entity_poly.pdbx_seq_one_letter_code' not available.'",
this->GetCurrentLinenum()));
}
edm_it->second.seqres = seqres.str_no_whitespace();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment