Coder Social home page Coder Social logo

chemcore's Introduction

ChemCore

Crates.io Docs

A cheminformatics toolkit for Rust.

ChemCore provides primitives for working with Molecules. For details, see: ChemCore: A Cheminformatics Toolkit for Rust.

Usage

Add this to your Cargo.toml:

[dependencies]
chemcore = "0.4"

Examples

Parse cyclopropane SMILES, traverse in depth-first order, and query its Molecule and Graph traits:

use gamma::graph::{ Graph };
use gamma::traversal::{ DepthFirst, Step };
use chemcore::daylight::{ read_smiles, SmilesInputError };
use chemcore::molecule::{ Atom, Element, Molecule, Error };

fn main() -> Result<(), SmilesInputError> {
    let molecule = read_smiles(&"C1CC1", None)?;
    let traversal = DepthFirst::new(&molecule, 0).expect("traversal error");

    assert_eq!(traversal.collect::<Vec<_>>(), vec![
        Step::new(0, 2, false),
        Step::new(2, 1, false),
        Step::new(1, 0, true)
    ]);

    // Graph trait
    assert_eq!(molecule.degree(0), Ok(2));
    assert_eq!(molecule.size(), 3);
    assert_eq!(molecule.order(), 3);

    // Molecule trait
    assert_eq!(molecule.atom(0), Ok(&Atom {
        isotope: None,
        element: Some(Element::C),
        hydrogens: 2,
        electrons: 0,
        parity: None,
    }));
    assert_eq!(molecule.charge(0), Ok(0.));
    assert_eq!(molecule.bond_order(0, 1), Ok(1.));

    Ok(())
}

Versions

ChemCore is not yet stable. Patch versions never introduce breaking changes, but minor/major revisions probably will.

License

ChemCore is distributed under the terms of the MIT License. See LICENSE-MIT and COPYRIGHT for details.

chemcore's People

Contributors

rapodaca avatar bddap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.