Skip to content

Commit

Permalink
update to version 0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkLoc committed Sep 20, 2023
1 parent 212badd commit 4c6d5d7
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 17 deletions.
203 changes: 199 additions & 4 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fqkit"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
authors = ["sharkLoc <[email protected]>"]
rust-version = "1.65.0"
Expand All @@ -20,6 +20,7 @@ clap = { version = "4.0.18", features = ["derive"] }
env_logger = "0.10.0"
flate2 = "1.0.24"
log = "0.4.20"
lowcharts = "0.5.8"
plotters = "0.3.4"
rand = "0.8.5"
rand_pcg = "0.3.1"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fqkit: a simple program for fastq file manipulation
Usage: fqkit <COMMAND>

Commands:
topn
get first N records from fastq file
subfq
subsample sequences from big fastq file
search
Expand Down
Binary file added example/gc_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions src/gcplot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ use bio::io::fastq;
use std::collections::HashMap;
use log::*;
use plotters::prelude::*;
use lowcharts::plot;
use crate::utils::*;
use std::time::Instant;

pub fn gc_content(
fqin: &Option<&str>,
output: &Option<&str>,
show: bool,
prefix: String,
width: usize,
height: usize,
Expand All @@ -33,17 +35,27 @@ pub fn gc_content(

}

let mut df_ret = vec![];
fo.write(format!("gc_content(%)\tratio(%)\n").as_bytes())?;
fo.write(format!("GC(%)\tReads\tRatio(%)\n").as_bytes())?;
let mut df_ret = vec![]; // data for PNG / SVG
let mut df_num = vec![]; // data for histogram in terminal
let total = df_hash.values().sum::<usize>() as f32;

for i in 0..=100 {
let v = (*df_hash.get(&i).unwrap_or(&0) as f32 *10000.0 / total ).round() / 100.0;
let num = *df_hash.get(&i).unwrap_or(&0);
let v = (num as f32 *10000.0 / total ).round() / 100.0;
df_ret.push(v);
fo.write(format!("{}\t{}\n",i,v).as_bytes())?;
fo.write(format!("{}\t{}\t{}\n", i, num, v).as_bytes())?;
if show {
for _ in 0..num{
df_num.push(i as f64)
}
}
}

plot_gc(df_ret, prefix, width, height, ylim, types)?;


if show {
info!("{}",plot::Histogram::new(&df_num, plot::HistogramOptions { intervals: 20, ..Default::default() }));
}
info!("time elapsed is: {:?}",start.elapsed());
Ok(())
}
Expand Down
Loading

0 comments on commit 4c6d5d7

Please sign in to comment.