Skip to content

Instantly share code, notes, and snippets.

View pontikos's full-sized avatar
😀

Nikolas Pontikos pontikos

😀
View GitHub Profile
@pontikos
pontikos / xlsx2csv.sh
Created February 12, 2015 12:59
Convert excel spreadsheet to csv using https://github.com/dilshod/xlsx2csv
#!/bin/bash
#$ -S /bin/bash
#$ -o /dev/null
#$ -e /dev/null
#$ -cwd
#$ -V
#$ -R y
#$ -pe smp 1
#$ -l scr=1G
#$ -l tmem=2G,h_vmem=1G
@pontikos
pontikos / createlinks.sh
Created January 19, 2015 13:00
Script for creating links to files (dirs are ignored).
@pontikos
pontikos / joinonfield.py
Created January 16, 2015 17:19
Join lines of CSV file on column field number specified (starting at 0).
import sys
i=int(sys.argv[1])
d=dict()
for l in sys.stdin.readlines():
l=l.strip().split(',')
k=l.pop(i)
d[k]=d.get(k,[])+l
for k in d:
print ','.join([k]+d[k])
@pontikos
pontikos / multiallele_to_single_gvcf.py
Created January 15, 2015 23:02
splits ALT alleles over multiple lines
import sys,gzip
vcf = gzip.open(sys.argv[1],"r")
#these 9 column headers are standard to all VCF files
STD_HEADERS=['CHROM','POS','ID','REF','ALT','QUAL','FILTER','INFO','FORMAT']
#the samples headers depend on the number of samples in the file
#which we find out once we read the #CHROM line
SAMPLE_HEADERS=[]
@pontikos
pontikos / createsymlinks.sh
Created January 13, 2015 15:58
Create symlinks to chr directory.
@pontikos
pontikos / xargs.sh
Created January 9, 2015 17:19
xargs examples for those that can never remember the syntax
seq 1 10 | xargs -I x echo number x
@pontikos
pontikos / jobarray.sh
Last active August 29, 2015 14:13
script to output SGE job array, which can then be submitted with qsub
#! /bin/bash
set -e
set -u
##
until [ -z "$1" ]
do
# use a case statement to test vars. we always test $1 and shift at the end of the for block.
case $1 in
# parameters to qsub
@pontikos
pontikos / bgziptabix.sh
Created January 7, 2015 14:52
Takes vcf file and writes to vcf.gz OR takes gz filename as arguments and reads from stdin.
#!/bin/bash
f=$1
extension=${f##*.}
if [[ "$extension" == 'vcf' ]]
then
in=$f
out=${in}.gz
bgzip $in > $out
@pontikos
pontikos / shellcommands.sh
Created January 7, 2015 14:35
Some random shell commands.
#Which shell?
ps | grep $$
#Which distro?
cat /etc/issue
#Which connections?
lsof -i
netstat -lptu
cat /proc/xxxx/net/tcp
@pontikos
pontikos / errorfunctions.sh
Created January 6, 2015 19:19
Error functions for bash.
# prints to stderr in red
function error() { >&2 echo -e "\033[31m$*\033[0m"; }
function stop() { error "$*"; exit 1; }
try() { "$@" || stop "cannot $*"; }