scripts/processing/clan_competition.py
def compete_seq_regions(regions, log):
    """
    regions: A list of duplicate regions for seq_acc
    log: log file pointer for tracking regions we haven't captured
    """

    index = 0

    non_sig_regs = []

    while index <= len(regions) - 2:
        reg1 = regions[index]
        comp_regs = regions[index + 1:]

        for reg2 in comp_regs:

            strand1 = get_strand(int(reg1[START]), int(reg1[END]))
            strand2 = get_strand(int(reg2[START]), int(reg2[END]))

            # check if the sequences come from the same strand
            if strand1 == strand2:

                # calculate overlap
                overlap = calc_seq_overlap(int(reg1[START]), int(reg1[END]),
                                           int(reg2[START]), int(reg2[END]))

                # check for a an overlap
                if overlap >= OVERLAP:

                    # at this point check the evalues and build the list for
                    # the non significant regions

                    if float(reg1[EVAL]) != float(reg2[EVAL]):
                        if float(reg1[EVAL]) < float(reg2[EVAL]):
                            if ((reg2[RFAM_ACC], reg2[SEQ_ACC],
                                 reg2[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg2[RFAM_ACC], reg2[SEQ_ACC], reg2[START]))
                        else:
                            if ((reg1[RFAM_ACC], reg1[SEQ_ACC],
                                 reg1[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg1[RFAM_ACC], reg1[SEQ_ACC], reg1[START]))

                    # check bit scores if e-values are equal
                    else:
                        if float(reg1[BIT_SCORE]) >= float(reg2[BIT_SCORE]):
                            if ((reg2[RFAM_ACC], reg2[SEQ_ACC],
                                 reg2[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg2[RFAM_ACC], reg2[SEQ_ACC], reg2[START]))
                        else:
                            if ((reg1[RFAM_ACC], reg1[SEQ_ACC],
                                 reg1[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg1[RFAM_ACC], reg1[SEQ_ACC], reg1[START]))

                elif overlap is None:
                    log.debug("reg1: %s" % '\t'.join(reg1))
                    log.debug("reg2: %s" % '\t'.join(reg2))

        index = index + 1
        comp_regs = None

    return non_sig_regs

    regions: A list of duplicate regions for seq_acc
    log: log file pointer for tracking regions we haven't captured
    
A list of duplicate regions for seq_acc
log: log file pointer for tracking regions we haven't captured
A list of duplicate regions for seq_acc log : log file pointer for tracking regions we haven ' t captured
def compete_seq_regions(regions, log):
    index = 0
    non_sig_regs = []
    while index <= len(regions) - 2:
        reg1 = regions[index]
        comp_regs = regions[index + 1:]
        for reg2 in comp_regs:
            strand1 = get_strand(int(reg1[START]), int(reg1[END]))
            strand2 = get_strand(int(reg2[START]), int(reg2[END]))
            if strand1 == strand2:
                overlap = calc_seq_overlap(int(reg1[START]), int(reg1[END]),
                                           int(reg2[START]), int(reg2[END]))
                if overlap >= OVERLAP:
                    if float(reg1[EVAL]) != float(reg2[EVAL]):
                        if float(reg1[EVAL]) < float(reg2[EVAL]):
                            if ((reg2[RFAM_ACC], reg2[SEQ_ACC],
                                 reg2[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg2[RFAM_ACC], reg2[SEQ_ACC], reg2[START]))
                        else:
                            if ((reg1[RFAM_ACC], reg1[SEQ_ACC],
                                 reg1[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg1[RFAM_ACC], reg1[SEQ_ACC], reg1[START]))
                    else:
                        if float(reg1[BIT_SCORE]) >= float(reg2[BIT_SCORE]):
                            if ((reg2[RFAM_ACC], reg2[SEQ_ACC],
                                 reg2[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg2[RFAM_ACC], reg2[SEQ_ACC], reg2[START]))
                        else:
                            if ((reg1[RFAM_ACC], reg1[SEQ_ACC],
                                 reg1[START]) not in non_sig_regs):
                                non_sig_regs.append(
                                    (reg1[RFAM_ACC], reg1[SEQ_ACC], reg1[START]))
                elif overlap is None:
                    log.debug("reg1: %s" % '\t'.join(reg1))
                    log.debug("reg2: %s" % '\t'.join(reg2))
        index = index + 1
        comp_regs = None
    return non_sig_regs
def compete_seq_regions ( regions , log ) : index = 0 non_sig_regs = [ ] while index <= len ( regions ) - 2 : reg1 = regions [ index ] comp_regs = regions [ index + 1 : ] for reg2 in comp_regs : strand1 = get_strand ( int ( reg1 [ START ] ) , int ( reg1 [ END ] ) ) strand2 = get_strand ( int ( reg2 [ START ] ) , int ( reg2 [ END ] ) ) if strand1 == strand2 : overlap = calc_seq_overlap ( int ( reg1 [ START ] ) , int ( reg1 [ END ] ) , int ( reg2 [ START ] ) , int ( reg2 [ END ] ) ) if overlap >= OVERLAP : if float ( reg1 [ EVAL ] ) != float ( reg2 [ EVAL ] ) : if float ( reg1 [ EVAL ] ) < float ( reg2 [ EVAL ] ) : if ( ( reg2 [ RFAM_ACC ] , reg2 [ SEQ_ACC ] , reg2 [ START ] ) not in non_sig_regs ) : non_sig_regs . append ( ( reg2 [ RFAM_ACC ] , reg2 [ SEQ_ACC ] , reg2 [ START ] ) ) else : if ( ( reg1 [ RFAM_ACC ] , reg1 [ SEQ_ACC ] , reg1 [ START ] ) not in non_sig_regs ) : non_sig_regs . append ( ( reg1 [ RFAM_ACC ] , reg1 [ SEQ_ACC ] , reg1 [ START ] ) ) else : if float ( reg1 [ BIT_SCORE ] ) >= float ( reg2 [ BIT_SCORE ] ) : if ( ( reg2 [ RFAM_ACC ] , reg2 [ SEQ_ACC ] , reg2 [ START ] ) not in non_sig_regs ) : non_sig_regs . append ( ( reg2 [ RFAM_ACC ] , reg2 [ SEQ_ACC ] , reg2 [ START ] ) ) else : if ( ( reg1 [ RFAM_ACC ] , reg1 [ SEQ_ACC ] , reg1 [ START ] ) not in non_sig_regs ) : non_sig_regs . append ( ( reg1 [ RFAM_ACC ] , reg1 [ SEQ_ACC ] , reg1 [ START ] ) ) elif overlap is None : log . debug ( "reg1: %s" % '\t' . join ( reg1 ) ) log . debug ( "reg2: %s" % '\t' . join ( reg2 ) ) index = index + 1 comp_regs = None return non_sig_regs
regions: A list of duplicate regions for seq_acc
log: log file pointer for tracking regions we haven't captured
regions : A list of duplicate regions for seq_acc log : log file pointer for tracking regions we haven ' t captured
"""
    regions: A list of duplicate regions for seq_acc
    log: log file pointer for tracking regions we haven't captured
    """ # check if the sequences come from the same strand # calculate overlap # check for a an overlap # at this point check the evalues and build the list for # the non significant regions # check bit scores if e-values are equal
regions
log