nextstrain / nextclade

Viral genome alignment, mutation calling, clade assignment, quality checks and phylogenetic placement

Home Page:https://clades.nextstrain.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible CLI bug: TSV output not gzipped.

theosanderson opened this issue · comments

On linux (nextclade 2.14.0) I ran:

nextclade run    --input-dataset=data/sars-cov-2    --input-ref=data/sars-cov-2/reference.fasta    --input-gene-map=data/sars-cov-2/genemap.gff    --genes=E,M,N,ORF1a,ORF1b,ORF3a,ORF6,ORF7a,ORF7b,ORF8,ORF9b,S    --input-tree=data/sars-cov-2/tree.json    --input-qc-config=data/sars-cov-2/qc.json    --input-pcr-primers=data/sars-cov-2/primers.csv    --input-virus-properties=data/sars-cov-2/virus_properties.json    --output-tsv=output/nextclade.tsv.gz    my.fa.zst

I expected nextclade.tsv.gz to be a compressed file but it was a plain text file. Maybe the TSV isn't supported for this?

Hi Theo @theosanderson!

I cannot reproduce. I tried this:

docker run -it --rm nextstrain/nextclade:2.14.0 bash -c "set -euxo pipefail \
&& apt-get update >/dev/null \
&& apt-get install --yes file gzip >/dev/null \
&& nextclade dataset get --name=sars-cov-2 --output-dir=data/sars-cov-2 \
&& nextclade run --input-dataset=data/sars-cov-2 --input-ref=data/sars-cov-2/reference.fasta --input-gene-map=data/sars-cov-2/genemap.gff --genes=E,M,N,ORF1a,ORF1b,ORF3a,ORF6,ORF7a,ORF7b,ORF8,ORF9b,S --input-tree=data/sars-cov-2/tree.json --input-qc-config=data/sars-cov-2/qc.json --input-pcr-primers=data/sars-cov-2/primers.csv --input-virus-properties=data/sars-cov-2/virus_properties.json --output-tsv=output/nextclade.tsv.gz data/sars-cov-2/sequences.fasta \
&& file output/nextclade.tsv.gz \
&& gzip -t -v output/nextclade.tsv.gz \
"

Results:

debconf: delaying package configuration, since apt-utils is not installed
output/nextclade.tsv.gz: gzip compressed data, original size modulo 2^32 175624
output/nextclade.tsv.gz:	 OK

How do you check that the output file is not compressed? Can you provide some more steps to reproduce?

In terms of implementation, I believe that all created files go though this line:

let compressor = Compressor::from_path(buf_file, filepath)?;

including in the CSV/TSV file writer:

let csv_writer = CsvVecFileWriter::new(filepath, delimiter, &headers)?;

let file = create_file_or_stdout(filepath)?;

But let's see if something weird is happening

I also can't reproduce. I was wrong. I am really sorry to have wasted your time on this. Thank you for writing such a detailed reply.

To explain what happened: I normally work on a system where less and wc both don't work on compressed files. I absent mindedly used wc -l to monitor a big gzipped Nextclade output (on a different system) and was surprised when it worked. I tried to "double-check" by "looking at the actual contents" with less, and that worked too so I thought it was plaintext. But actually both tools were decompressing under the hood, which I didn't know either of them could.

Really sorry again to have taken up your time! Thank you for Nextclade - it's wonderful.

both tools were decompressing under the hood, which I didn't know either of them could

Huh! No worries! I never knew they did either. Good to know :)