Package htsjdk.variant.utils
Class GeneralUtils
java.lang.Object
htsjdk.variant.utils.GeneralUtils
Constants and utility methods used throughout the VCF/BCF/VariantContext classes
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Setting this to true causes the VCF/BCF/VariantContext classes to emit debugging information to standard errorstatic final double
The smallest log10 value we'll emit from normalizeFromLog10 and other functions where the real-space value is 0.0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
arrayMax
(double[] array) static byte
compareDoubles
(double a, double b) Compares double values for equality (within 1e-6), or inequality.static byte
compareDoubles
(double a, double b, double epsilon) Compares double values for equality (within epsilon), or inequality.static <T> List<T>
static <T> String
join
(String separator, Collection<T> objects) Returns a string of the form elt1.toString() [sep elt2.toString() ...makePermutations
(List<T> objects, int n, boolean withReplacement) Make all combinations of N size of objects if objects = [A, B, C] if N = 1 => [[A], [B], [C]] if N = 2 => [[A, A], [B, A], [C, A], [A, B], [B, B], [C, B], [A, C], [B, C], [C, C]]static int
maxElementIndex
(double[] array) static int
maxElementIndex
(double[] array, int endIndex) static double[]
normalizeFromLog10
(double[] array) normalizes the log10-based array.static double[]
normalizeFromLog10
(double[] array, boolean takeLog10OfOutput) normalizes the log10-based array.static double[]
normalizeFromLog10
(double[] array, boolean takeLog10OfOutput, boolean keepInLogSpace) See #normalizeFromLog10 but with the additional option to use an approximation that keeps the calculation always in log-spacestatic final <T> List<T>
-
Field Details
-
DEBUG_MODE_ENABLED
public static final boolean DEBUG_MODE_ENABLEDSetting this to true causes the VCF/BCF/VariantContext classes to emit debugging information to standard error- See Also:
-
LOG10_P_OF_ZERO
public static final double LOG10_P_OF_ZEROThe smallest log10 value we'll emit from normalizeFromLog10 and other functions where the real-space value is 0.0.- See Also:
-
-
Constructor Details
-
GeneralUtils
public GeneralUtils()
-
-
Method Details
-
join
Returns a string of the form elt1.toString() [sep elt2.toString() ... sep elt.toString()] for a collection of elti objects (note there's no actual space between sep and the elti elements). Returns "" if collection is empty. If collection contains just elt, then returns elt.toString()- Type Parameters:
T
- the type of the objects- Parameters:
separator
- the string to use to separate objectsobjects
- a collection of objects. the element order is defined by the iterator over objects- Returns:
- a non-null string
-
normalizeFromLog10
public static double[] normalizeFromLog10(double[] array) normalizes the log10-based array. ASSUMES THAT ALL ARRAY ENTRIES ARE <= 0 (<= 1 IN REAL-SPACE).- Parameters:
array
- the array to be normalized- Returns:
- a newly allocated array corresponding the normalized values in array
-
normalizeFromLog10
public static double[] normalizeFromLog10(double[] array, boolean takeLog10OfOutput) normalizes the log10-based array. ASSUMES THAT ALL ARRAY ENTRIES ARE <= 0 (<= 1 IN REAL-SPACE).- Parameters:
array
- the array to be normalizedtakeLog10OfOutput
- if true, the output will be transformed back into log10 units- Returns:
- a newly allocated array corresponding the normalized values in array, maybe log10 transformed
-
normalizeFromLog10
public static double[] normalizeFromLog10(double[] array, boolean takeLog10OfOutput, boolean keepInLogSpace) See #normalizeFromLog10 but with the additional option to use an approximation that keeps the calculation always in log-space- Parameters:
array
-takeLog10OfOutput
-keepInLogSpace
-- Returns:
-
arrayMax
public static double arrayMax(double[] array) -
maxElementIndex
public static int maxElementIndex(double[] array) -
maxElementIndex
public static int maxElementIndex(double[] array, int endIndex) -
cons
-
makePermutations
Make all combinations of N size of objects if objects = [A, B, C] if N = 1 => [[A], [B], [C]] if N = 2 => [[A, A], [B, A], [C, A], [A, B], [B, B], [C, B], [A, C], [B, C], [C, C]]- Type Parameters:
T
-- Parameters:
objects
-n
-withReplacement
- if false, the resulting permutations will only contain unique objects from objects- Returns:
-
compareDoubles
public static byte compareDoubles(double a, double b) Compares double values for equality (within 1e-6), or inequality.- Parameters:
a
- the first double valueb
- the second double value- Returns:
- -1 if a is greater than b, 0 if a is equal to be within 1e-6, 1 if b is greater than a.
-
compareDoubles
public static byte compareDoubles(double a, double b, double epsilon) Compares double values for equality (within epsilon), or inequality.- Parameters:
a
- the first double valueb
- the second double valueepsilon
- the precision within which two double values will be considered equal- Returns:
- -1 if a is greater than b, 0 if a is equal to be within epsilon, 1 if b is greater than a.
-
reverse
-