From 2a8c97a4a7db2957645ec1d8a11d082c304f6248 Mon Sep 17 00:00:00 2001 From: aaron Date: Sat, 6 Nov 2010 19:12:19 +0000 Subject: [PATCH] better error catching, as well as allowing for default index naming, .idx git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4633 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/indexer/RMDIndexer.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/indexer/RMDIndexer.java b/java/src/org/broadinstitute/sting/gatk/refdata/indexer/RMDIndexer.java index fa248badb..34a9a330f 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/indexer/RMDIndexer.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/indexer/RMDIndexer.java @@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.refdata.indexer; import net.sf.picard.reference.IndexedFastaSequenceFile; import org.apache.log4j.Logger; import org.broad.tribble.FeatureCodec; +import org.broad.tribble.Tribble; import org.broad.tribble.index.Index; import org.broad.tribble.index.IndexFactory; import org.broad.tribble.util.LittleEndianOutputStream; @@ -40,10 +41,6 @@ public class RMDIndexer extends CommandLineProgram { @Override protected int execute() throws Exception { - logger.info(String.format("attempting to index file: %s",inputFileSource)); - logger.info(String.format("using reference: %s",referenceFile.getAbsolutePath())); - logger.info(String.format("using type: %s",inputFileType)); - logger.info(String.format("writing to location: %s",indexFile.getAbsolutePath())); // check parameters // --------------------------------------------------------------------------------- @@ -56,11 +53,19 @@ public class RMDIndexer extends CommandLineProgram { // create a reference file reader IndexedFastaSequenceFile seq = new IndexedFastaSequenceFile(referenceFile); + // set the index file to the default name if they didn't specify a file + if (indexFile == null && inputFileSource != null) + indexFile = new File(inputFileSource.getAbsolutePath() + Tribble.STANDARD_INDEX_EXTENSION); + // check that we can create the output file if (indexFile == null || indexFile.exists()) throw new IllegalArgumentException("We can't write to the index file location: " + indexFile + ", the index exists"); + logger.info(String.format("attempting to index file: %s", inputFileSource)); + logger.info(String.format("using reference: %s", referenceFile.getAbsolutePath())); + logger.info(String.format("using type: %s", inputFileType)); + logger.info(String.format("writing to location: %s", indexFile.getAbsolutePath())); // try to index the file // ---------------------------------------------------------------------------------