Added explicit @ClassType annotations to @Argument for Option[Int] or Option[Double] since scala seems to change the reflected type to Option[Object] on some systems.

Changed ReflectionUtils.getGenericTypes' order of looking for @ClassType since the primitive generic wasn't completely erased, only changed to Object which is incorrect.
More fixes to @Arguments labeled as java.io.File via incorrect @Input annotation.
Put in a default undocumented implementation of @Argument doc() to match the one added to @Input.
This commit is contained in:
Khalid Shakir 2012-10-19 13:19:56 -04:00
parent 4622896312
commit 2ef456d51a
4 changed files with 17 additions and 13 deletions

View File

@ -62,7 +62,7 @@ public @interface Argument {
* --help argument is specified.
* @return Doc string associated with this command-line argument.
*/
String doc();
String doc() default "Undocumented option";
/**
* Is this argument required. If true, the command-line argument system will

View File

@ -27,28 +27,28 @@ class PacbioProcessingPipeline extends QScript {
@Input(doc="dbsnp VCF file to use ", shortName="D", required=true)
var dbSNP: File = _
@Input(doc="Number of jobs to scatter/gather. Default: 0." , shortName = "sg", required=false)
@Argument(doc="Number of jobs to scatter/gather. Default: 0." , shortName = "sg", required=false)
var threads: Int = 0
@Input(doc="Sample Name to fill in the Read Group information (only necessary if using fasta/fastq)" , shortName = "sn", required=false)
@Argument(doc="Sample Name to fill in the Read Group information (only necessary if using fasta/fastq)" , shortName = "sn", required=false)
var sample: String = "NA"
@Input(doc="The path to the binary of bwa to align fasta/fastq files", fullName="path_to_bwa", shortName="bwa", required=false)
var bwaPath: File = _
@Input(doc="Input is a BLASR generated BAM file", shortName = "blasr", fullName="blasr_bam", required=false)
@Argument(doc="Input is a BLASR generated BAM file", shortName = "blasr", fullName="blasr_bam", required=false)
var BLASR_BAM: Boolean = false
@Hidden
@Input(doc="The default base qualities to use before recalibration. Default is Q20 (should be good for every dataset)." , shortName = "dbq", required=false)
@Argument(doc="The default base qualities to use before recalibration. Default is Q20 (should be good for every dataset)." , shortName = "dbq", required=false)
var dbq: Int = 20
@Hidden
@Input(shortName="bwastring", required=false)
@Argument(shortName="bwastring", required=false)
var bwastring: String = ""
@Hidden
@Input(shortName = "test", fullName = "test_mode", required = false)
@Argument(shortName = "test", fullName = "test_mode", required = false)
var testMode: Boolean = false
val queueLogDir: String = ".qlog/"

View File

@ -25,7 +25,7 @@
package org.broadinstitute.sting.queue
import java.io.File
import org.broadinstitute.sting.commandline.Argument
import org.broadinstitute.sting.commandline.{ClassType, Argument}
/**
* Default settings settable on the command line and passed to CommandLineFunctions.
@ -41,6 +41,7 @@ class QSettings {
var jobQueue: String = _
@Argument(fullName="job_priority", shortName="jobPriority", doc="Default priority for jobs. Min = 0, Max = 100", required=false)
@ClassType(classOf[Int])
var jobPriority: Option[Int] = None
@Argument(fullName="job_native_arg", shortName="jobNative", doc="Native arguments to pass to the job runner.", required=false)
@ -53,15 +54,19 @@ class QSettings {
var jobEnvironmentNames: Seq[String] = Nil
@Argument(fullName="memory_limit", shortName="memLimit", doc="Default memory limit for jobs, in gigabytes. If not set defaults to 2GB.", required=false)
@ClassType(classOf[Double])
var memoryLimit: Option[Double] = Some(2)
@Argument(fullName="memory_limit_threshold", shortName="memLimitThresh", doc="After passing this threshold stop increasing memory limit for jobs, in gigabytes.", required=false)
@ClassType(classOf[Double])
var memoryLimitThreshold: Option[Double] = None
@Argument(fullName="resident_memory_limit", shortName="resMemLimit", doc="Default resident memory limit for jobs, in gigabytes.", required=false)
@ClassType(classOf[Double])
var residentLimit: Option[Double] = None
@Argument(fullName="resident_memory_request", shortName="resMemReq", doc="Default resident memory request for jobs, in gigabytes.", required=false)
@ClassType(classOf[Double])
var residentRequest: Option[Double] = None
@Argument(fullName="resident_memory_request_parameter", shortName="resMemReqParam", doc="Parameter for resident memory requests. By default not requested.", required=false)

View File

@ -159,12 +159,11 @@ object ReflectionUtils {
private def getGenericTypes(field: Field): Option[Array[Class[_]]] = {
// TODO: Refactor: based on java code in org.broadinstitute.sting.commandline.ArgumentTypeDescriptor
// If this is a parameterized collection, find the contained type. If blow up if only one type exists.
if (field.getGenericType.isInstanceOf[ParameterizedType]) {
if (hasAnnotation(field, classOf[ClassType])) {
Some(Array(getAnnotation(field, classOf[ClassType]).value))
} else if (field.getGenericType.isInstanceOf[ParameterizedType]) {
val parameterizedType = field.getGenericType.asInstanceOf[ParameterizedType]
Some(parameterizedType.getActualTypeArguments.map(_.asInstanceOf[Class[_]]))
} else if (hasAnnotation(field, classOf[ClassType])) {
Some(Array(getAnnotation(field, classOf[ClassType]).value))
}
else None
} else None
}
}