4 $max_display_size => 50_000
10 #my @locs = $feature->featureloc_features(undef,{ prefetch => 'srcfeature' });
11 my @locs = $feature->featureloc_features({locgroup => 0,},{ prefetch => 'srcfeature' });
12 for my $loc ( @locs ) {
13 if( my $src = $loc->srcfeature ) {
15 my $has_seq = $src->subseq(1,1);
19 <div style="margin: 1em 3em">
21 # if the sequence is small enough to display
22 if( $loc->fmax - $loc->fmin <= $max_display_size ) {
24 my $seq = $src->trunc( $loc->fmin+1, $loc->fmax );
25 $seq->desc( location_string( $loc ) );
26 if( $loc->strand && $loc->strand == -1 ) {
28 $seq->desc( $seq->desc.' (sequence from reverse strand)' );
31 $seq->id( $feature->name );
35 <& /sequence/with_markup.mas,
39 blast_url => $blast_url,
42 % } else { # otherwise, if the sequence is big
43 <p class="warning">Sequence region (<% location_string_html($loc) %>) too large to display.</p>
45 % my ( $start, $end ) = $loc->strand == -1 ? ( $loc->fmax, $loc->fmin+1 ) : ( $loc->fmin+1, $loc->fmax );
47 __tableattrs => 'width="100%"',
49 'Download sequence region' => $m->scomp(
50 '/feature/sequence_download.mas',
52 length => $loc->fmax - $loc->fmin,
53 download_url => '/api/v1/sequence/download/single/'.$src->feature_id.".fasta?$start..$end",
55 'Get flanking sequences on '.($src->name || 'feature_'.$src->feature_id) =>
56 $m->scomp('.flanking_download', loc => $loc ),
65 use SGN::View::Feature qw/ location_string location_string_html /;
66 use List::Util qw/ min max /;
67 use List::MoreUtils qw/ pairwise /;
68 use CXGN::Page::FormattingHelpers 'info_table_html';
70 sub upstream_downstream_options {
73 my $id = $loc->srcfeature->feature_id;
74 my $start = $loc->fmin+1;
76 my $strand = $loc->strand;
77 my $src_length = $loc->srcfeature->length || 1e20;
79 my @increments = ( 1000, 3000, 5000 );
81 # calculate location strings for upstream and downstream regions
85 max( 1, $start - $_ ),
94 min( $end + 1, $src_length ),
95 min( $end + $_, $src_length ),
100 # upstream/downstream sense is reversed if feature is on the
102 if( $strand == -1 ) {
103 ( $upstream, $downstream ) = ( $downstream, $upstream );
106 # decorate the upstream/downstream loc strings with text
107 # descriptions for the dropdown
108 my @upstream_desc = map "$_ bp upstream", @increments;
109 my @downstream_desc = map "$_ bp downstream", @increments;
110 $upstream = [ pairwise { [$a, $b] } @$upstream, @upstream_desc ];
111 $downstream = [ pairwise { [$a, $b] } @$downstream, @downstream_desc ];
113 return ( reverse(@$upstream), @$downstream );
118 <%def .flanking_download>
122 <form name="get_flanking_sequence" action="/api/v1/sequence/download/multi" method="GET">
123 <input type="hidden" name="format" value="fasta" />
125 % for ( upstream_downstream_options( $loc ) ) {
126 % my ( $locstring, $description ) = @$_;
127 <option value="<% $locstring %>"><% $description %></option>
130 <input value="Download" type="submit" />