That works! Thank you very much indeed.
Hi,
I think this is a stupid question. But please help.
I want to do mpileup on the strand specific reads. I currently use two commands to achieve that. The first one is like this:
samtools view -b -o output.bam -f 0x10 input.sorted.bam
This generates a temporary file, say "output.bam". Then mpileup is applied on it like:
samtools mpileup output.bam|cut -d ' ' -f 1,2 |awk -F ' ' 'BEGIN... END ...'
Is there a solution to combine the two command without creating the temporary file "output.bam"?
I've tried this:
samtools view -f 0x10 input.sorted.bam|samtools mpileup|cut -d ' ' -f 1,2 |awk -F ' ' 'BEGIN... END ...'
But it returns an error coz samtools mpileup needs an input statement.
Please help. Thank you very much.
Dadi
2 answers
try
samtools view -f 0x10 -b input.sorted.bam|samtools mpileup -
instead of
samtools view -f 0x10 input.sorted.bam|samtools mpileup -
I have not tried it, but the manual states:
Samtools is designed to work on a stream. It regards an input file ‘-’ as the standard input (stdin) and an output file ‘-’ as the standard output (stdout). Several commands can thus be combined with Unix pipes. Samtools always output warning and error messages to the standard error output (stderr).
So you could try inserting "-" to represent the input for mpileup like so:
samtools view -f 0x10 input.sorted.bam | samtools mpileup - | cut -d ' ' -f 1,2 | awk -F ' ' 'BEGIN... END ...'
Thank you. But actually I've tried -. The bash said [bam_header_read] invalid BAM binary header (this is not a BAM file).
I think it recognized - as the filename and gave this error.
Log in to answer this question.
Hi all,
I am also having the same problem.
I want to pipe the samtools view(sam to bam converter) ,samtools sort and samtools index.
But I am getting error like following:
Commands working fine without the piping. When I checked I can see the output bam file generated by samtools view.
Please help....
Thanks,
Deeps
Next time please make a seperate question instead of posting your question as an answer. Try to understand what the commands do before putting them together.
Hi All
I have a question. I wish to run bowtie over 3 cores and get an output of aligned sorted and indexed bam files.
The above command just foes till sorted how can I also include a index via the pipe such that I get a sorted aligned bam and also the index in the same pipe?
I look forward for your help.
Thanks,
Yaseen
Maybe try posting a new question next time. To answer, try:
this is not an answer. ask this as as new question please.