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

View of /FigKernelScripts/FFB2_run_tests.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Mon Feb 14 22:44:07 2011 UTC (8 years, 9 months 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.2: +21 -5 lines
Update to figfam build code

#
# Use the newly-generated Kmers to call genes in the
# set of test organisms that are kept in /vol/figfam-prod/test_genomes.
#
# Each test genome in the test directory has a single fasta file
# of its protein data named genomeid.peg.fasta.
#
# Write the output into figfamdir/tests/<genomeid.out>
#
# The output is the raw output of assign_using_kmers.
#

use strict;
use FIG;
use FIG_Config;

use Getopt::Long;

my @kmers;
my $ordered = 0;

my $rc = GetOptions("kmers=i" => \@kmers,
		    "ordered" => \$ordered);

($rc && @ARGV == 1) or die "Usage: $0  [-ordered] [-kmers k1 -kmers k2 ...] figfam-dir\n";

my $ffdir = shift;

my @tests;

my $seq_hit_threshold = 2;
my $score_threshold = 2;
my $thresh = "--scoreThreshold $score_threshold";
#my $thresh = "--seqHitThreshold $seq_hit_threshold --scoreThreshold $score_threshold";
$thresh .= " --orderConstraint" if $ordered;

for my $file (</vol/figfam-prod/test_genomes/*.peg.fasta>)
{
    my($genome) = $file =~ m,/(\d+\.\d+)\.peg\.fasta$,;
    $genome or die "Invalid test data file $file\n";
    push(@tests, [$genome, $file]);
}

my $output_dir = "$ffdir/tests";
&FIG::verify_dir($output_dir);

#
# Find the set of kmers we have.
#
if (@kmers == 0)
{
    opendir(D, "$ffdir/Merged") or die "cannot opendir $ffdir/Merged: $!";
    @kmers = sort { $a <=> $b } grep { /^\d+$/ } readdir(D);
    closedir(D);
}

my @kmers = sort { $a->[0] <=> $b->[0] } grep { $_->[0] =~ /^\d+/ && -f $_->[1] } map { [$_, "$ffdir/Merged/$_/table.binary" ] } @kmers;
@kmers > 0 or die "No kmers found in $ffdir/Merged\n";

print "testing kmers " . join(" ", map { $_->[0] } @kmers) . "\n";

my $setI = "$ffdir/setI.db";
my $frI =  "$ffdir/FRI.db";

-f $setI or die "setI.db not found in $ffdir";
-f $frI or die "FRI.db not found in $ffdir";

for my $kmerent (@kmers)
{
    my($kmer, $kmer_data) = @$kmerent;

    my $koutdir = "$output_dir/$kmer";
    &FIG::verify_dir($koutdir);
	
    system("cat $kmer_data > /dev/null &");
    for my $test (@tests)
    {
	my($genome, $file) = @$test;

	print "Testing $genome with k=$kmer\n";

	if (-f "$koutdir/$genome.out")
	{
	    next;
	}
    
	my $cmd = "$FIG_Config::bin/assign_using_kmers $thresh --kmer $kmer $setI $frI $kmer_data <  $file > $koutdir/$genome.out 2> $koutdir/$genome.err";
	print "$cmd\n";
	my $rc = system $cmd;
	if ($rc != 0)
	{
	    die "test failed with rc=$rc: $cmd\n";
	}
	$cmd = "cut -f1,2 $koutdir/$genome.out | $FIG_Config::bin/svr_metabolic_reconstruction > $koutdir/$genome.reconstruction 2> $koutdir/$genome.reconstruction.nomatch";
	$rc = system $cmd;
	if ($rc != 0)
	{
	    die "test failed with rc=$rc: $cmd\n";
	}
    }
		
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3