Commit 84a7f167 authored by bow's avatar bow
Browse files

Update main interface

parent 59bb05d8
......@@ -16,33 +16,30 @@ import nl.lumc.sasc.biopet.pipelines.sage.Sage
object BiopetExecutable {
val pipelines: Map[String, PipelineCommand] = Map(
"flexiprep" -> Flexiprep,
"mapping" -> Mapping,
"gentrap" -> Gentrap,
"bam-metrics" -> BamMetrics,
"gatk-benchmark-genotyping" -> GatkBenchmarkGenotyping,
"gatk-genotyping" -> GatkGenotyping,
"gatk-variantcalling" -> GatkVariantcalling,
"gatk-pipeline" -> GatkPipeline,
"gatk-variant-recalibration" -> GatkVariantRecalibration,
"gatk-vcf-sample-compare" -> GatkVcfSampleCompare,
"sage" -> Sage,
"basty" -> Basty
)
val tools: Map[String, ToolCommand] = Map(
"WipeReads" -> WipeReads
)
val pipelines: List[MainCommand] = List(
Flexiprep,
Mapping,
Gentrap,
BamMetrics,
GatkBenchmarkGenotyping,
GatkGenotyping,
GatkVariantcalling,
GatkPipeline,
GatkVariantRecalibration,
GatkVcfSampleCompare,
Sage,
Basty)
val tools: List[MainCommand] = List(
WipeReads)
/**
* @param args the command line arguments
*/
def main(args: Array[String]): Unit = {
def toBulletedList(m: Map[String, Any], kind: String = "", bullet: String = "-") =
"Available %s:\n ".format(kind) + bullet + " " +
m.keys.toVector.sorted.mkString("\n " + bullet + " ")
def toBulletedList(m: List[MainCommand], kind: String = "", bullet: String = "-") =
"Available %s:\n ".format(kind) + bullet + " " + m.map(x => x.name).sorted.mkString("\n " + bullet + " ")
lazy val pipelineList: String = toBulletedList(pipelines, "pipelines")
......@@ -78,34 +75,37 @@ object BiopetExecutable {
System.exit(1)
}
def retrieveCommand(q: String, cl: List[MainCommand]): Option[MainCommand] = {
for (mc <- cl) {
if (q == mc.name.toLowerCase)
return Some(mc)
}
None
}
args match {
case Array("pipeline", pipelineName, pipelineArgs @ _*) =>
if (pipelines.contains(pipelineName))
if (pipelineArgs.isEmpty) {
pipelines(pipelineName).main(Array("--help"))
System.exit(1)
}
else {
pipelines(pipelineName).main(pipelineArgs.toArray)
retrieveCommand(pipelineName.toLowerCase, pipelines) match {
case Some(pipeline) =>
pipeline.main(pipelineArgs.toArray)
System.exit(0)
}
else {
System.err.println(s"ERROR: pipeline '$pipelineName' does not exist")
System.err.println(pipelineUsage)
System.exit(1)
case None =>
System.err.println(s"ERROR: pipeline '$pipelineName' does not exist")
System.err.println(pipelineUsage)
System.exit(1)
}
case Array("pipeline") =>
System.err.println(pipelineUsage)
System.exit(1)
case Array("tool", toolName, toolArgs @ _*) =>
if (tools.contains(toolName)) {
tools(toolName).main(toolArgs.toArray)
System.exit(0)
}
else {
System.err.println(s"ERROR: tool '$toolName' does not exist")
System.err.println(toolUsage)
System.exit(1)
retrieveCommand(toolName.toLowerCase, tools) match {
case Some(tool) =>
tool.main(toolArgs.toArray)
System.exit(0)
case None =>
System.err.println(s"ERROR: tool '$toolName' does not exist")
System.err.println(toolUsage)
System.exit(1)
}
case Array("tool") =>
System.err.println(toolUsage)
......
......@@ -3,9 +3,9 @@ package nl.lumc.sasc.biopet.core
import org.broadinstitute.gatk.queue.util.Logging
trait ToolCommand extends Logging {
trait MainCommand extends Logging {
lazy val toolName = this.getClass.getSimpleName
lazy val name = this.getClass.getSimpleName
.split("\\$").last
def main(args: Array[String])
......
package nl.lumc.sasc.biopet.core
import org.broadinstitute.gatk.queue.util.Logging
trait PipelineCommand extends Logging {
trait PipelineCommand extends MainCommand {
val pipeline = ""
def main(args: Array[String]): Unit = {
......
......@@ -19,7 +19,7 @@ import org.apache.commons.io.FilenameUtils.getExtension
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.ToolCommand
import nl.lumc.sasc.biopet.core.MainCommand
import nl.lumc.sasc.biopet.core.config.Configurable
// TODO: finish implementation for usage in pipelines
......@@ -40,7 +40,7 @@ class WipeReads(val root: Configurable) extends BiopetJavaCommandLineFunction {
}
object WipeReads extends ToolCommand {
object WipeReads extends MainCommand {
/** Container type for command line flags */
type OptionMap = Map[String, Any]
......@@ -458,9 +458,9 @@ object WipeReads extends ToolCommand {
val usage: String =
s"""
|Usage: java -jar BiopetFramework.jar tool $toolName [options] -I input -l regions -o output
|Usage: java -jar BiopetFramework.jar tool $name [options] -I input -l regions -o output
|
|$toolName - Tool for reads removal from an indexed BAM file
|$name - Tool for reads removal from an indexed BAM file
|
|Positional arguments:
| -I,--inputBAM Input BAM file, must be indexed with
......@@ -482,5 +482,5 @@ object WipeReads extends ToolCommand {
|This tool will remove BAM records that overlaps a set of given regions.
|By default, if the removed reads are also mapped to other regions outside
|the given ones, they will also be removed.
""".stripMargin.format(toolName, toolName)
""".stripMargin
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment