Skip to content

Commit

Permalink
Many small fixes:
Browse files Browse the repository at this point in the history
- Don't change 'undef' into an empty string during fixCase().
- Add getUnitigger() to return the unitigger, setting to default if needed.
- Use getUnitigger() in all the places where the unitigger is needed; during
  OBT, the default value was not set correctly.
- Remove a symlink from 5-consensus-insert-sizes after it is no longer needed.
- Remove an unused symlink from 5-consensus-split.
- Use relative symlinks in the 6-clonesize/$asm.tigStore directory.
- Use relative symlinks in the 10-toggledAsm ovlStore and gkpStore.
- Fix warnings about finding or removing files that don't exist.
- Fix detecting the last checkpoint if 7-1-ECR is the first stage to run.
- Redirect overlap_partition output to log file.
  • Loading branch information
brianwalenz committed Jun 17, 2013
1 parent 1c8a970 commit f486a06
Showing 1 changed file with 62 additions and 37 deletions.
99 changes: 62 additions & 37 deletions src/AS_RUN/runCA.pl
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,11 @@ ($)
sub fixCase ($) {
my $var = shift @_;
my $val = getGlobal($var);
$val =~ tr/A-Z/a-z/;
setGlobal($var, $val);

if (defined($val)) {
$val =~ tr/A-Z/a-z/;
setGlobal($var, $val);
}
}

sub setParametersFromFile ($@) {
Expand Down Expand Up @@ -1110,11 +1113,9 @@ ($)

$dir = "$wrk/$dir" if (! -d $dir);

open(F, "ls -1 $dir/$asm.ckp.[0-9]* |");
open(F, "find -L $dir -type f -name $asm.ckp.\[0-9\]\* |");
while (<F>) {
chomp;

if (m/ckp.(\d+)$/) {
if (m/ckp.(\d+)\s*$/) {
$firstckp = $1 if ($1 < $firstckp);
}
}
Expand All @@ -1129,11 +1130,9 @@ ($)

$dir = "$wrk/$dir" if (-d "$wrk/$dir");

open(F, "ls -1 $dir/$asm.ckp.[0-9]* |");
open(F, "find -L $dir -type f -name $asm.ckp.\[0-9\]\* |");
while (<F>) {
chomp;

if (m/ckp.(\d+)$/) {
if (m/ckp.(\d+)\s*$/) {
$lastckp = $1 if ($1 > $lastckp);
}
}
Expand Down Expand Up @@ -1188,6 +1187,29 @@ ($$)
}




# Default to unitigger, unless the gkpStore says otherwise.
#
sub getUnitigger () {
my $unitigger = getGlobal("unitigger");

if (!defined($unitigger)) {
setGlobal("unitigger", "utg");

if (system("$bin/gatekeeper -isfeatureset 0 forceBOGunitigger $wrk/$asm.gkpStore") == 0) {
setGlobal("unitigger", "bog");
}
}

$unitigger = getGlobal("unitigger");

die "Unitigger not defined.\n" if (!defined($unitigger));

return($unitigger);
}


# Decide if we have the CA meryl or the Mighty one.
#
sub merylVersion () {
Expand Down Expand Up @@ -3596,7 +3618,8 @@ ($)
$cmd .= " -H $hashLibrary \\\n" if ($hashLibrary ne "0");
$cmd .= " -R $refLibrary \\\n" if ($refLibrary ne "0");
$cmd .= " -C \\\n" if (!$checkLibrary);
$cmd .= " -o $wrk/$outDir";
$cmd .= " -o $wrk/$outDir \\\n";
$cmd .= "> $wrk/$outDir/overlap_partition.err 2>&1";

if (runCommand($wrk, $cmd)) {
caFailure("failed partition for overlapper", undef);
Expand Down Expand Up @@ -3992,7 +4015,7 @@ sub overlapTrim {
my $erate = 0.03; # Used for non-Sanger 'largest covered' style
my $elimit = 4.5;

my $utg = getGlobal("unitigger");
my $utg = getUnitigger();

if ($utg eq "utg") {
$erate = getGlobal("utgErrorRate");
Expand Down Expand Up @@ -4547,16 +4570,6 @@ ()
goto alldone;
}

# Default to unitigger, unless the gkpStore says otherwise.
#
if (!defined(getGlobal("unitigger"))) {
setGlobal("unitigger", "utg");

if (system("$bin/gatekeeper -isfeatureset 0 forceBOGunitigger $wrk/$asm.gkpStore") == 0) {
setGlobal("unitigger", "bog");
}
}

system("mkdir $wrk/4-unitigger") if (! -e "$wrk/4-unitigger");

my $e = getGlobal("utgErrorRate"); # Unitigger and BOG
Expand All @@ -4572,7 +4585,7 @@ ()

my $u = getGlobal("utgBubblePopping");

my $unitigger = getGlobal("unitigger");
my $unitigger = getUnitigger();

if ($unitigger eq "bogart") {
my $th = getGlobal("batThreads");
Expand Down Expand Up @@ -4619,7 +4632,7 @@ ()
$cmd .= " -o $wrk/4-unitigger/$asm ";
$cmd .= " > $wrk/4-unitigger/unitigger.err 2>&1";
} else {
caFailure("unknown unitigger $unitigger; must be 'bog' or 'utg'", undef);
caFailure("unknown unitigger '$unitigger'; must be 'bog' or 'utg'", undef);
}

stopBefore("unitigger", $cmd);
Expand Down Expand Up @@ -4787,10 +4800,14 @@ ()
#
# Estimate insert size estimates
#
# tigStore writes output files using the tigStore as a prefix. We thus need to temporarily symlink
# The tigStore to the proper directory.
#

if (! -e "$wrk/5-consensus-insert-sizes/estimates.out") {
system("mkdir $wrk/5-consensus-insert-sizes") if (! -d "$wrk/5-consensus-insert-sizes");
system("ln -s $wrk/$asm.tigStore $wrk/5-consensus-insert-sizes/$asm.tigStore");

system("ln -s ../$asm.tigStore $wrk/5-consensus-insert-sizes/$asm.tigStore");

$cmd = "$bin/tigStore \\\n";
$cmd .= " -g $wrk/$asm.gkpStore \\\n";
Expand All @@ -4801,7 +4818,9 @@ ()
if (runCommand("$wrk/5-consensus-insert-sizes", $cmd)) {
caFailure("Insert size estimation failed", "$wrk/5-consensus-insert-sizes/estimates.out");
}
}

unlink("$wrk/5-consensus-insert-sizes/$asm.tigStore");
}

#
# Update estimates in gatekeeper
Expand Down Expand Up @@ -4830,7 +4849,6 @@ ()

if (! -e "$wrk/5-consensus-split/splitUnitigs.out") {
system("mkdir $wrk/5-consensus-split") if (! -d "$wrk/5-consensus-split");
system("ln -s $wrk/$asm.tigStore $wrk/5-consensus-split/$asm.tigStore");

$cmd = "$bin/splitUnitigs \\\n";
$cmd .= " -g $wrk/$asm.gkpStore \\\n";
Expand Down Expand Up @@ -5069,7 +5087,14 @@ ($$$)

# Remove any existing eCR scripts -- possibly left behind by the user deleting
# the partitioinInfo and restarting.
system("rm $wrk/$thisDir/extendClearRanges-scaffold.*");

open(F, "find -L $wrk/$thisDir -name 'extendClearRanges-scaffold.*' -print |");
while (<F>) {
chomp;
print STDERR "Repartitioned; remove extraneous file $_\n";
unlink $_;
}
close(F);
}

# Read the partitioning info, create jobs. No partitions? No ECR jobs.
Expand Down Expand Up @@ -5140,7 +5165,7 @@ ($$$)
sub updateDistanceRecords ($) {
my $thisDir = shift @_;

return if (-e "$wrk/$thisDir/$asm.distupdate.success");
return $thisDir if (-e "$wrk/$thisDir/$asm.distupdate.success");

open(F, "> $wrk/$thisDir/$asm.distupdate");

Expand Down Expand Up @@ -5199,7 +5224,7 @@ ()
if ($cis == 1) {
if (! -e "$wrk/6-clonesize/$asm.tigStore") {
system("mkdir -p $wrk/6-clonesize/$asm.tigStore");
system("ln -s $wrk/$asm.tigStore/* $wrk/6-clonesize/$asm.tigStore");
system("cd $wrk/6-clonesize/$asm.tigStore && ln -s ../../$asm.tigStore/* .");
}
updateDistanceRecords(CGW("6-clonesize", undef, "$wrk/6-clonesize/$asm.tigStore", $stoneLevel, undef, 0));
}
Expand Down Expand Up @@ -5880,7 +5905,7 @@ ()
# A simple link to the ovlStore suffices.
#
if (! -e "$wrk/$toggledDir/$asm.ovlStore") {
system("ln -s $wrk/$asm.ovlStore $wrk/$toggledDir/$asm.ovlStore");
system("ln -s ../$asm.ovlStore $wrk/$toggledDir/$asm.ovlStore");
}

# The gatekeeper store must be paritally copied, so that we can first undo
Expand All @@ -5890,9 +5915,9 @@ ()
if (! -e "$wrk/$toggledDir/$asm.gkpStore") {
system("mkdir $wrk/$toggledDir/$asm.gkpStore");

system("ln -s $wrk/$asm.gkpStore/[qsu]?? $wrk/$toggledDir/$asm.gkpStore/");
system("cp $wrk/$asm.gkpStore/[filp]?? $wrk/$toggledDir/$asm.gkpStore/");
system("cp $wrk/$asm.gkpStore/clr-* $wrk/$toggledDir/$asm.gkpStore/");
system("cd $wrk/$toggledDir/$asm.gkpStore && ln -s ../..//$asm.gkpStore/[qsu]?? .");
system("cp $wrk/$asm.gkpStore/[filp]?? $wrk/$toggledDir/$asm.gkpStore/");
system("cp $wrk/$asm.gkpStore/clr-* $wrk/$toggledDir/$asm.gkpStore/");

$cmd = "$bin/gatekeeper";
$cmd .= " --revertclear OBTCHIMERA $wrk/$toggledDir/$asm.gkpStore";
Expand All @@ -5908,11 +5933,11 @@ ()
if (! -e "$wrk/$toggledDir/$asm.tigStore") {
system("mkdir $wrk/$toggledDir/$asm.tigStore") ;

system("ln -s $wrk/$asm.tigStore/*v00[12345]* $wrk/$toggledDir/$asm.tigStore/");
system("cd $wrk/$toggledDir/$asm.tigStore && ln -s ../../$asm.tigStore/*v00[12345]* .");
}

system("ln -s $wrk/4-unitigger $wrk/$toggledDir") if (! -e "$wrk/$toggledDir/4-unitigger");
system("ln -s $wrk/5-consensus $wrk/$toggledDir") if (! -e "$wrk/$toggledDir/5-consensus");
system("ln -s ../4-unitigger $wrk/$toggledDir") if (! -e "$wrk/$toggledDir/4-unitigger");
system("ln -s ../5-consensus $wrk/$toggledDir") if (! -e "$wrk/$toggledDir/5-consensus");

# Update the tigStore, flipping repeat untigs to unique unitigs.
#
Expand Down

0 comments on commit f486a06

Please sign in to comment.