Exemplo n.º 1
0
def inspect_file(path):
    """Inspect SDFile structure

    Returns:
        tuple: (data label list, number of records)
    """
    with open(path, 'rb') as f:
        labels, count = inspect(tx.decode(line) for line in f)
    return labels, count
Exemplo n.º 2
0
def mols_from_text(text, no_halt=True, assign_descriptors=True):
    """Returns molecules generated from sdfile text

    Throws:
        StopIteration: if the text does not have molecule
        ValueError: if Unsupported symbol is found
    """
    if isinstance(text, bytes):
        t = tx.decode(text)
    else:
        t = text
    # Lazy line splitter. More efficient memory usage than str.split.
    exp = re.compile(r"[^\n]*\n|.")
    sp = (x.group(0) for x in re.finditer(exp, t))
    for c in mol_supplier(sp, no_halt, assign_descriptors):
        yield c
Exemplo n.º 3
0
def mols_from_file(path, no_halt=True, assign_descriptors=True):
    """Compound supplier from CTAB text file (.mol, .sdf)"""
    with open(path, 'rb') as f:
        fd = (tx.decode(line) for line in f)
        for c in mol_supplier(fd, no_halt, assign_descriptors):
            yield c