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

View of /FigKernelScripts/CSA_ref_vs_ref.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (as text) (annotate)
Mon Aug 15 11:19:08 2011 UTC (8 years, 6 months ago) by overbeek
Branch: MAIN
CVS Tags: mgrast_release_3_1_2, rast_rel_2011_0928, mgrast_dev_12152011, mgrast_dev_10262011
Changes since 1.4: +1 -1 lines
remove .pl on invocation

########################################################################
use strict;
#
# This is a SAS Component
#
use Data::Dumper;
use Proc::ParallelLoop;

my $usage = "usage: CSA_ref_vs_ref OutputDir < RefGenomesDesc";

my $outputD;

(
 ($outputD    = shift @ARGV)
)
    || die $usage;
(! -d $outputD) || die "$outputD already exists";
mkdir($outputD,0777) || die "could not make $outputD";
mkdir("$outputD/ReferenceGenomes") || die "could not make $outputD/ReferenceGenomes";
foreach my $genome_dir ( map { chop; $_} <STDIN> )
{
    &run("cp -r $genome_dir $outputD/ReferenceGenomes");
}
opendir(REF,"$outputD/ReferenceGenomes") || die "could not set up ReferenceGenomes";
my @refG = sort { ($a <=> $b) or ($a cmp $b) } grep { $_ =~ /^\d+\.\d+$/ } readdir(REF);
closedir(REF);

for (my $stage = 1; ($stage <= 2); $stage++)
{
    my $stageD = "$outputD/$stage";
    mkdir($stageD,0777) || die "could not make $stageD";
    mkdir("$stageD/AnnoD",0777) || die "could not open $stageD/AnnoD";
    mkdir("$stageD/WorkD",0777) || die "could not open $stageD/WorkD";

    my @todo;
    my($i,$j);
    for ($i=0; ($i < @refG); $i++)
    {
	my $refI        = $refG[$i];
	my $genome_dirI = "$outputD/ReferenceGenomes/$refG[$i]";
	my @ref_genomes;
	for ($j=0; ($j < @refG); $j++)
	{
	    if ($i != $j)
	    {
		my $refJ        = $refG[$j];
		my $genome_dirJ = "$outputD/ReferenceGenomes/$refG[$j]";
		push(@ref_genomes,$genome_dirJ);
	    }
	}
	my $annoD       = "$stageD/AnnoD/$refI";
	my $workD       = "$stageD/WorkD/$refI";
	my $ref_dirs    = join(" ",@ref_genomes);
	push(@todo,"CSA_get_close_strain_annotations $annoD $workD $refI $genome_dirI/contigs $ref_dirs");
    }
    &pareach(\@todo,\&run,{ Max_Workers => 2 });

    mkdir("$stageD/Reports",0777) || die "could not make $stageD/Reports";
    for ($i=0; ($i < @refG); $i++)
    {
	my $refI = $refG[$i];
	my $genome_dirI = "$outputD/ReferenceGenomes/$refG[$i]";
	&run("CSA_predict_features_based_on_refs -install $stageD/AnnoD/$refI/features $stageD/AnnoD/$refI/contigs.index $genome_dirI > $stageD/Reports/$refI");
    }
}

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