Skip to content

Instantly share code, notes, and snippets.

View yannickwurm's full-sized avatar
😜

Yannick Wurm yannickwurm

😜
View GitHub Profile
@yannickwurm
yannickwurm / gist:1292170
Created October 17, 2011 07:58
alternate error message
"<h1>ERROR: incorrect number of sequences found.</h1
<p>Dear user,</p>
<p><strong>you requested #{sequenceids.length} sequences</strong>
with the following identifiers:  <emph>#{sequenceids.join(', ')}</emph>,
from the following databases:<emph>#{retrieval_databases.join(', ')}</emph>.
</p>
<p/>
<p><strong>But we found #{found_sequences_count} sequences.</strong>.
This is <em>#{found_sequences_count > sequenceids.length ? 'more' : 'less'}</em>
sequences than expected.</p>
@yannickwurm
yannickwurm / mergePairedReads.rb
Created August 22, 2012 14:00
Paste left read and right read from Illumina into a single megaread
#!/usr/bin/env ruby
# (copy) Yannick Wurm - google me.
# All right reserved.
help = "Usage: \n" +
" #{$0} MySequences_R1.fastq MySequences_R2.fastq > MySequences_R1R2pasted.fastq\n" +
"Joins two paired reads into a single megaread. Can be helpful for deduplication.\n" +
"The two fastq files must have reads in the same order. Some error checking is performed.\n"
def YWSystemTools.runMultithreaded(commandArray)
# runs commands on N processors at a time - can take more jobs & launches them sequentially.
if commandArray.length > 1
$log.info("#{commandArray.length} commands to run")
elsif commandArray.length == 1
$log.warn("only one command!")
else
raise ArgumentError, 'No commands to run!'
end
('proc00001'..'proc00024').each do |processor|
threads << Thread.new(processor) do |threadid|
until commandArray.empty?
commandToRun = commandArray.pop
$log.info('running:' + commandToRun)
## %x[#{commandToRun}]
stdout = %x[#{commandToRun}]
print(stdout)
end
end
@yannickwurm
yannickwurm / gist:6931821
Created October 11, 2013 09:06
Detecting numbers of processors in ruby (old ugly code)
def YWSystemTools.number_of_processors
if RUBY_PLATFORM =~ /linux/
cpuinfo = IO.readlines("/proc/cpuinfo").delete_if{|x| x.index("processor")==nil}
return cpuinfo.length
elsif RUBY_PLATFORM =~ /darwin/
return `sysctl -n hw.logicalcpu`.to_i
elsif RUBY_PLATFORM =~ /win32/
# this works for windows 2000 or greater
require 'win32ole'
wmi = WIN32OLE.connect("winmgmts://")
def parse(signalp_hash, open_reading_frames_condensed, motif)
signalp_with_seq = {}
signalp_hash.each do |id, h|
current_orf = open_reading_frames_condensed[id]
sequence = current_orf.to_s.gsub('["', '').gsub('"]', '')
sp_clv = h[0][:cut_off].to_i - 1
signalp = sequence[0,sp_clv]
seq_end = sequence[sp_clv+1, sequence.length - (sp_clv+1)]
if seq_end.match(/#{motif}/)
signalp_with_seq[id + "~- S.P. Cleavage Site: #{sp_clv}:" \
@yannickwurm
yannickwurm / gist:9988636
Created April 5, 2014 07:44
Create iPhone ringtones from directory of mp3s
mkdir converted
find . -regex .*mp3 | ruby -pe 'gsub(".mp3", "")' | xargs -I __ ffmpeg -i __.mp3 -ss 0 -t 30 -ac 1 -ab 256000 -f mp4 -acodec libfaac -y __.m4r
#important: limit to 30 seconds otherwise iTunes won't transfer it to iphone.
-bash-4.1$ uname -a
Linux sm11 2.6.32-431.1.2.el6.x86_64 #1 SMP Thu Dec 12 13:59:19 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
-bash-4.1$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
-bash-4.1$ which ruby
~/.rbenv/shims/ruby
-bash-4.1$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux]
Score Expect Identities Positives Gaps Frame
34.97 (70) 0.163 13/27 (48.15%) 19/27 (70.37%) 0/27 (0.00%) (3/-2)
Query 111 LVLGLIGNIFLMYYFVKCLLKYFI*KI 191
LVL L+ N+ + YY + CLL YF+ +I
Subject 120133 LVLKLVDNLAIYYYIILCLLLYFLIRI 120213
Failed to load resource: the server responded with a status of 401 (Unauthorized) http://afra.sbcs.qmul.ac.uk/lib/jquery/jquery.js?bust=1409565929178
Uncaught Error: Script error for: jquery
http://requirejs.org/docs/errors.html#scripterror require.js:138
Failed to load resource: net::ERR_FAILED chrome-extension://invalid/
less: XHR: Getting 'http://afra.sbcs.qmul.ac.uk/styles.less?bust=1409565929178' lessc.js?bust=1409565929178:6297
less: XHR: Getting 'http://afra.sbcs.qmul.ac.uk/lib/bootstrap/less/variables.less' lessc.js?bust=1409565929178:6297
less: XHR: Getting 'http://afra.sbcs.qmul.ac.uk/lib/bootstrap/less/mixins.less' lessc.js?bust=1409565929178:6297
less: XHR: Getting 'http://afra.sbcs.qmul.ac.uk/lib/bootstrap/less/normalize.less' lessc.js?bust=1409565929178:6297
less: XHR: Getting 'http://afra.sbcs.qmul.ac.uk/lib/bootstrap/less/scaffolding.less' lessc.js?bust=1409565929178:6297