Removed annoying FastaSequenceIndexBuilderProgressListener infrastructure that was just a boolean switch on whether to print progress or not.
This commit is contained in:
parent
06374c91d7
commit
f3ad4ec94b
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
package net.sf.picard.reference;
|
package net.sf.picard.reference;
|
||||||
|
|
||||||
import org.broadinstitute.sting.gatk.datasources.reference.ReferenceDataSourceProgressListener;
|
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
|
|
||||||
import static net.sf.picard.reference.FastaSequenceIndexBuilder.Status.*;
|
import static net.sf.picard.reference.FastaSequenceIndexBuilder.Status.*;
|
||||||
|
|
@ -39,8 +38,8 @@ import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
* Produces fai file with same output as samtools faidx
|
* Produces fai file with same output as samtools faidx
|
||||||
*/
|
*/
|
||||||
public class FastaSequenceIndexBuilder {
|
public class FastaSequenceIndexBuilder {
|
||||||
public File fastaFile;
|
final public File fastaFile;
|
||||||
ReferenceDataSourceProgressListener progress; // interface that provides a method for updating user on progress of reading file
|
final boolean printProgress;
|
||||||
|
|
||||||
// keep track of location in file
|
// keep track of location in file
|
||||||
long bytesRead, endOfLastLine, lastTimestamp, fileLength; // initialized to -1 to keep 0-indexed position in file;
|
long bytesRead, endOfLastLine, lastTimestamp, fileLength; // initialized to -1 to keep 0-indexed position in file;
|
||||||
|
|
@ -55,10 +54,10 @@ public class FastaSequenceIndexBuilder {
|
||||||
public enum Status { NONE, CONTIG, FIRST_SEQ_LINE, SEQ_LINE, COMMENT }
|
public enum Status { NONE, CONTIG, FIRST_SEQ_LINE, SEQ_LINE, COMMENT }
|
||||||
Status status = Status.NONE; // keeps state of what is currently being read. better to use int instead of enum?
|
Status status = Status.NONE; // keeps state of what is currently being read. better to use int instead of enum?
|
||||||
|
|
||||||
public FastaSequenceIndexBuilder(File fastaFile, ReferenceDataSourceProgressListener progress) {
|
public FastaSequenceIndexBuilder(File fastaFile, boolean printProgress) {
|
||||||
this.progress = progress;
|
|
||||||
this.fastaFile = fastaFile;
|
this.fastaFile = fastaFile;
|
||||||
fileLength = fastaFile.length();
|
fileLength = fastaFile.length();
|
||||||
|
this.printProgress = printProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -252,8 +251,8 @@ public class FastaSequenceIndexBuilder {
|
||||||
|
|
||||||
if (System.currentTimeMillis() - lastTimestamp > 10000) {
|
if (System.currentTimeMillis() - lastTimestamp > 10000) {
|
||||||
int percentProgress = (int) (100*bytesRead/fileLength);
|
int percentProgress = (int) (100*bytesRead/fileLength);
|
||||||
if (progress != null)
|
if (printProgress)
|
||||||
progress.percentProgress(percentProgress);
|
System.out.println(String.format("PROGRESS UPDATE: file is %d percent complete", percentProgress));
|
||||||
lastTimestamp = System.currentTimeMillis();
|
lastTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -926,9 +926,6 @@ public class GenomeAnalysisEngine {
|
||||||
GenomeLocParser genomeLocParser,
|
GenomeLocParser genomeLocParser,
|
||||||
ValidationExclusion.TYPE validationExclusionType) {
|
ValidationExclusion.TYPE validationExclusionType) {
|
||||||
RMDTrackBuilder builder = new RMDTrackBuilder(sequenceDictionary,genomeLocParser,validationExclusionType);
|
RMDTrackBuilder builder = new RMDTrackBuilder(sequenceDictionary,genomeLocParser,validationExclusionType);
|
||||||
// try and make the tracks given their requests
|
|
||||||
// create of live instances of the tracks
|
|
||||||
List<RMDTrack> tracks = new ArrayList<RMDTrack>();
|
|
||||||
|
|
||||||
List<ReferenceOrderedDataSource> dataSources = new ArrayList<ReferenceOrderedDataSource>();
|
List<ReferenceOrderedDataSource> dataSources = new ArrayList<ReferenceOrderedDataSource>();
|
||||||
for (RMDTriplet fileDescriptor : referenceMetaDataFiles)
|
for (RMDTriplet fileDescriptor : referenceMetaDataFiles)
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import java.io.File;
|
||||||
* Loads reference data from fasta file
|
* Loads reference data from fasta file
|
||||||
* Looks for fai and dict files, and tries to create them if they don't exist
|
* Looks for fai and dict files, and tries to create them if they don't exist
|
||||||
*/
|
*/
|
||||||
public class ReferenceDataSource implements ReferenceDataSourceProgressListener {
|
public class ReferenceDataSource {
|
||||||
private IndexedFastaSequenceFile index;
|
private IndexedFastaSequenceFile index;
|
||||||
|
|
||||||
/** our log, which we want to capture anything from this class */
|
/** our log, which we want to capture anything from this class */
|
||||||
|
|
@ -75,7 +75,7 @@ public class ReferenceDataSource implements ReferenceDataSourceProgressListener
|
||||||
// get exclusive lock
|
// get exclusive lock
|
||||||
if (!indexLock.exclusiveLock())
|
if (!indexLock.exclusiveLock())
|
||||||
throw new UserException.CouldNotCreateReferenceIndexFileBecauseOfLock(dictFile);
|
throw new UserException.CouldNotCreateReferenceIndexFileBecauseOfLock(dictFile);
|
||||||
FastaSequenceIndexBuilder faiBuilder = new FastaSequenceIndexBuilder(fastaFile, this);
|
FastaSequenceIndexBuilder faiBuilder = new FastaSequenceIndexBuilder(fastaFile, true);
|
||||||
FastaSequenceIndex sequenceIndex = faiBuilder.createIndex();
|
FastaSequenceIndex sequenceIndex = faiBuilder.createIndex();
|
||||||
FastaSequenceIndexBuilder.saveAsFaiFile(sequenceIndex, indexFile);
|
FastaSequenceIndexBuilder.saveAsFaiFile(sequenceIndex, indexFile);
|
||||||
}
|
}
|
||||||
|
|
@ -194,13 +194,4 @@ public class ReferenceDataSource implements ReferenceDataSourceProgressListener
|
||||||
public IndexedFastaSequenceFile getReference() {
|
public IndexedFastaSequenceFile getReference() {
|
||||||
return this.index;
|
return this.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify user of progress in creating fai file
|
|
||||||
* @param percent Percent of fasta file read as a percent
|
|
||||||
*/
|
|
||||||
public void percentProgress(int percent) {
|
|
||||||
System.out.println(String.format("PROGRESS UPDATE: file is %d percent complete", percent));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ package net.sf.picard.reference;
|
||||||
|
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.broadinstitute.sting.BaseTest;
|
import org.broadinstitute.sting.BaseTest;
|
||||||
import org.broadinstitute.sting.gatk.datasources.reference.ReferenceDataSourceProgressListener;
|
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
|
@ -40,7 +39,6 @@ import java.io.FileNotFoundException;
|
||||||
public class FastaSequenceIndexBuilderUnitTest extends BaseTest {
|
public class FastaSequenceIndexBuilderUnitTest extends BaseTest {
|
||||||
|
|
||||||
private FastaSequenceIndexBuilder builder;
|
private FastaSequenceIndexBuilder builder;
|
||||||
private ReferenceDataSourceProgressListener progress;
|
|
||||||
private File fastaFile;
|
private File fastaFile;
|
||||||
private FastaSequenceIndex controlIndex;
|
private FastaSequenceIndex controlIndex;
|
||||||
|
|
||||||
|
|
@ -58,7 +56,7 @@ public class FastaSequenceIndexBuilderUnitTest extends BaseTest {
|
||||||
logger.warn("Executing unixFileTest");
|
logger.warn("Executing unixFileTest");
|
||||||
|
|
||||||
fastaFile = new File(validationDataLocation + "exampleFASTA.fasta");
|
fastaFile = new File(validationDataLocation + "exampleFASTA.fasta");
|
||||||
builder = new FastaSequenceIndexBuilder(fastaFile, progress);
|
builder = new FastaSequenceIndexBuilder(fastaFile, false);
|
||||||
FastaSequenceIndex index = builder.createIndex();
|
FastaSequenceIndex index = builder.createIndex();
|
||||||
controlIndex.add(new FastaSequenceIndexEntry("chr1", 6, 100000, 60, 61,0));
|
controlIndex.add(new FastaSequenceIndexEntry("chr1", 6, 100000, 60, 61,0));
|
||||||
|
|
||||||
|
|
@ -75,7 +73,7 @@ public class FastaSequenceIndexBuilderUnitTest extends BaseTest {
|
||||||
logger.warn("Executing windowsFileTest");
|
logger.warn("Executing windowsFileTest");
|
||||||
|
|
||||||
fastaFile = new File(validationDataLocation + "exampleFASTA-windows.fasta");
|
fastaFile = new File(validationDataLocation + "exampleFASTA-windows.fasta");
|
||||||
builder = new FastaSequenceIndexBuilder(fastaFile, progress);
|
builder = new FastaSequenceIndexBuilder(fastaFile, false);
|
||||||
FastaSequenceIndex index = builder.createIndex();
|
FastaSequenceIndex index = builder.createIndex();
|
||||||
controlIndex.add(new FastaSequenceIndexEntry("chr2", 7, 29, 7, 9,0));
|
controlIndex.add(new FastaSequenceIndexEntry("chr2", 7, 29, 7, 9,0));
|
||||||
|
|
||||||
|
|
@ -91,7 +89,7 @@ public class FastaSequenceIndexBuilderUnitTest extends BaseTest {
|
||||||
logger.warn("Executing combinedWindowsUnix");
|
logger.warn("Executing combinedWindowsUnix");
|
||||||
|
|
||||||
fastaFile = new File(validationDataLocation + "exampleFASTA-combined.fasta");
|
fastaFile = new File(validationDataLocation + "exampleFASTA-combined.fasta");
|
||||||
builder = new FastaSequenceIndexBuilder(fastaFile, progress);
|
builder = new FastaSequenceIndexBuilder(fastaFile, false);
|
||||||
FastaSequenceIndex index = builder.createIndex();
|
FastaSequenceIndex index = builder.createIndex();
|
||||||
controlIndex.add(new FastaSequenceIndexEntry("chr1", 6, 100000, 60, 61,0));
|
controlIndex.add(new FastaSequenceIndexEntry("chr1", 6, 100000, 60, 61,0));
|
||||||
controlIndex.add(new FastaSequenceIndexEntry("chr2", 101680, 29, 7, 9,1));
|
controlIndex.add(new FastaSequenceIndexEntry("chr2", 101680, 29, 7, 9,1));
|
||||||
|
|
@ -108,7 +106,7 @@ public class FastaSequenceIndexBuilderUnitTest extends BaseTest {
|
||||||
logger.warn("Executing threeVariableLengthContigs");
|
logger.warn("Executing threeVariableLengthContigs");
|
||||||
|
|
||||||
fastaFile = new File(validationDataLocation + "exampleFASTA-3contigs.fasta");
|
fastaFile = new File(validationDataLocation + "exampleFASTA-3contigs.fasta");
|
||||||
builder = new FastaSequenceIndexBuilder(fastaFile, progress);
|
builder = new FastaSequenceIndexBuilder(fastaFile, false);
|
||||||
FastaSequenceIndex index = builder.createIndex();
|
FastaSequenceIndex index = builder.createIndex();
|
||||||
controlIndex.add(new FastaSequenceIndexEntry("chr1", 6, 17, 5, 6,0));
|
controlIndex.add(new FastaSequenceIndexEntry("chr1", 6, 17, 5, 6,0));
|
||||||
controlIndex.add(new FastaSequenceIndexEntry("chr2", 35, 21, 7, 8,1));
|
controlIndex.add(new FastaSequenceIndexEntry("chr2", 35, 21, 7, 8,1));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue