How to use the xenonpy.descriptor.ECFP function in xenonpy

To help you get started, we’ve selected a few xenonpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yoshida-lab / XenonPy / tests / inverse / test_iqspr.py View on Github external
def test_iqspr_1(data):
    np.random.seed(0)
    ecfp = ECFP(n_jobs=1, input_type='smiles')
    bre = GaussianLogLikelihood(descriptor=ecfp)
    ngram = NGram()
    iqspr = IQSPR(estimator=bre, modifier=ngram)
    X, y = data['pg']
    bre.fit(X, y)
    ngram.fit(data['pg'][0][0:20], train_order=10)
    beta = np.linspace(0.05, 1, 10)
    for s, ll, p, f in iqspr(data['pg'][0][:5], beta, yield_lpf=True, bandgap=(0.1, 0.2), density=(0.9, 1.2)):
        assert np.abs(np.sum(p) - 1.0) < 1e-5
        assert np.sum(f) == 5, print(f)
github yoshida-lab / XenonPy / tests / descriptor / test_fingerprint.py View on Github external
def test_ecfp_4(data):
    fps = ECFP(n_jobs=1, input_type='any')
    with pytest.raises(ValueError):
        fps.transform(data['err_smis'])

    fps = ECFP(n_jobs=1, input_type='any', on_errors='nan')
    ret = fps.transform(data['err_smis'])
    assert pd.DataFrame(data=ret).shape == (4, 2048)
    assert np.isnan(ret[1][10])
    assert np.isnan(ret[2][20])
github yoshida-lab / XenonPy / tests / descriptor / test_fingerprint.py View on Github external
def test_ecfp_2(data):
    fps = ECFP(n_jobs=1, input_type='smiles')
    with pytest.raises(TypeError):
        fps.transform(data['mols'])

    fps.transform(data['smis'])
github yoshida-lab / XenonPy / tests / inverse / test_iqspr.py View on Github external
def data():
    # ignore numpy warning
    import warnings
    print('ignore NumPy RuntimeWarning\n')
    warnings.filterwarnings("ignore", message="numpy.dtype size changed")
    warnings.filterwarnings("ignore", message="numpy.ndarray size changed")

    pwd = Path(__file__).parent
    pg_data = pd.read_csv(str(pwd / 'polymer_test_data.csv'))

    X = pg_data['smiles']
    y = pg_data.drop(['smiles', 'Unnamed: 0'], axis=1)
    ecfp = ECFP(n_jobs=1, input_type='smiles')
    bre = GaussianLogLikelihood(descriptor=ecfp)
    ngram = NGram()
    iqspr = IQSPR(estimator=bre, modifier=ngram)
    # prepare test data
    yield dict(ecfp=ecfp, bre=bre, ngram=ngram, iqspr=iqspr, pg=(X, y))

    print('test over')
github yoshida-lab / XenonPy / tests / descriptor / test_fingerprint.py View on Github external
def test_ecfp_3(data):
    fps = ECFP(n_jobs=1, input_type='any')
    fps.transform(data['mols'] + data['smis'])
github yoshida-lab / XenonPy / tests / descriptor / test_fingerprint.py View on Github external
def test_ecfp_1(data):
    fps = ECFP(n_jobs=1)
    fps.transform(data['mols'])

    with pytest.raises(TypeError):
        fps.transform(data['smis'])
github yoshida-lab / XenonPy / tests / descriptor / test_fingerprint.py View on Github external
def test_ecfp_4(data):
    fps = ECFP(n_jobs=1, input_type='any')
    with pytest.raises(ValueError):
        fps.transform(data['err_smis'])

    fps = ECFP(n_jobs=1, input_type='any', on_errors='nan')
    ret = fps.transform(data['err_smis'])
    assert pd.DataFrame(data=ret).shape == (4, 2048)
    assert np.isnan(ret[1][10])
    assert np.isnan(ret[2][20])
github yoshida-lab / XenonPy / xenonpy / iqspr / base.py View on Github external
def __init__(self, n_jobs=-1, *, elements=None, include=None,
                 exclude=None):
        super().__init__()
        self.n_jobs = n_jobs

        self.rdkit_fp = FPsCalc(n_jobs)
        # self.rdkit_fp = MACCS_MOLS(n_jobs)