Task tutorial

Build a Rust SMILES CLI with local descriptors

Parse one SMILES in a native Rust binary and print atom count, molecular weight, and TPSA from the same molecule.

You will make

A compact, reproducible local CLI that reports basic molecular properties for ethanol.

Steps

  1. Create a binary crate with cargo new smiles-cli and enter its directory.
  2. Add only the smiles, perception, and chem features.
  3. Replace src/main.rs with the shown program, then run cargo run.
  4. Keep the exact input and enabled features with any reported values.
cargo add chematic --features "smiles,perception,chem"

// src/main.rs
use chematic::chem::{molecular_weight, tpsa};
use chematic::smiles::parse;

fn main() {
    let mol = parse("CCO").expect("valid SMILES");
    println!("atoms={}", mol.atom_count());
    println!("mw={:.2}", molecular_weight(&mol));
    println!("tpsa={:.2}", tpsa(&mol));
}

Expected result

The program prints atoms=3, mw=46.07, and tpsa=20.23 for CCO. Repeating the same source and input produces the same output.

If it does not work

The command enables the transitive perception feature deliberately because the chemistry descriptors need it. For another workflow, choose the smallest documented feature set rather than copying a full feature list by default.

Next action

Read the Rust package guide