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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nth() { | |
target=$1 | |
shift | |
idx=1 | |
for symbol in $@; do | |
if [ $symbol == $target ]; then | |
echo $idx | |
return | |
fi | |
idx=$(($idx+1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Christian Theil Have, Sep. 2009. | |
require 'rubygems' | |
require 'xmlsimple' | |
class String | |
def to_prolog | |
"'" + self.gsub("'",'\\\\\'') + "'" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% DFA minimization | |
:- use_module(library(chr)). | |
:- chr_constraint trans/3, state/1, same/2, different/2, final/1, non_final/1, state_order/2. | |
% A simple test DFA for arithmetic expressions | |
test :- | |
final(s3), | |
trans('(', s1, s1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- use_module(library(chr)). | |
:- set_prolog_flag(chr_toplevel_show_store,false). | |
simplehmm2prism(InputFile,OutputFile) :- | |
read_hmm(InputFile), | |
write_hmm(OutputFile). | |
% These rules are only used as template for creating | |
hmm(L) :- msw(trans(start),S0),hmm(S0,L). |