haddock_restraints/core/commands/
tbl.rs

1use crate::*;
2
3/// Generates a table of Ambiguous Interaction Restraints (AIRs) based on input data.
4///
5/// This function reads interactor data from a JSON file, processes the interactors
6/// according to specified flags, and generates a table of AIRs.
7///
8/// # Arguments
9///
10/// * `input_file` - A string slice that holds the path to the input JSON file.
11///
12/// # Functionality
13///
14/// 1. Reads interactor data from the specified JSON file.
15/// 2. For each interactor with a non-empty structure:
16///    a. If `passive_from_active` is set, derives passive residues from active ones.
17///    b. If `surface_as_passive` is set, treats surface residues as passive.
18///    c. If `filter_buried` is set, removes buried residues from consideration.
19/// 3. Creates an `Air` instance from the processed interactors.
20/// 4. Generates a table of AIRs.
21/// 5. Prints the generated table to stdout.
22///
23pub fn gen_tbl(input_file: &str, pml: &Option<String>) {
24    let mut interactors = read_json_file(input_file).unwrap();
25
26    interactors.iter_mut().for_each(|interactor| {
27        if !interactor.structure().is_empty() {
28            if interactor.passive_from_active() {
29                interactor.set_passive_from_active();
30            }
31
32            if interactor.surface_as_passive() {
33                interactor.set_surface_as_passive();
34            }
35
36            if interactor.filter_buried() {
37                interactor.remove_buried_residues();
38            }
39        }
40    });
41
42    let air = Air::new(interactors);
43
44    let tbl = air.gen_tbl().unwrap();
45
46    println!("{}", tbl);
47
48    if let Some(output_f) = pml {
49        air.gen_pml(output_f)
50    };
51}
52
53#[cfg(test)]
54mod tests {}