Skip to content

Commit

Permalink
Change to PairOrientation stratifier and typo fix
Browse files Browse the repository at this point in the history
- The PairOrientation stratifier now checks if the read is paired and
returns null if it is not
- fixed small typo originating from the separation of the PRs
  • Loading branch information
michaelgatzen committed Aug 12, 2019
1 parent cde82fb commit 7a5c757
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ else if (!currentLocus.withinDistanceOf(locusInfo, 0)) {
* @param info The SAMLocusAndReference object
* @param operation Classifies whether the current event is a match, insertion, or deletion
*/
private void addAndRecordAndOffset(final Collection<BaseErrorAggregation> aggregatorList, final SamLocusIterator.RecordAndOffset rao, final SAMLocusAndReference info, final BaseOperation operation) {
private void addRecordAndOffset(final Collection<BaseErrorAggregation> aggregatorList, final SamLocusIterator.RecordAndOffset rao, final SAMLocusAndReference info, final BaseOperation operation) {
// If deletion has been processed already, skip it
if (operation == BaseOperation.Deletion && processDeletionLocus(rao, info.getLocus()))
return;
Expand All @@ -424,17 +424,17 @@ private void addAndRecordAndOffset(final Collection<BaseErrorAggregation> aggreg
private void addLocusBases(final Collection<BaseErrorAggregation> aggregatorList, final SAMLocusAndReference info) {
// Matching bases
for (final SamLocusIterator.RecordAndOffset rao : info.getRecordAndOffsets()) {
addAndRecordAndOffset(aggregatorList, rao, info, BaseOperation.Match);
addRecordAndOffset(aggregatorList, rao, info, BaseOperation.Match);
}

// Deleted bases
for (final SamLocusIterator.RecordAndOffset deletionRao : info.getLocus().getDeletedInRecord()) {
addAndRecordAndOffset(aggregatorList, deletionRao, info, BaseOperation.Deletion);
addRecordAndOffset(aggregatorList, deletionRao, info, BaseOperation.Deletion);
}

// Inserted bases
for (final SamLocusIterator.RecordAndOffset insertionRao : info.getLocus().getInsertedInRecord()) {
addAndRecordAndOffset(aggregatorList, insertionRao, info, BaseOperation.Insertion);
addRecordAndOffset(aggregatorList, insertionRao, info, BaseOperation.Insertion);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,11 @@ public static PairOrientation of(final SAMRecord sam) {
final ReadOrdinality ordinality = ReadOrdinality.of(sam);
final ReadDirection direction = ReadDirection.of(sam);

// Make sure that the read is paired
if (!sam.getReadPairedFlag()) {
return null;
}

// if read is unmapped, read isn't mapped, or mate is unmapped, return null
if (direction == null ||
sam.getReadUnmappedFlag() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public Object[][] provideForTestIndelErrors() {
// insertions & deletions
{ new String[] { "20M2I20M3D20M" }, ".indel_error_by_indel_length", new IndelErrorMetric("2", 2, 1, 2, 0, 0) },
{ new String[] { "20M2I20M3D20M" }, ".indel_error_by_indel_length", new IndelErrorMetric("3", 0, 0, 0, 1, 3) },
{ new String[] { "2I2D20M" }, ".indel_error_by_indel_length", new IndelErrorMetric("2", 2, 1, 2,1, 2) },
{ new String[] { "2I2D20M" }, ".indel_error_by_indel_length", new IndelErrorMetric("2", 2, 1, 2, 1, 2) },
{ new String[] { "2D2I20M" }, ".indel_error_by_indel_length", new IndelErrorMetric("2", 2, 1, 2, 1, 2) },
{ new String[] { "2M2D2I" }, ".indel_error_by_indel_length", new IndelErrorMetric("2", 2, 1, 2, 1, 2) },
{ new String[] { "20M2I2D" }, ".indel_error_by_indel_length", new IndelErrorMetric("2", 2, 1, 2, 1, 2) },
Expand Down

0 comments on commit 7a5c757

Please sign in to comment.