Merge branch 'master' of ssh://gsa1/humgen/gsa-scr1/gsa-engineering/git/unstable

This commit is contained in:
Mark DePristo 2011-11-22 17:19:11 -05:00
commit 990c02e4de
4 changed files with 53 additions and 33 deletions

View File

@ -392,7 +392,7 @@ public abstract class CommandLineProgram {
/** /**
* used to indicate an error occured * used to indicate an error occured
* *
* @param e the exception occured * @param t the exception that occurred
*/ */
public static void exitSystemWithError(Throwable t) { public static void exitSystemWithError(Throwable t) {
exitSystemWithError(t.getMessage(), t); exitSystemWithError(t.getMessage(), t);

View File

@ -30,7 +30,6 @@ import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.ArgumentCollection;
import org.broadinstitute.sting.commandline.CommandLineProgram; import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection; import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
import org.broadinstitute.sting.gatk.filters.ReadFilter;
import org.broadinstitute.sting.gatk.refdata.tracks.FeatureManager; import org.broadinstitute.sting.gatk.refdata.tracks.FeatureManager;
import org.broadinstitute.sting.gatk.walkers.Attribution; import org.broadinstitute.sting.gatk.walkers.Attribution;
import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.Walker;
@ -97,13 +96,20 @@ public class CommandLineGATK extends CommandLineExecutable {
// lazy loaded, so they aren't caught elsewhere and made into User Exceptions // lazy loaded, so they aren't caught elsewhere and made into User Exceptions
exitSystemWithUserError(e); exitSystemWithUserError(e);
} catch (net.sf.samtools.SAMException e) { } catch (net.sf.samtools.SAMException e) {
// Let's try this out and see how it is received by our users checkForTooManyOpenFilesProblem(e.getMessage());
exitSystemWithSamError(e); exitSystemWithSamError(e);
} catch (Throwable t) { } catch (Throwable t) {
checkForTooManyOpenFilesProblem(t.getMessage());
exitSystemWithError(t); exitSystemWithError(t);
} }
} }
private static void checkForTooManyOpenFilesProblem(String message) {
// Special case the "Too many open files" error because it's a common User Error for which we know what to do
if ( message.indexOf("Too many open files") != -1 )
exitSystemWithUserError(new UserException.TooManyOpenFiles());
}
/** /**
* Creates the a short blurb about the GATK, copyright info, and where to get documentation. * Creates the a short blurb about the GATK, copyright info, and where to get documentation.
* *

View File

@ -556,40 +556,48 @@ public class PairHMMIndelErrorModel {
long indStart = start - haplotype.getStartPosition(); long indStart = start - haplotype.getStartPosition();
long indStop = stop - haplotype.getStartPosition(); long indStop = stop - haplotype.getStartPosition();
final byte[] haplotypeBases = Arrays.copyOfRange(haplotype.getBases(),
(int)indStart, (int)indStop);
double readLikelihood; double readLikelihood;
if (matchMetricArray == null) {
final int X_METRIC_LENGTH = readBases.length+1;
final int Y_METRIC_LENGTH = haplotypeBases.length+1;
matchMetricArray = new double[X_METRIC_LENGTH][Y_METRIC_LENGTH]; if (indStart < 0 || indStop >= haplotype.getBases().length) {
XMetricArray = new double[X_METRIC_LENGTH][Y_METRIC_LENGTH]; // read spanned more than allowed reference context: we currently can't deal with this
YMetricArray = new double[X_METRIC_LENGTH][Y_METRIC_LENGTH]; readLikelihood =0;
} } else
final double[] currentContextGOP = Arrays.copyOfRange(gapOpenProbabilityMap.get(a), (int)indStart, (int)indStop); {
final double[] currentContextGCP = Arrays.copyOfRange(gapContProbabilityMap.get(a), (int)indStart, (int)indStop); final byte[] haplotypeBases = Arrays.copyOfRange(haplotype.getBases(),
if (previousHaplotypeSeen == null) (int)indStart, (int)indStop);
startIdx = 0;
else { if (matchMetricArray == null) {
final int s1 = computeFirstDifferingPosition(haplotypeBases, previousHaplotypeSeen); final int X_METRIC_LENGTH = readBases.length+1;
final int s2 = computeFirstDifferingPosition(currentContextGOP, previousGOP); final int Y_METRIC_LENGTH = haplotypeBases.length+1;
final int s3 = computeFirstDifferingPosition(currentContextGCP, previousGCP);
startIdx = Math.min(Math.min(s1, s2), s3); matchMetricArray = new double[X_METRIC_LENGTH][Y_METRIC_LENGTH];
} XMetricArray = new double[X_METRIC_LENGTH][Y_METRIC_LENGTH];
previousHaplotypeSeen = haplotypeBases.clone(); YMetricArray = new double[X_METRIC_LENGTH][Y_METRIC_LENGTH];
previousGOP = currentContextGOP.clone(); }
previousGCP = currentContextGCP.clone(); final double[] currentContextGOP = Arrays.copyOfRange(gapOpenProbabilityMap.get(a), (int)indStart, (int)indStop);
final double[] currentContextGCP = Arrays.copyOfRange(gapContProbabilityMap.get(a), (int)indStart, (int)indStop);
if (previousHaplotypeSeen == null)
startIdx = 0;
else {
final int s1 = computeFirstDifferingPosition(haplotypeBases, previousHaplotypeSeen);
final int s2 = computeFirstDifferingPosition(currentContextGOP, previousGOP);
final int s3 = computeFirstDifferingPosition(currentContextGCP, previousGCP);
startIdx = Math.min(Math.min(s1, s2), s3);
}
previousHaplotypeSeen = haplotypeBases.clone();
previousGOP = currentContextGOP.clone();
previousGCP = currentContextGCP.clone();
readLikelihood = computeReadLikelihoodGivenHaplotypeAffineGaps(haplotypeBases, readBases, readQuals, readLikelihood = computeReadLikelihoodGivenHaplotypeAffineGaps(haplotypeBases, readBases, readQuals,
currentContextGOP, currentContextGCP, startIdx, matchMetricArray, XMetricArray, YMetricArray); currentContextGOP, currentContextGCP, startIdx, matchMetricArray, XMetricArray, YMetricArray);
if (DEBUG) {
System.out.println("H:"+new String(haplotypeBases)); if (DEBUG) {
System.out.println("R:"+new String(readBases)); System.out.println("H:"+new String(haplotypeBases));
System.out.format("L:%4.2f\n",readLikelihood); System.out.println("R:"+new String(readBases));
System.out.format("StPos:%d\n", startIdx); System.out.format("L:%4.2f\n",readLikelihood);
System.out.format("StPos:%d\n", startIdx);
}
} }
readEl.put(a,readLikelihood); readEl.put(a,readLikelihood);
readLikelihoods[readIdx][j++] = readLikelihood; readLikelihoods[readIdx][j++] = readLikelihood;

View File

@ -100,6 +100,12 @@ public class UserException extends ReviewedStingException {
} }
} }
public static class TooManyOpenFiles extends UserException {
public TooManyOpenFiles() {
super(String.format("There was a failure because there are too many files open concurrently; your system's open file handle limit is too small. See the unix ulimit command to adjust this limit"));
}
}
public static class ErrorWritingBamFile extends UserException { public static class ErrorWritingBamFile extends UserException {
public ErrorWritingBamFile(String message) { public ErrorWritingBamFile(String message) {
super(String.format("An error occurred when trying to write the BAM file. Usually this happens when there is not enough space in the directory to which the data is being written (generally the temp directory) or when your system's open file handle limit is too small. To tell Java to use a bigger/better file system use -Djava.io.tmpdir=X on the command line. The exact error was %s", message)); super(String.format("An error occurred when trying to write the BAM file. Usually this happens when there is not enough space in the directory to which the data is being written (generally the temp directory) or when your system's open file handle limit is too small. To tell Java to use a bigger/better file system use -Djava.io.tmpdir=X on the command line. The exact error was %s", message));