From ff36077adabf4f0738290e5095776f93f134d112 Mon Sep 17 00:00:00 2001 From: afpowell Date: Fri, 13 Mar 2020 22:17:02 +0000 Subject: [PATCH] add ftp and ncbi links to sequenced accession info --- js/source/entries/sequenced_accessions.js | 4 + lib/CXGN/Stock/SequencingInfo.pm | 101 ++++++++++++++----------- lib/SGN/Controller/AJAX/SequencedAccessions.pm | 12 ++- mason/stock/sequencing_status.mas | 12 +++ 4 files changed, 83 insertions(+), 46 deletions(-) diff --git a/js/source/entries/sequenced_accessions.js b/js/source/entries/sequenced_accessions.js index ec22d857c..fe16b8dea 100644 --- a/js/source/entries/sequenced_accessions.js +++ b/js/source/entries/sequenced_accessions.js @@ -68,6 +68,8 @@ function clear_dialog_entries() { jQuery('#publication').val(undefined); jQuery('#jbrowse_link').val(undefined); jQuery('#blast_db_id').val(undefined); + jQuery('#ftp_link').val(undefined); + jQuery('#ncbi_link').val(undefined); jQuery('#stockprop_id').val(undefined); jQuery('#website').val(undefined); } @@ -109,6 +111,8 @@ export function edit_sequencing_info(stockprop_id) { jQuery('#publication').val(r.data.publication); jQuery('#jbrowse_link').val(r.data.jbrowse_link); jQuery('#blast_db_id').val(r.data.blast_db_id); + jQuery('#ftp_link').val(r.data.ftp_link); + jQuery('#ncbi_link').val(r.data.ncbi_link); jQuery('#stockprop_id').val(r.data.stockprop_id); jQuery('#sequencing_status_stock_id').val(r.data.stock_id); jQuery('#website').val(r.data.website); diff --git a/lib/CXGN/Stock/SequencingInfo.pm b/lib/CXGN/Stock/SequencingInfo.pm index 4cef35140..d8f7d8c47 100644 --- a/lib/CXGN/Stock/SequencingInfo.pm +++ b/lib/CXGN/Stock/SequencingInfo.pm @@ -50,6 +50,10 @@ use SGN::Model::Cvterm; =head2 jbrowse_link +=head2 ftp_link + +=head2 ncbi_link + =head2 blast_db_id =head2 sp_person_id @@ -58,7 +62,7 @@ use SGN::Model::Cvterm; =cut - + has 'schema' => (isa => 'Ref', is => 'rw', required => 1); has 'stockprop_id' => (isa => 'Maybe[Int]', is => 'rw'); @@ -87,13 +91,17 @@ has 'publication' => (isa => 'Maybe[Str]', is => 'rw'); has 'jbrowse_link' => (isa => 'Maybe[Str]', is => 'rw'); +has 'ftp_link' => (isa => 'Maybe[Str]', is => 'rw'); + +has 'ncbi_link' => (isa => 'Maybe[Str]', is => 'rw'); + has 'blast_db_id' => (isa => 'Maybe[Int]', is => 'rw'); has 'sp_person_id' => (isa => 'Maybe[Int]', is => 'rw'); has 'timestamp' => (isa => 'Maybe[Str]', is => 'rw'); -has 'allowed_fields' => (isa => 'Ref', is => 'ro', default => sub { [ qw | organization website genbank_accession funded_by funder_project_id contact_email sequencing_year publication jbrowse_link blast_db_id stockprop_id stock_id sp_person_id timestamp | ] } ); +has 'allowed_fields' => (isa => 'Ref', is => 'ro', default => sub { [ qw | organization website genbank_accession funded_by funder_project_id contact_email sequencing_year publication jbrowse_link ftp_link ncbi_link blast_db_id stockprop_id stock_id sp_person_id timestamp | ] } ); sub BUILD { @@ -114,7 +122,7 @@ sub BUILD { =head2 Class methods - + =head2 get_sequencing_project_infos($schema, $stock_id) @@ -127,28 +135,28 @@ sub BUILD { =cut -sub get_sequencing_project_infos { +sub get_sequencing_project_infos { my $class = shift; my $schema = shift; my $stock_id = shift; - + my @stockprops = $class->_retrieve_stockprops($schema, $stock_id, "sequencing_project_info"); - + print STDERR "Stockprops = ".Dumper(\@stockprops); - + my @infos = (); foreach my $sp (@stockprops) { my $hash; - + my $json = $sp->[1]; - - eval { + + eval { $hash = JSON::Any->jsonToObj($json); }; $hash->{stockprop_id} = $sp->[0]; $hash->{uniquename} = $schema->resultset("Stock::Stock")->find( { stock_id => $stock_id })->uniquename(); - if ($@) { - print STDERR "Warning: $json is not valid json in stockprop ".$sp->[0].".!\n"; + if ($@) { + print STDERR "Warning: $json is not valid json in stockprop ".$sp->[0].".!\n"; } push @infos, $hash; } @@ -162,7 +170,7 @@ sub get_sequencing_project_infos { Usage: @sequenced_stocks = CXGN::Stock->sequenced_stocks(); Desc: Ret: - Args: + Args: Side Effects: Example: @@ -171,13 +179,13 @@ sub get_sequencing_project_infos { sub all_sequenced_stocks { my $class = shift; my $schema = shift; - + print STDERR "all_sequenced_stocks with ".ref($schema)." as parameter...\n"; my $type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'sequencing_project_info', 'stock_property')->cvterm_id(); print STDERR "type_id = $type_id\n"; my $sp_rs = $schema->resultset("Stock::Stockprop")->search({ type_id => $type_id }); - + my @sequenced_stocks = (); while (my $row = $sp_rs->next()) { print STDERR "found stock with stock_id ".$row->stock_id()."\n"; @@ -194,7 +202,7 @@ sub all_sequenced_stocks { Usage: $s->set_sequencing_project_info($si, $stockprop_id) Desc: creates a sequencing project info in the stockprop - Ret: + Ret: Args: a CXGN::Stock::SequencingInfo object, and an optional stockprop_id (which will trigger an update instead of insert) @@ -219,7 +227,7 @@ sub store { $row->update(); } } - else { + else { # insert #get highest rank from previous inserts... @@ -227,24 +235,24 @@ sub store { my $rank = $rs->get_column("rank")->max(); $rank++; - + print STDERR "inserting stockprop...\n"; - my $row = $self->schema()->resultset("Stock::Stockprop")->create( - { - stock_id => $self->stock_id(), - type_id => $self->type_id(), + my $row = $self->schema()->resultset("Stock::Stockprop")->create( + { + stock_id => $self->stock_id(), + type_id => $self->type_id(), value => $self->to_json(), rank => $rank, - + }); $self->stockprop_id($row->stockprop_id()); $self->stock_id($row->stock_id()); return $row->stockprop_id(); } - + } - + =head2 method delete() Usage: @@ -263,15 +271,15 @@ sub delete { my $stockprop; print STDERR "stock_id = ".$self->stock_id().", stockprop_id = ".$self->stockprop_id()."\n"; - - eval { + + eval { $stockprop = $self->schema()->resultset("Stock::Stockprop")->find({ type_id=>$self->type_id(), stock_id => $self->stock_id(), stockprop_id=>$self->stockprop_id() }); }; - if ($@) { - die "Delete failed!\n"; + if ($@) { + die "Delete failed!\n"; } - + if (!$stockprop) { print STDERR "No such stockprop associated with such type or stock. Not deleting.\n"; return 0; @@ -304,11 +312,11 @@ sub _load_object { print STDERR "configuring object...\n"; my $stockprop_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema, $self->type(), 'stock_property')->cvterm_id(); my $rs = $self->schema->resultset("Stock::Stockprop")->search({ stockprop_id => $self->stockprop_id(), type_id => $stockprop_type_id } ); - + if ($rs->count() == 0) { die "No stockprops could be retrieved." } - + my $row = $rs->next(); # should only be one - + $self->type_id($stockprop_type_id); $self->stock_id($row->stock_id()); $self->from_json($row->value()); @@ -334,12 +342,12 @@ sub _retrieve_stockprops { my $schema = shift; my $stock_id = shift; my $type = shift; - + my @results; print STDERR "_retrieve_stockprops...\n"; - - eval { + + eval { my $stockprop_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, $type, 'stock_property')->cvterm_id(); my $rs = $schema->resultset("Stock::Stockprop")->search({ stock_id => $stock_id, type_id => $stockprop_type_id }, { order_by => {-asc => 'stockprop_id'} }); @@ -393,7 +401,7 @@ sub from_hash { my $allowed_fields = $self->allowed_fields(); print STDERR Dumper($hash); - + foreach my $f (@$allowed_fields) { print STDERR "Processing $f ($hash->{$f})...\n"; if ( ($hash->{$f} eq "undefined") || ($hash->{$f} eq "") ) { $hash->{$f} = undef; } @@ -414,14 +422,14 @@ sub from_hash { sub to_json { my $self = shift; - + my $allowed_fields = $self->allowed_fields(); print STDERR Dumper($allowed_fields); my $data; - + foreach my $f (@$allowed_fields) { - if (defined($self->$f())) { + if (defined($self->$f())) { $data->{$f} = $self->$f(); } } @@ -464,10 +472,10 @@ sub to_hashref { sub validate { my $self = shift; - + my @errors = (); my @warnings = (); - + # check keys in the info hash... if (!defined($self->sequencing_year())) { push @errors, "Need year for sequencing project"; @@ -487,6 +495,12 @@ sub validate { if (!defined($self->jbrowse_link())) { push @warnings, "Need jbrowse link for sequencing project"; } + if (!defined($self->ftp_link())) { + push @warnings, "Need jbrowse link for sequencing project"; + } + if (!defined($self->ncbi_link())) { + push @warnings, "Need jbrowse link for sequencing project"; + } if (@errors) { die join("\n", @errors); @@ -496,6 +510,3 @@ sub validate { 1; - - - diff --git a/lib/SGN/Controller/AJAX/SequencedAccessions.pm b/lib/SGN/Controller/AJAX/SequencedAccessions.pm index ccfa08735..7b5394b65 100644 --- a/lib/SGN/Controller/AJAX/SequencedAccessions.pm +++ b/lib/SGN/Controller/AJAX/SequencedAccessions.pm @@ -78,6 +78,16 @@ sub retrieve_sequencing_infos { $jbrowse_link = qq | JBrowse |; } + my $ftp_link = "FTP"; + if ($info->{ftp_link}) { + $ftp_link = qq | FTP |; + } + + my $ncbi_link = "NCBI"; + if ($info->{ncbi_link}) { + $ncbi_link = qq | NCBI |; + } + my $delete_link_js = "window.jsMod['sequenced_accessions'].delete_sequencing_info(".$info->{stockprop_id}.");"; my $edit_link_js = "window.jsMod['sequenced_accessions'].edit_sequencing_info(".$info->{stockprop_id}.");"; @@ -93,7 +103,7 @@ sub retrieve_sequencing_infos { $info->{sequencing_year}, $info->{organization}, $website, - $blast_link." | ".$jbrowse_link, + $blast_link." | ".$jbrowse_link." | ".$ftp_link." | ".$ncbi_link, $edit_delete_html, ]; } diff --git a/mason/stock/sequencing_status.mas b/mason/stock/sequencing_status.mas index 3ee60cfc4..9e1c9faa1 100644 --- a/mason/stock/sequencing_status.mas +++ b/mason/stock/sequencing_status.mas @@ -76,6 +76,18 @@ $stock_id
+
+ +
+
+
+
+
+ +
+
+
+
-- 2.11.4.GIT