From e182a536376a5399d50c3985d467f1b1703d8869 Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Thu, 14 Nov 2024 11:20:25 -0500 Subject: [PATCH 1/8] Added href with dataset name to analysis details page --- mason/analyses/analysis_details.mas | 6 +++--- mason/analyses/model_details.mas | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mason/analyses/analysis_details.mas b/mason/analyses/analysis_details.mas index b30cce5d3c..047d574b37 100644 --- a/mason/analyses/analysis_details.mas +++ b/mason/analyses/analysis_details.mas @@ -75,10 +75,10 @@ $analysis_metadata - Dataset ID + Dataset
-% print $analysis_metadata->dataset_id; +% print "dataset_id.">".$analysis_metadata->dataset_id."";
@@ -111,4 +111,4 @@ $analysis_metadata <& /util/barcode.mas, identifier => "$identifier_prefix"."$trial_id", trial_id=> "$trial_id", trial_name=> "$trial_name", format=>"trial_qrcode" &> - + \ No newline at end of file diff --git a/mason/analyses/model_details.mas b/mason/analyses/model_details.mas index e392dd83e4..368afaccc9 100644 --- a/mason/analyses/model_details.mas +++ b/mason/analyses/model_details.mas @@ -73,6 +73,7 @@ jQuery(document).ready(function(){ jQuery('#model_name').html(""+response.model_info.model_name+""); jQuery('#model_description').html(response.model_info.model_description); jQuery('#model_type').html(response.model_info.model_type_name); + jQuery('#analysis_dataset_id').html(""+response.dataset.dataset_name+""); var model_properties_string = ''; for (var key in response.model_info.model_properties) { From d080b2094904818bed967688e8fd0f080d50619b Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Thu, 14 Nov 2024 15:23:29 -0500 Subject: [PATCH 2/8] Created function to retrieve list of analyses that use this dataset. Added list of analyses to dataset details page --- lib/CXGN/Dataset.pm | 45 ++++++++++++++++++++++++++++++ lib/SGN/Controller/AJAX/Dataset.pm | 32 +++++++++++++++++++++ mason/dataset/index.mas | 16 +++++++++++ 3 files changed, 93 insertions(+) diff --git a/lib/CXGN/Dataset.pm b/lib/CXGN/Dataset.pm index d48f618267..847fd8a91c 100644 --- a/lib/CXGN/Dataset.pm +++ b/lib/CXGN/Dataset.pm @@ -54,6 +54,7 @@ use Moose; use Moose::Util::TypeConstraints; use Data::Dumper; use JSON::Any; +use JSON::XS; use CXGN::BreederSearch; use CXGN::People::Schema; use CXGN::Phenotypes::PhenotypeMatrix; @@ -1285,6 +1286,50 @@ sub update_description { } } +=head2 get_child_analyses() + +# Retrieves the list of analyses that use this dataset. + +=cut + +sub get_child_analyses { + my $self = shift; + my $dataset_id = $self->sp_dataset_id(); + + my $dbh = $self->schema->storage->dbh(); + + my @all_analyses = (); + + my $analysis_info_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema, 'analysis_metadata_json', 'project_property')->cvterm_id(); + + my $analysis_q = "select DISTINCT project.name, project.project_id, analysisinfo.value FROM nd_experiment_project + JOIN project USING (project_id) + JOIN nd_experiment ON nd_experiment.nd_experiment_id=nd_experiment_project.nd_experiment_id + JOIN projectprop AS analysisinfo ON (project.project_id=analysisinfo.project_id) + JOIN cvterm ON cvterm.cvterm_id=nd_experiment.type_id + WHERE cvterm.name='analysis_experiment' AND analysisinfo.type_id=$analysis_info_type_id;"; + my $h = $dbh->prepare($analysis_q); + $h->execute(); + + while (my ($analysis_name, $analysis_id, $metadata_json) = $h->fetchrow_array()){ + my $analysis_metadata = decode_json($metadata_json); + push @all_analyses, [ + $analysis_name, + $analysis_id, + $analysis_metadata->{dataset_id} + ]; + } + + my @html = (); + + foreach my $row (@all_analyses) { + if ($dataset_id == $row->[2]){ + push @html, "[1].">".$row->[0].""; + } + } + return join(" | ", @html); +} + 1; diff --git a/lib/SGN/Controller/AJAX/Dataset.pm b/lib/SGN/Controller/AJAX/Dataset.pm index c2c55c5515..3fe477fa9c 100644 --- a/lib/SGN/Controller/AJAX/Dataset.pm +++ b/lib/SGN/Controller/AJAX/Dataset.pm @@ -356,6 +356,38 @@ sub get_dataset :Path('/ajax/dataset/get') Args(1) { $c->stash->{rest} = { dataset => $dataset_data }; } +sub get_child_analyses :Path('/ajax/dataset/get_child_analyses') Args(1) { + my $self = shift; + my $c = shift; + my $dataset_id = shift; + + my $sp_person_id = $c->user() ? $c->user->get_object()->get_sp_person_id() : undef; + + my $dataset = CXGN::Dataset->new( + { + schema => $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id), + people_schema => $c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id), + sp_dataset_id=> $dataset_id, + }); + + my $analysis_list; + eval { + $analysis_list = $dataset->get_child_analyses(); + }; + + if ($@){ + $c->stash->{rest} = {error => "Error retrieving analyses using this dataset. $@"}; + } + + if ($analysis_list eq "") { + $analysis_list = "(none)"; + } + + print STDERR "Got the following list of accessions using this dataset: $analysis_list \n"; + + $c->stash->{rest} = { analysis_html_list => $analysis_list }; +} + sub retrieve_dataset_dimension :Path('/ajax/dataset/retrieve') Args(2) { my $self = shift; diff --git a/mason/dataset/index.mas b/mason/dataset/index.mas index df32ccc697..04634aeb16 100644 --- a/mason/dataset/index.mas +++ b/mason/dataset/index.mas @@ -99,6 +99,7 @@ $dataset_contents => '' % } Select Dataset in Wizard<% $wizard_link %> + Analyses using this dataset @@ -249,6 +250,21 @@ $dataset_contents => '' window.open(url,'_blank'); }) + + jQuery.ajax({ + type: 'GET', + url: '/ajax/dataset/get_child_analyses/<% $dataset_id %>', + success: function(response) { + if (response.error){ + alert(response.error); + } else { + jQuery('#dataset_analysis_usage').html(response.analysis_html_list); + } + }, + error: function(response) { + alert("Error retrieving analyses using this dataset."); + } + }); }); From 65793b2615635acf04d45ba500cd31717ceb1af0 Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Fri, 15 Nov 2024 10:39:04 -0500 Subject: [PATCH 3/8] Removed mixed models welcome alert --- js/source/entries/mixedmodels.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/source/entries/mixedmodels.js b/js/source/entries/mixedmodels.js index be743b3738..7eec211a6c 100644 --- a/js/source/entries/mixedmodels.js +++ b/js/source/entries/mixedmodels.js @@ -11,7 +11,7 @@ export function init(main_div) { var dataset_id; - alert("WELCOME TO MIXED MODELS!"); + // alert("WELCOME TO MIXED MODELS!"); get_select_box("datasets", "mixed_model_dataset_select", { "checkbox_name": "mixed_model_dataset_select_checkbox" }); jQuery('#mixed_model_analysis_prepare_button').removeClass('active').addClass('inactive'); From 5f3fdd219baf8d1a15b70b893e6d897cf81a8954 Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Mon, 18 Nov 2024 14:21:23 -0500 Subject: [PATCH 4/8] Changed query to use JSONB grammar to get dataset_id instead of unpacking JSON in backend controller --- lib/CXGN/Dataset.pm | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/CXGN/Dataset.pm b/lib/CXGN/Dataset.pm index 847fd8a91c..bd9d609da0 100644 --- a/lib/CXGN/Dataset.pm +++ b/lib/CXGN/Dataset.pm @@ -1298,35 +1298,27 @@ sub get_child_analyses { my $dbh = $self->schema->storage->dbh(); - my @all_analyses = (); - my $analysis_info_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema, 'analysis_metadata_json', 'project_property')->cvterm_id(); - my $analysis_q = "select DISTINCT project.name, project.project_id, analysisinfo.value FROM nd_experiment_project + my $analysis_q = "select DISTINCT project.name, project.project_id, analysisinfo.value::json->>'dataset_id' FROM nd_experiment_project JOIN project USING (project_id) JOIN nd_experiment ON nd_experiment.nd_experiment_id=nd_experiment_project.nd_experiment_id JOIN projectprop AS analysisinfo ON (project.project_id=analysisinfo.project_id) JOIN cvterm ON cvterm.cvterm_id=nd_experiment.type_id - WHERE cvterm.name='analysis_experiment' AND analysisinfo.type_id=$analysis_info_type_id;"; + WHERE cvterm.name='analysis_experiment' + AND analysisinfo.type_id=$analysis_info_type_id + AND analysisinfo.value::json->>'dataset_id'=?;"; my $h = $dbh->prepare($analysis_q); - $h->execute(); - - while (my ($analysis_name, $analysis_id, $metadata_json) = $h->fetchrow_array()){ - my $analysis_metadata = decode_json($metadata_json); - push @all_analyses, [ - $analysis_name, - $analysis_id, - $analysis_metadata->{dataset_id} - ]; - } + $h->execute($dataset_id); my @html = (); - foreach my $row (@all_analyses) { - if ($dataset_id == $row->[2]){ - push @html, "[1].">".$row->[0].""; + while (my ($analysis_name, $analysis_id, $analysis_ds_id) = $h->fetchrow_array()){ + if ($dataset_id == $analysis_ds_id){ + push @html, "".$analysis_name.""; } } + return join(" | ", @html); } From 85fe822833548ed01c25e71de055723612c6f903 Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Tue, 19 Nov 2024 11:08:13 -0500 Subject: [PATCH 5/8] Added test of dataset details page --- t/selenium2/breeders/breeder_search.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/selenium2/breeders/breeder_search.t b/t/selenium2/breeders/breeder_search.t index ff6bda2814..80d16855e0 100644 --- a/t/selenium2/breeders/breeder_search.t +++ b/t/selenium2/breeders/breeder_search.t @@ -2,7 +2,7 @@ use strict; use lib 't/lib'; -use Test::More 'tests' => 110; +use Test::More 'tests' => 113; use SGN::Test::WWW::WebDriver; use Selenium::Remote::WDKeys 'KEYS'; @@ -390,6 +390,17 @@ $t->while_logged_in_as("submitter", sub { ok($selected_reloaded_elements =~ /IITA-TMS-IBA011412/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession IITA-TMS-IBA011412"); ok($selected_reloaded_elements =~ /IITA-TMS-IBA30572/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession IITA-TMS-IBA30572"); + # TEST WORKING MIXED MODEL AND DETAILS PAGE FOR DATASET 1 + $t->get_ok('/search/datasets'); + sleep(1); + + $t->find_element_ok("//a[text()='$dataset_name_1']",'xpath','checking for created dataset on dataset overview page')->click(); + sleep(5); + + my $child_analyses = $t->find_element('dataset_analysis_usage', 'id')->get_text(); + ok($child_analyses eq "(none)", 'checking initial analysis usage'); + sleep(1); + # DELETE DATASET $t->get_ok('/breeders/search'); sleep(3); From b51b95a702bf223f99178719cd62594451d399cc Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Tue, 19 Nov 2024 14:48:32 -0500 Subject: [PATCH 6/8] Removed debugging stuff from sql query --- lib/CXGN/Dataset.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/CXGN/Dataset.pm b/lib/CXGN/Dataset.pm index bd9d609da0..030ed6b5bf 100644 --- a/lib/CXGN/Dataset.pm +++ b/lib/CXGN/Dataset.pm @@ -1300,7 +1300,7 @@ sub get_child_analyses { my $analysis_info_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema, 'analysis_metadata_json', 'project_property')->cvterm_id(); - my $analysis_q = "select DISTINCT project.name, project.project_id, analysisinfo.value::json->>'dataset_id' FROM nd_experiment_project + my $analysis_q = "select DISTINCT project.name, project.project_id FROM nd_experiment_project JOIN project USING (project_id) JOIN nd_experiment ON nd_experiment.nd_experiment_id=nd_experiment_project.nd_experiment_id JOIN projectprop AS analysisinfo ON (project.project_id=analysisinfo.project_id) @@ -1313,10 +1313,8 @@ sub get_child_analyses { my @html = (); - while (my ($analysis_name, $analysis_id, $analysis_ds_id) = $h->fetchrow_array()){ - if ($dataset_id == $analysis_ds_id){ - push @html, "".$analysis_name.""; - } + while (my ($analysis_name, $analysis_id) = $h->fetchrow_array()){ + push @html, "".$analysis_name.""; } return join(" | ", @html); From 8780a71e51dca444ff447a6cef474565314221e5 Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Tue, 19 Nov 2024 15:37:19 -0500 Subject: [PATCH 7/8] Satisfying the linter --- lib/CXGN/Dataset.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CXGN/Dataset.pm b/lib/CXGN/Dataset.pm index 030ed6b5bf..8429a5f3c7 100644 --- a/lib/CXGN/Dataset.pm +++ b/lib/CXGN/Dataset.pm @@ -449,7 +449,7 @@ sub set_dataset_public { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } } @@ -475,7 +475,7 @@ sub set_dataset_private { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } } @@ -1259,7 +1259,7 @@ sub delete { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } @@ -1281,7 +1281,7 @@ sub update_description { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } } From d30ed57472b50b609a636ecffe86009e9ccb7f26 Mon Sep 17 00:00:00 2001 From: ryan-preble Date: Mon, 9 Dec 2024 12:38:01 -0500 Subject: [PATCH 8/8] Trim debug stuff away from query --- lib/CXGN/Dataset.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/CXGN/Dataset.pm b/lib/CXGN/Dataset.pm index 8429a5f3c7..b46f0010ad 100644 --- a/lib/CXGN/Dataset.pm +++ b/lib/CXGN/Dataset.pm @@ -1300,13 +1300,9 @@ sub get_child_analyses { my $analysis_info_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema, 'analysis_metadata_json', 'project_property')->cvterm_id(); - my $analysis_q = "select DISTINCT project.name, project.project_id FROM nd_experiment_project + my $analysis_q = "select DISTINCT project.name, project.project_id FROM projectprop JOIN project USING (project_id) - JOIN nd_experiment ON nd_experiment.nd_experiment_id=nd_experiment_project.nd_experiment_id - JOIN projectprop AS analysisinfo ON (project.project_id=analysisinfo.project_id) - JOIN cvterm ON cvterm.cvterm_id=nd_experiment.type_id - WHERE cvterm.name='analysis_experiment' - AND analysisinfo.type_id=$analysis_info_type_id + WHERE projectprop.type_id=$analysis_info_type_id AND analysisinfo.value::json->>'dataset_id'=?;"; my $h = $dbh->prepare($analysis_q); $h->execute($dataset_id);