Skip to content

Commit

Permalink
优化代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
eric committed Apr 19, 2024
1 parent e42cf02 commit de7ceae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions ncbi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ enum Mode {
Fna {
/// library fna 文件存储目录,为了不和原始文件混淆
#[clap(value_parser)]
out_dir: PathBuf,
out_dir: Option<PathBuf>,
},
/// 仅下载和解析 assembly 文件
Assembly,
Expand Down Expand Up @@ -205,7 +205,11 @@ async fn async_run(args: Args) -> Result<()> {
}
},
Some(Mode::Fna { out_dir }) => {
let fna_out_dir = out_dir.join("library").join(grp.clone());
let fna_out_dir = out_dir
.clone()
.unwrap_or(db_path.clone())
.join("library")
.join(grp.clone());
utils::create_dir(&fna_out_dir)?;
let _ = write_to_fna(
&site.to_string(),
Expand Down
7 changes: 6 additions & 1 deletion ncbi/src/md5sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ use tokio::fs::File;
use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader};

async fn get_md5_for_file(target_file: &PathBuf, md5_file: &PathBuf) -> Result<String> {
let file = File::open(md5_file).await?;
let file = File::open(md5_file).await.map_err(|e| {
tokio::io::Error::new(
tokio::io::ErrorKind::NotFound,
format!("File operation failed: {:?}-{:?}", md5_file, e),
)
})?;
let reader = BufReader::new(file);
let mut lines = reader.lines();

Expand Down
2 changes: 1 addition & 1 deletion ncbi/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub async fn run_task(
asm_levels: &Vec<&str>,
num_threads: usize,
) -> Result<()> {
log::info!("{} {} download assembly file start...", group, site);
log::info!("{} {} download file start...", group, site);
let (tx, rx) = mpsc::channel(4096); // 通道大小可以根据需要调整
let (tx1, rx1) = mpsc::channel(4096); // 通道大小可以根据需要调整
let assembly_tasks = process_assembly_tasks(site, group, data_dir, asm_levels, tx);
Expand Down

0 comments on commit de7ceae

Please sign in to comment.