예제 #1
0
def cpd_reshape_export(cpd_path, ccl_file, output_file, codon_vector=gc.codon_list_hypothesis[:]):
    cpd_main = RNAsnp.get_whole_cpd(cpd_path)
    #codon_vector = gc.codon_list_hypothesis[:]
    mp = pyMH.ModelHYPHY(lst_2_tuple_file_name=ccl_file)
    with open(output_file, "w") as writer:
        writer.write("from\tto\tMutationCount\tMutationClass\n")
        available_cc = cpd_main.keys()
        for codon_origin in codon_vector:

            for codon_target in codon_vector:
                # build a line for lst file
                num_mutation = 0
                class_mutation = 0
                if (codon_origin, codon_target) in available_cc:
                    num_mutation = len(cpd_main[codon_origin, codon_target])
                    codon_check_response = mp.check_codons(codon_origin, codon_target)

                    if type(codon_check_response) == tuple:  # two codon only differ one site
                        is_transversion, is_sysnonmous, is_larger, nt_diff = codon_check_response
                        class_mutation += 1
                        if not is_sysnonmous:
                            class_mutation += 1
                        if is_larger:
                            class_mutation += 2

                writer.write("%d\t%d\t%d\t%d\n" % (codon_vector.index(codon_origin) + 1,
                                                   codon_vector.index(codon_target) + 1,
                                                   num_mutation,
                                                   class_mutation))
예제 #2
0
def main2():
    cpd_main = RNAsnp.get_whole_cpd("/home/zerodel/Workspace/cpd_store_site")
    codon_vector = gc.codon_list_hypothesis
    with open("/home/zerodel/GitProjects/python-rna-structure/data/rnasnp.matrix", "w") as writer:
        for codon1 in codon_vector:
            # build a line for lst file
            line_single = []
            for codon2 in codon_vector:
                line_single.append(str(len(cpd_main[(codon1, codon2)])))

            writer.write("\t".join(line_single) + "\n")
    with open("/home/zerodel/GitProjects/python-rna-structure/data/codon_vector.txt", "w") as writer:
        writer.write("\n".join(gc.codon_list_hypothesis))
예제 #3
0
def main2():
    cpd_main = RNAsnp.get_whole_cpd("/home/zerodel/Workspace/cpd_store_site")
    codon_vector = gc.codon_list_hypothesis
    with open(
            "/home/zerodel/GitProjects/python-rna-structure/data/rnasnp.matrix",
            "w") as writer:
        for codon1 in codon_vector:
            # build a line for lst file
            line_single = []
            for codon2 in codon_vector:
                line_single.append(str(len(cpd_main[(codon1, codon2)])))

            writer.write("\t".join(line_single) + "\n")
    with open(
            "/home/zerodel/GitProjects/python-rna-structure/data/codon_vector.txt",
            "w") as writer:
        writer.write("\n".join(gc.codon_list_hypothesis))
예제 #4
0
def main3():
    cpd_main = RNAsnp.get_whole_cpd("/home/zerodel/Workspace/cpd_store_site")
    codon_vector = gc.codon_list_64
    with open("/home/zerodel/GitProjects/python-rna-structure/data/fullRnasnp.matrix", "w") as writer:
        available_cc = cpd_main.keys()
        for codon1 in codon_vector:
            # build a line for lst file
            line_single = []
            for codon2 in codon_vector:
                if (codon1, codon2) in available_cc:
                    line_single.append(str(len(cpd_main[(codon1, codon2)])))
                else:
                    line_single.append(str(0))

            writer.write("\t".join(line_single) + "\n")
    with open("/home/zerodel/GitProjects/python-rna-structure/data/codon_vector64.txt", "w") as writer:
        writer.write("\n".join(gc.codon_list_64))
예제 #5
0
def main3():
    cpd_main = RNAsnp.get_whole_cpd("/home/zerodel/Workspace/cpd_store_site")
    codon_vector = gc.codon_list_64
    with open(
            "/home/zerodel/GitProjects/python-rna-structure/data/fullRnasnp.matrix",
            "w") as writer:
        available_cc = cpd_main.keys()
        for codon1 in codon_vector:
            # build a line for lst file
            line_single = []
            for codon2 in codon_vector:
                if (codon1, codon2) in available_cc:
                    line_single.append(str(len(cpd_main[(codon1, codon2)])))
                else:
                    line_single.append(str(0))

            writer.write("\t".join(line_single) + "\n")
    with open(
            "/home/zerodel/GitProjects/python-rna-structure/data/codon_vector64.txt",
            "w") as writer:
        writer.write("\n".join(gc.codon_list_64))
예제 #6
0
        if sys.platform == 'win32':
            x = x.lower()
        if new_path in (x, x + os.sep):
            return 0
    sys.path.append(new_path)
    # if you want the new_path to take precedence over existing
    # directories already in sys.path, instead of appending, use:
    # sys.path.insert(0, new_path)
    return 1


AddSysPath("..")

import pyRNAsnp.pyRNAsnp as pyr

### for test in emacs python mode
test_emacs = True
if __name__ == "__main__":
    test_emacs = False

if (test_emacs):
    print "hello world"
    cpd_path = '/media/zerodel/Program/Workspace/Ecoli/cpd_full'
    print cpd_path
    whole = pyr.get_whole_cpd(
        "/media/zerodel/Program/Workspace/Ecoli/cpd_full")
    print len(whole)

if __name__ == "__main__":
    pass
예제 #7
0
        if new_path in (x, x + os.sep):
            return 0
    sys.path.append(new_path)
    # if you want the new_path to take precedence over existing
    # directories already in sys.path, instead of appending, use:
    # sys.path.insert(0, new_path)
    return 1

AddSysPath("..")

import pyRNAsnp.pyRNAsnp as pyr




### for test in emacs python mode
test_emacs = True
if __name__ == "__main__":
    test_emacs = False

if (test_emacs):
    print "hello world"
    cpd_path = '/media/zerodel/Program/Workspace/Ecoli/cpd_full'
    print cpd_path
    whole = pyr.get_whole_cpd("/media/zerodel/Program/Workspace/Ecoli/cpd_full")
    print len(whole)
    

if __name__ == "__main__":
    pass
예제 #8
0
            "w") as writer:
        writer.write("\n".join(gc.codon_list_hypothesis))


if __name__ == "__main__":
    parent_path = "/home/zerodel/GitProject"
    work_path = "/home/zerodel/Workspace"
    source_path = "/home/zerodel/Workspace/yeast_rnasnp"
    output_path = "/home/zerodel/Workspace/yeast_cpd"
    single_codon_file_path = os.path.join(work_path, "codon_lst")
    cc_significant_file_path = os.path.join(work_path, "codon_all.lst")
    rnasnp_files, snppathname = RNAsnp.snp_dir_list(source_path)

    # #step 1 , set up  .cpd files
    # RNAsnp.snp_dir_traversal(rnasnp_files, snppathname, output_path, True)
    cpd_main = RNAsnp.get_whole_cpd(output_path)
    codon_vector = gc.codon_list_64
    with open(
            "/home/zerodel/GitProjects/python-rna-structure/data/YeastfullRnasnp.matrix",
            "w") as writer:
        available_cc = cpd_main.keys()
        for codon1 in codon_vector:
            # build a line for lst file
            line_single = []
            for codon2 in codon_vector:
                if (codon1, codon2) in available_cc:
                    line_single.append(str(len(cpd_main[(codon1, codon2)])))
                else:
                    line_single.append(str(0))

            writer.write("\t".join(line_single) + "\n")
예제 #9
0
    # sys.path.insert(0, new_path)
    return 1


AddSysPath("..")


import pyRNAsnp.pyRNAsnp as pyr
import pyHYPHY.global_constants as gc

# testing part in emacs
DEBUG_WITH_EMACS = True
if __name__ == "__main__":
    DEBUG_WITH_EMACS = False
if DEBUG_WITH_EMACS:
    print "hello world"
    cpd_path = "/Users/zerodel/WorkSpace/data/cpd_full"
    whole_cpd = pyr.get_whole_cpd(cpd_path)
    length_cc = [(key, len(whole_cpd[key])) for key in whole_cpd.keys() if len(whole_cpd[key])]
    length_cc = sorted(length_cc)
    codon_order = gc.codon_list_hypothesis
    with open("length_cpd.lst", "w") as writek:
        writek.write("\t".join(codon_order) + "\n")
        for c1 in codon_order:
            for c2 in codon_order:
                writek.write(str(len(whole_cpd[(c1, c2)])))
                writek.write("\t")
            wri
if __name__ == "__main__":
    pass
예제 #10
0
                line_single.append(str(len(cpd_main[(codon1, codon2)])))

            writer.write("\t".join(line_single) + "\n")
    with open("/home/zerodel/GitProjects/python-rna-structure/data/codon_vector.txt", "w") as writer:
        writer.write("\n".join(gc.codon_list_hypothesis))

if __name__ == "__main__":
    parent_path = "/home/zerodel/GitProject"
    work_path = "/home/zerodel/Workspace"
    source_path = "/home/zerodel/Workspace/yeast_rnasnp"
    output_path = "/home/zerodel/Workspace/yeast_cpd"
    single_codon_file_path = os.path.join(work_path, "codon_lst")
    cc_significant_file_path = os.path.join(work_path, "codon_all.lst")
    rnasnp_files, snppathname = RNAsnp.snp_dir_list(source_path)

    # #step 1 , set up  .cpd files
    # RNAsnp.snp_dir_traversal(rnasnp_files, snppathname, output_path, True)
    cpd_main = RNAsnp.get_whole_cpd(output_path)
    codon_vector = gc.codon_list_64
    with open("/home/zerodel/GitProjects/python-rna-structure/data/YeastfullRnasnp.matrix", "w") as writer:
        available_cc = cpd_main.keys()
        for codon1 in codon_vector:
            # build a line for lst file
            line_single = []
            for codon2 in codon_vector:
                if (codon1, codon2) in available_cc:
                    line_single.append(str(len(cpd_main[(codon1, codon2)])))
                else:
                    line_single.append(str(0))

            writer.write("\t".join(line_single) + "\n")