This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def concentration_value(c) | |
unit = "" | |
conc = c.conc_value | |
mean = 0 | |
error = 0 | |
if (conc.nil?) | |
return "" | |
elsif(conc == "Detected") | |
mean = -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################## | |
# | |
# This class finds properties of a compound, given the SMILES string. | |
# For required programs, check the comments before each method. | |
# | |
# Written by Roman Eisner, 2010 | |
# | |
# Updated by Yannick Djoumbou | |
####################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
rescue_from ActiveRecord::RecordNotFound, :with => :render_404 | |
# Render 404: Not Found | |
def render_404(exception = nil) | |
logger.info( clean_backtrace(exception, "Rendering 404 due to exception") ) | |
if /(jpe?g|png|gif)/i === request.path | |
# Images should simply return the error as text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
module Uniprot | |
# Download and annotate the given uniprot_id and return an entry as an array | |
def Uniprot.annotate_name(uniprot_id) | |
doc = Nokogiri::XML( open("http://www.uniprot.org/uniprot/#{uniprot_id}.xml") ) | |
doc.remove_namespaces! | |
name_node = doc.at_xpath("//recommendedName/fullName") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
options = params | |
options[:page] ||= 1 | |
options[:limit] ||= 50 | |
@pathway_visualizations = | |
PathwayVisualization.search(load: true, page: options[:page], | |
per_page: options[:limit]) do |search| | |
if options[:term].present? | |
search.query do |query| |
OlderNewer