sam to bam then delete sam file
1
0
Entering edit mode
2.4 years ago

Hi, how can I make a loop for sam to bam then delete sam file in the same loop

samtobam loop • 1.4k views
ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

what did you try ?

ADD REPLY
1
Entering edit mode
2.4 years ago
seidel 11k

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
ADD COMMENT

Login before adding your answer.

Traffic: 2159 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6