Coping out and forcing the entire GATK (and associated JVM) to use US English
locale. Method to force JVM into proper locale exists in CommandLineProgram and is disabled by default, but implementers of CommandLineProgram can opt in to the forced US locale by calling a static method. Question for the VCF developers: I removed the code to explicitly output doubles in US locale. Do you / how do you want to handle this in applications that use Tribble outside the GATK? git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3917 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
b5b2c19124
commit
5f1b67c1de
|
|
@ -25,11 +25,7 @@
|
|||
|
||||
package org.broad.tribble.vcf;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class VCFConstants {
|
||||
public static final Locale VCF_LOCALE = Locale.US;
|
||||
|
||||
// standard INFO/FORMAT field keys
|
||||
public static final String ANCESTRAL_ALLELE_KEY = "AA";
|
||||
public static final String ALLELE_COUNT_KEY = "AC";
|
||||
|
|
|
|||
|
|
@ -32,10 +32,7 @@ import org.broadinstitute.sting.utils.help.HelpFormatter;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Enumeration;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class CommandLineProgram {
|
||||
|
||||
|
|
@ -400,4 +397,11 @@ public abstract class CommandLineProgram {
|
|||
public void generateErrorLog(PrintStream stream, Exception e) {
|
||||
stream.println(e.getStackTrace().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* A hack to ensure that numbers are always formatted in the US style.
|
||||
*/
|
||||
protected static void forceJVMLocaleToUSEnglish() {
|
||||
Locale.setDefault(Locale.US);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,14 @@ public class CommandLineGATK extends CommandLineExecutable {
|
|||
return argCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* The very first thing that the GATK does is forces the JVM locale into US English, so that we don't have
|
||||
* to think about number formatting issues.
|
||||
*/
|
||||
{
|
||||
forceJVMLocaleToUSEnglish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Required main method implementation.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public class VCFWriter {
|
|||
}
|
||||
|
||||
private String getQualValue(double qual) {
|
||||
String s = String.format(VCFConstants.VCF_LOCALE, VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, qual);
|
||||
String s = String.format(VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, qual);
|
||||
if ( s.endsWith(VCFConstants.DOUBLE_PRECISION_INT_SUFFIX) )
|
||||
s = s.substring(0, s.length() - VCFConstants.DOUBLE_PRECISION_INT_SUFFIX.length());
|
||||
return s;
|
||||
|
|
@ -365,7 +365,7 @@ public class VCFWriter {
|
|||
if ( val == null )
|
||||
result = VCFConstants.MISSING_VALUE_v4;
|
||||
else if ( val instanceof Double )
|
||||
result = String.format(VCFConstants.VCF_LOCALE, VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, (Double)val);
|
||||
result = String.format(VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, (Double)val);
|
||||
else if ( val instanceof Boolean )
|
||||
result = (Boolean)val ? "" : null; // empty string for true, null for false
|
||||
else if ( val instanceof List ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue