Skip to content

Commit

Permalink
update log in each subcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkLoc committed Sep 28, 2024
1 parent d5a97bd commit 0d6362d
Show file tree
Hide file tree
Showing 43 changed files with 40 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "fqkit"
version = "0.4.10"
version = "0.4.11"
edition = "2021"
authors = ["sharkLoc <[email protected]>"]
rust-version = "1.77.2"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cargo install --git https://github.com/sharkLoc/fqkit.git
```bash
FqKit -- A simple and cross-platform program for fastq file manipulation

Version: 0.4.10
Version: 0.4.11

Authors: sharkLoc <[email protected]>
Source code: https://github.com/sharkLoc/fqkit.git
Expand Down
Binary file added base_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions base_plot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/base_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions example/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
read average length: 126
read min length: 126
read max length: 126
total gc content(%): 57.52
total read count: 2000
total base count: 252000

base A count: 53864 (21.37%)
base T count: 53136 (21.09%)
base G count: 70989 (28.17%)
base C count: 73967 (29.35%)
base N count: 44 (0.02%)

Number of base calls with quality value of 5 or higher (Q5+) (%) 251956 (99.98%)
Number of base calls with quality value of 10 or higher (Q10+) (%) 251956 (99.98%)
Number of base calls with quality value of 15 or higher (Q15+) (%) 244768 (97.13%)
Number of base calls with quality value of 20 or higher (Q20+) (%) 237670 (94.31%)
Number of base calls with quality value of 30 or higher (Q30+) (%) 223461 (88.67%)
4 changes: 1 addition & 3 deletions src/cli/barcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use log::*;
use std::collections::HashMap;
use std::io::BufRead;
use std::path::{Path, PathBuf};
use std::time::Instant;

fn barcode_list(file: &String, rev_comp: bool) -> Result<HashMap<String, String>> {
let mut maps = HashMap::new();
Expand Down Expand Up @@ -97,7 +96,7 @@ pub fn split_fq(
xz: bool,
compression_level: u32,
) -> Result<()> {
let start = Instant::now();


if !Path::new(outdir).try_exists().unwrap() {
error!("{}", FqkitError::InvalidOutputDir(outdir.to_string()));
Expand Down Expand Up @@ -229,6 +228,5 @@ pub fn split_fq(
);
}

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
3 changes: 0 additions & 3 deletions src/cli/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::utils::*;
use anyhow::Result;
use bio::io::fastq;
use log::*;
use std::time::Instant;

pub fn check_fastq(
file: Option<&String>,
Expand All @@ -11,7 +10,6 @@ pub fn check_fastq(
compression_level: u32,
stdout_type: char,
) -> Result<()> {
let start = Instant::now();

let (mut total, mut ok_read, mut err_read) = (0, 0, 0);
let fp_reader = file_reader(file).map(fastq::Reader::new)?;
Expand Down Expand Up @@ -57,7 +55,6 @@ pub fn check_fastq(
"total reads num: {}, ok reads number: {}, error reads number: {}",
total, ok_read, err_read
);
info!("time elapsed is: {:?}", start.elapsed());

Ok(())
}
4 changes: 1 addition & 3 deletions src/cli/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use bio::io::fastq;
use log::*;
use std::{io::BufRead, time::Instant};
use std::io::BufRead;

pub fn concat_fqstq_lane(
r1_list: &String,
Expand All @@ -12,7 +12,6 @@ pub fn concat_fqstq_lane(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();

let mut vec1 = vec![];
let mut vec2 = vec![];
Expand Down Expand Up @@ -65,7 +64,6 @@ pub fn concat_fqstq_lane(
pe_read,
vec1.len()
);
info!("time elapsed is: {:?}", start.elapsed());

Ok(())
}
3 changes: 0 additions & 3 deletions src/cli/cutadapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anyhow::{Error, Ok, Result};
use bio::io::{fasta, fastq};
use log::*;
use std::collections::HashMap;
use std::time::Instant;

pub fn cut_adapter(
input: Option<&String>,
Expand All @@ -15,7 +14,6 @@ pub fn cut_adapter(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();

let seqfile_reader = file_reader(Some(seqfile)).map(fasta::Reader::new)?;
if let Some(file) = input {
Expand Down Expand Up @@ -99,6 +97,5 @@ pub fn cut_adapter(
}
fq_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
3 changes: 0 additions & 3 deletions src/cli/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use anyhow::{Ok, Result};
use bio::io::fastq;
use crossbeam::channel::unbounded;
use log::*;
use std::time::Instant;

#[allow(clippy::too_many_arguments)]
pub fn filter_fastq(
Expand All @@ -22,7 +21,6 @@ pub fn filter_fastq(
compression_level: u32,
stdout_type: char,
) -> Result<()> {
let start = Instant::now();
info!("read forward reads from file: {}", read1);
info!("read reverse reads from file: {}", read2);
if ![33u8, 64u8].contains(&phred) {
Expand Down Expand Up @@ -210,7 +208,6 @@ pub fn filter_fastq(

info!("total clean pe reads number (r1+r2): {}", pe_ok * 2);
info!("total failed pe reads number (r1+r2): {}", pe_fail * 2);
info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}

Expand Down
3 changes: 0 additions & 3 deletions src/cli/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use bio::io::fastq;
use log::*;
use std::time::Instant;

#[allow(clippy::too_many_arguments)]
pub fn flatten_fq(
Expand All @@ -16,7 +15,6 @@ pub fn flatten_fq(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();

let fq_reader = file_reader(file).map(fastq::Reader::new)?;
if let Some(file) = file {
Expand Down Expand Up @@ -62,7 +60,6 @@ pub fn flatten_fq(
}
out_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}

Expand Down
3 changes: 0 additions & 3 deletions src/cli/fq2fa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use anyhow::{Error, Ok};
use bio::io::fasta;
use bio::io::fastq;
use log::*;
use std::time::Instant;

pub fn fq2fa(
file: Option<&String>,
Expand All @@ -12,7 +11,6 @@ pub fn fq2fa(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();

let mut num = 0usize;
let fq_reader = fastq::Reader::new(file_reader(file)?);
Expand All @@ -37,6 +35,5 @@ pub fn fq2fa(
fo.flush()?;

info!("total reads number: {}", num);
info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 0 additions & 4 deletions src/cli/fq2sam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use bio::io::fastq;
use log::*;
use std::time::Instant;

#[allow(clippy::too_many_arguments)]
pub fn fastq2sam(
Expand All @@ -16,7 +15,6 @@ pub fn fastq2sam(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();
if let Some(r2) = r2 {
info!("read file1 from: {}", r1);
info!("read file2 from: {}", r2);
Expand Down Expand Up @@ -105,7 +103,5 @@ pub fn fastq2sam(
}
}
sam.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
5 changes: 1 addition & 4 deletions src/cli/fqscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::utils::*;
use anyhow::{Ok, Result};
use bio::io::{fastq, fastq::Record};
use log::*;
use std::time::Instant;

pub fn phred_score(
file: Option<&String>,
Expand All @@ -12,8 +11,7 @@ pub fn phred_score(
compression_level: u32,
stdout_type: char,
) -> Result<()> {
let start = Instant::now();


let fq_reader = file_reader(file).map(fastq::Reader::new)?;
if let Some(r) = file {
info!("read file from: {}", r);
Expand Down Expand Up @@ -55,6 +53,5 @@ pub fn phred_score(
}
fq_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
3 changes: 0 additions & 3 deletions src/cli/gcplot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use log::*;
use lowcharts::plot;
use plotters::prelude::*;
use std::collections::HashMap;
use std::time::Instant;

#[allow(clippy::too_many_arguments)]
pub fn gc_content(
Expand All @@ -21,7 +20,6 @@ pub fn gc_content(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();

let fq_reader = file_reader(fqin).map(fastq::Reader::new)?;
if let Some(inp) = fqin {
Expand Down Expand Up @@ -76,7 +74,6 @@ pub fn gc_content(
}
plot_gc(df_ret, prefix, width, height, ylim, types)?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}

Expand Down
3 changes: 0 additions & 3 deletions src/cli/grep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anyhow::{Ok, Result};
use bio::io::fastq;
use log::*;
use std::io::BufRead;
use std::time::Instant;

pub fn grep_fastq(
fq: Option<&String>,
Expand All @@ -14,7 +13,6 @@ pub fn grep_fastq(
compression_level: u32,
stdout_type: char,
) -> Result<()> {
let start = Instant::now();

let fq_reader = file_reader(fq).map(fastq::Reader::new)?;
if let Some(file) = fq {
Expand Down Expand Up @@ -59,6 +57,5 @@ pub fn grep_fastq(
fo.flush()?;

info!("total reads matched number: {}", num);
info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/cli/kmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Error;
use bio::io::fastq;
use log::*;
use nthash::nthash;
use std::{collections::HashMap, time::Instant};
use std::collections::HashMap;

pub fn kmer_count(
input: Option<&String>,
Expand All @@ -13,7 +13,6 @@ pub fn kmer_count(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();
let reader = file_reader(input).map(fastq::Reader::new)?;
if let Some(file) = input {
info!("reading from file: {}", file);
Expand Down Expand Up @@ -48,6 +47,5 @@ pub fn kmer_count(
writer.write_all(format!("\t{}\n", v).as_bytes())?;
}
writer.flush()?;
info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
3 changes: 0 additions & 3 deletions src/cli/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use anyhow::{Error, Ok};
use bio::io::fastq;
use log::*;
use std::collections::HashMap;
use std::time::Instant;

pub fn fq_length(
file: Option<&String>,
Expand All @@ -12,7 +11,6 @@ pub fn fq_length(
compression_level: u32,
stdout_type: char,
) -> Result<(), Error> {
let start = Instant::now();

let mut reads_len = HashMap::new();
let mut total = 0usize;
Expand Down Expand Up @@ -43,7 +41,6 @@ pub fn fq_length(
}
fo.flush()?;
info!("total scan reads number: {}", total);
info!("time elapsed is: {:?}", start.elapsed());

Ok(())
}
3 changes: 0 additions & 3 deletions src/cli/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::utils::*;
use anyhow::{Ok, Result};
use bio::io::{fastq, fastq::Record};
use log::*;
use std::time::Instant;

pub fn mask_fastq(
file: Option<&String>,
Expand All @@ -13,7 +12,6 @@ pub fn mask_fastq(
compression_level: u32,
stdout_type: char,
) -> Result<()> {
let start = Instant::now();

let (mut mask_base, mut mask_read) = (0, 0);
let fp_reader = file_reader(file).map(fastq::Reader::new)?;
Expand Down Expand Up @@ -50,6 +48,5 @@ pub fn mask_fastq(
fp_writer.flush()?;

info!("total mask {} bases from {} reads", mask_base, mask_read);
info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
Loading

0 comments on commit 0d6362d

Please sign in to comment.