Skip to content

Commit

Permalink
Fix the -list_comparisons argument in CompareAdam (resolves #90)
Browse files Browse the repository at this point in the history
Added control flow in CompareADAM.scala to return options for -list_arguments flag when no arguments (files) are provided.
  • Loading branch information
jvivian committed Feb 6, 2015
1 parent 20b621d commit e4f3520
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions adam-cli/src/main/scala/org/bdgenomics/adam/cli/CompareADAM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.bdgenomics.adam.rdd.read.comparisons.ComparisonTraversalEngine
import org.bdgenomics.adam.util._
import org.bdgenomics.utils.metrics.{ Collection, Histogram }
import org.bdgenomics.utils.metrics.aggregators.{ HistogramAggregator, CombinedAggregator, AggregatedCollection, Writable }
import org.kohsuke.args4j.{ Option => Args4jOption, Argument }
import org.kohsuke.args4j.{ Option => Args4jOption, Argument, CmdLineParser }
import scala.collection.Seq

/**
Expand Down Expand Up @@ -98,10 +98,10 @@ object CompareADAM extends ADAMCommandCompanion with Serializable {

class CompareADAMArgs extends Args4jBase with ParquetArgs with Serializable {

@Argument(required = true, metaVar = "INPUT1", usage = "The first ADAM file to compare", index = 0)
@Argument(required = false, metaVar = "INPUT1", usage = "The first ADAM file to compare", index = 0)
val input1Path: String = null

@Argument(required = true, metaVar = "INPUT2", usage = "The second ADAM file to compare", index = 1)
@Argument(required = false, metaVar = "INPUT2", usage = "The second ADAM file to compare", index = 1)
val input2Path: String = null

@Args4jOption(required = false, name = "-recurse1", metaVar = "REGEX",
Expand Down Expand Up @@ -174,13 +174,21 @@ class CompareADAM(protected val args: CompareADAMArgs) extends ADAMSparkCommand[

def run(sc: SparkContext, job: Job): Unit = {

if (args.listComparisons) {
// Work around for -list_comparisons (doesn't require @Arguments)
if (!args.listComparisons) {
if (args.input1Path == null || args.input2Path == null) {
val options = new CompareADAMArgs
val parser = new CmdLineParser(options)
println("\n2 Arguments (files) must be given as input.\n")
parser.printUsage(System.err)
sys.exit(1)
}
} else {
println("\nAvailable comparisons:")
DefaultComparisons.comparisons.foreach {
generator =>
println("\t%10s : %s".format(generator.name, generator.description))
}

return
}

Expand Down Expand Up @@ -242,6 +250,4 @@ class CompareADAM(protected val args: CompareADAMArgs) extends ADAMSparkCommand[
}
}
}

}

}

0 comments on commit e4f3520

Please sign in to comment.