Skip to content

Commit f20c2b2

Browse files
committed
refactor(lib): formart code with cargo fmt
1 parent ffad98d commit f20c2b2

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

microbiorust-py/src/lib.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,20 @@
2323
//! result = amino_percentage("MSNTQKKNVPELRFPGFEGEWEEKKLGDLTTKIGSGKTPKGGSENYTNKGIPFLRSQNIRNGKLNLNDLVYISKDIDDEMKNSRTY")
2424
//! print(result)
2525
26-
27-
use pyo3::{
28-
prelude::*,
29-
types::PyModule,
30-
};
31-
use microBioRust::genbank;
32-
use std::collections::HashMap;
33-
use std::{
34-
collections::BTreeMap,
35-
io::{self, Write},
36-
fs::OpenOptions,
37-
};
38-
use microBioRust::gbk::{Record, Reader, RangeValue, gff_write};
3926
use microBioRust::embl;
4027
use microBioRust::embl::gff_write as embl_gff_write;
41-
use microBioRust_seqmetrics::metrics::hydrophobicity as rust_hydrophobicity;
28+
use microBioRust::gbk::{gff_write, RangeValue, Reader, Record};
29+
use microBioRust::genbank;
4230
use microBioRust_seqmetrics::metrics::amino_counts as rust_amino_counts;
4331
use microBioRust_seqmetrics::metrics::amino_percentage as rust_amino_percentage;
32+
use microBioRust_seqmetrics::metrics::hydrophobicity as rust_hydrophobicity;
33+
use pyo3::{prelude::*, types::PyModule};
34+
use std::collections::HashMap;
35+
use std::{
36+
collections::BTreeMap,
37+
fs::OpenOptions,
38+
io::{self, Write},
39+
};
4440

4541
#[pyfunction]
4642
fn gbk_to_faa(filename: &str) -> PyResult<Vec<String>> {
@@ -62,7 +58,7 @@ fn gbk_to_faa_count(filename: &str) -> PyResult<usize> {
6258
let mut count = 0;
6359
for record in records {
6460
for (k, _) in &record.cds.attributes {
65-
count += 1;
61+
count += 1;
6662
}
6763
}
6864
Ok(count)
@@ -185,7 +181,7 @@ fn hydrophobicity(seq: &str, window_size: usize) -> Vec<f64> {
185181
#[allow(unused_imports)]
186182
#[allow(unused_variables)]
187183
#[pyfunction]
188-
fn amino_percentage(seq: &str) -> HashMap<char,f64> {
184+
fn amino_percentage(seq: &str) -> HashMap<char, f64> {
189185
rust_amino_percentage(seq)
190186
}
191187

@@ -196,7 +192,6 @@ fn amino_counts(seq: &str) -> HashMap<char, u64> {
196192
rust_amino_counts(seq)
197193
}
198194

199-
200195
#[pymodule]
201196
fn microbiorust(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
202197
m.add_function(wrap_pyfunction!(gbk_to_faa, m)?)?;
@@ -210,7 +205,6 @@ fn microbiorust(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
210205
Ok(())
211206
}
212207

213-
214208
#[cfg(test)]
215209
mod tests {
216210
use crate::microbiorust;
@@ -222,10 +216,18 @@ mod tests {
222216
Python::with_gil(|py| {
223217
let m = PyModule::new(py, "microbiorust").unwrap();
224218
microbiorust(py, &m).unwrap();
225-
for func in &["gbk_to_faa", "gbk_to_faa_count", "embl_to_faa", "gbk_to_gff", "embl_to_gff", "hydrophobicity", "amino_counts", "amino_percentage"] {
219+
for func in &[
220+
"gbk_to_faa",
221+
"gbk_to_faa_count",
222+
"embl_to_faa",
223+
"gbk_to_gff",
224+
"embl_to_gff",
225+
"hydrophobicity",
226+
"amino_counts",
227+
"amino_percentage",
228+
] {
226229
assert!(m.getattr(func).is_ok(), "Function {} not found", func);
227230
}
228231
});
229232
}
230-
231233
}

0 commit comments

Comments
 (0)