Residue CG6p::to_cg(const Residue &r) const { auto foo = [this](const Residue &res, auto && names) { Residue r; r.m_cg = m_cg; r.name = res.name; for (auto &&name : names) { auto it = std::find_if(res.begin(), res.end(), [&name](auto &&atom) { return atom.name == name; }); std::ostringstream stream; stream << "jian::CG6p::to_cg error! Atom '" << name << "' not found"; if (it == res.end()) throw stream.str(); r.push_back(*it); } return r; }; const CompleteResidue &complete = CompleteResidue::instance(); if (is_cg(r)) { return r; } else { if (complete.lack_atoms(r)) { Residue res = r; complete(res); return foo(res, m_basic_atoms); } else { return foo(r, m_basic_atoms); } } }
Residue make_residue(const string &name, const Mat &coords) { Residue residue; residue.name = name; for (int i = 0; i < coords.rows(); i++) { residue.push_back(Atom(_atom_names[name][i], coords(i, 0), coords(i, 1), coords(i, 2))); } return residue; }
void read(Residue &res) { char c; read(res.name, res.num, res.m_cg); while (true) { read(c); if (c == 'r') { return; } else if (c == 'A') { res.push_back(Atom{}); read(res.back()); } else { throw "This is not a standard '.jn' file! Illegal " + c; } } }