1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
Description: Fix FreeSASA incompatibility with gemmi >= 0.7.0.
Author: Andrius Merkys <merkys@debian.org>
Forwarded: https://github.com/mittinatten/freesasa/issues/101
--- a/src/cif.cc
+++ b/src/cif.cc
@@ -23,19 +23,19 @@
static std::map<size_t, gemmi::cif::Document> docs;
struct ModelDiscriminator {
- ModelDiscriminator(const std::string &model_name,
+ ModelDiscriminator(const int &model_num,
const int model_col = 11)
- : _model_name(model_name), _model_col(model_col)
+ : _model_num(model_num), _model_col(model_col)
{
}
bool operator()(const gemmi::cif::Table::Row &site) const
{
- return _model_name != site[_model_col];
+ return _model_num != std::stoi(site[_model_col]);
}
private:
- const std::string _model_name;
+ const int _model_num;
int _model_col;
};
@@ -57,21 +57,21 @@
};
struct ChainDiscriminator {
- ChainDiscriminator(const std::string &model_name, const std::string &chain_name,
+ ChainDiscriminator(const int &model_num, const std::string &chain_name,
const int model_col = 11, const int chain_col = 1)
- : _model_name(model_name), _chain_name(chain_name),
+ : _model_num(model_num), _chain_name(chain_name),
_model_col(model_col), _chain_col(chain_col)
{
}
bool operator()(const gemmi::cif::Table::Row &site) const
{
- return _model_name != site[_model_col] || _chain_name != site[_chain_col];
+ return _model_num != std::stoi(site[_model_col]) || _chain_name != site[_chain_col];
}
private:
- const std::string _model_name, _chain_name;
- int _model_col, _chain_col;
+ const std::string _chain_name;
+ int _model_num, _model_col, _chain_col;
};
static std::unique_ptr<std::set<int>>
@@ -241,22 +241,22 @@
static freesasa_structure *
structure_from_model(const gemmi::cif::Document &doc,
- const std::string &model_name,
+ const int &model_num,
const freesasa_classifier *classifier,
int structure_options)
{
- const ModelDiscriminator discriminator(model_name);
+ const ModelDiscriminator discriminator(model_num);
return structure_from_pred(doc, discriminator, classifier, structure_options);
}
static freesasa_structure *
structure_from_chain(const gemmi::cif::Document doc,
- const std::string &model_name,
+ const int &model_num,
const std::string &chain_name,
const freesasa_classifier *classifier,
int structure_options)
{
- const ChainDiscriminator discriminator(model_name, chain_name);
+ const ChainDiscriminator discriminator(model_num, chain_name);
return structure_from_pred(doc, discriminator, classifier, structure_options);
}
@@ -291,13 +291,13 @@
if (n_new_chains == 0) {
freesasa_warn("in %s(): no chains found (in model %s)",
- __func__, models[i].name.c_str());
+ __func__, models[i].num);
continue;
}
ss.reserve(n_new_chains);
for (auto &chain_name : *chain_names) {
- freesasa_structure *structure = structure_from_chain(doc, models[i].name, chain_name, classifier, options);
+ freesasa_structure *structure = structure_from_chain(doc, models[i].num, chain_name, classifier, options);
if (freesasa_structure_n(structure) == 0) {
--n_chains;
free(structure);
@@ -318,7 +318,7 @@
ss.reserve(n_models);
for (int i = 0; i < n_models; ++i) {
ss.emplace_back(
- structure_from_model(doc, models[i].name, classifier, options));
+ structure_from_model(doc, models[i].num, classifier, options));
freesasa_structure_set_model(ss.back(), i + 1);
freesasa_structure_set_cif_ref(ss.back(), doc_idx_pair.second, NULL);
}
@@ -712,7 +712,7 @@
// Table exist. Making sure its a loop.
if (!table.loop_item) {
// Table is a pair so turning it into a loop
- table.convert_pair_to_loop();
+ table.ensure_loop();
}
table.get_loop()->clear();
}
|