@@ -554,23 +554,17 @@ int bam_next_basemod(const bam1_t *b, hts_base_mod_state *state,
554554 // Look through state->MMcount arrays to see when the next lowest is
555555 // per base type;
556556 int next [16 ], freq [16 ] = {0 }, i ;
557- memset (next , 0x7f , 16 * sizeof (* next ));
557+ memset (next , 0x7f , 16 * sizeof (* next )); // approx max => no next value
558558 const int unchecked = state -> flags & HTS_MOD_REPORT_UNCHECKED ;
559559
560- if (b -> core .flag & BAM_FREVERSE ) {
561- for (i = 0 ; i < state -> nmods ; i ++ ) {
562- if (unchecked && !state -> implicit [i ])
563- next [seqi_rc [state -> canonical [i ]]] = 0 ;
564- else if (next [seqi_rc [state -> canonical [i ]]] > state -> MMcount [i ])
565- next [seqi_rc [state -> canonical [i ]]] = state -> MMcount [i ];
566- }
567- } else {
568- for (i = 0 ; i < state -> nmods ; i ++ ) {
569- if (unchecked && !state -> implicit [i ])
570- next [state -> canonical [i ]] = 0 ;
571- else if (next [state -> canonical [i ]] > state -> MMcount [i ])
572- next [state -> canonical [i ]] = state -> MMcount [i ];
573- }
560+ for (i = 0 ; i < state -> nmods ; i ++ ) {
561+ int base = state -> canonical [i ];
562+ if (b -> core .flag & BAM_FREVERSE )
563+ base = seqi_rc [base ];
564+ if (unchecked && !state -> implicit [i ])
565+ next [base ] = 0 ;
566+ else if (next [base ] > state -> MMcount [i ])
567+ next [base ] = state -> MMcount [i ];
574568 }
575569
576570 // Now step through the sequence counting off base types.
0 commit comments