diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index 8fa9b53b41572eb827e365b1090cfcb5096f7e02..c52e5cf3151e1fc1e2c59f39616e822a4b7dd90f 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -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();; diff --git a/modules/io/src/mol/pdb_writer.cc b/modules/io/src/mol/pdb_writer.cc index e18d96d7fbc551494ca0277a9f05b5fda9b7c226..f3c863594c926c330426c5322f0638715cb676ce 100644 --- a/modules/io/src/mol/pdb_writer.cc +++ b/modules/io/src/mol/pdb_writer.cc @@ -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); } diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc index 5bbfbf699a9684f0eee761fbe04f42698f77daa2..1e7ecde2f7aabbc31843870d0dc6f3260584a66b 100644 --- a/modules/io/tests/test_io_pdb.cc +++ b/modules/io/tests/test_io_pdb.cc @@ -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;