From 0e7f3c196b123acd9d311f02f09f8b03992cea5f Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 19 Jan 2010 10:02:09 +0100 Subject: move authorization to branch test --- lib/authorization.rb | 24 ++++++++++++++++++++++++ lib/dataset.rb | 9 +++++---- lib/environment.rb | 9 +++++++++ lib/model.rb | 4 ++-- lib/opentox-ruby-api-wrapper.rb | 2 +- lib/templates/users.yaml | 5 +++++ 6 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 lib/authorization.rb create mode 100644 lib/templates/users.yaml diff --git a/lib/authorization.rb b/lib/authorization.rb new file mode 100644 index 0000000..372d52b --- /dev/null +++ b/lib/authorization.rb @@ -0,0 +1,24 @@ +helpers do + + def protected! + response['WWW-Authenticate'] = %(Basic realm="Testing HTTP Auth") and \ + throw(:halt, [401, "Not authorized\n"]) and \ + return unless authorized? + end + + def authorized? + @auth ||= Rack::Auth::Basic::Request.new(request.env) + @auth.provided? && @auth.basic? && @auth.credentials && valid_user? + end + + def valid_user? + users = @@users[:users] + return @auth.credentials == [@auth.username, users.fetch(@auth.username)] if users.has_key?(@auth.username) + return false + end + +end + +before do + protected! unless env['REQUEST_METHOD'] == "GET" +end \ No newline at end of file diff --git a/lib/dataset.rb b/lib/dataset.rb index 8d1c0c1..f4372be 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -78,7 +78,7 @@ module OpenTox end def self.create(data, content_type = 'application/rdf+xml') - uri = RestClient.post @@config[:services]["opentox-dataset"], data, :content_type => content_type + uri = RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => request.username, :password => request.password).post data, :content_type => content_type dataset = Dataset.new dataset.read uri.to_s dataset @@ -168,11 +168,12 @@ module OpenTox # Delete a dataset def delete - RestClient.delete @uri - end + resource = RestClient::Resource.new(@uri, :user => request.username, :password => request.password) + resource.delete + end def save - RestClient.post(@@config[:services]["opentox-dataset"], self.rdf, :content_type => "application/rdf+xml").to_s + RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => request.username, :password => request.password).post(self.rdf, :content_type => "application/rdf+xml").to_s end def to_yaml diff --git a/lib/environment.rb b/lib/environment.rb index 6100928..f7513c5 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -6,6 +6,7 @@ basedir = File.join(ENV['HOME'], ".opentox") config_dir = File.join(basedir, "config") @@tmp_dir = File.join(basedir, "tmp") config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml") +user_file = File.join(config_dir, "users.yaml") if File.exist?(config_file) @@config = YAML.load_file(config_file) @@ -17,6 +18,14 @@ else exit end +if File.exist?(user_file) + @@users = YAML.load_file(user_file) +else + FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/users.yaml'), user_file) + puts "Please edit #{user_file} and restart your application." + exit +end + # RDF namespaces RDF = Redland::Namespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' OWL = Redland::Namespace.new 'http://www.w3.org/2002/07/owl#' diff --git a/lib/model.rb b/lib/model.rb index 24f6e52..b86b3fc 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -34,7 +34,7 @@ module OpenTox # Predict a compound def predict(compound) - RestClient.post(@uri, :compound_uri => compound.uri) + RestClient::Resource.new(@uri, :user => request.username, :password => request.password).post(:compound_uri => compound.uri) end def self.base_uri @@ -42,7 +42,7 @@ module OpenTox end def self.create(data) - RestClient.post(@@config[:services]["opentox-model"], data, :content_type => "application/x-yaml").to_s + RestClient::Resource.new(@@config[:services]["opentox-model"], :user => request.username, :password => request.password).post(data, :content_type => "application/x-yaml").to_s end def endpoint diff --git a/lib/opentox-ruby-api-wrapper.rb b/lib/opentox-ruby-api-wrapper.rb index ca57fc9..03838e8 100644 --- a/lib/opentox-ruby-api-wrapper.rb +++ b/lib/opentox-ruby-api-wrapper.rb @@ -8,6 +8,6 @@ rescue LoadError puts "Please install Openbabel with 'rake openbabel:install' in the compound component" end -['owl', 'compound','dataset','algorithm','model','task','utils'].each do |lib| +['owl', 'compound','dataset','algorithm','model','task','utils','authorization'].each do |lib| require lib end diff --git a/lib/templates/users.yaml b/lib/templates/users.yaml new file mode 100644 index 0000000..483fd7b --- /dev/null +++ b/lib/templates/users.yaml @@ -0,0 +1,5 @@ +# please insert users and passwords here. +# one user and password each line. uncomment the line. +:users: +# username: "secretpassword" +# exampleuser: "ih9aiTog" \ No newline at end of file -- cgit v1.2.3 From 33237fc34c933123a62bf7d85c824589dc12201c Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 19 Jan 2010 14:30:39 +0100 Subject: authorizaion --- lib/authorization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/authorization.rb b/lib/authorization.rb index 372d52b..6abbc91 100644 --- a/lib/authorization.rb +++ b/lib/authorization.rb @@ -20,5 +20,5 @@ helpers do end before do - protected! unless env['REQUEST_METHOD'] == "GET" + #protected! unless env['REQUEST_METHOD'] == "GET" end \ No newline at end of file -- cgit v1.2.3 From 4c2ac1a90b686b0e4bc361403770e0756bbfbdf9 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 19 Jan 2010 14:31:08 +0100 Subject: authorizaion --- .gitignore | 1 + lib/algorithm.rb | 6 ++++-- lib/task.rb | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 00c0b86..fedf1b5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ coverage rdoc pkg +*~ diff --git a/lib/algorithm.rb b/lib/algorithm.rb index c5d162a..6ae9e72 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -16,7 +16,8 @@ module OpenTox end def self.create_feature_dataset(params) - RestClient.post params[:feature_generation_uri], :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] + resource = RestClient::Resource.new(params[:feature_generation_uri], :user => request.username, :password => request.password) + resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] end end @@ -39,7 +40,8 @@ module OpenTox end def self.create_model(params) - @uri = RestClient.post File.join(@@config[:services]["opentox-algorithm"], "lazar"), :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") + resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => request.username, :password => request.password) + @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") end end diff --git a/lib/task.rb b/lib/task.rb index e50a982..5dd5e4c 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -10,7 +10,7 @@ module OpenTox end def self.create - uri = RestClient.post @@config[:services]["opentox-task"], nil + uri = RestClient::Resource.new(@@config[:services]["opentox-task"], :user => request.username, :password => request.password).post nil Task.new(uri) end @@ -24,15 +24,15 @@ module OpenTox def started #LOGGER.info File.join(@uri,'started') - RestClient.put File.join(@uri,'started'), {} + RestClient::Resource.new(@uri, :user => request.username, :password => request.password).put File.join(@uri,'started'), {} end def cancel - RestClient.put File.join(@uri,'cancelled'), {} + RestClient::Resource.new(@uri, :user => request.username, :password => request.password).put File.join(@uri,'cancelled'), {} end def completed(uri) - RestClient.put File.join(@uri,'completed'), :resource => uri + RestClient::Resource.new(@uri, :user => request.username, :password => request.password).put File.join(@uri,'completed'), :resource => uri end def status -- cgit v1.2.3 From a165822a7bd663916cff9484a76e6bb6bcf9a353 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 25 Jan 2010 09:29:21 +0100 Subject: internal authorization with first user of users.yaml --- lib/algorithm.rb | 112 ++++++++++++++++++++++++------------------------ lib/authorization.rb | 2 +- lib/dataset.rb | 7 +-- lib/environment.rb | 4 ++ lib/model.rb | 6 ++- lib/task.rb | 14 +++--- lib/templates/config.ru | 4 ++ 7 files changed, 82 insertions(+), 67 deletions(-) diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 6ae9e72..d5f85c7 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -1,66 +1,66 @@ module OpenTox - module Algorithm + module Algorithm - class Fminer - include Owl + class Fminer + include Owl - def initialize - super - self.uri = File.join(@@config[:services]["opentox-algorithm"],'fminer') - self.title = "fminer" - self.source = "http://github.com/amaunz/libfminer" - self.parameters = { - "Dataset URI" => { :scope => "mandatory", :value => "dataset_uri" }, - "Feature URI for dependent variable" => { :scope => "mandatory", :value => "feature_uri" } - } - end + def initialize + super + self.uri = File.join(@@config[:services]["opentox-algorithm"],'fminer') + self.title = "fminer" + self.source = "http://github.com/amaunz/libfminer" + self.parameters = { + "Dataset URI" => { :scope => "mandatory", :value => "dataset_uri" }, + "Feature URI for dependent variable" => { :scope => "mandatory", :value => "feature_uri" } + } + end - def self.create_feature_dataset(params) - resource = RestClient::Resource.new(params[:feature_generation_uri], :user => request.username, :password => request.password) - resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] - end - end + def self.create_feature_dataset(params) + resource = RestClient::Resource.new(params[:feature_generation_uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] + end + end - class Lazar - include Owl + class Lazar + include Owl - def initialize - super - self.uri = File.join(@@config[:services]["opentox-algorithm"],'lazar') - self.title = "lazar" - self.source = "http://github.com/helma/opentox-algorithm" - self.parameters = { - "Dataset URI" => - { :scope => "mandatory", :value => "dataset_uri" }, - "Feature URI for dependent variable" => - { :scope => "mandatory", :value => "feature_uri" }, - "Feature generation URI" => - { :scope => "mandatory", :value => "feature_generation_uri" } - } - end - - def self.create_model(params) - resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => request.username, :password => request.password) - @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") - end + def initialize + super + self.uri = File.join(@@config[:services]["opentox-algorithm"],'lazar') + self.title = "lazar" + self.source = "http://github.com/helma/opentox-algorithm" + self.parameters = { + "Dataset URI" => + { :scope => "mandatory", :value => "dataset_uri" }, + "Feature URI for dependent variable" => + { :scope => "mandatory", :value => "feature_uri" }, + "Feature generation URI" => + { :scope => "mandatory", :value => "feature_generation_uri" } + } + end + + def self.create_model(params) + resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") + end - end + end - class Similarity - def self.weighted_tanimoto(fp_a,fp_b,p) - common_features = fp_a & fp_b - all_features = fp_a + fp_b - common_p_sum = 0.0 - if common_features.size > 0 - common_features.each{|f| common_p_sum += p[f]} - all_p_sum = 0.0 - all_features.each{|f| all_p_sum += p[f]} - common_p_sum/all_p_sum - else - 0.0 - end - end - end + class Similarity + def self.weighted_tanimoto(fp_a,fp_b,p) + common_features = fp_a & fp_b + all_features = fp_a + fp_b + common_p_sum = 0.0 + if common_features.size > 0 + common_features.each{|f| common_p_sum += p[f]} + all_p_sum = 0.0 + all_features.each{|f| all_p_sum += p[f]} + common_p_sum/all_p_sum + else + 0.0 + end + end + end - end + end end diff --git a/lib/authorization.rb b/lib/authorization.rb index 6abbc91..372d52b 100644 --- a/lib/authorization.rb +++ b/lib/authorization.rb @@ -20,5 +20,5 @@ helpers do end before do - #protected! unless env['REQUEST_METHOD'] == "GET" + protected! unless env['REQUEST_METHOD'] == "GET" end \ No newline at end of file diff --git a/lib/dataset.rb b/lib/dataset.rb index f4372be..1aa3469 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -78,7 +78,8 @@ module OpenTox end def self.create(data, content_type = 'application/rdf+xml') - uri = RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => request.username, :password => request.password).post data, :content_type => content_type + resource = RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + uri = resource.post data, :content_type => content_type dataset = Dataset.new dataset.read uri.to_s dataset @@ -168,12 +169,12 @@ module OpenTox # Delete a dataset def delete - resource = RestClient::Resource.new(@uri, :user => request.username, :password => request.password) + resource = RestClient::Resource.new(@uri, :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) resource.delete end def save - RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => request.username, :password => request.password).post(self.rdf, :content_type => "application/rdf+xml").to_s + RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]).post(self.rdf, :content_type => "application/rdf+xml").to_s end def to_yaml diff --git a/lib/environment.rb b/lib/environment.rb index f7513c5..ee36366 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -25,6 +25,10 @@ else puts "Please edit #{user_file} and restart your application." exit end +if @@users.length < 1 or !@@users + puts "Please edit #{user_file} and restart your application." + exit +end # RDF namespaces RDF = Redland::Namespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' diff --git a/lib/model.rb b/lib/model.rb index b86b3fc..6bdbfd2 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -34,7 +34,8 @@ module OpenTox # Predict a compound def predict(compound) - RestClient::Resource.new(@uri, :user => request.username, :password => request.password).post(:compound_uri => compound.uri) + resource = RestClient::Resource.new(@uri, :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.post(:compound_uri => compound.uri) end def self.base_uri @@ -42,7 +43,8 @@ module OpenTox end def self.create(data) - RestClient::Resource.new(@@config[:services]["opentox-model"], :user => request.username, :password => request.password).post(data, :content_type => "application/x-yaml").to_s + resource = RestClient::Resource.new(@@config[:services]["opentox-model"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.post(data, :content_type => "application/x-yaml").to_s end def endpoint diff --git a/lib/task.rb b/lib/task.rb index 5dd5e4c..23795dc 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -10,7 +10,8 @@ module OpenTox end def self.create - uri = RestClient::Resource.new(@@config[:services]["opentox-task"], :user => request.username, :password => request.password).post nil + resource = RestClient::Resource.new(@@config[:services]["opentox-task"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + uri = resource.post(nil) Task.new(uri) end @@ -23,16 +24,19 @@ module OpenTox end def started - #LOGGER.info File.join(@uri,'started') - RestClient::Resource.new(@uri, :user => request.username, :password => request.password).put File.join(@uri,'started'), {} + LOGGER.info File.join(@uri,'started') + resource = RestClient::Resource.new(File.join(@uri,'started'), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.put({}) end def cancel - RestClient::Resource.new(@uri, :user => request.username, :password => request.password).put File.join(@uri,'cancelled'), {} + resource = RestClient::Resource.new(@File.join(@uri,'cancelled'), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.put({}) end def completed(uri) - RestClient::Resource.new(@uri, :user => request.username, :password => request.password).put File.join(@uri,'completed'), :resource => uri + resource = RestClient::Resource.new(File.join(@uri,'completed'), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.put :resource => uri end def status diff --git a/lib/templates/config.ru b/lib/templates/config.ru index 63dd2ce..ffccbc1 100644 --- a/lib/templates/config.ru +++ b/lib/templates/config.ru @@ -8,6 +8,9 @@ FileUtils.mkdir_p 'log' unless File.exists?('log') log = File.new("log/#{ENV["RACK_ENV"]}.log", "a") $stdout.reopen(log) $stderr.reopen(log) +$stdout.sync = true +$stderr.sync = true + if ENV['RACK_ENV'] == 'production' use Rack::MailExceptions do |mail| @@ -21,3 +24,4 @@ end run Sinatra::Application +set :raise_errors, true \ No newline at end of file -- cgit v1.2.3 From 2187b121ddb95a6ef5de59ac1c72427b4294d9be Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 25 Jan 2010 15:24:31 +0100 Subject: ensure that minimum 1 user is in users.yaml --- lib/environment.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/environment.rb b/lib/environment.rb index ee36366..354190c 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -25,8 +25,11 @@ else puts "Please edit #{user_file} and restart your application." exit end -if @@users.length < 1 or !@@users - puts "Please edit #{user_file} and restart your application." + +begin + 0 < @@users[:users].keys.length +rescue + puts "Please edit #{user_file} and restart your application. Create at least one user with password." exit end -- cgit v1.2.3 From 492f73257e6c87d84e4b25c49e4a392859d59b1c Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 26 Jan 2010 12:16:59 +0100 Subject: set 'Basic realm' to Opentox Ruby API Wrapper Auth --- lib/authorization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/authorization.rb b/lib/authorization.rb index 372d52b..4e4abe2 100644 --- a/lib/authorization.rb +++ b/lib/authorization.rb @@ -1,7 +1,7 @@ helpers do def protected! - response['WWW-Authenticate'] = %(Basic realm="Testing HTTP Auth") and \ + response['WWW-Authenticate'] = %(Basic realm="Opentox Ruby API Wrapper Auth") and \ throw(:halt, [401, "Not authorized\n"]) and \ return unless authorized? end -- cgit v1.2.3 From 6626ea9e65b09f4c5f3c85556157f42c53e99fea Mon Sep 17 00:00:00 2001 From: David Vorgrimmler Date: Tue, 2 Feb 2010 13:12:08 +0100 Subject: New install-script(tested on Ubuntu 9.10/8.10) --- bin/opentox-install-ubuntu.sh | 363 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 363 insertions(+) create mode 100755 bin/opentox-install-ubuntu.sh diff --git a/bin/opentox-install-ubuntu.sh b/bin/opentox-install-ubuntu.sh new file mode 100755 index 0000000..e038c17 --- /dev/null +++ b/bin/opentox-install-ubuntu.sh @@ -0,0 +1,363 @@ +#!/bin/bash +#Installation is tested on Debian Ubuntu 9.10 +#Update the system + +FAILED=0 +STARTPATH=$PWD +ERRLOG=$PWD/'install_err.log' +INSTALLLOG=$PWD/'install_log.log' +DATE=$(date +%Y/%m/%d\ %H:%M:%S) +BRANCH=$1 +GEMVERSION="1.3.5" +GITVERSION="1.6.5.2" +RAPTORVERSION="1.4.20" +RASQALVERSION="0.9.16" +RASQALVERSION2="0.9.15" +REDLANDVERSION="1.0.7" +REDBINDVERSION="1.0.7.1" + +if [ "$BRANCH" = '' ] +then + echo "Please enter: sudo ./[filename] [brunchtpy]" + exit 1 +fi +echo "=================================================" +echo "Selected branch is: $BRANCH" +echo "=================================================" +echo "Please enshure that the sudo package is installed" +echo "on your system. " +echo "On Ubuntu Linux sudo is installed by default." +echo "If you are unsure check with it 'sudo ls'" +echo "and installed it with 'apt-get install sudo'" +echo "and add your username with visudo." +echo "=================================================" +echo "Some programs and the OpenTox webservices will be installed in the current folder." +echo "=================================================" +echo -n "To continue installation press y: " +read answer +if [ "$answer" != "y" ] +then + echo "exiting the script..." + exit 1 +fi + +echo "opentox webservice install log - " $DATE > $INSTALLLOG +echo "opentox webservice install err log - " $DATE > $ERRLOG +echo "Installing: build-essential" +sudo apt-get install build-essential | tee -a $INSTALLLOG + +echo "Installing: ruby 1.8 with its dev files" +sudo apt-get install ruby ruby1.8-dev | tee -a $INSTALLLOG + +echo "Installing: gems rdoc rubygems libxml-parser-ruby1.8 libxml++2.6-dev libyaml-ruby libzlib-ruby sqlite3 libsqlite3-dev libsqlite3-ruby1.8 and rake" +sudo apt-get install gems rdoc rubygems libxml-parser-ruby1.8 libxml++2.6-dev libyaml-ruby libzlib-ruby rake sqlite3 libsqlite3-dev libsqlite3-ruby1.8 | tee -a $INSTALLLOG + +#RUBYGEMS +echo "Installing rubygems from source. This may take some time" +if [ ! -d $STARTPATH/rubygems-$GEMVERSION ]; +then + wget http://rubyforge.org/frs/download.php/60718/rubygems-$GEMVERSION.tgz >>$INSTALLLOG 2>>$ERRLOG + tar xzfv rubygems-$GEMVERSION.tgz >>$INSTALLLOG 2>>$ERRLOG + cd rubygems-$GEMVERSION + sudo ruby setup.rb >>$INSTALLLOG 2>>$ERRLOG + cd .. + sudo rm rubygems-$GEMVERSION.tgz + CHECKGEM=`gem -v` + if [ "$CHECKGEM" == "$GEMVERSION" ] + then + echo "Adding http://gems.github.com to ruby gem sources" + sudo gem sources -a http://gems.github.com >>$INSTALLLOG 2>>$ERRLOG + + echo "=================================================" + echo "Rubygems version $GEMVERSION successfully installed." + echo "=================================================" + else + echo "Rubygems version $GEMVERSION installation failed." + FAILED=1 + fi +else + echo "rubygems-$GEMVERSION folder already exist. " +fi + +echo "Installing packages: zlib1g-dev tcl curl perl ssh tcl tk8.5 libopenssl-ruby libgsl0-dev swig r-base rinruby" +sudo apt-get install zlib1g-dev tcl curl perl libopenssl-ruby libgsl0-dev r-base | tee -a $INSTALLLOG +sudo apt-get install ssh tcl tk8.5 | tee -a $INSTALLLOG +sudo apt-get install swig | tee -a $INSTALLLOG + +#echo "Installing gems jeweler sinatra emk-sinatra-url-for dm-core cehoffman-sinatra-respond_to rest-client rack-contrib thin cucumber datamapper data_objects do_sqlite3 rinruby" +#sudo gem install jeweler | tee -a $INSTALLLOG +#sudo gem install sinatra | tee -a $INSTALLLOG +#sudo gem install emk-sinatra-url-for -s http://gems.github.com | tee -a $INSTALLLOG +#sudo gem install dm-core | tee -a $INSTALLLOG +#sudo gem install cehoffman-sinatra-respond_to -s http://gems.github.com | tee -a $INSTALLLOG +#sudo gem install rest-client | tee -a $INSTALLLOG +#sudo gem install rack-contrib | tee -a $INSTALLLOG +#sudo gem install thin | tee -a $INSTALLLOG +#sudo gem install cucumber | tee -a $INSTALLLOG +#sudo gem install datamapper | tee -a $INSTALLLOG +#sudo gem install data_objects | tee -a $INSTALLLOG +#sudo gem install do_sqlite3 | tee -a $INSTALLLOG +#sudo gem install rinruby | tee -a $INSTALLLOG +#sudo gem cleanup | tee -a $INSTALLLOG + +echo "Installing LibRDF-ruby" +sudo apt-get install librdf0 librdf-ruby | tee -a $INSTALLLOG + +#GIT +echo "Installing git from source" +echo "This could take a while..." +if [ ! -d $STARTPATH/git-$GITVERSION ]; +then + wget http://www.kernel.org/pub/software/scm/git/git-$GITVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + tar xzfv git-$GITVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + cd git-$GITVERSION + ./configure >>$INSTALLLOG 2>>$ERRLOG + make >>$INSTALLLOG 2>>$ERRLOG + sudo make install >>$INSTALLLOG 2>>$ERRLOG + cd .. + sudo rm git-$GITVERSION.tar.gz + CHECKGIT=`git --version` + if [ "$CHECKGIT" == "git version $GITVERSION" ] + then + echo "=================================================" + echo "Git version $GITVERSION successfully installed." + echo "=================================================" + else + echo "Git version $GITVERSION installation failed." + FAILED=1 + fi +else + echo "git-$GITVERSION folder exists." +fi + +#REDLAND +if [ ! -d $STARTPATH/redland ]; +then + echo "Making Redland folder." + mkdir redland >>$INSTALLLOG 2>>$ERRLOG + cd redland + echo "Installing Redland raptor" + if [ ! -d $STARTPATH/redland/raptor-$RAPTORVERSION ]; + then + wget wget http://download.librdf.org/source/raptor-$RAPTORVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + tar xzfv raptor-$RAPTORVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + cd raptor-$RAPTORVERSION + ./configure >>$INSTALLLOG 2>>$ERRLOG + sudo make >>$INSTALLLOG 2>>$ERRLOG + sudo make install >>$INSTALLLOG 2>>$ERRLOG + cd .. + sudo rm raptor-$RAPTORVERSION.tar.gz + CHECKRAPTOR=`raptor-config --version` + if [ "$CHECKRAPTOR" == "$RAPTORVERSION" ] + then + echo "=================================================" + echo "Raptor version $RAPTORVERSION successfully installed." + echo "=================================================" + else + echo "Raptor version $RAPTORVERSION installation failed." + FAILED=1 + fi + else + echo "raptor-$RAPTORVERSION folder exists." + fi + + echo "Installing Redland rasqal" + wget wget http://download.librdf.org/source/rasqal-$RASQALVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + tar xzfv rasqal-$RASQALVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + cd rasqal-$RASQALVERSION + ./configure >>$INSTALLLOG 2>>$ERRLOG + sudo make >>$INSTALLLOG 2>>$ERRLOG + sudo make install >>$INSTALLLOG 2>>$ERRLOG + cd .. + sudo rm rasqal-$RASQALVERSION.tar.gz + CHECKRASQAL=`rasqal-config --version` + if [ "$CHECKRASQAL" == "$RASQALVERSION2" -o "$CHECKRASQAL" == "$RASQALVERSION" ] + then + echo "=================================================" + echo "Raptor version $RASQALVERSION2 or higher successfully installed." + echo "=================================================" + else + echo "Raptor version $RASQALVERSION2 or higher installation failed." + FAILED=1 + fi + + echo "Installing Redland redland" + wget wget http://download.librdf.org/source/redland-$REDLANDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + tar xzfv redland-$REDLANDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + cd redland-$REDLANDVERSION + ./configure >>$INSTALLLOG 2>>$ERRLOG + sudo make >>$INSTALLLOG 2>>$ERRLOG + sudo make install >>$INSTALLLOG 2>>$ERRLOG + cd .. + sudo rm redland-$REDLANDVERSION.tar.gz + CHECKREDLAND=`redland-config --version` + if [ "$CHECKREDLAND" == "$REDLANDVERSION" ] + then + echo "=================================================" + echo "Redland version $REDLANDVERSION successfully installed." + echo "=================================================" + else + echo "Redland version $REDLANDVERSION installation failed." + FAILED=1 + fi + + + echo "Installing Redland Bindings with ruby" + wget http://download.librdf.org/source/redland-bindings-$REDBINDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + tar xzfv redland-bindings-$REDBINDVERSION.tar.gz >>$INSTALLLOG 2>>$ERRLOG + cd redland-bindings-$REDBINDVERSION + ./configure --with-ruby >>$INSTALLLOG 2>>$ERRLOG + sudo make >>$INSTALLLOG 2>>$ERRLOG + sudo make install >>$INSTALLLOG 2>>$ERRLOG + cd .. + sudo rm redland-bindings-$REDBINDVERSION.tar.gz + cd .. + #CHECKREDBIND=`??? --version` + #if [ "$CHECKREDBIND" == "$REDBINDVERSION" ] + #then + # echo "=================================================" + # echo "Redland Bindings version $REDBINDVERSION successfully installed." + # echo "=================================================" + #else + # echo "Redland Bindings version $REDBINDVERSION installation failed." + # FAILED=1 + #fi +else + echo "Redland folder exists." +fi + +echo "Installing the opentox webservices" +mkdir webservices +cd webservices + +echo "Install the opentox-ruby-api-wrapper" +echo "This could take a while..." +git clone git://github.com/helma/opentox-ruby-api-wrapper.git >>$INSTALLLOG 2>>$ERRLOG +cd opentox-ruby-api-wrapper +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG +OTAPIVERSION=`cat VERSION` +sudo rake install | tee -a $INSTALLLOG +cd .. +CHECKOTAPI=`gem list | grep "opentox-ruby-api-wrapper" | grep "$OTAPIVERSION"` +if [ ! "$CHECKOTAPI" = '' ] +then + echo "=================================================" + echo "opentox-ruby-api-wrapper ($OTAPIVERSION) successfully installed." + echo "=================================================" +else + echo "opentox-ruby-api-wrapper ($OTAPIVERSION) installation failed." + FAILED=1 +fi + +echo "Installing the webservices: compound, dataset, algorithm, model, task, feature" +git clone git://github.com/helma/opentox-compound.git >>$INSTALLLOG 2>>$ERRLOG +git clone git://github.com/helma/opentox-dataset.git >>$INSTALLLOG 2>>$ERRLOG +# opentox-algorithem only temporally from davor! +git clone git://github.com/davor/opentox-algorithm.git >>$INSTALLLOG 2>>$ERRLOG +git clone git://github.com/helma/opentox-model.git >>$INSTALLLOG 2>>$ERRLOG +git clone git://github.com/helma/opentox-task.git >>$INSTALLLOG 2>>$ERRLOG +git clone git://github.com/helma/opentox-feature.git >>$INSTALLLOG 2>>$ERRLOG + +cd opentox-compound +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG +cd ../opentox-dataset +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG +cd ../opentox-algorithm +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG +cd ../opentox-model +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG +cd ../opentox-task +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG +cd ../opentox-task +git checkout -b development origin/development >>$INSTALLLOG 2>>$ERRLOG +cd .. + +#edit /home/[username]/.opentox/config/test.yaml set :base_dir: /home/[username]/webservices + +echo "Installing the tests" +git clone git://github.com/helma/opentox-test.git >>$INSTALLLOG 2>>$ERRLOG +cd opentox-test +git checkout -b $BRANCH origin/$BRANCH >>$INSTALLLOG 2>>$ERRLOG + +echo "Installing openbabel" +cd ../opentox-compound +sudo rake openbabel:install | tee -a $INSTALLLOG +sudo ldconfig >>$INSTALLLOG 2>>$ERRLOG +#VERSION=` --version` +#if [ "$VERSION" == "$RAPTORVERSION" ] +#then +# echo "=================================================" +# echo "Raptor version $RAPTORVERSION successfully installed." +# echo "=================================================" +#else +# echo "Raptor version $RAPTORVERSION installation failed." +# FAILED=1 +#fi + + +#check /webservices/opentox-algorithm/fminer.rb for 1,0/ture,false bug +BUGCHECK1=`grep "@@fminer.AddActivity(true, id)" $STARTPATH/webservices/opentox-algorithm/fminer.rb` +BUGCHECK2=`grep "@@fminer.AddActivity(false, id)" $STARTPATH/webservices/opentox-algorithm/fminer.rb` +if [ -z "$BUGCHECK1$BUGCHECK2" ] +then + echo "fminer.rb is correct." +else + sed -i 's/@@fminer.AddActivity(true, id)/@@fminer.AddActivity(1, id)/g' $STARTPATH/webservices/opentox-algorithm/fminer.rb + sed -i 's/@@fminer.AddActivity(false, id)/@@fminer.AddActivity(0, id)/g' $STARTPATH/webservices/opentox-algorithm/fminer.rb + echo "fminer.rb updated." +fi + +#todo: configure libfminer Makefile (location of ruby.h) +#-> fixed by using davor's repository + + +cd ../opentox-algorithm +echo "Installing fminer" +echo "This could take a while..." +sudo updatedb +sudo rake fminer:install | tee -a $INSTALLLOG +cd .. +FMINERVERSION=`ls $STARTPATH/webservices/opentox-algorithm/libfminer | grep "fminer.so"` +if [ "$FMINERVERSION" == "fminer.so" ] +then + echo "=================================================" + echo "Fminer successfully installed." + echo "=================================================" +else + echo "Fminer installation failed." + FAILED=1 +fi + +if [ $FAILED == 0 ] +then + #get username + echo "Please enter username:" + read USERNAME + + #change rights from root to user + sudo chown -R $USERNAME: $STARTPATH/webservices/ + sudo chown -R $USERNAME: ~/.opentox/ +fi + +if [ "$FAILED" == "1" ] +then + echo "=================================================" + echo "Installation script failed!" + echo "=================================================" + exit 1 +else +echo "=================================================" +echo "opentox-install-script is completed." +echo "=================================================" +echo "Configuration:" +echo "Edit the settings in $HOME/.opentox/config/{development|production|test}.yaml for your environment." +echo "=================================================" +echo "Start the webservices local:" +echo "cd webservices/opentox-test/" +echo "rake opentox:services:start" +echo "=================================================" +echo "Test local webservices:" +echo "rake features" +echo "=================================================" +fi +exit 0 -- cgit v1.2.3 From 61afba520203c613eb17bb6e6e57d33e4cfb1dca Mon Sep 17 00:00:00 2001 From: David Vorgrimmler Date: Tue, 2 Feb 2010 14:21:02 +0100 Subject: Added postgresql-server-dev-8.2 --- bin/opentox-install-ubuntu.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/bin/opentox-install-ubuntu.sh b/bin/opentox-install-ubuntu.sh index e038c17..f512b71 100755 --- a/bin/opentox-install-ubuntu.sh +++ b/bin/opentox-install-ubuntu.sh @@ -83,22 +83,24 @@ echo "Installing packages: zlib1g-dev tcl curl perl ssh tcl tk8.5 libopenssl-rub sudo apt-get install zlib1g-dev tcl curl perl libopenssl-ruby libgsl0-dev r-base | tee -a $INSTALLLOG sudo apt-get install ssh tcl tk8.5 | tee -a $INSTALLLOG sudo apt-get install swig | tee -a $INSTALLLOG +apt-get install postgresql-server-dev-8.2 | tee -a $INSTALLLOG + #echo "Installing gems jeweler sinatra emk-sinatra-url-for dm-core cehoffman-sinatra-respond_to rest-client rack-contrib thin cucumber datamapper data_objects do_sqlite3 rinruby" -#sudo gem install jeweler | tee -a $INSTALLLOG -#sudo gem install sinatra | tee -a $INSTALLLOG -#sudo gem install emk-sinatra-url-for -s http://gems.github.com | tee -a $INSTALLLOG -#sudo gem install dm-core | tee -a $INSTALLLOG -#sudo gem install cehoffman-sinatra-respond_to -s http://gems.github.com | tee -a $INSTALLLOG -#sudo gem install rest-client | tee -a $INSTALLLOG -#sudo gem install rack-contrib | tee -a $INSTALLLOG -#sudo gem install thin | tee -a $INSTALLLOG -#sudo gem install cucumber | tee -a $INSTALLLOG -#sudo gem install datamapper | tee -a $INSTALLLOG -#sudo gem install data_objects | tee -a $INSTALLLOG -#sudo gem install do_sqlite3 | tee -a $INSTALLLOG -#sudo gem install rinruby | tee -a $INSTALLLOG -#sudo gem cleanup | tee -a $INSTALLLOG +sudo gem install jeweler | tee -a $INSTALLLOG +sudo gem install sinatra | tee -a $INSTALLLOG +sudo gem install emk-sinatra-url-for -s http://gems.github.com | tee -a $INSTALLLOG +sudo gem install dm-core | tee -a $INSTALLLOG +sudo gem install cehoffman-sinatra-respond_to -s http://gems.github.com | tee -a $INSTALLLOG +sudo gem install rest-client | tee -a $INSTALLLOG +sudo gem install rack-contrib | tee -a $INSTALLLOG +sudo gem install thin | tee -a $INSTALLLOG +sudo gem install cucumber | tee -a $INSTALLLOG +sudo gem install datamapper | tee -a $INSTALLLOG +sudo gem install data_objects | tee -a $INSTALLLOG +sudo gem install do_sqlite3 | tee -a $INSTALLLOG +sudo gem install rinruby | tee -a $INSTALLLOG +sudo gem cleanup | tee -a $INSTALLLOG echo "Installing LibRDF-ruby" sudo apt-get install librdf0 librdf-ruby | tee -a $INSTALLLOG -- cgit v1.2.3 From 1ed45e8676b1a2c183fc426afe3d22f63787ddcd Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 2 Feb 2010 17:37:08 +0100 Subject: lib/task --- lib/task.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/task.rb b/lib/task.rb index 8f44dc6..779b87c 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -61,7 +61,8 @@ module OpenTox end def pid=(pid) - RestClient.put File.join(@uri, 'pid'), :pid => pid + resource = RestClient::Resource.new(File.join(@uri,'pid'), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.put :pid => pid end def completed? -- cgit v1.2.3 From 53d755065500701a46b2a3754dc1299febe79c43 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 3 Feb 2010 15:34:46 +0100 Subject: change Basic realm text for http authentication --- lib/authorization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/authorization.rb b/lib/authorization.rb index 4e4abe2..7cb548e 100644 --- a/lib/authorization.rb +++ b/lib/authorization.rb @@ -1,7 +1,7 @@ helpers do def protected! - response['WWW-Authenticate'] = %(Basic realm="Opentox Ruby API Wrapper Auth") and \ + response['WWW-Authenticate'] = %(Basic realm="Opentox Webservice Authentication") and \ throw(:halt, [401, "Not authorized\n"]) and \ return unless authorized? end -- cgit v1.2.3 From 6ab4b3f02b11e2d3d605d547e841b5469170832f Mon Sep 17 00:00:00 2001 From: David Vorgrimmler Date: Mon, 8 Feb 2010 15:11:45 +0100 Subject: Updating ubuntu script. --- bin/opentox-install-ubuntu.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/opentox-install-ubuntu.sh b/bin/opentox-install-ubuntu.sh index f512b71..b27f9f9 100755 --- a/bin/opentox-install-ubuntu.sh +++ b/bin/opentox-install-ubuntu.sh @@ -74,6 +74,7 @@ then else echo "Rubygems version $GEMVERSION installation failed." FAILED=1 + exit $FAILED fi else echo "rubygems-$GEMVERSION folder already exist. " @@ -83,7 +84,7 @@ echo "Installing packages: zlib1g-dev tcl curl perl ssh tcl tk8.5 libopenssl-rub sudo apt-get install zlib1g-dev tcl curl perl libopenssl-ruby libgsl0-dev r-base | tee -a $INSTALLLOG sudo apt-get install ssh tcl tk8.5 | tee -a $INSTALLLOG sudo apt-get install swig | tee -a $INSTALLLOG -apt-get install postgresql-server-dev-8.2 | tee -a $INSTALLLOG +sudo apt-get install postgresql-server-dev-8.4 | tee -a $INSTALLLOG #echo "Installing gems jeweler sinatra emk-sinatra-url-for dm-core cehoffman-sinatra-respond_to rest-client rack-contrib thin cucumber datamapper data_objects do_sqlite3 rinruby" @@ -127,6 +128,7 @@ then else echo "Git version $GITVERSION installation failed." FAILED=1 + exit $FAILED fi else echo "git-$GITVERSION folder exists." @@ -158,6 +160,7 @@ then else echo "Raptor version $RAPTORVERSION installation failed." FAILED=1 + exit $FAILED fi else echo "raptor-$RAPTORVERSION folder exists." @@ -181,6 +184,7 @@ then else echo "Raptor version $RASQALVERSION2 or higher installation failed." FAILED=1 + exit $FAILED fi echo "Installing Redland redland" @@ -201,6 +205,7 @@ then else echo "Redland version $REDLANDVERSION installation failed." FAILED=1 + exit $FAILED fi @@ -223,6 +228,7 @@ then #else # echo "Redland Bindings version $REDBINDVERSION installation failed." # FAILED=1 + # exit $FAILED #fi else echo "Redland folder exists." @@ -249,6 +255,7 @@ then else echo "opentox-ruby-api-wrapper ($OTAPIVERSION) installation failed." FAILED=1 + exit $FAILED fi echo "Installing the webservices: compound, dataset, algorithm, model, task, feature" @@ -285,6 +292,8 @@ echo "Installing openbabel" cd ../opentox-compound sudo rake openbabel:install | tee -a $INSTALLLOG sudo ldconfig >>$INSTALLLOG 2>>$ERRLOG + +ln -s /usr/local/lib/libopenbabel.so.3 /usr/lib/libopenbabel.so.3 >> $INSTALLLOG 2>>$ERR #VERSION=` --version` #if [ "$VERSION" == "$RAPTORVERSION" ] #then @@ -294,6 +303,7 @@ sudo ldconfig >>$INSTALLLOG 2>>$ERRLOG #else # echo "Raptor version $RAPTORVERSION installation failed." # FAILED=1 +# exit $FAILED #fi @@ -328,6 +338,7 @@ then else echo "Fminer installation failed." FAILED=1 + exit $FAILED fi if [ $FAILED == 0 ] -- cgit v1.2.3 From 62d4979cb96ca8243a6915c6fa1c3b317a41b041 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 8 Feb 2010 17:41:53 +0100 Subject: jeweler development dependency added --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index e585ca6..ffe1f61 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,9 @@ begin ["sinatra", "rest-client", "rack", "rack-contrib", "rack-flash", "thin", "emk-sinatra-url-for", "cehoffman-sinatra-respond_to", "dm-more", "dm-core", "sinatra-static-assets", "do_sqlite3", "do_postgres"].each do |dep| gem.add_dependency dep end - gem.add_development_dependency "cucumber" + ['cucmber','jeweler'].each do |dep| + gem.add_development_dependency dep + end gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore'] gem.files.include %w(lib/tasks/owl.rb, lib/environment.rb, lib/algorithm.rb, lib/compound.rb, lib/dataset.rb, lib/model.rb, lib/utils.rb, lib/templates/*) # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings -- cgit v1.2.3 From 9b136b483eb826bc25fb60d4e33b1e8128a85559 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 8 Feb 2010 18:03:36 +0100 Subject: data_objects requirements removed --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index ffe1f61..102160f 100644 --- a/Rakefile +++ b/Rakefile @@ -10,7 +10,7 @@ begin gem.email = "helma@in-silico.ch" gem.homepage = "http://github.com/helma/opentox-ruby-api-wrapper" gem.authors = ["Christoph Helma"] - ["sinatra", "rest-client", "rack", "rack-contrib", "rack-flash", "thin", "emk-sinatra-url-for", "cehoffman-sinatra-respond_to", "dm-more", "dm-core", "sinatra-static-assets", "do_sqlite3", "do_postgres"].each do |dep| + ["sinatra", "rest-client", "rack", "rack-contrib", "rack-flash", "thin", "emk-sinatra-url-for", "cehoffman-sinatra-respond_to", "dm-more", "dm-core", "sinatra-static-assets"].each do |dep| gem.add_dependency dep end ['cucmber','jeweler'].each do |dep| -- cgit v1.2.3 From 63172223d1aeadd38850c85de668d1b1b333ceb0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 9 Feb 2010 12:09:30 +0100 Subject: Dataset service with tasks --- lib/config/config_ru.rb | 1 + lib/dataset.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/config/config_ru.rb b/lib/config/config_ru.rb index 3720ef3..1d32c7e 100644 --- a/lib/config/config_ru.rb +++ b/lib/config/config_ru.rb @@ -10,6 +10,7 @@ $stdout.reopen(log) $stderr.reopen(log) $stdout.sync = true $stderr.sync = true +set :logging, false set :raise_errors, true ['public','tmp'].each do |dir| diff --git a/lib/dataset.rb b/lib/dataset.rb index bd523a3..19572f6 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -156,7 +156,18 @@ module OpenTox end def save - RestClient.post(@@config[:services]["opentox-dataset"], self.rdf, :content_type => "application/rdf+xml").to_s + LOGGER.debug "Saving dataset" + task_uri = RestClient.post(@@config[:services]["opentox-dataset"], self.rdf, :content_type => "application/rdf+xml").to_s + task = OpenTox::Task.find(task_uri) + LOGGER.debug "Waiting for task #{task_uri}" + task.wait_for_completion + LOGGER.debug "Dataset task #{task_uri} completed" + if task.failed? + LOGGER.error "Saving dataset failed" + task.failed + exit + end + task.resource end def to_yaml -- cgit v1.2.3 From e3b3717024d644f17a52f5a49b6b145e53fee503 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 9 Feb 2010 15:56:20 +0100 Subject: Debug messages for Dataset.find --- lib/dataset.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dataset.rb b/lib/dataset.rb index 19572f6..3971537 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -86,7 +86,9 @@ module OpenTox def self.find(uri) dataset = Dataset.new + LOGGER.debug "Getting data from #{uri}" data = `curl "#{uri}"` + LOGGER.debug data #data = RestClient.get(uri, :accept => 'application/rdf+xml') # unclear why this does not work for complex uris, Dataset.find works from irb dataset.rdf = data dataset -- cgit v1.2.3 From 658a73f4648f179f4f9073e0011e71085ee3e733 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 10 Feb 2010 11:01:33 +0100 Subject: Algorithm component switched back to helma --- bin/opentox-install-ubuntu.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/opentox-install-ubuntu.sh b/bin/opentox-install-ubuntu.sh index b27f9f9..75faff7 100755 --- a/bin/opentox-install-ubuntu.sh +++ b/bin/opentox-install-ubuntu.sh @@ -261,8 +261,7 @@ fi echo "Installing the webservices: compound, dataset, algorithm, model, task, feature" git clone git://github.com/helma/opentox-compound.git >>$INSTALLLOG 2>>$ERRLOG git clone git://github.com/helma/opentox-dataset.git >>$INSTALLLOG 2>>$ERRLOG -# opentox-algorithem only temporally from davor! -git clone git://github.com/davor/opentox-algorithm.git >>$INSTALLLOG 2>>$ERRLOG +git clone git://github.com/helma/opentox-algorithm.git >>$INSTALLLOG 2>>$ERRLOG git clone git://github.com/helma/opentox-model.git >>$INSTALLLOG 2>>$ERRLOG git clone git://github.com/helma/opentox-task.git >>$INSTALLLOG 2>>$ERRLOG git clone git://github.com/helma/opentox-feature.git >>$INSTALLLOG 2>>$ERRLOG -- cgit v1.2.3 From bfa1d9f1a85d8c6c5a7132328819d95d29fb07a8 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 10 Feb 2010 16:09:24 +0100 Subject: debugging output of owl-dl removed --- lib/dataset.rb | 2 +- opentox-ruby-api-wrapper.gemspec | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/dataset.rb b/lib/dataset.rb index 3971537..0ffefdc 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -88,7 +88,7 @@ module OpenTox dataset = Dataset.new LOGGER.debug "Getting data from #{uri}" data = `curl "#{uri}"` - LOGGER.debug data + #LOGGER.debug data #data = RestClient.get(uri, :accept => 'application/rdf+xml') # unclear why this does not work for complex uris, Dataset.find works from irb dataset.rdf = data dataset diff --git a/opentox-ruby-api-wrapper.gemspec b/opentox-ruby-api-wrapper.gemspec index 36ae17b..89de270 100644 --- a/opentox-ruby-api-wrapper.gemspec +++ b/opentox-ruby-api-wrapper.gemspec @@ -9,10 +9,10 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Christoph Helma"] - s.date = %q{2010-02-02} + s.date = %q{2010-02-09} s.description = %q{Ruby wrapper for the OpenTox REST API (http://www.opentox.org)} s.email = %q{helma@in-silico.ch} - s.executables = ["opentox-install-debian.sh", "yaml2owl.rb"] + s.executables = ["yaml2owl.rb", "opentox-install-debian.sh"] s.extra_rdoc_files = [ "LICENSE", "README.rdoc" @@ -26,6 +26,7 @@ Gem::Specification.new do |s| "bin/yaml2owl.rb", "lib/algorithm.rb", "lib/compound.rb", + "lib/config/config_ru.rb", "lib/dataset.rb", "lib/environment.rb", "lib/helper.rb", @@ -35,7 +36,6 @@ Gem::Specification.new do |s| "lib/owl.rb", "lib/spork.rb", "lib/task.rb", - "lib/tasks/config.rb", "lib/tasks/opentox.rb", "lib/templates/config.yaml", "lib/utils.rb" @@ -62,9 +62,8 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) @@ -77,9 +76,8 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) @@ -93,9 +91,8 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end end -- cgit v1.2.3 From 33d59523b3340d213b2bee58cde5de9ff4bffe99 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 15 Feb 2010 10:14:43 +0100 Subject: OWL-DL partially fixed according to Ninas suggestions --- lib/dataset.rb | 8 ++++++-- lib/environment.rb | 1 + lib/model.rb | 2 +- lib/owl.rb | 1 - 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/dataset.rb b/lib/dataset.rb index 3971537..65e1e6b 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -14,6 +14,8 @@ module OpenTox data_entry = @model.subject OT['compound'], compound if data_entry.nil? data_entry = @model.create_resource + dataset = @model.subject(RDF['type'],OT[self.owl_class]) + @model.add dataset, RDF['dataEntry'], data_entry @model.add data_entry, RDF['type'], OT["DataEntry"] @model.add data_entry, OT['compound'], compound end @@ -29,6 +31,8 @@ module OpenTox data_entry = @model.subject OT['compound'], compound if data_entry.nil? data_entry = @model.create_resource + dataset = @model.subject(RDF['type'],OT[self.owl_class]) + @model.add dataset, RDF['dataEntry'], data_entry @model.add data_entry, RDF['type'], OT["DataEntry"] @model.add data_entry, OT['compound'], compound end @@ -57,7 +61,7 @@ module OpenTox def find_or_create_compound(uri) compound = @model.subject(DC["identifier"], uri) if compound.nil? - compound = @model.create_resource + compound = @model.create_resource(uri) @model.add compound, RDF['type'], OT["Compound"] @model.add compound, DC["identifier"], uri end @@ -68,7 +72,7 @@ module OpenTox def find_or_create_feature(uri) feature = @model.subject(DC["identifier"], uri) if feature.nil? - feature = @model.create_resource + feature = @model.create_resource(uri) @model.add feature, RDF['type'], OT["Feature"] @model.add feature, DC["identifier"], uri @model.add feature, DC["title"], File.basename(uri).split(/#/)[1] diff --git a/lib/environment.rb b/lib/environment.rb index fedc3cf..814e5c0 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -15,6 +15,7 @@ if File.exist?(config_file) else FileUtils.mkdir_p TMP_DIR FileUtils.mkdir_p LOG_DIR + FileUtils.mkdir_p config_dir FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/config.yaml'), config_file) puts "Please edit #{config_file} and restart your application." exit diff --git a/lib/model.rb b/lib/model.rb index a585b59..976efac 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -24,7 +24,7 @@ module OpenTox lazar.algorithm = File.join(@@config[:services]["opentox-algorithm"],"lazar") lazar.trainingDataset = yaml[:activity_dataset] lazar.dependentVariables = yaml[:endpoint] - lazar.predictedVariables = yaml[:endpoint] #+ " lazar prediction" + lazar.predictedVariables = yaml[:endpoint] + "_lazar_prediction" lazar end diff --git a/lib/owl.rb b/lib/owl.rb index a843e59..82d6e0e 100644 --- a/lib/owl.rb +++ b/lib/owl.rb @@ -16,7 +16,6 @@ module OpenTox # reate an anonymous resource for metadata # this has to be rewritten with an URI as soon as the resource has been saved at an definitive location tmp = @model.create_resource - @model.add tmp, RDF['type'], OWL['Ontology'] @model.add tmp, RDF['type'], OT[self.owl_class] end -- cgit v1.2.3 From 8946f755a1b6063d424263924acefce0d0d9d49e Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 16 Feb 2010 16:22:14 +0100 Subject: data_entry linked to dataset --- lib/dataset.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dataset.rb b/lib/dataset.rb index f8f4a1b..e4e4e9d 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -15,7 +15,7 @@ module OpenTox if data_entry.nil? data_entry = @model.create_resource dataset = @model.subject(RDF['type'],OT[self.owl_class]) - @model.add dataset, RDF['dataEntry'], data_entry + @model.add dataset, OT['dataEntry'], data_entry @model.add data_entry, RDF['type'], OT["DataEntry"] @model.add data_entry, OT['compound'], compound end @@ -32,7 +32,7 @@ module OpenTox if data_entry.nil? data_entry = @model.create_resource dataset = @model.subject(RDF['type'],OT[self.owl_class]) - @model.add dataset, RDF['dataEntry'], data_entry + @model.add dataset, OT['dataEntry'], data_entry @model.add data_entry, RDF['type'], OT["DataEntry"] @model.add data_entry, OT['compound'], compound end -- cgit v1.2.3 From 7b59d1f07bf8cf0e23f3070f97f940af3bfad843 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 23 Feb 2010 17:49:02 +0100 Subject: some test issues resolved --- lib/algorithm.rb | 2 ++ lib/authorization.rb | 4 ++-- lib/compound.rb | 3 ++- lib/model.rb | 8 ++++++++ lib/task.rb | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/algorithm.rb b/lib/algorithm.rb index ed7b629..2a781d8 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -16,6 +16,7 @@ module OpenTox end def self.create_feature_dataset(params) + LOGGER.debug File.basename(__FILE__) + ": creating feature dataset" resource = RestClient::Resource.new(params[:feature_generation_uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] end @@ -41,6 +42,7 @@ module OpenTox def self.create_model(params) LOGGER.debug params + LOGGER.debug File.basename(__FILE__) + ": creating model" #@uri = RestClient.post File.join(@@config[:services]["opentox-algorithm"], "lazar"), :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") diff --git a/lib/authorization.rb b/lib/authorization.rb index 7cb548e..9a1760a 100644 --- a/lib/authorization.rb +++ b/lib/authorization.rb @@ -20,5 +20,5 @@ helpers do end before do - protected! unless env['REQUEST_METHOD'] == "GET" -end \ No newline at end of file + #protected! unless env['REQUEST_METHOD'] == "GET" +end diff --git a/lib/compound.rb b/lib/compound.rb index 56646c0..0ee853d 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -17,7 +17,8 @@ module OpenTox @inchi = sdf2inchi(params[:sdf]) @uri = File.join(@@config[:services]["opentox-compound"],URI.escape(@inchi)) elsif params[:name] - @inchi = RestClient.get("#{@@cactus_uri}#{params[:name]}/stdinchi").chomp + # paranoid URI encoding to keep SMILES charges and brackets + @inchi = RestClient.get("#{@@cactus_uri}#{URI.encode(params[:name], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}/stdinchi").chomp @uri = File.join(@@config[:services]["opentox-compound"],URI.escape(@inchi)) elsif params[:uri] @uri = params[:uri] diff --git a/lib/model.rb b/lib/model.rb index 8abd040..6c48734 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -39,6 +39,7 @@ module OpenTox # Predict a compound def predict(compound) + # nicht absichern?? resource = RestClient::Resource.new(@uri, :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) resource.post(:compound_uri => compound.uri) end @@ -52,6 +53,13 @@ module OpenTox resource.post(data, :content_type => "application/x-yaml").to_s end + def delete + resource = RestClient::Resource.new(self.uri, :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.delete + #RestClient.delete @uri if @uri + #RestClient.delete model.task_uri if model.task_uri + end + # def self.create(task) # @uri = RestClient.post(@@config[:services]["opentox-model"], :task_uri => task.uri) # end diff --git a/lib/task.rb b/lib/task.rb index 97b3c1d..c5cddf7 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -84,7 +84,8 @@ module OpenTox def parent=(task) #RestClient.put File.join(@uri,'parent'), {:uri => task.uri} - resource = RestClient::Resource.new(@File.join(@uri,'parent'), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource = RestClient::Resource.new(File.join(@uri,'parent'), :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + LOGGER.debug "task.rb: #{resource}" resource.put :uri => task.uri end -- cgit v1.2.3 From 40097421ffccc1c20f302e95f82242ccba9a501e Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 26 Feb 2010 16:54:37 +0100 Subject: source file added to logger --- lib/algorithm.rb | 2 ++ lib/dataset.rb | 2 ++ lib/task.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 2a781d8..179a4a2 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -1,3 +1,5 @@ +LOGGER.progname = File.expand_path(__FILE__) + module OpenTox module Algorithm diff --git a/lib/dataset.rb b/lib/dataset.rb index d4e7082..b5b2e06 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -1,3 +1,5 @@ +LOGGER.progname = File.expand_path(__FILE__) + module OpenTox class Dataset diff --git a/lib/task.rb b/lib/task.rb index c5cddf7..f507a22 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -1,3 +1,5 @@ +LOGGER.progname = File.expand_path(__FILE__) + module OpenTox class Task -- cgit v1.2.3 From 771e8acd790d7c2d5c54c7395ae650a6f4bd3bf0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 1 Mar 2010 10:17:00 +0100 Subject: Version bump to 1.3.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c04c650..f0bb29e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.7 +1.3.0 -- cgit v1.2.3 From a11d6ddbde79e82888bec072748b1b9dd9e8af60 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 1 Mar 2010 10:21:43 +0100 Subject: wrapper version bumped to 1.3.0 --- lib/algorithm.rb | 8 ++++++++ lib/model.rb | 2 +- lib/opentox-ruby-api-wrapper.rb | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 179a4a2..817340f 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -22,6 +22,10 @@ module OpenTox resource = RestClient::Resource.new(params[:feature_generation_uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri] end + + def self.uri + File.join(@@config[:services]["opentox-algorithm"], "fminer") + end end class Lazar @@ -50,6 +54,10 @@ module OpenTox @uri = resource.post :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") end + def self.uri + File.join(@@config[:services]["opentox-algorithm"], "lazar") + end + end class Similarity diff --git a/lib/model.rb b/lib/model.rb index 6c48734..b5129d7 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -45,7 +45,7 @@ module OpenTox end def self.base_uri - @@config[:services]["opentox-model"] + File.join @@config[:services]["opentox-model"],'lazar' end def self.create(data) diff --git a/lib/opentox-ruby-api-wrapper.rb b/lib/opentox-ruby-api-wrapper.rb index 03838e8..849043c 100644 --- a/lib/opentox-ruby-api-wrapper.rb +++ b/lib/opentox-ruby-api-wrapper.rb @@ -8,6 +8,6 @@ rescue LoadError puts "Please install Openbabel with 'rake openbabel:install' in the compound component" end -['owl', 'compound','dataset','algorithm','model','task','utils','authorization'].each do |lib| +['owl', 'compound','dataset','algorithm','model','task','validation','utils','authorization'].each do |lib| require lib end -- cgit v1.2.3 From 5ba6fa6748002f4937fb5ac1100313fb904a6229 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 1 Mar 2010 10:49:47 +0100 Subject: validation object added --- lib/validation.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/validation.rb diff --git a/lib/validation.rb b/lib/validation.rb new file mode 100644 index 0000000..6fd5704 --- /dev/null +++ b/lib/validation.rb @@ -0,0 +1,21 @@ +module OpenTox + class Validation + + attr_accessor :uri + + def initialize(params) + resource = RestClient::Resource.new(params[:uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + @uri = resource.post(params).to_s + end + + def self.crossvalidation(params) + params[:uri] = File.join(@@config[:services]['opentox-validation'], "crossvalidation") + params[:num_folds] = 10 unless params[:num_folds] + params[:random_seed] = 2 unless params[:random_seed] + params[:stratified] = false unless params[:stratified] + OpenTox::Validation.new(params) + end + + end +end + -- cgit v1.2.3 From 0e461d0157337c699f2a5c6f0faaa9faeb881da3 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 1 Mar 2010 11:07:26 +0100 Subject: validation.rb added to Rakefile --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 102160f..d2eaf64 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,7 @@ begin gem.add_development_dependency dep end gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore'] - gem.files.include %w(lib/tasks/owl.rb, lib/environment.rb, lib/algorithm.rb, lib/compound.rb, lib/dataset.rb, lib/model.rb, lib/utils.rb, lib/templates/*) + gem.files.include %w(lib/tasks/owl.rb, lib/environment.rb, lib/algorithm.rb, lib/compound.rb, lib/dataset.rb, lib/model.rb, lib/utils.rb, lib/validation.rb, lib/templates/*) # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end Jeweler::GemcutterTasks.new -- cgit v1.2.3