Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tianyishi2001/protein

Protein Structural Biology in Rust
https://github.com/tianyishi2001/protein

biology protein rust science

Last synced: about 1 month ago
JSON representation

Protein Structural Biology in Rust

Awesome Lists containing this project

README

        

# protein

[![crates.io](https://img.shields.io/crates/d/protein.svg)](https://crates.io/crates/protein)
[![crates.io](https://img.shields.io/crates/v/protein.svg)](https://crates.io/crates/protein)
[![crates.io](https://img.shields.io/crates/l/protein.svg)](https://crates.io/crates/protein)
[![docs.rs](https://docs.rs/protein/badge.svg)](https://docs.rs/protein)

Protein structural Biology in Rust.

**NOTE: This crate is in early development and the API has not yet been stabilized, so do not use this crate in production. If you have any suggestions, please don't hesitate to open an issue or make a PR!**

## Components

The **protein** crate essentially re-exports the components listed below. Depending on the use case, you may want to only use some of them.

| **crate** | Links |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **protein-core** | [![crates.io](https://img.shields.io/crates/d/protein-core.svg)](https://crates.io/crates/protein-core)[![crates.io](https://img.shields.io/crates/v/protein-core.svg)](https://crates.io/crates/protein-core)[![docs.rs](https://docs.rs/protein-core/badge.svg)](https://docs.rs/protein-core) |
| **protein-get** | [![crates.io](https://img.shields.io/crates/d/protein-get.svg)](https://crates.io/crates/protein-get)[![crates.io](https://img.shields.io/crates/v/protein-get.svg)](https://crates.io/crates/protein-get)[![docs.rs](https://docs.rs/protein-get/badge.svg)](https://docs.rs/protein-get) |
| **protein-io** | [![crates.io](https://img.shields.io/crates/d/protein-io.svg)](https://crates.io/crates/protein-io)[![crates.io](https://img.shields.io/crates/v/protein-io.svg)](https://crates.io/crates/protein-io)[![docs.rs](https://docs.rs/protein-io/badge.svg)](https://docs.rs/protein-io) |
| **protein-analysis** | [![crates.io](https://img.shields.io/crates/d/protein-analysis.svg)](https://crates.io/crates/protein-analysis)[![crates.io](https://img.shields.io/crates/v/protein-analysis.svg)](https://crates.io/crates/protein-analysis)[![docs.rs](https://docs.rs/protein-analysis/badge.svg)](https://docs.rs/protein-analysis) |

## Example

Let's read a protein structure from a PDB file and draw a Ramachandran plot!

```rust
use csv::Writer; // the crate `csv` is required if you want to output csv
use protein::{
analysis::model::ModelAnalysis, // `Structure` alone only stores data.
get::get_pdb,
// Functions for analysing the `Structure` are provided by separate traits
io::parse_pdb, // the PDB parser that parses PDB file into a `Structure`
};

fn main() {
let pdbfile = get_pdb("4f7i").unwrap();
let structure = parse_pdb(&pdbfile).unwrap();
let (phis, psis) = structure.models[0].ramachandran();
// the `.ramachandran()` function is provided by the `ModelAnalysis` trait
// this produces vectors of phi and psi angles in radians

// the code below is used to output csv, which is optional
let mut wtr = Writer::from_path("examples/ramachandran.csv").unwrap();
wtr.write_record(&["phi", "psi"]).unwrap();
for (&phi, &psi) in phis.iter().zip(psis.iter()) {
wtr.write_record(&[phi.to_string(), psi.to_string()])
.unwrap()
}
wtr.flush().unwrap();
}
```

This will produce a csv file containing two columns representing phi and psi angles. Then we can read the csv file in R and plot it (unfortunately I am not familiar with any graphing libraries in Rust):

![ramachandran plot](./examples/ramachandran.png)

You can directly run the above example using `cargo run`:

```bash
cargo run --example ramachandran
```