Skip to content

Commit

Permalink
add ketcher api for convert to inchi
Browse files Browse the repository at this point in the history
  • Loading branch information
Allenskywalker92 authored and PiTrem committed Dec 2, 2021
1 parent 9c20d43 commit 287c848
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ gemspec
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'
gem 'openbabel', '2.4.90.3', git: 'https://github.com/ComPlat/openbabel-gem.git', branch: 'hot-fix-svg'
gem 'inchi-gem', '1.06.1', git: 'https://github.com/ComPlat/inchi-gem.git', branch: 'main'

# To use a debugger
# gem 'byebug', group: [:development, :test]
gem 'openbabel', '2.4.90.3', git: 'https://github.com/ComPlat/openbabel-gem.git', branch: 'hot-fix-svg'

21 changes: 13 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
GIT
remote: https://github.com/ComPlat/inchi-gem.git
revision: 9a95669b42e18a20d2a0c2d5440670ff94e46c37
branch: main
specs:
inchi-gem (1.06.1)

GIT
remote: https://github.com/ComPlat/openbabel-gem.git
revision: 3e25548fd95c2ac83c7fb5d9544ed2cf6ae1344b
branch: hot-fix-svg
specs:
openbabel (2.4.90.3)

GIT
remote: https://github.com/mimemagicrb/mimemagic.git
revision: 01f92d86d15d85cfd0f20dabd025dcbd36a8a60f
ref: 01f92d86d15d85cfd0f20dabd025dcbd36a8a60f
specs:
mimemagic (0.3.5)

PATH
remote: .
specs:
Expand All @@ -25,9 +25,11 @@ PATH
grape-active_model_serializers (~> 1.3.2)
haml-rails
httparty
inchi-gem
jquery-rails
jquery-ui-rails (~> 5.0.5)
kaminari
mimemagic (>= 0.3.10)
nokogiri (>= 1.10, < 1.13)
openbabel
paperclip (~> 5.2.0)
Expand Down Expand Up @@ -193,6 +195,9 @@ GEM
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_mime (1.1.2)
mini_portile2 (2.6.1)
minitest (5.14.4)
Expand Down Expand Up @@ -290,8 +295,8 @@ DEPENDENCIES
byebug
grape
grape-swagger
inchi-gem (= 1.06.1)!
ketcherails!
mimemagic!
openbabel (= 2.4.90.3)!
pg
rspec
Expand Down
12 changes: 12 additions & 0 deletions app/api/ketcherails/ketcher_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ class KetcherAPI < Grape::API
name: mol_info[:names]
}
end

desc 'Return Inchi from mol data'
params do
requires :moldata, type: String, desc: 'Mol data'
end
post :getinchi do
return_values = Inchi::ExtraInchiReturnValues.new
inchikey = Inchi.molfileToInchi(params[:moldata], return_values, '-Polymers -FoldCRU -NPZz -SAtZZ -LargeMolecules')

env['api.format'] = :binary
"Ok.\n" + inchikey
end
end
end
end
2 changes: 1 addition & 1 deletion app/assets/javascripts/ketcherails/ui/ui.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ ui.buildAminoAcidsSequence = function(sequence_name, reversed = false) {
var tool = new rnd.Editor.TemplateTool(ui.editor, data);
ui.render.current_tool = tool;
} else if(res.status == 404) {
alert("Error: can not find one of items in sequnce. Some items are not known.");
alert("Error: block unknown: cannot find one of the block from the sequence.");
}
else if (res.responseText.startsWith('Error.')) {
alert(res.responseText.split('\n')[1]);
Expand Down
3 changes: 2 additions & 1 deletion ketcherails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Gem::Specification.new do |s|
s.add_dependency 'grape-active_model_serializers', '~> 1.3.2'
s.add_dependency 'active_model_serializers', '< 0.10.0'
s.add_dependency 'openbabel'

s.add_dependency 'mimemagic', '>= 0.3.10'
s.add_dependency 'inchi-gem'


# s.add_dependency 'openbabel', '~> 2.4.90.1'#, git: 'https://github.com/ComPlat/openbabel-gem'
Expand Down

0 comments on commit 287c848

Please sign in to comment.