40 std::string atom_name;
43 float float_user_data;
44 std::string string_user_data;
46 atom_spec_t() : chain_id(
"unset") {
47 res_no = mmdb::MinInt4;
52 atom_spec_t(
const std::string &chain_in,
54 const std::string &insertion_code_in,
55 const std::string &atom_name_in,
56 const std::string &alt_conf_in) : chain_id(chain_in), ins_code(insertion_code_in), atom_name(atom_name_in), alt_conf(alt_conf_in) {
63 explicit atom_spec_t(mmdb::Atom *at) {
65 chain_id = at->GetChainID();
66 res_no = at->GetSeqNum();
67 ins_code = at->GetInsCode();
68 model_number = at->GetModelNum();
70 alt_conf = at->altLoc;
73 res_no = mmdb::MinInt4;
81 atom_spec_t(mmdb::Atom *at,
const std::string &user_data_string) {
82 model_number = at->GetModelNum();
83 chain_id = at->GetChainID();
84 res_no = at->GetSeqNum();
85 ins_code = at->GetInsCode();
87 alt_conf = at->altLoc;
88 string_user_data = user_data_string;
94 if (res_no == mmdb::MinInt4)
100 void selectatoms(mmdb::Manager *mol,
int SelHnd) {
101 const char *chainid = chain_id.c_str();
102 const char *inscode = ins_code.c_str();
103 const char *atname = atom_name.c_str();
104 const char *altconf = alt_conf.c_str();
106 mol->SelectAtoms(SelHnd, 0, chainid, res_no, inscode, res_no, inscode,
107 "*", atname,
"*", altconf);
112 bool matches_spec(mmdb::Atom *atom)
const;
114 std::string format()
const;
116 std::string label()
const;
118 std::string label(
const std::string &residue_name)
const;
121 std::string simple_label(
const std::string &residue_name=
"")
const;
124 bool operator==(
const atom_spec_t &matcher)
const {
126 if (matcher.model_number == model_number) {
127 if (matcher.chain_id == chain_id) {
128 if (matcher.res_no == res_no) {
129 if (matcher.ins_code == ins_code) {
130 if (matcher.atom_name == atom_name) {
131 if (matcher.alt_conf == alt_conf) {
141 bool operator !=(
const atom_spec_t &matcher)
const {
142 return ! operator==(matcher);
148 bool operator<(
const atom_spec_t &matcher)
const {
153 if (matcher.model_number < model_number) {
156 if (matcher.chain_id < chain_id) {
159 if (matcher.res_no < res_no) {
162 if (matcher.ins_code < ins_code) {
165 if (matcher.atom_name < atom_name) {
168 if (matcher.alt_conf < alt_conf) {
181 bool is_same(
const atom_spec_t &matcher)
const {
183 if (matcher.chain_id == chain_id) {
184 if (matcher.res_no == res_no) {
185 if (matcher.ins_code == ins_code) {
186 if (matcher.atom_name == atom_name) {
187 if (matcher.alt_conf == alt_conf) {
199 mmdb::Atom *get_atom(mmdb::Manager *mol)
const;
202 friend std::ostream& operator<< (std::ostream& s,
const atom_spec_t &spec);
216 class residue_spec_t {
219 std::string chain_id;
221 std::string ins_code;
223 float float_user_data;
224 std::string string_user_data;
225 explicit residue_spec_t(
int r) : res_no(r) {
228 float_user_data = -1;
230 residue_spec_t(
const std::string &chain_in,
int r) : chain_id(chain_in) {
231 model_number = mmdb::MinInt4;
234 float_user_data = -1;
236 residue_spec_t(
int model_number_in,
237 const std::string &chain_in,
int r,
238 const std::string &ins_code_in) : chain_id(chain_in), ins_code(ins_code_in) {
239 model_number = model_number_in;
242 float_user_data = -1;
244 residue_spec_t(
const std::string &chain_in,
int r,
245 const std::string &ins_code_in) : chain_id(chain_in), ins_code(ins_code_in) {
246 model_number = mmdb::MinInt4;
249 float_user_data = -1;
251 explicit residue_spec_t(mmdb::Residue *res) {
254 model_number = mmdb::MinInt4;
255 res_no = mmdb::MinInt4;
258 chain_id = res->GetChainID();
259 model_number = res->GetModelNum();
260 res_no = res->GetSeqNum();
261 ins_code = res->GetInsCode();
265 explicit residue_spec_t(
const atom_spec_t &atom_spec) : chain_id(atom_spec.chain_id), ins_code(atom_spec.ins_code) {
266 model_number = atom_spec.model_number;
267 res_no = atom_spec.res_no;
269 float_user_data = -1;
273 model_number = mmdb::MinInt4;
274 res_no = mmdb::MinInt4;
276 float_user_data = -1;
278 bool unset_p()
const {
280 if (res_no != mmdb::MinInt4)
287 residue_spec_t next()
const {
288 residue_spec_t r = *
this;
289 if (res_no != mmdb::MinInt4)
293 residue_spec_t previous()
const {
294 residue_spec_t r = *
this;
295 if (res_no != mmdb::MinInt4)
300 bool operator==(
const residue_spec_t &matcher)
const {
301 if (matcher.chain_id == chain_id) {
302 if (matcher.res_no == res_no) {
303 if (matcher.ins_code == ins_code) {
314 bool operator<(
const residue_spec_t &matcher)
const{
315 if (matcher.chain_id == chain_id) {
316 if (matcher.res_no == res_no) {
317 if (matcher.ins_code == ins_code) {
320 if (matcher.ins_code < ins_code)
326 if (matcher.res_no < res_no)
332 if (matcher.chain_id < chain_id)
341 std::string format()
const;
343 std::string label()
const;
345 std::string label(
const std::string &residue_name)
const;
348 mmdb::Residue *get_residue(mmdb::Manager *mol)
const;
356 int select_atoms(mmdb::Manager *mol,
int selhnd,
357 mmdb::SELECTION_KEY selection_key);
360 friend std::ostream& operator<< (std::ostream& s,
const residue_spec_t &spec);