use of htsjdk.samtools.metrics.StringHeader in project gatk by broadinstitute.
the class CommandLineProgram method instanceMainPostParseArgs.
public Object instanceMainPostParseArgs() {
// Provide one temp directory if the caller didn't
if (this.TMP_DIR == null)
this.TMP_DIR = new ArrayList<>();
if (this.TMP_DIR.isEmpty())
TMP_DIR.add(IOUtil.getDefaultTmpDir());
// Build the default headers
final ZonedDateTime startDateTime = ZonedDateTime.now();
this.defaultHeaders.add(new StringHeader(commandLine));
this.defaultHeaders.add(new StringHeader("Started on: " + Utils.getDateTimeForDisplay(startDateTime)));
// propagate the VERBOSITY level to logging frameworks
LoggingUtils.setLoggingLevel(VERBOSITY);
for (final File f : TMP_DIR) {
// need a tmp_dir. If this fails, the problem will be discovered downstream.
if (!f.exists())
f.mkdirs();
f.setReadable(true, false);
f.setWritable(true, false);
// in loop so that last one takes effect
System.setProperty("java.io.tmpdir", f.getAbsolutePath());
}
//Set defaults (note: setting them here means they are not controllable by the user)
if (!useJdkDeflater) {
BlockCompressedOutputStream.setDefaultDeflaterFactory(new IntelDeflaterFactory());
}
if (!useJdkInflater) {
BlockGunzipper.setDefaultInflaterFactory(new IntelInflaterFactory());
}
if (!QUIET) {
System.err.println("[" + Utils.getDateTimeForDisplay(startDateTime) + "] " + commandLine);
// Output a one liner about who/where and what software/os we're running on
try {
System.err.println("[" + Utils.getDateTimeForDisplay(startDateTime) + "] Executing as " + System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName() + " on " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch") + "; " + System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version") + "; Version: " + getVersion());
// Print important settings to the logger:
printSettings();
} catch (final Exception e) {
/* Unpossible! */
}
}
try {
return runTool();
} finally {
// Emit the time even if program throws
if (!QUIET) {
final ZonedDateTime endDateTime = ZonedDateTime.now();
final double elapsedMinutes = (Duration.between(startDateTime, endDateTime).toMillis()) / (1000d * 60d);
final String elapsedString = new DecimalFormat("#,##0.00").format(elapsedMinutes);
System.err.println("[" + Utils.getDateTimeForDisplay(endDateTime) + "] " + getClass().getName() + " done. Elapsed time: " + elapsedString + " minutes.");
System.err.println("Runtime.totalMemory()=" + Runtime.getRuntime().totalMemory());
}
}
}
Aggregations