Skip to content
Snippets Groups Projects
Commit ec25b68e authored by Tobias Schmidt's avatar Tobias Schmidt
Browse files

fixed writing TER for empty chains, added testcase (BZDNG-276)

parent 12ecba8f
No related branches found
No related tags found
No related merge requests found
...@@ -233,17 +233,21 @@ public: ...@@ -233,17 +233,21 @@ public:
virtual bool VisitChain(const mol::ChainHandle& chain) virtual bool VisitChain(const mol::ChainHandle& chain)
{ {
if (peptide_) { if (chain.GetResidueCount()!=0) {
this->WriteTer(prev_); if (peptide_) {
this->WriteTer(prev_);
}
} }
return true; return true;
} }
virtual void OnExit() virtual void OnExit()
{ {
if (peptide_) { if (peptide_) {
this->WriteTer(prev_); this->WriteTer(prev_);
} }
} }
void WriteTer(mol::ResidueHandle res) void WriteTer(mol::ResidueHandle res)
{ {
counter_++; counter_++;
......
...@@ -373,6 +373,48 @@ BOOST_AUTO_TEST_CASE(write_ter3) ...@@ -373,6 +373,48 @@ BOOST_AUTO_TEST_CASE(write_ter3)
"testfiles/pdb/ter3-out.pdb")); "testfiles/pdb/ter3-out.pdb"));
} }
BOOST_AUTO_TEST_CASE(write_ter4)
{
{
PDBWriter writer(String("testfiles/pdb/ter_emptychain-out.pdb"), IOProfile());
mol::EntityHandle ent=mol::CreateEntity();
mol::XCSEditor edi=ent.EditXCS();
mol::ChainHandle ch=edi.InsertChain("A");
mol::ResidueHandle r=edi.AppendResidue(ch, "ALA");
mol::AtomHandle a=edi.InsertAtom(r, "N", geom::Vec3(32.0, -128.0, -2.5));
mol::ResidueHandle r2=edi.AppendResidue(ch, "GLY");
mol::AtomHandle a2=edi.InsertAtom(r2, "N", geom::Vec3(35.0, -99.0, -10.5));
mol::ChainHandle ch2=edi.InsertChain("B");
conop::Conopology& conop_inst=conop::Conopology::Instance();
conop_inst.ConnectAll(conop_inst.GetBuilder(), ent);
writer.Write(ent);
}
BOOST_CHECK(compare_files("testfiles/pdb/ter_emptychain.pdb",
"testfiles/pdb/ter_emptychain-out.pdb"));
}
BOOST_AUTO_TEST_CASE(write_ter5)
{
{
PDBWriter writer(String("testfiles/pdb/ter_view-emptychain-out.pdb"), IOProfile());
mol::EntityHandle ent=mol::CreateEntity();
mol::XCSEditor edi=ent.EditXCS();
mol::ChainHandle ch=edi.InsertChain("A");
mol::ResidueHandle r=edi.AppendResidue(ch, "ALA");
mol::AtomHandle a=edi.InsertAtom(r, "N", geom::Vec3(32.0, -128.0, -2.5));
mol::ResidueHandle r2=edi.AppendResidue(ch, "GLY");
mol::AtomHandle a2=edi.InsertAtom(r2, "N", geom::Vec3(35.0, -99.0, -10.5));
mol::ChainHandle ch2=edi.InsertChain("B");
conop::Conopology& conop_inst=conop::Conopology::Instance();
conop_inst.ConnectAll(conop_inst.GetBuilder(), ent);
writer.Write(ent.Select(""));
}
BOOST_CHECK(compare_files("testfiles/pdb/ter_view-emptychain.pdb",
"testfiles/pdb/ter_view-emptychain-out.pdb"));
}
BOOST_AUTO_TEST_CASE(write_conect) BOOST_AUTO_TEST_CASE(write_conect)
{ {
// this scope is required to force the writer stream to be closed before // this scope is required to force the writer stream to be closed before
......
ATOM 1 N ALA A 1 32.000-128.000 -2.500 1.00 0.00 N
ATOM 2 N GLY A 2 35.000 -99.000 -10.500 1.00 0.00 N
TER 3 GLY A 2
END
ATOM 1 N ALA A 1 32.000-128.000 -2.500 1.00 0.00 N
ATOM 2 N GLY A 2 35.000 -99.000 -10.500 1.00 0.00 N
TER 3 GLY A 2
END
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment