1 use CatalystX
::GlobalContext
qw( $c );
8 use CXGN::BioTools::AGP qw/ agp_contigs agp_contig_seq agp_parse /;
9 use CXGN::TomatoGenome::BACPublish qw/ agp_file /;
13 my $publisher = CXGN::Publish->new;
14 my $bcs = $c->dbic_schema('Bio::Chado::Schema');
16 if( my $contig_name = $cgi->param('contig') ) {
17 $contig_name =~ s/[^\w\.]//g; #< sanitize the contig name
19 my $p = CXGN::Tools::Identifiers::parse_identifier($contig_name,'tomato_bac_contig')
20 or $c->throw( message => "Invalid contig identifier $contig_name", is_error => 0 );
22 my $agp_file_unversioned = agp_file( $p->{chr}, 'unpublished' )
23 or $c->throw( message => 'No AGP file found for chromosome '.$p->{chr} );
25 my $agp_publishing_record = $publisher->publishing_history( $agp_file_unversioned );
26 #$c->throw( message => 'break', developer_message => '<pre>'.Dumper($agp_publishing_record).'</pre>' );
28 # hash of file version => publishing record (which is { version => $num, fullpath => path to file })
29 my %agp_versions = map { $_->{version} => $_ }
30 ( $agp_publishing_record, @{ $agp_publishing_record->{ancestors} || []} );
32 my $agp_file = $agp_versions{ $p->{ver} }->{fullpath}
33 or $c->throw( message => "No AGP file found for chromosome $p->{chr} version $p->{ver}",
34 developer_message => join '', (
36 Dumper({ agp_versions => \%agp_versions,
37 agp_publishing_record => $agp_publishing_record,
38 agp_file_unversioned => $agp_file_unversioned
44 my @contigs = agp_contigs( agp_parse( $agp_file ) );
45 my $contig = $contigs[ $p->{ctg_num} - 1 ]
46 or $c->throw( message => "No contig $p->{ctg_num} found in AGP for chromosome $p->{chr}.$p->{ver}",
47 developer_message => join '', (
49 Dumper({ contigs => \@contigs,
50 contig_count => scalar(@contigs),
51 agp_file => $agp_file,
57 $c->forward_to_mason_view(
58 '/genomes/Solanum_lycopersicum/sequencing/view_contig/view.mas',
60 contig_name => $contig_name,
63 my $feat = $bcs->resultset('Sequence::Feature')->search({name => $seq_name},{rows => 1})->single
64 or $c->throw( message => "Sequence $seq_name not found" );
65 #die Dumper({ name => $feat->id, residues => $feat->seq });
66 return $feat->residues; #< feature acts as a Bio::PrimarySeqI
70 $c->forward_to_mason_view('/genomes/Solanum_lycopersicum/sequencing/view_contig/input.mas');