Skip to content
Snippets Groups Projects
Commit 86cfc86d authored by marco's avatar marco
Browse files

improve writing of TER records

Fixes BZDNG-147

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2641 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent b51035eb
No related branches found
No related tags found
No related merge requests found
...@@ -200,6 +200,19 @@ public: ...@@ -200,6 +200,19 @@ public:
return true; return true;
} }
virtual bool VisitChain(const mol::ChainHandle& chain)
{
if (peptide_) {
this->WriteTer(prev_);
}
return true;
}
virtual void OnExit()
{
if (peptide_) {
this->WriteTer(prev_);
}
}
void WriteTer(mol::ResidueHandle res) void WriteTer(mol::ResidueHandle res)
{ {
counter_++; counter_++;
......
...@@ -305,6 +305,48 @@ BOOST_AUTO_TEST_CASE(write_ter) ...@@ -305,6 +305,48 @@ BOOST_AUTO_TEST_CASE(write_ter)
"testfiles/pdb/ter-out.pdb")); "testfiles/pdb/ter-out.pdb"));
} }
BOOST_AUTO_TEST_CASE(write_ter2)
{
String fname("testfiles/pdb/ter2.pdb");
// this scope is required to force the writer stream to be closed before
// opening the file again in compare_files. Avoids a race condition.
{
PDBReader reader(fname);
PDBWriter writer(String("testfiles/pdb/ter2-out.pdb"));
mol::EntityHandle ent=mol::CreateEntity();
reader.Import(ent);
// we use conopology to mark amino acids as peptide-linking. this is
// require for proper TER output
conop::Conopology& conop_inst=conop::Conopology::Instance();
conop_inst.ConnectAll(conop_inst.GetBuilder(), ent);
writer.Write(ent);
}
BOOST_CHECK(compare_files("testfiles/pdb/ter2.pdb",
"testfiles/pdb/ter2-out.pdb"));
}
BOOST_AUTO_TEST_CASE(write_ter3)
{
String fname("testfiles/pdb/ter3.pdb");
// this scope is required to force the writer stream to be closed before
// opening the file again in compare_files. Avoids a race condition.
{
PDBReader reader(fname);
PDBWriter writer(String("testfiles/pdb/ter3-out.pdb"));
mol::EntityHandle ent=mol::CreateEntity();
reader.Import(ent);
// we use conopology to mark amino acids as peptide-linking. this is
// require for proper TER output
conop::Conopology& conop_inst=conop::Conopology::Instance();
conop_inst.ConnectAll(conop_inst.GetBuilder(), ent);
writer.Write(ent);
}
BOOST_CHECK(compare_files("testfiles/pdb/ter3.pdb",
"testfiles/pdb/ter3-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 GLN A 153 27.125 29.174 32.121 1.00 27.40 N
ATOM 2 CA GLN A 153 28.561 29.394 32.241 1.00 30.81 C
ATOM 3 C GLN A 153 29.250 29.251 30.888 1.00 35.59 C
ATOM 4 O GLN A 153 28.979 28.314 30.130 1.00 33.20 O
ATOM 5 CB GLN A 153 29.210 28.461 33.272 1.00 30.18 C
ATOM 6 CG GLN A 153 30.694 28.783 33.468 1.00 34.18 C
ATOM 7 CD GLN A 153 31.213 28.442 34.849 1.00 34.20 C
ATOM 8 OE1 GLN A 153 31.095 27.308 35.304 1.00 34.26 O
ATOM 9 NE2 GLN A 153 31.808 29.430 35.522 1.00 40.83 N
ATOM 10 OXT GLN A 153 30.094 30.079 30.532 1.00 45.02 O
TER 11 GLN A 153
ATOM 12 N ALA B 1 13.054 45.273 35.363 1.00 44.31 N
ATOM 13 CA ALA B 1 12.088 44.308 35.884 1.00 39.90 C
ATOM 14 C ALA B 1 11.751 44.590 37.349 1.00 35.09 C
ATOM 15 O ALA B 1 12.633 44.881 38.156 1.00 39.85 O
ATOM 16 CB ALA B 1 12.616 42.890 35.717 1.00 36.61 C
TER 17 ALA B 1
TER 18 ALA B 1
HETATM 19 S SO4 z 1 25.896 25.925 48.976 0.60 29.86 S
HETATM 20 O1 SO4 z 1 25.480 27.268 48.589 0.60 30.25 O
HETATM 21 O2 SO4 z 1 25.611 24.961 47.915 0.60 34.83 O
HETATM 22 O3 SO4 z 1 27.332 25.943 49.244 0.60 34.94 O
HETATM 23 O4 SO4 z 1 25.183 25.525 50.189 0.60 32.47 O
HETATM 24 ZN ZN z 2 23.332 26.722 48.256 0.66 22.52 ZN
HETATM 25 ZN ZN z 3 4.294 31.320 20.337 0.28 33.21 ZN
HETATM 26 S SO4 z 4 0.081 30.633 21.315 0.63 40.84 S
HETATM 27 O1 SO4 z 4 -1.116 31.446 21.507 0.63 45.94 O
HETATM 28 O2 SO4 z 4 1.268 31.440 21.578 0.63 33.61 O
HETATM 29 O3 SO4 z 4 0.032 29.503 22.239 0.63 29.10 O
HETATM 30 O4 SO4 z 4 0.115 30.163 19.934 0.63 40.96 O
CONECT 19 20 21 22 23
CONECT 20 19
CONECT 21 19
CONECT 22 19
CONECT 23 19
CONECT 26 27 28 29 30
CONECT 27 26
CONECT 28 26
CONECT 29 26
CONECT 30 26
END
\ No newline at end of file
ATOM 1 N GLN A 153 27.125 29.174 32.121 1.00 27.40 N
ATOM 2 CA GLN A 153 28.561 29.394 32.241 1.00 30.81 C
ATOM 3 C GLN A 153 29.250 29.251 30.888 1.00 35.59 C
ATOM 4 O GLN A 153 28.979 28.314 30.130 1.00 33.20 O
ATOM 5 CB GLN A 153 29.210 28.461 33.272 1.00 30.18 C
ATOM 6 CG GLN A 153 30.694 28.783 33.468 1.00 34.18 C
ATOM 7 CD GLN A 153 31.213 28.442 34.849 1.00 34.20 C
ATOM 8 OE1 GLN A 153 31.095 27.308 35.304 1.00 34.26 O
ATOM 9 NE2 GLN A 153 31.808 29.430 35.522 1.00 40.83 N
ATOM 10 OXT GLN A 153 30.094 30.079 30.532 1.00 45.02 O
TER 11 GLN A 153
END
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment