Skip to content

Commit

Permalink
LabiIMotion Integration
Browse files Browse the repository at this point in the history
* Generic Element
* Generic Segment
* Generic Dataset

---------

Co-authored-by: Chia-Lin (Claire) Lin <[email protected]>
Co-authored-by: Pei-Chi (Paggy) Huang <[email protected]>
  • Loading branch information
cllde8 and phuang26 committed Aug 31, 2023
1 parent e29301f commit e5f105c
Show file tree
Hide file tree
Showing 220 changed files with 5,560 additions and 11,740 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
aliasifyConfig.js
/app/assets/javascripts/components/extra/*
/app/packs/src/components/extra/*
/app/packs/klasses.json

# Backups folder
backup/deploy_backup
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.21.3
v18.17.1
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ gem 'kaminari'
gem 'kaminari-grape'
gem 'ketcherails', git: 'https://github.com/complat/ketcher-rails.git', branch: 'upgrade-to-rails-6'

gem 'labimotion', '1.0.5'

gem 'mimemagic', '0.3.10'

# locked to enforce latest version of net-scp. without lock net-ssh would be updated first which locks
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ GEM
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
labimotion (1.0.5)
rails (~> 6.1.7)
latex-decode (0.4.0)
launchy (2.5.0)
addressable (~> 2.7)
Expand Down Expand Up @@ -917,6 +919,7 @@ DEPENDENCIES
kaminari
kaminari-grape
ketcherails!
labimotion (= 1.0.5)
launchy
listen
memory_profiler
Expand Down Expand Up @@ -990,4 +993,4 @@ DEPENDENCIES
yaml_db

BUNDLED WITH
2.1.4
2.2.29
47 changes: 25 additions & 22 deletions app/api/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
require 'grape-entity'
require 'grape-swagger'

# rubocop:disable Metrics/BlockLength
class API < Grape::API
format :json
prefix :api
version 'v1'

# TODO needs to be tested,
# TODO: needs to be tested,
# source: http://funonrails.com/2014/03/api-authentication-using-devise-token/
helpers do
def present(*args)
Expand Down Expand Up @@ -64,25 +65,23 @@ def is_public_request?
'/api/v1/chemspectra/',
'/api/v1/ketcher/layout',
'/api/v1/gate/receiving',
'/api/v1/gate/ping'
'/api/v1/gate/ping',
)
end

def cache_key search_method, arg, molfile, collection_id, molecule_sort, opt
molecule_sort = molecule_sort == 1 ? true : false
def cache_key(search_method, arg, molfile, collection_id, molecule_sort, opt) # rubocop:disable Metrics/ParameterLists
molecule_sort = molecule_sort == 1
inchikey = Chemotion::OpenBabelService.inchikey_from_molfile molfile

cache_key = [
[
latest_updated,
search_method,
arg,
inchikey,
collection_id,
molecule_sort,
opt
opt,
]

return cache_key
end

def to_snake_case_key(k)
Expand All @@ -94,7 +93,7 @@ def to_rails_snake_case(val)
when Array
val.map { |v| to_rails_snake_case(v) }
when Hash
Hash[val.map { |k, v| [to_snake_case_key(k), to_rails_snake_case(v)] }]
Hash[val.map { |k, v| [to_snake_case_key(k), to_rails_snake_case(v)] }] # rubocop:disable Style/HashConversion
else
val
end
Expand All @@ -109,7 +108,7 @@ def to_json_camel_case(val)
when Array
val.map { |v| to_json_camel_case(v) }
when Hash
Hash[val.map { |k, v| [to_camelcase_key(k), to_json_camel_case(v)] }]
Hash[val.map { |k, v| [to_camelcase_key(k), to_json_camel_case(v)] }] # rubocop:disable Style/HashConversion
else
val
end
Expand All @@ -122,13 +121,14 @@ def to_json_camel_case(val)

# desc: whitelisted tables and columns for advanced_search
WL_TABLES = {
'samples' => %w(name short_label external_label xref)
'samples' => %w(name short_label external_label xref),
}
TARGET = Rails.env.production? ? 'https://www.chemotion-repository.net/' : 'http://localhost:3000/'

ELEMENTS = %w[research_plan screen wellplate reaction sample]

TEXT_TEMPLATE = %w[SampleTextTemplate ReactionTextTemplate WellplateTextTemplate ScreenTextTemplate ResearchPlanTextTemplate ReactionDescriptionTextTemplate ElementTextTemplate ]
TEXT_TEMPLATE = %w[SampleTextTemplate ReactionTextTemplate WellplateTextTemplate ScreenTextTemplate
ResearchPlanTextTemplate ReactionDescriptionTextTemplate ElementTextTemplate]

mount Chemotion::LiteratureAPI
mount Chemotion::ContainerAPI
Expand Down Expand Up @@ -163,29 +163,32 @@ def to_json_camel_case(val)
mount Chemotion::MessageAPI
mount Chemotion::AdminAPI
mount Chemotion::AdminUserAPI
mount Chemotion::AdminGenericAPI
mount Chemotion::EditorAPI
mount Chemotion::UiAPI
mount Chemotion::OlsTermsAPI
mount Chemotion::PredictionAPI
mount Chemotion::ComputeTaskAPI
mount Chemotion::TextTemplateAPI
mount Chemotion::GenericElementAPI
mount Chemotion::SegmentAPI
mount Chemotion::GenericDatasetAPI
mount Chemotion::ReportTemplateAPI
mount Chemotion::PrivateNoteAPI
mount Chemotion::NmrdbAPI
mount Chemotion::MeasurementsAPI
mount Chemotion::ConverterAPI
mount Chemotion::AttachableAPI
mount Chemotion::SampleTaskAPI
mount Chemotion::ChemicalAPI
mount Chemotion::CalendarEntryAPI
mount Chemotion::CommentAPI

add_swagger_documentation(info: {
"title": "Chemotion ELN",
"version": "1.0"
}) if Rails.env.development?
mount Labimotion::ConverterAPI
mount Labimotion::GenericElementAPI
mount Labimotion::GenericDatasetAPI
mount Labimotion::SegmentAPI
mount Labimotion::LabimotionHubAPI

if Rails.env.development?
add_swagger_documentation(info: {
title: 'Chemotion ELN',
version: '1.0',
})
end
end
# rubocop: enable Metrics/BlockLength
Loading

0 comments on commit e5f105c

Please sign in to comment.