Skip to content

Commit

Permalink
Additional annotation in FeatureMap (#8347)
Browse files Browse the repository at this point in the history
X_FILTERED_COUNT the number of reads in the locus that pass the FeatureMap filters, regardless of whether the considered base matches the reference or not
  • Loading branch information
ilyasoifer authored Jul 2, 2023
1 parent 2b9d54d commit c068947
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

public interface FeatureMapper {

enum FilterStatus {
None,
Filtered,
NoFeatureAndFiltered
};

void forEachOnRead(GATKRead read, ReferenceContext referenceContext, Consumer<? super FlowFeatureMapper.MappedFeature> action);
boolean noFeatureButFilterAt(GATKRead read, ReferenceContext referenceContext, int start);
FilterStatus noFeatureButFilterAt(GATKRead read, ReferenceContext referenceContext, int start);
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected static class MappedFeature implements Comparable<MappedFeature> {
byte[] readBases;
byte[] refBases;
int readBasesOffset; // offset of read bases array
int start; // location (on rerence)
int start; // location (on reference)
int offsetDelta;
double score;
int readCount;
Expand Down Expand Up @@ -405,7 +405,7 @@ private void enrichFeature(final MappedFeature fr) {
for ( ReadContext rc : readQueue ) {
if ( rc.read.contains(loc) ) {
fr.readCount++;
if ( mapper.noFeatureButFilterAt(rc.read, rc.referenceContext, fr.start) ) {
if ( mapper.noFeatureButFilterAt(rc.read, rc.referenceContext, fr.start) == FeatureMapper.FilterStatus.Filtered ) {
fr.filteredCount++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private int calcSmq(final byte[] quals, int from, int to, boolean median) {
}
}

public boolean noFeatureButFilterAt(GATKRead read, ReferenceContext referenceContext, int start) {
public FilterStatus noFeatureButFilterAt(GATKRead read, ReferenceContext referenceContext, int start) {

// access bases
final byte[] bases = read.getBasesNoCopy();
Expand All @@ -245,7 +245,7 @@ public boolean noFeatureButFilterAt(GATKRead read, ReferenceContext referenceCon
// break out if not enough clearing
if ( (start < referenceContext.getStart() + refOfs + identBefore) ||
(start >= referenceContext.getStart() + refOfs + length - identAfter) )
return false;
return FilterStatus.Filtered;

int delta = start - (referenceContext.getStart() + refOfs);
readOfs += delta;
Expand All @@ -269,10 +269,10 @@ public boolean noFeatureButFilterAt(GATKRead read, ReferenceContext referenceCon
continue;
}

// this is it! no feature but filtred in
return true;
// this is it! no feature but filtered in
return FilterStatus.NoFeatureAndFiltered;
} else
return false;
return FilterStatus.Filtered;

} else {

Expand All @@ -287,7 +287,7 @@ public boolean noFeatureButFilterAt(GATKRead read, ReferenceContext referenceCon
};

// if here, false
return false;
return FilterStatus.None;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,11 @@ public void applyBaseClipping(final int clipLeftBase, final int clipRightBase, b

private void applyClipping(int clipLeft, final int leftHmerClip, int clipRight, final int rightHmerClip, final boolean spread){
if ((clipLeft < 0) || (clipRight < 0) || (clipLeft >= getKeyLength() ) || ( clipRight >= getKeyLength())) {
throw new IllegalStateException("Weird read clip calculated");
throw new IllegalStateException(String.format("Weird read clip calculated: left/right/keyLength %d/%d/%d", clipLeft, clipRight, getKeyLength()));
}

if ((leftHmerClip < 0) || (rightHmerClip < 0) || (leftHmerClip >= 14 ) || ( rightHmerClip >= 14)) {
throw new IllegalStateException("Weird read clip calculated");
if ((leftHmerClip < 0) || (rightHmerClip < 0) || (leftHmerClip >= (getMaxHmer() + 2) ) || ( rightHmerClip >= (getMaxHmer() + 2))) {
throw new IllegalStateException(String.format("Weird read clip calculated: left/right/maxHmer+2 %d/%d/%d", leftHmerClip, rightHmerClip, getMaxHmer() + 2));
}

final int originalLength = key.length;
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown

0 comments on commit c068947

Please sign in to comment.