2010-06-15 12:43:46 +08:00
|
|
|
package org.broadinstitute.sting.queue
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
import org.broadinstitute.sting.queue.util.Logging
|
2010-10-16 04:00:35 +08:00
|
|
|
import org.broadinstitute.sting.queue.function.QFunction
|
2010-06-15 12:43:46 +08:00
|
|
|
|
|
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Defines a Queue pipeline as a collection of CommandLineFunctions.
|
2010-06-15 12:43:46 +08:00
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
trait QScript extends Logging {
|
2010-06-15 12:43:46 +08:00
|
|
|
// Type aliases so users don't have to import
|
|
|
|
|
type File = java.io.File
|
2010-06-26 04:51:13 +08:00
|
|
|
type Input = org.broadinstitute.sting.commandline.Input
|
|
|
|
|
type Output = org.broadinstitute.sting.commandline.Output
|
2010-08-10 00:42:48 +08:00
|
|
|
type Argument = org.broadinstitute.sting.commandline.Argument
|
|
|
|
|
type ArgumentCollection = org.broadinstitute.sting.commandline.ArgumentCollection
|
2010-06-15 12:43:46 +08:00
|
|
|
type CommandLineFunction = org.broadinstitute.sting.queue.function.CommandLineFunction
|
2010-10-16 04:00:35 +08:00
|
|
|
type InProcessFunction = org.broadinstitute.sting.queue.function.InProcessFunction
|
2010-06-23 02:39:20 +08:00
|
|
|
type ScatterGatherableFunction = org.broadinstitute.sting.queue.function.scattergather.ScatterGatherableFunction
|
2010-06-26 04:51:13 +08:00
|
|
|
type Gather = org.broadinstitute.sting.queue.function.scattergather.Gather
|
2010-06-23 02:39:20 +08:00
|
|
|
type SimpleTextGatherFunction = org.broadinstitute.sting.queue.function.scattergather.SimpleTextGatherFunction
|
2010-06-15 12:43:46 +08:00
|
|
|
|
|
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Builds the CommandLineFunctions that will be used to run this script and adds them to this.functions directly or using the add() utility method.
|
2010-06-15 12:43:46 +08:00
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
def script: Unit
|
2010-06-15 12:43:46 +08:00
|
|
|
|
|
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* The command line functions that will be executed for this QScript.
|
2010-06-15 12:43:46 +08:00
|
|
|
*/
|
2010-10-16 04:00:35 +08:00
|
|
|
var functions = List.empty[QFunction]
|
2010-06-15 12:43:46 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Exchanges the extension on a file.
|
2010-10-16 01:01:36 +08:00
|
|
|
* @param file File to look for the extension.
|
|
|
|
|
* @param oldExtension Old extension to strip off, if present.
|
|
|
|
|
* @param newExtension New extension to append.
|
|
|
|
|
* @return new File with the new extension in the current directory.
|
2010-06-15 12:43:46 +08:00
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
protected def swapExt(file: File, oldExtension: String, newExtension: String) =
|
2010-06-15 12:43:46 +08:00
|
|
|
new File(file.getName.stripSuffix(oldExtension) + newExtension)
|
|
|
|
|
|
2010-10-16 01:01:36 +08:00
|
|
|
/**
|
|
|
|
|
* Exchanges the extension on a file.
|
|
|
|
|
* @param dir New directory for the file.
|
|
|
|
|
* @param file File to look for the extension.
|
|
|
|
|
* @param oldExtension Old extension to strip off, if present.
|
|
|
|
|
* @param newExtension New extension to append.
|
|
|
|
|
* @return new File with the new extension in dir.
|
|
|
|
|
*/
|
|
|
|
|
protected def swapExt(dir: String, file: File, oldExtension: String, newExtension: String) =
|
|
|
|
|
new File(dir, file.getName.stripSuffix(oldExtension) + newExtension)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Exchanges the extension on a file.
|
|
|
|
|
* @param dir New directory for the file.
|
|
|
|
|
* @param file File to look for the extension.
|
|
|
|
|
* @param oldExtension Old extension to strip off, if present.
|
|
|
|
|
* @param newExtension New extension to append.
|
|
|
|
|
* @return new File with the new extension in dir.
|
|
|
|
|
*/
|
|
|
|
|
protected def swapExt(dir: File, file: File, oldExtension: String, newExtension: String) =
|
|
|
|
|
new File(dir, file.getName.stripSuffix(oldExtension) + newExtension)
|
|
|
|
|
|
2010-06-15 12:43:46 +08:00
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Adds one or more command line functions to be run.
|
2010-10-16 01:01:36 +08:00
|
|
|
* @param functions Functions to add.
|
2010-06-15 12:43:46 +08:00
|
|
|
*/
|
2010-10-16 04:00:35 +08:00
|
|
|
def add(functions: QFunction*) = {
|
|
|
|
|
functions.foreach(function => function.addOrder = QScript.nextAddOrder)
|
|
|
|
|
this.functions ++= functions
|
|
|
|
|
}
|
2010-12-12 13:10:45 +08:00
|
|
|
|
|
|
|
|
def addAll(functions: List[QFunction] ) = {
|
|
|
|
|
functions.foreach( f => add(f) )
|
|
|
|
|
}
|
2010-10-16 04:00:35 +08:00
|
|
|
}
|
2010-10-08 21:30:28 +08:00
|
|
|
|
2010-10-16 04:00:35 +08:00
|
|
|
object QScript {
|
|
|
|
|
private var addOrder = 0
|
|
|
|
|
private def nextAddOrder = {
|
|
|
|
|
addOrder += 1
|
|
|
|
|
List(addOrder)
|
|
|
|
|
}
|
2010-06-15 12:43:46 +08:00
|
|
|
}
|