From 7551ba82496806e6f7ea48cf200092db15660704 Mon Sep 17 00:00:00 2001 From: depristo Date: Fri, 1 Oct 2010 22:32:59 +0000 Subject: [PATCH] Trival refactoring in preparation for on-the-fly indexing git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4409 348d0f76-0448-11de-a6fe-93d51630548a --- .../gatk/refdata/tracks/builders/RMDTrackBuilder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java index a7cdb3d99..c4c8a727b 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java @@ -201,7 +201,7 @@ public class RMDTrackBuilder extends PluginManager { // if we don't have a dictionary in the Tribble file, and we've set a dictionary for this builder, set it in the file if they match if (dictFromIndex.size() == 0 && dict != null) { - File indexFile = new File(inputFile.getAbsoluteFile() + indexExtension); + File indexFile = indexFileForFile(inputFile); setIndexSequenceDictionary(index,dict,indexFile,true); dictFromIndex = getSequenceDictionaryFromProperties(index); } @@ -218,6 +218,10 @@ public class RMDTrackBuilder extends PluginManager { return reader; } + public static File indexFileForFile(File inputFile) { + return new File(inputFile.getAbsoluteFile() + indexExtension); + } + /** * create an index for the input file * @param inputFile the input file @@ -226,9 +230,8 @@ public class RMDTrackBuilder extends PluginManager { * @throws IOException if we cannot write the index file */ public synchronized static Index loadIndex(File inputFile, FeatureCodec codec) throws IOException { - // create the index file name, locking on the index file name - File indexFile = new File(inputFile.getAbsoluteFile() + indexExtension); + File indexFile = indexFileForFile(inputFile); FSLockWithShared lock = new FSLockWithShared(indexFile); // acquire a lock on the file @@ -309,7 +312,7 @@ public class RMDTrackBuilder extends PluginManager { private static Index writeIndexToDisk(Index index, File indexFile, FSLockWithShared lock) throws IOException { boolean locked = false; // could we exclusive lock the file? try { - locked = lock.exclusiveLock(); + lock.exclusiveLock(); // handle the case where we aren't locking anything if (locked) { logger.info("Writing Tribble index to disk for file " + indexFile); LittleEndianOutputStream stream = new LittleEndianOutputStream(new FileOutputStream(indexFile));