Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
if ARGV.length != 1
puts "Usage: ./average_experiments experiment_directory\n\n"
puts "Computes the average over a number of experiment data files"
puts "located in the directory given as first argument. "
puts "The experiment files are expected to contain an equal number lines "
puts "with an equal number of entries. Each entry is expected to be a number"
puts "and entries are expected to be separated by space."
exit
#!/usr/bin/env ruby
# Simple utility to remove trailing space in the end of lines
# Takes as first argument the file to be processed.
lines = []
File.open(ARGV[0]).each do |line|
line.reverse =~ /\s*(.*)/
lines << $1.reverse
end
@cth
cth / prism_switch_html.pl
Created May 2, 2011 07:37
A prolog program that creates a colored HTML document for visualizing PRISM parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A simple script to create a visual report of PRISM parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% May 2011, Christian Theil Have
%
% usage: prism_switch_html(PRISM_SWITCH_FILE, HTML_OUTPUT_FILE).
%
:- table int_to_hex/2.
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
public class RectangleComponent extends JComponent {
public void paintComponent(Graphics g) {
// Recover Graphics2D
Graphics2D g2 = (Graphics2D)g;
@cth
cth / nth.sh
Created March 12, 2014 11:43
Select index of a particular named argument
function nth() {
target=$1
shift
idx=1
for symbol in $@; do
if [ $symbol == $target ]; then
echo $idx
return
fi
idx=$(($idx+1))
@cth
cth / swapgeno.rb
Created September 22, 2014 10:51
Script to swap alleles in imputed .gprobs files (genotype likelihoods), e.g., from IMPUTE2
# Script to swap alleles in imputed .gprobs files (genotype likelihoods), e.g., from IMPUTE2
# ruby swapgeno.rb genotypes.gprobs swap_snps.txt swapped.gprobs
# swap_snps.txt is a list of SNPs for which genotypes should be swapped (one per line in file)
# Read list of snps to swap
swap_snps = {}
File.open(ARGV[1]) { |sf| sf.each { |l| swap_snps[l.chomp] = true } }
File.open(ARGV[2],"w") do |outfile|
File.open(ARGV[0]) do |file|
@cth
cth / README.md
Last active February 22, 2016 09:03 — forked from anonymous/README.md

Markdown based testing of files

This is a markdown based language for specification of testcases for files in a filesystem. Ideally a set of files may be described and at the same time formal specifications about the files can be specified using test cases written in, e.g., shell scripts embedded as code-blocks.

Overview

def mean_std_dev(arr,n)
sum=0
mean = arr.inject{|sum,x| sum + x } / n.to_f
total=0
[mean, Math.sqrt(arr.inject{|total,x| total + ((mean-x)*(mean-x)) } / n.to_f) ]
end
def percentile_depths(arr,n,pct)
samples_in_percentile = (n * pct).floor
(arr.sort.reverse.slice(0,samples_in_percentile)).min
require 'rinruby'
require 'bio-samtools'
require 'rake'
plink_stems = {
:lucamp => "/eva/brutus/J8/data/deepExom/burden5/clean/lrt24qibin7R2BeagleV2",
# :metabochip => "/eva/brutus/J8/data/metaboChip/clean/metaboChipAll",
:exomchip => "/eva/brutus/J8/data/exomChip/clean/exomChipAll"
}
#!/bin/sh
#$ -S /bin/bash
#$ -cwd
# Christian Theil HAve, 2015
# Modify this to be the final report directory of interest
# Note that final reports must contain LRR and BAF
FINAL_REPORTS_DIR=target_final_reports
# This is where