changed b-factor options for structure loading

This commit is contained in:
Maarten L. Hekkelman
2025-06-11 14:17:50 +02:00
parent e8fb53c49b
commit 82eae05868
3 changed files with 25 additions and 11 deletions

View File

@@ -886,7 +886,8 @@ struct structure_open_options
bool skip_water = false; ///< Do not include water atoms in the structure object
occupancy_policy occupancy_mode = occupancy_policy::ALL; ///< By default, the occupancy policy is set to occupancy_policy::ALL
std::vector<std::string> asyms; ///< The asyms to load, if empty load all
float b_factor_limit = std::numeric_limits<float>::max(); ///< Only load atoms with at least this b_factor
std::optional<float> min_b_factor; ///< Only load atoms with at least this b_factor
std::optional<float> max_b_factor; ///< Only load atoms with at most this b_factor
};
// --------------------------------------------------------------------

View File

@@ -1248,8 +1248,11 @@ void structure::load_atoms_for_model(structure_open_options options)
c = std::move(c) and (cif::key("group_PDB") != "HETATM" or (cif::key("auth_comp_id") == "HOH" or cif::key("auth_comp_id") == "H20" or cif::key("auth_comp_id") == "WAT"));
}
if (options.b_factor_limit < std::numeric_limits<float>::max())
c = std::move(c) and cif::key("B_iso_or_equiv") <= options.b_factor_limit;
if (options.min_b_factor.has_value())
c = std::move(c) and cif::key("B_iso_or_equiv") >= *options.min_b_factor;
if (options.max_b_factor.has_value())
c = std::move(c) and cif::key("B_iso_or_equiv") <= *options.max_b_factor;
if (not options.asyms.empty())
{

View File

@@ -474,14 +474,24 @@ TEST_CASE("options_1")
CHECK(a.get_label_asym_id() == "A");
}
SECTION("b-factor")
SECTION("min-b-factor")
{
cif::mm::structure s(file, 1, { .b_factor_limit = 20.f });
cif::mm::structure s(file, 1, { .min_b_factor = 20.f });
REQUIRE_NOTHROW(s.validate_atoms());
for (auto a : s.atoms())
CHECK(a.get_property_float("B_iso_or_equiv") < 20.f);
CHECK(a.get_property_float("B_iso_or_equiv") >= 20.f);
}
SECTION("max-b-factor")
{
cif::mm::structure s(file, 1, { .max_b_factor = 20.f });
REQUIRE_NOTHROW(s.validate_atoms());
for (auto a : s.atoms())
CHECK(a.get_property_float("B_iso_or_equiv") <= 20.f);
}
}