forked from plumed/plumed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PDB.h
114 lines (104 loc) · 5.06 KB
/
PDB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2011-2016 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed.org for more information.
This file is part of plumed, version 2.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifndef __PLUMED_tools_PDB_h
#define __PLUMED_tools_PDB_h
#include "AtomNumber.h"
#include "Vector.h"
#include <vector>
#include <string>
#include "Log.h"
#include <map>
namespace PLMD{
/// Minimalistic pdb parser.
/// Contain positions, atomic indexes, occupancy and beta.
/// We should also add other info (e.g. residue name etc).
class PDB{
std::vector<unsigned> block_ends;
std::vector<std::string> atomsymb, chain;
std::vector<unsigned> residue;
std::vector<Vector> positions;
std::vector<double> occupancy;
std::vector<double> beta;
std::vector<std::string> remark;
std::vector<AtomNumber> numbers;
std::map<AtomNumber,unsigned> number2index;
std::vector<std::string> residuenames;
public:
/// Read the pdb from a file, scaling positions by a factor scale
bool read(const std::string&file,bool naturalUnits,double scale);
/// Read from a file pointer
bool readFromFilepointer(FILE *fp,bool naturalUnits,double scale);
/// Access to the position array
const std::vector<Vector> & getPositions()const;
/// Access to the occupancy array
const std::vector<double> & getOccupancy()const;
/// Access to the beta array
const std::vector<double> & getBeta()const;
/// This is used to set the keyword ARG - this is so we
/// we can use a1.* in the input for reference configurations
void setArgKeyword( const std::string& new_args );
/// Add information to the remark
void addRemark( const std::vector<std::string>& v1 );
/// Access to the lines of REMARK
const std::vector<std::string> & getRemark()const;
/// Access to the indexes
const std::vector<AtomNumber> & getAtomNumbers()const;
/// Returns the number of atoms
unsigned size()const;
/// Get the names of all the chains in the pdb file
void getChainNames( std::vector<std::string>& chains ) const;
/// Get the residues in each of the chains
void getResidueRange( const std::string& chainname, unsigned& res_start, unsigned& res_end, std::string& errmsg ) const;
/// Get the atoms in each of the chains
void getAtomRange( const std::string& chainname, AtomNumber& a_start, AtomNumber& a_end, std::string& errmsg ) const;
/// Get the chain ID that a particular residue is a part of
std::string getChainID(const unsigned& resnumber) const;
///use the log to dump information
friend Log& operator<<(Log& ostr, const PDB& pdb);
/// return the name of a specific atom
std::string getAtomName(AtomNumber a) const;
/// return the residue number for a specific atom
unsigned getResidueNumber(AtomNumber a) const;
/// return the residue name for a specific atom
std::string getResidueName(AtomNumber a) const;
/// get the name of the resnum'th residue
std::string getResidueName(const unsigned& resnum ) const;
/// get the name of the resnum'th residue of chain
/// Chain=="*" matches any chain and makes it equivalent to getResidueName
std::string getResidueName(const unsigned& resnum,const std::string& chain ) const;
/// Check if any of the residues are named name
bool checkForResidue( const std::string& name ) const ;
/// Check if any of the atoms are named atom
bool checkForAtom( const std::string& name ) const ;
/// Return the atom named aname from residue number resnum
AtomNumber getNamedAtomFromResidue( const std::string& aname, const unsigned& resnum ) const;
/// Return the atom named aname from residue number resnum and chain.
/// Chain=="*" matches any chain and makes it equivalent to getNamedAtomFromResidue.
AtomNumber getNamedAtomFromResidueAndChain( const std::string& aname, const unsigned& resnum, const std::string& chain ) const;
/// Access to the atoms of a residue
std::vector<AtomNumber> getAtomsInResidue(const unsigned& resnum,const std::string& chainid)const;
/// Access to the atoms of a chain
std::vector<AtomNumber> getAtomsInChain(const std::string& chainid)const;
/// Get the extents of the blocks containing the atoms
const std::vector<unsigned> & getAtomBlockEnds() const ;
/// Get the number of blocks of atoms in the pdb
unsigned getNumberOfAtomBlocks() const ;
/// Set the position array
void setPositions(const std::vector<Vector> &v);
};
}
#endif