[Bio] / Sprout / LoadProjections.pl Repository:
ViewVC logotype

View of /Sprout/LoadProjections.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Fri Sep 9 13:27:02 2011 UTC (7 years, 11 months ago) by parrello
Branch: MAIN
CVS Tags: rast_rel_2014_0912, rast_rel_2014_0729, mgrast_release_3_1_2, rast_rel_2011_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_10262011, HEAD
Changes since 1.2: +1 -1 lines
Fixed Sapling constructor.

#!/usr/bin/perl -w

#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
#
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License.
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

use strict;
use Tracer;
use Stats;
use ERDB;
use Sapling;
use SeedUtils;

=head1 LoadProjections

=head2 Introduction

    LoadProjections [options] <inputfile> 

This script will create the ProjectOnto relationship in the Sapling database and
load it from the specified flat file. It is intended as a one-time use script.

=head2 Command-Line Options

=over 4

=item trace

Specifies the tracing level. The higher the tracing level, the more messages
will appear in the trace log. Use E to specify emergency tracing.

=item user

Name suffix to be used for log files. If omitted, the PID is used.

=item sql

If specified, turns on tracing of SQL activity.

=item background

Save the standard and error output to files. The files will be created
in the FIG temporary directory and will be named C<err>I<User>C<.log> and
C<out>I<User>C<.log>, respectively, where I<User> is the value of the
B<user> option above.

=item DBD

Name of the XML database definition file, if specified. Otherwise, the
default DBD will be used.

=item dbName

SQL name of the target database. If not specified, the default name is used.
This option allows you to specify a backup or alternate database that can
be updated without compromising the main database.

=item dbhost

Name of the MySQL database host. If not specified, the default host is used.
This option is required when the default host is restricted to read-only
database access.

=item help

Display this command's parameters and options.

=back

=cut

	# Get the command-line options and parameters.
	my ($options, @parameters) = StandardSetup([qw(ERDB) ],
	                                           {
	                                              DBD => ["", "if specified, the name of the DBD file to use"],
	                                              dbName => ["", "if specified, the SQL name of the target database"],
	                                              dbhost => ["", "if specified, the name of the target database"],
	                                              trace => ["2", "tracing level"],
	                                           },
	                                           "",
	                                           @ARGV);
	# Create the statistics object.
	my $stats = Stats->new();
    # Create the SAPLING object.
    my $sap = Sapling->new(%$options);
	# Get the input file name.
	my $fileName = $parameters[0];
	# If a DBD was specified, internalize it.
	if ($options->{DBD}) {
		Trace("Storing $options->{DBD} in database.") if T(2);
		$sap->InternalizeDBD();
	}
	# Now we must create a copy of the input file that has no redundant projections.
	my $ih = Tracer::Open(undef, "<$fileName");
	my $oh = Tracer::Open(undef, ">$FIG_Config::temp/projections.copy.tbl");
	while (! eof $ih) {
		my ($from, $to, $context, $percent, $score) = Tracer::GetLine($ih);
		if ($from lt $to) {
			Tracer::PutLine($oh, [$from, $to, $context, $percent, $score]);
		}
	}
	close $ih;
	close $oh;
	# Load the table.
	Trace("Loading projection data.") if T(2);
	$sap->LoadTable("$FIG_Config::temp/projections.copy.tbl", 'ProjectsOnto', truncate => 1, failOnError => 1);
	# Display the run statistics.
	Trace("Statistics for this run:\n" . $stats->Show()) if T(2);
	

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3