Package picard.cmdline
Class CommandLineProgram
- java.lang.Object
-
- picard.cmdline.CommandLineProgram
-
- Direct Known Subclasses:
AbstractOpticalDuplicateFinderCommandLineProgram
,AccumulateVariantCallingMetrics
,AddCommentsToBam
,AddOATag
,AddOrReplaceReadGroups
,BaitDesigner
,BamIndexStats
,BamToBfq
,BedToIntervalList
,BpmToNormalizationManifestCsv
,BuildBamIndex
,CalculateFingerprintMetrics
,CalculateReadGroupChecksum
,CheckDuplicateMarking
,CheckFingerprint
,CheckIlluminaDirectory
,CheckTerminatorBlock
,CleanSam
,ClusterCrosscheckMetrics
,CollectArraysVariantCallingMetrics
,CollectHiSeqXPfFailMetrics
,CollectIlluminaBasecallingMetrics
,CollectIlluminaLaneMetrics
,CollectIndependentReplicateMetrics
,CollectJumpingLibraryMetrics
,CollectMultipleMetrics
,CollectOxoGMetrics
,CollectRrbsMetrics
,CollectSamErrorMetrics
,CollectTargetedMetrics
,CollectVariantCallingMetrics
,CollectWgsMetrics
,CombineGenotypingArrayVcfs
,CompareGtcFiles
,CompareMetrics
,CompareSAMs
,ConvertSequencingArtifactToOxoG
,CreateSequenceDictionary
,CreateVerifyIDIntensityContaminationMetricsFile
,CrosscheckFingerprints
,DownsampleSam
,ExtractFingerprint
,ExtractIlluminaBarcodes
,ExtractSequences
,FastqToSam
,FifoBuffer
,FilterSamReads
,FilterVcf
,FindMendelianViolations
,FixMateInformation
,FixVcfHeader
,GatherBamFiles
,GatherVcfs
,GenotypeConcordance
,GtcToVcf
,IdentifyContaminant
,IlluminaBasecallsToFastq
,IlluminaBasecallsToSam
,IntervalListToBed
,IntervalListTools
,LiftOverHaplotypeMap
,LiftOverIntervalList
,LiftoverVcf
,MakeSitesOnlyVcf
,MakeVcfSampleNameMap
,MarkIlluminaAdapters
,MergeBamAlignment
,MergePedIntoVcf
,MergeSamFiles
,MergeVcfs
,NonNFastaSize
,NormalizeFasta
,PositionBasedDownsampleSam
,RenameSampleInVcf
,ReorderSam
,ReplaceSamHeader
,RevertOriginalBaseQualitiesAndAddMateCigar
,RevertSam
,SamFormatConverter
,SamToFastq
,ScatterIntervalsByNs
,SetNmMdAndUqTags
,SinglePassSamProgram
,SortSam
,SortVcf
,SplitSamByLibrary
,SplitSamByNumberOfReads
,SplitVcfs
,UpdateVcfSequenceDictionary
,ValidateSamFile
,VcfFormatConverter
,VcfToAdpc
,VcfToIntervalList
,ViewSam
public abstract class CommandLineProgram extends Object
Abstract class to facilitate writing command-line programs. To use: 1. Extend this class with a concrete class that is annotated with @COmmandLineProgramProperties, and has data members annotated with @Argument, @PositionalArguments, and/or @ArgumentCollection annotations. 2. If there is any custom command-line validation, override customCommandLineValidation(). When this method is called, the command line has been parsed and set into the data members of the concrete class. 3. Implement a method doWork(). This is called after successful command-line processing. The value it returns is the exit status of the program. It is assumed that the concrete class emits any appropriate error message before returning non-zero. doWork() may throw unchecked exceptions, which are caught and reported appropriately.
-
-
Field Summary
Fields Modifier and Type Field Description int
COMPRESSION_LEVEL
Boolean
CREATE_INDEX
boolean
CREATE_MD5_FILE
String
GA4GH_CLIENT_SECRETS
static int
MAX_ALLOWABLE_ONE_LINE_SUMMARY_LENGTH
CommandLineProgramProperties oneLineSummary attribute must be shorted than this in order to maintain reasonable help output formatting.Integer
MAX_RECORDS_IN_RAM
Boolean
QUIET
protected File
REFERENCE_SEQUENCE
ReferenceArgumentCollection
referenceSequence
Object
specialArgumentsCollection
List<File>
TMP_DIR
Boolean
USE_JDK_DEFLATER
Boolean
USE_JDK_INFLATER
htsjdk.samtools.ValidationStringency
VALIDATION_STRINGENCY
htsjdk.samtools.util.Log.LogLevel
VERBOSITY
-
Constructor Summary
Constructors Constructor Description CommandLineProgram()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static boolean
checkRInstallation(boolean has_chart_output)
Check if R is installedprotected String[]
customCommandLineValidation()
Put any custom command-line validation in an override of this method.protected abstract int
doWork()
Do the work after command line has been parsed.String
getCommandLine()
org.broadinstitute.barclay.argparser.CommandLineParser
getCommandLineParser()
org.broadinstitute.barclay.argparser.CommandLineParser
getCommandLineParserForArgs(String[] argv)
List<htsjdk.samtools.metrics.Header>
getDefaultHeaders()
static String
getFaqLink()
protected <A extends htsjdk.samtools.metrics.MetricBase,B extends Comparable<?>>
htsjdk.samtools.metrics.MetricsFile<A,B>getMetricsFile()
Gets a MetricsFile with default headers already written into it.htsjdk.samtools.SAMProgramRecord
getPGRecord(htsjdk.samtools.SAMFileHeader header)
String
getStandardUsagePreamble()
static String
getStandardUsagePreamble(Class<?> mainClass)
A typical command line program will call this to get the beginning of the usage message, and then typically append a description of the program, like this: public String USAGE = getStandardUsagePreamble(getClass()) + "Frobnicate the freebozle."String
getVersion()
static boolean
hasWebDocumentation(Class<?> clazz)
Determine if a class has web documentation based on its package nameint
instanceMain(String[] argv)
void
instanceMainWithExit(String[] argv)
protected ReferenceArgumentCollection
makeReferenceArgumentCollection()
protected boolean
parseArgs(String[] argv)
protected boolean
requiresReference()
void
setDefaultHeaders(List<htsjdk.samtools.metrics.Header> headers)
static boolean
useLegacyParser()
Return true if the legacy Picard command line parser should be used in place of the Barclay command line parser, otherwise, false.
-
-
-
Field Detail
-
MAX_ALLOWABLE_ONE_LINE_SUMMARY_LENGTH
public static int MAX_ALLOWABLE_ONE_LINE_SUMMARY_LENGTH
CommandLineProgramProperties oneLineSummary attribute must be shorted than this in order to maintain reasonable help output formatting.
-
TMP_DIR
@Argument(doc="One or more directories with space available to be used by this program for temporary storage of working files", common=true, optional=true) public List<File> TMP_DIR
-
VERBOSITY
@Argument(doc="Control verbosity of logging.", common=true) public htsjdk.samtools.util.Log.LogLevel VERBOSITY
-
QUIET
@Argument(doc="Whether to suppress job-summary info on System.err.", common=true) public Boolean QUIET
-
VALIDATION_STRINGENCY
@Argument(doc="Validation stringency for all SAM files read by this program. Setting stringency to SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded.", common=true) public htsjdk.samtools.ValidationStringency VALIDATION_STRINGENCY
-
COMPRESSION_LEVEL
@Argument(doc="Compression level for all compressed files created (e.g. BAM and VCF).", common=true) public int COMPRESSION_LEVEL
-
MAX_RECORDS_IN_RAM
@Argument(doc="When writing files that need to be sorted, this will specify the number of records stored in RAM before spilling to disk. Increasing this number reduces the number of file handles needed to sort the file, and increases the amount of RAM needed.", optional=true, common=true) public Integer MAX_RECORDS_IN_RAM
-
CREATE_INDEX
@Argument(doc="Whether to create an index when writing VCF or coordinate sorted BAM output.", common=true) public Boolean CREATE_INDEX
-
CREATE_MD5_FILE
@Argument(doc="Whether to create an MD5 digest for any BAM or FASTQ files created. ", common=true) public boolean CREATE_MD5_FILE
-
referenceSequence
@ArgumentCollection public ReferenceArgumentCollection referenceSequence
-
REFERENCE_SEQUENCE
protected File REFERENCE_SEQUENCE
-
GA4GH_CLIENT_SECRETS
@Argument(doc="Google Genomics API client_secrets.json file path.", common=true) public String GA4GH_CLIENT_SECRETS
-
specialArgumentsCollection
@ArgumentCollection(doc="Special Arguments that have meaning to the argument parsing system. It is unlikely these will ever need to be accessed by the command line program") public Object specialArgumentsCollection
-
USE_JDK_DEFLATER
@Argument(shortName="use_jdk_deflater", doc="Use the JDK Deflater instead of the Intel Deflater for writing compressed output", common=true) public Boolean USE_JDK_DEFLATER
-
USE_JDK_INFLATER
@Argument(shortName="use_jdk_inflater", doc="Use the JDK Inflater instead of the Intel Inflater for reading compressed input", common=true) public Boolean USE_JDK_INFLATER
-
-
Method Detail
-
doWork
protected abstract int doWork()
Do the work after command line has been parsed. RuntimeException may be thrown by this method, and are reported appropriately.- Returns:
- program exit status.
-
requiresReference
protected boolean requiresReference()
-
makeReferenceArgumentCollection
protected ReferenceArgumentCollection makeReferenceArgumentCollection()
-
instanceMainWithExit
public void instanceMainWithExit(String[] argv)
-
instanceMain
public int instanceMain(String[] argv)
-
customCommandLineValidation
protected String[] customCommandLineValidation()
Put any custom command-line validation in an override of this method. clp is initialized at this point and can be used to print usage and access argv. Any options set by command-line parser can be validated.- Returns:
- null if command line is valid. If command line is invalid, returns an array of error message to be written to the appropriate place.
-
parseArgs
protected boolean parseArgs(String[] argv)
- Returns:
- true if command line is valid
-
getMetricsFile
protected <A extends htsjdk.samtools.metrics.MetricBase,B extends Comparable<?>> htsjdk.samtools.metrics.MetricsFile<A,B> getMetricsFile()
Gets a MetricsFile with default headers already written into it.
-
getStandardUsagePreamble
public String getStandardUsagePreamble()
-
getCommandLineParserForArgs
public org.broadinstitute.barclay.argparser.CommandLineParser getCommandLineParserForArgs(String[] argv)
-
getCommandLineParser
public org.broadinstitute.barclay.argparser.CommandLineParser getCommandLineParser()
- Returns:
- Return the command line parser to be used.
-
useLegacyParser
public static boolean useLegacyParser()
Return true if the legacy Picard command line parser should be used in place of the Barclay command line parser, otherwise, false. The legacy parser is enabled by opt-in only, via the presence of a (true-valued) boolean property "picard.useLegacyParser", either as a System property.- Returns:
- true if the legacy parser should be used
-
getVersion
public String getVersion()
- Returns:
- Version stored in the manifest of the jarfile.
-
getCommandLine
public String getCommandLine()
-
setDefaultHeaders
public void setDefaultHeaders(List<htsjdk.samtools.metrics.Header> headers)
-
getPGRecord
public htsjdk.samtools.SAMProgramRecord getPGRecord(htsjdk.samtools.SAMFileHeader header)
-
getDefaultHeaders
public List<htsjdk.samtools.metrics.Header> getDefaultHeaders()
-
getStandardUsagePreamble
public static String getStandardUsagePreamble(Class<?> mainClass)
A typical command line program will call this to get the beginning of the usage message, and then typically append a description of the program, like this: public String USAGE = getStandardUsagePreamble(getClass()) + "Frobnicate the freebozle."
-
hasWebDocumentation
public static boolean hasWebDocumentation(Class<?> clazz)
Determine if a class has web documentation based on its package name- Parameters:
clazz
-- Returns:
- true if the class has web documentation
-
getFaqLink
public static String getFaqLink()
- Returns:
- the link to a FAQ
-
checkRInstallation
public static boolean checkRInstallation(boolean has_chart_output)
Check if R is installed- Parameters:
has_chart_output
-- Returns:
- true if R is installed
-
-