use molframe_core::structure::Structure;
const FALLBACK_BLOCK_ID: &str = "molframe";
pub(crate) fn complete(
structure: &Structure,
options: &molframe_cif::CifWriteOptions,
) -> molframe_cif::CifWriteOptions {
let mut completed = options.clone();
if completed.extra_categories().is_none() {
let text = extension_categories(structure);
completed = completed.with_extra_categories(text);
}
if completed.block_id().is_none() && structure.data().entry.id.is_none() {
completed = completed.with_block_id(FALLBACK_BLOCK_ID);
}
completed
}
#[cfg(feature = "crystal")]
fn extension_categories(structure: &Structure) -> String {
let extensions = structure.extensions();
let mut text = String::new();
if let Some(set) =
extensions.get::<molframe_xtal::SymmetrySet>(molframe_xtal::SYMMETRY_EXTENSION)
{
text.push_str(&molframe_xtal::symmetry_cif(set));
}
if let Some(set) =
extensions.get::<molframe_xtal::AssemblySet>(molframe_xtal::ASSEMBLIES_EXTENSION)
{
text.push_str(&molframe_xtal::assemblies_cif(set));
}
if let Some(set) = extensions.get::<molframe_xtal::NcsSet>(molframe_xtal::NCS_EXTENSION) {
text.push_str(&molframe_xtal::ncs_cif(set));
}
text
}
#[cfg(not(feature = "crystal"))]
fn extension_categories(_structure: &Structure) -> String {
String::new()
}