[Bio] / FortyEight / rp_auto_assign.pl Repository:
ViewVC logotype

View of /FortyEight/rp_auto_assign.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (download) (as text) (annotate)
Wed Aug 4 15:03:40 2010 UTC (9 years, 4 months ago) by olson
Branch: MAIN
Changes since 1.8: +16 -2 lines
add model creation

#
# Perform auto-assignment on unassigned pegs.
#

use strict;
use FIG;
use FIG_Config;
use File::Basename;
use GenomeMeta;
use Carp 'croak';

@ARGV == 1 or die "Usage: $0 job-dir\n";

my $jobdir = shift;

-d $jobdir or die "$0: job dir $jobdir does not exist\n";

my $genome = &FIG::file_head("$jobdir/GENOME_ID");
chomp $genome;
$genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";

my $meta = new GenomeMeta($genome, "$jobdir/meta.xml");

my $tbl = "$jobdir/rp/$genome/Features/peg/tbl";
-f $tbl or die "$0: Cannot find tbl file $tbl\n";

my $proposed = "$jobdir/rp/$genome/proposed_functions";

my %done;

if (!open(PROP, "<$proposed"))
{
    warn "could not  open proposed functions $proposed: $!";
    $meta->add_log_entry($0, "could not open proposed fucntions $proposed");
}
else
{
    while (<PROP>)
    {
	chomp;
	my($peg, $assign) = split;
	$done{$peg} = $assign;
    }
    close(PROP);
}

my $simfile = "$jobdir/rp/$genome/expanded_similarities";

open(TBL, "<$tbl") or &fatal("Cannot open tbl file $tbl: $!");

my $cmd = "$FIG_Config::bin/auto_assign -orgdir $jobdir/rp/$genome > $jobdir/rp/$genome/proposed_non_ff_functions";
print "running $cmd\n";
open(AA, "| $cmd")
	or &fatal("aa failed: $!");

my $peg_count = 0;
while (<TBL>)
{
    chomp;
    my($peg, @rest) = split(/\t/);
    if (!$done{$peg})
    {
	$peg_count++;
	print AA "$peg\n";
    }
}
close(TBL);

$meta->add_log_entry($0, "computing auto_assign on $peg_count pegs");

if (!close(AA))
{
    &fatal("error on close \$?=$? \$!=$!");
}

#
# When auto assign is complete, we are able to submit the model computation.
#

if ($meta->get_metadata("model_build.enabled"))
{
    my $user = &FIG::file_head("$jobdir/USER", 1);
    chomp $user;
    my $cmd = ("/vol/model-prod/FIGdisk/bin/ModelDriver.sh 'createmodelfile?$genome?$user' > $jobdir/rp.errors/create_model.stderr 2>&1");
    my $rc = system($cmd);
    if ($rc != 0)
    {
	$meta->add_log_entry($0, ['error creating model', $rc]);
    }
    else
    {
	$meta->add_log_entry($0, ['model submitted']);
	
	my $link = "http://seed-viewer.theseed.org/seedviewer.cgi?model=Seed${genome}&page=ModelView";

	$meta->set_metaata("model_build.viewing_link", $link);
    }
}


$meta->add_log_entry($0, "auto_assign completed\n");
$meta->set_metadata("status.auto_assign", "complete");
$meta->set_metadata("auto_assign.running", "no");

sub fatal
{
    my($msg) = @_;

    $meta->add_log_entry($0, ['fatal error', $msg]);
    $meta->set_metadata("status.auto_assign", "error");

    croak "$0: $msg";
}
    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3