use molframe_core::index::EntityIndex;
use molframe_core::structure::Structure;
use molframe_core::topology::PolymerKind;
#[doc(hidden)]
#[must_use]
pub fn declared_polymer_types(structure: &Structure) -> Vec<(EntityIndex, &'static str)> {
let topology = &structure.data().topology;
let mut declared = Vec::new();
for entity in topology.entities.iter() {
let kind = topology.chains.iter().find_map(|chain| {
(topology.chains.entity(chain) == Some(entity))
.then(|| topology.chains.polymer_kind(chain))
.flatten()
.and_then(declared_type)
});
if let Some(kind) = kind {
declared.push((entity, kind));
}
}
declared
}
fn declared_type(kind: PolymerKind) -> Option<&'static str> {
match kind {
PolymerKind::Protein => Some("polypeptide(L)"),
PolymerKind::Dna => Some("polydeoxyribonucleotide"),
PolymerKind::Rna => Some("polyribonucleotide"),
PolymerKind::NucleicHybrid => Some("polydeoxyribonucleotide/polyribonucleotide hybrid"),
PolymerKind::Saccharide => Some("polysaccharide(D)"),
_ => None,
}
}