Skip to content

Commit

Permalink
crd: write ncs matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
keitaroyam committed Apr 6, 2024
1 parent 8dadf35 commit 2e559d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/gemmi/to_mmcif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ GEMMI_DLL cif::Block make_mmcif_headers(const Structure& st);
GEMMI_DLL void add_minimal_mmcif_data(const Structure& st, cif::Block& block);

// temporarily we use it in crd.cpp
GEMMI_DLL void write_ncs_oper(const Structure& st, cif::Block& block);
GEMMI_DLL void write_struct_conn(const Structure& st, cif::Block& block);
GEMMI_DLL void write_cispeps(const Structure& st, cif::Block& block);

Expand Down
6 changes: 6 additions & 0 deletions src/crd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ cif::Block prepare_crd(const Structure& st, const Topo& topo,
if (const SpaceGroup* sg = st.find_spacegroup())
items.emplace_back("_symmetry.Int_Tables_number",
std::to_string(sg->number));
if (!st.ncs.empty()) {
items.emplace_back(cif::CommentArg{"#########\n"
"## NCS ##\n"
"#########"});
write_ncs_oper(st, block);
}
const Model& model0 = st.first_model();
items.emplace_back(cif::CommentArg{"#################\n"
"## STRUCT_ASYM ##\n"
Expand Down
14 changes: 7 additions & 7 deletions src/to_mmcif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ void write_cell_parameters(const UnitCell& cell, cif::ItemSpan& span) {
span.set_pair("_cell.angle_gamma", to_str(cell.gamma));
}

bool is_valid_block_name(const std::string& name) {
return !name.empty() &&
std::all_of(name.begin(), name.end(), [](char c){ return c >= '!' && c <= '~'; });
}

} // anonymous namespace

void write_ncs_oper(const Structure& st, cif::Block& block) {
// _struct_ncs_oper (MTRIX)
if (st.ncs.empty())
Expand All @@ -321,13 +328,6 @@ void write_ncs_oper(const Structure& st, cif::Block& block) {
add_op(op);
}

bool is_valid_block_name(const std::string& name) {
return !name.empty() &&
std::all_of(name.begin(), name.end(), [](char c){ return c >= '!' && c <= '~'; });
}

} // anonymous namespace

void write_struct_conn(const Structure& st, cif::Block& block) {
// example:
// disulf1 disulf A CYS 3 SG ? 3 ? 1_555 A CYS 18 SG ? 18 ? 1_555 ? 2.045
Expand Down

0 comments on commit 2e559d8

Please sign in to comment.