Skip to content

Commit

Permalink
X_FILTERED_COUNT
Browse files Browse the repository at this point in the history
 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
dror27 authored and ilyasoifer committed Jul 2, 2023
1 parent 2b9d54d commit 4495942
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()));

Check warning on line 594 in src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedRead.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedRead.java#L594

Added line #L594 was not covered by tests
}

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));

Check warning on line 598 in src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedRead.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedRead.java#L598

Added line #L598 was not covered by tests
}

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 4495942

Please sign in to comment.