Merge pull request #1150 from broadinstitute/eb_keep_iupac_in_IR

Don't have the Indel Realigner change IUPAC reference bases.
This commit is contained in:
Eric Banks 2015-09-04 13:43:34 -04:00
commit b0dea2ccca
3 changed files with 17 additions and 3 deletions

View File

@ -394,7 +394,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
throw new RuntimeException("Entropy threshold must be a fraction between 0 and 1");
try {
referenceReader = new CachingIndexedFastaSequenceFile(getToolkit().getArguments().referenceFile);
referenceReader = new CachingIndexedFastaSequenceFile(getToolkit().getArguments().referenceFile, false, true);
}
catch(FileNotFoundException ex) {
throw new UserException.CouldNotReadInputFile(getToolkit().getArguments().referenceFile,ex);

View File

@ -125,8 +125,9 @@ public class CachingIndexedFastaSequenceFile extends IndexedFastaSequenceFile {
* @param fasta The file to open.
* @param cacheSize the size of the cache to use in this CachingIndexedFastaReader, must be >= 0
* @param preserveCase If true, we will keep the case of the underlying bases in the FASTA, otherwise everything is converted to upper case
* @param preserveIUPAC If true, we will keep the IUPAC bases in the FASTA, otherwise they are converted to Ns
*/
public CachingIndexedFastaSequenceFile(final File fasta, final long cacheSize, final boolean preserveCase, final boolean preserveIUPAC) throws FileNotFoundException {
public CachingIndexedFastaSequenceFile(final File fasta, final long cacheSize, final boolean preserveCase, final boolean preserveIUPAC) throws FileNotFoundException {
super(fasta);
if ( cacheSize < 0 ) throw new IllegalArgumentException("cacheSize must be > 0");
this.cacheSize = cacheSize;
@ -172,6 +173,19 @@ public class CachingIndexedFastaSequenceFile extends IndexedFastaSequenceFile {
this(fasta, DEFAULT_CACHE_SIZE, preserveCase, false);
}
/**
* Open the given indexed fasta sequence file. Throw an exception if the file cannot be opened.
*
* Looks for a index file for fasta on disk
*
* @param fasta The file to open.
* @param preserveCase If true, we will keep the case of the underlying bases in the FASTA, otherwise everything is converted to upper case
* @param preserveIUPAC If true, we will keep the IUPAC bases in the FASTA, otherwise they are converted to Ns
*/
public CachingIndexedFastaSequenceFile(final File fasta, final boolean preserveCase, final boolean preserveIUPAC) throws FileNotFoundException {
this(fasta, DEFAULT_CACHE_SIZE, preserveCase, preserveIUPAC);
}
/**
* Create reference data source from fasta file, after performing several preliminary checks on the file.
* This static utility was refactored from the constructor of ReferenceDataSource.

View File

@ -236,7 +236,7 @@ public class CachingIndexedFastaSequenceFileUnitTest extends BaseTest {
@Test(enabled = true)
public void testIupacChanges() throws FileNotFoundException, InterruptedException {
final String testFasta = privateTestDir + "iupacFASTA.fasta";
final CachingIndexedFastaSequenceFile iupacPreserving = new CachingIndexedFastaSequenceFile(new File(testFasta), CachingIndexedFastaSequenceFile.DEFAULT_CACHE_SIZE, false, true);
final CachingIndexedFastaSequenceFile iupacPreserving = new CachingIndexedFastaSequenceFile(new File(testFasta), false, true);
final CachingIndexedFastaSequenceFile makeNs = new CachingIndexedFastaSequenceFile(new File(testFasta));
int preservingNs = 0;