-
Notifications
You must be signed in to change notification settings - Fork 51
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
Split cell lines #1971
base: main
Are you sure you want to change the base?
Split cell lines #1971
Changes from all commits
af51e8e
caf9b08
c51fe20
6bd053a
0a01175
9cd9da9
9996875
4c302c9
aa460fe
9cb2796
cfb18f7
c514055
44e95bc
8570333
cc6997c
9bee601
7c2e475
b931b80
b9bb1c2
7639ad4
0f1128d
aef1d29
50e58a2
cb0c48a
3001284
24fc8ff
b9d83fd
02c8b5b
3a399d4
89abda3
c6582ef
c261471
b4f28aa
2d73ba7
9e2d849
96a3a2c
1d37471
a58a21f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,23 +5,21 @@ class CellLineAPI < Grape::API | |
include Grape::Kaminari | ||
helpers ParamsHelpers | ||
helpers ContainerHelpers | ||
helpers CellLineApiParamsHelpers | ||
|
||
rescue_from ActiveRecord::RecordNotFound do | ||
error!('Ressource not found', 401) | ||
end | ||
resource :cell_lines do | ||
desc 'return cell lines of a collection' | ||
params do | ||
optional :collection_id, type: Integer, desc: 'Collection id' | ||
optional :sync_collection_id, type: Integer, desc: 'SyncCollectionsUser id' | ||
optional :filter_created_at, type: Boolean, desc: 'filter by created at or updated at' | ||
optional :from_date, type: Integer, desc: 'created_date from in ms' | ||
optional :to_date, type: Integer, desc: 'created_date to in ms' | ||
use :cell_line_get_params | ||
end | ||
paginate per_page: 5, offset: 0 | ||
before do | ||
params[:per_page].to_i > 50 && (params[:per_page] = 50) | ||
end | ||
|
||
get do | ||
scope = if params[:collection_id] | ||
begin | ||
|
@@ -82,29 +80,7 @@ class CellLineAPI < Grape::API | |
|
||
desc 'Create a new Cell line sample' | ||
params do | ||
optional :organism, type: String, desc: 'name of the donor organism of the cell' | ||
optional :tissue, type: String, desc: 'tissue from which the cell originates' | ||
requires :amount, type: Integer, desc: 'amount of cells' | ||
requires :unit, type: String, desc: 'unit of cell amount' | ||
requires :passage, type: Integer, desc: 'passage of cells' | ||
optional :disease, type: String, desc: 'deasease of cells' | ||
requires :material_names, type: String, desc: 'names of cell line e.g. name1;name2' | ||
requires :collection_id, type: Integer, desc: 'Collection of the cell line sample' | ||
optional :cell_type, type: String, desc: 'type of cells' | ||
optional :biosafety_level, type: String, desc: 'biosafety_level of cells' | ||
optional :growth_medium, type: String, desc: 'growth medium of cells' | ||
optional :variant, type: String, desc: 'variant of cells' | ||
optional :optimal_growth_temp, type: Float, desc: 'optimal_growth_temp of cells' | ||
optional :cryo_pres_medium, type: String, desc: 'cryo preservation medium of cells' | ||
optional :gender, type: String, desc: 'gender of donor organism' | ||
optional :material_description, type: String, desc: 'description of cell line concept' | ||
optional :contamination, type: String, desc: 'contamination of a cell line sample' | ||
requires :source, type: String, desc: 'source of a cell line sample' | ||
optional :name, type: String, desc: 'name of a cell line sample' | ||
optional :mutation, type: String, desc: 'mutation of a cell line' | ||
optional :description, type: String, desc: 'description of a cell line sample' | ||
optional :short_label, type: String, desc: 'short label of a cell line sample' | ||
requires :container, type: Hash, desc: 'root Container of element' | ||
use :cell_line_creation_params | ||
end | ||
post do | ||
error!('401 Unauthorized', 401) unless current_user.collections.find(params[:collection_id]) | ||
|
@@ -116,28 +92,7 @@ class CellLineAPI < Grape::API | |
end | ||
desc 'Update a Cell line sample' | ||
params do | ||
requires :cell_line_sample_id, type: String, desc: 'id of the cell line to update' | ||
optional :organism, type: String, desc: 'name of the donor organism of the cell' | ||
optional :mutation, type: String, desc: 'mutation of a cell line' | ||
optional :tissue, type: String, desc: 'tissue from which the cell originates' | ||
requires :amount, type: Integer, desc: 'amount of cells' | ||
requires :unit, type: String, desc: 'unit of amount of cells' | ||
optional :passage, type: Integer, desc: 'passage of cells' | ||
optional :disease, type: String, desc: 'deasease of cells' | ||
optional :material_names, type: String, desc: 'names of cell line e.g. name1;name2' | ||
optional :collection_id, type: Integer, desc: 'Collection of the cell line sample' | ||
optional :cell_type, type: String, desc: 'type of cells' | ||
optional :biosafety_level, type: String, desc: 'biosafety_level of cells' | ||
optional :variant, type: String, desc: 'variant of cells' | ||
optional :optimal_growth_temp, type: Float, desc: 'optimal_growth_temp of cells' | ||
optional :cryo_pres_medium, type: String, desc: 'cryo preservation medium of cells' | ||
optional :gender, type: String, desc: 'gender of donor organism' | ||
optional :material_description, type: String, desc: 'description of cell line concept' | ||
optional :contamination, type: String, desc: 'contamination of a cell line sample' | ||
optional :source, type: String, desc: 'source of a cell line sample' | ||
optional :name, type: String, desc: 'name of a cell line sample' | ||
optional :description, type: String, desc: 'description of a cell line sample' | ||
requires :container, type: Hash, desc: 'root Container of element' | ||
use :cell_line_update_params | ||
end | ||
put do | ||
use_case = Usecases::CellLines::Update.new(params, current_user) | ||
|
@@ -146,12 +101,59 @@ class CellLineAPI < Grape::API | |
return present cell_line_sample, with: Entities::CellLineSampleEntity | ||
end | ||
|
||
desc 'Copy a cell line' | ||
params do | ||
requires :id, type: Integer, desc: 'id of cell line sample to copy' | ||
requires :collection_id, type: Integer, desc: 'id of collection of copied cell line sample' | ||
requires :container, type: Hash, desc: 'root container of element' | ||
end | ||
namespace :copy do | ||
post do | ||
cell_line_to_copy = @current_user.cellline_samples.where(id: [params[:id]]).reorder('id') | ||
|
||
error!('401 Unauthorized', 401) unless ElementsPolicy.new(@current_user, cell_line_to_copy).update? | ||
|
||
begin | ||
use_case = Usecases::CellLines::Copy.new(cell_line_to_copy.first, @current_user, params[:collection_id]) | ||
copied_cell_line_sample = use_case.execute! | ||
copied_cell_line_sample.container = update_datamodel(params[:container]) | ||
rescue StandardError => e | ||
error!(e, 400) | ||
end | ||
return present copied_cell_line_sample, with: Entities::CellLineSampleEntity | ||
end | ||
end | ||
|
||
desc 'Splits a cell line' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename from "Splits a cell line" to "Split a cell line"? Then it'd be consistent with the other descriptions that use the grammatical base form of the verb, not the third-person (e.g., "Copy a cell line"). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apart from |
||
params do | ||
requires :id, type: Integer, desc: 'id of cell line sample to copy' | ||
requires :collection_id, type: Integer, desc: 'id of collection of copied cell line sample' | ||
optional :container, type: Hash, desc: 'root container of element' | ||
end | ||
namespace :split do | ||
post do | ||
cell_line_to_copy = @current_user.cellline_samples.where(id: [params[:id]]).reorder('id') | ||
|
||
error!('401 Unauthorized', 401) unless ElementsPolicy.new(@current_user, cell_line_to_copy).update? | ||
|
||
begin | ||
use_case = Usecases::CellLines::Split.new(cell_line_to_copy.first, @current_user, params[:collection_id]) | ||
splitted_cell_line_sample = use_case.execute! | ||
splitted_cell_line_sample.container = update_datamodel(params[:container]) if @params.key?('container') | ||
rescue StandardError => e | ||
error!(e, 400) | ||
end | ||
return present splitted_cell_line_sample, with: Entities::CellLineSampleEntity | ||
end | ||
end | ||
|
||
resource :names do | ||
desc 'Returns all accessable cell line material names and their id' | ||
get 'all' do | ||
return present CelllineMaterial.all, with: Entities::CellLineMaterialNameEntity | ||
end | ||
end | ||
|
||
resource :material do | ||
params do | ||
requires :id, type: Integer, desc: 'id of cell line material to load' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module CellLineApiParamsHelpers | ||
extend Grape::API::Helpers | ||
|
||
params :cell_line_get_params do | ||
optional :collection_id, type: Integer, desc: 'Collection id' | ||
optional :sync_collection_id, type: Integer, desc: 'SyncCollectionsUser id' | ||
optional :filter_created_at, type: Boolean, desc: 'filter by created at or updated at' | ||
optional :from_date, type: Integer, desc: 'created_date from in ms' | ||
optional :to_date, type: Integer, desc: 'created_date to in ms' | ||
end | ||
|
||
params :cell_line_creation_params do | ||
optional :organism, type: String, desc: 'name of the donor organism of the cell' | ||
optional :tissue, type: String, desc: 'tissue from which the cell originates' | ||
requires :amount, type: Integer, desc: 'amount of cells' | ||
requires :unit, type: String, desc: 'unit of cell amount' | ||
requires :passage, type: Integer, desc: 'passage of cells' | ||
optional :disease, type: String, desc: 'deasease of cells' | ||
requires :material_names, type: String, desc: 'names of cell line e.g. name1;name2' | ||
requires :collection_id, type: Integer, desc: 'Collection of the cell line sample' | ||
optional :cell_type, type: String, desc: 'type of cells' | ||
optional :biosafety_level, type: String, desc: 'biosafety_level of cells' | ||
optional :growth_medium, type: String, desc: 'growth medium of cells' | ||
optional :variant, type: String, desc: 'variant of cells' | ||
optional :optimal_growth_temp, type: Float, desc: 'optimal_growth_temp of cells' | ||
optional :cryo_pres_medium, type: String, desc: 'cryo preservation medium of cells' | ||
optional :gender, type: String, desc: 'gender of donor organism' | ||
optional :material_description, type: String, desc: 'description of cell line concept' | ||
optional :contamination, type: String, desc: 'contamination of a cell line sample' | ||
requires :source, type: String, desc: 'source of a cell line sample' | ||
optional :name, type: String, desc: 'name of a cell line sample' | ||
optional :mutation, type: String, desc: 'mutation of a cell line' | ||
optional :description, type: String, desc: 'description of a cell line sample' | ||
optional :short_label, type: String, desc: 'short label of a cell line sample' | ||
requires :container, type: Hash, desc: 'root Container of element' | ||
end | ||
|
||
params :cell_line_update_params do | ||
requires :cell_line_sample_id, type: String, desc: 'id of the cell line to update' | ||
optional :organism, type: String, desc: 'name of the donor organism of the cell' | ||
optional :mutation, type: String, desc: 'mutation of a cell line' | ||
optional :tissue, type: String, desc: 'tissue from which the cell originates' | ||
requires :amount, type: Integer, desc: 'amount of cells' | ||
requires :unit, type: String, desc: 'unit of amount of cells' | ||
optional :passage, type: Integer, desc: 'passage of cells' | ||
optional :disease, type: String, desc: 'deasease of cells' | ||
optional :material_names, type: String, desc: 'names of cell line e.g. name1;name2' | ||
optional :collection_id, type: Integer, desc: 'Collection of the cell line sample' | ||
optional :cell_type, type: String, desc: 'type of cells' | ||
optional :biosafety_level, type: String, desc: 'biosafety_level of cells' | ||
optional :variant, type: String, desc: 'variant of cells' | ||
optional :optimal_growth_temp, type: Float, desc: 'optimal_growth_temp of cells' | ||
optional :cryo_pres_medium, type: String, desc: 'cryo preservation medium of cells' | ||
optional :gender, type: String, desc: 'gender of donor organism' | ||
optional :material_description, type: String, desc: 'description of cell line concept' | ||
optional :contamination, type: String, desc: 'contamination of a cell line sample' | ||
optional :source, type: String, desc: 'source of a cell line sample' | ||
optional :name, type: String, desc: 'name of a cell line sample' | ||
optional :description, type: String, desc: 'description of a cell line sample' | ||
requires :container, type: Hash, desc: 'root Container of element' | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also check for presence of
:container
like in the:split
endpoint (line 142)?