Linux: Zipping all files recursively to different names

Hey people,

Quickly, using shell script, one can tar the required files in a folder recursively to ’.tar.gz’

for i in `ls *`; do tar czvf $i.tar.gz $i; done

# specific selection - zipping all avi movie files to specific tar

for i in `ls *.mp3`; do tar czvf $i.tar.gz $i; done

Have fun,

Sukhdeep Singh

ogv to mp4 converter (Record my desktop)


Record my desktop produces .ogv files but for uploading to youtube, I would recommend some fancy format like .mp4 or .avi.

Use this tool called ‘mencoder’ to convert the files, using command

install it using

sudo apt-get install mencoder

run it using

mencoder out.ogv -of lavf -lavfopts format=mp4 -oac mp3lame -lameopts cbr:br=128 -ovc x264 -x264encopts bitrate=1000 -o final.mp4

input ogv file = out.ogv

output mp4 file = final.mp4

Cheers Sukhi
NGS: Getting coverage from bam file for displaying peaks in UCSC browser in bigwig format.

Hola people!

Quick tutorial on how to convert bam file to bedGraph (different from bed files) for displaying them into UCSC browser. We will convert them to bigwig (bw), which are more portable, encrypted and less space consuming data formats. Its an important step is called obtaining coverage and visualizing them as peaks.

Step 1: using a combination of ‘samtools’ and 'bedtools’ and ofcourse 'shell pipe’

samtools view -b file.bam | genomeCoverageBed -ibam stdin -bg -g genomeIndex/mm9.chrom > file.bedGraph &

input file = file.bam; output = file.bedGraph

genomeIndex = mm9.chrom (to get the genome index, which a text file containing the mouse genome size per chromosome, use fetchChromSizes, get it from UCSC ftp

Step2 : sort obtained bedGraph file chromosome wise using sort

sort -k1,1 -k2,2n file.bedGraph > file.bedGraph.sorted

Step 2: converting bedGraph to bigwig

using  bedGraphToBigWig utility from UCSC tools (

bedGraphToBigWig file.bedGraph.sorted genomeIndex/mm9.chrom

I will make another post, how to use 'bw’ (bigwig) files for viewing them on server using a https link and sharing a url.

Any problems, please comment, I will try to answer.


Sukhdeep Singh

Max Planck Society