Commit 11c99934 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Changed scala docs

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