Skip to content

Commit

Permalink
replace m8 with tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed Jan 9, 2025
1 parent d6a484c commit f6426c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/modules/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::fs::File;
use std::io::{self, BufRead, BufReader, BufWriter, Write};
use std::path::Path;

fn profile(m8_file: &str, mapping: &str, output_dir: &str, threshold: usize, print_copiness: bool) -> io::Result<()> {
fn profile(tsv_file: &str, mapping: &str, output_dir: &str, threshold: usize, print_copiness: bool) -> io::Result<()> {
let mut gene_to_spe: HashMap<String, HashSet<String>> = HashMap::new();
let mut species_set: HashSet<String> = HashSet::new();

Expand All @@ -32,7 +32,7 @@ fn profile(m8_file: &str, mapping: &str, output_dir: &str, threshold: usize, pri
if let Some(output) = output.as_mut() {
writeln!(output, "Query\tMultipleCopyPercent\tSingleCopyPercent")?;
}
let file = File::open(m8_file)?;
let file = File::open(tsv_file)?;
let reader = BufReader::new(file);
let mut curr_query: Option<String> = None;
let mut spe_cnt: HashMap<String, i32> = HashMap::new();
Expand Down Expand Up @@ -99,7 +99,7 @@ fn output_statistics_and_genes<W: Write>(output: &mut Option<W>, query: &str, sp
pub fn run(args: &Args, _: &var::BinaryPaths) -> Result<(), Box<dyn std::error::Error>> {
// Retrieve arguments
let input_db = args.profile_input_db.clone().unwrap_or_else(|| { crate::envs::error_handler::error(crate::envs::error_handler::ERR_ARGPARSE, Some("profile - input".to_string())); });
let input_m8 = args.profile_input_m8.clone().unwrap_or_else(|| { crate::envs::error_handler::error(crate::envs::error_handler::ERR_ARGPARSE, Some("profile - mapping".to_string())); });
let input_tsv = args.profile_input_tsv.clone().unwrap_or_else(|| { crate::envs::error_handler::error(crate::envs::error_handler::ERR_ARGPARSE, Some("profile - mapping".to_string())); });
let output = args.profile_output.clone().unwrap_or_else(|| { crate::envs::error_handler::error(crate::envs::error_handler::ERR_ARGPARSE, Some("profile - output".to_string())); });
let threshold = args.profile_threshold.unwrap_or_else(|| { crate::envs::error_handler::error(crate::envs::error_handler::ERR_ARGPARSE, Some("profile - threshold".to_string())); });
let print_copiness = args.profile_print_copiness.unwrap_or_else(|| { crate::envs::error_handler::error(crate::envs::error_handler::ERR_ARGPARSE, Some("profile - print_copiness".to_string())); });
Expand All @@ -113,7 +113,7 @@ pub fn run(args: &Args, _: &var::BinaryPaths) -> Result<(), Box<dyn std::error::
chkpnt::write_checkpoint(&format!("{}/profile.chk", output), "0")?;

let mapping = format!("{}.map", input_db);
profile(&input_m8, &mapping, &output, threshold, print_copiness)?;
profile(&input_tsv, &mapping, &output, threshold, print_copiness)?;

// Write the checkpoint file
chkpnt::write_checkpoint(&format!("{}/profile.chk", output), "1")?;
Expand Down
12 changes: 6 additions & 6 deletions src/util/arg_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ pub enum Commands {
Profile {
/// Input database (createdb output)
input_db: PathBuf,
/// Input m8 file (cluster or search output)
input_m8: PathBuf,
/// Input tsv file (cluster or search output)
input_tsv: PathBuf,
/// Output directory
output: PathBuf,
/// Coverage threshold for core structures. [0 - 100]
Expand Down Expand Up @@ -335,7 +335,7 @@ pub struct Args {
pub createdb_afdb_local: Option<Option<String>>,

pub profile_input_db: Option<String>,
pub profile_input_m8: Option<String>,
pub profile_input_tsv: Option<String>,
pub profile_output: Option<String>,
pub profile_threshold: Option<usize>,
pub profile_print_copiness: Option<bool>,
Expand Down Expand Up @@ -448,8 +448,8 @@ impl Args {
Some(EasyCore { output, .. }) => Some(format!("{}/proteome/proteome_db", own(output))),
Some(EasySearch { output, .. }) => Some(format!("{}/proteome/proteome_db", own(output))), _ => None,
};
let profile_input_m8 = match &args.command {
Some(Profile { input_m8, .. }) => Some(own(input_m8)),
let profile_input_tsv = match &args.command {
Some(Profile { input_tsv, .. }) => Some(own(input_tsv)),
Some(EasyCore { output, .. }) => Some(format!("{}/cluster/clust.tsv", own(output))),
Some(EasySearch { output, .. }) => Some(format!("{}/search/search.m8", own(output))), _ => None,
};
Expand Down Expand Up @@ -559,7 +559,7 @@ impl Args {
Args {
command: args.command, version: args.version, threads, verbosity,
createdb_input, createdb_output, createdb_model, createdb_keep, createdb_overwrite, createdb_max_len, createdb_gpu, createdb_use_python, createdb_use_foldseek, createdb_afdb_lookup, createdb_afdb_local,
profile_input_db, profile_input_m8, profile_output, profile_threshold, profile_print_copiness,
profile_input_db, profile_input_tsv, profile_output, profile_threshold, profile_print_copiness,
search_input, search_target, search_output, search_tmp, search_keep_aln_db, search_search_options,
cluster_input, cluster_output, cluster_tmp, cluster_keep_cluster_db, cluster_cluster_options,
tree_db, tree_input, tree_output, tree_aligner, tree_tree_builder, tree_aligner_options, tree_tree_options, tree_threshold,
Expand Down

0 comments on commit f6426c9

Please sign in to comment.