Merge pull request #5069 from solgenomics/topic/accession_upload_file
[sgn.git] / cgi-bin / tools / sixframe_translate.pl
blob71a4bfda3427e2b5ef1a7fd0e46a4d234ca9344b
1 use CatalystX::GlobalContext qw( $c );
2 # instead of linking to this, consider just embedding the translations
3 # directly into the relevant detail page
5 use strict;
6 use warnings;
8 use CGI;
9 use Bio::PrimarySeq;
11 my $cgi = CGI->new;
12 my $seq = get_legacy_est( $cgi ) || get_legacy_unigene( $cgi ) || get_direct_seq( $cgi )
13 or $c->throw( message => 'No sequence found.', is_error => 0 );
15 $c->forward_to_mason_view( '/tools/sixframe_translate_standalone.mas',
16 seq => $seq,
17 blast_url => '/tools/blast'
21 # ========= helper functions =======
23 sub get_legacy_est {
24 my ($cgi) = @_;
26 my $sp_person_id = $c->user() ? $c->user->get_object()->get_sp_person_id() : undef;
28 my $est_id = $cgi->param('est_id')
29 or return;
31 my $est = $c->dbic_schema('SGN::Schema', undef, $sp_person_id)
32 ->resultset('Est')
33 ->find( $est_id )
34 or return;
36 return Bio::PrimarySeq->new( -id => "SGN-E".($est_id+0),
37 -seq => $est->hqi_seq,
41 sub get_legacy_unigene {
42 my ($cgi) = @_;
44 my $sp_person_id = $c->user() ? $c->user->get_object()->get_sp_person_id() : undef;
46 my $unigene_id = $cgi->param('unigene_id')
47 or return;
49 my $unigene = $c->dbic_schema('SGN::Schema', undef, $sp_person_id)
50 ->resultset('Unigene')
51 ->find( $unigene_id )
52 or return;
54 return Bio::PrimarySeq->new( -id => 'SGN-U'.( $unigene_id+0 ),
55 -seq => $unigene->seq,
59 sub get_direct_seq {
60 my ($cgi) = @_;
62 my $seq = $cgi->param('seq')
63 or return;
65 my ( $seqid, $sequence ) = split '#', $seq;
66 return Bio::PrimarySeq->new( -id => $seqid, -seq => $seq );