Skip to content
Snippets Groups Projects
Commit 7b1a1a42 authored by Bienchen's avatar Bienchen
Browse files

Changed behaviour on > 99999 atoms: now ***** is always used. Fixed PDB...

Changed behaviour on > 99999 atoms: now ***** is always used. Fixed PDB writer, reader, added unit test.

Signed-off-by: default avatarStefan Bienert <stefan.bienert@unibas.ch>
parent 5c92f6e5
Branches
Tags
No related merge requests found
......@@ -602,16 +602,6 @@ bool PDBReader::ParseAtomIdent(const StringRef& line, int line_num,
}
}
std::pair<bool, int> a_num=line.substr(6, 5).ltrim().to_int();
if (!a_num.first) {
if (!(profile_.fault_tolerant)) {
throw IOException(str(format("invalid atom number on line %d") %line_num));
}
if (!(charmm_style_)) {
LOG_WARNING("invalid atom number on line " << line_num);
}
}
alt_loc=line[16];
res_name=line.substr(17, charmm_style_ ? 4 : 3).trim();
std::pair<bool, int> res_num=line.substr(22, 4).ltrim().to_int();;
......
......@@ -80,12 +80,7 @@ void write_atom(std::ostream& ostr, FormattedLine& line,
line( 0, 6)=record_name;
// Avoid writing out atomnumbers larger than 5 digits
if (atomnum > 99999) {
if (charmm_style) {
line( 6, 5)=fmt::LPadded("*****");
} else {
throw IOException("Atom number is too long for PDB output."
" At most 5 digits are allowed");
}
line( 6, 5)=fmt::LPadded("*****");
} else {
line( 6, 5)=fmt::LPaddedInt(atomnum);
}
......
......@@ -457,6 +457,64 @@ BOOST_AUTO_TEST_CASE(write_atom)
" 1.00128.00 C ");
}
BOOST_AUTO_TEST_CASE(write_atom_100000)
{
char c_names[] = "ABCDEFGHIJ";
std::stringstream out;
PDBWriter writer(out, IOProfile());
mol::EntityHandle ent=mol::CreateEntity();
mol::XCSEditor edi=ent.EditXCS();
mol::ChainHandle ch;
mol::ResidueHandle r;
mol::AtomHandle a;
for (unsigned long i = 0; i < 10; ++i) {
ch=edi.InsertChain(String(1, c_names[i]));
for (unsigned long j = 1; j < 1000; ++j) {
r=edi.AppendResidue(ch, "ARG");
a=edi.InsertAtom(r,"N", geom::Vec3(26.861, 50.841, 38.803), "N");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"CA", geom::Vec3(27.437, 49.969, 37.786), "C");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"C", geom::Vec3(26.336, 48.959, 37.429), "C");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"O", geom::Vec3(25.745, 48.313, 38.312), "O");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"CB", geom::Vec3(28.653, 49.266, 38.349), "C");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"CG", geom::Vec3(29.870, 50.188, 38.416), "C");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"CD", geom::Vec3(31.033, 49.532, 39.173), "C");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"NE", geom::Vec3(32.318, 50.244, 39.125), "N");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"CZ", geom::Vec3(33.462, 49.750, 39.679), "C");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"NH1", geom::Vec3(33.522, 48.572, 40.308), "N");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
a=edi.InsertAtom(r,"NH2", geom::Vec3(34.610, 50.427, 39.597), "N");
a.SetOccupancy(1.0);
a.SetBFactor(128.0);
}
}
writer.Write(ent);
String s=out.str();
BOOST_CHECK_EQUAL(s.substr(8099844, 5), "99999");
BOOST_CHECK_EQUAL(s.substr(8099925, 5), "*****");
}
BOOST_AUTO_TEST_CASE(write_hetatom)
{
std::stringstream out;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment