1 /******************************************************************************
2 
3   This source file is part of the Avogadro project.
4 
5   Copyright 2018 Kitware, Inc.
6 
7   This source code is released under the New BSD License, (the "License").
8 
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14 
15 ******************************************************************************/
16 
17 #ifndef AVOGADRO_CORE_RESIDUE_H
18 #define AVOGADRO_CORE_RESIDUE_H
19 
20 #include "avogadrocore.h"
21 
22 #include <map>
23 #include <string>
24 
25 #include "array.h"
26 #include "bond.h"
27 #include "vector.h"
28 
29 namespace Avogadro {
30 namespace Core {
31 
32 class Atom;
33 class Molecule;
34 
35 /**
36  * @class Residue residue.h <avogadro/core/residue.h>
37  * @brief The Residue class represents a chemical residue, used commonly in the
38  * PDB format.
39  */
40 class AVOGADROCORE_EXPORT Residue
41 {
42 public:
43   /** Type for atom name map. */
44   typedef std::map<std::string, Atom> AtomNameMap;
45 
46   /** Creates a new, empty residue. */
47   Residue();
48   Residue(std::string& name);
49   Residue(std::string& name, Index& number);
50   Residue(std::string& name, Index& number, char& id);
51 
52   Residue(const Residue& other);
53 
54   Residue& operator=(Residue other);
55 
56   virtual ~Residue();
57 
residueName()58   inline std::string residueName() { return m_residueName; }
59 
setResidueName(std::string & name)60   inline void setResidueName(std::string& name) { m_residueName = name; }
61 
residueId()62   inline Index residueId() { return m_residueId; }
63 
setResidueId(Index & number)64   inline void setResidueId(Index& number) { m_residueId = number; }
65 
chainId()66   inline char chainId() { return m_chainId; }
67 
setChainId(char & id)68   inline void setChainId(char& id) { m_chainId = id; }
69 
70   /** Adds an atom to the residue class */
71   void addResidueAtom(std::string& name, Atom& atom);
72 
73   /** Returns a vector containing the atoms added to the residue */
74   std::vector<Atom> residueAtoms();
75 
76   /** Sets bonds to atoms in the residue based on data from residuedata header
77    */
78   void resolveResidueBonds(Molecule& mol);
79 
80   int getAtomicNumber(std::string name);
81 
82 protected:
83   std::string m_residueName;
84   Index m_residueId;
85   char m_chainId;
86   AtomNameMap m_atomNameMap;
87 };
88 
89 } // namespace Core
90 } // namespace Avogadro
91 
92 #endif // AVOGADRO_CORE_RESIDUE_H
93