The following command line perl provides an easy way to convert the alignments in a BAM file to BED format.
samtools view file.bam | perl -F'\t' -ane '$strand=($F&16)?"-":"+";$length=1;$tmp=$F;$tmp =~ s/(\d+)[MD]/$length+=$1/eg;print "$F\t$F\t".($F+$length)."\t$F\t0\t$strand\n";'
ecSeq is a bioinformatics solution provider with solid expertise in the analysis of high-throughput sequencing data. We can help you to get the most out of your sequencing experiments by developing data analysis strategies and expert consulting. We organize public workshops and conduct on-site trainings on NGS data analysis.
Last updated on May 06, 2013