def trim5p3p_helper(r, seq_5p, seq_3p_rev):
    "\n    Search for 5' and 3' in the first and last 100 bp window\n    "
    s1 = str(r.seq[:100])
    s2 = str(r.reverse_complement().seq[:100])
    o1 = parasail.sg_qx_trace(s1, seq_5p, 3, 1, SCOREMAT)
    o2 = parasail.sg_qe_db_trace(s2, seq_3p_rev, 3, 1, SCOREMAT)
    lenA = None
    if (o2.score >= MINSCORE_3P):
        lenA = trimA(s2[(o2.end_query + 1):])
    if (MIN_A_LEN == 0):
        end3 = ((len(r.seq) - o2.end_query) - 1)
        return ScoreTuple(score5=o1.score, end5=o1.end_query, score3=o2.score, end3=end3, endA=end3)
    elif (lenA is not None):
        end3 = ((len(r.seq) - o2.end_query) - 1)
        endA = ((end3 - lenA) + 1)
        return ScoreTuple(score5=o1.score, end5=o1.end_query, score3=o2.score, end3=end3, endA=endA)
    else:
        end3 = ((len(r.seq) - o2.end_query) - 1)
        return ScoreTuple(score5=o1.score, end5=o1.end_query, score3=o2.score, end3=end3, endA=end3)
Search for 5' and 3' in the first and last 100 bp window
def trim5p3p_helper(r, seq_5p, seq_3p_rev):
    "\n    \n    "
    s1 = str(r.seq[:100])
    s2 = str(r.reverse_complement().seq[:100])
    o1 = parasail.sg_qx_trace(s1, seq_5p, 3, 1, SCOREMAT)
    o2 = parasail.sg_qe_db_trace(s2, seq_3p_rev, 3, 1, SCOREMAT)
    lenA = None
    if (o2.score >= MINSCORE_3P):
        lenA = trimA(s2[(o2.end_query + 1):])
    if (MIN_A_LEN == 0):
        end3 = ((len(r.seq) - o2.end_query) - 1)
        return ScoreTuple(score5=o1.score, end5=o1.end_query, score3=o2.score, end3=end3, endA=end3)
    elif (lenA is not None):
        end3 = ((len(r.seq) - o2.end_query) - 1)
        endA = ((end3 - lenA) + 1)
        return ScoreTuple(score5=o1.score, end5=o1.end_query, score3=o2.score, end3=end3, endA=endA)
    else:
        end3 = ((len(r.seq) - o2.end_query) - 1)
        return ScoreTuple(score5=o1.score, end5=o1.end_query, score3=o2.score, end3=end3, endA=end3)