[Bio] / Clearinghouse / clearinghouse_browser.pl Repository:
ViewVC logotype

View of /Clearinghouse/clearinghouse_browser.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (download) (as text) (annotate)
Tue Jun 14 16:02:34 2005 UTC (14 years, 4 months ago) by olson
Branch: MAIN
CVS Tags: myrast_33, HEAD
Changes since 1.17: +1 -0 lines
genome upload script.

#),!/usr/bin/perl
use strict;
#use CGI qw/:standard :html3/;
use CGI qw/:all/;
use CH_Config;
use SOAP::Lite;
use Clearinghouse::utils;

my $proxy = SOAP::Lite-> uri('http://www.soaplite.com/Scripts')
-> proxy($CH_Config::service_url);

my $sort = param('sort');
my $sort_column;

my $show_versions = param('show_all_subsystem_versions');
print STDERR "show versions = $show_versions\n";

if ($sort =~/(\w+)/) {
    $sort_column = $1;
} else{
    $sort_column = "ID";
}

my @checked_types = param('type'); 

if (@checked_types == 0) {
	CGI::delete('type'); #force the defaults to be checked
}

#get the download url
my $response = $proxy->get_download_url();  
if ($response->fault)
{
    die "Failed to get download url: ", $response->faultcode, " ", $response->faultstring, "\n";
}
my $url = $response->result;


#get the clearinghouse contents sorted by column
$response = $proxy->what_is_there($sort_column, \@checked_types);  
if ($response->fault)
{
    die "Failed to retrieve data: ", $response->faultcode, " ", $response->faultstring, "\n";
}


#First, go through the results building a table of subsystem names, id's and highest version numbers 

my %subsystems;
for my $row (@{$response->result}) {
    my ($id, $type, $meta_data, $desc, $who, $source, $date, $file_list) = @$row;
    my ($name, $version);
    if ($type eq "SUBSYSTEM") {
	    for my $mdline (split(/\n/, $meta_data))
	    {
		my($key, $val) = split(/\t/, $mdline);
		if ($key eq "name") {
			$name = $val;
		} elsif ($key eq "version") {
			$version = $val;
		}
	    }
	    if ($name && $version) {
		if ($version > $subsystems{$name}) {
			$subsystems{$name} = $version;
		}
	    }
    }
}
#build the html table
my @table;
TABLE_MAKER: for my $row (@{$response->result}) {
    my ($id, $type, $meta_data, $desc, $who, $source, $date, $file_list) = @$row;

    my ($name, $version);
    my(@mdkey, @mdval);

    for my $mdline (split(/\n/, $meta_data))
    {
	my($key, $val) = split(/\t/, $mdline);
	if ($key eq "name") {
		$name = $val;
	} elsif ($key eq "version") {
		$version = $val;
	}
	push(@mdkey, $key);
	push(@mdval, $val);
    }
    if ($name && $version) {
        if ($show_versions ne 'on') {
		if ($version < $subsystems{$name}) {
			next TABLE_MAKER;
		}
	}
    }
    
    my $mdkey = join("<br>\n", @mdkey);
    my $mdval = join("<br>\n", @mdval);
    
    my($download_list, $view_list);

    if (@$file_list > 1)
    {
	my(@download_list, @view_list);
	my $file_num = 1;
	for my $file_id (@$file_list)
	{
	    push(@download_list, a({href => $url . "?ID=$file_id"}, "Download file $file_num"));
	    push(@view_list, a({href => $url . "?ID=$file_id&view=1"}, "View file $file_num"));
	    $file_num++;
	}
	$download_list = join(" ", @download_list);
	$view_list = join(" ", @view_list);
    }
    elsif (@$file_list == 1)
    {
	my $file_id = $file_list->[0];
	$download_list =  a({href => $url . "?ID=$file_id"}, "Download");
	$view_list = a({href => $url . "?ID=$file_id&view=1"}, "View");
    }
    #
    #If a subsystem. only push if it is in the table built above
    #
    push @table, th($id).td([$type, $mdkey, $mdval, $desc, $who,
			     $source, scalar (localtime($date)), $view_list, $download_list]);
}

my @types = qw(GENOME SUBSYSTEM 1-SUBSYSTEM ANNOTATION SIMS FEATURE);

$response = $proxy->how_many_are_there(\@types);  
if ($response->fault)
{
    die "Failed to count data: ", $response->faultcode, " ", $response->faultstring, "\n";
}

#my $row = (@{$response->result}); 
my ($g, $s, $one_s, $a, $s, $f) = (@{$response->result}); 

#now print it all
print header,
    start_html('Clearing House'),
    get_page_header(),
    h1('Clearing House Browser'),
    h3("Contains $g type $types[0], $s type $types[1], $one_s type $types[2], $a type $types[3], $s type $types[4] and $f type $types[5]");
print start_form;
print table({-border=>''},
	    strong('Check to view types:'),
	    checkbox_group(-name => 'type',
			   -values => \@types,
			   -default => \@types),
	    br, p,
	    checkbox(-name=>'show_all_subsystem_versions', -checked=>'', label=>'Show all subsystem versions'),
	    br, p,
	    submit(-name=>'refresh', -value=>"Refresh"), p,
	    caption(strong("The selected clearing house list sorted by $sort_column (Click column heading to re-sort)")),
	    Tr({-valign=>'TOP'}, 
	       [
		#th(['ID','Type','MetaData','Description','Who', 'Source', 'Date', 'Download']),
		th([submit(-name=>'sort', -value=>"ID"),
		    submit(-name=>'sort', -value=>"Type"),
		    'MetaData Key',
		    'MetaData Value',
		    'Description',
		    submit(-name=>'sort',-value=>'Who'),
		    submit(-name=>'sort',-value=>"Source"),
		    submit(-name=>'sort', -value=>"Date"),
		    'View',
		    'Download']),
		@table
		]
	      )
	   ),
    hidden('sort', $sort_column),
    end_form,
    end_html;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3