Skip to content
Snippets Groups Projects
Commit 11c99934 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Changed scala docs

parent 1c158133
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,7 @@ import org.broadinstitute.gatk.queue.function.scattergather.ScatterGatherableFun
import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging }
import scala.collection.mutable.ListBuffer
/**
* Base for biopet pipeline
*/
/** Base for biopet pipeline */
trait BiopetQScript extends Configurable with GatkLogging {
@Argument(doc = "JSON / YAML config file(s)", fullName = "config_file", shortName = "config", required = false)
......@@ -36,6 +34,7 @@ trait BiopetQScript extends Configurable with GatkLogging {
@Argument(doc = "Config values, value should be formatted like 'key=value' or 'path:path:key=value'", fullName = "config_value", shortName = "cv", required = false)
val configValues: List[String] = Nil
/** Output directory of pipeline */
var outputDir: File = {
if (config.contains("output_dir", path = Nil)) config("output_dir", path = Nil).asFile
else new File(".")
......@@ -58,9 +57,7 @@ trait BiopetQScript extends Configurable with GatkLogging {
/** Pipeline itself */
def biopetScript
/**
* Script from queue itself, final to force some checks for each pipeline and write report
*/
/** Script from queue itself, final to force some checks for each pipeline and write report */
final def script() {
outputDir = config("output_dir")
outputDir = outputDir.getAbsoluteFile
......
......@@ -20,9 +20,7 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Config
import nl.lumc.sasc.biopet.core.workaround.BiopetQCommandLine
/**
* Wrapper around executable from Queue
*/
/** Wrapper around executable from Queue */
trait PipelineCommand extends MainCommand with GatkLogging {
/**
......@@ -31,10 +29,7 @@ trait PipelineCommand extends MainCommand with GatkLogging {
*/
def pipeline = "/" + getClass.getName.stripSuffix("$").replaceAll("\\.", "/") + ".class"
/**
* Class can be used directly from java with -cp option
* @param args
*/
/** Class can be used directly from java with -cp option */
def main(args: Array[String]): Unit = {
val argsSize = args.size
for (t <- 0 until argsSize) {
......
......@@ -20,8 +20,6 @@ import nl.lumc.sasc.biopet.core.Logging
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.ConfigUtils._
import scala.reflect.io.Directory
/**
* This class can store nested config values
* @param map Map with value for new config
......
......@@ -19,64 +19,34 @@ import java.io.File
import nl.lumc.sasc.biopet.utils.ConfigUtils._
class ConfigValue(val requestIndex: ConfigValueIndex, val foundIndex: ConfigValueIndex, val value: Any, val default: Boolean) {
/**
* Get value as String
* @return value as String
*/
/** Get value as String */
def asString = any2string(value)
/**
* Get value as File
* @return value as File
*/
/** Get value as File */
def asFile = new File(any2string(value))
/**
* Get value as Int
* @return value as Int
*/
/** Get value as Int */
def asInt = any2int(value)
/**
* Get value as Double
* @return value as Double
*/
/** Get value as Double */
def asDouble = any2double(value)
/**
* Get value as List[Any]
* @return value as List[Any]
*/
/** Get value as List[Any] */
def asList = any2list(value)
/**
* Get value as List[File]
* @return value as List[File]
*/
/** Get value as List[File] */
def asFileList: List[File] = for (file <- any2stringList(value)) yield new File(file)
/**
* Get value as List[String]
* @return value as List[String]
*/
/** Get value as List[String] */
def asStringList: List[String] = any2stringList(value)
/**
* Get value as Map
* @return value as Map
*/
/** Get value as Map */
def asMap = any2map(value)
/**
* Get value as Boolean
* @return value as Boolean
*/
/** Get value as Boolean */
def asBoolean = any2boolean(value)
/**
* Readable output of indexes and value, just for debug
* @return
*/
/** Readable output of indexes and value, just for debug */
override def toString: String = {
var output = "key = " + requestIndex.key
output += ", value = " + value
......
......@@ -15,9 +15,7 @@
*/
package nl.lumc.sasc.biopet.core.config
import nl.lumc.sasc.biopet.core.Logging
import nl.lumc.sasc.biopet.utils.ConfigUtils.ImplicitConversions
import scala.collection.JavaConversions._
trait Configurable extends ImplicitConversions {
/** Should be object of parant object */
......@@ -58,9 +56,7 @@ trait Configurable extends ImplicitConversions {
(if (submodule != null) configPath ::: configName :: Nil else configPath)
}
/**
* Class is used for retrieval of config values
*/
/** Class is used for retrieval of config values */
protected class ConfigFunctions(val defaultSample: Option[String] = None, val defaultLibrary: Option[String] = None) {
def this(defaultSample: String, defaultLibrary: String) = {
this(defaultSample = Some(defaultSample), defaultLibrary = Some(defaultLibrary))
......
......@@ -21,7 +21,6 @@ import nl.lumc.sasc.biopet.core.Logging
import nl.lumc.sasc.biopet.core.config.ConfigValue
import argonaut._, Argonaut._
import org.yaml.snakeyaml.Yaml
import scala.collection.mutable
import scalaz._, Scalaz._
import scala.collection.JavaConversions._
......@@ -87,11 +86,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Make json aboject from a file
* @param configFile Input file
* @return Json object
*/
/** Make json aboject from a file */
def fileToJson(configFile: File): Json = {
logger.debug("Jsonfile: " + configFile)
val jsonText = scala.io.Source.fromFile(configFile).mkString
......@@ -103,11 +98,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert config value to map
* @param configFile
* @return Config map
*/
/** Convert config value to map */
def fileToConfigMap(configFile: File): Map[String, Any] = {
val configMap = {
......@@ -118,22 +109,14 @@ object ConfigUtils extends Logging {
return configMap
}
/**
* Convert a yaml file to map[String, Any]
* @param file Input file
* @return config map
*/
/** Convert a yaml file to map[String, Any] */
def yamlToMap(file: File): Map[String, Any] = {
val yaml = new Yaml()
val a = yaml.load(scala.io.Source.fromFile(file).reader())
ConfigUtils.any2map(a)
}
/**
* Convert json to native scala map/values
* @param json input json
* @return
*/
/** Convert json to native scala map/values */
def jsonToMap(json: Json): Map[String, Any] = {
var output: Map[String, Any] = Map()
if (json.isObject) {
......@@ -145,11 +128,7 @@ object ConfigUtils extends Logging {
return output
}
/**
* Convert json value to native scala value
* @param json input json
* @return
*/
/** Convert json value to native scala value */
def jsonToAny(json: Json): Any = {
if (json.isObject) return jsonToMap(json)
else if (json.isArray) {
......@@ -166,11 +145,7 @@ object ConfigUtils extends Logging {
else throw new IllegalStateException("Config value type not supported, value: " + json)
}
/**
* Convert native scala map to json
* @param map Input map
* @return
*/
/** Convert native scala map to json */
def mapToJson(map: Map[String, Any]): Json = {
map.foldLeft(jEmptyObject)((acc, kv) => (kv._1 := {
kv._2 match {
......@@ -180,11 +155,7 @@ object ConfigUtils extends Logging {
}) ->: acc)
}
/**
* Convert native scala value to json, fall back on .toString if type is not a native scala value
* @param any Input Any value
* @return
*/
/** Convert native scala value to json, fall back on .toString if type is not a native scala value */
def anyToJson(any: Any): Json = {
any match {
case j: Json => j
......@@ -202,11 +173,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to String
* @param any Input Any value
* @return
*/
/** Convert Any to String */
def any2string(any: Any): String = {
if (any == null) return null
any match {
......@@ -215,11 +182,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to Int
* @param any Input Any value
* @return
*/
/** Convert Any to Int */
def any2int(any: Any): Int = {
any match {
case i: Int => i
......@@ -233,11 +196,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to Long
* @param any Input Any value
* @return
*/
/** Convert Any to Long */
def any2long(any: Any): Long = {
any match {
case l: Double => l.toLong
......@@ -251,11 +210,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to Double
* @param any Input Any value
* @return
*/
/** Convert Any to Double */
def any2double(any: Any): Double = {
any match {
case d: Double => d
......@@ -270,11 +225,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to Float
* @param any Input Any value
* @return
*/
/** Convert Any to Float */
def any2float(any: Any): Float = {
any match {
case f: Double => f.toFloat
......@@ -289,11 +240,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to Boolean
* @param any Input Any value
* @return
*/
/** Convert Any to Boolean */
def any2boolean(any: Any): Boolean = {
any match {
case b: Boolean => b
......@@ -309,11 +256,7 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to List[Any], fallback on list with 1 value
* @param any Input Any value
* @return
*/
/** Convert Any to List[Any], fallback on list with 1 value */
def any2list(any: Any): List[Any] = {
if (any == null) return null
any match {
......@@ -322,31 +265,19 @@ object ConfigUtils extends Logging {
}
}
/**
* Convert Any to List[String]
* @param any Input Any value
* @return
*/
/** Convert Any to List[String] */
def any2stringList(any: Any): List[String] = {
if (any == null) return null
any2list(any).map(_.toString)
}
/**
* Convert Any to List[File]
* @param any Input Any value
* @return
*/
/** Convert Any to List[File] */
def any2fileList(any: Any): List[File] = {
if (any == null) return null
any2list(any).map(x => new File(x.toString))
}
/**
* Convert Any to Map[String, Any]
* @param any Input Any value
* @return
*/
/** Convert Any to Map[String, Any] */
def any2map(any: Any): Map[String, Any] = {
if (any == null) return null
any match {
......@@ -366,9 +297,7 @@ object ConfigUtils extends Logging {
}).toMap
}
/**
* Trait for implicit conversions for ConfigValue to native scala values
*/
/** Trait for implicit conversions for ConfigValue to native scala values */
trait ImplicitConversions {
import scala.language.implicitConversions
......@@ -385,191 +314,115 @@ object ConfigUtils extends Logging {
value != null && value.value != null && value.value != None
}
/**
* Convert ConfigValue to File
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to File */
implicit def configValue2file(value: ConfigValue): File = {
if (requiredValue(value)) new File(any2string(value.value))
else new File("")
}
/**
* Convert ConfigValue to File
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to File */
implicit def configValue2optionFile(value: ConfigValue): Option[File] = {
if (valueExists(value)) Some(new File(any2string(value.value)))
else None
}
/**
* Convert ConfigValue to String
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to String */
implicit def configValue2string(value: ConfigValue): String = {
if (requiredValue(value)) any2string(value.value)
else ""
}
/**
* Convert ConfigValue to String
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to String */
implicit def configValue2optionString(value: ConfigValue): Option[String] = {
if (valueExists(value)) Some(any2string(value.value))
else None
}
/**
* Convert ConfigValue to Long
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Long */
implicit def configValue2long(value: ConfigValue): Long = {
if (requiredValue(value)) any2long(value.value)
else 0L
}
/**
* Convert ConfigValue top Option[Long]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue top Option[Long] */
implicit def configValue2optionLong(value: ConfigValue): Option[Long] = {
if (valueExists(value)) Option(any2long(value.value))
else None
}
/**
* Convert ConfigValue to Int
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Int */
implicit def configValue2int(value: ConfigValue): Int = {
if (requiredValue(value)) any2int(value.value)
else 0
}
/**
* Convert ConfigValue to Option[Int]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Option[Int] */
implicit def configValue2optionInt(value: ConfigValue): Option[Int] = {
if (valueExists(value)) Option(any2int(value.value))
else None
}
/**
* Convert ConfigValue to Double
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Double */
implicit def configValue2double(value: ConfigValue): Double = {
if (requiredValue(value)) any2double(value.value)
else 0.0
}
/**
* Convert ConfigValue to Option[Double]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Option[Double] */
implicit def configValue2optionDouble(value: ConfigValue): Option[Double] = {
if (valueExists(value)) Option(any2double(value.value))
else None
}
/**
* Convert ConfigValue to Float
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Float */
implicit def configValue2float(value: ConfigValue): Float = {
if (requiredValue(value)) any2float(value.value)
else 0f
}
/**
* Convert ConfigValue to Option[Float]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Option[Float] */
implicit def configValue2optionFloat(value: ConfigValue): Option[Float] = {
if (valueExists(value)) Option(any2float(value.value))
else None
}
/**
* Convert ConfigValue to Boolean
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Boolean */
implicit def configValue2boolean(value: ConfigValue): Boolean = {
if (requiredValue(value)) any2boolean(value.value)
else false
}
/**
* Convert ConfigValue to Option[Boolean]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Option[Boolean] */
implicit def configValue2optionBoolean(value: ConfigValue): Option[Boolean] = {
if (valueExists(value)) Option(any2boolean(value.value))
else None
}
/**
* Convert ConfigValue to List[Any]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to List[Any] */
implicit def configValue2list(value: ConfigValue): List[Any] = {
if (requiredValue(value)) any2list(value.value)
else Nil
}
/**
* Convert ConfigValue to List[String]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to List[String] */
implicit def configValue2stringList(value: ConfigValue): List[String] = {
if (requiredValue(value)) any2stringList(value.value)
else Nil
}
/**
* Convert ConfigValue to List[File]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to List[File] */
implicit def configValue2fileList(value: ConfigValue): List[File] = {
if (requiredValue(value)) any2fileList(value.value)
else Nil
}
/**
* Convert ConfigValue to Set[String]
* @param value Input ConfigValue
* @return
*/
/** Convert ConfigValue to Set[String] */
implicit def configValue2stringSet(value: ConfigValue): Set[String] = {
if (requiredValue(value)) any2stringList(value.value).toSet
else Set()
}
/**
* Config config value to Map[String, Any]
* @param value Input ConfigValue
* @return
*/
/** Config config value to Map[String, Any] */
implicit def configValue2map(value: ConfigValue): Map[String, Any] = {
if (requiredValue(value)) any2map(value.value)
else Map()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment