Skip to content

Instantly share code, notes, and snippets.

View BioSparqlDraft.rb
require 'rubygems'
require 'active_rdf'
class Bio
class SPARQL
def initialize(params ={})
@adapter=ConnectionPool.add(:type => :sparql, :url => '', :engine => :virtuoso)
View gist:302336
=> ["type", "label", "title", "comment", "identifier", "url", "created", "modified", "replaced", "isReplacedBy", "seeAlso", "symbol", "subType", "location", "chromosome", "fromInterval", "toInterval", "xGI", "xGenBank", "xProteinID", "xTaxon", "xRef", "xEC", "synonym"]
irb(main):141:0> mySubject.xGI
=> [<RDFS::Resource:0xb7434650 @predicates={}, @uri="">, <RDFS::Resource:0xb74345d8 @predicates={}, @uri="">, <RDFS::Resource:0xb7434538 @predicates={}, @uri="">]
View gist:302339
irb(main):136:0> mySubject=myGenSemWeb.first.first
=> <RDFS::Resource:0xb74abcb4 @predicates={}, @uri="">
View gist:302340
irb(main):134:0> myGenSemWeb.fisrt
=> [<RDFS::Resource:0xb74abcb4 @predicates={}, @uri="">, <RDFS::Resource:0xb74abc50 @predicates={}, @uri="">, "similar to TP53 regulating kinase (p53-related protein kinase) (Nori-2)[geneid:578147]"]
View gist:777672
# Recode a vector based on a block
class Pippo
def recode!(vector_name)
0.upto(@cases-1) {|i|
@vectors[vector_name].data[i]=yield case_as_hash(i)
helios / gist:804318
Created Jan 31, 2011
Recover stats from genes list using targetscan filtered by miRNA 125b
View gist:804318
def gene_list(genes_str)
genes_str.split("\n").select{|gene| !(gene.empty? || gene.match(/LOC/))}
def targetted_genes(genes_ary)
Bio::Kb::Targetscan::Prediction.where(['gene_symbol IN (?) and species = 9606', genes_ary]).select("distinct gene_symbol").count
def targetted_125b(genes_ary),'hsa-miR-125b').count
helios / gist:885723
Created Mar 24, 2011
Esempio per il riassunto dei dati da sequenziamento
View gist:885723
require 'yaml'
ary_stats.each do |record|
sum += record[:stats] [: reads_total]
#in sum troverai il risultato
helios / gist:887127
Created Mar 25, 2011
BioRuby & Google Summer of Code 2011
View gist:887127
Dear All,
our project, is looking for students to participate at GSoC 2011, thanks to OBF and NESCENT
Please feel free to forward this message to your university-ml, lab or local ruby group.
Use our ml to discuss ideas and feel free to contact the mentors or any other member for the development team.
March 18-27: Would-be student participants discuss application ideas with mentoring organizations.
March 28: Student application period opens.
April 8 19:00 UTC Student application deadline.
helios / gist:905246
Created Apr 6, 2011
bioruby-ngs tophat task with sorting and indexing
View gist:905246
desc "tophat DIST INDEX OUTPUTDIR FASTQS", "run tophat as from command line, default 6 processors and then create a sorted bam indexed."
method_option :paired, :type => :boolean, :default => false, :desc => 'Are reads paired? If you chose this option pass just the basename of the file without forward/reverse and .fastq', :tophat) do |wrapper, task, dist, index, outputdir, fastqs|
wrapper.params = task.options #merge passed options to the wrapper.
wrapper.params = {"mate-inner-dist"=>dist, "output-dir"=>outputdir, "num-threads"=>6, "solexa1.3-quals"=>true}
fastq_files = task.options[:paired] ? ["#{fastqs}_forward.fastq","#{fastqs}_reverse.fastq"] : ["#{fastqs}"] :arguments=>[index, fastq_files ].flatten, :separator=>"="
accepted_hits_bam_fn = File.join(outputdir, "accepted_hit.bam")
helios / gist:942392
Created Apr 26, 2011
binding with ffi bam_merge_core
View gist:942392
# @abstract Merge multiple sorted BAM.
# @param is_by_qname whether to sort by query name
# @param out output BAM file name
# @param headers name of SAM file from which to copy '@' header lines,
# or NULL to copy them from the first file to be merged
# @param n number of files to be merged
# @param fn names of files to be merged
# @discussion Padding information may NOT correctly maintained. This
# function is NOT thread safe.