Skip to content

Commit

Permalink
Merge branch 'master' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Mar 7, 2024
2 parents 3191a93 + b5254fa commit 2cc892d
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-with-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion canto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion etc/docker-run-tests.sh
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 21 additions & 2 deletions lib/Canto/Controller/Curs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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):) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions lib/Canto/Curs/MetadataStorer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Canto/Role/MetadataAccess.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
65 changes: 65 additions & 0 deletions lib/Canto/Track.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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, );
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/Canto/Track/OntologyLookup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 3 additions & 0 deletions root/curs/modules/ontology.mhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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"></extension-builder>
</div>
</div>
Expand Down Expand Up @@ -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());
}
Expand Down
1 change: 0 additions & 1 deletion root/static/js/canto-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion root/static/ng_templates/term_children.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<div class="curs-box-body">
<ul>
<li ng-repeat="child in termDetails.children">
<a href="#" ng-click="gotoChild(child.id)">{{child.name}}
<a href="#" ng-click="gotoChild(child.id)"
title="{{child.definition}}">{{child.name}}
<img ng-src="{{CantoGlobals.application_root}}/static/images/right_arrow.png"></img>
</a>
</li>
Expand Down

0 comments on commit 2cc892d

Please sign in to comment.