Skip to content

Instantly share code, notes, and snippets.

View MatthewRalston's full-sized avatar
🤒
Out sick

Matt Ralston MatthewRalston

🤒
Out sick
View GitHub Profile
@MatthewRalston
MatthewRalston / Random_subsample.xml
Last active August 29, 2015 14:25
Galaxy tool for subsampling a fastq file.
<tool name="Random Subsample" id="subsample_fastq" version="0.0.1">
<description>Subsamples a fastq file</description>
<command>
RandomSubFq -w $readsRequested
-i $paired_fastq_files.forward
-i $paired_fastq_files.reverse
-o $paired_list_output.forward
-o $paired_list_output.reverse
</command>
@MatthewRalston
MatthewRalston / summarize_fastqc.xml
Created July 15, 2015 21:02
Galaxy tool for summarizing fastqc information
<tool name="Summarize FastQC" id="summarizeFastQCMetrics" version="0.0.1">
<description>summarizes data from FastQC</description>
<command>
#def pairfunc($theList)
#set $left = []
#set $right = []
#for $file1, $file2 in $theList
#$left.append(str($file1))
#$right.append(str($file2))
@MatthewRalston
MatthewRalston / log.conf
Created October 28, 2015 21:51
Python logging: configuration file and root_logger setup.
import logging
import logging.config
def get_root_logger(loglevel, logfile=None, log_config="log.conf"):
# Requires 'import logging' and 'import logging.config'
def log_level(loglevel):
case = {"DEBUG": logging.DEBUG,
"INFO": logging.INFO,
"WARNING": logging.WARNING,
@MatthewRalston
MatthewRalston / example.rb
Created November 16, 2015 17:08
log4r YAML configuration
require 'log4r'
require 'log4r/yamlconfigurator'
include Log4r
ycfg = YamlConfigurator
ycfg["LOGFILE"] = "/home/matt/logs/myapp.log"
ycfg.load_yaml_file("/home/matt/.config/ruby/logger.yaml")
root_logger = Logger['root_logger']
@MatthewRalston
MatthewRalston / Autogen.log
Created November 24, 2015 16:13
Slurm-drmaa compilation logs
>./autogen.sh
checking for aclocal... yes
checking for autoheader... yes
checking for autoconf... yes
checking for libtoolize... yes
checking for automake... yes
running aclocal -I m4 (/opt/slurm-drmaa-slurm-drmaa-1.2.0-clusters)
running libtoolize --automake --copy --force (/opt/slurm-drmaa-slurm-drmaa-1.2.0-clusters)
running autoheader --warnings=all (/opt/slurm-drmaa-slurm-drmaa-1.2.0-clusters)
running automake --foreign --add-missing --copy --warnings=all (/opt/slurm-drmaa-slurm-drmaa-1.2.0-clusters)
@MatthewRalston
MatthewRalston / fancy_scientific.R
Created March 21, 2016 16:16
Scientific notation (5x10^5)
fancy_scientific <- function(l) {
# turn in to character string in scientific notation
l <- format(l, scientific = TRUE)
# quote the part before the exponent to keep all the digits
l <- gsub("^(.*)e", "'\\1'e", l)
# turn the 'e+' into plotmath format
l <- gsub("e", "%*%10^", l)
# return this as an expression
parse(text=l)
}
@MatthewRalston
MatthewRalston / hamming_match.py
Created April 29, 2016 22:27
Hamming distance match
'''
When you want to match files that only differ by one character: sample_1.fastq.gz sample_2.fastq.gz
'''
def is_hamming_match(seq1, seq2):
if len(seq1) == len(seq2): # The sequences must be of equal length
zipped = zip(seq1, seq2)
is_mismatch = list([c1 != c2 for c1, c2 in zipped])
if sum(is_mismatch) == 1: # The sequences must have only one mismatch
mismatches = list([[c1, c2] for c1, c2 in zipped if c1 != c2])
if mismatches[0] == ['1', '2'] or mismatches[0] == ['2', '1']: # The mismatch must only be the numbers 1 and 2
@MatthewRalston
MatthewRalston / ml-ruby.md
Created May 5, 2016 21:43 — forked from gbuesing/ml-ruby.md
Resources for Machine Learning in Ruby

Resources for Machine Learning in Ruby

Gems

@MatthewRalston
MatthewRalston / Hello.rb
Created December 19, 2016 22:23
Adelle
partner = Object.new
def my_most_sincere_apology
"I'm sorry for everything that I've done. But when I call you never seem to be home."
end
try:
1000.times do |t|
partner.call(:my_most_sincere_apology)
end
catch e:
@MatthewRalston
MatthewRalston / _service.md
Created April 7, 2017 14:35 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)