diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index 850556679293f37ce1eeeba7e5b32cd65c015f5d..3d7bd37563205c8f4428791717fe068536241490 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -150,11 +150,22 @@ void PDBReader::ParseCompndEntry (const StringRef& line, int line_num) } if((entry.find(':')!=entry.end())){ std::vector<StringRef> fields=entry.split(':'); - key=fields[0].trim(); - old_key_=key.str(); - data=fields[1].trim(); + key=fields[0].trim(); + old_key_=key.str(); + if (fields.size()>1) { + data=fields[1].trim(); + } + if(data.size()<1){ + if (!(key.str()=="MOL_ID")&&!(key.str()=="CHAIN")){ + LOG_WARNING("skipping unsupported COMPND record on line " << line_num<< ": record value"<< key.str()<<" too small"); + if (data_continues_) { + skip_next_=true; + } else { + return; + } + } ThrowFaultTolerant(str(format("invalid COMPND record on line %d, record after ':' too small")%line_num)); } data_continues_=true; @@ -182,7 +193,7 @@ void PDBReader::ParseCompndEntry (const StringRef& line, int line_num) } //currently only these are parsed if (!(key.str()=="MOL_ID")&&!(key.str()=="CHAIN")){ - LOG_TRACE("reading COMPND record on line " << line_num<< "is not supported"); + LOG_INFO("reading COMPND record on line " << line_num<< "is not supported"); if (data_continues_) { skip_next_=true; } else { @@ -474,7 +485,7 @@ void PDBReader::AssignMolIds(mol::EntityHandle ent) { if (chain) { chain.SetIntProp("mol_id", compnd_iterator->mol_id); }else{ - std::cout << "failedchain: "<<*chain_iterator <<":: "<<std::endl; + std::cout << "failed to assign MOL_ID to chain: "<<*chain_iterator <<std::endl; std::stringstream ss; ss << "could not map COMPND record MOL_ID onto chain"; diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc index fbf45c67a54fb7c941d5b7b5599d587b813cd947..5bbfbf699a9684f0eee761fbe04f42698f77daa2 100644 --- a/modules/io/tests/test_io_pdb.cc +++ b/modules/io/tests/test_io_pdb.cc @@ -139,26 +139,28 @@ BOOST_AUTO_TEST_CASE(test_parse_compnd_record5) PDBReader reader(fname, IOProfile()); mol::EntityHandle ent=mol::CreateEntity(); - BOOST_CHECK_THROW(reader.Import(ent), IOException); + BOOST_CHECK_NO_THROW(reader.Import(ent)); + + mol::ChainHandle ch = ent.FindChain("A"); + BOOST_CHECK(ch.HasProp("mol_id")==true); + BOOST_CHECK(ch.GetIntProp("mol_id")==1); + + ch = ent.FindChain("B"); + BOOST_CHECK(ch.HasProp("mol_id")==false); } +//chain I in MOL_ID record but no chain I +BOOST_AUTO_TEST_CASE(test_parse_compnd_record6) +{ + String fname("testfiles/pdb/1oax.pdb"); + PDBReader reader(fname, IOProfile()); + mol::EntityHandle ent=mol::CreateEntity(); + + BOOST_CHECK_THROW(reader.Import(ent), IOException); + +} -//~ BOOST_AUTO_TEST_CASE(test_parse_compnd_record6) -//~ { - //~ String fname("testfiles/pdb/1oax.pdb"); - //~ PDBReader reader(fname, IOProfile()); - //~ mol::EntityHandle ent=mol::CreateEntity(); - //~ - //~ reader.Import(ent); - //~ mol::ChainHandle ch = ent.FindChain("I"); - //~ BOOST_CHECK(ch.HasProp("mol_id")==true); - //~ BOOST_CHECK(ch.GetIntProp("mol_id")==1); -//~ - //~ ch = ent.FindChain("L"); - //~ BOOST_CHECK(ch.HasProp("mol_id")==true); - //~ BOOST_CHECK(ch.GetIntProp("mol_id")==2); -//~ } - +// has an empy MOLECULE record (unsupported ATM anyway, but crashed ost) BOOST_AUTO_TEST_CASE(test_parse_compnd_record7) { String fname("testfiles/pdb/2p6a.pdb"); diff --git a/modules/io/tests/testfiles/pdb/1oax.pdb b/modules/io/tests/testfiles/pdb/1oax.pdb new file mode 100644 index 0000000000000000000000000000000000000000..8a61950e8a0970d2b719b35c65465907ff0b6f3d --- /dev/null +++ b/modules/io/tests/testfiles/pdb/1oax.pdb @@ -0,0 +1,24 @@ + +COMPND MOL_ID: 1; +COMPND 2 MOLECULE: IMMUNOGLOBULIN E; +COMPND 3 CHAIN: H, I, J, K; +COMPND 4 FRAGMENT: FV REGION, RESIDUES 1-122; +COMPND 5 ENGINEERED: YES; +COMPND 6 MOL_ID: 2; +COMPND 7 MOLECULE: IMMUNOGLOBULIN E; +COMPND 8 CHAIN: L, M, N, O; +COMPND 9 FRAGMENT: FV REGION, RESIDUES 1-110; +COMPND 10 ENGINEERED: YES + +ATOM 961 CB ALA H 122 24.405 78.113 110.762 1.00 46.85 C +TER 962 ALA H 122 +ATOM 1923 CB ALA J 122 -18.810 34.607 14.909 1.00 46.23 C +TER 1924 ALA J 122 +ATOM 2722 CD2 LEU L 109 61.832 51.079 106.030 1.00 43.23 C +TER 2723 LEU L 109 +ATOM 3521 CD2 LEU M 109 2.184 -0.589 68.108 1.00 43.23 C +TER 3522 LEU M 109 +ATOM 4320 CD2 LEU N 109 7.889 -2.865 19.656 1.00 43.22 C +TER 4321 LEU N 109 +ATOM 5113 CD2 LEU O 109 59.692 56.678 57.399 1.00 43.23 C +TER 5114 LEU O 109 diff --git a/modules/io/tests/testfiles/pdb/2p6a.pdb b/modules/io/tests/testfiles/pdb/2p6a.pdb new file mode 100644 index 0000000000000000000000000000000000000000..19935ba86c1e7b632bd02a2c50ac89a726f0e9cb --- /dev/null +++ b/modules/io/tests/testfiles/pdb/2p6a.pdb @@ -0,0 +1,25 @@ +COMPND MOL_ID: 1; +COMPND 2 MOLECULE: INHIBIN BETA A CHAIN; +COMPND 3 CHAIN: A, B; +COMPND 4 SYNONYM: ACTIVIN BETA-A CHAIN, ERYTHROID DIFFERENTIATION +COMPND 5 PROTEIN, EDF; +COMPND 6 ENGINEERED: YES; +COMPND 7 MOL_ID: 2; +COMPND 8 MOLECULE: FOLLISTATIN; +COMPND 9 CHAIN: D, C; +COMPND 10 SYNONYM: FS, ACTIVIN-BINDING PROTEIN; +COMPND 11 ENGINEERED: YES; +COMPND 12 MOL_ID: 3; +COMPND 13 MOLECULE:; +COMPND 14 CHAIN: E; +COMPND 15 ENGINEERED: YES +ATOM 882 OXT SER A 116 15.399 37.353 44.611 1.00 73.37 O +TER 883 SER A 116 +ATOM 3870 OXT SER B 116 13.780 40.357 30.274 1.00 27.95 O +TER 3871 SER B 116 +ATOM 2987 OE2 GLU D 299 33.348 36.499 4.332 1.00 81.88 O +TER 2988 GLU D 299 +ATOM 5905 CB ILE C 290 46.026 -9.354 55.435 1.00233.79 C +TER 5906 ILE C 290 +ATOM 5956 CB ALA E 10 30.651 13.129 53.296 1.00191.07 C +TER 5957 ALA E 10