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: 2018-12-19 07:49:13 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2018 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 "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        8332 : class PDB {
      39             :   std::vector<unsigned> block_ends;
      40             :   std::vector<std::string> atomsymb, chain;
      41             :   std::vector<unsigned> residue;
      42             :   std::vector<Vector> positions;
      43             :   std::vector<double> occupancy;
      44             :   std::vector<double> beta;
      45             :   std::vector<std::string> remark;
      46             :   std::vector<AtomNumber> numbers;
      47             :   std::map<AtomNumber,unsigned> number2index;
      48             :   std::vector<std::string> residuenames;
      49             : public:
      50             : /// Read the pdb from a file, scaling positions by a factor scale
      51             :   bool read(const std::string&file,bool naturalUnits,double scale);
      52             : /// Read from a file pointer
      53             :   bool readFromFilepointer(FILE *fp,bool naturalUnits,double scale);
      54             : /// Access to the position array
      55             :   const std::vector<Vector>     & getPositions()const;
      56             : /// Access to the occupancy array
      57             :   const std::vector<double>     & getOccupancy()const;
      58             : /// Access to the beta array
      59             :   const std::vector<double>     & getBeta()const;
      60             : /// This is used to set the keyword ARG - this is so we
      61             : /// we can use a1.* in the input for reference configurations
      62             :   void setArgKeyword( const std::string& new_args );
      63             : /// Add information to the remark
      64             :   void addRemark( const std::vector<std::string>& v1 );
      65             : /// Access to the lines of REMARK
      66             :   const std::vector<std::string>     & getRemark()const;
      67             : /// Access to the indexes
      68             :   const std::vector<AtomNumber> & getAtomNumbers()const;
      69             : /// Returns the number of atoms
      70             :   unsigned                        size()const;
      71             : /// Get the names of all the chains in the pdb file
      72             :   void getChainNames( std::vector<std::string>& chains ) const;
      73             : /// Get the residues in each of the chains
      74             :   void getResidueRange( const std::string& chainname, unsigned& res_start, unsigned& res_end, std::string& errmsg ) const;
      75             : /// Get the atoms in each of the chains
      76             :   void getAtomRange( const std::string& chainname, AtomNumber& a_start, AtomNumber& a_end, std::string& errmsg ) const;
      77             : /// Get the chain ID that a particular residue is a part of
      78             :   std::string getChainID(const unsigned& resnumber) const;
      79             : ///use the log to dump information
      80             :   friend Log& operator<<(Log& ostr, const PDB& pdb);
      81             : /// return the name of a specific atom
      82             :   std::string getAtomName(AtomNumber a) const;
      83             : /// return the residue number for a specific atom
      84             :   unsigned getResidueNumber(AtomNumber a) const;
      85             : /// return the residue name for a specific atom
      86             :   std::string getResidueName(AtomNumber a) const;
      87             : /// get the name of the resnum'th residue
      88             :   std::string getResidueName(const unsigned& resnum ) const;
      89             : /// get the name of the resnum'th residue of chain
      90             : /// Chain=="*" matches any chain and makes it equivalent to getResidueName
      91             :   std::string getResidueName(const unsigned& resnum,const std::string& chain ) const;
      92             : /// Check if any of the residues are named name
      93             :   bool checkForResidue( const std::string& name ) const ;
      94             : /// Check if any of the atoms are named atom
      95             :   bool checkForAtom( const std::string& name ) const ;
      96             : /// Return the atom named aname from residue number resnum
      97             :   AtomNumber getNamedAtomFromResidue( const std::string& aname, const unsigned& resnum ) const;
      98             : /// Return the atom named aname from residue number resnum and chain.
      99             : /// Chain=="*" matches any chain and makes it equivalent to getNamedAtomFromResidue.
     100             :   AtomNumber getNamedAtomFromResidueAndChain( const std::string& aname, const unsigned& resnum, const std::string& chain ) const;
     101             : /// Access to the atoms of a residue
     102             :   std::vector<AtomNumber> getAtomsInResidue(const unsigned& resnum,const std::string& chainid)const;
     103             : /// Access to the atoms of a chain
     104             :   std::vector<AtomNumber> getAtomsInChain(const std::string& chainid)const;
     105             : /// Get the extents of the blocks containing the atoms
     106             :   const std::vector<unsigned> & getAtomBlockEnds() const ;
     107             : /// Get the number of blocks of atoms in the pdb
     108             :   unsigned getNumberOfAtomBlocks() const ;
     109             : /// Set the position array
     110             :   void setPositions(const std::vector<Vector> &v);
     111             : /// Access to the position array
     112             :   Vector getPosition(AtomNumber a)const;
     113             : };
     114             : 
     115             : }
     116             : #endif

Generated by: LCOV version 1.13