Hi,

I'm trying to pipe the following commands for ChipSeq analysis:

    ${bowtie2_source} -x ${ref_genome} -U ${fastq_file} -S - | ${samtools} view -Shub - | ${samtools} sort - | ${samtools} rmdup -S - - ${target_dir}/${sample_name}.bam

Up till the sorting part it works fine, but in the end, no bam file is created and it gives me the message:

    [bam_rmdup] input SAM does not have header. Abort!

What is the problem? and How should I fix it?

Thanks!
In the last step you seem to specify two `-` flags, I think that might attempt to open the stream twice, and since the second time it is empty, there is no header information. 

    ${samtools} rmdup -S - - ${target_dir}/${sample_name}.bam

In general, in such cases decompose the command into individual steps, each operating on a differently named file, then investigate the resulting file after each step.

The samtools error says that the SAM file does not have a header - check the file yourself - does it have a header?

BTW the `samtools view` step is not needed anymore, all samtools actions will auto detect and work seamlessly on SAM or BAM files. I also think that samtools now detects input stream, so specifying the `-` should not be needed in say sorting. The commands chain together much more elegantly now.
