27 #include "tools/PDB.h"
42 keys.
add(
"compulsory",
"STRUCTURE",
"a file in pdb format containing a reference structure. "
43 "This is used to defines the atoms in the various residues, chains, etc . "
44 "For more details on the PDB file format visit http://www.wwpdb.org/docs.html");
45 keys.
add(
"atoms",
"CHAIN",
"(for masochists ( mostly Davide Branduardi ) ) The atoms involved in each of the chains of interest in the structure.");
59 if( moldat.size()!=0 )
error(
"cannot use more than one MOLINFO action in input");
61 std::vector<AtomNumber> backbone;
64 for(
unsigned i=1;;++i){
66 if( backbone.size()==0 )
break;
74 std::string reference;
parse(
"STRUCTURE",reference);
77 if( !
pdb.
read(reference,
plumed.getAtoms().usingNaturalUnits(),0.1/
plumed.getAtoms().getUnits().getLength()))plumed_merror(
"missing input file " + reference );
79 log.
printf(
" pdb file named %s contains %d chains \n",reference.c_str(), chains.size() );
80 for(
unsigned i=0;i<chains.size();++i){
81 unsigned start,end; std::string errmsg;
83 if( errmsg.length()!=0 )
error( errmsg );
86 if( errmsg.length()!=0 )
error( errmsg );
87 log.
printf(
" chain named %s contains residues %u to %u and atoms %d to %d \n",chains[i].c_str(),start,end,astart.
serial(),aend.
serial());
93 void SetupMolInfo::getBackbone( std::vector<std::string>& restrings,
const std::vector<std::string>& atnames, std::vector< std::vector<AtomNumber> >& backbone ){
95 if( restrings.size()!=1 )
error(
"cannot interpret anything other than all for residues when using CHAIN keywords");
96 if( restrings[0]!=
"all" )
error(
"cannot interpret anything other than all for residues when using CHAIN keywords");
103 if( restrings.size()==1 ){
104 if( restrings[0]==
"all" ){
106 for(
unsigned i=0;i<chains.size();++i){
107 unsigned r_start, r_end; std::string errmsg, mm, nn;
110 if(i==0) restrings[0] = mm +
"-" + nn;
111 else restrings.push_back( mm +
"-" + nn );
118 int nk, nj; std::vector< std::vector<unsigned> > segments;
119 std::vector<unsigned> thissegment;
121 for(
unsigned i=1;i<restrings.size();++i){
125 segments.push_back(thissegment);
126 thissegment.resize(0);
128 thissegment.push_back(nj);
130 segments.push_back( thissegment );
133 backbone.resize( segments.size() );
134 std::vector<AtomNumber> atomnumbers( atnames.size() );
135 for(
unsigned i=0;i<segments.size();++i){
136 for(
unsigned j=0;j<segments[i].size();++j){
137 bool terminus=( j==0 || j==segments[i].size()-1 );
138 bool foundatoms=
pdb.
getBackbone( segments[i][j], atnames, atomnumbers );
139 if( terminus && !foundatoms ){
141 warning(
"Assuming residue " + num +
" is a terminal group");
142 }
else if( !foundatoms ){
144 error(
"Could not find required backbone atom in residue number " + num );
145 }
else if( foundatoms ){
146 for(
unsigned k=0;k<atomnumbers.size();++k) backbone[i].push_back( atomnumbers[k] );
151 for(
unsigned i=0;i<backbone.size();++i){
152 if( backbone[i].size()%atnames.size()!=0 )
error(
"number of atoms in one of the segments of backbone is not a multiple of the number of atoms in each residue");
Simple class to store the index of an atom.
bool read(const std::string &file, bool naturalUnits, double scale)
Read the pdb from a file, scaling positions by a factor scale.
unsigned getResidueNumber(AtomNumber a) const
return the residue number for a specific atom
Log & log
Reference to the log stream.
void getAtomRange(const std::string &chainname, AtomNumber &a_start, AtomNumber &a_end, std::string &errmsg) const
Get the atoms in each of the chains.
void warning(const std::string &msg)
Issue a warning.
unsigned serial() const
Returns the serial number.
SetupMolInfo(const ActionOptions &ao)
void error(const std::string &msg) const
Crash calculation and print documentation.
std::string getAtomName(AtomNumber a) const
return the name of a specific atom
void parseAtomList(const std::string &key, std::vector< AtomNumber > &t)
Parse a list of atoms without a numbered keyword.
void add(const std::string &t, const std::string &k, const std::string &d)
Add a new keyword of type t with name k and description d.
void getChainNames(std::vector< std::string > &chains) const
Get the names of all the chains in the pdb file.
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...
std::string getAtomName(AtomNumber a) const
Action used to create a PLMD::Action that do something during setup only e.g.
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
This class holds the keywords and their documentation.
static void registerKeywords(Keywords &keys)
Creator of keywords.
void getBackbone(std::vector< std::string > &resstrings, const std::vector< std::string > &atnames, std::vector< std::vector< AtomNumber > > &backbone)
This class is used to bring the relevant information to the Action constructor.
Action used to create objects that access the positions of the atoms from the MD code.
unsigned getResidueNumber(AtomNumber a) const
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
Base class for all the input Actions.
std::string getResidueName(AtomNumber a) const
return the residue name for a specific atom
std::vector< std::vector< AtomNumber > > read_backbone
std::string getResidueName(AtomNumber a) const
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.
static void registerKeywords(Keywords &keys)
std::string getChainID(const unsigned &resnumber) const
Get the chain ID that a particular residue is a part of.
void getResidueRange(const std::string &chainname, unsigned &res_start, unsigned &res_end, std::string &errmsg) const
Get the residues in each of the chains.