[Bio] / MGRASTBackend / mg_check_sequence_distribution.pl Repository:
ViewVC logotype

View of /MGRASTBackend/mg_check_sequence_distribution.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Mon Jul 6 19:40:28 2009 UTC (10 years, 4 months ago) by arodri7
Branch: MAIN
CVS Tags: HEAD
first version, figfams pipeline

#
# dereplication of the input fasta.
#

use strict;
use FIG;
use FIG_Config;
use File::Basename;
use GenomeMeta;
use Job48;
use JobStage;
use SGE;
use FortyEightMeta::SimDB;
use FortyEightMeta::SimStatusDB;

my $STAGE = "dereplication";

@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 $stage = new JobStage('Job48', $STAGE, $jobdir);
$stage or die "Cannot create job for $jobdir\n";

my $job_id = basename($jobdir);
my $job = $stage->job();

my $meta = $job->meta;

print "Running job! $jobdir\n";

$stage->set_status("in_progress");

#
# Find needed executables
#

#my $dereplication_exe = "/home/arodri7/public_html/FIGdisk/dist/releases/dev/MGRASTBackend/scripts/sequence_dereplication.pl";
my $dereplication_exe = "$FIG_Config::bin/sequence_dereplication";
-x $dereplication_exe or $stage->fatal("Executable missing: $dereplication_exe");

my $proc = "$jobdir/proc";
chdir($proc) or $stage->fatal("cannot chdir $proc: $!");

my $fasta = $meta->get_metadata("preprocess.fasta_file");
($fasta and -f $fasta) or $stage->fatal("fasta not found: '$fasta'");

my $new_fasta = "dereplication.fasta";


$stage->log("Dereplication original=$fasta new_fasta=$new_fasta");

my $stderr = "$jobdir/errors/$STAGE.stderr";
my $cmd = "$dereplication_exe -f $fasta -o $new_fasta -v";
open(P, "$cmd |") or $stage->fatal("Failed pipe open: $!: $cmd");
open(E, ">$stderr") or $stage->fata("Failed stderr open $!: $stderr");
my($start, $end);
while (<P>)
{
    print E $_;
}
close(P) or $stage->fatal("Error on close: \$!=$! \$?=$?: $cmd");
close(E);

$stage->set_qualified_metadata("fasta_file", $new_fasta);    
$stage->set_status("complete");
$stage->set_running("no");




MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3