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

make AttachView stricter

The method now checks for agreement of the one letter code in the structure
and the character in the sequence. If there is a mismatch, AttachView throws
an IntegrityError telling you where in the sequence the problem was
detected. The one letter code of the residue and the character in the
sequence agree, if either one of the is X or they are identical.
parent e939008d
No related branches found
No related tags found
No related merge requests found
......@@ -322,6 +322,12 @@ an alignment:
Attach the given view to the sequence at index `seq_index`.
The method now checks for agreement of the one letter code in the structure
and the character in the sequence. If there is a mismatch, AttachView throws
an IntegrityError telling you where in the sequence the problem was
detected. The one letter code of the residue and the character in the
sequence agree, if either one of the is X or they are identical.
.. method:: Cut(start, end)
Removes the columns in the half-closed interval `start`, `end` from the
......
......@@ -233,10 +233,26 @@ mol::EntityView SequenceImpl::GetAttachedView() const
void SequenceImpl::AttachView(const mol::EntityView& view)
{
static const char* msg="Expected 1 chain, but %d chains found";
static const char* msg_1="Expected 1 chain, but %d chains found";
if (view.IsValid() && view.GetChainCount()!=1) {
throw IntegrityError(str(format(msg_1) % view.GetChainCount()));
}
attached_view_=view;
if (view.IsValid() && attached_view_.GetChainCount()!=1) {
throw IntegrityError(str(format(msg) % attached_view_.GetChainCount()));
if (!attached_view_.IsValid()) {
return;
}
for (size_t i=0; i<seq_string_.size(); ++i) {
if (mol::ResidueView res=this->GetResidue(i)) {
char olc1=res.GetOneLetterCode();
char olc2=seq_string_[i];
if (olc1!='X' && olc2!='X' && olc1!=olc2) {
std::stringstream ss;
ss << "One letter code of residue and sequence does not agree "
"at position " << i << " in sequence (" << res.GetOneLetterCode()
<< "!=" << seq_string_[i] << ")";
throw IntegrityError(ss.str());
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment