From 4067d78c78c1f503b5f21d043ece8042260a3d78 Mon Sep 17 00:00:00 2001 From: ch Date: Tue, 18 Aug 2015 16:37:09 +0200 Subject: initial installation fixes, installs on Debian 3.16.7 --- lib/compound.rb | 28 ++++++++++++++++------------ lib/lazar.rb | 7 +++++-- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/compound.rb b/lib/compound.rb index 10deabc..e51e9ad 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -62,7 +62,7 @@ module OpenTox # Temporary workaround for OpenBabels Inchi bug # http://sourceforge.net/p/openbabel/bugs/957/ # bug has not been fixed in latest git/development version - smiles = `echo "#{inchi}" | babel -iinchi - -ocan`.chomp.strip + smiles = `echo "#{inchi}" | "#{File.join(File.dirname(__FILE__),"..","openbabel","bin","babel")}" -iinchi - -ocan`.chomp.strip if smiles.empty? Compound.find_or_create_by(:warning => "InChi parsing failed for #{inchi}, this may be caused by an incorrect InChi string or a bug in OpenBabel libraries.") else @@ -91,7 +91,8 @@ module OpenTox # @return [String] InChI string def inchi unless self["inchi"] - result = `echo "#{self.smiles}" | babel -ismi - -oinchi`.chomp + + result = `echo "#{self.smiles}" | "#{File.join(File.dirname(__FILE__),"..","openbabel","bin","babel")}" -ismi - -oinchi`.chomp update(:inchi => result.chomp) unless result.empty? end self["inchi"] @@ -182,21 +183,23 @@ module OpenTox #reqbits = [count['_id'] for count in db.mfp_counts.find({'_id': {'$in': qfp}}).sort('count', 1).limit(qn - qmin + 1)] aggregate = [ #{'$match': {'mfp.count': {'$gte': qmin, '$lte': qmax}, 'mfp.bits': {'$in': reqbits}}}, - {'$match': {'_id': {'$ne': self.id}}}, # remove self - {'$project': { - 'tanimoto': {'$let': { - 'vars': {'common': {'$size': {'$setIntersection': ['$fp4', fp4]}}}, - 'in': {'$divide': ['$$common', {'$subtract': [{'$add': [qn, '$fp4_size']}, '$$common']}]} + {'$match' => {'_id' => {'$ne' => self.id}}}, # remove self + {'$project' => { + 'tanimoto' => {'$let' => { + 'vars' => {'common' => {'$size' => {'$setIntersection' => ['$fp4', fp4]}}}, + 'in' => {'$divide' => ['$$common', {'$subtract' => [{'$add' => [qn, '$fp4_size']}, '$$common']}]} }}, - '_id': 1 + '_id' => 1 }}, - {'$match': {'tanimoto': {'$gte': threshold}}}, - {'$sort': {'tanimoto': -1}} + {'$match' => {'tanimoto' => {'$gte' => threshold}}}, + {'$sort' => {'tanimoto' => -1}} ] $mongo["compounds"].aggregate(aggregate).collect{ |r| [r["_id"], r["tanimoto"]] } end +=begin +=end private @@ -210,11 +213,12 @@ module OpenTox when /smi|can|inchi/ obconversion.write_string(obmol).gsub(/\s/,'').chomp when /sdf/ - OpenBabel::OBOp.find_type("Gen3D").do(obmol) +# TODO set 3D + #OpenBabel::OBOp.find_type("Gen3D").do(obmol) sdf = obconversion.write_string(obmol) if sdf.match(/.nan/) $logger.warn "3D generation failed for compound #{identifier}, trying to calculate 2D structure" - OpenBabel::OBOp.find_type("Gen2D").do(obmol) + #OpenBabel::OBOp.find_type("Gen2D").do(obmol) sdf = obconversion.write_string(obmol) if sdf.match(/.nan/) $logger.warn "2D generation failed for compound #{identifier}" diff --git a/lib/lazar.rb b/lib/lazar.rb index 0c5e18b..9e2363c 100644 --- a/lib/lazar.rb +++ b/lib/lazar.rb @@ -14,7 +14,7 @@ require "base64" # TODO retrieve correct environment from Rack/Sinatra ENV["MONGOID_ENV"] ||= "development" # TODO remove config files, change default via ENV or directly in Mongoid class -Mongoid.load!("#{ENV['HOME']}/.opentox/config/mongoid.yml") +Mongoid.load!("#{File.expand_path(File.join(File.dirname(__FILE__),'..','mongoid.yml'))}") # TODO get Mongo::Client from Mongoid $mongo = Mongo::Client.new('mongodb://127.0.0.1:27017/opentox') # TODO same for GridFS @@ -31,10 +31,13 @@ Mongo::Logger.level = Logger::WARN #Mongoid.logger = $logger # Require sub-Repositories +# TODO: set +ENV["LD_LIBRARY_PATH"] = "#{File.join File.dirname(__FILE__),'..','openbabel','lib'}" +p ENV["LD_LIBRARY_PATH"] require_relative '../libfminer/libbbrc/bbrc' # include before openbabel require_relative '../libfminer/liblast/last' # require_relative '../last-utils/lu.rb' -require 'openbabel' +require_relative '../openbabel/lib/openbabel' # Fminer environment variables ENV['FMINER_SMARTS'] = 'true' -- cgit v1.2.3