示例#1
0
def dumpResults(results, dir, prefix):
    """ Print out the results {} in 4 files,
        using this prefix & directory.

    @parm results: {} w/ H1, H2, H12 {} and edge {} H1toH2.
    @param dir: directory to put results, /w '/' at end.
    @param prefix: name of file to stick before ex. '.H1'.
    """

    utils_graph.dumpNodes(dir + prefix + '.H1', results['H1'])
    utils_graph.dumpNodes(dir + prefix + '.H2', results['H2'])
    utils_graph.dumpNodes(dir + prefix + '.H12', results['H12'])
    utils_graph.dumpEdges(dir + prefix + '.H1toH2', results['H1toH2'])
示例#2
0
             else:
                 if check_gtr(elm, elm2freq):
                  f.write(elm + '\tGTR\n')
                 elif check_less(elm, elm2freq):
                     f.write(elm + '\tLESS\n')
                 else:
                     f.write(elm + '\tSAME\n')

# with open('mammal_bird.notTest', 'w') as f:
#     for elm in utils_graph.intersectLists([control_elms,freq_elms]):
#         if not elm in test_elms:
#             if elm in elm2fracs:
#                 if check_gtr(elm, elm2fracs):
#                     f.write(elm + '\tGTR\n')
#                 elif check_less(elm, elm2fracs):
#                     f.write(elm + '\tLESS\n')
#                 else:
#                     f.write(elm + '\tSAME\n')
#             else:
#                 if check_gtr(elm, elm2freq):
#                  f.write(elm + '\tGTR\n')
#                 elif check_less(elm, elm2freq):
#                     f.write(elm + '\tLESS\n')
#                 else:
#                     f.write(elm + '\tSAME\n')

utils_graph.dumpNodes('common_bird', utils_graph.intersectLists([elm2fracs,bird_elms]))
utils_graph.dumpNodes('common_mammal', utils_graph.intersectLists([elm2fracs,mammal_elms]))
        

示例#3
0
ls = [human, swine, horse]
common_mammal, mammal_elms = get_common_elms(ls)
with open('mammalAll' + str(cut), 'w') as f:
    for protein in common_mammal:
        for elm in common_mammal[protein]:
            f.write(protein + '\t' + elm + '\n')
ls = [chicken, duck]
common_bird, bird_elms = get_common_elms(ls)
with open('birdAll' + str(cut), 'w') as f:
    for protein in common_bird:
        for elm in common_bird[protein]:
            f.write(protein + '\t' + elm + '\n')

use_mammal = get_unique_elms(common_mammal, common_bird)
use_bird = get_unique_elms(common_bird, common_mammal)
utils_graph.dumpNodes('mammal' + str(cut), use_mammal)
utils_graph.dumpNodes('bird' + str(cut), use_bird)
utils_graph.dumpNodes('common' + str(cut), common_all_elms)

ls = [human_controled, swine_controled, 
      horse_controled, chicken_controled, duck_controled]
common_all_controled, common_all_elms_controled = get_common_elms(ls)

ls = [human_controled, swine_controled, horse_controled]
common_mammal_controled, mammal_elms_controled = get_common_elms(ls)
with open('mammalAllControled' + str(cut), 'w') as f:
    for protein in common_mammal_controled:
        for elm in common_mammal_controled[protein]:
            f.write(protein + '\t' + elm + '\n')

ls = [chicken_controled, duck_controled]
示例#4
0
protein_ls = {}
new2old = {}
old2new = {}

old_fasta = utils_fasta.loadFASTA(sys.argv[1])
for protein in old_fasta.keys():
    new_seq = clean(old_fasta[protein])
    name = protein
    if name.split('.')[-1] != vp_suffix:
        name = name + '.' + vp_suffix
    utils_fasta.prettyPrint(name, new_seq)
    protein_ls[name] = True
    new2old[name] = {}
    old2new[name] = {}
    new_index = 0
    for old_index in xrange(len(old_fasta[protein])):
        old_residue = old_fasta[protein][old_index]
        if old_residue  == '-' or old_residue == '*':
            pass
        else:
            new2old[name][new_index+1] = old_index+1
            old2new[name][old_index+1] = new_index+1
            new_index += 1
f = open(new2old_file, 'w')
pickle.dump(new2old,f)
f.close()    
f = open(old2new_file, 'w')
pickle.dump(old2new,f)
f.close()    
utils_graph.dumpNodes(protein_ls_output_file, protein_ls)