Package htsjdk.tribble.util
Class ParsingUtils
java.lang.Object
htsjdk.tribble.util.ParsingUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
appendToPath
(String filepath, String indexExtension) Add theindexExtension
to thefilepath
, preserving query string elements if present.static URLHelper
getURLHelper
(URL url) Return a URLHelper from the current URLHelperFactorystatic URLHelperFactory
static <T extends Comparable<? super T>>
booleanstatic String
join an array of strings given a seperatorstatic String
join a set of strings, using the separator provided, from index start to index stopstatic <T> String
join
(String separator, Collection<T> objects) static InputStream
openInputStream
(String path) static InputStream
openInputStream
(String uri, Function<SeekableByteChannel, SeekableByteChannel> wrapper) open an input stream from the given path and wrap the raw byte stream with a wrapper if given the wrapper will only be applied to paths that are 1.static Color
parseColor
(String string) Convert an rgb string, hex, or symbol to a color.static boolean
resourceExists
(String resource) static void
setURLHelperFactory
(URLHelperFactory factory) Set the factory object for providing URLHelpers.static <T extends Comparable<T>,
V>
StringsortedString
(Map<T, V> c) static <T extends Comparable>
List<T>sortList
(Collection<T> list) a small utility function for sorting a listSplit the string into tokens separated by the given delimiter.static int
Split the string into tokesn separated by the given delimiter.static int
Split the string into tokens separated by the given delimiter.static int
splitWhitespace
(String aString, String[] tokens) Split the string into tokens separated by tab or space(s).static String
-
Field Details
-
colorCache
-
-
Constructor Details
-
ParsingUtils
public ParsingUtils()
-
-
Method Details
-
openInputStream
- Returns:
- an input stream from the given path
- Throws:
IOException
-
openInputStream
public static InputStream openInputStream(String uri, Function<SeekableByteChannel, SeekableByteChannel> wrapper) throws IOExceptionopen an input stream from the given path and wrap the raw byte stream with a wrapper if given the wrapper will only be applied to paths that are 1. not local files 2. not being handled by the legacy http(s)/ftp providers i.e. anyPath
using a custom FileSystem plugin- Parameters:
uri
- a uri like stringwrapper
- to wrap the input stream in, may be used to implement caching or prefetching, etc- Returns:
- An inputStream appropriately created from uri and conditionally wrapped with wrapper (only in certain cases)
- Throws:
IOException
- when stream cannot be opened against uri
-
join
-
sortList
a small utility function for sorting a list- Type Parameters:
T
-- Parameters:
list
-- Returns:
-
sortedString
-
join
join an array of strings given a seperator- Parameters:
separator
- the string to insert between each array elementstrings
- the array of strings- Returns:
- a string, which is the joining of all array values with the separator
-
join
join a set of strings, using the separator provided, from index start to index stop- Parameters:
separator
- the separator to usestrings
- the list of stringsstart
- the start position (index in the list)0end
- the end position (index in the list)- Returns:
- a joined string, or "" if end - start == 0
-
split
Split the string into tokens separated by the given delimiter. This looks suspiciously like what String.split should do. It is here because String.split has particularly poor performance for this use case in some versions of the Java SE API because of use of java.util.regex APIs (see bug report at http://bugs.java.com/view_bug.do?bug_id=6840246 for information).- Parameters:
input
- the string to splitdelim
- the character that delimits tokens- Returns:
- a list of the tokens
-
split
Split the string into tokesn separated by the given delimiter. Profiling has revealed that the standard string.split() method typically takes > 1/2 the total time when used for parsing ascii files.- Parameters:
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokens- Returns:
- the number of tokens parsed
-
split
public static int split(String aString, String[] tokens, char delim, boolean condenseTrailingTokens) Split the string into tokens separated by the given delimiter. Profiling has revealed that the standard string.split() method typically takes > 1/2 the total time when used for parsing ascii files.- Parameters:
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokenscondenseTrailingTokens
- if true and there are more tokens than will fit in the tokens array, condense all trailing tokens into the last token- Returns:
- the number of tokens parsed
-
trim
-
splitWhitespace
Split the string into tokens separated by tab or space(s). This method was added so support wig and bed files, which apparently accept space delimiters. Note: TODO REGEX expressions are not used for speed. This should be re-evaluated with JDK 1.5 or later- Parameters:
aString
- the string to splittokens
- an array to hold the parsed tokens- Returns:
- the number of tokens parsed
-
isSorted
-
parseColor
Convert an rgb string, hex, or symbol to a color.- Parameters:
string
-- Returns:
-
resourceExists
- Throws:
IOException
-
getURLHelper
Return a URLHelper from the current URLHelperFactory- Parameters:
url
-- Returns:
- See Also:
-
setURLHelperFactory
Set the factory object for providing URLHelpers. .- Parameters:
factory
-
-
getURLHelperFactory
-
appendToPath
Add theindexExtension
to thefilepath
, preserving query string elements if present. Intended for use wherefilepath
is a URL. Will behave correctly on regular file paths (just add the extension to the end)- Parameters:
filepath
-indexExtension
-- Returns:
-