ampinzonv / BB2

BioBash UN official repository
Other
3 stars 1 forks source link

bb_get_fasta_info fails when data comes from pipe #9

Open ampinzonv opened 1 year ago

ampinzonv commented 1 year ago

CONTEXT When invoked without optional arguments, only the necessary "--input" bb_get_fasta info displays all data in tabular format, like this: Seq_id header sequence

If the script is invoked without any argument it displays the Help, as is the default behavior in any other BB script.

PROBLEM When data comes from a pipe like this:

cat sequence.fasta | bb_get_fasta_info

Instead of showing the sequence information in tabular format, bb_get_fasta_info shows the help. Maybe because the underlyinf function that it uses (BBSeq::get_fasta_components) fails in identifying that the "-i" is not necessary if data comes already from a pipe. The problem is solved if any optional flag is used, like this:

cat sequence.fasta | bb_get_fasta_info -h (will show the header) cat sequence.fasta | bb_get_fasta_info -dsh (will show all the info in tabular format)

SOLUTION Probably the best way to solve this is inside the BBSeq::get_fasta_components function itself. I think between lines 137 and 145 is the key?

koriege commented 5 months ago

this is because you check for the number of positional arguments if [ $# -eq 0 ]. Piping a file into your script leaves $# zero.