Commit 799ed658 authored by jasonych99's avatar jasonych99
Browse files

BE: integrate prediction nmr

parent d39612cc
......@@ -91,6 +91,23 @@ module Chemotion
zip_io.read
end
end
resource :predict do
desc 'Predict by peaks'
params do
requires :layout, type: String
requires :peaks, type: Array
requires :molecule, type: String
end
post 'by_peaks' do
rsp = Chemotion::Jcamp::Predict.by_peaks(
params[:layout], params[:peaks], params[:molecule]
)
content_type('application/json')
rsp
end
end
end
end
end
......@@ -139,3 +139,34 @@ module Chemotion
end
end
end
# Chemotion module
module Chemotion
# process Jcamp files
module Jcamp
# CreateImg module
module Predict
include HTTParty
def self.stub_by_peaks(layout, peaks, molecule)
url = Rails.configuration.spectra.url
port = Rails.configuration.spectra.port
response = HTTParty.post(
"http://#{url}:#{port}/predict/by_peaks",
body: {
layout: layout,
peaks: peaks,
molecule: molecule
}.to_json,
headers: { 'Content-Type' => 'application/json' }
)
response
end
def self.by_peaks(layout, peaks, molecule)
rsp = stub_by_peaks(layout, peaks, molecule)
rsp.parsed_response
end
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment