1 //
2 //  Copyright (C) 2013 Greg Landrum
3 //
4 //   @@ All Rights Reserved @@
5 //  This file is part of the RDKit.
6 //  The contents are covered by the terms of the BSD license
7 //  which is included in the file license.txt, found at the root
8 //  of the RDKit source tree.
9 //
10 /*! \file MonomerInfo.h
11 
12   \brief Defines Monomer information classes
13 
14 */
15 #include <RDGeneral/export.h>
16 #ifndef _RD_MONOMERINFO_H
17 #define _RD_MONOMERINFO_H
18 
19 #include <string>
20 #include <boost/shared_ptr.hpp>
21 
22 namespace RDKit {
23 
24 //! The abstract base class for atom-level monomer info
25 class RDKIT_GRAPHMOL_EXPORT AtomMonomerInfo {
26  public:
27   typedef enum { UNKNOWN = 0, PDBRESIDUE, OTHER } AtomMonomerType;
28 
~AtomMonomerInfo()29   virtual ~AtomMonomerInfo(){};
30 
AtomMonomerInfo()31   AtomMonomerInfo() :  d_name(""){};
32   AtomMonomerInfo(AtomMonomerType typ, const std::string &nm = "")
d_monomerType(typ)33       : d_monomerType(typ), d_name(nm){};
AtomMonomerInfo(const AtomMonomerInfo & other)34   AtomMonomerInfo(const AtomMonomerInfo &other)
35       : d_monomerType(other.d_monomerType), d_name(other.d_name){};
36 
getName()37   const std::string &getName() const { return d_name; };
setName(const std::string & nm)38   void setName(const std::string &nm) { d_name = nm; };
getMonomerType()39   AtomMonomerType getMonomerType() const { return d_monomerType; };
setMonomerType(AtomMonomerType typ)40   void setMonomerType(AtomMonomerType typ) { d_monomerType = typ; };
41 
copy()42   virtual AtomMonomerInfo *copy() const { return new AtomMonomerInfo(*this); }
43 
44  private:
45   AtomMonomerType d_monomerType{UNKNOWN};
46   std::string d_name;
47 };
48 
49 //! Captures atom-level information about peptide residues
50 class RDKIT_GRAPHMOL_EXPORT AtomPDBResidueInfo : public AtomMonomerInfo {
51  public:
AtomPDBResidueInfo()52   AtomPDBResidueInfo() : AtomMonomerInfo(PDBRESIDUE){};
AtomPDBResidueInfo(const AtomPDBResidueInfo & other)53   AtomPDBResidueInfo(const AtomPDBResidueInfo &other)
54       : AtomMonomerInfo(other),
55         d_serialNumber(other.d_serialNumber),
56         d_altLoc(other.d_altLoc),
57         d_residueName(other.d_residueName),
58         d_residueNumber(other.d_residueNumber),
59         d_chainId(other.d_chainId),
60         d_insertionCode(other.d_insertionCode),
61         d_occupancy(other.d_occupancy),
62         d_tempFactor(other.d_tempFactor),
63         df_heteroAtom(other.df_heteroAtom),
64         d_secondaryStructure(other.d_secondaryStructure),
65         d_segmentNumber(other.d_segmentNumber){};
66 
67   AtomPDBResidueInfo(const std::string &atomName, int serialNumber = 0,
68                      const std::string &altLoc = "",
69                      const std::string &residueName = "", int residueNumber = 0,
70                      const std::string &chainId = "",
71                      const std::string &insertionCode = "",
72                      double occupancy = 1.0, double tempFactor = 0.0,
73                      bool isHeteroAtom = false,
74                      unsigned int secondaryStructure = 0,
75                      unsigned int segmentNumber = 0)
AtomMonomerInfo(PDBRESIDUE,atomName)76       : AtomMonomerInfo(PDBRESIDUE, atomName),
77         d_serialNumber(serialNumber),
78         d_altLoc(altLoc),
79         d_residueName(residueName),
80         d_residueNumber(residueNumber),
81         d_chainId(chainId),
82         d_insertionCode(insertionCode),
83         d_occupancy(occupancy),
84         d_tempFactor(tempFactor),
85         df_heteroAtom(isHeteroAtom),
86         d_secondaryStructure(secondaryStructure),
87         d_segmentNumber(segmentNumber){};
88 
getSerialNumber()89   int getSerialNumber() const { return d_serialNumber; };
setSerialNumber(int val)90   void setSerialNumber(int val) { d_serialNumber = val; };
getAltLoc()91   const std::string &getAltLoc() const { return d_altLoc; };
setAltLoc(const std::string & val)92   void setAltLoc(const std::string &val) { d_altLoc = val; };
getResidueName()93   const std::string &getResidueName() const { return d_residueName; };
setResidueName(const std::string & val)94   void setResidueName(const std::string &val) { d_residueName = val; };
getResidueNumber()95   int getResidueNumber() const { return d_residueNumber; };
setResidueNumber(int val)96   void setResidueNumber(int val) { d_residueNumber = val; };
getChainId()97   const std::string &getChainId() const { return d_chainId; };
setChainId(const std::string & val)98   void setChainId(const std::string &val) { d_chainId = val; };
getInsertionCode()99   const std::string &getInsertionCode() const { return d_insertionCode; };
setInsertionCode(const std::string & val)100   void setInsertionCode(const std::string &val) { d_insertionCode = val; };
getOccupancy()101   double getOccupancy() const { return d_occupancy; };
setOccupancy(double val)102   void setOccupancy(double val) { d_occupancy = val; };
getTempFactor()103   double getTempFactor() const { return d_tempFactor; };
setTempFactor(double val)104   void setTempFactor(double val) { d_tempFactor = val; };
getIsHeteroAtom()105   bool getIsHeteroAtom() const { return df_heteroAtom; };
setIsHeteroAtom(bool val)106   void setIsHeteroAtom(bool val) { df_heteroAtom = val; };
getSecondaryStructure()107   unsigned int getSecondaryStructure() const { return d_secondaryStructure; };
setSecondaryStructure(unsigned int val)108   void setSecondaryStructure(unsigned int val) { d_secondaryStructure = val; };
getSegmentNumber()109   unsigned int getSegmentNumber() const { return d_segmentNumber; };
setSegmentNumber(unsigned int val)110   void setSegmentNumber(unsigned int val) { d_segmentNumber = val; };
111 
copy()112   AtomMonomerInfo *copy() const {
113     return static_cast<AtomMonomerInfo *>(new AtomPDBResidueInfo(*this));
114   }
115 
116  private:
117   // the fields here are from the PDB definition
118   // (http://www.wwpdb.org/documentation/format33/sect9.html#ATOM) [9 Aug, 2013]
119   // element and charge are not present since the atom itself stores that
120   // information
121   unsigned int d_serialNumber = 0;
122   std::string d_altLoc = "";
123   std::string d_residueName = "";
124   int d_residueNumber = 0;
125   std::string d_chainId = "";
126   std::string d_insertionCode = "";
127   double d_occupancy = 1.0;
128   double d_tempFactor = 0.0;
129   // additional, non-PDB fields:
130   bool df_heteroAtom = false;  // is this from a HETATM record?
131   unsigned int d_secondaryStructure = 0;
132   unsigned int d_segmentNumber = 0;
133 };
134 };  // namespace RDKit
135 //! allows AtomPDBResidueInfo objects to be dumped to streams
136 RDKIT_GRAPHMOL_EXPORT std::ostream &operator<<(
137     std::ostream &target, const RDKit::AtomPDBResidueInfo &apri);
138 
139 #endif
140