[Bio] / FigKernelScripts / svr_file_to_spreadsheet.pl Repository:
ViewVC logotype

View of /FigKernelScripts/svr_file_to_spreadsheet.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.3 - (download) (as text) (annotate)
Wed Jun 8 18:53:13 2011 UTC (8 years, 8 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2014_0729, mgrast_release_3_1_2, mgrast_release_3_1_1, rast_rel_2011_0928, mgrast_dev_10262011, HEAD
Changes since 1.2: +23 -3 lines
If -u url flag is added, add links to pegs.

#!/usr/bin/perl -w
use Getopt::Std;
use Spreadsheet::WriteExcel;
use strict;
use Data::Dumper;
use Carp;

# This is a SAS Component

=head1 svr_file_to_spreadsheet -f filename 

Writes the contents of the tab separated file on STDIN to a spreadsheet

The output is an xls file

Example: svr_file_to_spreadsheet -f test.xls  < test.txt 

=head2 Command-Line Options

=over 4

=item -f 

The file name given to the output xls format spreadsheet.


=head2 Output Format

The output is a file in xls format


our ($opt_f, $opt_u);
if (!$opt_f) {
	die "Usage: No File Specified (-f missing)\n";

# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new($opt_f);
if (!$workbook) {die "$opt_f workbook failure"};

# Add a worksheet
my $worksheet = $workbook->add_worksheet();
if (!$worksheet) {die "$opt_f worksheet failure"};

my $row = 0;
my $col = 0;
my @ctot;
while (<STDIN>) {
	my @line = split("\t", $_);

	$col = 0;
	foreach my $element (@line) {
	    $ctot[$col] += length($element);
	    if ($opt_u && $element =~ /fig\|/)
		my $link = $opt_u;
		$link =~ s/PEG/$element/;
		$worksheet->write_url($row, $col, $link, $element);
		$worksheet->write($row, $col, $element);
for my $col (0..$#ctot)
    my $avg = int($ctot[$col] / $row);
    if ($avg > 5)
	$worksheet->set_column($col, $col, $avg);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3