2009-05-11 10:07:20 +08:00
|
|
|
package org.broadinstitute.sting.gatk;
|
|
|
|
|
|
2009-07-07 23:18:05 +08:00
|
|
|
import org.broadinstitute.sting.utils.cmdLine.*;
|
2009-05-11 10:07:20 +08:00
|
|
|
|
2009-07-22 06:23:28 +08:00
|
|
|
import java.util.*;
|
2009-05-16 05:02:12 +08:00
|
|
|
|
2009-05-11 10:07:20 +08:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* User: aaron
|
|
|
|
|
* Date: May 8, 2009
|
|
|
|
|
* Time: 10:50:58 AM
|
|
|
|
|
*
|
|
|
|
|
* The Broad Institute
|
|
|
|
|
* SOFTWARE COPYRIGHT NOTICE AGREEMENT
|
|
|
|
|
* This software and its documentation are copyright 2009 by the
|
|
|
|
|
* Broad Institute/Massachusetts Institute of Technology. All rights are reserved.
|
|
|
|
|
*
|
|
|
|
|
* This software is supplied without any warranty or guaranteed support whatsoever. Neither
|
|
|
|
|
* the Broad Institute nor MIT can be responsible for its use, misuse, or functionality.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author aaron
|
|
|
|
|
* @version 1.0
|
|
|
|
|
* @date May 8, 2009
|
|
|
|
|
* <p/>
|
|
|
|
|
* Class CommandLineGATK
|
|
|
|
|
* <p/>
|
|
|
|
|
* We run command line GATK programs using this class. It gets the command line args, parses them, and hands the
|
|
|
|
|
* gatk all the parsed out information. Pretty much anything dealing with the underlying system should go here,
|
|
|
|
|
* the gatk engine should deal with any data related information.
|
|
|
|
|
*/
|
2009-07-17 06:02:21 +08:00
|
|
|
public class CommandLineGATK extends CommandLineExecutable {
|
2009-05-12 23:33:55 +08:00
|
|
|
@Argument(fullName = "analysis_type", shortName = "T", doc = "Type of analysis to run")
|
2009-07-17 06:48:44 +08:00
|
|
|
private String analysisName = null;
|
|
|
|
|
|
2009-07-17 06:02:21 +08:00
|
|
|
// our argument collection, the collection of command line args we accept
|
|
|
|
|
@ArgumentCollection
|
2009-07-17 06:48:44 +08:00
|
|
|
private GATKArgumentCollection argCollection = new GATKArgumentCollection();
|
2009-05-11 10:07:20 +08:00
|
|
|
|
2009-07-14 05:56:41 +08:00
|
|
|
/**
|
|
|
|
|
* Get pleasing info about the GATK.
|
2009-07-17 06:02:21 +08:00
|
|
|
* @return A list of Strings that contain pleasant info about the GATK.
|
2009-07-14 05:56:41 +08:00
|
|
|
*/
|
|
|
|
|
@Override
|
2009-07-22 06:23:28 +08:00
|
|
|
protected ApplicationDetails getApplicationDetails() {
|
|
|
|
|
return new ApplicationDetails( createApplicationHeader(),
|
|
|
|
|
ApplicationDetails.createDefaultRunningInstructions(getClass()),
|
|
|
|
|
getAdditionalHelp() );
|
2009-07-14 05:56:41 +08:00
|
|
|
}
|
|
|
|
|
|
2009-05-11 10:07:20 +08:00
|
|
|
@Override
|
2009-07-17 06:02:21 +08:00
|
|
|
protected String getAnalysisName() {
|
|
|
|
|
return analysisName;
|
2009-05-11 10:07:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2009-07-17 06:02:21 +08:00
|
|
|
protected GATKArgumentCollection getArgumentCollection() {
|
2009-05-11 10:07:20 +08:00
|
|
|
return argCollection;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-17 06:02:21 +08:00
|
|
|
/** Required main method implementation. */
|
|
|
|
|
public static void main(String[] argv) {
|
|
|
|
|
try {
|
|
|
|
|
CommandLineGATK instance = new CommandLineGATK();
|
|
|
|
|
start(instance, argv);
|
2009-09-05 03:13:37 +08:00
|
|
|
System.exit(CommandLineProgram.result); // todo -- this is a painful hack
|
2009-07-17 06:02:21 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
exitSystemWithError(e);
|
2009-05-16 05:02:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
2009-07-22 06:23:28 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates the a short blurb about the GATK, copyright info, and where to get documentation.
|
|
|
|
|
* @return The application header.
|
|
|
|
|
*/
|
|
|
|
|
private List<String> createApplicationHeader() {
|
|
|
|
|
List<String> header = new ArrayList<String>();
|
|
|
|
|
header.add("The Genome Analysis Toolkit (GATK)");
|
|
|
|
|
header.add("Copyright (c) 2009 The Broad Institute");
|
|
|
|
|
header.add("Please view our documentation at http://www.broadinstitute.org/gsa/wiki");
|
2009-09-21 07:36:54 +08:00
|
|
|
header.add("For support, email gsahelp@broadinstitute.org");
|
2009-07-22 06:23:28 +08:00
|
|
|
header.add("");
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieves additional information about GATK walkers.
|
|
|
|
|
* TODO: This functionality is very similar to that employed by the HelpFormatter. Generalize
|
|
|
|
|
* the code in HelpFormatter and supply it as a helper to this method.
|
|
|
|
|
* @return A string summarizing the walkers available in this distribution.
|
|
|
|
|
*/
|
|
|
|
|
private String getAdditionalHelp() {
|
|
|
|
|
// Get the list of walker names from the walker manager.
|
|
|
|
|
Set<String> walkerNames = GATKEngine.getWalkerNames();
|
|
|
|
|
|
|
|
|
|
// Sort the list of walker names.
|
|
|
|
|
walkerNames = new TreeSet<String>( walkerNames );
|
|
|
|
|
|
|
|
|
|
// Construct a help string to output available walkers.
|
|
|
|
|
StringBuilder additionalHelp = new StringBuilder();
|
|
|
|
|
Formatter formatter = new Formatter( additionalHelp );
|
|
|
|
|
|
|
|
|
|
formatter.format( "Available analyses:%n" );
|
|
|
|
|
|
|
|
|
|
// Compute the max size of any walker name
|
|
|
|
|
int maxNameLength = 0;
|
|
|
|
|
for( String walkerName: walkerNames ) {
|
|
|
|
|
if( maxNameLength < walkerName.length() )
|
|
|
|
|
maxNameLength = walkerName.length();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final int fieldWidth = maxNameLength + HelpFormatter.FIELD_SEPARATION_WIDTH;
|
|
|
|
|
final int walkersPerLine = Math.min(HelpFormatter.LINE_WIDTH / fieldWidth, 4 );
|
2009-08-26 03:54:54 +08:00
|
|
|
final int columnSpacing = Math.max((HelpFormatter.LINE_WIDTH - (fieldWidth * walkersPerLine)) / walkersPerLine, 1);
|
2009-07-22 06:23:28 +08:00
|
|
|
|
|
|
|
|
int currentWalkerName = 0;
|
|
|
|
|
for( String walkerName: walkerNames ) {
|
|
|
|
|
formatter.format( "%-" + HelpFormatter.FIELD_SEPARATION_WIDTH + "s" +
|
|
|
|
|
"%-" + fieldWidth + "s" +
|
|
|
|
|
"%-" + columnSpacing + "s", "", walkerName, "" );
|
|
|
|
|
if( ++currentWalkerName % walkersPerLine == 0 )
|
|
|
|
|
formatter.format("%n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return additionalHelp.toString();
|
|
|
|
|
}
|
2009-05-11 10:07:20 +08:00
|
|
|
}
|