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

View of /FigKernelScripts/compute_PSEED_reconstructions.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Mon Feb 14 22:47:39 2011 UTC (9 years ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, mgrast_release_3_0, mgrast_dev_03252011, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.1: +51 -8 lines
More fixups.

########################################################################
use Time::HiRes 'gettimeofday';
use Data::Dumper;
use FIG;        ### This references the PSEED
use YAML::Any;

use Getopt::Long;
use Subsystem;
use Proc::ParallelLoop;

use SeedEnv;    ### The servers go (more-or-less) to the ASEED
my $annO = ANNOserver->new();

my $function_override_file;
my $genomes_file;
my $parallel = 1;

my $rc = GetOptions("functions=s" => \$function_override_file,
		    "genomes=s" => \$genomes_file,
		    "parallel=i" => \$parallel);

($rc && @ARGV == 1) or die "Usage: compute_PSEED_reconstructions [-functions function-defs] reconstruction-dir\n";

my $base = shift @ARGV;

#
# I don't remember why we read genomes from stdin. Just use
# all genomes in pseed if we don't specify a file.

my @genomes;
if (defined($genomes_file))
{
    open(G,"<", $genomes_file) or die "Cannot open $genomes_file: $!";
    @genomes = <G>;
    chomp @genomes;
    @genomes = map { /(\d+\.\d+)/ ? $1 : () } @genomes;
}
else
{
    my $fig = new FIG;
    @genomes = $fig->genomes();
    undef $fig;
}

my $fn_override = {};
if (defined($function_override_file))
{
    open(FN, "<", $function_override_file) or die "Cannot open $function_override_file: $!";
    while (<FN>)
    {
	chomp;

	my($id, $fn) = split(/\t/);
	$fn_override{$id} = $fn;
    }
    close(FN);
}

my $n_genomes = @genomes;
print "Process $n_genomes genomes\n";

pareach \@genomes, sub {
    my $genome = shift;
    $fig = new FIG;

    my $roleL = [];
	
    foreach my $peg_data (@{$fig->all_features_detailed_fast($genome)})
    {
	my $peg = $peg_data->[0];
	my $func = exists($fn_override{$peg}) ? $fn_override{$peg} : $peg_data->[6];
	foreach my $role (&SeedUtils::roles_of_function($func))
	{
	    push(@$roleL,[$role,$peg]);
	}
    }
    my $meta_recon = $annO->metabolic_reconstruction( -roles => $roleL );

    my($tax) = ($genome =~ /^(\d+)/);
    my $dir = $tax % 100;
    &FIG::verify_dir("$base/$dir");
    open(F, ">", "$base/$dir/$genome");
    print F Dump($meta_recon);
    close(F);
}, { Max_Workers => $parallel };

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3