Class ParsingUtils

java.lang.Object
htsjdk.tribble.util.ParsingUtils

public class ParsingUtils extends Object
  • Field Details

  • Constructor Details

    • ParsingUtils

      public ParsingUtils()
  • Method Details

    • openInputStream

      public static InputStream openInputStream(String path) throws IOException
      Returns:
      an input stream from the given path
      Throws:
      IOException
    • openInputStream

      public static InputStream openInputStream(String uri, Function<SeekableByteChannel,SeekableByteChannel> wrapper) throws IOException
      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. not local files 2. not being handled by the legacy http(s)/ftp providers i.e. any Path using a custom FileSystem plugin
      Parameters:
      uri - a uri like string
      wrapper - 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

      public static <T> String join(String separator, Collection<T> objects)
    • sortList

      public static <T extends Comparable> List<T> sortList(Collection<T> list)
      a small utility function for sorting a list
      Type Parameters:
      T -
      Parameters:
      list -
      Returns:
    • sortedString

      public static <T extends Comparable<T>, V> String sortedString(Map<T,V> c)
    • join

      public static String join(String separator, String[] strings)
      join an array of strings given a seperator
      Parameters:
      separator - the string to insert between each array element
      strings - the array of strings
      Returns:
      a string, which is the joining of all array values with the separator
    • join

      public static String join(String separator, String[] strings, int start, int end)
      join a set of strings, using the separator provided, from index start to index stop
      Parameters:
      separator - the separator to use
      strings - the list of strings
      start - the start position (index in the list)0
      end - the end position (index in the list)
      Returns:
      a joined string, or "" if end - start == 0
    • split

      public static List<String> split(String input, char delim)
      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 split
      delim - the character that delimits tokens
      Returns:
      a list of the tokens
    • split

      public static int split(String aString, String[] tokens, char delim)
      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 split
      tokens - an array to hold the parsed tokens
      delim - 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 split
      tokens - an array to hold the parsed tokens
      delim - character that delimits tokens
      condenseTrailingTokens - 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

      public static String trim(String str, char ch)
    • splitWhitespace

      public static int splitWhitespace(String aString, String[] tokens)
      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 split
      tokens - an array to hold the parsed tokens
      Returns:
      the number of tokens parsed
    • isSorted

      public static <T extends Comparable<? super T>> boolean isSorted(Iterable<T> iterable)
    • parseColor

      public static Color parseColor(String string)
      Convert an rgb string, hex, or symbol to a color.
      Parameters:
      string -
      Returns:
    • resourceExists

      public static boolean resourceExists(String resource) throws IOException
      Throws:
      IOException
    • getURLHelper

      public static URLHelper getURLHelper(URL url)
      Return a URLHelper from the current URLHelperFactory
      Parameters:
      url -
      Returns:
      See Also:
    • setURLHelperFactory

      public static void setURLHelperFactory(URLHelperFactory factory)
      Set the factory object for providing URLHelpers. .
      Parameters:
      factory -
    • getURLHelperFactory

      public static URLHelperFactory getURLHelperFactory()
    • appendToPath

      public static String appendToPath(String filepath, String indexExtension)
      Add the indexExtension to the filepath, preserving query string elements if present. Intended for use where filepath is a URL. Will behave correctly on regular file paths (just add the extension to the end)
      Parameters:
      filepath -
      indexExtension -
      Returns: