LCOV - code coverage report
Current view: top level - tools - PDB.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 1 1 100.0 %
Date: 2021-11-18 15:22:58 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2020 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.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       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 <map>
      30             : #include "Tensor.h"
      31             : 
      32             : 
      33             : namespace PLMD {
      34             : 
      35             : class SetupMolInfo;
      36             : class OFile;
      37             : class Log;
      38             : 
      39             : /// Minimalistic pdb parser.
      40             : /// Contain positions, atomic indexes, occupancy and beta.
      41             : /// We should also add other info (e.g. residue name etc).
      42       40202 : class PDB {
      43             :   std::vector<unsigned> block_ends;
      44             :   std::vector<std::string> atomsymb, chain;
      45             :   std::vector<unsigned> residue;
      46             :   std::vector<Vector> positions;
      47             :   std::vector<double> occupancy;
      48             :   std::vector<double> beta;
      49             :   std::vector<AtomNumber> numbers;
      50             :   std::map<AtomNumber,unsigned> number2index;
      51             :   std::vector<std::string> residuenames;
      52             :   std::string mtype;
      53             :   std::vector<std::string> flags;
      54             :   std::vector<std::string> argnames;
      55             :   std::map<std::string,double> arg_data;
      56             :   Vector BoxXYZ,BoxABG;
      57             :   Tensor Box;
      58             : public:
      59             : /// Read the pdb from a file, scaling positions by a factor scale
      60             :   bool read(const std::string&file,bool naturalUnits,double scale);
      61             : /// Read from a file pointer
      62             :   bool readFromFilepointer(FILE *fp,bool naturalUnits,double scale);
      63             : /// Access to the position array
      64             :   const std::vector<Vector>     & getPositions()const;
      65             : /// Access to the occupancy array
      66             :   const std::vector<double>     & getOccupancy()const;
      67             : /// Access to the beta array
      68             :   const std::vector<double>     & getBeta()const;
      69             : /// Access to the indexes
      70             :   const std::vector<AtomNumber> & getAtomNumbers()const;
      71             : ///
      72             :   std::vector<std::string> getArgumentNames()const;
      73             : /// Add data to argnames map
      74             :   void addRemark( std::vector<std::string>& v1 );
      75             : /// Returns the number of atoms
      76             :   unsigned                        size()const;
      77             : /// Get the names of all the chains in the pdb file
      78             :   void getChainNames( std::vector<std::string>& chains ) const;
      79             : /// Get the residues in each of the chains
      80             :   void getResidueRange( const std::string& chainname, unsigned& res_start, unsigned& res_end, std::string& errmsg ) const;
      81             : /// Get the atoms in each of the chains
      82             :   void getAtomRange( const std::string& chainname, AtomNumber& a_start, AtomNumber& a_end, std::string& errmsg ) const;
      83             : /// Get the chain ID that a particular residue is a part of
      84             :   std::string getChainID(const unsigned& resnumber) const;
      85             : ///use the log to dump information
      86             :   friend Log& operator<<(Log& ostr, const PDB& pdb);
      87             : /// return the name of a specific atom
      88             :   std::string getAtomName(AtomNumber a) const;
      89             : /// return the residue number for a specific atom
      90             :   unsigned getResidueNumber(AtomNumber a) const;
      91             : /// return the residue name for a specific atom
      92             :   std::string getResidueName(AtomNumber a) const;
      93             : /// get the name of the resnum'th residue
      94             :   std::string getResidueName(const unsigned& resnum ) const;
      95             : /// get the name of the resnum'th residue of chain
      96             : /// Chain=="*" matches any chain and makes it equivalent to getResidueName
      97             :   std::string getResidueName(const unsigned& resnum,const std::string& chain ) const;
      98             : /// Check if any of the residues are named name
      99             :   bool checkForResidue( const std::string& name ) const ;
     100             : /// Check if any of the atoms are named atom
     101             :   bool checkForAtom( const std::string& name ) const ;
     102             : /// Return the atom named aname from residue number resnum
     103             :   AtomNumber getNamedAtomFromResidue( const std::string& aname, const unsigned& resnum ) const;
     104             : /// Return the atom named aname from residue number resnum and chain.
     105             : /// Chain=="*" matches any chain and makes it equivalent to getNamedAtomFromResidue.
     106             :   AtomNumber getNamedAtomFromResidueAndChain( const std::string& aname, const unsigned& resnum, const std::string& chain ) const;
     107             : /// Check if the properties that are required are in this pdb this is used in PLMD::mapping::Mapping
     108             : //  bool hasRequiredProperties( const std::vector<std::string>& inproperties );
     109             : /// This is used in PLMD::analysis::AnalysisWithDataCollection to add the sizes of the domains for PLMD::MultiRMSD
     110             :   void addBlockEnd( const unsigned& end );
     111             : /// This is used in PLMD::analysis::AnalysisWithDataCollection to add the numbers of the atoms
     112             :   void setAtomNumbers( const std::vector<AtomNumber>& atoms );
     113             : /// This is used in PLMD::analysis::AnalysisWithDataCollection to set the atom positions
     114             :   void setAtomPositions( const std::vector<Vector>& pos );
     115             : /// Set the argument names that you would like to use
     116             :   void setArgumentNames( const std::vector<std::string>& argument_names );
     117             : /// This is used in PLMD::analysis::AnalysisWithDataCollection to set the argument values
     118             :   void setArgumentValue( const std::string& argname, const double& val );
     119             : /// Get the value of one of the arguments in the PDB file
     120             :   bool getArgumentValue( const std::string& name, double& value ) const ;
     121             : /// Access to the atoms of a residue
     122             :   std::vector<AtomNumber> getAtomsInResidue(const unsigned& resnum,const std::string& chainid)const;
     123             : /// Access to the atoms of a chain
     124             :   std::vector<AtomNumber> getAtomsInChain(const std::string& chainid)const;
     125             : /// Get the extents of the blocks containing the atoms
     126             :   const std::vector<unsigned> & getAtomBlockEnds() const ;
     127             : /// Get the number of blocks of atoms in the pdb
     128             :   unsigned getNumberOfAtomBlocks() const ;
     129             : /// Set the position array
     130             :   void setPositions(const std::vector<Vector> &v);
     131             : /// Access to the position array
     132             :   Vector getPosition(AtomNumber a)const;
     133             : /// Print out a PDB object
     134             :   void print( const double& lunits, SetupMolInfo* mymoldat, OFile& ofile, const std::string& fmt );
     135             : /// Does the PDB have this flag
     136             :   bool hasFlag( const std::string& fname ) const ;
     137             : /// Get the metric type
     138             :   std::string getMtype() const ;
     139             : /// Returns box axis lengths
     140             :   const Vector & getBoxAxs()const;
     141             : /// Returns box axis angles
     142             :   const Vector & getBoxAng()const;
     143             : /// Returns box axis vectors
     144             :   const Tensor & getBoxVec()const;
     145             : };
     146             : 
     147             : }
     148             : #endif

Generated by: LCOV version 1.14