Esempio n. 1
0
def main(args):
    a_file = open("../doc/pickle/alignment.pickle", "r")

    # Load the 5-way alignment
    alignment = pickle.load(a_file)

    # Close relevant files
    a_file.close()

    skip = [1, 2, 3, 4, 5, 6]
    pvals = [-9, -10]
    len1 = 0
    len2 = 0
    f1 = ""
    f2 = ""
    offset = 0
    for j in pvals:
        #if j == -9: offset = 60
        #else: offset = 0
        print "Doing pval " + str(j)
        pwms = []
        pwmsShuffled = []
        for i in range(111):
            if i+1 < 10:                
                pwms.append("MA000" + str(i+1) + "(p " + str(j) + ").gff")
                pwmsShuffled.append("MA000" + str(i+1) + "random(p " + str(j) + ").gff")
            elif i+1 < 100:
                pwms.append("MA00" + str(i+1) + "(p " + str(j) + ").gff")
                pwmsShuffled.append("MA00" + str(i+1) + "random(p " + str(j) + ").gff")
            else:
                pwms.append("MA0" + str(i+1) + "(p " + str(j) + ").gff")
                pwmsShuffled.append("MA0" + str(i+1) + "random(p " + str(j) + ").gff")            
        for i in range(len(pwms)-offset):            
            f1 = open("../doc/fasta/" + pwms[i+offset], "r")
            f2 = open("../doc/fasta/" + pwmsShuffled[i+offset], "r")
            m1 = cm_scan3.buildMotifs(f1, alignment)
            m2 = cm_scan3.buildMotifs(f2, alignment)
            len1 = len(m1)
            len2 = len(m2)
            f1.close()
            f2.close()
            try:
                print len1, len2
                if len1 != 0 and len2 != 0:
                    print pwms[i+offset]
                    cm_scan3NA.mainRunner(pwms[i+offset], m1, min([len1, len2]), "LL all PWM pval " + str(j) + "/")
                    print pwmsShuffled[i+offset]
                    cm_scan3NA.mainRunner(pwmsShuffled[i+offset], m2, min([len1, len2]), "LL all PWMRandom pval " + str(j) + "/")
                else: print "NO HITS"
            except KeyError:
                print "\t\tkey problem", pwms[i+offset]               
    sys.exit(0)
Esempio n. 2
0
def main(args):
    a_file = open("../doc/pickle/alignment.pickle", "r")

    # Load the 5-way alignment
    alignment = pickle.load(a_file)

    # Close relevant files
    a_file.close()

    skip = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
    pvals = [-9, -10]
    len1 = 0    
    f1 = ""    
    for j in pvals:        
        print "Doing pval " + str(j)
        pwms = []
        
        for i in range(111):
            if i+1 < 10:                
                pwms.append("MA000" + str(i+1))                
            elif i+1 < 100:
                pwms.append("MA00" + str(i+1))                
            else:
                pwms.append("MA0" + str(i+1))
        for s in skip:                    
            for i in range(len(pwms)):                
                f1 = open("../doc/fasta/" + pwms[i] + "(p " + str(j) + ").gff", "r")            
                m1 = cm_scan3.buildMotifs(f1, alignment)            
                len1 = findLength(pwms[i] + ".pwm")            
                f1.close()
                print len(m1)
                if len1 > s+1:
                    try:                
                        if len(m1) != 0:
                            print pwms[i]
                            cm_scan3NA.mainRunner(pwms[i] + "(p " + str(j) + ").gff", m1, len(m1), "LL all PWM pval " + str(j) + " NA " + str(s) + "/", s)                    
                        else: print "NO HITS"
                    except KeyError:
                        print "\t\tkey problem", pwms[i]
            makeGraphs.make("LL all PWM pval " + str(j) + " NA " + str(s) + "/", j, s)
            cm_scanTester2.mainRunner(s, j)
    sys.exit(0)