~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
// $Id$
#include <sstream>
#include <stdio.h>

#include "atom.h"
#include "coord3d.h"

using namespace std;

namespace PTools{

Coord3D Atom::GetCoords() const {return mCoords;}

//! Convert an atom to a string
std::string Atom::ToString() const {
    std::stringstream info;
    info<<GetAtomId()<<" "<<GetType()<<" ";
    info<<GetResidType()<<" "<<GetChainId()<<" "<<GetResidId();
    Coord3D coord = GetCoords();
    info<<PrintCoord(coord);
    return info.str();
}


//! convert an atom to a string in PDB format
std::string Atom::ToPdbString() const
{
    char output[81];
    const char* atomname = GetType().c_str();
    const char* residName = GetResidType().c_str();
    int residnumber = GetResidId();
    const char* chainID = GetChainId().c_str();

    int atomnumber = GetAtomId();

    Coord3D coord = GetCoords();
    double x = coord.x;
    double y = coord.y;
    double z = coord.z ;

    snprintf(output,80,"ATOM  %5d  %-4s%3s %1s%4d    %8.3f%8.3f%8.3f%s\n",atomnumber,atomname,residName,chainID,residnumber,x,y,z,GetExtra().c_str());
    output[79]='\n';
    output[80]='\0';
    return std::string(output);
}

//! translate an atom with a Coord3D vector
void Atom::Translate(const Coord3D& tr)
{
    mCoords=mCoords+tr;
}


} // namespace PTools