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`
85 #insert default space and break styles
87 $styles->{space} ||= '<span style="margin: 0 0.5em"></span>';
88 $styles->{break} ||= '<br />';
90 #insert space and break regions
92 if( $subdiv || $width ) {
93 # break every $width bases, and also hash them to use for filtering the spaces
96 : map { $_ *= $width; $_ => ['break',$_] }
97 1..POSIX::floor($seq->length/$width);
98 push @$regions, values %breaks;
100 # spaces every $subdiv bases, except where there is a break already
103 : map { $_ *= $subdiv; $breaks{$_} ? () : ['space',$_] }
104 1..POSIX::floor($seq->length/$subdiv);
109 <span class="sequence">
110 ><% $seq->id %> <% $seq->desc %>
112 <form style="display: inline" method="post" action="<% $blast_url %>">
113 <input type="hidden" name="seq" value="<% '>'.$seq->id.( $seq->desc ? ' '.$seq->desc : '' )."\n".$seq->seq | h %>" />
114 <input style="padding: 1px; line-height: 0.8" type="submit" value="BLAST" />
119 <& /util/markup_string.mas,