Package htsjdk.variant.utils

# Class GeneralUtils

java.lang.Object
htsjdk.variant.utils.GeneralUtils

public class GeneralUtils extends Object
Constants and utility methods used throughout the VCF/BCF/VariantContext classes

## Field Summary

Fields
Modifier and Type
Field
Description
`static final boolean`
`DEBUG_MODE_ENABLED`
Setting this to true causes the VCF/BCF/VariantContext classes to emit debugging information to standard error
`static final double`
`LOG10_P_OF_ZERO`
The smallest log10 value we'll emit from normalizeFromLog10 and other functions where the real-space value is 0.0.

## Constructor Summary

Constructors
Constructor
Description
`GeneralUtils()`

## Method Summary

Modifier and Type
Method
Description
`static 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>`
`cons(T elt, List<T> l)`
`static <T> String`
`join(String separator, Collection<T> objects)`
Returns a string of the form elt1.toString() [sep elt2.toString() ...
`static <T> List<List<T>>`
`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-space
`static final <T> List<T>`
`reverse(List<T> l)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEBUG_MODE_ENABLED

public static final boolean DEBUG_MODE_ENABLED
Setting this to true causes the VCF/BCF/VariantContext classes to emit debugging information to standard error

See Also:
  - Constant Field Values

### LOG10_P_OF_ZERO

public static final double LOG10_P_OF_ZERO
The smallest log10 value we'll emit from normalizeFromLog10 and other functions where the real-space value is 0.0.

See Also:
  - Constant Field Values

## Constructor Details

### GeneralUtils

public GeneralUtils()

## Method Details

### join

public static <T> String join(String separator, Collection<T> objects)
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 objects
  `objects` - 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 normalized
  `takeLog10OfOutput` - 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

public static <T> List<T> cons(T elt, List<T> l)

### makePermutations

public static <T> List<List<T>> 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]]

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 value
  `b` - 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 value
  `b` - the second double value
  `epsilon` - 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

public static final <T> List<T> reverse(List<T> l)