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";'
Last updated on May 06, 2013
ecSeq is a bioinformatics solution provider with solid expertise in the analysis of high-throughput sequencing data. We organize public workshops and conduct on-site trainings on NGS data analysis.
Would you like to receive updates about our NGS trainings and solutions? Then sign-up for our newsletter