From fc7320133c8822b6a87ac0f90096c4221a8e3508 Mon Sep 17 00:00:00 2001 From: hanna Date: Mon, 1 Jun 2009 15:34:38 +0000 Subject: [PATCH] Cleaned up error when fasta index is missing. Code still throws an exception, but the message is more direct (no more 'error while micromanaging') and tells the user to run 'samtools faidx' to fix the issue. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@867 348d0f76-0448-11de-a6fe-93d51630548a --- .../broadinstitute/sting/gatk/executive/MicroScheduler.java | 2 +- .../broadinstitute/sting/utils/fasta/FastaSequenceIndex.java | 2 +- .../sting/utils/fasta/IndexedFastaSequenceFile.java | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java b/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java index 3eee8c22b..8336007e9 100755 --- a/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java +++ b/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java @@ -196,7 +196,7 @@ public abstract class MicroScheduler { ref = new IndexedFastaSequenceFile(refFile); } catch (FileNotFoundException ex) { - throw new RuntimeException("File not found opening fasta file; please do this check before MicroManaging", ex); + throw new StingException("I/O error while opening fasta file: " + ex.getMessage(), ex); } GenomeLoc.setupRefContigOrdering(ref); return ref; diff --git a/java/src/org/broadinstitute/sting/utils/fasta/FastaSequenceIndex.java b/java/src/org/broadinstitute/sting/utils/fasta/FastaSequenceIndex.java index 80643e06d..490826c86 100755 --- a/java/src/org/broadinstitute/sting/utils/fasta/FastaSequenceIndex.java +++ b/java/src/org/broadinstitute/sting/utils/fasta/FastaSequenceIndex.java @@ -31,7 +31,7 @@ public class FastaSequenceIndex implements Iterable { */ public FastaSequenceIndex( File indexFile ) throws FileNotFoundException { if(!indexFile.exists()) - throw new FileNotFoundException("Index file is missing"); + throw new FileNotFoundException(String.format("Fasta index file is missing",indexFile.getAbsolutePath())); IoUtil.assertFileIsReadable(indexFile); parseIndexFile(indexFile); diff --git a/java/src/org/broadinstitute/sting/utils/fasta/IndexedFastaSequenceFile.java b/java/src/org/broadinstitute/sting/utils/fasta/IndexedFastaSequenceFile.java index 026a60cfc..d1a426e3f 100755 --- a/java/src/org/broadinstitute/sting/utils/fasta/IndexedFastaSequenceFile.java +++ b/java/src/org/broadinstitute/sting/utils/fasta/IndexedFastaSequenceFile.java @@ -90,6 +90,9 @@ public class IndexedFastaSequenceFile implements ReferenceSequenceFile { */ private void loadIndex( File fastaFile ) throws FileNotFoundException { File indexFile = new File(fastaFile.getAbsolutePath() + ".fai"); + if (!indexFile.exists()) + throw new PicardException(String.format("Unable to load fasta index file %s. "+ + "Please create it using 'samtools faidx'.",indexFile.getAbsolutePath())); index = new FastaSequenceIndex(indexFile); indexIterator = index.iterator(); }