3

For example

bwa sampe ref.fa r1.sai r2.sai r1.fq r2.fq | samtools view -bSho out.bam -;

What is the purpose of the "-;" characters at the end? What do they do? Why are they necessary?

feargal
  • 2,655
  • 2
  • 22
  • 27
E.Cross
  • 2,087
  • 5
  • 31
  • 39

1 Answers1

4

The semicolon ends the command (to end the pipeline is, I believe, technically the right way to say it). You could follow it with another command if you wanted to, as in

bwa sampe ref.fa r1.sai r2.sai r1.fq r2.fq | samtools view -bSho out.bam -; echo Here is another command.

Otherwise, the semicolon is harmless but probably unnecessary.

Regarding the - hyphen that precedes the semicolon, for samtools and many other commands it means to use standard input in place of an input file (or, in some cases, standard output in place of an output file). This is typical Linux/Unix usage.

(Thanks to @phatfingers for verifying the usage of the samtools command.)

thb
  • 13,796
  • 3
  • 40
  • 68
  • Ah, my understanding of it now is "the thing thats being piped", if that makes sense! Cool, thanks! – E.Cross Apr 26 '12 at 17:55
  • 1
    The man page at http://linux.die.net/man/1/samtools confirms your statement under the section entitled, "Description". – phatfingers Apr 26 '12 at 20:28
  • The semicolon does not mean end the "pipeline". It means the end of a command or statement or is a separator. That is "for x in `ls`; do echo $x; done" could be considered one pipeline but has two semicolons. Double semicolons are used for case separators. – Adam Gent Apr 27 '12 at 01:53
  • @AdamGent: Thanks for the feedback. Maybe I misread Bash's manpage. My version of the manpage reads, "A *list* is a sequence of one or more *pipelines* separated by one of the operators ;, &, &&, or ||, and optionally terminated by one of ;, &, or ." Of course you are right, and one does not wish to quibble with you over the trivia of semantics! But I *think* that my usage is correct. If not so, please advise. – thb Apr 27 '12 at 02:05
  • @thb No your right! I didn't really read or think before commenting :) – Adam Gent Apr 27 '12 at 15:09