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 StringReturn file's name (without the path)static StringReturn file's name (without the path)static Stringbin64(long l) Show a long as a 64 bit binary numberstatic booleanCan we read this file (either exact name or append a '.gz'static intcompareNull(Comparable c1, Comparable c2) static StringcompileDate(Class<?> cl) static Stringstatic StringcompileTimeStamp(Class<?> cl) Return a time-stamp showing When was the JAR file created OR when was a class compiledstatic StringcompileTimeStamp(Class<?> cl, SimpleDateFormat dateFormat) Return a time-stamp showing When was the JAR file created OR when was a class compiledstatic intcountColumns(String file) Count number of column in a filestatic intcountLines(String file) Count lines in a file (same as 'wc -l file' in unix)static StringReturn file's dirstatic booleanDoes 'file' exist?static StringGet a file's extension (all letters after the last '.'static Stringstatic StringBufferinputStream2StringBuffer(InputStream inputStream) static booleanEmpty or '-' means STDINstatic booleanstatic booleanisValidRid(int i) Is this a valid Ridstatic StringRemove spaces and tabs from string.static booleanEquivalent to Boolean.parseBoolean, except it returns 0 on invalid integer (NumberFormatException)static doubleEquivalent to Double.parseDouble(), except it returns 0 on invalid double (NumberFormatException)static floatEquivalent to Float.parseFloat(), except it returns 0 on invalid double (NumberFormatException)static intEquivalent to Integer.parseInt, except it returns 0 on invalid integer (NumberFormatException)static longEquivalent to Integer.parseInt, except it returns 0 on invalid integer (NumberFormatException)static StringprependEachLine(String prepend, Object lines) Prepend a message to each linestatic Stringread(InputStream is) Read an input streamstatic BufferedReaderTry to open a file (BufferedReader) using either the file or a gzip file (appending '.gz' to fileName)static BufferedReaderTry to open a file (BufferedReader) using either the file or a gzip file (appending '.gz' to fileName)static StringRead a file as a String.static StringRead a file as a String.static ObjectreadFileSerialized(String fileName) Read an object from a file (supposing an object was previously serialized to that file)static ObjectreadFileSerializedGz(String fileName) Read an object from a file (supposing an object was previously serialized to that file) Note: The file is compressed using GZIPstatic ObjectreadFileSerializedGzThrow(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 StringremoveBackslashR(String line) Remove trailing '\r'static Stringstatic StringRemove extension from a file (if matches one of 'fileExtensions[]')static Stringrepeat(char c, int n) Create a string of n time 'c'static StringsanityzeFileName(String fileName) static StringsanityzeName(String fileName) static voidshowMark(int i, int showEvery) Show a markstatic voidShow a markstatic voidshowMarkStderr(int i, int showEvery) Show a mark (on STDERR)static voidshowStackTrace(int steps) static voidshowStackTrace(int steps, int offset) Prints a stack trace for a number of stepsstatic String[]Splits a separated string into an array ofStringtokens.static Stringtabs(int tabs) static Stringstatic StringtoByteSize(long l) static voidWrite an object to a filestatic voidWrite an object to a filestatic voidWrite an object to a file (as a string) Note: The file is compressed using GZIPstatic voidtoFileSerialize(String fileName, Object obj) Write an object to a file by invoking Serialization methodsstatic voidtoFileSerializeGz(String fileName, Object obj) Write an object to a file by invoking Serialization methods Note: The file is compressed using GZIPstatic StringtoString(boolean[] vals) static StringtoString(double val) static StringtoString(double[] vals) static StringtoString(double[][] vals) static StringtoString(int[] vals) static StringtoStringHead(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:
IOExceptionFileNotFoundExceptionClassNotFoundException
-
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 ofStringtokens. 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
-