# HG changeset patch # User ondovb # Date 1316811975 14400 # Node ID a5814dd5a11a1fb1cc459ee8cb1f0534a9f5dff3 Uploaded diff -r 000000000000 -r a5814dd5a11a tabular2HTML.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tabular2HTML.pl Fri Sep 23 17:06:15 2011 -0400 @@ -0,0 +1,69 @@ + +use strict; + +my ($table, $input, $output, @spans) = @ARGV; + +# positions that should have dark right borders +# +my %dark; + +foreach my $span ( @spans ) +{ + if ( $span > 1 ) + { + # only initialize if there are any spans more than 1 + + pop @spans; + my $i; + + foreach my $span ( @spans ) + { + $i += $span; + $dark{$i - 1} = 1; + } + + last; + } +} + +open TABLE, ">>$table" or die $!; +open INPUT, "<$input" or die $!; + +my $parity; + +while ( my $line = ) +{ + chomp $line; + + my @vals = split /\t/, $line; + + $parity = ( $parity eq 'odd' ? 'even' : 'odd' ); + + print TABLE ""; + + for( my $i = 0; $i < @vals; $i++ ) + { + my $val = $vals[$i]; + my $class; + + if ( $dark{$i} ) + { + $class = ' class="darkRight"'; + } + + $val =~ s//>/; + + print TABLE "$val"; + } + + print TABLE "\n"; +} + +close INPUT; + +print TABLE "\n"; + +close TABLE; + +`mv $table $output`; diff -r 000000000000 -r a5814dd5a11a tabular2HTML.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tabular2HTML.xml Fri Sep 23 17:06:15 2011 -0400 @@ -0,0 +1,154 @@ + + for easier table viewing + + tabular2HTML.pl + $tableHeader + $input + $output + #if $headerSource.source == 'explicit': + #for $header in $headerSource.headers + #if len($header.subheaders) > 0 + ${len($header.subheaders)} + #else + 1 + #end if + #end for + #end if + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <html><head><style type="text/css"> + table,td,th + { + border: 1px solid #dddddd; + border-collapse: collapse; + padding: 4px; + font-size: 10pt; + } + th{border-width:2px; background-color: #888888; color: #ffffff} + tr.odd {background-color: #f2fff2} + tr.even {background-color: #f2f2ff} + td.darkRight {border-right: 2px solid #888888} + </style></head><body> + <table style="border-collapse:collapse"> + #if $headerSource.source == 'numbers': + <tr> + #for $i in range(int($input.metadata.columns)): + <th>${i + 1}</th> + #end for + </tr> + #elif $headerSource.source == 'names' and hasattr($input.datatype, 'column_names'): + <tr> + #for $columnName in $input.datatype.column_names: + <th>$columnName</th> + #end for + </tr> + #elif $headerSource.source == 'explicit': + <tr> + #for $header in $headerSource.headers: + <th + #if len($header.subheaders) > 0: + colspan="${len($header.subheaders)}" + #else + rowspan="2" + #end if + > + $header.name + </th> + #end for + <tr> + #for $header in $headerSource.headers: + #for $subheader in $header.subheaders: + <th> + ${subheader.name} + </th> + #end for + #end for + </tr> + #end if + + + +**===What it does===** + +Wraps tabular data in an HTML table for easier viewing. + +------ + +**===Headers===** + +**Column numbers** - The header will show the order of the columns. + +**Column names** - The header will show column names if the data file is a +specific type of tabular file that has column names in +Galaxy (such as *sam* or *taxonomy*). Otherwise, no header will be shown. + +**Specify headers and subheaders** - This allows custom headers, which can span +multiple columns if subheaders are included. For example, the tabular file:: + + 1 2 3 4 + read1 100 12345 50 + read2 150 56789 60 + +...with the headers and subheaders:: + + Query + ID + length + Hit + gi + score + +...would create an html table with the format: + ++----------------+---------------+ +| Query | Hit | ++-------+--------+-------+-------+ +| ID | length | gi | score | ++=======+========+=======+=======+ +| read1 | 100 | 12345 | 50 | ++-------+--------+-------+-------+ +| read2 | 150 | 56789 | 60 | ++-------+--------+-------+-------+ + + +