diff --git a/modules/io/src/mol/pdb_io.hh b/modules/io/src/mol/pdb_io.hh index 54edc8a1320cf57f697bb44b2d8ac4d2a13e603c..140db87e3648055a3bff689f18657da8cceb820e 100644 --- a/modules/io/src/mol/pdb_io.hh +++ b/modules/io/src/mol/pdb_io.hh @@ -64,7 +64,9 @@ struct PDB { /// PDB::JOIN_SPREAD_ATOM_RECORDS and CoordGroups. /// /// The atoms are accessible via PDBReader::GetSequentialAtoms() - SEQUENTIAL_ATOM_IMPORT=32 + SEQUENTIAL_ATOM_IMPORT=32, + /// \brief only import C-alpha atoms + CALPHA_ONLY=64 } Type; }; diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index e4a68ee11c8b8f05a7aeb6ac15ada41ac6f38e4b..ec0dbaccb37e140bd8227659455beee97f516ad3 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -92,11 +92,15 @@ void PDBReader::Init(const boost::filesystem::path& loc) } else { is_pqr_=false; } + hard_end_=false; } bool PDBReader::HasNext() { + if (hard_end_) { + return false; + } // since helix and sheet have to appear before any atom/hetatm records // a HELIX/SHEET entry implies a next model. while (std::getline(in_, curr_line_) && ++line_num_) { @@ -108,7 +112,8 @@ bool PDBReader::HasNext() IEquals(curr_line.substr(0, 6), StringRef("SHEET ", 6)) || IEquals(curr_line.substr(0, 6), StringRef("HELIX ", 6))) { return true; - } else if (IEquals(curr_line, StringRef("END", 3))) { + } else if (IEquals(curr_line.substr(0, 3), StringRef("END", 3))) { + hard_end_=true; return false; } } @@ -149,6 +154,7 @@ void PDBReader::Import(mol::EntityHandle& ent, continue; } if (IEquals(curr_line.substr(0, 3), StringRef("END", 3))) { + hard_end_=true; go_on=false; break; } @@ -184,7 +190,7 @@ void PDBReader::Import(mol::EntityHandle& ent, default: break; } - } while (std::getline(in_, curr_line_) && ++line_num_); + } while (std::getline(in_, curr_line_) && ++line_num_ && go_on); LOGN_MESSAGE("imported " << chain_count_ << " chains, " << residue_count_ << " residues, " @@ -241,6 +247,7 @@ void PDBReader::ClearState() chain_count_=0; residue_count_=0; atom_count_=0; + hard_end_=false; helix_list_.clear(); strand_list_.clear(); sequential_atom_list_.clear(); diff --git a/modules/io/src/mol/pdb_reader.hh b/modules/io/src/mol/pdb_reader.hh index 5beb44eb30c8c5c21e6f073a253ba5b700f0c68b..5c85e23a14a88e80d6229f728171914b9deaa6b9 100644 --- a/modules/io/src/mol/pdb_reader.hh +++ b/modules/io/src/mol/pdb_reader.hh @@ -81,6 +81,7 @@ private: int residue_count_; int atom_count_; int line_num_; + bool hard_end_; String restrict_chains_; HSList helix_list_; HSList strand_list_; diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc index 8ae918f4f843ad3c1c3edf38b73b47f92311f687..64f46c26b62a2bc508afe0d84a67376597b9fba8 100644 --- a/modules/io/tests/test_io_pdb.cc +++ b/modules/io/tests/test_io_pdb.cc @@ -76,7 +76,15 @@ BOOST_AUTO_TEST_CASE(atom_record) BOOST_CHECK_EQUAL(a2.GetProp().occupancy, 1.0); BOOST_CHECK_EQUAL(a2.GetProp().element, "C"); BOOST_CHECK_EQUAL(a2.GetProp().is_hetatm, true); - +} + +BOOST_AUTO_TEST_CASE(end_record) +{ + String fname("testfiles/pdb/end.pdb"); + PDBReader reader(fname); + mol::EntityHandle ent=mol::CreateEntity(); + reader.Import(ent); + BOOST_CHECK_EQUAL(ent.GetAtomCount(), 1); } BOOST_AUTO_TEST_CASE(join_spread_records_on) diff --git a/modules/io/tests/testfiles/pdb/end.pdb b/modules/io/tests/testfiles/pdb/end.pdb new file mode 100644 index 0000000000000000000000000000000000000000..daf8241778b0a17c15e235cad46a6b229190b78b --- /dev/null +++ b/modules/io/tests/testfiles/pdb/end.pdb @@ -0,0 +1,3 @@ +ATOM 1 N MET A 1 16.000 64.000 8.000 0.50 1.00 N +END +ATOM 2 CA MET A 1 32.000-128.000 -2.500 1.00128.00 C