示例#1
0
def load_atoms(cid=None, smiles=None) -> Atoms:
    inputs = [cid, smiles]
    input_check = [a is not None for a in inputs]
    if input_check.count(True) == 1:
        index = input_check.index(True)
        if index == 0:
            compounds = pubchem_conformer_search(cid=cid)
        else:
            compounds = pubchem_conformer_search(smiles=smiles)
    else:
        return Atoms()
    return compounds[0].atoms
示例#2
0
def test_pubchem():
    from ase.data.pubchem import pubchem_search, pubchem_conformer_search
    from ase.data.pubchem import pubchem_atoms_search
    from ase.data.pubchem import pubchem_atoms_conformer_search

    # check class functionality
    data = pubchem_search('ammonia', mock_test=True)
    data.get_atoms()
    data.get_pubchem_data()
    # XXX maybe verify some of this data?

    # check the various entry styles and the functions that return atoms
    pubchem_search(cid=241, mock_test=True).get_atoms()
    pubchem_atoms_search(smiles='CCOH', mock_test=True)
    pubchem_atoms_conformer_search('octane', mock_test=True)
    # (maybe test something about some of the returned atoms)

    # check conformer searching
    confs = pubchem_conformer_search('octane', mock_test=True)
    for conf in confs:
        pass
    try:  # check that you can't pass in two args
        pubchem_search(name='octane', cid=222, mock_test=True)
        raise Exception('Test Failed')
    except ValueError:
        pass

    try:  # check that you must pass at least one arg
        pubchem_search(mock_test=True)
        raise Exception('Test Failed')
    except ValueError:
        pass
示例#3
0
def main():
    try:
        compounds = pubchem_conformer_search(cid=31525001)
        for conformer in compounds:
            # print(conformer.data)
            atoms = conformer.atoms
            print(atoms.symbols)
            print(atoms.positions)
            print(atoms.numbers)
            points = []
            for step, number in enumerate(atoms.numbers):
                point = {number: atoms.positions[step]}
                points.append(point)
            print(points)
    except ValueError:
        print('The compound is not found in PubChem!')
def main():
    try:
        compounds = pubchem_conformer_search(smiles='C=CC=C=CNO')
        for conformer in compounds:
            # print(conformer.data)
            atoms = conformer.atoms
            # print(points.symbols)
            # print(points.positions)
            # print(points.numbers)
            points = []
            for step, number in enumerate(atoms.numbers):
                point = list(atoms.positions[step]).copy()
                point.append(colors[number])
                points.append(point)
            # 平滑操作
            # smoothing(point)
            # print(points)
            draw(points)
    except ValueError as e:
        print(str(e))
        print('The compound is not found in PubChem!')
示例#5
0
from ase.data.pubchem import pubchem_search, pubchem_conformer_search
from ase.data.pubchem import pubchem_atoms_search
from ase.data.pubchem import pubchem_atoms_conformer_search

# check class functionality
data = pubchem_search('ammonia', mock_test=True)
atoms = data.get_atoms()
entry_data = data.get_pubchem_data()

# check the various entry styles and the functions that return atoms
atoms = pubchem_search(cid=241, mock_test=True).get_atoms()
atoms = pubchem_atoms_search(smiles='CCOH', mock_test=True)
atoms = pubchem_atoms_conformer_search('octane', mock_test=True)

# check conformer searching
confs = pubchem_conformer_search('octane', mock_test=True)
for conf in confs:
    pass
try:  # check that you can't pass in two args
    atoms = pubchem_search(name='octane', cid=222, mock_test=True)
    raise Exception('Test Failed')
except ValueError:
    pass

try:  # check that you must pass at least one arg
    atoms = pubchem_search(mock_test=True)
    raise Exception('Test Failed')
except ValueError:
    pass