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

Show analyses on dataset details page #5215

Merged
merged 8 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/source/entries/mixedmodels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
39 changes: 35 additions & 4 deletions lib/CXGN/Dataset.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -448,7 +449,7 @@ sub set_dataset_public {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}
}
}
Expand All @@ -474,7 +475,7 @@ sub set_dataset_private {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}
}
}
Expand Down Expand Up @@ -1258,7 +1259,7 @@ sub delete {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}

}
Expand All @@ -1280,11 +1281,41 @@ sub update_description {
if ($@) {
return "An error occurred, $@";
} else {
return undef;
return;
}
}
}

=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 $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 projectprop
JOIN project USING (project_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);

my @html = ();

while (my ($analysis_name, $analysis_id) = $h->fetchrow_array()){
push @html, "<a href=/analyses/".$analysis_id.">".$analysis_name."</a>";
}

return join(" | ", @html);
}



1;
32 changes: 32 additions & 0 deletions lib/SGN/Controller/AJAX/Dataset.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions mason/analyses/analysis_details.mas
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ $analysis_metadata
</td>
</tr>

<tr><td><b>Dataset ID</b></td>
<tr><td><b>Dataset</b></td>
<td>
<div id="analysis_dataset_id">
% print $analysis_metadata->dataset_id;
% print "<a href=/dataset/".$analysis_metadata->dataset_id.">".$analysis_metadata->dataset_id."</a>";
</div>
</td>
</tr>
Expand Down Expand Up @@ -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" &>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions mason/analyses/model_details.mas
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jQuery(document).ready(function(){
jQuery('#model_name').html("<a href=\"/analyses_model/"+response.model_info.model_id+"\">"+response.model_info.model_name+"</a>");
jQuery('#model_description').html(response.model_info.model_description);
jQuery('#model_type').html(response.model_info.model_type_name);
jQuery('#analysis_dataset_id').html("<a href=\"/dataset/"+response.dataset.dataset_id+"\">"+response.dataset.dataset_name+"</a>");

var model_properties_string = '';
for (var key in response.model_info.model_properties) {
Expand Down
16 changes: 16 additions & 0 deletions mason/dataset/index.mas
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ $dataset_contents => ''
</span>
% }
<tr><td>Select Dataset in Wizard<td><% $wizard_link %>
<tr><td>Analyses using this dataset<td id="dataset_analysis_usage"></td></td>
</table>
</div>
</div>
Expand Down Expand Up @@ -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.");
}
});
});

</script>
Expand Down
13 changes: 12 additions & 1 deletion t/selenium2/breeders/breeder_search.t
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
Loading