Skip to content

Instantly share code, notes, and snippets.

View cknoxrun's full-sized avatar

Craig Knox cknoxrun

View GitHub Profile
use strict;
package HyperGeometric;
use base 'Exporter';
our @EXPORT = qw( hypergeom );
####################################################################
## To calculate p-value using a hypergeometric test for compounds
## matched to a particular pathway in a given pathway database
##
require 'java'
require 'jchem_connection'
require 'lib/jchem/lib/jchem.jar'
java_package 'search.db'
java_import 'chemaxon.jchem.db.JChemSearch'
java_import 'chemaxon.sss.SearchConstants'
java_import 'chemaxon.sss.search.JChemSearchOptions'
def self.apply!(features, ca, oxy, hy, halo, s, ni, total_atom_nr, morphology, amino_acid_derivative, bile_acid_or_alcohol)
# TODO: ca + oxy + hy == total_atom_nr does not always hold
# for fatty acids, exple given CCCCCCCC(=O)O.NN.
# Deal with this!
if features.include?('fatty-ester-head') &&
features.include_any?('pregnane-skeleton',
'cholestane-skeleton',
'androstane-skeleton',
'estrane-skeleton',
# Note that this action responds to fracked up datatable parameters.
# If you need to use this for some other reason (HTML, etc), you
# might want to consider moving it into it's own method
# (datatable or something).
def index
# These are the columns, in the correct order, used by datatables
cols = [:gene_name, :gene_symbol, :gene_id, :interaction, :chromosome]
@gene_regulations =
if params[:kind] == 'up_regulated'
json.key_format! camelize: :lower
json.draw params[:draw].to_i + 1
json.records_total @total_count
json.records_filtered @filter_count
json.data do
json.array! @gene_regulations.each do |gene_regulation|
json.array! [ gene_regulation.gene_name,
bio_link_out(:genecard, gene_regulation.gene_symbol),
bio_link_out(:ncbi_gene, gene_regulation.gene_id),
gene_regulation.interaction,
$ ->
$('.gene-regulations').each ->
table = $(this)
source = table.data('source')
table.dataTable
processing: true
serverSide: true
ajax: source
aoColumnDefs: [
# Don't sort columns with class 'no-sort'

Drug Groups

Vitamin D - Several individual compounds is_a vitamin D Often referred to as a single compound, even by DPD/FDA

Prodrug

Fun times!
namespace :redis do
namespace :flush do
desc "Flushes all redis cached moldbi views"
task :moldbi do
on roles(:db) do
execute "redis-cli KEYS \"moldbi/*\" | xargs redis-cli DEL"
end
end
desc "Flushes all redis cached moldbi resources"
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
max_allowed_packet=500M
#
# include all files from the config directory
#