Skip to main content

molar/
lib.rs

1//! MolAR is a library for molecular modeling and analysis written in Rust with an emphasis on memory safety and performance.
2//! Molar is designed to simplify the analysis of molecular dynamics trajectories and to implement new analysis algorithms. Molar is intended to provide facilities, which are routinely used in all molecular analysis programs, namely input/output of popular file formats, powerful and flexible atom selections, geometry transformations, RMSD fitting and alignment, etc.
3//! MolAR is a logical successor of [Pteros](https://github.com/yesint/pteros) molecular modeling library, which is written in C++ and become hard to develop and maintain due to all C++ idiosyncrasies.
4
5mod aliases;
6mod analysis_task;
7mod atom;
8mod atom_storage;
9mod bond;
10mod bond_storage;
11mod connectivity;
12mod distance_search;
13mod dss;
14mod dssp;
15mod measure;
16mod modify;
17mod ndx_file;
18mod par;
19mod particle;
20mod perception;
21mod periodic_box;
22mod periodic_table;
23mod providers;
24mod sasa;
25mod secondary_structure;
26mod selection;
27mod smiles;
28mod state;
29mod topology;
30mod seq_align;
31
32pub mod io;
33pub mod voronoi_cell;
34
35/// Most useful public imports exposed to the users
36pub mod prelude {
37    pub use crate::{
38        aliases::*, analysis_task::*, atom::*, atom_storage::*, bond::*, bond_storage::*,
39        connectivity::*,
40        distance_search::*, dssp::*, io::*, measure::*, modify::*, ndx_file::*, particle::*,
41        perception::*, periodic_box::*, providers::*, dss::*, sasa::*, secondary_structure::*,
42        selection::*, smiles::*, state::*, topology::*,
43    };
44    // Parallel-iterator traits via the `par` shim: rayon on native, serial
45    // std-iterator fallbacks on wasm32 (which has no threads). See `crate::par`.
46    pub use crate::par::*;
47}
48
49pub use crate::{
50    aliases::*, analysis_task::*, atom::*, bond::*, connectivity::*, distance_search::*, dss::*, dssp::*, io::*,
51    measure::*, modify::*, ndx_file::*, particle::*, perception::*, periodic_box::*, providers::*, sasa::*,
52    secondary_structure::*, selection::*, smiles::*, state::*, topology::*,
53};
54
55const BOLD: &str = "\x1b[1m";
56const RESET: &str = "\x1b[0m";
57
58/// Prints a welcome message for MolAR with package information and the specified tool name
59/// # Example
60/// ```
61/// use molar::greeting;
62/// greeting("analysis");
63/// ```
64pub fn greeting(tool: impl AsRef<str>) {
65    const TITLE: &str = "MolAR - Molecular Analysis for Rust";
66
67    let version = format!("MolAR version: {}", env!("CARGO_PKG_VERSION"));
68    let tool    = format!("Tool: {}", tool.as_ref());
69
70    // Content width = widest row; bar = content + one space of padding on each side
71    let w = [env!("CARGO_PKG_HOMEPAGE"), env!("CARGO_PKG_AUTHORS"), &version, &tool]
72        .iter()
73        .map(|s| s.len())
74        .max()
75        .unwrap_or(0)
76        .max(TITLE.len());
77    let bar = "─".repeat(w + 2);
78
79    println!("╭{bar}╮");
80    println!("│ {BOLD}{TITLE:<w$}{RESET} │");
81    println!("├{bar}┤");
82    println!("│ {:<w$} │", env!("CARGO_PKG_HOMEPAGE"));
83    println!("│ {:<w$} │", env!("CARGO_PKG_AUTHORS"));
84    println!("├{bar}┤");
85    println!("│ {version:<w$} │");
86    println!("├{bar}┤");
87    println!("│ {tool:<w$} │");
88    println!("╰{bar}╯");
89}
90
91// Test code in README
92#[cfg(doctest)]
93#[doc = include_str!("../../README.md")]
94struct _ReadMe;