Esempio n. 1
0
def load_mcard(filename, gzipped=False):
    if (gzipped):
        file = gzip.GzipFile(filename, 'r')
    else:
        file = open(filename, 'r')

    print >> sys.stderr, "Parsing database file: %s" % filename
    # Parse the Mcard SDF database file:
    while True:
        header = file.readline()
        if (header == ""):
            break

        body = util.readlines_until_mark(file, "$$$$")
        compound = header.split('\t')[-1].rstrip().upper()

        G = ChemGraph()
        G.filename = filename
        try:
            G.read_mol(body)
            map_compound2graph[compound] = G
            map_hash2compound[G.hash()] = compound
            map_hash2compound_unchiral[G.hash_unchiral()] = compound

        except ChemException, errstring:
            print >> sys.stderr, " - Skipping this compound [%s] because of: %s" % (
                compound, errstring)
            pass
Esempio n. 2
0
def load_mcard(filename, gzipped=False):
    if (gzipped):
        file = gzip.GzipFile(filename, 'r')
    else:
        file = open(filename, 'r')
    
    print >> sys.stderr, "Parsing database file: %s" % filename
    # Parse the Mcard SDF database file:
    while True:
        header = file.readline()
        if (header == ""):
            break
        
        body = util.readlines_until_mark(file, "$$$$")
        compound = header.split('\t')[-1].rstrip().upper()

        G = ChemGraph()
        G.filename = filename
        try:
            G.read_mol(body)
            map_compound2graph[compound] = G
            map_hash2compound[G.hash()] = compound
            map_hash2compound_unchiral[G.hash_unchiral()] = compound
            
        except ChemException, errstring:
            print >> sys.stderr, " - Skipping this compound [%s] because of: %s" % (compound, errstring)
            pass
Esempio n. 3
0
def mol2svg(mol, width=200, height=200, font_size=7):
    G = ChemGraph()
    G.read_mol(mol.split("\n"))
    scene = svg.Scene(width, height, font_size)
    G.svg(scene)
    return scene
Esempio n. 4
0
def smiles2graph(smiles):
    mol = smiles2mol(smiles)
    G = ChemGraph()
    G.read_mol(mol.split("\n"))
    return G
Esempio n. 5
0
def mol2svg(mol, width=200, height=200, font_size=7):
    G = ChemGraph()
    G.read_mol(mol.split("\n"))
    scene = svg.Scene(width, height, font_size)
    G.svg(scene)
    return scene
Esempio n. 6
0
def smiles2graph(smiles):
    mol = smiles2mol(smiles)
    G = ChemGraph()
    G.read_mol(mol.split("\n"))
    return G