Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sample types extension - mixtures #2311

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

TasnimMehzabin
Copy link
Contributor

@TasnimMehzabin TasnimMehzabin commented Jan 29, 2025

feat: add/modify required database tables
feat: add/modify required models
feat: Add/modify fetcher, actions, stores, and model
feat (UI): add mixture components table with calculations

Documentation: here

mixture_demo-1.mp4
mixture_demo-2.mp4

app/api/chemotion/component_api.rb Outdated Show resolved Hide resolved
app/api/chemotion/sample_api.rb Outdated Show resolved Hide resolved
app/api/chemotion/sample_api.rb Outdated Show resolved Hide resolved
# frozen_string_literal: true

class Micromolecule < ApplicationRecord
has_many :samples

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails/HasManyOrHasOneDependent: Specify a :dependent option.

@@ -620,7 +623,7 @@ def set_elem_composition_data d_type, d_values, loading = nil
end

def check_molfile_polymer_section
return if decoupled
return if decoupled || sample_type == 'Mixture'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/AbcSize: Assignment Branch Condition size for check_molfile_polymer_section is too high. [<9, 40, 12> 42.72/25]

@@ -620,7 +623,7 @@ def set_elem_composition_data d_type, d_values, loading = nil
end

def check_molfile_polymer_section
return if decoupled
return if decoupled || sample_type == 'Mixture'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/PerceivedComplexity: Perceived complexity for check_molfile_polymer_section is too high. [12/8]

@@ -72,6 +72,10 @@ def execute!
modified_sample = update_existing_sample(sample, fixed_label)
end

if sample.components.present? && sample.sample_type == 'Mixture'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/AbcSize: Assignment Branch Condition size for execute! is too high. [<12, 31, 18> 37.8/25]

@@ -72,6 +72,10 @@ def execute!
modified_sample = update_existing_sample(sample, fixed_label)
end

if sample.components.present? && sample.sample_type == 'Mixture'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/CyclomaticComplexity: Cyclomatic complexity for execute! is too high. [13/7]

@@ -72,6 +72,10 @@ def execute!
modified_sample = update_existing_sample(sample, fixed_label)
end

if sample.components.present? && sample.sample_type == 'Mixture'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/PerceivedComplexity: Perceived complexity for execute! is too high. [15/8]

components.each do |component_params|
molecule_id = component_params[:component_properties][:molecule_id]

component = Component.where("sample_id = ? AND CAST(component_properties ->> 'molecule_id' AS INTEGER) = ?", sample_id, molecule_id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/LineLength: Line is too long. [142/120]

@PiTrem PiTrem changed the title Sample types extenstion: mixtures Sample types extention: mixtures Feb 4, 2025
@PiTrem PiTrem changed the title Sample types extention: mixtures feat: sample types extension - mixtures Feb 4, 2025
@TasnimMehzabin TasnimMehzabin force-pushed the mixture-samples-main-v1 branch 3 times, most recently from 3a5e038 to 3680474 Compare February 5, 2025 16:01
PiTrem and others added 4 commits February 10, 2025 12:29
- set env variables in the docker-compose.dev.yml to allow using
  - prebuild images for the app and skip the building process
  - distinct postgres images
  - distinct named volume for the db and homedir(asdf, gems, etc)

- add .dockerenv.example file to help settings those variables
example
```
docker compose -f docker-compose.dev.yml --env-file .dockerenv.example up
```

- rework the preparation scripts to better separate node packages
  installation from ruby env installation. so that `yarn install`
  is only run by the js container

- introduce FULL_BUILD BRANCH args for preparing the dev docker
  image with preinstalled gems and nodejs packages for a given
  branch from complat/chemotion_ELN

- add optional var RAKE_DB_MIGRATE to run db:migrate instead of db:setup
   (see .dockerenv.example)
- add micromolecules table
- add components table
- modify samples table
- add micromolecules model
- add components model
- modify samples model

feat: add/modify required APIs
- add components APIs
- modify samples APIs
- add ComponentsFetcher
- add Component model
- modify Sample model
- add ComponentActions
- modify ElementActions
- add ComponentStore
- modify ElementStore

test: add test codes for Component model
@TasnimMehzabin TasnimMehzabin force-pushed the mixture-samples-main-v1 branch from 3680474 to 227cfb5 Compare February 10, 2025 11:29
spec/api/chemotion/component_api_spec.rb Outdated Show resolved Hide resolved
}
end

it 'updates an existing component' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSpec/MultipleExpectations: Example has too many expectations [4/3].

spec/api/chemotion/component_api_spec.rb Outdated Show resolved Hide resolved
spec/factories/components.rb Outdated Show resolved Hide resolved
@TasnimMehzabin TasnimMehzabin force-pushed the mixture-samples-main-v1 branch 3 times, most recently from 0188cbb to 84dce94 Compare February 12, 2025 14:29
Tasnim Mehzabin added 2 commits February 17, 2025 14:25
- add select sample type dropdown
- add component table header
- add liquid components section
- add liquid components calculations
- add solid components section
- add solid components calculations
- drag and drop samples in mixture comps table
- do not render structure editor & cas fast input for mixtures
- move component between tables
- option to merge components
- calculate total MW for mixtures & use in reaction table
- mixture samples in reactions scheme
- solvent volume column only for mixture samples
- add the preview image to component in mixtures
- modified the calculations related to various fields
- added the field for required total volume
- modified the structure of the solid components table
- import the molarity value from sample in drag-n-drop into component
- when Target Concentration is updated, then Amount and Volume gets recalculated
- re-calculate amount_mol and related attributes, when Purity is updated
- add the functionality to lock concentration for multiple components
- when there is Total Conc. and amount, then the total volume is calculated
- fix the amount_mol calculations to use the density or stock
- disable the lock concentration button, if it is 0
- lock the Ratio when total conc. is locked
- fix the tooltip buttons
- show indication in the sample list if the sample is a mixture
- split sample with components
- though a field is locked it should be possible to change the unit multiplier

fix (UI): cannot create a single molecule
fix: issue with the Amount field not being set for mixture components
fix: fetching of components after fetching the sample causing the sample appear as edited
fix: input fields CSS
fix: sample type selection input field

test: added test codes

refactor: code
refactor: eslint warnings
refactor: moved packs/src files to javascript directory
@TasnimMehzabin TasnimMehzabin force-pushed the mixture-samples-main-v1 branch from 84dce94 to e6e1fef Compare February 17, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stock solutions / multicomponent samples / mixtures for reactions or reaction series in variations tool
2 participants