Skip to content

Commit b063ca3

Browse files
authored
Merge pull request #97 from broadinstitute/development
10X Market Exchange Format support
2 parents e57d091 + 670f8d6 commit b063ca3

29 files changed

+34542
-136
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ gem 'mongoid-encrypted-fields'
7676
gem 'gibberish'
7777
gem 'parallel'
7878
gem 'ruby_native_statistics'
79-
gem 'mongoid_rails_migrations'
79+
gem 'mongoid_rails_migrations'
80+
gem 'nmatrix'

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ GEM
9696
arel (6.0.4)
9797
autoprefixer-rails (7.2.5)
9898
execjs
99+
backports (3.11.1)
99100
bcrypt (3.1.11)
100101
bson (4.3.0)
101102
bson_ext (1.5.1)
@@ -238,6 +239,8 @@ GEM
238239
multipart-post (2.0.0)
239240
naturally (2.1.0)
240241
netrc (0.11.0)
242+
nmatrix (0.2.4)
243+
packable (~> 1.3, >= 1.3.5)
241244
nokogiri (1.8.1)
242245
mini_portile2 (~> 2.3.0)
243246
non-stupid-digest-assets (1.0.9)
@@ -262,6 +265,8 @@ GEM
262265
origin (2.3.1)
263266
orm_adapter (0.5.0)
264267
os (0.9.6)
268+
packable (1.3.9)
269+
backports
265270
paperclip (5.2.1)
266271
activemodel (>= 4.2.0)
267272
activesupport (>= 4.2.0)
@@ -404,6 +409,7 @@ DEPENDENCIES
404409
mongoid_rails_migrations
405410
naturally
406411
nested_form!
412+
nmatrix
407413
non-stupid-digest-assets
408414
omniauth-google-oauth2
409415
parallel

app/assets/javascripts/application.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,4 +910,18 @@ function closeUserAnnotationsForm() {
910910
function validateEmail(email) {
911911
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
912912
return re.test(email);
913+
}
914+
915+
// gather all MM Coordinate Matrix instances from a page
916+
function gatherCoordinateMatrices() {
917+
var matrices = [];
918+
$('.file-type').each(function(index, fileType) {
919+
if ($(fileType).val() == 'MM Coordinate Matrix') {
920+
var mForm = $(fileType).closest('.unsynced-study-file');
921+
var mId = $(mForm).attr('id').split('-')[2];
922+
var mName = $(mForm).find('.filename').val();
923+
matrices.push([mName, mId]);
924+
}
925+
});
926+
return matrices;
913927
}

app/controllers/site_controller.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ def get_workspace_submissions
956956

957957
# retrieve any optional parameters for a selected workflow
958958
def get_workflow_options
959-
@options = WorkflowConfiguration.get_optional_parameters(params[:workflow_identifier])
959+
@options = WorkflowConfiguration.get_additional_parameters(params[:workflow_identifier])
960960
end
961961

962962
# create a workspace analysis submission for a given sample
@@ -1115,7 +1115,11 @@ def get_submission_metadata
11151115
# export a submission analysis metadata file
11161116
def export_submission_metadata
11171117
@metadata = AnalysisMetadatum.find_by(study_id: @study.id, submission_id: params[:submission_id])
1118-
send_data JSON.pretty_generate(@metadata.payload), content_type: :json, filename: 'analysis.json'
1118+
respond_to do |format|
1119+
format.html {send_data JSON.pretty_generate(@metadata.payload), content_type: :json, filename: 'analysis.json'}
1120+
format.json {render json: @metadata.payload}
1121+
end
1122+
11191123
end
11201124

11211125
# delete all files from a submission
@@ -1135,7 +1139,7 @@ def delete_submission_files
11351139
AnalysisMetadatum.where(submission_id: params[:submission_id]).delete
11361140
logger.info "#{Time.now}: queueing submission #{params[:submission]} deletion in #{@study.firecloud_workspace}"
11371141
submission_files = Study.firecloud_client.execute_gcloud_method(:get_workspace_files, @study.firecloud_project, @study.firecloud_workspace, prefix: params[:submission_id])
1138-
DeleteQueueJob.new(submission_files).delay.perform
1142+
DeleteQueueJob.new(submission_files).perform
11391143
rescue => e
11401144
logger.error "#{Time.now}: unable to remove submission #{params[:submission_id]} files from #{@study.firecloud_workspace} due to: #{e.message}"
11411145
@alert = "Unable to delete the outputs for #{params[:submission_id]} due to the following error: #{e.message}"
@@ -1993,8 +1997,8 @@ def load_available_workflows
19931997

19941998
# parellelize gets to speed up performance if there are a lot of workflows
19951999
Parallel.map(allowed_workflows, in_threads: 100) do |workflow_opts|
1996-
namespace, name = workflow_opts.split('/')
1997-
all_workflows << Study.firecloud_client.get_methods(namespace: namespace, name: name)
2000+
namespace, name, snapshot = workflow_opts.split('/')
2001+
all_workflows << Study.firecloud_client.get_methods(namespace: namespace, name: name, snapshotId: snapshot)
19982002
end
19992003

20002004
# flatten list as it will be nested arrays

app/controllers/studies_controller.rb

Lines changed: 136 additions & 12 deletions
Large diffs are not rendered by default.

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def get_submission_actions(submission, study)
269269
if submission['status'] == 'Done' && submission['workflowStatuses'].keys.include?('Succeeded')
270270
# actions << link_to("<i class='fa fa-files-o'></i> Download".html_safe, '#', class: 'btn btn-xs btn-block btn-primary get-submission-outputs', title: 'Download outputs from this run', data: {toggle: 'tooltip', url: get_submission_outputs_path(study_name: study.url_safe_name, submission_id: submission['submissionId']), id: submission['submissionId']})
271271
actions << link_to("<i class='fa fa-fw fa-code'></i> View Run Info".html_safe, 'javascript:;', class: 'btn btn-xs btn-block btn-info view-submission-metadata', title: 'View HCA-formatted analysis metadata', data: {toggle: 'tooltip', id: submission['submissionId'], url: get_submission_metadata_path(study_name: @study.url_safe_name, submission_id: submission['submissionId'])})
272-
actions << link_to("<i class='fa fa-fw fa-refresh'></i> Sync".html_safe, sync_submission_outputs_study_path(id: @study.id, submission_id: submission['submissionId']), class: 'btn btn-xs btn-block btn-warning sync-submission-outputs', title: 'Sync outputs from this run back to study', data: {toggle: 'tooltip', id: submission['submissionId']})
272+
actions << link_to("<i class='fa fa-fw fa-refresh'></i> Sync".html_safe, sync_submission_outputs_study_path(id: @study.id, submission_id: submission['submissionId'], configuration_name: submission['methodConfigurationName']), class: 'btn btn-xs btn-block btn-warning sync-submission-outputs', title: 'Sync outputs from this run back to study', data: {toggle: 'tooltip', id: submission['submissionId']})
273273
end
274274
# submission has failed
275275
if %w(Done Aborted).include?(submission['status']) && submission['workflowStatuses'].keys.include?('Failed')

app/models/admin_configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def url_safe_name
2929
end
3030

3131
def self.config_types
32-
['Daily User Download Quota', 'Workflow Name', 'Portal FireCloud User Group', API_NOTIFIER_NAME]
32+
['Daily User Download Quota', 'Workflow Name', 'Portal FireCloud User Group', 'Reference Data Workspace', API_NOTIFIER_NAME]
3333
end
3434

3535
def self.value_types

app/models/delete_queue_job.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def perform
4646
Gene.where(study_file_id: object.id, study_id: study.id).delete_all
4747
DataArray.where(study_file_id: object.id, study_id: study.id).delete_all
4848
study.set_gene_count
49+
when 'MM Coordinate Matrix'
50+
Gene.where(study_file_id: object.id, study_id: study.id).delete_all
51+
DataArray.where(study_file_id: object.id, study_id: study.id).delete_all
52+
study.set_gene_count
4953
when 'Metadata'
5054
CellMetadatum.where(study_file_id: object.id, study_id: study.id).delete_all
5155
DataArray.where(study_file_id: object.id, study_id: study.id).delete_all
@@ -74,7 +78,7 @@ def perform
7478
object.user_annotation_shares.delete_all
7579
when 'Google::Cloud::Storage::File::List'
7680
# called when a user wants to delete an entire directory of files from a FireCloud submission
77-
# this list could be very large, hence the background process so we don't tie the UI up
81+
# this is run in the foreground as Delayed::Job cannot deserialize the list anymore
7882
files = object
7983
files.each {|f| f.delete}
8084
while files.next?

app/models/fire_cloud_client.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,56 @@ def get_workspace_submission_outputs(workspace_namespace, workspace_name, submis
772772
process_firecloud_request(:get, path)
773773
end
774774

775+
# get permissions for a method configuration namespace
776+
#
777+
# * *params*
778+
# - +config_namespace+ (String) => namespace of configuraiton
779+
#
780+
# * *return*
781+
# - +Array+ of users & permission levels
782+
def get_config_namespace_permissions(config_namespace)
783+
path = self.api_root + "/api/configurations/#{config_namespace}/permissions"
784+
process_firecloud_request(:get, path)
785+
end
786+
787+
# get permissions for a method configuration namespace
788+
#
789+
# * *params*
790+
# - +config_namespace+ (String) => namespace of configuraiton
791+
# - +permissions+ (Array) => Array of permission objects (Hash of user & role)
792+
#
793+
# * *return*
794+
# - +Array+ of users & permission levels
795+
def update_config_namespace_permissions(config_namespace, permissions)
796+
path = self.api_root + "/api/configurations/#{config_namespace}/permissions"
797+
process_firecloud_request(:post, path, permissions.to_json)
798+
end
799+
800+
# get permissions for a method namespace
801+
#
802+
# * *params*
803+
# - +config_namespace+ (String) => namespace of configuraiton
804+
#
805+
# * *return*
806+
# - +Array+ of users & permission levels
807+
def get_method_namespace_permissions(config_namespace)
808+
path = self.api_root + "/api/methods/#{config_namespace}/permissions"
809+
process_firecloud_request(:get, path)
810+
end
811+
812+
# get permissions for a method namespace
813+
#
814+
# * *params*
815+
# - +config_namespace+ (String) => namespace of configuraiton
816+
# - +permissions+ (Array) => Array of permission objects (Hash of user & role)
817+
#
818+
# * *return*
819+
# - +Array+ of users & permission levels
820+
def update_method_namespace_permissions(config_namespace, permissions)
821+
path = self.api_root + "/api/methods/#{config_namespace}/permissions"
822+
process_firecloud_request(:post, path, permissions.to_json)
823+
end
824+
775825
##
776826
## WORKSPACE ENTITY METHODS
777827
##

0 commit comments

Comments
 (0)