Simple optimizations for cases where there is no data or RODs at sites, such as with the FastaStats walker. private static immutable Lists and Maps in underlying data structures that have no associated data. Also, avoiding a double map.get() in the low-level genome loc parser. RefMetaDataTracker is now
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5664 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
54660a8c25
commit
a8f8077d7a
|
|
@ -1,5 +1,6 @@
|
||||||
package org.broadinstitute.sting.gatk.datasources.providers;
|
package org.broadinstitute.sting.gatk.datasources.providers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -97,7 +98,9 @@ public class AllLocusView extends LocusView {
|
||||||
* @param site Site at which to create the blank locus context.
|
* @param site Site at which to create the blank locus context.
|
||||||
* @return empty context.
|
* @return empty context.
|
||||||
*/
|
*/
|
||||||
private AlignmentContext createEmptyLocus( GenomeLoc site ) {
|
private final static List<SAMRecord> EMPTY_PILEUP_READS = Collections.emptyList();
|
||||||
return new AlignmentContext(site,new ReadBackedPileupImpl(site,new ArrayList<SAMRecord>(), new ArrayList<Integer>()));
|
private final static List<Integer> EMPTY_PILEUP_OFFSETS = Collections.emptyList();
|
||||||
|
private AlignmentContext createEmptyLocus( GenomeLoc site ) {
|
||||||
|
return new AlignmentContext(site,new ReadBackedPileupImpl(site, EMPTY_PILEUP_READS, EMPTY_PILEUP_OFFSETS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ public class ManagingReferenceOrderedView implements ReferenceOrderedView {
|
||||||
* @return A tracker containing information about this locus.
|
* @return A tracker containing information about this locus.
|
||||||
*/
|
*/
|
||||||
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc ) {
|
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc ) {
|
||||||
RefMetaDataTracker tracks = new RefMetaDataTracker();
|
RefMetaDataTracker tracks = new RefMetaDataTracker(states.size());
|
||||||
for (ReferenceOrderedDataState state: states )
|
for ( ReferenceOrderedDataState state: states )
|
||||||
tracks.bind( state.dataSource.getName(), state.iterator.seekForward(loc) );
|
tracks.bind( state.dataSource.getName(), state.iterator.seekForward(loc) );
|
||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RefMetaDataTracker createTracker( Collection<RODRecordList> allTracksHere ) {
|
private RefMetaDataTracker createTracker( Collection<RODRecordList> allTracksHere ) {
|
||||||
RefMetaDataTracker t = new RefMetaDataTracker();
|
RefMetaDataTracker t = new RefMetaDataTracker(allTracksHere.size());
|
||||||
for ( RODRecordList track : allTracksHere ) {
|
for ( RODRecordList track : allTracksHere ) {
|
||||||
if ( ! t.hasROD(track.getName()) )
|
if ( ! t.hasROD(track.getName()) )
|
||||||
t.bind(track.getName(), track);
|
t.bind(track.getName(), track);
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,15 @@ Genotype * Traversal calls tracker.bind(name, RMD) for each RMDs in RMDs
|
||||||
* Time: 3:05:23 PM
|
* Time: 3:05:23 PM
|
||||||
*/
|
*/
|
||||||
public class RefMetaDataTracker {
|
public class RefMetaDataTracker {
|
||||||
final HashMap<String, RODRecordList> map = new HashMap<String, RODRecordList>();
|
final Map<String, RODRecordList> map;
|
||||||
protected static Logger logger = Logger.getLogger(RefMetaDataTracker.class);
|
protected static Logger logger = Logger.getLogger(RefMetaDataTracker.class);
|
||||||
|
|
||||||
|
public RefMetaDataTracker(int nBindings) {
|
||||||
|
if ( nBindings == 0 )
|
||||||
|
map = Collections.emptyMap();
|
||||||
|
else
|
||||||
|
map = new HashMap<String, RODRecordList>(nBindings);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all the reference meta data associated with a track name.
|
* get all the reference meta data associated with a track name.
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,10 @@ public class GenomeLocParser {
|
||||||
* @return the contig index, -1 if not found
|
* @return the contig index, -1 if not found
|
||||||
*/
|
*/
|
||||||
public int getContigIndex(final String contig, boolean exceptionOut) {
|
public int getContigIndex(final String contig, boolean exceptionOut) {
|
||||||
if (contigInfo.getSequenceIndex(contig) == -1 && exceptionOut)
|
int idx = contigInfo.getSequenceIndex(contig);
|
||||||
|
if (idx == -1 && exceptionOut)
|
||||||
throw new UserException.CommandLineException(String.format("Contig %s given as location, but this contig isn't present in the Fasta sequence dictionary", contig));
|
throw new UserException.CommandLineException(String.format("Contig %s given as location, but this contig isn't present in the Fasta sequence dictionary", contig));
|
||||||
|
return idx;
|
||||||
return contigInfo.getSequenceIndex(contig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue