Skip to content

Commit

Permalink
Cdx parser
Browse files Browse the repository at this point in the history
  • Loading branch information
CamAnNguyen authored and PiTrem committed Apr 19, 2018
1 parent 39ff780 commit 83203c2
Show file tree
Hide file tree
Showing 69 changed files with 16,509 additions and 846 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Expand Up @@ -58,14 +58,14 @@
/public/images/*
!/public/images/wild_card/

/uploads/attachments/*
/uploads/thumbnails
/uploads/*
!/public/attachments/.keep


/public/docx/*
!/public/docx/.keep

/public/assets/*.js
/public/assets/*

/coverage/

Expand Down
8 changes: 7 additions & 1 deletion .rubocop.yml
@@ -1,3 +1,7 @@
AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.3

Style/BlockDelimiters:
EnforcedStyle: semantic
FunctionalMethods:
Expand All @@ -15,6 +19,8 @@ Metrics/ModuleLength:
Metrics/BlockLength:
Exclude:
- "**/*_spec.rb"

Metrics/LineLength:
Max: 100

Metrics/MethodLength:
Max: 20
5 changes: 3 additions & 2 deletions Gemfile
Expand Up @@ -106,6 +106,7 @@ gem 'rubocop', require: false
gem 'yaml_db'

gem 'ruby-ole'
gem 'ruby-geometry', require: 'geometry'

# CI
gem 'coveralls', require: false
Expand All @@ -114,8 +115,8 @@ gem 'coveralls', require: false
# to compile from github/openbabel/openbabel master
# gem 'openbabel', '2.4.1.2', git: 'https://github.com/ComPlat/openbabel-gem'
# to compile from github/openbabel/openbabel branch openbabel-2-4-x
gem 'openbabel', '2.4.0.1', git: 'https://github.com/ComPlat/openbabel-gem',
branch: 'openbabel-2-4-x'
gem 'openbabel', '2.4.1.2', git: 'https://github.com/ComPlat/openbabel-gem',
branch: 'cdx-extraction'

gem 'barby'
gem 'prawn'
Expand Down
13 changes: 9 additions & 4 deletions Gemfile.lock
Expand Up @@ -15,10 +15,10 @@ GIT

GIT
remote: https://github.com/ComPlat/openbabel-gem
revision: 837eec9e660b6dbc9d2517889de39a6e93bb4b98
branch: openbabel-2-4-x
revision: b651909dc84ea33ab79a8e95dc50486ba272a3d4
branch: cdx-extraction
specs:
openbabel (2.4.0.1)
openbabel (2.4.1.2)

GIT
remote: https://github.com/ComPlat/sablon
Expand Down Expand Up @@ -333,6 +333,7 @@ GEM
skinny (~> 0.2.3)
sqlite3 (~> 1.3)
thin (~> 1.5.0)
memoist (0.16.0)
memory_profiler (0.9.7)
meta_request (0.4.3)
callsite (~> 0.0, >= 0.0.11)
Expand Down Expand Up @@ -469,6 +470,9 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-geometry (0.0.6)
activesupport
memoist
ruby-mailchecker (3.0.27)
ruby-ole (1.2.12)
ruby-progressbar (1.8.1)
Expand Down Expand Up @@ -632,7 +636,7 @@ DEPENDENCIES
net-sftp
net-ssh
nokogiri
openbabel (= 2.4.0.1)!
openbabel (= 2.4.1.2)!
paranoia (~> 2.0)
pg (~> 0.20.0)
pg_search
Expand All @@ -648,6 +652,7 @@ DEPENDENCIES
rspec-rails
rtf
rubocop
ruby-geometry
ruby-mailchecker
ruby-ole
rubyXL (= 3.3.26)
Expand Down
2 changes: 1 addition & 1 deletion app/api/api.rb
Expand Up @@ -190,7 +190,7 @@ def to_molecule_array(hash_groups)
mount Chemotion::DevicesAnalysisAPI
mount Chemotion::GeneralAPI
mount Chemotion::V1PublicAPI
mount Chemotion::DocxAPI
mount Chemotion::GateAPI
mount Chemotion::ElementAPI
mount Chemotion::ChemReadAPI
end
69 changes: 69 additions & 0 deletions app/api/chemotion/chem_read_api.rb
@@ -0,0 +1,69 @@
# frozen_string_literal: true

# Belong to Chemotion module
module Chemotion
require 'open3'
require 'ole/storage'

# API for ChemRead manipulation
class ChemReadAPI < Grape::API
helpers ChemReadHelpers

resource :chemread do
resource :embedded do
desc 'Upload import files'
params do
requires :get_mol, type: Boolean, default: false, desc: ''
end

post 'upload' do
smi_arr = []

get_mol = params[:get_mol]
params.delete('get_mol')

params.each do |uid, file|
temp_file = file.tempfile
temp_path = temp_file.to_path
extn = File.extname temp_path
tmp_dir = Dir.mktmpdir([uid, File.basename(temp_path, extn)])

info = read_uploaded_file(temp_file, tmp_dir, get_mol)
smi_obj = { uid: uid, name: file.filename, info: info }

temp_file.close
temp_file.unlink
FileUtils.remove_dir tmp_dir, true
smi_arr.push(smi_obj)
end

smi_arr
end
end

resource :svg do
desc 'Convert svg from smi'
params do
requires :smiArr, type: Array, desc: 'Files and uids'
end

post 'smi' do
smi_arr = params[:smiArr]
res = []
smi_arr.each do |smi|
res.push(
uid: smi[:uid],
smiIdx: smi[:smiIdx],
svg: SVG::ReactionComposer.cr_reaction_svg_from_rsmi(
smi[:newSmi],
ChemReadHelpers::SOLVENTS_SMI,
ChemReadHelpers::REAGENTS_SMI
)
)
end
res
end
end
end
end
end
75 changes: 0 additions & 75 deletions app/api/chemotion/docx_api.rb

This file was deleted.

0 comments on commit 83203c2

Please sign in to comment.