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 2cc892d + 6e03f96 commit 0e14fb0
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 1 deletion.
2 changes: 1 addition & 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: v1797
app_version: v1798

schema_version: 35

Expand Down
118 changes: 118 additions & 0 deletions lib/Canto/Chado/FeaturePubLookup.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package Canto::Chado::FeaturePubLookup;

=head1 NAME
Canto::Chado::FeaturePubLookup - Look up publication to feature relations and
sources in Chado
=head1 SYNOPSIS
=head1 AUTHOR
Kim Rutherford C<< <[email protected]> >>
=head1 BUGS
Please report any bugs or feature requests to C<[email protected]>.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Canto::Chado::FeaturePubLookup
=over 4
=back
=head1 COPYRIGHT & LICENSE
Copyright 2024 University of Cambridge, all rights reserved.
Canto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
=head1 FUNCTIONS
=cut

use feature qw(state);

use Moose;

use Canto::Curs::Utils;

with 'Canto::Role::Configurable';
with 'Canto::Chado::ChadoLookup';


=head2 lookup
Usage : my $feature_pub_lookup = Canto::Track::get_adaptor($config, 'feature_pub');
my $results = $allele_lookup->lookup(publication_uniquename => 'PMID:31563844',
feature_type => 'gene')
Function: Look up the features and feature_pub_source props in Chado
Args : publication_uniquename - a PMID
feature_type - a SO term name
Return : [ { gene_uniquename => 'SPBC685.02'
gene_name => 'exo5',
feature_pub_source => 'contig_file_dbxref' }
{ ... },
...
]
=cut

sub lookup
{
my $self = shift;

my %args = @_;

my $publication_uniquename = $args{publication_uniquename};

if (!defined $publication_uniquename) {
die "no publication_uniquename passed to lookup()";
}

my $feature_type = $args{feature_type};
if (!defined $feature_type) {
die "no feature_type parameter passed to lookup()";
}

my $schema = $self->schema();

my $chado_dbh = $schema->storage()->dbh();

my $query = <<'EOQ';
SELECT f.uniquename AS gene_uniquename,
f.name AS gene_name,
fcp.value AS feature_pub_source
FROM feature f
JOIN feature_pub ON feature_pub.feature_id = f.feature_id
JOIN pub ON pub.pub_id = feature_pub.pub_id
JOIN cvterm t ON f.type_id = t.cvterm_id
JOIN feature_pubprop fcp ON fcp.feature_pub_id = feature_pub.feature_pub_id
JOIN cvterm fcpt ON fcp.type_id = fcpt.cvterm_id
WHERE pub.uniquename = ?
AND t.name = ?
AND fcpt.name = 'feature_pub_source'
EOQ

my $sth = $chado_dbh->prepare($query);
$sth->execute($publication_uniquename, $feature_type)
or die "Couldn't execute: " . $sth->errstr;

my @rows = ();

while (my ($gene_uniquename, $gene_name, $feature_pub_source) = $sth->fetchrow_array()) {
push @rows, {
gene_uniquename => $gene_uniquename,
gene_name => $gene_name,
feature_pub_source => $feature_pub_source,
};
}

return @rows;
}

0 comments on commit 0e14fb0

Please sign in to comment.