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/mol/mol.hh>
00029 #include <ost/mol/xcs_editor.hh>
00030 #include <ost/io/module_config.hh>
00031 #include <ost/io/mol/pdb_io.hh>
00032
00033 namespace ost { namespace io {
00034
00035 class DLLEXPORT_OST_IO PDBReader {
00036 struct HSEntry {
00037 mol::ResNum start;
00038 mol::ResNum end;
00039 String chain;
00040 };
00041 typedef std::vector<HSEntry> HSList;
00042 public:
00043 PDBReader(const String& filename);
00044 PDBReader(const boost::filesystem::path& loc);
00045 PDBReader(std::istream& instream);
00046
00047 bool HasNext();
00048
00049 void Import(mol::EntityHandle& ent,
00050 const String& restrict_chains="");
00051
00052 private:
00053 void ClearState();
00054 void AssignSecStructure(mol::EntityHandle ent);
00055 void ParseAndAddAtom(const StringRef& line, int line_num,
00056 mol::EntityHandle& h, const StringRef& record_type);
00057
00059 bool ParseAtomIdent(const StringRef& line, int line_num,
00060 char& chain_name, StringRef& res,
00061 mol::ResNum& resnum, StringRef& atom_name, char& alt_loc,
00062 const StringRef& record_type);
00063 void ParseAnisou(const StringRef& line, int line_num,
00064 mol::EntityHandle& h);
00065 void ParseHelixEntry(const StringRef& line);
00066 void ParseStrandEntry(const StringRef& line);
00067 void Init(const boost::filesystem::path& loc);
00068 bool EnsureLineLength(const StringRef& line, size_t size);
00069 mol::ChainHandle curr_chain_;
00070 mol::ResidueHandle curr_residue_;
00071 int chain_count_;
00072 int residue_count_;
00073 int atom_count_;
00074 int line_num_;
00075 bool hard_end_;
00076 int num_model_records_;
00077 String restrict_chains_;
00078 HSList helix_list_;
00079 HSList strand_list_;
00080
00081 boost::filesystem::ifstream infile_;
00082 std::istream& instream_;
00083 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
00084 String curr_line_;
00085
00086
00087
00088
00089 bool is_pqr_;
00090 };
00091
00092 }}
00093
00094 #endif