Skip to content

Instantly share code, notes, and snippets.

View cknoxrun's full-sized avatar

Craig Knox cknoxrun

View GitHub Profile
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',
@cknoxrun
cknoxrun / gist:441276
Created June 16, 2010 21:12
A small module to download and convert PubMed citations to TextTile format.
require 'rubygems'
require 'bio'
module PubMed
# Download and annotate the given pubmed_id and return a citation in textile format.
# Example Citation:
# Smythe MA, Stephens JL, Koerber JM, Mattson JC: A comparison of lepirudin and argatroban outcomes.
# Clin Appl Thromb Hemost. 2005 Oct;11(4):371-4. "Pubmed":http://www.ncbi.nlm.nih.gov/pubmed/16244762
def PubMed.annotate(pubmed_id)
require 'zip/zip'
# Interface to the mutfinder library
class ReadAnalysis
@@nml_dir = File.join(Rails.root, 'lib', 'mutfinder')
@@result_dir = File.join(@@nml_dir, '/var/results/')
# Main entry point for analysis. Just pass an analysis ID
# (An object is not passed because this doesnt work with delayed_job)
def check_cas_number
# Check the CAS number for validity (the last number in a CAS number is a checksum)
if cas_number.present?
matches = cas_number.scan(/^(\d{1,7})-(\d{1,2})-(\d)$/)
if matches.first.blank? || matches.first.size != 3
self.errors.add(:cas_number, "format invalid")
else
match = matches.first
# 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

require 'zip/zipfilesystem'
require 'builder'
namespace :hmdb do
namespace :export do
DOWNLOAD_PATH = 'public/downloads'
desc "Run all export tasks"
task :all => [ :xml, :structures, :sequences ]
# desc 'Export all compounds to json format'