diff --git a/.github/workflows/test-with-docker.yml b/.github/workflows/test-with-docker.yml index d25f3ca4b..f30306946 100644 --- a/.github/workflows/test-with-docker.yml +++ b/.github/workflows/test-with-docker.yml @@ -17,6 +17,6 @@ jobs: steps: - uses: actions/checkout@v3 - name: pull base image - run: docker pull pombase/canto-base:v14 + run: docker pull pombase/canto-base:v17 - name: run make test inside a Docker container run: ./etc/docker-run-tests.sh diff --git a/canto.yaml b/canto.yaml index 9e594f69f..717a5d4e6 100644 --- a/canto.yaml +++ b/canto.yaml @@ -25,7 +25,7 @@ header_image: logos/curation_tool.png canto_url: https://curation.pombase.org/ -app_version: v1789 +app_version: v1797 schema_version: 35 @@ -1462,6 +1462,10 @@ implementation_classes: organism_adaptor: Canto::Track::OrganismLookup strain_adaptor: Canto::Track::StrainLookup +# Possible values for "feature_pub_source" in Chado when pre-populating +# sessions. Ignored if the feature_pub_lookup adaptor isn't configured. +feature_pub_sources: [] + wildtype_name_template: '@@gene_display_name@@+' deletion_name_template: '@@gene_display_name@@delta' transformant_name_template: '@@gene_display_name@@ transformant' diff --git a/etc/docker-run-tests.sh b/etc/docker-run-tests.sh index 2f2cc4cfa..027e3f402 100755 --- a/etc/docker-run-tests.sh +++ b/etc/docker-run-tests.sh @@ -1,4 +1,4 @@ #!/bin/sh - docker run --rm --net="host" --mount type=bind,source=$(pwd)/,target=/canto -w=/canto \ - pombase/canto-base:v15 /bin/bash -c "cd /canto && perl Makefile.PL && make test" + pombase/canto-base:v17 /bin/bash -c "cd /canto && perl Makefile.PL && make test" diff --git a/lib/Canto/Controller/Curs.pm b/lib/Canto/Controller/Curs.pm index 64dfc8cf0..ea8b06db9 100644 --- a/lib/Canto/Controller/Curs.pm +++ b/lib/Canto/Controller/Curs.pm @@ -216,8 +216,8 @@ sub top : Chained('/') PathPart('curs') CaptureArgs(1) $st->{submitter_email} = $submitter_email; $st->{submitter_name} = $submitter_name; - $st->{message_to_curators} = - $self->get_metadata($schema, MESSAGE_FOR_CURATORS_KEY); + my $message_to_curators = $self->get_metadata($schema, MESSAGE_FOR_CURATORS_KEY); + $st->{message_to_curators} = $message_to_curators; my $external_notes = $self->get_metadata($schema, Canto::Curs->EXTERNAL_NOTES_KEY); @@ -258,6 +258,12 @@ sub top : Chained('/') PathPart('curs') CaptureArgs(1) $st->{current_user_is_admin} = 0; } + if ($st->{current_user_is_admin} && + ($state eq NEEDS_APPROVAL || $state eq APPROVAL_IN_PROGRESS || $state eq APPROVED) && + defined $message_to_curators && $message_to_curators !~ /^\s*$/) { + push @{$st->{notice}}, qq|This session has a message to curators|; + } + if ($config->{canto_offline} && !$st->{read_only_curs} && (!defined $current_user || !$current_user->is_admin()) && $path !~ m:/(ws/\w+/list):) { @@ -341,6 +347,19 @@ sub top : Chained('/') PathPart('curs') CaptureArgs(1) $use_dispatch = 0; } + if ($state eq CURATION_IN_PROGRESS) { + my $existing_genes = + $self->get_metadata($schema, Canto::Curs::MetadataStorer::SESSION_HAS_EXISTING_GENES); + + if (defined $existing_genes) { + $self->unset_metadata($schema, Canto::Curs::MetadataStorer::SESSION_HAS_EXISTING_GENES); + my $pub_uniquename = $st->{pub}->uniquename(); + push @{$st->{message}}, qq|Warning: this session has been populated with $pub_uniquename genes known from other sources. Use the "Add more genes from $pub_uniquename" link to add missing genes|; + $c->detach('edit_genes'); + $use_dispatch = 0; + } + } + if ($use_dispatch) { my $dispatch_dest = $state_dispatch{$state}; if (defined $dispatch_dest) { diff --git a/lib/Canto/Curs/MetadataStorer.pm b/lib/Canto/Curs/MetadataStorer.pm index 3cd32b74a..796809447 100644 --- a/lib/Canto/Curs/MetadataStorer.pm +++ b/lib/Canto/Curs/MetadataStorer.pm @@ -51,6 +51,12 @@ has state => (is => 'ro', init_arg => undef, isa => 'Canto::Curs::State', lazy_build => 1); +use constant { + # the session was pre-populated with genes from Chado associated with + # the publication + SESSION_HAS_EXISTING_GENES => "session_has_existing_genes", +}; + sub _build_state { my $self = shift; diff --git a/lib/Canto/Role/MetadataAccess.pm b/lib/Canto/Role/MetadataAccess.pm index 7d0d5fdfe..f67a552ef 100644 --- a/lib/Canto/Role/MetadataAccess.pm +++ b/lib/Canto/Role/MetadataAccess.pm @@ -58,7 +58,7 @@ sub my $self = shift; if (@_ < 3) { - croak "not enough arguments to get_metadata()"; + croak "not enough arguments to set_metadata()"; } my $schema = shift; diff --git a/lib/Canto/Track.pm b/lib/Canto/Track.pm index d48685b13..2b2f6e553 100644 --- a/lib/Canto/Track.pm +++ b/lib/Canto/Track.pm @@ -96,6 +96,69 @@ sub create_curs return ($curs, $curs_db); } +=head2 + + Usage : lookup_and_store_chado_genes($config, $curs_schema, $pub); + Function: If Chado is configured, lookup any genes that are known from + PMID keywords or other source (see feature_pub_sources in + config.yaml) + Args : + Returns : + +=cut + +sub lookup_and_store_chado_genes +{ + my ($config, $state, $curs_schema, $pub_uniquename) = @_; + + my $feature_pub_lookup = Canto::Track::get_adaptor($config, 'feature_pub'); + + if (!defined $feature_pub_lookup) { + return; + } + + my $taxonid; + + my $instance_organism = $config->{instance_organism}; + + if (defined $instance_organism) { + $taxonid = $instance_organism->{taxonid}; + } else { + return; + } + + my @results = $feature_pub_lookup->lookup(publication_uniquename => $pub_uniquename, + feature_type => 'gene'); + + if (@results == 0) { + return; + } + + my @feature_pub_sources = @{$config->{feature_pub_sources}}; + + my %genes_to_add = (); + + map { + my $row = $_; + + if (grep { $row->{feature_pub_source} eq $_ } @feature_pub_sources) { + $genes_to_add{$row->{gene_uniquename}} = 1; + } + } @results; + + my $organism = + Canto::CursDB::Organism::get_organism($curs_schema, $taxonid); + + for my $gene_uniquename (keys %genes_to_add) { + $curs_schema->create_with_type('Gene', { + primary_identifier => $gene_uniquename, + organism => $organism, + }); + } + + $state->set_metadata($curs_schema, Canto::Curs::MetadataStorer::SESSION_HAS_EXISTING_GENES, scalar(keys %genes_to_add)); +} + =head2 create_curs_db Usage : Canto::Track::create_curs_db($config, $curs_object, ); @@ -179,6 +242,8 @@ sub create_curs_db my $state = Canto::Curs::State->new(config => $config); $state->store_statuses($curs_schema); + lookup_and_store_chado_genes($config, $state, $curs_schema, $pub->uniquename()); + if (wantarray) { return ($curs_schema, $db_file_name); } else { diff --git a/lib/Canto/Track/OntologyLookup.pm b/lib/Canto/Track/OntologyLookup.pm index 42a6781ba..4acb4909d 100644 --- a/lib/Canto/Track/OntologyLookup.pm +++ b/lib/Canto/Track/OntologyLookup.pm @@ -190,7 +190,7 @@ sub _make_term_hash if (!$seen{$child_cvterm->cvterm_id()}) { push @child_hashes, {$self->_make_term_hash($child_cvterm, - $child_cvterm->cv()->name(), 0, 0, 0, undef)}; + $child_cvterm->cv()->name(), 1, 0, 0, undef)}; $seen{$child_cvterm->cvterm_id()} = 1; } } diff --git a/root/curs/modules/ontology.mhtml b/root/curs/modules/ontology.mhtml index 8a348eefc..53b211fb1 100644 --- a/root/curs/modules/ontology.mhtml +++ b/root/curs/modules/ontology.mhtml @@ -59,6 +59,7 @@ Annotation extensions term-id="{{currentTerm()}}" is-valid="extensionBuilderIsValid" annotation-type-name="<% $annotation_type_name %>" + gene-systematic-id="<% $gene_systematic_id %>" feature-type="finalFeatureType"> @@ -95,8 +96,10 @@ Annotation extensions <%init> my $feature_display_name; +my $gene_systematic_id = ''; if ($feature_type eq 'gene') { $feature_display_name = $feature->display_name(); + $gene_systematic_id = $feature->primary_identifier(); } else { $feature_display_name = $feature->display_name($c->config()); } diff --git a/root/static/js/canto-modules.js b/root/static/js/canto-modules.js index 80ee1067b..412ee0e77 100644 --- a/root/static/js/canto-modules.js +++ b/root/static/js/canto-modules.js @@ -4289,7 +4289,6 @@ var alleleEditDialogCtrl = const alleleType = $scope.alleleData.type.trim(); if (!qcUrl || !$scope.current_type_config || - !$scope.userIsAdmin || !$scope.current_type_config.check_description_with_api) { $scope.descriptionState = 'ok'; return $q.when(null); diff --git a/root/static/ng_templates/term_children.html b/root/static/ng_templates/term_children.html index 7c07a26bd..31b621b5e 100644 --- a/root/static/ng_templates/term_children.html +++ b/root/static/ng_templates/term_children.html @@ -11,7 +11,8 @@