12#include <mmdb2/mmdb_manager.h>
17 mmdb::mat33& mat, mmdb::vect3& vec) {
18 for (
int i = 0;
i < 3; ++
i) {
19 for (
int j = 0;
j < 3; ++
j)
21 vec[
i] = tr.
vec.at(
i);
27 if (
src.size() + 1 >=
N)
28 fail(
"This string is too long: " +
src);
29 std::memcpy(
dest,
src.c_str(),
src.size() + 1);
34 icode[0] = icode[1] =
'\0';
36 icode[0] = seqid.
icode;
44 mmdb::CisPep*
m =
new mmdb::CisPep();
52 m->modNum = model_num;
53 m->measure =
g.reported_angle;
59 g.partner_c.res_id.name =
m.pep1;
61 g.partner_c.chain_name =
m.chainID1;
62 g.partner_n.res_id.name =
m.pep2;
64 g.partner_n.chain_name =
m.chainID2;
65 g.model_num = model_num;
66 g.reported_angle =
m.measure;
73 if (!
con.partner1.res_id.seqid.num || !
con.partner2.res_id.seqid.num)
78 link.aloc1[0] =
con.partner1.altloc;
84 link.aloc2[0] =
con.partner2.altloc;
88 if (
con.reported_distance > 0)
89 link.dist =
con.reported_distance;
106 mmdb::Link&
link = *
static_cast<mmdb::Link*
>(
mmdb_links.GetContainerClass(
i));
109 con.partner1.atom_name =
link.atName1;
110 con.partner1.altloc =
link.aloc1[0];
112 con.partner1.res_id.name =
link.resName1;
113 con.partner1.chain_name =
link.chainID1;
115 con.partner2.atom_name =
link.atName2;
116 con.partner2.altloc =
link.aloc2[0];
118 con.partner2.res_id.name =
link.resName2;
119 con.partner2.chain_name =
link.chainID2;
120 con.reported_distance =
link.dist;
133 st.connections.push_back(
con);
138 for (
const std::string& s :
st.raw_remarks) {
145 mmdb::Model*
model2 = mmdb::newModel();
149 mmdb::Chain*
chain2 =
model2->CreateChain(chain.name.c_str());
150 for (
const Residue& res : chain.residues) {
152 if (res.seqid.has_icode())
153 icode[0] = res.seqid.icode;
154 mmdb::Residue* res2 =
chain2->GetResidueCreate(res.name.c_str(),
158 for (
const Atom& atom : res.atoms) {
159 mmdb::Atom*
atom2 = mmdb::newAtom();
160 const char altloc[2] = {atom.altloc,
'\0'};
161 std::string padded_name = atom.padded_name();
163 if (padded_name.size() < 4)
164 padded_name.resize(4,
' ');
165 atom2->SetAtomName(0, atom.serial, padded_name.c_str(),
166 altloc, res.segment.c_str(), atom.element.uname());
167 atom2->Het = res.het_flag ==
'H';
168 atom2->SetCharge(atom.charge);
169 atom2->SetCoordinates(atom.pos.x, atom.pos.y, atom.pos.z,
170 atom.occ, atom.b_iso);
171 if (atom.aniso.nonzero()) {
172 atom2->u11 = atom.aniso.u11;
173 atom2->u22 = atom.aniso.u22;
174 atom2->u33 = atom.aniso.u33;
175 atom2->u12 = atom.aniso.u12;
176 atom2->u13 = atom.aniso.u13;
177 atom2->u23 = atom.aniso.u23;
178 atom2->WhatIsSet |= mmdb::ASET_Anis_tFSigma;
180 res2->AddAtom(
atom2);
184 (&res == &chain.residues.back() ||
186 mmdb::Atom*
atom2 = mmdb::newAtom();
188 atom2->serNum = res.atoms.back().serial + 1;
189 res2->AddAtom(
atom2);
194 st.cell.alpha,
st.cell.beta,
st.cell.gamma, 1);
195 manager->SetSpaceGroup(
st.spacegroup_hm.c_str());
197 auto z =
st.info.find(
"_cell.Z_PDB");
198 if (z !=
st.info.end() && !z->second.empty()) {
199 cryst->Z = std::atoi(z->second.c_str());
200 cryst->WhatIsSet |= mmdb::CSET_ZValue;
202 if (
st.has_origx && !
st.origx.is_identity()) {
204 cryst->WhatIsSet |= mmdb::CSET_OrigMatrix;
206 if (
st.cell.explicit_matrices) {
208 cryst->WhatIsSet |= mmdb::CSET_ScaleMatrix;
210 if (!
st.ncs.empty()) {
213 if (
st.info.find(
"_struct_ncs_oper.id") !=
st.info.end()) {
215 cryst->AddNCSMatrix(
m, v, 1);
217 for (
const NcsOp& op :
st.ncs) {
219 cryst->AddNCSMatrix(
m, v, op.given);
223 if (!
st.cispeps.empty() && !
st.models.empty()) {
248 if (
m_atom.WhatIsSet & mmdb::ASET_Anis_tFSigma) {
263 int n =
m_res.GetNumberOfAtoms();
264 res.
atoms.reserve(n);
266 for (
int i = 0;
i < n; ++
i)
284 int n =
m_chain.GetNumberOfResidues();
286 for (
int i = 0;
i < n; ++
i)
304 int n =
m_model.GetNumberOfChains();
306 for (
int i = 0;
i < n; ++
i)
316 if (
cryst.WhatIsSet & mmdb::CSET_ZValue)
317 st.info.emplace(
"_cell.Z_PDB", std::to_string(
cryst.Z));
318 st.spacegroup_hm =
cryst.spaceGroup;
319 int n =
manager->GetNumberOfModels();
320 st.models.reserve(n);
321 for (
int i = 1;
i <= n; ++
i)
324 int model_num =
st.models.back().num;
325 for (
int j = 1;
j <=
m_model->GetNumberOfCisPeps(); ++
j)
Data structures to store macromolecular structure models.
void strcpy_to_mmdb(char(&dest)[N], const std::string &src)
Model copy_model_from_mmdb(mmdb::Model &m_model)
void transfer_links_to_mmdb(const Structure &st, mmdb::Manager *mol)
std::string rtrim_str(const std::string &str)
void set_seqid_in_mmdb(int *seqnum, mmdb::InsCode &icode, SeqId seqid)
Residue copy_residue_from_mmdb(mmdb::Residue &m_res)
SeqId seqid_from_mmdb(int seqnum, const mmdb::InsCode &inscode)
CisPep cispep_from_mmdb(const mmdb::CisPep &m, int model_num)
Atom copy_atom_from_mmdb(mmdb::Atom &m_atom)
void copy_to_mmdb(const Structure &st, mmdb::Manager *manager)
void copy_transform_to_mmdb(const Transform &tr, mmdb::mat33 &mat, mmdb::vect3 &vec)
Structure copy_from_mmdb(mmdb::Manager *manager)
Chain copy_chain_from_mmdb(mmdb::Chain &m_chain)
void fail(const std::string &msg)
mmdb::CisPep * cispep_to_mmdb(const CisPep &g, int ser_num, int model_num)
void transfer_links_from_mmdb(mmdb::LinkContainer &mmdb_links, Structure &st)
Represents atom site in macromolecular structure (~100 bytes).
std::vector< Residue > residues
std::vector< Chain > chains
Non-crystallographic symmetry operation (such as in the MTRIXn record)
Coordinates in Angstroms - orthogonal (Cartesian) coordinates.
std::vector< Atom > atoms
Utilities. Mostly for working with strings and vectors.