示例#1
0
def use_mordred(mols, descs=None):
    if descs is None:
        calc = Calculator(descriptors, ignore_3D=True)
        df = pd.DataFrame(calc.pandas(mols,quiet=True).fill_missing().dropna(axis='columns'),dtype=np.float64)
        return df
    else:
        calc = Calculator(descriptors, ignore_3D=True)
        calc.descriptors = [d for d in calc.descriptors if str(d) in descs]
        df = pd.DataFrame(calc.pandas(mols,quiet=True).fill_missing().dropna(axis='columns'),dtype=np.float64)
        return df
示例#2
0
def test_Calculator_descriptors():
    calc = Calculator()

    def check(l, msg=None):
        yield eq_, len(calc), l, msg
        yield ok_, all(isinstance(d, Descriptor) for d in calc.descriptors)

    # register instance
    calc.register(Dummy.Dummy2())
    for c in check(1, "instance register failed"):
        yield c

    # register class
    yield raises(ValueError)(lambda: calc.register(Dummy.Dummy1))
    for c in check(1):
        yield c

    calc.register(Dummy.Dummy2)
    for c in check(1):
        yield c

    calc.register(Dummy.Dummy3)
    for c in check(2):
        yield c

    calc.register(Dummy.Dummy4)
    for c in check(4):
        yield c

    # delete
    del calc.descriptors
    for c in check(0):
        yield c

    # register module
    calc.register(Dummy)
    for c in check(3):
        yield c

    eq_(calc["Dummy4_1"], Dummy.Dummy4(1))

    # set instance
    calc.descriptors = Dummy.Dummy2()
    for c in check(1):
        yield c
示例#3
0
def test_Calculator_descriptors():
    calc = Calculator()

    def check(l, msg=None):
        yield eq_, len(calc), l, msg
        yield ok_, all(isinstance(d, Descriptor) for d in calc.descriptors)

    # register instance
    calc.register(Dummy.Dummy2())
    for c in check(1, 'instance register failed'):
        yield c

    # register class
    yield raises(ValueError)(lambda: calc.register(Dummy.Dummy1))
    for c in check(1):
        yield c

    calc.register(Dummy.Dummy2)
    for c in check(1):
        yield c

    calc.register(Dummy.Dummy3)
    for c in check(2):
        yield c

    calc.register(Dummy.Dummy4)
    for c in check(4):
        yield c

    # register module
    calc.register(Dummy)
    for c in check(7):
        yield c

    # delete
    del calc.descriptors
    for c in check(0):
        yield c

    # set instance
    calc.descriptors = Dummy.Dummy2()
    for c in check(1):
        yield c