Skip to content
Snippets Groups Projects
Commit f3ce5e81 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Added possibility to retrieve more info from MOLINFO

parent e09429fa
No related branches found
No related tags found
No related merge requests found
...@@ -151,4 +151,17 @@ void SetupMolInfo::getBackbone( std::vector<std::string>& restrings, const std:: ...@@ -151,4 +151,17 @@ void SetupMolInfo::getBackbone( std::vector<std::string>& restrings, const std::
} }
} }
std::string SetupMolInfo::getAtomName(AtomNumber a)const{
return pdb.getAtomName(a);
}
unsigned SetupMolInfo::getResidueNumber(AtomNumber a)const{
return pdb.getResidueNumber(a);
}
std::string SetupMolInfo::getResidueName(AtomNumber a)const{
return pdb.getResidueName(a);
}
} }
...@@ -41,6 +41,9 @@ public: ...@@ -41,6 +41,9 @@ public:
static void registerKeywords( Keywords& keys ); static void registerKeywords( Keywords& keys );
SetupMolInfo(const ActionOptions&ao); SetupMolInfo(const ActionOptions&ao);
void getBackbone( std::vector<std::string>& resstrings, const std::vector<std::string>& atnames, std::vector< std::vector<AtomNumber> >& backbone ); void getBackbone( std::vector<std::string>& resstrings, const std::vector<std::string>& atnames, std::vector< std::vector<AtomNumber> >& backbone );
std::string getAtomName(AtomNumber a)const;
unsigned getResidueNumber(AtomNumber a)const;
std::string getResidueName(AtomNumber a)const;
}; };
} }
......
...@@ -48,6 +48,27 @@ const std::vector<AtomNumber> & PDB::getAtomNumbers()const{ ...@@ -48,6 +48,27 @@ const std::vector<AtomNumber> & PDB::getAtomNumbers()const{
return numbers; return numbers;
} }
std::string PDB::getAtomName(AtomNumber a)const{
std::map<AtomNumber,unsigned>::const_iterator p;
p=number2index.find(a);
if(p==number2index.end()) return "";
else return atomsymb[p->second];
}
unsigned PDB::getResidueNumber(AtomNumber a)const{
std::map<AtomNumber,unsigned>::const_iterator p;
p=number2index.find(a);
if(p==number2index.end()) return 0;
else return residue[p->second];
}
std::string PDB::getResidueName(AtomNumber a) const{
std::map<AtomNumber,unsigned>::const_iterator p;
p=number2index.find(a);
if(p==number2index.end()) return "";
else return residuenames[p->second];
}
unsigned PDB::size()const{ unsigned PDB::size()const{
return positions.size(); return positions.size();
} }
...@@ -65,6 +86,7 @@ bool PDB::readFromFilepointer(FILE *fp,bool naturalUnits,double scale){ ...@@ -65,6 +86,7 @@ bool PDB::readFromFilepointer(FILE *fp,bool naturalUnits,double scale){
string record=line.substr(0,6); string record=line.substr(0,6);
string serial=line.substr(6,5); string serial=line.substr(6,5);
string atomname=line.substr(12,4); string atomname=line.substr(12,4);
string residuename=line.substr(17,3);
string chainID=line.substr(21,1); string chainID=line.substr(21,1);
string resnum=line.substr(22,4); string resnum=line.substr(22,4);
string x=line.substr(30,8); string x=line.substr(30,8);
...@@ -94,6 +116,7 @@ bool PDB::readFromFilepointer(FILE *fp,bool naturalUnits,double scale){ ...@@ -94,6 +116,7 @@ bool PDB::readFromFilepointer(FILE *fp,bool naturalUnits,double scale){
// scale into nm // scale into nm
p*=scale; p*=scale;
numbers.push_back(a); numbers.push_back(a);
number2index[a]=positions.size();
std::size_t startpos=atomname.find_first_not_of(" \t"); std::size_t startpos=atomname.find_first_not_of(" \t");
std::size_t endpos=atomname.find_last_not_of(" \t"); std::size_t endpos=atomname.find_last_not_of(" \t");
atomsymb.push_back( atomname.substr(startpos, endpos-startpos+1) ); atomsymb.push_back( atomname.substr(startpos, endpos-startpos+1) );
...@@ -102,6 +125,7 @@ bool PDB::readFromFilepointer(FILE *fp,bool naturalUnits,double scale){ ...@@ -102,6 +125,7 @@ bool PDB::readFromFilepointer(FILE *fp,bool naturalUnits,double scale){
occupancy.push_back(o); occupancy.push_back(o);
beta.push_back(b); beta.push_back(b);
positions.push_back(p); positions.push_back(p);
residuenames.push_back(residuename);
} }
} }
return file_is_alive; return file_is_alive;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "Log.h" #include "Log.h"
#include <map>
namespace PLMD{ namespace PLMD{
...@@ -42,6 +43,8 @@ class PDB{ ...@@ -42,6 +43,8 @@ class PDB{
std::vector<double> beta; std::vector<double> beta;
std::vector<std::string> remark; std::vector<std::string> remark;
std::vector<AtomNumber> numbers; std::vector<AtomNumber> numbers;
std::map<AtomNumber,unsigned> number2index;
std::vector<std::string> residuenames;
public: public:
/// Read the pdb from a file, scaling positions by a factor scale /// Read the pdb from a file, scaling positions by a factor scale
bool read(const std::string&file,bool naturalUnits,double scale); bool read(const std::string&file,bool naturalUnits,double scale);
...@@ -73,6 +76,12 @@ public: ...@@ -73,6 +76,12 @@ public:
void renameAtoms( const std::string& old_name, const std::string& new_name ); void renameAtoms( const std::string& old_name, const std::string& new_name );
///use the log to dump information ///use the log to dump information
friend Log& operator<<(Log& ostr, const PDB& pdb); 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;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment