-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxAtom.cpp
More file actions
80 lines (71 loc) · 2.2 KB
/
xAtom.cpp
File metadata and controls
80 lines (71 loc) · 2.2 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: xAtom.cpp
* Author: tg
*
* Created on June 9, 2020, 8:54 AM
*/
#include "xAtom.h"
#include "myExceptions.h"
#include <iostream>
xAtom::xAtom(const std::string& instr, const ShelxState& xstate) {
float x,y,z;
float u[5];
name_ = instr.substr(0, 4);
// strip white space from name_:
std::istringstream ws(name_);
ws >> name_;
std::istringstream conv(instr.substr(4, std::string::npos));
conv >> sfac_ >> x >> y >> z >> sof_ >> U_[0];
if (conv.fail()) {
std::cout << "*** Error: cannot convert line " << instr << " to shelxl atom line\n";
throw myExcepts::ShelxFormat("Atom line");
}
xyz_ = XYZ(x,y,z);
if (!conv.eof()) // expect 5x Uaniso
conv >> u[0] >> u[1] >> u[2] >> u[3] >> u[4];
if (!conv.fail()) { // proper definition of Uaniso
U_[1] = u[0];
U_[2] = u[1];
U_[3] = u[2];
U_[4] = u[3];
U_[5] = u[4];
}
resinum_ = xstate.resinumber();
resiclass_ = xstate.resiclass();
partnum_ = xstate.partnum();
}
/**
* check for selection criteria
* @param name
* @param resiclass
* @param part
* @param resinum
* @return
*/
bool xAtom::match(const std::string name, const std::string& resiclass, int resinum, int part) const {
if (name != name_) return false;
if (part != 0 && partnum_ != 0 && partnum_ != part) return false;
// when residue number is set, residue class is irrelevant
if (resinum != 0 && resinum_ == resinum) return true;
if (resinum == 0 && !resiclass.empty() && resiclass == resiclass)
return true;
return false;
}
/**
* output string of atom name plus residue number (if set) and part number (if set)
* @param out
* @param atom
* @return
*/
std::ostream& operator<< (std::ostream& out, const xAtom& atom) {
out << atom.name_;
if (atom.resinum_ != 0) out << '_' << atom.resinum_;
if (atom.partnum_ != 0) out << '^' << atom.partnum_;
if (atom.resiclass_ != "") out << " Residue " << atom.resiclass_;
return out;
}