| 1 | #!/usr/local/bin/perl -w | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | frend.pl -- Render a Bio::Graphics Feature File on the web | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | http://your.host.com/cgi-bin/frend.pl | ||
| 10 | |||
| 11 | =head1 DESCRIPTION | ||
| 12 | |||
| 13 | The frend.pl script is a thin front end around the Bio::Graphics | ||
| 14 | module. It accepts a list of files containing sequence (protein, | ||
| 15 | nucleotide) feature coordinates from the file(s) listed on the command | ||
| 16 | line or on standard input, renders them, and produces a PNG file on | ||
| 17 | standard output. | ||
| 18 | |||
| 19 | =head1 INSTALLATION | ||
| 20 | |||
| 21 | Copy this script into your web site's cgi-bin directory. Name it | ||
| 22 | whatever you want. | ||
| 23 | |||
| 24 | =head1 Feature Files Format | ||
| 25 | |||
| 26 | This script accepts and processes sequence annotations in a simple | ||
| 27 | tab-delimited format or in GFF format. | ||
| 28 | |||
| 29 | The feature file format has a configuration section and a data | ||
| 30 | section. The configuration section sets up the size and overall | ||
| 31 | properties of the image, and the data section gives the feature | ||
| 32 | data itself. | ||
| 33 | |||
| 34 | =head2 Configuration Section | ||
| 35 | |||
| 36 | If not provided, this scripts generates a reasonable default | ||
| 37 | configuration section for you, so you do not need to provide a | ||
| 38 | configuration section to get a reasonable image. However, to tune the | ||
| 39 | appearance of the image, you will probably want to tweak the | ||
| 40 | configuration. Here is an excerpt from the configuration section: | ||
| 41 | |||
| 42 | |||
| 43 | # example file | ||
| 44 | [general] | ||
| 45 | bases = -1000..21000 | ||
| 46 | height = 12 | ||
| 47 | |||
| 48 | [EST] | ||
| 49 | glyph = segments | ||
| 50 | bgcolor= yellow | ||
| 51 | connector = solid | ||
| 52 | height = 5 | ||
| 53 | |||
| 54 | [FGENES] | ||
| 55 | glyph = transcript2 | ||
| 56 | bgcolor = green | ||
| 57 | description = 1 | ||
| 58 | |||
| 59 | |||
| 60 | The configuration section is divided into a set of sections, each one | ||
| 61 | labeled with a [section title]. The [general] section specifies global | ||
| 62 | options for the entire image. Other sections apply to particular | ||
| 63 | feature types. In the example above, the configuration in the [EST] | ||
| 64 | section applies to features labeled as ESTs, while the configuration | ||
| 65 | in the [FGENES] section applies to features labeled as predictions | ||
| 66 | from the FGENES gene prediction program. | ||
| 67 | |||
| 68 | Inside each section is a series of name=value pairs, where the name is | ||
| 69 | the name of an option to set. You can put whitespace around the = sign | ||
| 70 | to make it more readable, or even use a colon (:) if you prefer. The | ||
| 71 | following option names are recognized: | ||
| 72 | |||
| 73 | Option Value Example | ||
| 74 | ------ ----- ------- | ||
| 75 | |||
| 76 | bases Min & max of the sequence range (bp) 1200..60000 | ||
| 77 | width width of the image (pixels) 600 | ||
| 78 | height Height of each graphical element (pixels) 10 | ||
| 79 | glyph Style of each graphical element (see below) transcript | ||
| 80 | fgcolor Foreground color of each element yellow | ||
| 81 | bgcolor Background color of each element blue | ||
| 82 | linewidth Width of lines 3 | ||
| 83 | label Print the feature's name 1 | ||
| 84 | description Whether to print the feature's description 0 | ||
| 85 | bump Elements are not allowed to collide 1 | ||
| 86 | ticks Print tick marks on arrows 1 | ||
| 87 | connector Type of group connector (dashed, hat or solid) dashed | ||
| 88 | |||
| 89 | The "bases" and "width" options are only relevant in the [general] | ||
| 90 | section. They are overridden by the like-named command-line options. | ||
| 91 | |||
| 92 | The remainder of the options can be located in any section, but if | ||
| 93 | present in the [general] section will set defaults for the others. | ||
| 94 | |||
| 95 | Colors are English-language color names or Web-style #RRGGBB colors | ||
| 96 | (see a book on HTML for an explanation). True/false values are 1 for | ||
| 97 | true, and 0 for false. Numeric ranges can be expressed in start..end | ||
| 98 | fashion with two dots, or as start-end with a hyphen. | ||
| 99 | |||
| 100 | The "glyph" option controls how the features are rendered. The | ||
| 101 | following glyphs are implemented: | ||
| 102 | |||
| 103 | Name Description | ||
| 104 | ---- ----------- | ||
| 105 | |||
| 106 | box A filled rectangle, nondirectional. | ||
| 107 | ellipse An oval. | ||
| 108 | arrow An arrow; can be unidirectional or | ||
| 109 | bidirectional. It is also capable of displaying | ||
| 110 | a scale with major and minor tickmarks, and can | ||
| 111 | be oriented horizontally or vertically. | ||
| 112 | segments A set of filled rectangles connected by solid | ||
| 113 | lines. Used for interrupted features, such as | ||
| 114 | gapped alignments and exon groups. | ||
| 115 | transcript Similar to segments, but the connecting line is | ||
| 116 | a "hat" shape, and the direction of | ||
| 117 | transcription is indicated by a small arrow. | ||
| 118 | transcript2 Similar to transcript, but the direction of | ||
| 119 | transcription is indicated by a terminal segment | ||
| 120 | in the shape of an arrow. | ||
| 121 | primers Two inward pointing arrows connected by a line. Used for STSs. | ||
| 122 | |||
| 123 | The bump option is the most important option for controlling the look | ||
| 124 | of the image. If set to false (the number 0), then the features are | ||
| 125 | allowed to overlap. If set to true (the number 1), then the features | ||
| 126 | will move vertically to avoid colliding. If not specified, bump is | ||
| 127 | turned on if the number of any given type of sequence feature is | ||
| 128 | greater than 50. | ||
| 129 | |||
| 130 | =head2 Data Section | ||
| 131 | |||
| 132 | The data section can follow or proceed the configuration section. The | ||
| 133 | two sections can also be intermixed. The data section is a tab or | ||
| 134 | whitespace-delimited file which you can export from a spreadsheet | ||
| 135 | application or word processor file (be sure to save as text only!) | ||
| 136 | |||
| 137 | Here is an example data section: | ||
| 138 | |||
| 139 | |||
| 140 | Cosmid B0511 . 516-619 | ||
| 141 | Cosmid B0511 . 3185-3294 | ||
| 142 | Cosmid B0511 . 10946-11208 | ||
| 143 | Cosmid B0511 . 13126-13511 | ||
| 144 | Cosmid B0511 . 66-208 | ||
| 145 | Cosmid B0511 . 6354-6499 | ||
| 146 | Cosmid B0511 . 13955-14115 | ||
| 147 | EST yk595e6.5 + 3187-3294 | ||
| 148 | EST yk846e07.3 - 11015-11208 | ||
| 149 | EST yk53c10 | ||
| 150 | yk53c10.5 + 18892-19154 | ||
| 151 | yk53c10.3 - 15000-15500,15700-15800 | ||
| 152 | EST yk53c10.5 + 16032-16105 | ||
| 153 | SwissProt PECANEX + 13153-13656 Swedish fish | ||
| 154 | FGENESH "Gene 1" - 1-205,518-616,661-735,3187-3365,3436-3846 Transmembrane domain | ||
| 155 | FGENESH "Gene 2" - 16626-17396,17451-17597 Kinase and sushi domains | ||
| 156 | |||
| 157 | |||
| 158 | Each line of the file contains five columns. The columns are: | ||
| 159 | |||
| 160 | Column # Description | ||
| 161 | -------- ----------- | ||
| 162 | |||
| 163 | 1 feature type | ||
| 164 | 2 feature name | ||
| 165 | 3 strand | ||
| 166 | 4 coordinates | ||
| 167 | 5 description | ||
| 168 | |||
| 169 | =over 4 | ||
| 170 | |||
| 171 | =item Feature type | ||
| 172 | |||
| 173 | The feature type should correspond to one of the [feature type] | ||
| 174 | headings in the configuration section. If it doesn't, the [general] | ||
| 175 | options will be applied to the feature when rendering it. The feature | ||
| 176 | name is a name for the feature. Use a "." or "-" if this is not | ||
| 177 | relevant. If the name contains whitespace, put single or double quotes | ||
| 178 | ("") around the name. | ||
| 179 | |||
| 180 | =item Strand | ||
| 181 | |||
| 182 | The strand indicates which strand the feature is on. It is one of "+" | ||
| 183 | for the forward strand, "-" for the reverse strand, or "." for | ||
| 184 | features that are not stranded. | ||
| 185 | |||
| 186 | =item Coordinates | ||
| 187 | |||
| 188 | The coordinates column is a set of one or more ranges that the feature | ||
| 189 | occupies. Ranges are written using ".." as in start..stop, or with | ||
| 190 | hyphens, as in start-stop. For features that are composed of multiple | ||
| 191 | ranges &em; for example transcripts that have multiple exons &em; you | ||
| 192 | can either put the ranges on the same line separated by commas or | ||
| 193 | spaces, or put the ranges on individual lines and just use the same | ||
| 194 | feature name and type to group them. In the example above, the Cosmid | ||
| 195 | B0511 features use the individual line style, while the FGENESH | ||
| 196 | features use the all-ranges-on-one-line style. | ||
| 197 | |||
| 198 | =item Description | ||
| 199 | |||
| 200 | The last column contains some descriptive text. If the description | ||
| 201 | option is set to true, this text will be printed underneath the | ||
| 202 | feature in the rendering. | ||
| 203 | |||
| 204 | =back | ||
| 205 | |||
| 206 | Finally, it is possible to group related features together. An example | ||
| 207 | is the ESTs yk53c10.5 and yk53c10.3, which are related by being reads | ||
| 208 | from the two ends of the clone yk53c10. To indicate this relationship, | ||
| 209 | generate a section that looks like this: | ||
| 210 | |||
| 211 | EST yk53c10 | ||
| 212 | yk53c10.5 + 18892-19154 | ||
| 213 | yk53c10.3 - 15000-15500,15700-15800 | ||
| 214 | |||
| 215 | |||
| 216 | The group is indicated by a line that contains just two columns | ||
| 217 | containing the feature type and a unique name for the group. Follow | ||
| 218 | this line with all the features that form the group, but leave the | ||
| 219 | first column (the feature type) blank. The group will be rendered by | ||
| 220 | drawing a dashed line between all the members of the group. You can | ||
| 221 | change this by specifying a different connector option in the | ||
| 222 | configuration section for this feature type. | ||
| 223 | |||
| 224 | =head1 BUGS | ||
| 225 | |||
| 226 | Please report them to the author. | ||
| 227 | |||
| 228 | =head1 SEE ALSO | ||
| 229 | |||
| 230 | L<Bio::Graphics>, L<feature_draw.pl> | ||
| 231 | |||
| 232 | =head1 AUTHOR | ||
| 233 | |||
| 234 | Lincoln Stein, lstein@cshl.org | ||
| 235 | |||
| 236 | =cut | ||
| 237 | |||
| 238 | use strict; | ||
| 239 | use Bio::Graphics::Panel; | ||
| 240 | use Bio::Graphics::Feature; | ||
| 241 | use Bio::Graphics::FeatureFile; | ||
| 242 | use CGI qw(:standard); | ||
| 243 | use CGI::Carp; | ||
| 244 | use File::Temp ':mktemp'; | ||
| 245 | use File::Spec; | ||
| 246 | use File::Basename 'basename'; | ||
| 247 | use File::Path 'mkpath'; | ||
| 248 | use vars '@COLORS'; | ||
| 249 | |||
| 250 | use constant WIDTH => 600; # default width | ||
| 251 | use constant BUMP_THRESHOLD => 50; # if more than this # of features, will stop bumping | ||
| 252 | @COLORS = qw(cyan blue red yellow green wheat turquoise orange); # default colors | ||
| 253 | |||
| 254 | if (param('cat')) { | ||
| 255 | catfile(param('cat')); | ||
| 256 | exit 0; | ||
| 257 | } | ||
| 258 | |||
| 259 | print header,start_html('Sequence Feature Renderer'); | ||
| 260 | print h1('Sequence Feature Renderer'); | ||
| 261 | |||
| 262 | print p('This is a front end to the Bio::Graphics package, a part of the', | ||
| 263 | a({-href=>'http://www.bioperl.org'},'BioPerl library.'), | ||
| 264 | 'Cut and paste your sequence annotation data into the text field below, or upload it using the', | ||
| 265 | 'upload button.', | ||
| 266 | 'The format of the annotation data is explained',a({-href=>'#format'},'below.')); | ||
| 267 | |||
| 268 | my $self = url(-relative=>1); | ||
| 269 | print h3('Instant examples'), | ||
| 270 | p('For the impatient, you can paste in an', | ||
| 271 | b(a({-href=>"$self?Paste+Example+1"},'example file.'))); | ||
| 272 | |||
| 273 | read_file() if param('file'); | ||
| 274 | |||
| 275 | my $example = param('Example 1') | ||
| 276 | ? test_data(0) | ||
| 277 | : param('Example 2') | ||
| 278 | ? test_data(1) | ||
| 279 | : ''; | ||
| 280 | param(text => $example) if length $example; | ||
| 281 | |||
| 282 | render() if param('text') || param('file') =~ /\w/; | ||
| 283 | |||
| 284 | print start_multipart_form(), | ||
| 285 | table({-border=>0,-width=>300,-cellspacing=>0,-cellpadding=>0}, | ||
| 286 | TR({-class=>'resultsbody'}, | ||
| 287 | td({-colspan=>1}, | ||
| 288 | 'Cut and Paste the annotation file...' | ||
| 289 | ), | ||
| 290 | td({-colspan=>2}, | ||
| 291 | 'Image width: ', | ||
| 292 | popup_menu(-name=>'width',-values=>[480,640,800,1024,1280,1600],-default=>800) | ||
| 293 | ), | ||
| 294 | TR({-class=>'resultsbody'}, | ||
| 295 | td({-colspan=>3}, | ||
| 296 | pre( | ||
| 297 | textarea(-name=>'text',-value=>$example, | ||
| 298 | -cols=>80,-rows=>10,-wrap=>'off',-override=>length $example || param('Clear')) | ||
| 299 | ) | ||
| 300 | ) | ||
| 301 | ) | ||
| 302 | ), | ||
| 303 | TR({-class=>'resultsbody'}, | ||
| 304 | td({-colspan=>1},'Upload it... ',filefield(-name=>'file',-size=>30)), | ||
| 305 | td({-align=>'left',-colspan=>2}, | ||
| 306 | 'Or paste one of the example files...', | ||
| 307 | submit('Example 1'), | ||
| 308 | submit('Example 2'), | ||
| 309 | submit('Clear'), | ||
| 310 | ) | ||
| 311 | ), | ||
| 312 | TR({-class=>'resultstitle'}, | ||
| 313 | td({-align=>'left',-colspan=>3}, | ||
| 314 | "Press",b('Render'),'when ready...', | ||
| 315 | b(submit('Render...')) | ||
| 316 | ), | ||
| 317 | )), | ||
| 318 | end_form; | ||
| 319 | |||
| 320 | print_format(); | ||
| 321 | |||
| 322 | print hr(),a({-href=>'http://www.bioperl.org'},'www.bioperl.org'),end_html(); | ||
| 323 | |||
| 324 | exit 0; | ||
| 325 | |||
| 326 | sub read_file { | ||
| 327 | my $text; | ||
| 328 | my $fh = param('file') or return; | ||
| 329 | $text .= $_ while <$fh>; | ||
| 330 | param(text => $text); | ||
| 331 | } | ||
| 332 | |||
| 333 | sub render { | ||
| 334 | my $text = shift; | ||
| 335 | my $color = 0; # position in color cycle | ||
| 336 | |||
| 337 | $text ||= param('text'); | ||
| 338 | my $data = $text ? Bio::Graphics::FeatureFile->new(-text => $text) | ||
| 339 | : Bio::Graphics::FeatureFile->new(-file => param('file')); | ||
| 340 | |||
| 341 | unless ($data->min < $data->max) { | ||
| 342 | AceError("This doesn't look like a valid annotation file. No annotations found."); | ||
| 343 | exit 0; | ||
| 344 | } | ||
| 345 | |||
| 346 | # adjust the width if requested | ||
| 347 | $data->setting(general => 'width',param('width')) if param('width'); | ||
| 348 | |||
| 349 | # render the panel | ||
| 350 | my $panel = $data->new_panel; | ||
| 351 | $data->render($panel); | ||
| 352 | |||
| 353 | # we create the file and write it out | ||
| 354 | my $gd = $panel->gd; | ||
| 355 | my $suffix = $gd->can('gif') ? '.gif' : '.png'; | ||
| 356 | my $dir = tmpdir(); | ||
| 357 | mkpath($dir) unless -e $dir; | ||
| 358 | my($fh,$filename) = mkstemps(tmpfile('XXXXXXXX'),$suffix); | ||
| 359 | |||
| 360 | print $fh ($gd->can('gif') ? $gd->gif : $gd->png); | ||
| 361 | close $fh; | ||
| 362 | |||
| 363 | # now we send the link to the user | ||
| 364 | my $self = url(-relative=>1); | ||
| 365 | my $base = basename($filename); | ||
| 366 | my $url = "$self/features$suffix?cat=$base"; | ||
| 367 | my ($w,$h) = $gd->getBounds; | ||
| 368 | |||
| 369 | print hr(),h2('Rendering'); | ||
| 370 | print a({-name=>'rendering'}, | ||
| 371 | img({-src=>$url,-alt=>'Right-click and "Save As..." to save this image', | ||
| 372 | -border=>0,-width=>$w,-height=>$h}) | ||
| 373 | ); | ||
| 374 | } | ||
| 375 | |||
| 376 | sub tmpdir { | ||
| 377 | return File::Spec->catfile(File::Spec->tmpdir,'frend'); | ||
| 378 | } | ||
| 379 | |||
| 380 | sub tmpfile { | ||
| 381 | return File::Spec->catfile(tmpdir(),shift); | ||
| 382 | } | ||
| 383 | |||
| 384 | sub catfile { | ||
| 385 | my $file = shift; | ||
| 386 | my $path = tmpfile($file); | ||
| 387 | print header($path =~ /\.gif$/ ? 'image/gif' : 'image/png'); | ||
| 388 | open F,$path or die "Couldn't open $file for reading: $!"; | ||
| 389 | print while <F>; | ||
| 390 | close F; | ||
| 391 | unlink $path; | ||
| 392 | } | ||
| 393 | |||
| 394 | sub print_format { | ||
| 395 | print hr(); | ||
| 396 | print a({-name=>'format'},h2('Annotation file format')); | ||
| 397 | print <<END; | ||
| 398 | <p> | ||
| 399 | The annotation file format has a configuration section and a data section. The configuration section | ||
| 400 | sets up the size and overall properties of the image, and the data section gives the annotation data | ||
| 401 | itself. | ||
| 402 | <p> | ||
| 403 | <h3>Configuration Section</h3> | ||
| 404 | <p> | ||
| 405 | If not provided, this page generates a reasonable default configuration section for you, so you | ||
| 406 | do not need to provide a configuration section to get a reasonable image. However, to tune the | ||
| 407 | appearance of the image, you will probably want to tweak the configuration. Here is an excerpt | ||
| 408 | from the configuration section: | ||
| 409 | <blockquote> | ||
| 410 | <pre> | ||
| 411 | # example file | ||
| 412 | [general] | ||
| 413 | bases = -1000..21000 | ||
| 414 | height = 12 | ||
| 415 | |||
| 416 | [EST] | ||
| 417 | glyph = segments | ||
| 418 | bgcolor= yellow | ||
| 419 | connector = solid | ||
| 420 | height = 5 | ||
| 421 | |||
| 422 | [FGENES] | ||
| 423 | glyph = transcript2 | ||
| 424 | bgcolor = green | ||
| 425 | description = 1 | ||
| 426 | </pre> | ||
| 427 | </blockquote> | ||
| 428 | |||
| 429 | <p> | ||
| 430 | The configuration section is divided into a set of sections, each one labeled with a [section title]. | ||
| 431 | The [general] section specifies global options for the entire image. Other sections apply to particular | ||
| 432 | feature types. In the example above, the configuration in the [EST] section applies to features labeled | ||
| 433 | as ESTs, while the configuration in the [FGENES] section applies to features labeled as predictions from | ||
| 434 | the FGENES gene prediction program. | ||
| 435 | <p> | ||
| 436 | Inside each section is a series of <i>name</i>=<i>value</i> pairs, where the name is the name of | ||
| 437 | an option to set. You can put whitespace around the = sign to make it more readable, or even use | ||
| 438 | a colon (:) if you prefer. The following option names are recognized: | ||
| 439 | <p> | ||
| 440 | <table border="1"> | ||
| 441 | <tr> | ||
| 442 | <th>Option</th><th>Value</th><th>Example</th> | ||
| 443 | </tr> | ||
| 444 | <tr> | ||
| 445 | <th>bases</th><td>Min & max of the sequence range (bp)</td><td>1200..60000</td> | ||
| 446 | </tr> | ||
| 447 | <tr> | ||
| 448 | <th>width</th><td>width of the image (pixels)</td> <td>600</td> | ||
| 449 | </tr> | ||
| 450 | <tr> | ||
| 451 | <th>height</th><td>Height of each graphical element (pixels)</td><td>10</td> | ||
| 452 | </tr> | ||
| 453 | <tr> | ||
| 454 | <th>glyph</th><td>Style of each graphical element (see below)</td><td>transcript</td> | ||
| 455 | </tr> | ||
| 456 | <tr> | ||
| 457 | <th>fgcolor</th> <td>Foreground color of each element</td> <td>yellow</td> | ||
| 458 | </tr> | ||
| 459 | <tr> | ||
| 460 | <th>bgcolor</th> <td>Background color of each element</td> <td>blue</td> | ||
| 461 | </tr> | ||
| 462 | <tr> | ||
| 463 | <th>linewidth</th> <td>Width of lines</td> <td>3</td> | ||
| 464 | </tr> | ||
| 465 | <tr> | ||
| 466 | <th>label</th> <td>Print the feature's name</td> <td>1</td> | ||
| 467 | </tr> | ||
| 468 | <tr> | ||
| 469 | <th>description</th> <td>Whether to print the feature's description </td> <td>0</td> | ||
| 470 | </tr> | ||
| 471 | <tr> | ||
| 472 | <th>bump</th> <td>Elements are not allowed to collide</td> <td>1</td> | ||
| 473 | </tr> | ||
| 474 | <tr> | ||
| 475 | <th>ticks</th> <td>Print tick marks on arrows</td> <td>1</td> | ||
| 476 | </tr> | ||
| 477 | <tr> | ||
| 478 | <th>connector</th> <td>Type of group connector (dashed, hat or solid)</td> <td>dashed</td> | ||
| 479 | </tr> | ||
| 480 | </table> | ||
| 481 | <p> | ||
| 482 | |||
| 483 | The "bases" and "width" options are only relevant in the [general] | ||
| 484 | section. The rest can be located in any section, but if present in | ||
| 485 | the [general] section will set defaults for the others. | ||
| 486 | |||
| 487 | <p> | ||
| 488 | |||
| 489 | Colors are English-language color names or Web-style #RRGGBB colors | ||
| 490 | (see a book on HTML for an explanation). True/false values are 1 for | ||
| 491 | true, and 0 for false. Numeric ranges can be expressed in | ||
| 492 | <i>start</i>..<i>end</i> fashion with two dots, or as | ||
| 493 | <i>start</i>-<i>end</i> with a hyphen. | ||
| 494 | |||
| 495 | <p> | ||
| 496 | The "glyph" option controls how the features are rendered. The | ||
| 497 | following glyphs are implemented: | ||
| 498 | |||
| 499 | <p> | ||
| 500 | |||
| 501 | <table border="1"> | ||
| 502 | |||
| 503 | <tr><th>Name</th><th>Description</th></tr> | ||
| 504 | <tr> | ||
| 505 | <th> | ||
| 506 | box | ||
| 507 | </th> | ||
| 508 | <td>A filled rectangle, nondirectional.</td> | ||
| 509 | </tr> | ||
| 510 | <tr> | ||
| 511 | <th>ellipse</th><td>An oval.</td> | ||
| 512 | </tr> | ||
| 513 | <tr> | ||
| 514 | <th>arrow</th> | ||
| 515 | <td> An arrow; can be unidirectional or bidirectional. | ||
| 516 | It is also capable of displaying a scale with | ||
| 517 | major and minor tickmarks, and can be oriented | ||
| 518 | horizontally or vertically. | ||
| 519 | </td> | ||
| 520 | </tr> | ||
| 521 | <tr> | ||
| 522 | <th>segments</th> | ||
| 523 | <td> A set of filled rectangles connected by solid lines. | ||
| 524 | Used for interrupted features, such as gapped | ||
| 525 | alignments. | ||
| 526 | </td> | ||
| 527 | </tr> | ||
| 528 | <tr> | ||
| 529 | <th>transcript</th> | ||
| 530 | <td> | ||
| 531 | Similar to segments, but the connecting line is | ||
| 532 | a "hat" shape, and the direction of transcription | ||
| 533 | is indicated by a small arrow. | ||
| 534 | </td> | ||
| 535 | </tr> | ||
| 536 | <tr> | ||
| 537 | <th> | ||
| 538 | transcript2</th> | ||
| 539 | <td> Similar to transcript, but the direction of | ||
| 540 | transcription is indicated by a terminal segment | ||
| 541 | in the shape of an arrow. | ||
| 542 | </td> | ||
| 543 | </tr> | ||
| 544 | <tr> | ||
| 545 | <th> | ||
| 546 | primers | ||
| 547 | </th> | ||
| 548 | <td> Two inward pointing arrows connected by a line. | ||
| 549 | Used for STSs. | ||
| 550 | </td> | ||
| 551 | </tr> | ||
| 552 | </table> | ||
| 553 | <p> | ||
| 554 | |||
| 555 | The <b>bump</b> option is the most important option for controlling the look | ||
| 556 | of the image. If set to false (the number 0), then the features are allowed | ||
| 557 | to overlap. If set to true (the number 1), then the features will move | ||
| 558 | vertically to avoid colliding. If not specified, bump is turned on | ||
| 559 | if the number of any given type of sequence feature is greater than | ||
| 560 | ${\BUMP_THRESHOLD}. | ||
| 561 | |||
| 562 | <h3>Data Section</h3> | ||
| 563 | <p> | ||
| 564 | |||
| 565 | The data section can follow or proceed the configuration section. The two sections | ||
| 566 | can also be intermixed. The data section is a tab or whitespace-delimited file which you can | ||
| 567 | export from a spreadsheet application or word processor file (be sure to save as text only!) | ||
| 568 | |||
| 569 | <p> | ||
| 570 | |||
| 571 | Here is an example data section: | ||
| 572 | |||
| 573 | <p> | ||
| 574 | |||
| 575 | <blockquote> | ||
| 576 | <pre> | ||
| 577 | Cosmid B0511 . 516-619 | ||
| 578 | Cosmid B0511 . 3185-3294 | ||
| 579 | Cosmid B0511 . 10946-11208 | ||
| 580 | Cosmid B0511 . 13126-13511 | ||
| 581 | Cosmid B0511 . 66-208 | ||
| 582 | Cosmid B0511 . 6354-6499 | ||
| 583 | Cosmid B0511 . 13955-14115 | ||
| 584 | EST yk595e6.5 + 3187-3294 | ||
| 585 | EST yk846e07.3 - 11015-11208 | ||
| 586 | EST yk53c10 | ||
| 587 | yk53c10.5 + 18892-19154 | ||
| 588 | yk53c10.3 - 15000-15500,15700-15800 | ||
| 589 | EST yk53c10.5 + 16032-16105 | ||
| 590 | SwissProt PECANEX + 13153-13656 Swedish fish | ||
| 591 | FGENESH "Gene 1" - 1-205,518-616,661-735,3187-3365,3436-3846 Transmembrane domain | ||
| 592 | FGENESH "Gene 2" - 16626-17396,17451-17597 Kinase and sushi domains | ||
| 593 | </pre> | ||
| 594 | </blockquote> | ||
| 595 | |||
| 596 | <p> | ||
| 597 | |||
| 598 | Each line of the file contains five columns. The columns are: | ||
| 599 | |||
| 600 | <p> | ||
| 601 | |||
| 602 | <table border="1"> | ||
| 603 | <tr><th>Column #</th><th>Column Description</th></tr> | ||
| 604 | <tr><td align="right">1</td><td>feature type</td></tr> | ||
| 605 | <tr><td align="right">2</td><td>feature name</td></tr> | ||
| 606 | <tr><td align="right">3</td><td>strand</td></tr> | ||
| 607 | <tr><td align="right">4</td><td>coordinates</td></tr> | ||
| 608 | <tr><td align="right">5</td><td>description</td></tr> | ||
| 609 | </table> | ||
| 610 | <p> | ||
| 611 | |||
| 612 | The <b>feature type</b> should correspond to one of the [feature type] headings | ||
| 613 | in the configuration section. If it doesn't, the [general] options will | ||
| 614 | be applied to the feature when rendering it. The <b>feature name</b> is a | ||
| 615 | name for the feature. Use a "." or "-" if this is not relevant. If | ||
| 616 | the name contains whitespace, put single or double quotes ("") around | ||
| 617 | the name. | ||
| 618 | |||
| 619 | <p> | ||
| 620 | |||
| 621 | The <b>strand</b> | ||
| 622 | indicates which strand the feature is on. It is one of "+" for the | ||
| 623 | forward strand, "-" for the reverse strand, or "." for features that are not | ||
| 624 | stranded. | ||
| 625 | |||
| 626 | <p> | ||
| 627 | |||
| 628 | The <b>coordinates</b> column is a set of one or more ranges that the | ||
| 629 | feature occupies. Ranges are written using ".." as in <i>start</i>..<i>stop</i>, | ||
| 630 | or with hyphens, as in <i>start</i>-<i>stop</i>. For features that are composed | ||
| 631 | of multiple ranges &em; for example transcripts that have multiple exons &em; | ||
| 632 | you can either put the ranges on the same line separated by commas or spaces, | ||
| 633 | or put the ranges on individual lines and just use the same feature name and | ||
| 634 | type to group them. In the example above, the Cosmid B0511 features use | ||
| 635 | the individual line style, while the FGENESH features use the all-ranges-on-one-line | ||
| 636 | style. | ||
| 637 | |||
| 638 | <p> | ||
| 639 | |||
| 640 | The last column contains some descriptive text. If the <b>description</b> option | ||
| 641 | is set to true, this text will be printed underneath the feature in the rendering. | ||
| 642 | |||
| 643 | <p> | ||
| 644 | |||
| 645 | Finally, it is possible to group related features together. An example is | ||
| 646 | the ESTs yk53c10.5 and yk53c10.3, which are related by being reads from | ||
| 647 | the two ends of the clone yk53c10. To indicate this relationship, generate | ||
| 648 | a section that looks like this: | ||
| 649 | |||
| 650 | <p> | ||
| 651 | |||
| 652 | <blockquote> | ||
| 653 | <pre> | ||
| 654 | EST yk53c10 | ||
| 655 | yk53c10.5 + 18892-19154 | ||
| 656 | yk53c10.3 - 15000-15500,15700-15800 | ||
| 657 | </pre> | ||
| 658 | </blockquote> | ||
| 659 | |||
| 660 | <p> | ||
| 661 | |||
| 662 | The group is indicated by a line that contains just two columns | ||
| 663 | containing the feature type and a unique name for the group. | ||
| 664 | Follow this line with all | ||
| 665 | the features that form the group, but leave the first column | ||
| 666 | (the feature type) blank. The group will be rendered by | ||
| 667 | drawing a dashed line between all the members of the group. | ||
| 668 | You can change this by specifying a different <b>connector</b> | ||
| 669 | option in the configuration section for this feature type. | ||
| 670 | |||
| 671 | END | ||
| 672 | ; | ||
| 673 | |||
| 674 | } | ||
| 675 | |||
| 676 | sub test_data { | ||
| 677 | my $config = shift; | ||
| 678 | my $header = <<'END'; | ||
| 679 | [general] | ||
| 680 | bases = -1000..21000 | ||
| 681 | height = 12 | ||
| 682 | reference = B0511 | ||
| 683 | |||
| 684 | [Cosmid] | ||
| 685 | glyph = segments | ||
| 686 | fgcolor = blue | ||
| 687 | key = C. elegans conserved regions | ||
| 688 | |||
| 689 | [EST] | ||
| 690 | glyph = segments | ||
| 691 | bgcolor= yellow | ||
| 692 | connector = solid | ||
| 693 | height = 5 | ||
| 694 | |||
| 695 | [FGENESH] | ||
| 696 | glyph = transcript2 | ||
| 697 | bgcolor = green | ||
| 698 | description = 1 | ||
| 699 | |||
| 700 | [SwissProt] | ||
| 701 | glyph = arrow | ||
| 702 | base = 1 | ||
| 703 | linewidth = 2 | ||
| 704 | fgcolor = red | ||
| 705 | description = 1 | ||
| 706 | |||
| 707 | [P-element] | ||
| 708 | glyph = triangle | ||
| 709 | orient = S | ||
| 710 | bgcolor = red | ||
| 711 | fgcolor = white | ||
| 712 | label = 1 | ||
| 713 | point = 1 | ||
| 714 | |||
| 715 | END | ||
| 716 | ; | ||
| 717 | |||
| 718 | my $data =<<'END'; | ||
| 719 | Cosmid B0511 516-619 | ||
| 720 | Cosmid B0511 3185-3294 | ||
| 721 | Cosmid B0511 10946-11208 | ||
| 722 | Cosmid B0511 13126-13511 | ||
| 723 | Cosmid B0511 11394-11539 | ||
| 724 | Cosmid B0511 14383-14490 | ||
| 725 | Cosmid B0511 15569-15755 | ||
| 726 | Cosmid B0511 18879-19178 | ||
| 727 | Cosmid B0511 15850-16110 | ||
| 728 | Cosmid B0511 66-208 | ||
| 729 | Cosmid B0511 6354-6499 | ||
| 730 | Cosmid B0511 13955-14115 | ||
| 731 | Cosmid B0511 7985-8042 | ||
| 732 | Cosmid B0511 11916-12046 | ||
| 733 | P-element "" 500-500 | ||
| 734 | P-element MrQ 700-700 | ||
| 735 | P-element MrR 10000-10000 | ||
| 736 | EST yk260e10.5 15569-15724 | ||
| 737 | EST yk672a12.5 537-618,3187-3294 | ||
| 738 | EST yk595e6.5 552-618 | ||
| 739 | EST yk595e6.5 3187-3294 | ||
| 740 | EST yk846e07.3 11015-11208 | ||
| 741 | EST yk53c10 | ||
| 742 | yk53c10.3 12876-13577,13882-14121,14169-14535 | ||
| 743 | yk53c10.5 18892-19154,15853-16219 | ||
| 744 | SwissProt "PECANEX Protein" 5513-16656 "From SwissProt" | ||
| 745 | FGENESH "Predicted gene 1" -1200--500,518-616,661-735,3187-3365,3436-3846 Pfam domain | ||
| 746 | FGENESH "Predicted gene 2" 5513-6497,7968-8136,8278-8383,8651-8839,9462-9515,10032-10705,10949-11340,11387-11524,11765-12067,12876-13577,13882-14121,14169-14535,15006-15209,15259-15462,15513-15753,15853-16219 Mysterious | ||
| 747 | FGENESH "Predicted gene 3" 16626-17396,17451-17597 | ||
| 748 | FGENESH "Predicted gene 4" 18459-18722,18882-19176,19221-19513,19572-30000 "Transmembrane protein" | ||
| 749 | END | ||
| 750 | |||
| 751 | return $config ? $header . $data : $data; | ||
| 752 | } | ||
| 753 | |||
| 754 | __END__ |