~sfiorucci/ptools/test_seb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef ATOM_H
#define ATOM_H

#include "basetypes.h"

#include <string>
#include <iostream>
#include "coord3d.h"

namespace PTools{


class Atomproperty {
private:
    std::string mAtomType;  ///< CA, N, HN1, ...
    std::string mAtomElement; ///< C, N, H, O, etc.
    std::string mResidType; ///< LEU, ARG, ...
    std::string mChainId; ///< A, B, etc.
    uint mResidId; ///< residue number
    uint mAtomId; ///< atom number
    dbl mAtomCharge; ///< charge of the atom
    std::string mExtra; ///< extra data

public:
    /// default constructor
    Atomproperty()
    {
        mAtomType="X";
        mAtomElement="X";
        mResidType="XXX";
        mChainId="X";
        mResidId=1;
        mAtomId=1;
        mAtomCharge=0.0;
    };

    /// return atom type (CA, CB, O, N...)
    std::string GetType() const  {return mAtomType;};

    /// define atom type (CA, CB, O, N...)
    void SetType(std::string newtype) { mAtomType = newtype;};

    /// return residue type (LEU, ARG...)
    std::string GetResidType() const {return mResidType;};

    /// define residue type (LEU, ARG...)
    void SetResidType(std::string residtype){mResidType=residtype;};

    /// return atom charge
    inline dbl GetAtomCharge() const {return mAtomCharge;};

    /// define atom charge
    inline void SetAtomCharge(dbl ch) {mAtomCharge=ch;};

    /// return chain ID (A, B...)
    inline std::string GetChainId() const {return mChainId;};

    /// define chain ID (A, B...)
    inline void SetChainId(std::string chainid) {mChainId=chainid;};

    /// return residue ID (1, 2...)
    inline uint GetResidId() const {return mResidId;};

    /// define residue ID (1, 2...)
    inline void SetResidId(uint id) {mResidId = id;};

    /// return atom ID (1, 2...)
    inline uint GetAtomId() const {return mAtomId;};

    /// define atom ID (1, 2...)
    inline void SetAtomId(uint atomnumber) {mAtomId=atomnumber;};

    /// set the extra data field
    inline void SetExtra(std::string extra){mExtra=extra;};

    /// get the extra data field
    inline std::string GetExtra() const {return mExtra;};

};


class Atom : public Atomproperty
{

private:
    Coord3D mCoords; ///< Atom cartesian coordinates

public:

    Atom(Atomproperty ap, Coord3D co)
            : Atomproperty(ap), mCoords(co) {};
    Coord3D GetCoords() const; ///< return atom coordinates

    /// define atom coordinates
    inline void SetCoords(const Coord3D& coords) {mCoords=coords;};

    /// convert atom (properties and coordinates) to std::string
    std::string ToString() const;

    /// convert atom (properties and coordinates) to classical PDB-like string
    std::string ToPdbString() const ;

    /// translation of an atom
    void Translate(const Coord3D& tr);

};


/// distance between two atoms
inline dbl Dist(const Atom& at1, const Atom& at2)
{
    return Norm(at1.GetCoords()-at2.GetCoords());
}

/// distance**2 between two atoms
inline dbl Dist2(const Atom& at1, const Atom& at2)
{
    return Norm2(at1.GetCoords()-at2.GetCoords());
}


}

#endif