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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -97,7 +98,9 @@ public class AllLocusView extends LocusView {
|
|||
* @param site Site at which to create the blank locus context.
|
||||
* @return empty context.
|
||||
*/
|
||||
private AlignmentContext createEmptyLocus( GenomeLoc site ) {
|
||||
return new AlignmentContext(site,new ReadBackedPileupImpl(site,new ArrayList<SAMRecord>(), new ArrayList<Integer>()));
|
||||
private final static List<SAMRecord> EMPTY_PILEUP_READS = Collections.emptyList();
|
||||
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.
|
||||
*/
|
||||
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc ) {
|
||||
RefMetaDataTracker tracks = new RefMetaDataTracker();
|
||||
for (ReferenceOrderedDataState state: states )
|
||||
RefMetaDataTracker tracks = new RefMetaDataTracker(states.size());
|
||||
for ( ReferenceOrderedDataState state: states )
|
||||
tracks.bind( state.dataSource.getName(), state.iterator.seekForward(loc) );
|
||||
return tracks;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
|
|||
}
|
||||
|
||||
private RefMetaDataTracker createTracker( Collection<RODRecordList> allTracksHere ) {
|
||||
RefMetaDataTracker t = new RefMetaDataTracker();
|
||||
RefMetaDataTracker t = new RefMetaDataTracker(allTracksHere.size());
|
||||
for ( RODRecordList track : allTracksHere ) {
|
||||
if ( ! t.hasROD(track.getName()) )
|
||||
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
|
||||
*/
|
||||
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);
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@ public class GenomeLocParser {
|
|||
* @return the contig index, -1 if not found
|
||||
*/
|
||||
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));
|
||||
|
||||
return contigInfo.getSequenceIndex(contig);
|
||||
return idx;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue