Crates.io | tf-binding-rs |
lib.rs | tf-binding-rs |
version | 0.1.4 |
source | src |
created_at | 2024-11-03 22:35:12.39768 |
updated_at | 2024-11-17 19:45:58.514501 |
description | Fast transcription factor binding site prediction and FASTA manipulation in Rust |
homepage | |
repository | |
max_upload_size | |
id | 1434302 |
size | 127,610 |
A Rust library for predicting transcription factor (TF) binding site occupancy in DNA sequences. This toolkit provides efficient implementations for:
Add this to your Cargo.toml
:
[dependencies]
tf-binding-rs = "0.1.1"
Or install using cargo:
cargo add tf-binding-rs
use tf_binding_rs::fasta;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read sequences from a FASTA file
let sequences = fasta::read_fasta("path/to/sequences.fasta")?;
// Print sequence information
println!("Number of sequences: {}", sequences.height());
// Calculate GC content
let gc_stats = fasta::gc_content(&sequences)?;
println!("GC content analysis: {:?}", gc_stats);
Ok(())
}
use tf_binding_rs::occupancy;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read PWM motifs from MEME format file
let pwm_collection = occupancy::read_pwm_files("path/to/motifs.meme")?;
// Process each motif
for (motif_id, pwm) in pwm_collection {
println!("Processing motif: {}", motif_id);
println!("Matrix dimensions: {:?}", pwm.shape());
}
Ok(())
}
use tf_binding_rs::occupancy;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read PWMs and convert to Energy Weight Matrices
let ewm_collection = occupancy::read_pwm_to_ewm("path/to/motifs.meme")?;
// Calculate binding landscape for a sequence
let sequence = "ATCGATCGTAGCTACGT";
let mu = -3.0; // chemical potential
// Get occupancy predictions for all TFs
let occupancy_landscape = occupancy::total_landscape(
&sequence,
&ewm_collection,
mu
)?;
println!("Occupancy predictions:\n{}", occupancy_landscape);
Ok(())
}
For detailed API documentation, visit docs.rs/tf-binding-rs