Skip to content

Instantly share code, notes, and snippets.

View pontikos's full-sized avatar
😀

Nikolas Pontikos pontikos

😀
View GitHub Profile
@pontikos
pontikos / format_time.py
Last active August 29, 2015 14:12
Format time given on stdin in format specified by first argument to stdout in format given by second argument.
import time
import sys
print time.strftime(sys.argv[2], time.strptime(sys.stdin.read().strip(), sys.argv[1]))
@pontikos
pontikos / count.awk
Last active August 29, 2015 14:12
Counts occurences of a field in output.
#! /usr/bin/awk -f
{
count[$1]++
}
END {
sort = "sort -n"
for(j in count)
print j, count[j] | sort
close(sort)
@pontikos
pontikos / replaceline.awk
Last active August 29, 2015 14:12
Prepends the string Levine_ to fields which do not start with the prefix Levine_
#! /bin/awk -f
BEGIN {
OFS = FS
}
{
# only one line starting with #CHROM needs to be modified in file
# all others just print out unmoodified
if ( $1 !~ /^#CHROM/ ) {
@pontikos
pontikos / drawchull.R
Last active January 4, 2016 07:19
Draw convex hull around points
testpts <- structure(list(x = c(4.9, 4.2, 4, 4.1, 4.4, 5.8, 5.8, 5.8, 5.8,
5.5, 4.9, 3.2, 3.2, 3.3, 5.4, 5.4, 5.7, 6.4, 6.7, 6.7, 6, 4.8,
3.6, 2.8, 3.5, 4.4, 5.1, 4, 3.7, 4.5, 4.9, 5.7), y = c(6.9, 6.2,
5.3, 4.1, 3.1, 2.9, 2.9, 3.5, 4.2, 4.9, 5.1, 4.9, 4.9, 5.2, 6.9,
6.9, 5.3, 3.8, 4.2, 5.6, 6.9, 5.8, 1.2, 2.5, 5.3, 6.4, 6.8, 7.6,
6.9, 5.4, 4.8, 4.4)), .Names = c("x", "y"))
x <- do.call('cbind',testpts)
ch<-chull(x)
plot(x,pch=20)
points(x[ch,],pch=20,col='red')