pub fn index_search(
mol: &Molecule,
enumerate_mode: EnumerateMode,
canonize_mode: CanonizeMode,
parallel_mode: ParallelMode,
memoize_mode: MemoizeMode,
kernel_mode: KernelMode,
bounds: &[Bound],
) -> (u32, u32, usize)
Expand description
Compute a molecule’s assembly index and related information using a top-down recursive algorithm, parameterized by the specified options.
See EnumerateMode
, CanonizeMode
, ParallelMode
, KernelMode
,
and Bound
for details on how to customize the algorithm. Notably,
bounds are applied in the order they appear in the bounds
slice. It is
generally better to provide bounds that are quick to compute first.
The results returned are:
- The molecule’s
u32
assembly index. - The molecule’s
u32
number of non-overlapping isomorphic subgraph pairs. - The
usize
total number of assembly states searched, where an assembly state is a collection of fragments. Note that, depending on the algorithm parameters used, some states may be searched/counted multiple times.
§Example
use assembly_theory::{
assembly::{index_search, ParallelMode},
bounds::Bound,
canonize::CanonizeMode,
enumerate::EnumerateMode,
kernels::KernelMode,
loader::parse_molfile_str,
memoize::MemoizeMode,
};
// Load a molecule from a .mol file.
let path = PathBuf::from(format!("./data/checks/anthracene.mol"));
let molfile = fs::read_to_string(path)?;
let anthracene = parse_molfile_str(&molfile).expect("Parsing failure.");
// Compute the molecule's assembly index without parallelism, memoization,
// kernelization, or bounds.
let (slow_index, _, _) = index_search(
&anthracene,
EnumerateMode::GrowErode,
CanonizeMode::TreeNauty,
ParallelMode::None,
MemoizeMode::None,
KernelMode::None,
&[],
);
// Compute the molecule's assembly index with parallelism, memoization, and
// some bounds.
let (fast_index, _, _) = index_search(
&anthracene,
EnumerateMode::GrowErode,
CanonizeMode::TreeNauty,
ParallelMode::DepthOne,
MemoizeMode::CanonIndex,
KernelMode::None,
&[Bound::Log, Bound::Int],
);
assert_eq!(slow_index, 6);
assert_eq!(fast_index, 6);