summaryrefslogtreecommitdiff
path: root/similarity.rb
blob: faf43f9c8b0720cb0c1b740103c83e9cbeaeefd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require File.join(File.dirname(__FILE__),'dataset.rb')

helpers do
def find
  # + charges are dropped
  uri = uri(params[:splat].first.gsub(/(InChI.*) (.*)/,'\1+\2')) # reinsert dropped '+' signs in InChIs
  raise OpenTox::NotFoundError.new "Dataset \"#{uri}\" not found." unless @set = Dataset.find(uri)
end

def uri(name)
  name = URI.encode(name)
  uri = File.join Dataset.base_uri, name
  end
end

get '/tanimoto/dataset/*/dataset/*/?' do
  find
  @set.tanimoto(uri(params[:splat][1]))
end

get '/weighted_tanimoto/dataset/*/dataset/*/?' do
  find
  @set.weighted_tanimoto(uri(params[:splat][1]))
end