00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_IO_PDB_READER_HH
00020 #define OST_IO_PDB_READER_HH
00021
00022
00023
00024
00025 #include <boost/iostreams/filtering_stream.hpp>
00026 #include <boost/filesystem/fstream.hpp>
00027 #include <ost/string_ref.hh>
00028 #include <ost/seq/sequence_list.hh>
00029 #include <ost/mol/residue_handle.hh>
00030 #include <ost/mol/entity_handle.hh>
00031 #include <ost/mol/chain_handle.hh>
00032 #include <ost/mol/atom_handle.hh>
00033 #include <ost/mol/xcs_editor.hh>
00034
00035 #include <ost/io/module_config.hh>
00036 #include <ost/io/mol/io_profile.hh>
00037 namespace ost { namespace io {
00038
00039 class DLLEXPORT_OST_IO PDBReader {
00040 struct HSEntry {
00041 mol::ResNum start;
00042 mol::ResNum end;
00043 String chain;
00044 };
00045 struct HetEntry {
00046 HetEntry(char c, mol::ResNum n): chain(c), num(n) {}
00047 char chain;
00048 mol::ResNum num;
00049 };
00050 struct CompndEntry {
00051 CompndEntry(std::vector<String> c, int n): chains(c), mol_id(n) {}
00052 std::vector<String> chains;
00053 int mol_id;
00054 };
00055 typedef std::vector<HSEntry> HSList;
00056 typedef std::vector<HetEntry> HetList;
00057 typedef std::vector<CompndEntry> CompndList;
00058 public:
00059 PDBReader(const String& filename, const IOProfile& profile);
00060 PDBReader(const boost::filesystem::path& loc, const IOProfile& profile);
00061 PDBReader(std::istream& instream, const IOProfile& profile);
00062
00063 bool HasNext();
00064
00065 void Import(mol::EntityHandle& ent,
00066 const String& restrict_chains="");
00067 void SetReadSeqRes(bool flag) { read_seqres_=flag; }
00068 bool GetReadSeqRes() const { return read_seqres_; }
00069
00070 seq::SequenceList GetSeqRes() const { return seqres_; }
00071 private:
00072 void ParseSeqRes(const StringRef& line, int line_num);
00074 void ParseCompndEntry(const StringRef& line, int line_num);
00075 void ClearState();
00076 void AssignSecStructure(mol::EntityHandle ent);
00078 void AssignMolIds(mol::EntityHandle ent);
00079 void ParseAndAddAtom(const StringRef& line, int line_num,
00080 mol::EntityHandle& h, const StringRef& record_type);
00081 void ThrowFaultTolerant(const String& msg);
00083 bool ParseAtomIdent(const StringRef& line, int line_num,
00084 String& chain_name, StringRef& res,
00085 mol::ResNum& resnum, StringRef& atom_name, char& alt_loc,
00086 const StringRef& record_type);
00087 void ParseAnisou(const StringRef& line, int line_num,
00088 mol::EntityHandle& h);
00089 void ParseHelixEntry(const StringRef& line);
00090 void ParseStrandEntry(const StringRef& line);
00091 void Init(const boost::filesystem::path& loc);
00092 bool EnsureLineLength(const StringRef& line, size_t size);
00093 mol::ChainHandle curr_chain_;
00094 mol::ResidueHandle curr_residue_;
00095 int chain_count_;
00096 int residue_count_;
00097 int atom_count_;
00098 int line_num_;
00099 bool hard_end_;
00100 int num_model_records_;
00101 String restrict_chains_;
00102 HSList helix_list_;
00103 HSList strand_list_;
00104 boost::filesystem::ifstream infile_;
00105 std::istream& instream_;
00106 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
00107 String curr_line_;
00108 HetList hets_;
00109 CompndList compnds_;
00110 std::pair <bool, int> mol_id_;
00111 bool skip_next_;
00112 bool data_continues_;
00113 String old_key_;
00114
00115
00116
00117 bool is_pqr_;
00118 IOProfile profile_;
00119 bool charmm_style_;
00120 bool warned_name_mismatch_;
00121 bool read_seqres_;
00122 bool warned_rule_based_;
00123 seq::SequenceList seqres_;
00124 };
00125
00126 }}
00127
00128 #endif