output_SW.py
def createheatmap(fileR1, fileR2, maxlinenum):
    ''' Central function, return numpy "heatmaps"
     Ensures that files are of same length'''
    numlines1 = countlines(fileR1); numlines2 = countlines(fileR2)
    assert numlines1 == numlines2, 'These files are different lengths'
    vals1, numFaultyCpf1 = getvals(fileR1, maxlinenum, isR2=False)
    vals2, numFaultycrispr_gate = getvals(fileR2, maxlinenum, isR2=True)
    try:
        print("Number of faulty Cpf1/Cas12 repeat: " + str(numFaultyCpf1))
        print("Number of faulty crispr-gate promoter: " + str(numFaultycrispr_gate))
    except Exception as e:
        print(e)
        pass

    # Create histogram, heatmap for R1 and show histogram for R1
    heatmap1 = np.ones((1, 128), dtype=np.uint8)
    declist1 = []
    for i in range(len(vals1)):
        if vals1[i] != 'null':
            bin1 = vals1[i]
            dec1 = int(bin1, 2)
            declist1.append(dec1)
            heatmap1[0][dec1] += 1
        else:
            declist1.append('null')
    """ plt.hist(declist1, bins=128)
    plt.title(fileR1)
    plt.show()
"""
    # Create histogram, heatmap for R2 and show histogram for R2
    heatmap2 = np.zeros((1, 128), dtype=np.uint8)
    declist2 = []
    for i in range(len(vals2)):
        if (vals2[i] != 'null'):
            bin2 = vals2[i]
            dec2 = int(bin2, 2)
            declist2.append(dec2)
            heatmap2[0][dec2] += 1
        else:
            declist2.append('null')

    """plt.hist(declist2, bins=128)
    plt.title(fileR2)
    plt.show()
"""

    # Create 2d heatmap
    heatmap_2d = np.zeros((128, 128))
    try:
        for i in range(10000):
            for j in range(10000):
                r1val = declist1[i]
                r2val = declist2[j]
                if not(r1val == 'null' or r2val == 'null'):
                    heatmap_2d[r1val][r2val] += 1
        '''fig = plt.figure()
        fig.suptitle('heatmap')
        ax = fig.add_subplot(111)
        ax.set_title(fileR1)
        ax.set_ylabel(fileR2)
        ax.plot(heatmap_2d)'''
        heatmap_2d = np.log(heatmap_2d + .01)
        plt.imshow(heatmap_2d)
        plt.gca().invert_yaxis()
        plt.title('heatmap_2d')
        plt.xlabel(fileR2)
        plt.ylabel(fileR1)
        print('Displaying heatmap_2d; close it to exit program')
        plt.show()

        return heatmap1, heatmap2
    except Exception as e:
        print('*** ' + str(e))
        print('*** If got \"list index out of range\" error, is likely that no matches found')
        return
 Central function, return numpy "heatmaps"
     Ensures that files are of same length
Central function, return numpy "heatmaps"
Ensures that files are of same length
Central function return numpy " heatmaps " Ensures that files are of same length
def createheatmap(fileR1, fileR2, maxlinenum):
    numlines1 = countlines(fileR1); numlines2 = countlines(fileR2)
    assert numlines1 == numlines2, 'These files are different lengths'
    vals1, numFaultyCpf1 = getvals(fileR1, maxlinenum, isR2=False)
    vals2, numFaultycrispr_gate = getvals(fileR2, maxlinenum, isR2=True)
    try:
        print("Number of faulty Cpf1/Cas12 repeat: " + str(numFaultyCpf1))
        print("Number of faulty crispr-gate promoter: " + str(numFaultycrispr_gate))
    except Exception as e:
        print(e)
        pass
    heatmap1 = np.ones((1, 128), dtype=np.uint8)
    declist1 = []
    for i in range(len(vals1)):
        if vals1[i] != 'null':
            bin1 = vals1[i]
            dec1 = int(bin1, 2)
            declist1.append(dec1)
            heatmap1[0][dec1] += 1
        else:
            declist1.append('null')
    heatmap2 = np.zeros((1, 128), dtype=np.uint8)
    declist2 = []
    for i in range(len(vals2)):
        if (vals2[i] != 'null'):
            bin2 = vals2[i]
            dec2 = int(bin2, 2)
            declist2.append(dec2)
            heatmap2[0][dec2] += 1
        else:
            declist2.append('null')
    heatmap_2d = np.zeros((128, 128))
    try:
        for i in range(10000):
            for j in range(10000):
                r1val = declist1[i]
                r2val = declist2[j]
                if not(r1val == 'null' or r2val == 'null'):
                    heatmap_2d[r1val][r2val] += 1
        heatmap_2d = np.log(heatmap_2d + .01)
        plt.imshow(heatmap_2d)
        plt.gca().invert_yaxis()
        plt.title('heatmap_2d')
        plt.xlabel(fileR2)
        plt.ylabel(fileR1)
        print('Displaying heatmap_2d; close it to exit program')
        plt.show()
        return heatmap1, heatmap2
    except Exception as e:
        print('*** ' + str(e))
        print('*** If got \"list index out of range\" error, is likely that no matches found')
        return
def createheatmap ( fileR1 , fileR2 , maxlinenum ) : numlines1 = countlines ( fileR1 ) ; numlines2 = countlines ( fileR2 ) assert numlines1 == numlines2 , 'These files are different lengths' vals1 , numFaultyCpf1 = getvals ( fileR1 , maxlinenum , isR2 = False ) vals2 , numFaultycrispr_gate = getvals ( fileR2 , maxlinenum , isR2 = True ) try : print ( "Number of faulty Cpf1/Cas12 repeat: " + str ( numFaultyCpf1 ) ) print ( "Number of faulty crispr-gate promoter: " + str ( numFaultycrispr_gate ) ) except Exception as e : print ( e ) pass heatmap1 = np . ones ( ( 1 , 128 ) , dtype = np . uint8 ) declist1 = [ ] for i in range ( len ( vals1 ) ) : if vals1 [ i ] != 'null' : bin1 = vals1 [ i ] dec1 = int ( bin1 , 2 ) declist1 . append ( dec1 ) heatmap1 [ 0 ] [ dec1 ] += 1 else : declist1 . append ( 'null' ) """ plt.hist(declist1, bins=128)
    plt.title(fileR1)
    plt.show()
""" heatmap2 = np . zeros ( ( 1 , 128 ) , dtype = np . uint8 ) declist2 = [ ] for i in range ( len ( vals2 ) ) : if ( vals2 [ i ] != 'null' ) : bin2 = vals2 [ i ] dec2 = int ( bin2 , 2 ) declist2 . append ( dec2 ) heatmap2 [ 0 ] [ dec2 ] += 1 else : declist2 . append ( 'null' ) """plt.hist(declist2, bins=128)
    plt.title(fileR2)
    plt.show()
""" heatmap_2d = np . zeros ( ( 128 , 128 ) ) try : for i in range ( 10000 ) : for j in range ( 10000 ) : r1val = declist1 [ i ] r2val = declist2 [ j ] if not ( r1val == 'null' or r2val == 'null' ) : heatmap_2d [ r1val ] [ r2val ] += 1 '''fig = plt.figure()
        fig.suptitle('heatmap')
        ax = fig.add_subplot(111)
        ax.set_title(fileR1)
        ax.set_ylabel(fileR2)
        ax.plot(heatmap_2d)''' heatmap_2d = np . log ( heatmap_2d + .01 ) plt . imshow ( heatmap_2d ) plt . gca ( ) . invert_yaxis ( ) plt . title ( 'heatmap_2d' ) plt . xlabel ( fileR2 ) plt . ylabel ( fileR1 ) print ( 'Displaying heatmap_2d; close it to exit program' ) plt . show ( ) return heatmap1 , heatmap2 except Exception as e : print ( '*** ' + str ( e ) ) print ( '*** If got \"list index out of range\" error, is likely that no matches found' ) return
Central function, return numpy "heatmaps"
Ensures that files are of same length
Central function return numpy " heatmaps " Ensures that files are of same length
''' Central function, return numpy "heatmaps"
     Ensures that files are of same length''' # Create histogram, heatmap for R1 and show histogram for R1 """ plt.hist(declist1, bins=128)
    plt.title(fileR1)
    plt.show()
""" # Create histogram, heatmap for R2 and show histogram for R2 """plt.hist(declist2, bins=128)
    plt.title(fileR2)
    plt.show()
""" # Create 2d heatmap '''fig = plt.figure()
        fig.suptitle('heatmap')
        ax = fig.add_subplot(111)
        ax.set_title(fileR1)
        ax.set_ylabel(fileR2)
        ax.plot(heatmap_2d)'''
fileR1
fileR2
maxlinenum