Enable pangolin to read from stdin #334
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This aims to resolve #329.
pangolin can now read in stdin from a bash pipe with "-", as requested in #329. If no query fasta or stdin is specified, such as :
pangolin --outfile lineage_report.csv
pangolin will output:
Error: input query fasta could not be detected from a filepath or through stdin. Please enter your fasta sequence file and refer to pangolin usage at: https://cov-lineages.org/pangolin.html for detailed instructions.
If "-" is used to designate stdin, but there is no stdin for pangolin to use, i.e. if nothing is piped into the pangolin command:
pangolin --outfile lineage_report.csv -
it will output:
Error: cannot find query (input) fasta file using stdin. Please enter your fasta sequence file and refer to pangolin usage at: https://cov-lineages.org/pangolin.html for detailed instructions.
The methods for dealing with file paths that do not exist remain the same as before.
If the user attempts to pass a compressed stdin, such as:
cat test.fa | gzip | pangolin --outfile lineage_report.csv -
pangolin will report:
Error: error when reading query fasta. It is possible that compressed stdin was passed.
A important note that is this error message above will be thrown if any of the inputs (compressed or not) cannot ultimately be read as a FASTA file by SeqIO. This may want to be changed in the future but I tried my best to allow pangolin to differentiate between stdin and filepaths and the compression status of either input.