OpenStructure
Loading...
Searching...
No Matches
pdb_reader.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_IO_PDB_READER_HH
20#define OST_IO_PDB_READER_HH
21/*
22 Author: Marco Biasini
23 */
24
25#include <boost/iostreams/filtering_stream.hpp>
26#include <boost/filesystem/fstream.hpp>
27#include <ost/string_ref.hh>
33#include <ost/mol/xcs_editor.hh>
34
37namespace ost { namespace io {
38
39class DLLEXPORT_OST_IO PDBReader {
40 struct HSEntry {
41 mol::ResNum start;
42 mol::ResNum end;
43 String chain;
44 };
45 struct HetEntry {
46 HetEntry(char c, mol::ResNum n): chain(c), num(n) {}
47 char chain;
48 mol::ResNum num;
49 };
50 struct CompndEntry {
51 CompndEntry(std::vector<String> c, int n): chains(c), mol_id(n) {}
52 std::vector<String> chains;
53 int mol_id;
54 };
55 typedef std::vector<HSEntry> HSList;
56 typedef std::vector<HetEntry> HetList;
57 typedef std::vector<CompndEntry> CompndList;
58public:
59 PDBReader(const String& filename, const IOProfile& profile);
60 PDBReader(const boost::filesystem::path& loc, const IOProfile& profile);
61 PDBReader(std::istream& instream, const IOProfile& profile);
62
63 bool HasNext();
64
66 const String& restrict_chains="");
67 void SetReadSeqRes(bool flag) { read_seqres_=flag; }
68 bool GetReadSeqRes() const { return read_seqres_; }
69
70 seq::SequenceList GetSeqRes() const { return seqres_; }
71private:
72 void ParseSeqRes(const StringRef& line, int line_num);
74 void ParseCompndEntry(const StringRef& line, int line_num);
75 void ClearState();
76 void AssignSecStructure(mol::EntityHandle ent);
78 void AssignMolIds(mol::EntityHandle ent);
79 void ParseAndAddAtom(const StringRef& line, int line_num,
80 mol::EntityHandle& h, const StringRef& record_type);
81 void ThrowFaultTolerant(const String& msg);
83 bool ParseAtomIdent(const StringRef& line, int line_num,
84 String& chain_name, StringRef& res,
85 mol::ResNum& resnum, StringRef& atom_name, char& alt_loc,
86 const StringRef& record_type, int& serial);
87 void ParseAnisou(const StringRef& line, int line_num,
89 void ParseHelixEntry(const StringRef& line);
90 void ParseStrandEntry(const StringRef& line);
91 void Init(const boost::filesystem::path& loc);
92 bool EnsureLineLength(const StringRef& line, size_t size);
93 void ParseConectEntry(const StringRef& line, int line_num, mol::EntityHandle& ent);
94 std::map<int, mol::AtomHandle> amap_; // <serial_number, AtomHandle>
95 mol::ChainHandle curr_chain_;
96 mol::ResidueHandle curr_residue_;
97 int chain_count_;
98 int residue_count_;
99 int atom_count_;
100 int line_num_;
101 bool hard_end_;
102 int num_model_records_;
103 String restrict_chains_;
104 HSList helix_list_;
105 HSList strand_list_;
106 boost::filesystem::ifstream infile_;
107 std::istream& instream_;
108 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
109 String curr_line_;
110 HetList hets_;
111 CompndList compnds_;
112 std::pair <bool, int> mol_id_;
113 bool skip_next_;
114 bool data_continues_;
115 String old_key_;
116 // this needs to be set to true for reading pqr
117 // file (i.e. pdb formatted file with charges in occupacy
118 // column, and radii in b-factor column)
119 bool is_pqr_;
120 IOProfile profile_;
121 bool charmm_style_;
122 bool warned_name_mismatch_;
123 bool read_seqres_;
124 bool warned_rule_based_;
125 seq::SequenceList seqres_;
126};
127
128}}
129
130#endif
convenient datatype for referencing character data
Definition string_ref.hh:39
void Import(mol::EntityHandle &ent, const String &restrict_chains="")
PDBReader(const String &filename, const IOProfile &profile)
bool GetReadSeqRes() const
Definition pdb_reader.hh:68
void SetReadSeqRes(bool flag)
Definition pdb_reader.hh:67
seq::SequenceList GetSeqRes() const
Definition pdb_reader.hh:70
PDBReader(const boost::filesystem::path &loc, const IOProfile &profile)
PDBReader(std::istream &instream, const IOProfile &profile)
linear chain of residues
Protein or molecule.
list of sequences.
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
pointer_it< T > end(const std::vector< T > &values)
Definition base.dox:1