tf_binding_rs::occupancy

Function read_pwm_files

Source
pub fn read_pwm_files(filename: &str) -> Result<PWMCollection, MotifError>
Expand description

Reads Position Weight Matrices (PWMs) from a MEME format file

This function parses a MEME-formatted file containing one or more Position Weight Matrices, each identified by a unique motif ID. The PWMs represent DNA binding motifs where each position contains probabilities for the four nucleotides (A, C, G, T).

§Arguments

  • filename - Path to the MEME format file to read

§Returns

  • Result<PWMCollection, MotifError> - A HashMap where keys are motif IDs and values are their corresponding PWMs

§Errors

  • MotifError::Io - If the file cannot be opened or read
  • MotifError::InvalidFileFormat - If the file format is invalid or no PWMs are found
  • MotifError::DataError - If there are issues creating the PWM DataFrame

§Example

use tf_binding_rs::occupancy::read_pwm_files;

let pwms = read_pwm_files("path/to/motifs.meme").unwrap();
for (motif_id, pwm) in pwms {
    println!("Found motif: {}", motif_id);
}

§Format

The input file should be in MEME format, where each PWM is preceded by a “MOTIF” line containing the motif ID, followed by the matrix values.