diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index c8e1136526d786b8daf971f99c586b29350db34d..8c8e7cbca13a568d497e2ecf1297aa12265c6558 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -382,11 +382,19 @@ void PDBReader::ParseAndAddAtom(const StringRef& line, int line_num, if(is_pqr_) { occ=std::make_pair(true, 1.0); temp=std::make_pair(true, 0.0); - charge=line.substr(54,6).ltrim().to_float(); - radius=line.substr(60, 6).ltrim().to_float(); + if (line.length()>=60) { + charge=line.substr(54,6).ltrim().to_float(); + } + if (line.length()>=66) { + radius=line.substr(60, 6).ltrim().to_float(); + } } else { - occ=line.substr(54,6).ltrim().to_float(); - temp=line.substr(60, 6).ltrim().to_float(); + if (line.length()>=60) { + occ=line.substr(54,6).ltrim().to_float(); + } + if (line.length()>=66) { + temp=line.substr(60, 6).ltrim().to_float(); + } } LOGN_TRACE( "line: [" << line << "]" ); String s_ele; diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc index fe5c51f3af93f401554f6e4ec356180d75a69e08..f8a5d70ad6e31ec3dbe17ba01469d729e0a892a3 100644 --- a/modules/io/tests/test_io_pdb.cc +++ b/modules/io/tests/test_io_pdb.cc @@ -171,4 +171,12 @@ BOOST_AUTO_TEST_CASE(anisou_record) } +BOOST_AUTO_TEST_CASE(only_66_cols) +{ + String fname("testfiles/pdb/short.pdb"); + PDBReader reader(fname); + mol::EntityHandle ent=mol::CreateEntity(); + reader.Import(ent); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/io/tests/testfiles/pdb/short.pdb b/modules/io/tests/testfiles/pdb/short.pdb new file mode 100644 index 0000000000000000000000000000000000000000..316a527e838cbe2164219804837a669050a34768 --- /dev/null +++ b/modules/io/tests/testfiles/pdb/short.pdb @@ -0,0 +1,2 @@ +ATOM 1 N SER 1 -35.012 -34.611 -8.045 1.0 0.0 +ATOM 2 H1 SER 1 -34.315 -35.342 -8.037 1.0 0.0 \ No newline at end of file