예제 #1
0
def init():
    global html_path
    html_path = "../results"

    global compound2smiles
    compound2smiles = util.parse_dat("../metacyc/compounds.dat", "UNIQUE-ID",
                                     "SMILES")

    global atom_types
    atom_types = ['C', 'N', 'O', 'P', 'S']
    #global bond_types; bond_types = range(5)
    global bond_types
    bond_types = range(4)
    global motif_sizes
    motif_sizes = range(2, 7)
    global log_zero
    log_zero = -800.0

    global compound2graph
    compound2graph = {}
    for compound in compound2smiles.keys():
        try:
            compound2graph[compound] = chemconvert.molfile2graph("../mol/" +
                                                                 compound +
                                                                 ".mol")
        except Exception:
            pass

    return
예제 #2
0
def convert_compounds_hash(compound_dat_filename):
    compound2hash = util.parse_dat(compound_dat_filename, "UNIQUE-ID", "HASH")
    util._mkdir("../mol")
    for (key, smiles) in compound2hash.iteritems():
        mol_filename = "../mol/" + key + ".mol"
        if (not os.path.exists(mol_filename)):
            print "Writing a MOL file to: " + mol_filename
            if (len(smiles) > 0):
                mol = chemconvert.hash2graph(smiles[0]).to_mol()
                mol_file = open(mol_filename, "w")
                mol_file.write(mol)
                mol_file.close()
        else:
            print "Found the MOL file: " + mol_filename
    return
예제 #3
0
def convert_compounds_hash(compound_dat_filename):
    compound2hash = util.parse_dat(compound_dat_filename, "UNIQUE-ID", "HASH")
    util._mkdir("../mol")
    for (key, smiles) in compound2hash.iteritems():
        mol_filename = "../mol/" + key + ".mol"
        if (not os.path.exists(mol_filename)):
            print "Writing a MOL file to: " + mol_filename
            if (len(smiles) > 0):
                mol = chemconvert.hash2graph(smiles[0]).to_mol()
                mol_file = open(mol_filename, "w")
                mol_file.write(mol)
                mol_file.close()
        else:
            print "Found the MOL file: " + mol_filename
    return
예제 #4
0
파일: plot.py 프로젝트: yesimon/af-homology
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('identifier', help='Identifier name e.g. cne.100899.FST.')
    parser.add_argument('-f', '--file', nargs='?', type=argparse.FileType('r'), default=sys.stdin,
                        help='Input file e.g. d2z.dat.')
    parser.add_argument('--extra_data', type=argparse.FileType('r'), default='hg18.toDanRer5.seqs.txt',
                        help='Extra data file e.g. hg18.toDanRer5.seqs.txt.')
    parser.add_argument('--valid', type=int, default=9, help='Field number of valid test coordinates.')
    OPTS = parser.parse_args()
    cne_dict = parse_dat(read_fields(f=OPTS.file))
    line_tups = read_fields(f=OPTS.extra_data)
    cne_valids = {}
    for l in line_tups:
        danrer_co, valid_co = parse_coords(l[4]), parse_coords(l[OPTS.valid-1])
        valid_indices = (valid_co['start'] - danrer_co['start'], valid_co['end'] - danrer_co['start'])
        cne_valids[l[0]] = valid_indices
    plot_cne(OPTS.identifier, cne_dict[OPTS.identifier], cne_valids[OPTS.identifier])
예제 #5
0
def main():
  import argparse
  parser = argparse.ArgumentParser()
  parser.add_argument('-f', '--file', nargs='?', type=argparse.FileType('r'), default=sys.stdin,
                      help='Input file e.g. d2z.dat.')
  parser.add_argument('--extra_data', type=argparse.FileType('r'), default='hg18.toDanRer5.seqs.txt',
                    help='Extra data file e.g. hg18.toDanRer5.seqs.txt.')
  parser.add_argument('scoring', choices=['ranked_peaks', 'overlap'])
  OPTS = parser.parse_args()
  line_tups = read_fields(f=OPTS.file)
  cne_dict = parse_dat(line_tups)
  extra = parse_extra_data(read_fields(f=OPTS.extra_data))
  if OPTS.scoring == 'ranked_peaks':
    results = ranked_peaks(cne_dict, extra)
  elif OPTS.scoring == 'overlap':
    results = overlap(cne_dict, extra)
  for cne, result in sorted(results.iteritems()):
    sys.stdout.write('\t'.join([cne, str(result['rank']),
                                str(result['places'])]) + '\n')
예제 #6
0
def init():
    global html_path; html_path = "../results"

    global compound2smiles;
    compound2smiles = util.parse_dat("../metacyc/compounds.dat", "UNIQUE-ID", "SMILES")

    global atom_types; atom_types = ['C', 'N', 'O', 'P', 'S']
    #global bond_types; bond_types = range(5)
    global bond_types; bond_types = range(4)
    global motif_sizes; motif_sizes = range(2, 7)
    global log_zero; log_zero = -800.0

    global compound2graph; compound2graph = {}
    for compound in compound2smiles.keys():
        try:
            compound2graph[compound] = chemconvert.molfile2graph("../mol/" + compound + ".mol")
        except Exception:
            pass
        
    return