summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorch <ch@ch-test2>2015-08-18 16:37:09 +0200
committerch <ch@ch-test2>2015-08-18 16:37:09 +0200
commit4067d78c78c1f503b5f21d043ece8042260a3d78 (patch)
tree1bf9e2ead59676009a91058d8cd6c301f27549c8
parent4f622dd05299c3812286e11e8fce3e656e21ef29 (diff)
initial installation fixes, installs on Debian 3.16.7
-rw-r--r--ext/lazar/extconf.rb12
-rw-r--r--lazar.gemspec2
-rw-r--r--lib/compound.rb28
-rw-r--r--lib/lazar.rb7
-rw-r--r--mongoid.yml8
-rw-r--r--test/compound.rb2
6 files changed, 35 insertions, 24 deletions
diff --git a/ext/lazar/extconf.rb b/ext/lazar/extconf.rb
index 0c86985..d274c4d 100644
--- a/ext/lazar/extconf.rb
+++ b/ext/lazar/extconf.rb
@@ -28,11 +28,12 @@ Dir.chdir main_dir do
puts "Downloading OpenBabel sources"
system "git clone https://github.com/openbabel/openbabel.git"
end
+
FileUtils.mkdir_p build_dir
FileUtils.mkdir_p install_dir
Dir.chdir build_dir do
puts "Configuring OpenBabel"
- cmake = "cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DRUBY_BINDINGS=ON"
+ cmake = "cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DRUN_SWIG=ON -DRUBY_BINDINGS=ON"
# set rpath for local installations
# http://www.cmake.org/Wiki/CMake_RPATH_handling
# http://vtk.1045678.n5.nabble.com/How-to-force-cmake-not-to-remove-install-rpath-td5721193.html
@@ -55,19 +56,12 @@ ob_lib= File.expand_path "../../openbabel/lib"
# compile ruby bindings
puts "Compiling and installing OpenBabel Ruby bindings."
Dir.chdir ruby_src_dir do
- #p `pwd`
# fix rpath
system "sed -i 's|with_ldflags.*$|with_ldflags(\"#\$LDFLAGS -dynamic -Wl,-rpath,#{install_lib_dir}\") do|' #{File.join(ruby_src_dir,'extconf.rb')}"
system "#{RbConfig.ruby} extconf.rb --with-openbabel-include=#{ob_include} --with-openbabel-lib=#{ob_lib}"
system "make -j#{nr_processors}"
end
-#p(ruby_src_dir+"/openbabel.#{RbConfig::CONFIG["DLEXT"]}", "./")
-#FileUtils.cp(ruby_src_dir+"/openbabel.#{RbConfig::CONFIG["DLEXT"]}", "./")
-FileUtils.mkdir_p lib_dir
-FileUtils.mv "openbabel.#{RbConfig::CONFIG["DLEXT"]}", lib_dir
-#FileUtils.remove_entry_secure src_dir, build_dir
-
# install fminer
fminer_dir = File.join main_dir, "libfminer"
system "git clone git://github.com/amaunz/fminer2.git #{fminer_dir}"
@@ -86,5 +80,7 @@ end
# install last-utils
FileUtils.cd main_dir
system "git clone git://github.com/amaunz/last-utils.git"
+FileUtils.cd File.join(main_dir,"last-utils")
+`sed -i '8s/"openbabel", //' lu.rb`
# install R packagemain_dir
diff --git a/lazar.gemspec b/lazar.gemspec
index 8da29b7..6fe3f5b 100644
--- a/lazar.gemspec
+++ b/lazar.gemspec
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "bundler"
s.add_runtime_dependency "rest-client"
s.add_runtime_dependency 'nokogiri'
- s.add_runtime_dependency "openbabel"
+ #s.add_runtime_dependency "openbabel"
s.add_runtime_dependency 'rserve-client'
s.add_runtime_dependency "mongoid", '~> 5.0beta'
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'
diff --git a/mongoid.yml b/mongoid.yml
new file mode 100644
index 0000000..20b644b
--- /dev/null
+++ b/mongoid.yml
@@ -0,0 +1,8 @@
+development:
+ clients:
+ default:
+ database: opentox
+ hosts:
+ - localhost:27017
+ options:
+ raise_not_found_error: false
diff --git a/test/compound.rb b/test/compound.rb
index b45e3d0..40b9f9e 100644
--- a/test/compound.rb
+++ b/test/compound.rb
@@ -83,7 +83,7 @@ class CompoundTest < MiniTest::Test
end
def test_neighbors
- d = Dataset.from_csv_file "data/EPAFHM.csv"
+ d = Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.csv")
d.compounds.each do |c|
refute_nil c.fp4
end