nextclade icon indicating copy to clipboard operation
nextclade copied to clipboard

ENH: Add convenience flag to Nextclade CLI that auto-downloads and uses latest dataset

Open corneliusroemer opened this issue 3 years ago • 4 comments

In most situations, users will want to automatically use the latest dataset version.

Right now, that means one has to run two commands:

nextclade dataset get [...]
nextclade run --input-dataset [...]

We could add a convenience flag to nextclade to invoke the dataset command automatically after invokation, like:

nextclade run --input-sequences in.fa --download-dataset sars-cov-2 ...

This would download the latest version of the specified dataset to a temporary folder and use it directly followed by deletion.

corneliusroemer avatar Apr 20 '22 11:04 corneliusroemer

@corneliusroemer Where would be the temporary folder located? Is it not too risky to delete things?

ivan-aksamentov avatar Apr 20 '22 11:04 ivan-aksamentov

Doesn't this work: tempdir from tempfile crate? https://crates.io/crates/tempfile

use tempfile::tempdir;
use std::fs::File;
use std::io::{self, Write};

// Create a directory inside of `std::env::temp_dir()`
let dir = tempdir()?;

let file_path = dir.path().join("my-temporary-note.txt");
let mut file = File::create(file_path)?;
writeln!(file, "Brian was here. Briefly.")?;

// `tmp_dir` goes out of scope, the directory as well as
// `tmp_file` will be deleted here.
drop(file);
dir.close()?;

corneliusroemer avatar Apr 20 '22 12:04 corneliusroemer

Might work! (if it also works with docker and other weird things). Maybe we could just dump it to the current dir, with some predefined dir name?

In any case, a bit scary to delete stuff.

ivan-aksamentov avatar Apr 20 '22 12:04 ivan-aksamentov

Yes, create a temp-dir in the current directory. Should work - don't see why not. Not a priority, just think this could make it more usable without being too difficult to implement (I hope).

corneliusroemer avatar Apr 20 '22 12:04 corneliusroemer

We've completed this! One can auto-download a dataset with -d

corneliusroemer avatar Sep 22 '22 10:09 corneliusroemer