Skip to content

Commit

Permalink
fix dl filename
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegenes committed May 21, 2024
1 parent 58b0037 commit c328cc3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
7 changes: 3 additions & 4 deletions src/directsketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,12 @@ async fn dl_sketch_url(
{
Some(data) => {
// check keep_fastas instead??
if let Some(download_filename) = download_filename {
if let Some(ref download_filename) = download_filename {
let path = location.join(download_filename);
fs::write(path, &data).context("Failed to write data to file")?;
}
if !download_only {
// let filename = download_filename.clone().unwrap();
let filename = "".to_string();
let filename = download_filename.clone().unwrap_or("".to_string());
// sketch data
match moltype {
InputMolType::Dna => sigs.extend(
Expand Down Expand Up @@ -451,7 +450,7 @@ async fn dl_sketch_url(
name: name.clone(),
moltype: moltype.to_string(),
md5sum: expected_md5.map(|x| x.to_string()),
download_filename: download_filename,
download_filename,
url: Some(url),
};
failed.push(failed_download);
Expand Down
12 changes: 3 additions & 9 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ pub fn load_gbassembly_info(input_csv: String) -> Result<(Vec<GBAssemblyData>, u
Ok((results, row_count))
}

#[allow(dead_code)]
pub fn load_accession_info(
input_csv: String,
keep_fasta: bool,
Expand Down Expand Up @@ -228,14 +227,9 @@ pub fn load_accession_info(
.parse::<InputMolType>()
.map_err(|_| anyhow!("Invalid 'moltype' value"))?;
let expected_md5sum = record.get(3).map(|s| s.to_string());
let mut download_filename = None;
if keep_fasta {
download_filename = Some(
record
.get(4)
.ok_or_else(|| anyhow!("Missing 'download_filename' field"))?
.to_string(),
);
let download_filename = record.get(4).map(|s| s.to_string());
if keep_fasta && download_filename.is_none() {
return Err(anyhow!("Missing 'download_filename' field"));
}
let url = record
.get(5)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_urlsketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ def test_urlsketch_from_gbsketch_failed(runtmp, capfd):
assert acc == "GCA_000175535.1"
assert name == "GCA_000175535.1 Chlamydia muridarum MopnTet14 (agent of mouse pneumonitis) strain=MopnTet14"
assert moltype == "protein"
# TODO: fix download_filename
# assert download_filename == "GCA_000175535.1_protein.faa.gz"
assert download_filename == "GCA_000175535.1_protein.faa.gz"
assert url == "https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/175/535/GCA_000175535.1_ASM17553v1/GCA_000175535.1_ASM17553v1_protein.faa.gz"


Expand Down

0 comments on commit c328cc3

Please sign in to comment.