5 sequence/with_markup.mas - display a sequence formatted on the client
6 side with Text.Markup javascript
12 The L<Bio::PrimarySeqI> to display.
16 The width at which to line-break the sequence, default 80, set 0 or
21 The number of bases at which to subdivide the sequence into groups,
22 default 10, set 0 or undef to disable.
26 Hashref of Text.Markup styles for use on the sequence. Styles can be
27 either single strings, which will insert that string at the given
28 (single) coordinate, or arrayrefs of two strings that will be inserted
29 at either side of a region. Note that this component will add 'break'
30 and 'space' styles to your styles if you don't already have them,
31 which are defined as in the example below.
33 Example styles definition:
35 { methionine => ['<span class="methionine">','</span>'],
36 stop_codon => ['<b>','</b>'],
43 Text.Markup regions to apply the styles onto. Regions coordinates are
44 numbered using space-oriented coordinates, which means that start=0
45 means to insert in front of the first base pair, and an end equal to
46 the sequence length will insert after the last base pair:
48 0 1 2 3 4 5 6 7 perl string coordinates (0-based)
49 1 2 3 4 5 6 7 8 sequence coordinates (1-based)
50 g a t c g a t c sequence
51 0 1 2 3 4 5 6 7 8 space coordinates
53 Example regions (using example styles above):
55 [ ['methionine', 23,24], #< highlight the single base at index 23
56 #< (the 24th base) with the methionine style
58 ['orf', 23,54 ], #< highlight bases 24-54 with the ORF style
60 ['break', 43 ], #< insert the string from the 'break' style before
66 If passed, will provide a 'BLAST' button that will POST the sequence
67 to the given URL as `seq`
77 % if( $seq->length > 50_000 ) {
78 <span class="sequence">
79 ><% $seq->id %> <% $seq->desc %>
80 <br /><span class="warning">Sequence too large to display.</span>
83 <& .really_display, %ARGS &>
86 <%def .really_display>
100 #insert default space and break styles
102 $styles->{space} ||= '<span style="margin: 0 0.5em"></span>';
103 $styles->{break} ||= '<br />';
105 #insert space and break regions
107 if( $subdiv || $width ) {
108 # break every $width bases, and also hash them to use for filtering the spaces
111 : map { $_ *= $width; $_ => ['break',$_] }
112 1..POSIX::floor($seq->length/$width);
113 push @$regions, values %breaks;
115 # spaces every $subdiv bases, except where there is a break already
118 : map { $_ *= $subdiv; $breaks{$_} ? () : ['space',$_] }
119 1..POSIX::floor($seq->length/$subdiv);
124 <span class="sequence">
125 ><% $seq->id %> <% $seq->desc %>
127 <form style="display: inline" method="post" action="<% $blast_url %>">
128 <input type="hidden" name="seq" value="<% '>'.$seq->id."\n".$seq->seq | h %>" />
129 <input style="padding: 1px; line-height: 0.8" type="submit" value="BLAST" />
134 <& /util/markup_string.mas,