Batch convert of .xlsx (Microsoft Office) to .tsv (tab-delimited) files

I had to retrieve data from multiple .xlsx files with multiple sheets. This can be done manually, but it will be rather time-consuming tasks, plus Office quotes text fields, which is not very convenient for downstream analysis…
I have found handy script, xlsx2tsv.py, that does the job, but it reports only one sheet at the time. Thus, I have rewritten xlsx2tsv.py a little to save all sheets from given .xlsx file into separate folder. In addition, multiple .xlsx files can be process at once. My version can be found on github.

xlsx2tsv.py *.xlsx

Get gene names for set of RefSeq IDs

Today I needed to annotate set of RefSeq IDs in .bed file with gene names.
Firstly, I was looking for a way to get gene names for RefSeq IDs. I have found simple solution on BioStars.

mysql --user=genome -N --host=genome-mysql.cse.ucsc.edu -A -D danRer10 \
  -e "select name,name2 from refGene" > refSeq2gene.txt

Secondly, I’ve written simple Python script to add the gene name to .bed file in place of score which I don’t need at all.

#!/usr/bin/env python
# Add gene name instead of score to BED file
 
# USAGE: cat bed | bed2gene.py refSeq2gene.txt > with_gene_names.bed
 
import sys
 
fn = sys.argv[1]
refSeq2gene = {}
for l in open(fn):
    refSeq, gene = l[:-1].split('\t')
    refSeq2gene[refSeq] = gene
     
sys.stderr.write(" %s accesssions loaded!\n"%len(refSeq2gene))
     
for l in sys.stdin:
    ldata = l[:-1].split('\t')
    chrom, s, e, refSeq = ldata[:4]
    if refSeq in refSeq2gene:
        ldata[4] = refSeq2gene[refSeq]
    else:
        ldata[4] = "-"
    sys.stdout.write("\t".join(ldata)+"\n")

Hope, some will find it useful.

Making music on Ubuntu

This is just to share my (extremely basic!) knowledge for people having some sort of electric keyboard, piano or other MIDI enabled device and willing to learn something new. Once, you can connect your instrument to your computer you should be fine to follow this tutorial.
Recording MIDI
I have been playing previously with Reaper, but unfortunately it’s Windows-based program and sometimes I was encountering problems with it under Ubuntu. Therefore, I’ve looked for alternative, and I have found Rosegarden.

# install
sudo apt-get install rosegarden
 
# you may also want to install qjack, but it may  be installed internally by rosegarden
sudo apt-get install libjack0:i386 \qjackctl
 
# plug your MIDI device, run & record
rosegarden

Converting MIDI to MP3
Personally, I recommend online solution, solmire, that offers better sound quality in my opinion, than using timidity. Anyway, timidity seems quite powerful and I guess there is possibility to improve the quality somehow.

# install
sudo apt-get install timidity lame
 
# play
timidity your.mid
 
# convert to mp3
timidity your.mid -Ow -o - | lame - -b 96 your.mp3

Sharing your music
I really recommend SoundClound. It’s free for basic usage and has very strong community. You can check some of my pieces.
Do you know something more? Great! Please share it, as I’m really looking for some advices!
Inspired by UbuntuForums and many other forums.