Improvements to the error display code to print out the SVN number in all messages. Fixes to CallableLoci and tests to check for that case

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4270 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-09-13 18:36:45 +00:00
parent 4d0ff336c2
commit fa3be2209f
3 changed files with 35 additions and 17 deletions

View File

@ -26,6 +26,8 @@
package org.broadinstitute.sting.commandline;
import org.apache.log4j.*;
import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
import org.broadinstitute.sting.utils.help.HelpFormatter;
@ -350,17 +352,19 @@ public abstract class CommandLineProgram {
* @param msg the message
* @param e the error
*/
public static void exitSystemWithError(final String msg, Exception e) {
public static void exitSystemWithError(String msg, final Exception e) {
errorPrintf("------------------------------------------------------------------------------------------%n");
errorPrintf("stack trace %n");
e.printStackTrace();
errorPrintf("------------------------------------------------------------------------------------------%n");
errorPrintf("A GATK RUNTIME ERROR has occurred:%n");
errorPrintf("A GATK RUNTIME ERROR has occurred (version %s):%n", CommandLineGATK.getVersionNumber());
errorPrintf("%n");
errorPrintf("Please visit to wiki to see if this is a known problem%n");
errorPrintf("If not, please post the error, with stack trace, to the GATK forum%n");
printDocumentationReference();
if ( msg == null ) // some exceptions don't have detailed messages
msg = "Code exception (see stack trace for error itself)";
errorPrintf("%n");
errorPrintf("MESSAGE: %s%n", msg.trim());
errorPrintf("------------------------------------------------------------------------------------------%n");
@ -368,8 +372,12 @@ public abstract class CommandLineProgram {
}
public static void exitSystemWithUserError(UserException e) {
if ( e.getMessage() == null )
throw new ReviewedStingException("UserException found with no message!", e);
errorPrintf("------------------------------------------------------------------------------------------%n");
errorPrintf("A USER ERROR has occurred. The invalid arguments or inputs must be corrected before the GATK can proceed%n");
errorPrintf("A USER ERROR has occurred (version %s): %n", CommandLineGATK.getVersionNumber());
errorPrintf("The invalid arguments or inputs must be corrected before the GATK can proceed%n");
errorPrintf("%n");
errorPrintf("See the documentation (rerun with -h) for this tool to view allowable command-line argument.%n");
printDocumentationReference();

View File

@ -183,17 +183,17 @@ public class CallableLociWalker extends LocusWalker<CallableLociWalker.CallableB
if ( outputFormat == OutputFormat.STATE_PER_BASE ) {
out.println(state.toString());
}
// format is integrating
if ( integrator.state == null )
integrator.state = state;
else if ( state.getLocation().getStart() != integrator.state.getLocation().getStop() + 1 ||
integrator.state.changingState(state.getState()) ) {
out.println(integrator.state.toString());
integrator.state = state;
} else {
// format is integrating
if ( integrator.state == null )
integrator.state = state;
else if ( state.getLocation().getStart() != integrator.state.getLocation().getStop() + 1 ||
integrator.state.changingState(state.getState()) ) {
out.println(integrator.state.toString());
integrator.state = state;
} else {
integrator.state.update(state.getLocation());
}
integrator.state.update(state.getLocation());
}
return integrator;
@ -207,7 +207,8 @@ public class CallableLociWalker extends LocusWalker<CallableLociWalker.CallableB
public void onTraversalDone(Integrator result) {
// print out the last state
if ( result != null ) {
out.println(result.state.toString());
if ( outputFormat == OutputFormat.BED ) // get the last interval
out.println(result.state.toString());
try {
PrintStream summaryOut = new PrintStream(summaryFile);
@ -215,7 +216,6 @@ public class CallableLociWalker extends LocusWalker<CallableLociWalker.CallableB
for ( CalledState state : CalledState.values() ) {
summaryOut.printf("%30s %d%n", state, result.counts[state.ordinal()]);
}
summaryOut.close();
} catch (FileNotFoundException e) {
throw new UserException.CouldNotCreateOutputFile(summaryFile, e);

View File

@ -32,14 +32,24 @@ import java.util.Arrays;
public class CallableLociWalkerIntegrationTest extends WalkerTest {
final static String commonArgs = "-R " + b36KGReference + " -T CallableLoci -I " + validationDataLocation + "/NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -o %s";
final static String SUMMARY_MD5 = "ed4c255bb78313b8e7982127caf3d6c4";
@Test
public void testCallableLociWalker1() {
public void testCallableLociWalkerBed() {
String gatk_args = commonArgs + " -format BED -L 1:10,000,000-11,000,000 -summary %s";
WalkerTestSpec spec = new WalkerTestSpec(gatk_args, 2,
Arrays.asList("884c9c2d96419d990a708d2bd98fcefa", "ed4c255bb78313b8e7982127caf3d6c4"));
Arrays.asList("884c9c2d96419d990a708d2bd98fcefa", SUMMARY_MD5));
executeTest("formatBed", spec);
}
@Test
public void testCallableLociWalkerPerBase() {
String gatk_args = commonArgs + " -format STATE_PER_BASE -L 1:10,000,000-11,000,000 -summary %s";
WalkerTestSpec spec = new WalkerTestSpec(gatk_args, 2,
Arrays.asList("fb4524f8b3b213060c0c5b85362b5902", SUMMARY_MD5));
executeTest("format_state_per_base", spec);
}
@Test
public void testCallableLociWalker2() {
String gatk_args = commonArgs + " -format BED -L 1:10,000,000-10,000,100;1:10,000,110-10,000,120 -summary %s";