Part III of GSA-462: Consistent RODBinding access across Ref and Read trackers
-- shardSpan is only calculated when there some ROD is live in the GATK. No sense in paying the cost per read when you don't need it -- Update contract to allow null span or unmapped span (good catch unittests!)
This commit is contained in:
parent
1200848bbf
commit
53376b9423
|
|
@ -57,7 +57,9 @@ public class ReadBasedReferenceOrderedView implements View {
|
||||||
private final GenomeLoc shardSpan;
|
private final GenomeLoc shardSpan;
|
||||||
|
|
||||||
public ReadBasedReferenceOrderedView(final ShardDataProvider provider) {
|
public ReadBasedReferenceOrderedView(final ShardDataProvider provider) {
|
||||||
this(provider.getGenomeLocParser(), ((ReadShard)provider.getShard()).getReadsSpan());
|
this.genomeLocParser = provider.getGenomeLocParser();
|
||||||
|
// conditional to optimize the case where we don't have any ROD data
|
||||||
|
this.shardSpan = provider.getReferenceOrderedData() != null ? ((ReadShard)provider.getShard()).getReadsSpan() : null;
|
||||||
provider.register(this);
|
provider.register(this);
|
||||||
|
|
||||||
if ( provider.getReferenceOrderedData() != null && ! shardSpan.isUnmapped() ) {
|
if ( provider.getReferenceOrderedData() != null && ! shardSpan.isUnmapped() ) {
|
||||||
|
|
@ -66,10 +68,6 @@ public class ReadBasedReferenceOrderedView implements View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadBasedReferenceOrderedView(final GenomeLocParser genomeLocParser, final GenomeLoc shardSpan) {
|
|
||||||
this.genomeLocParser = genomeLocParser;
|
|
||||||
this.shardSpan = shardSpan;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Testing constructor
|
* Testing constructor
|
||||||
|
|
@ -78,7 +76,8 @@ public class ReadBasedReferenceOrderedView implements View {
|
||||||
final GenomeLoc shardSpan,
|
final GenomeLoc shardSpan,
|
||||||
final List<String> names,
|
final List<String> names,
|
||||||
final List<PeekableIterator<RODRecordList>> featureSources) {
|
final List<PeekableIterator<RODRecordList>> featureSources) {
|
||||||
this(genomeLocParser, shardSpan);
|
this.genomeLocParser = genomeLocParser;
|
||||||
|
this.shardSpan = shardSpan;
|
||||||
for ( int i = 0; i < names.size(); i++ )
|
for ( int i = 0; i < names.size(); i++ )
|
||||||
states.add(new RMDDataState(names.get(i), featureSources.get(i)));
|
states.add(new RMDDataState(names.get(i), featureSources.get(i)));
|
||||||
}
|
}
|
||||||
|
|
@ -106,10 +105,10 @@ public class ReadBasedReferenceOrderedView implements View {
|
||||||
return getReferenceOrderedDataForInterval(genomeLocParser.createGenomeLoc(rec));
|
return getReferenceOrderedDataForInterval(genomeLocParser.createGenomeLoc(rec));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Requires({"interval != null", "shardSpan.containsP(interval)"})
|
@Requires({"interval != null", "shardSpan == null || shardSpan.isUnmapped() || shardSpan.containsP(interval)"})
|
||||||
@Ensures("result != null")
|
@Ensures("result != null")
|
||||||
public RefMetaDataTracker getReferenceOrderedDataForInterval(final GenomeLoc interval) {
|
public RefMetaDataTracker getReferenceOrderedDataForInterval(final GenomeLoc interval) {
|
||||||
if ( states.isEmpty() ) // optimization for no bindings (common for read walkers)
|
if ( states.isEmpty() || shardSpan.isUnmapped() ) // optimization for no bindings (common for read walkers)
|
||||||
return EMPTY_TRACKER;
|
return EMPTY_TRACKER;
|
||||||
else {
|
else {
|
||||||
final List<RODRecordList> bindings = new ArrayList<RODRecordList>(states.size());
|
final List<RODRecordList> bindings = new ArrayList<RODRecordList>(states.size());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue