7#ifndef GEMMI_ASSEMBLY_HPP_
8#define GEMMI_ASSEMBLY_HPP_
29 bool has(
const std::string& name)
const {
32 const std::string&
added(
const std::string& name) {
38 static const char symbols[] = {
39 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
40 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
41 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
42 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
43 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
46 return added(preferred);
47 std::string name(1,
'A');
48 for (
char symbol : symbols) {
54 for (
char symbol1 : symbols) {
56 for (
char symbol2 : symbols) {
62 fail(
"run out of 1- and 2-letter chain names");
66 std::string name = base;
67 name += std::to_string(n);
69 name.resize(base.size());
70 name += std::to_string(++n);
79 case How::Dup:
return old;
88 if (&ch != &chain && !namegen.
has(ch.name))
89 namegen.
added(ch.name);
98 std::vector<Assembly::Operator> operators(cell.
images.size() + 1);
100 for (
size_t i = 1; i != operators.size(); ++i) {
104 assembly.
generators.push_back({{
"(all)"}, {}, operators});
112 bool keep_spacegroup=
false,
double merge_dist=0.2);
121 double max_dist=0.2,
bool compare_serial=
true);
GEMMI_DLL Model make_assembly(const Assembly &assembly, const Model &model, HowToNameCopiedChain how, std::ostream *out)
GEMMI_DLL Model expand_ncs_model(const Model &model, const std::vector< NcsOp > &ncs, HowToNameCopiedChain how)
GEMMI_DLL void merge_atoms_in_expanded_model(Model &model, const UnitCell &cell, double max_dist=0.2, bool compare_serial=true)
Searches and merges overlapping equivalent atoms from different chains.
GEMMI_DLL void shorten_chain_names(Structure &st)
bool in_vector(const T &x, const std::vector< T > &v)
GEMMI_DLL void expand_ncs(Structure &st, HowToNameCopiedChain how, double merge_dist=0.2)
GEMMI_DLL void split_chains_by_segments(Model &model, HowToNameCopiedChain how)
HowToNameCopiedChain::Dup adds segment name to chain name.
void fail(const std::string &msg)
void ensure_unique_chain_name(const Model &model, Chain &chain)
GEMMI_DLL void transform_to_assembly(Structure &st, const std::string &assembly_name, HowToNameCopiedChain how, std::ostream *out, bool keep_spacegroup=false, double merge_dist=0.2)
If called with assembly_name="unit_cell" changes structure to unit cell (P1).
Assembly pseudo_assembly_for_unit_cell(const UnitCell &cell)
std::vector< Gen > generators
std::string make_name_with_numeric_postfix(const std::string &base, int n)
ChainNameGenerator(How how_)
std::string make_new_name(const std::string &old, int n)
std::string make_short_name(const std::string &preferred)
const std::string & added(const std::string &name)
bool has(const std::string &name) const
std::vector< std::string > used_names
ChainNameGenerator(const Model &model, How how_)
std::vector< Chain > chains
std::vector< FTransform > images