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

View of /FigKernelScripts/get_needed_corr.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Mar 1 20:50:45 2012 UTC (7 years, 8 months ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2014_0729, mgrast_version_3_2, rast_rel_2014_0912, HEAD
for veronika projections

use strict;
use Data::Dumper;
use FIG;

my $pubseed = "/vol/public-pseed/FIGdisk/FIG/Data/Organisms";

my $usage = "usage:  get_needed_corr CorrDir < anno.data";
my $corrD;
(
 ($corrD = shift @ARGV)
)
    || die $usage;

my %genomes = map { ($_ =~ /fig\|(\d+\.\d+)\.peg\.\d+/) ? ($1 => 1) : () } <STDIN>;
my @g = keys(%genomes);
my $otu2genomes = {};
my $genome2otu = {};
foreach $_ (`cat "$FIG_Config::global/genome.sets"`)
{
    if ($_ =~ /^(\d+)\s+(\d+\.\d+)/)
    {
	push(@{$otu2genomes->{$1}},$2);
	$genome2otu->{$2} = $1;
    }
}

my %needed;

foreach my $g (@g)
{
    my $otu    = $genome2otu->{$g};
    if($otu)
    {
	my $in_otu = $otu2genomes->{$otu};
	if ($in_otu)
	{
	    foreach my $g2 (grep { ! $genomes{$_} } @$in_otu)
	    {
		if ($g < $g2)
		{
		    next if (-s "$corrD/$g-$g2");
		    $needed{"$g,$g2"} = 1;
		}
		elsif ($g > $g2)
		{
		    next if (-s "$corrD/$g2-$g");
		    $needed{"$g2,$g"} = 1;
		}
		if ((! $genomes{$g}) && (! $genomes{$g2})) { die "$g $g2" }
	    }
	}
    }
}

use SeedEnv;
&SeedUtils::verify_dir($corrD);

use Proc::ParallelLoop;
my @tasks = map { [split(/,/,$_),$corrD,$pubseed] } keys(%needed);

# print &Dumper($tasks[0],$tasks[-1]); die "HERE";

pareach(\@tasks,\&wu,{ Max_Workers => 12 });

sub wu {
    my($tuple) = @_;
    my($g1,$g2,$corrD,$pubseed) = @$tuple;
    &run("svr_corresponding_genes2 $pubseed/$g1 $pubseed/$g2 > $corrD/$g1-$g2");
}

sub run {
    my($cmd) = @_;

#    print STDERR "running: $cmd\n";
    my $rc = system($cmd);
    if ($rc)
    {
	die "$rc: $cmd failed";
    }
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3