def check_window_qual_scores(qual_scores, window=50, min_average=25):
 l = len(qual_scores)
 window = min(window, l)
 if (window == 0):
  return True
 window_score = sum(qual_scores[:window])
 idx = 0
 while (((window_score / float(window)) >= min_average) and (idx < (l - window))):
  window_score += (qual_scores[(idx + window)] - qual_scores[idx])
  idx += 1
 if (idx == (l - window)):
  return (True, idx)
 else:
  return (False, idx)

def check_window_qual_scores ( qual_scores , window = 50 , min_average = 25 ) : l = len ( qual_scores ) window = min ( window , l ) if ( window == 0 ) : return True window_score = sum ( qual_scores [ : window ] ) idx = 0 while ( ( ( window_score / float ( window ) ) >= min_average ) and ( idx < ( l - window ) ) ) : window_score += ( qual_scores [ ( idx + window ) ] - qual_scores [ idx ] ) idx += 1 if ( idx == ( l - window ) ) : return ( True , idx ) else : return ( False , idx )
check that all windows have ave qual score > threshold .