All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PDB.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 The plumed team
3  (see the PEOPLE file at the root of the distribution for a list of names)
4 
5  See http://www.plumed-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
8 
9  plumed is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  plumed is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 #ifndef __PLUMED_tools_PDB_h
23 #define __PLUMED_tools_PDB_h
24 
25 #include "AtomNumber.h"
26 #include "Vector.h"
27 #include <vector>
28 #include <string>
29 #include "Log.h"
30 #include <map>
31 
32 
33 namespace PLMD{
34 
35 /// Minimalistic pdb parser.
36 /// Contain positions, atomic indexes, occupancy and beta.
37 /// We should also add other info (e.g. residue name etc).
38 class PDB{
39  std::vector<std::string> atomsymb, chain;
40  std::vector<unsigned> residue;
41  std::vector<Vector> positions;
42  std::vector<double> occupancy;
43  std::vector<double> beta;
44  std::vector<std::string> remark;
45  std::vector<AtomNumber> numbers;
46  std::map<AtomNumber,unsigned> number2index;
47  std::vector<std::string> residuenames;
48 public:
49 /// Read the pdb from a file, scaling positions by a factor scale
50  bool read(const std::string&file,bool naturalUnits,double scale);
51 /// Read from a file pointer
52  bool readFromFilepointer(FILE *fp,bool naturalUnits,double scale);
53 /// Access to the position array
54  const std::vector<Vector> & getPositions()const;
55 /// Access to the occupancy array
56  const std::vector<double> & getOccupancy()const;
57 /// Access to the beta array
58  const std::vector<double> & getBeta()const;
59 /// This is used to set the keyword ARG - this is so we
60 /// we can use a1.* in the input for reference configurations
61  void setArgKeyword( const std::string& new_args );
62 /// Access to the lines of REMARK
63  const std::vector<std::string> & getRemark()const;
64 /// Access to the indexes
65  const std::vector<AtomNumber> & getAtomNumbers()const;
66 /// Returns the number of atoms
67  unsigned size()const;
68 /// Get the names of all the chains in the pdb file
69  void getChainNames( std::vector<std::string>& chains ) const;
70 /// Get the residues in each of the chains
71  void getResidueRange( const std::string& chainname, unsigned& res_start, unsigned& res_end, std::string& errmsg ) const;
72 /// Get the atoms in each of the chains
73  void getAtomRange( const std::string& chainname, AtomNumber& a_start, AtomNumber& a_end, std::string& errmsg ) const;
74 /// Get the atoms in the backbone of a particular residue
75  bool getBackbone( const unsigned& resnumber, const std::vector<std::string>& backnames, std::vector<AtomNumber>& backnumbers ) const ;
76 /// Get the chain ID that a particular residue is a part of
77  std::string getChainID(const unsigned& resnumber) const;
78 /// This allows you to give atoms a new name - this is used to rename the HB1 atoms in GLY residues CB so that alpharmsd works
79  void renameAtoms( const std::string& old_name, const std::string& new_name );
80 ///use the log to dump information
81  friend Log& operator<<(Log& ostr, const PDB& pdb);
82 /// return the name of a specific atom
83  std::string getAtomName(AtomNumber a) const;
84 /// return the residue number for a specific atom
85  unsigned getResidueNumber(AtomNumber a) const;
86 /// return the residue name for a specific atom
87  std::string getResidueName(AtomNumber a) const;
88 };
89 
90 }
91 #endif
Simple class to store the index of an atom.
Definition: AtomNumber.h:39
std::vector< std::string > atomsymb
Definition: PDB.h:39
std::vector< std::string > residuenames
Definition: PDB.h:47
bool read(const std::string &file, bool naturalUnits, double scale)
Read the pdb from a file, scaling positions by a factor scale.
Definition: PDB.cpp:144
unsigned getResidueNumber(AtomNumber a) const
return the residue number for a specific atom
Definition: PDB.cpp:58
void getAtomRange(const std::string &chainname, AtomNumber &a_start, AtomNumber &a_end, std::string &errmsg) const
Get the atoms in each of the chains.
Definition: PDB.cpp:177
friend Log & operator<<(Log &ostr, const PDB &pdb)
use the log to dump information
Definition: PDB.cpp:225
std::string getAtomName(AtomNumber a) const
return the name of a specific atom
Definition: PDB.cpp:51
void getChainNames(std::vector< std::string > &chains) const
Get the names of all the chains in the pdb file.
Definition: PDB.cpp:152
Class containing the log stream.
Definition: Log.h:35
void renameAtoms(const std::string &old_name, const std::string &new_name)
This allows you to give atoms a new name - this is used to rename the HB1 atoms in GLY residues CB so...
Definition: PDB.cpp:219
std::vector< double > beta
Definition: PDB.h:43
const std::vector< Vector > & getPositions() const
Access to the position array.
Definition: PDB.cpp:31
void setArgKeyword(const std::string &new_args)
This is used to set the keyword ARG - this is so we we can use a1.
Definition: PDB.cpp:134
const std::vector< double > & getBeta() const
Access to the beta array.
Definition: PDB.cpp:39
const std::vector< double > & getOccupancy() const
Access to the occupancy array.
Definition: PDB.cpp:35
std::vector< Vector > positions
Definition: PDB.h:41
std::string getResidueName(AtomNumber a) const
return the residue name for a specific atom
Definition: PDB.cpp:65
std::vector< double > occupancy
Definition: PDB.h:42
Minimalistic pdb parser.
Definition: PDB.h:38
std::vector< std::string > chain
Definition: PDB.h:39
std::map< AtomNumber, unsigned > number2index
Definition: PDB.h:46
const std::vector< std::string > & getRemark() const
Access to the lines of REMARK.
Definition: PDB.cpp:43
std::vector< unsigned > residue
Definition: PDB.h:40
bool getBackbone(const unsigned &resnumber, const std::vector< std::string > &backnames, std::vector< AtomNumber > &backnumbers) const
Get the atoms in the backbone of a particular residue.
Definition: PDB.cpp:194
bool readFromFilepointer(FILE *fp, bool naturalUnits, double scale)
Read from a file pointer.
Definition: PDB.cpp:76
unsigned size() const
Returns the number of atoms.
Definition: PDB.cpp:72
const std::vector< AtomNumber > & getAtomNumbers() const
Access to the indexes.
Definition: PDB.cpp:47
std::string getChainID(const unsigned &resnumber) const
Get the chain ID that a particular residue is a part of.
Definition: PDB.cpp:212
void const char const char int double * a
Definition: Matrix.h:42
void getResidueRange(const std::string &chainname, unsigned &res_start, unsigned &res_end, std::string &errmsg) const
Get the residues in each of the chains.
Definition: PDB.cpp:160
std::vector< AtomNumber > numbers
Definition: PDB.h:45
std::vector< std::string > remark
Definition: PDB.h:44