Package org.snpeff.util
Class Gpr
java.lang.Object
org.snpeff.util.Gpr
General pupose rutines
- Author:
- root
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Return file's name (without the path)static String
Return file's name (without the path)static String
bin64
(long l) Show a long as a 64 bit binary numberstatic boolean
Can we read this file (either exact name or append a '.gz'static int
compareNull
(Comparable c1, Comparable c2) static String
compileDate
(Class<?> cl) static String
static String
compileTimeStamp
(Class<?> cl) Return a time-stamp showing When was the JAR file created OR when was a class compiledstatic String
compileTimeStamp
(Class<?> cl, SimpleDateFormat dateFormat) Return a time-stamp showing When was the JAR file created OR when was a class compiledstatic int
countColumns
(String file) Count number of column in a filestatic int
countLines
(String file) Count lines in a file (same as 'wc -l file' in unix)static String
Return file's dirstatic boolean
Does 'file' exist?static String
Get a file's extension (all letters after the last '.'static String
static StringBuffer
inputStream2StringBuffer
(InputStream inputStream) static boolean
Empty or '-' means STDINstatic boolean
static boolean
isValidRid
(int i) Is this a valid Ridstatic String
Remove spaces and tabs from string.static boolean
Equivalent to Boolean.parseBoolean, except it returns 0 on invalid integer (NumberFormatException)static double
Equivalent to Double.parseDouble(), except it returns 0 on invalid double (NumberFormatException)static float
Equivalent to Float.parseFloat(), except it returns 0 on invalid double (NumberFormatException)static int
Equivalent to Integer.parseInt, except it returns 0 on invalid integer (NumberFormatException)static long
Equivalent to Integer.parseInt, except it returns 0 on invalid integer (NumberFormatException)static String
prependEachLine
(String prepend, Object lines) Prepend a message to each linestatic String
read
(InputStream is) Read an input streamstatic BufferedReader
Try to open a file (BufferedReader) using either the file or a gzip file (appending '.gz' to fileName)static BufferedReader
Try to open a file (BufferedReader) using either the file or a gzip file (appending '.gz' to fileName)static String
Read a file as a String.static String
Read a file as a String.static Object
readFileSerialized
(String fileName) Read an object from a file (supposing an object was previously serialized to that file)static Object
readFileSerializedGz
(String fileName) Read an object from a file (supposing an object was previously serialized to that file) Note: The file is compressed using GZIPstatic Object
readFileSerializedGzThrow
(String fileName) Read an object from a file (supposing an object was previously serialized to that file) Note: Same as 'readFileSerializedGz' but it throws all the exceptionsstatic String
removeBackslashR
(String line) Remove trailing '\r'static String
static String
Remove extension from a file (if matches one of 'fileExtensions[]')static String
repeat
(char c, int n) Create a string of n time 'c'static String
sanityzeFileName
(String fileName) static String
sanityzeName
(String fileName) static void
showMark
(int i, int showEvery) Show a markstatic void
Show a markstatic void
showMarkStderr
(int i, int showEvery) Show a mark (on STDERR)static void
showStackTrace
(int steps) static void
showStackTrace
(int steps, int offset) Prints a stack trace for a number of stepsstatic String[]
Splits a separated string into an array ofString
tokens.static String
tabs
(int tabs) static String
static String
toByteSize
(long l) static void
Write an object to a filestatic void
Write an object to a filestatic void
Write an object to a file (as a string) Note: The file is compressed using GZIPstatic void
toFileSerialize
(String fileName, Object obj) Write an object to a file by invoking Serialization methodsstatic void
toFileSerializeGz
(String fileName, Object obj) Write an object to a file by invoking Serialization methods Note: The file is compressed using GZIPstatic String
toString
(boolean[] vals) static String
toString
(double val) static String
toString
(double[] vals) static String
toString
(double[][] vals) static String
toString
(int[] vals) static String
toStringHead
(double[] vals)
-
Field Details
-
KB
public static final long KB- See Also:
-
MB
public static final long MB- See Also:
-
GB
public static final long GB- See Also:
-
TB
public static final long TB- See Also:
-
NUM_CORES
public static final int NUM_CORES -
HOME
-
GZIP_EXTENTIONS
-
-
Constructor Details
-
Gpr
public Gpr()
-
-
Method Details
-
baseName
Return file's name (without the path) -
baseName
Return file's name (without the path) -
bin64
Show a long as a 64 bit binary number -
canRead
Can we read this file (either exact name or append a '.gz' -
compareNull
-
compileDate
-
compileTimeStamp
-
compileTimeStamp
Return a time-stamp showing When was the JAR file created OR when was a class compiled -
compileTimeStamp
Return a time-stamp showing When was the JAR file created OR when was a class compiled -
countColumns
Count number of column in a file -
countLines
Count lines in a file (same as 'wc -l file' in unix)- Parameters:
file
-- Returns:
-
dirName
Return file's dir -
exists
Does 'file' exist? -
extName
Get a file's extension (all letters after the last '.' -
head
-
inputStream2StringBuffer
- Throws:
IOException
-
isStdin
Empty or '-' means STDIN -
isValidIp
-
isValidRid
public static boolean isValidRid(int i) Is this a valid Rid -
noSpaces
Remove spaces and tabs from string. -
parseBoolSafe
Equivalent to Boolean.parseBoolean, except it returns 0 on invalid integer (NumberFormatException) -
parseDoubleSafe
Equivalent to Double.parseDouble(), except it returns 0 on invalid double (NumberFormatException) -
parseFloatSafe
Equivalent to Float.parseFloat(), except it returns 0 on invalid double (NumberFormatException)- Parameters:
s
-- Returns:
- int
-
parseIntSafe
Equivalent to Integer.parseInt, except it returns 0 on invalid integer (NumberFormatException)- Parameters:
s
-- Returns:
- int
-
parseLongSafe
Equivalent to Integer.parseInt, except it returns 0 on invalid integer (NumberFormatException)- Parameters:
s
-- Returns:
- int
-
prependEachLine
Prepend a message to each line -
read
Read an input stream- Parameters:
is
-- Returns:
-
reader
Try to open a file (BufferedReader) using either the file or a gzip file (appending '.gz' to fileName) -
reader
Try to open a file (BufferedReader) using either the file or a gzip file (appending '.gz' to fileName)- Parameters:
gzip
- : If true, file is assumed to be gzipped
-
readFile
Read a file as a String. Note: the file can be compressed using gzip (file name must have a ".gz" extension).- Parameters:
fileName
- : File to read (null on error)showExceptions
- : show exceptions if true
-
readFile
Read a file as a String. Note: the file can be compressed using gzip (file name must have a ".gz" extension).- Parameters:
fileName
- : File to read (null on error)showExceptions
- : show exceptions if true
-
readFileSerialized
Read an object from a file (supposing an object was previously serialized to that file)- Parameters:
fileName
-- Returns:
- An object from that file
-
readFileSerializedGz
Read an object from a file (supposing an object was previously serialized to that file) Note: The file is compressed using GZIP- Parameters:
fileName
-- Returns:
- An object from that file
-
readFileSerializedGzThrow
public static Object readFileSerializedGzThrow(String fileName) throws FileNotFoundException, IOException, ClassNotFoundException Read an object from a file (supposing an object was previously serialized to that file) Note: Same as 'readFileSerializedGz' but it throws all the exceptions- Parameters:
fileName
-- Returns:
- An object from that file
- Throws:
IOException
FileNotFoundException
ClassNotFoundException
-
removeBackslashR
Remove trailing '\r' -
removeExt
-
removeExt
Remove extension from a file (if matches one of 'fileExtensions[]') -
repeat
Create a string of n time 'c' -
sanityzeFileName
-
sanityzeName
-
showMark
public static void showMark(int i, int showEvery) Show a mark -
showMark
Show a mark -
showMarkStderr
public static void showMarkStderr(int i, int showEvery) Show a mark (on STDERR) -
showStackTrace
public static void showStackTrace(int steps) -
showStackTrace
public static void showStackTrace(int steps, int offset) Prints a stack trace for a number of steps- Parameters:
count
-
-
split
Splits a separated string into an array ofString
tokens. If the input string is null, this method returns null. Implementation note: for performance reasons, this implementation uses neither StringTokenizer nor String.split(). StringTokenizer does not return all tokens for strings of the form "1,2,,3," unless you use an instance that returns the separator. By doing so, our code would need to modify the token string which would create another temporary object and would make this method very slow.
String.split does not return all tokens for strings of the form "1,2,3,,,". We simply cannot use this method. The result is a custom String splitter algorithm which performs well for large Strings.- Parameters:
value
- the string value to split into tokens- Returns:
- an array of String Objects or null if the string value is null
-
tabs
-
tail
-
toByteSize
-
toFile
Write an object to a file -
toFile
Write an object to a file -
toFileGz
Write an object to a file (as a string) Note: The file is compressed using GZIP- Parameters:
fileName
- : File to writeobj
- : Object
-
toFileSerialize
Write an object to a file by invoking Serialization methods- Parameters:
fileName
- : File to writeobj
- : Object
-
toFileSerializeGz
Write an object to a file by invoking Serialization methods Note: The file is compressed using GZIP- Parameters:
fileName
- : File to writeobj
- : Object
-
toString
-
toString
-
toString
-
toString
-
toString
-
toStringHead
-