Entering edit mode
3.2 years ago
houssienali
•
0
Hi, how can I make a loop for sam to bam then delete sam file in the same loop
Hi, how can I make a loop for sam to bam then delete sam file in the same loop
As others have suggested, do you have a process that generates SAM output that can be piped directly to samtools?
# sam output generated, yet sam file never exists
bowtie alignment_index -c GGATCC --sam | samtools view -b -o output.bam -
What language/method would you like to loop with? What have you tried? A bash example:
#!/bin/bash
sam_file="my_filename.sam"
alignment_index="path_to_your_index"
for f in $sam_file
do
bowtie $alignment_index -c GGATCC --sam > $f
samtools view $f -b -o output.bam
rm $f
done
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Are you sure you can't pipe your output straight to something that will convert it to bam? For instance, samtools sort will work on a sam, so you can pipe your sam output straight into it, and never actually make a sam file.
what did you try ?