Package

com.fulcrumgenomics.commons

util

Permalink

package util

Visibility
  1. Public
  2. All

Type Members

  1. trait CaptureSystemStreams extends AnyRef

    Permalink

    Methods to help capture stdin and stderr

  2. final class ClassFinder extends AnyRef

    Permalink
  3. class Configuration extends ConfigurationLike

    Permalink

    Class that provides useful methods for resolving all kinds of things in configuration.

    Class that provides useful methods for resolving all kinds of things in configuration. Uses Config to retrieve configuration values in a type-safe way.

    The requestedKeys method returns all the keys requested.

    The public methods to retrieve values are the apply, get, and getOrElse methods.

    Examples:
    1. A common pattern is to create an object that extends this class, and reference that object when retrieving values from a path. An additional trait is created that references the custom configuration object, allowing other classes to mix in the additional trait to get access the the configuration methods that use the custom configuration object.

      scala> import com.fulcrumgenomics.commons.util.{Configuration, ConfigurationLike}
      scala> import com.typesafe.config.{Config, ConfigFactory}
      scala> // create an object that stores the config that will be referenced everywhere
      scala> object CustomConfiguration extends Configuration(ConfigFactory.load())
      scala> // create the trait that can be mixed into other classes to get access to the configuration methods that use the custom configuration object
      scala> trait CustomConfiguration extends ConfigurationLike { protected def config: Config = CustomConfiguration.config }
      scala> // create a class that mixes in the custom configuration trait
      scala> class Foo extends CustomConfiguration { val maybeLong: Option[Long] = this.get[Long]("path.does-not-exist") }
      scala> val foo = new Foo()
      scala> foo.maybeLong
      res0: Option[Long] = None
      scala> foo.get("path.does-not-exist")
      res1: Option[Long] = None
      scala> foo[Long]("path.does-exists-and-is-1")
      res2: Long = 1
      scala> foo.getOrElse[Long]("path.does-not-exist", 2)
      res3: Long = 2
    2. ,
    3. A common pattern is to create an object that extends this class, and reference that object when retrieving values from a path.

      scala> import com.fulcrumgenomics.commons.util.Configuration
      scala> import com.typesafe.config.{Config, ConfigFactory}
      scala> object CustomConfiguration extends Configuration(ConfigFactory.load())
      scala> CustomConfiguration.get[Long]("path.does-not-exist")
      res0: Option[Long] = None
  4. trait ConfigurationLike extends AnyRef

    Permalink

    Trait that provides useful methods for resolving all kinds of things in configuration.

    Trait that provides useful methods for resolving all kinds of things in configuration. Uses Config to retrieve configuration values in a type-safe way.

    The config method must be implemented by a subclass, giving the Config from which to retrieve configuration values.

    Overriding the keyRequested method allows a call to be received each time a configuration path is requested.

    Overriding the handle method allows a subclass to determine how errors are handled.

    Extending the asType method allows a subclass to support additional (possibly custom) types.

    The fetch method is used to retrieve configuration values.

    Example:
    1. Retrieve a value at a given path:

      scala> import com.fulcrumgenomics.commons.util.ConfigurationLike
      scala> import com.typesafe.config.{Config, ConfigFactory}
      scala> import scala.reflect.runtime.universe.TypeTag
      scala> val conf = new ConfigurationLike {
        val config: Config = ConfigFactory.parseString("""a.str = "string", a.int = 2, a.set = [1,2,3]""")
        def get[T : TypeTag](path: String): Option[T] = fetch[T](path)
      }
      scala> conf.get[String]("a.str")
      res0: Option[String] = Some(string)
      scala> conf.get[Int]("a.int")
      res1: Option[Int] = Some(2)
      scala> conf.get[Set[Int]]("a.set")
      res2: Option[Set[Int]] = Some(Set(1, 2, 3))
      scala> conf.get[Set[Int]]("a.does-not-exist")
      res3: Option[Set[Int]] = None
      scala> conf.get[Int]("a.set")
      java.lang.IllegalArgumentException: Exception retrieving configuration key 'a.set'
      ...
  5. class DelimitedDataParser extends Iterator[Row] with LazyLogging

    Permalink

    A parser for files of text columns delimited by some character (e.g.

    A parser for files of text columns delimited by some character (e.g. tab-delimited or csv).

  6. trait LazyLogging extends AnyRef

    Permalink

    Trait that can be mixed into classes to provide a Logger that is constructed at first access.

  7. final class LogLevel extends Enum[LogLevel]

    Permalink
  8. class Logger extends AnyRef

    Permalink

    Very simple logging class that supports logging at multiple levels.

  9. class NumericCounter[T] extends SimpleCounter[T]

    Permalink

    Super-simple class for counting occurrences of any [Numeric].

    Super-simple class for counting occurrences of any [Numeric]. Will return zero for any item that has not been counted yet. Implements some useful methods to compute statistics when the objects being counted are numeric types.

  10. class Row extends AnyRef

    Permalink

    Represents a row of parsed data.

    Represents a row of parsed data. Provides methods for accessing values in a type-safe way either via apply() methods for non-optional fields or via get for optional fields.

  11. class SimpleCounter[T] extends Iterable[(T, Long)]

    Permalink

    Super-simple class for counting occurrences of any kind of object.

    Super-simple class for counting occurrences of any kind of object. Will return zero for any item that has not been counted yet.

Value Members

  1. object Configuration

    Permalink

    Companion object to Configuration.

  2. object DelimitedDataParser

    Permalink
  3. object Logger

    Permalink

    Companion object for the Logger class that holds the system-wide log level, and a PrintWriter to write to.

  4. object NumericCounter

    Permalink
  5. object SimpleCounter

    Permalink
  6. object StringUtil

    Permalink
  7. object TimeUtil

    Permalink

Ungrouped