[Bio] / FortyEight / rp_preprocess_sims.pl Repository:
ViewVC logotype

View of /FortyEight/rp_preprocess_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Mon Jan 4 20:30:23 2010 UTC (9 years, 11 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2011_0119, 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, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.2: +1 -1 lines
mods from batch rasting


use strict;
use FIG;
use FIG_Config;
use File::Basename;
use GenomeMeta;
use Carp 'croak';

@ARGV == 3 or die "Usage: $0 job-dir NR peg.synonyms\n";

my $jobdir = shift;
my $sims_nr = shift;
my $sims_peg_synonyms = shift;

-d $jobdir or die "$0: job dir $jobdir does not exist\n";

my $genome = &FIG::file_head("$jobdir/GENOME_ID");
chomp $genome;
$genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";

my $meta = new GenomeMeta($genome, "$jobdir/meta.xml");

#
# Use pull_sims_from_server to extract sims for the fasta file we have,
# writing them to jobdir/sims.job/sims.server. Write the sequences that did not
# have sims to jobdir/sims.job/seqs_needing_sims.
#
# Use rp_chunk_sims to chunk the remaining sims, setting up for the main
# pipeline script to submit them.
#

my $fasta = "$jobdir/rp/$genome/Features/peg/fasta";
if (! -f $fasta)
{
    &fatal("Fasta file $fasta is not present");
}

-d "$jobdir/sims.job" or mkdir "$jobdir/sims.job" or die "mkdir $jobdir/sims.job failed: $!";

my $server_sims = "$jobdir/sims.job/sims.server";
my $seqs_needing_sims = "$jobdir/sims.job/seqs_needing_sims";
my $ids_needing_sims = "$jobdir/sims.job/ids_needing_sims";

my $cmd;
if ($FIG_Config::rast_sims_database)
{
    my($dsn, $user, $pw, $tbl) = @$FIG_Config::rast_sims_database;
    $cmd = "$FIG_Config::bin/pull_sims_from_database '$dsn' '$user' '$pw' '$tbl' < $fasta > $server_sims 2> $ids_needing_sims";
}
else
{
    $cmd = "$FIG_Config::bin/pull_sims_from_server < $fasta > $server_sims 2> $ids_needing_sims";
}
$meta->add_log_entry($0, $cmd);
my $rc = system($cmd);
if ($rc != 0)
{
    &fatal("pull_sims_from_server failed with rc=$rc: $cmd");
}

#
# Reinflate the ids to a fasta.
#

$cmd = "$FIG_Config::bin/pull_fasta_entries $fasta < $ids_needing_sims > $seqs_needing_sims";
$rc = system($cmd);
if ($rc != 0)
{
    &fatal("pull_fasta_entries failed with rc=$rc: $cmd");
}

#
# And chunk.
#
$cmd = "$FIG_Config::bin/rp_chunk_sims -include-self -self-fasta $fasta $seqs_needing_sims $sims_nr $sims_peg_synonyms $jobdir/sims.job > $jobdir/sims.job/chunk.out";
$rc = system($cmd);
if ($rc != 0)
{
    &fatal("rp_chunk_sims failed with rc=$rc: $cmd");
}


$meta->add_log_entry($0, "sims_preprocess completed\n");
$meta->set_metadata("status.sims_preprocess", "complete");
$meta->set_metadata("sims_preprocess.running", "no");

sub fatal
{
    my($msg) = @_;

    $meta->add_log_entry($0, ['fatal error', $msg]);
    $meta->set_metadata("status.sims_preprocess", "error");

    croak "$0: $msg";
}
    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3