Converting Sam To Bam
2
Hi,
I have set of sam files and I would like to convert them into bam files with the following script. But it didn't create bam files? What I have made wrong?
for file in ` ls ~/wgs/sam` ;
do
~/bin/samtools-0.1.18/samtools view -bS ~/wgs/sam/$file \
> ~/wgs/bam/$FILE .bam;
done
Thanks
bam
sam
• 31k views
•
link
updated 2.3 years ago by
Ram
45k
•
written 13.2 years ago by
Haluk
▴
190
Haluk, you should use the option -o FILE output file name [ stdout]
instead of redirecting the stdout to the bam file.
•
link
updated 2.3 years ago by
Ram
45k
•
written 13.2 years ago by
Pascal
★
1.5k
Not sure what you did wrong, but I use samtools view -bT reference.fa test.sam > test.bam
and it works pretty well
•
link
updated 2.3 years ago by
Ram
45k
•
written 9.9 years ago by
Jautis
▴
580
Login before adding your answer.
Çould you comment on whether any files are created at all? If yes, what type of files are they?
Actually, I had a typo in my script. Here is the right one. Sorry about that.
You use
$file
to define the SAM file, yet$FILE
for the BAM.s/$FILE/$file/
and you should be good.As a result, I had bam files for each sam files.
And that's what you wanted, right
yes, Andreas, problem solved.