Skip to content

Instantly share code, notes, and snippets.

View konrad's full-sized avatar

Konrad Förstner konrad

View GitHub Profile
@konrad
konrad / split_fasta.py
Last active October 19, 2016 07:50
Split a multi entry fasta file into several files with on entry
import argparse
from Bio import SeqIO
parser = argparse.ArgumentParser(
description="Split a multi entry fasta file into several files "
"with one entry")
parser.add_argument("input_file")
parser.add_argument("output_prefix")
args = parser.parse_args()
@konrad
konrad / explore_music.sh
Last active August 29, 2015 14:13
Explore my music folder
# Search for all mp3 and ogg files in my music folder and use mplayer to play in random order
mplayer -shuffle -playlist $(find $MY_MUSIC_FOLDER -name "*ogg" -o -name "*mp3")
@konrad
konrad / medline_search.py
Last active August 29, 2015 14:09
Small script to retrieve data of all publications of a given journal in a given time frame from MEDLINE
#!/usr/bin/python
# medline_search.py
#
# Small script to retrieve data of all publications of a given journal in
# a given time frame from MEDLINE
#
# 2014 - Konrad Förstner <[email protected]>
#
# To the extent possible under law, the author have dedicated all
@konrad
konrad / reademption_install.sh
Created July 30, 2014 21:03
READemption installation script
main(){
upgrade_and_install_packages
install_segemehl
install_reademption
}
upgrade_and_install_packages(){
sudo apt-get update
sudo apt-get upgrade --assume-yes
sudo apt-get install --assume-yes \
@konrad
konrad / csv2xlsx.py
Last active April 1, 2022 16:46
Converts a CSV (tab delimited) file to an Excel xlsx file
#!/usr/bin/env python
"""
FUNCTION: Converts a CSV (tab delimited) file to an Excel xlsx file.
Copyright (c) 2016, Konrad Foerstner <[email protected]>
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all
copies.
@konrad
konrad / convert_video_to_spedup_mp3.sh
Created July 16, 2012 11:18
Script to convert videos to mp3 with higher speed
SPEED=1.5
for FILE in $@
do
WAV_FILE=$(basename $FILE .mp4).wav
WAV_FILE_SPED_UP=$(basename $FILE .mp4)_spedup.wav
MP3_FILE=$(basename $FILE .mp4)_spedup.mp3
ffmpeg -i $FILE -vn $WAV_FILE
sox $WAV_FILE $WAV_FILE_SPED_UP tempo $SPEED
lame $WAV_FILE_SPED_UP $MP3_FILE
@konrad
konrad / pubmed_search_bookmarkelt.js
Created March 22, 2012 12:04
Pubmed search bookmarklet - search marked text in Pubmed
/*
Use this as a bookmarklet by saving it as a web browser bookmark. Then mark a piece of text in a page and click the bookmark. The marked text will be searched in Pubmed.
*/
javascript:(function(){
var selected_text = '';
if (window.getSelection){
selected_text = window.getSelection();
}
else if (document.getSelection){
@konrad
konrad / generate_sam_test.py
Created September 28, 2011 18:03
A short test to generate a test SAM file with a long read
import sys
base_seq = "ACGT"
seq = base_seq * int(int(sys.argv[1])/len(base_seq))
spacer_length = 10000
header = "@HD VN:1.0\n@SQ SN:Mock LN:%s" % (len(seq) + spacer_length)
cigar_string = "%sM" % (len(seq))
genome_line = "62DJLAAXX_8:1:17056:1190 0 Mock 1 255 %s * 0 0 %s * NM:i:0 MD:Z:30 NH:i:1" % (
cigar_string, seq)
@konrad
konrad / Genbank genome downloader
Created April 2, 2011 17:14
A one-liner to get all the genome files form GenBank
# I always forget how easy it is to download all genome files from
# Genbank. Sure you can get any other file type (e.g. all protein
# file = *faa) instead.
wget -c -r -A "*fna" ftp://ftp.ncbi.nih.gov/genomes/Bacteria/
@konrad
konrad / send_msg_to_osw.py
Created June 5, 2010 15:17
A little example how to send messages to a OneSociaWeb server in Python.
#!/usr/bin/python
"""
FUNCTION: A little example how to send messages to a OneSociaWeb server
(http://onesocialweb.org). Heavily inspired by Tyler
Gillies' ruby script with the same purpose.
Copyright (c) 2010, Konrad Foerstner <[email protected]>
Permission to use, copy, modify, and/or distribute this software for