Skip to content

Commit eb8e602

Browse files
committed
update code
1 parent 93980e9 commit eb8e602

File tree

4 files changed

+7
-55
lines changed

4 files changed

+7
-55
lines changed

src/cli/length.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use anyhow::{Error, Ok};
33
use bio::io::fastq;
44
use log::*;
55
use std::collections::HashMap;
6+
use rayon::prelude::*;
67

78
pub fn fq_length(
89
file: Option<&String>,
@@ -30,9 +31,9 @@ pub fn fq_length(
3031

3132
let mut sort_len: Vec<(&usize, &usize)> = reads_len.iter().collect();
3233
if rev {
33-
sort_len.sort_by(|x, y| y.0.cmp(x.0));
34+
sort_len.par_sort_by(|x, y| y.0.cmp(x.0));
3435
} else {
35-
sort_len.sort_by_key(|x| x.0);
36+
sort_len.par_sort_by_key(|x| x.0);
3637
}
3738

3839
fo.write_all("lenth\tcount\n".as_bytes())?;

src/cli/search.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::utils::*;
22
use anyhow::{Error, Ok};
33
use bio::io::fastq;
4-
use crossbeam::channel::unbounded;
4+
use crossbeam::channel::bounded;
55
use log::*;
66
use regex::RegexBuilder;
77

@@ -67,7 +67,7 @@ pub fn search_fq(
6767
}
6868
fo.flush()?;
6969
} else {
70-
let (tx, rx) = unbounded();
70+
let (tx, rx) = bounded(5000);
7171
let mut fqiter = fq_reader.records();
7272
loop {
7373
let chunks: Vec<_> = fqiter.by_ref().take(chunk).map_while(Result::ok).collect();
@@ -79,7 +79,7 @@ pub fn search_fq(
7979
drop(tx);
8080

8181
crossbeam::scope(|s| {
82-
let (tx2, rx2) = unbounded();
82+
let (tx2, rx2) = bounded(5000);
8383
let _handles: Vec<_> = (0..ncpu)
8484
.map(|_| {
8585
let tx_tmp = tx2.clone();

src/cli/stats.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -199,55 +199,6 @@ pub fn stat_fq(
199199
tf[4] += 1;
200200
}
201201
}
202-
/*if each.contains_key(&pos) {
203-
let tf = each.get_mut(&pos).unwrap();
204-
let gap = (idx + 5 + 1) as i32 - tf.len() as i32;
205-
if gap > 0 {
206-
//tf.resize(gap+tf.len(), 0); // error
207-
//tf.resize_with(gap+tf.len(), || 0); // error
208-
//tf.append(&mut vec![0;gap]); // error
209-
//for _ in 0..gap { tf.push(0); } // error
210-
for _ in 0..gap {
211-
tf.insert(tf.len(), 0);
212-
} // WFK? ok: add zero at vec![] tail in loop n
213-
}
214-
tf[idx + 5] += 1;
215-
if sf == &b'A' {
216-
tf[0] += 1;
217-
}
218-
if sf == &b'T' {
219-
tf[1] += 1;
220-
}
221-
if sf == &b'G' {
222-
tf[2] += 1;
223-
}
224-
if sf == &b'C' {
225-
tf[3] += 1;
226-
}
227-
if sf == &b'N' {
228-
tf[4] += 1;
229-
}
230-
} else {
231-
let cap = this_q as usize + 1 + 5;
232-
let mut v_tmp = vec![0usize; cap];
233-
v_tmp[idx + 5] += 1;
234-
if sf == &b'A' {
235-
v_tmp[0] += 1;
236-
}
237-
if sf == &b'T' {
238-
v_tmp[1] += 1;
239-
}
240-
if sf == &b'G' {
241-
v_tmp[2] += 1;
242-
}
243-
if sf == &b'C' {
244-
v_tmp[3] += 1;
245-
}
246-
if sf == &b'N' {
247-
v_tmp[4] += 1;
248-
}
249-
each.insert(pos, v_tmp);
250-
}*/
251202
}
252203
}
253204

src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Args {
3434
pub command: Subcli,
3535

3636
/// threads number
37-
#[arg(short = '@', long = "threads", default_value_t = 1, global = true, value_name = "INT", help_heading = Some("Global Arguments"))]
37+
#[arg(short = '@', long = "threads", default_value_t = 4, global = true, value_name = "INT", help_heading = Some("Global Arguments"))]
3838
pub threads: usize,
3939

4040
/// set gzip/bzip2/xz compression level 1 (compress faster) - 9 (compress better) for gzip/bzip2/xz output file, just work with option -o/--out

0 commit comments

Comments
 (0)