• RE: Jupyter notebook for CSD-python-API

    Hi Frank,

    I've just done a clean install of the latest CSD system on a Mac, and installed jupyter on it with no problems:

    source /path/to/miniconda/bin/activate
    conda install jupyter
    jupyter-console
    In [1]: from ccdc import io
    In [2]: csd = io.EntryReader('csd')
    In [3]: len(csd)
    Out[3]: 961466

    So I'm really not sure what's happening when you try it.  Is it possibly an instance of this issue?
    https://downloads.ccdc.cam.ac.uk/documentation/API/trouble_shooting.html#un-installing-in-csds-conda-environment

    If not, are there any other details you can give me, like how you installed jupyter, and what error messages you have seen?

    Best wishes

    Richard

  • RE: SMILES code of MOF sub-database

    Hi Frank,

    putting the * before an argument essentially says 'treat the expression after the * as the remaining positional arguments to the function'.  Here I used it as a shorthand for:

    m.add_bond('Aromatic', b[0], b[1])

    Mostly because I'm lazy.

    Here is a good explanation of the basics behind *args, **kwargs:

    https://thepythonguru.com/python-args-and-kwargs/

    Best wishes

    Richard

  • RE: SMILES code of MOF sub-database

    Hi Frank,

    the problem is with the delocalised bonds in these structures, and we do not have any method in the API to replace them.

    You can get a SMILES representation of the molecule by replacing the delocalised bonds with aromatic bonds:

    from ccdc import io, utilities
    csd = io.EntryReader('csd')

    m = csd.molecule('ABACUF')
    m.assign_bond_types()

    deloc = [b.atoms for b in m.bonds if b.bond_type == 'Delocalised']
    m.remove_bonds(b for b in m.bonds if b.bond_type == 'Delocalised')
    for b in deloc:
        m.add_bond('Aromatic', *b)
    print m.smiles

    [O][Ba]12([OH2])([OH2][Cu]3([OH2][Ba]4([O])([OH2])(oco4)O3C=O)(oco[Ba])(oco[Ba])O1C=O)oco2

    I'm not perfectly convinced that the SMILES is legitimate, so I would be very wary of submitting it to other programs.

    Best wishes

    Richard

  • RE: Jupyter notebook for CSD-python-API

    Hi Frank,

    it should be possible to install Jupyter notebook into the CSD's miniconda:

    /path/to/csd/miniconda/bin/conda install jupyter

    then you can run:

    /path/to/csd/miniconda/bin/jupyter-console

    Best wishes

    Richard

     

  • RE: SMILES code of MOF sub-database

    HI Frank,

    can you give me a REFCODE where the SMILES fails?  In general the smiles property of a molecule will return None if there are unknown atoms or unknown bonds in the structure.

    Best wishes

    Richard

  • RE: CSD Python API on Linux

    Good to hear.  Let me know if any other problems crop up.

    Best wishes

    Richard

  • RE: CSD Python API on Linux

    Hi Tahereh,

    on a linux system you will need to set the environment variable CSDHOME to point to where you installed the CSD:

    export CSDHOME=/..../CSD_2018

    which will enable the API to find the CSD and other files in your installation.

    Sorry about the mistake in the second form.  It should read

    source /.../CSD_2018/Python_API_2018/miniconda/bin/activate

    which will set the default python, here called 'base'.  This should appear at the start of your prompt string as (base) followed by the rest of the prompt string.

    Best wishes

    Richard

  • RE: CSD Python API on Linux

    Hi Tahereh,

    you can run the script directly by:

    /.../Python API/miniconda/bin/python2 script.py

    or you can activate the python:

    /.../Python API/miniconda/bin/activate

    then run:

    python script.py

    I hope this is helpful.  If not, please get back to me.

    Best wishes

    Richard

     

  • RE: BFDH Morphology

    Dear Vijay,

    the BFDH morphology has been implemented in the API but is currently restricted to research partners of the CCDC.  Since I can see from your registration that you are at the University of Strathclyde, I am afraid that licensing restrictions mean that you will be unable to perform these calculations at the moment.

    I will discuss with my managers when it will be possible to release this feature to a wider public.

    Best wishes

    Richard

  • RE: about Halogen bond search

    I think you may not be searching for exactly what you want.  You search  successively for HC Br, HC I, NC Br, etc.  The following script is how I would cast your problem:

    from ccdc import io, search
    csd = io.EntryReader('csd')
    crystal = csd.crystal('ISIJEZ01')

    poss_donors = ['C', 'c', 'N', 'O']
    poss_acceptors = ['Br', 'I']
    vdw_radius = {
        'Br' : 1.85,
        'I'  : 1.98,
        'N'  : 1.55,
        'n'  : 1.55,
        'O'  : 1.52,
        'o'  : 1.52,
        'C'  : 1.70,
        'c'  : 1.70,
    }



    all_hits = []
    for d in poss_donors:
        for a in poss_acceptors:
            searcher = search.SubstructureSearch()
            searcher.add_substructure(search.SMARTSSubstructure(d + 'H'))
            searcher.add_substructure(search.SMARTSSubstructure(a))
            searcher.add_distance_constraint('DIST1', (0, 1), (1, 0), (0.0, vdw_radius[a] + vdw_radius[d]), 'intermolecular', vdw_corrected=False)
            searcher.add_angle_constraint('ANG1', (0, 0), (0, 1), (1, 0), (120, 180))
            all_hits.extend(searcher.search(crystal))


    print '\n'.join(str(h.match_atoms()) for h in all_hits)


    [Atom(C1), Atom(H1), Atom(I1)]
    [Atom(C2), Atom(H2), Atom(I1)]
    [Atom(C3), Atom(H3), Atom(I1)]
    [Atom(C4), Atom(H4), Atom(I1A)]

    Note that the distance constraint is between the donated H and the acceptor, and the angle is D-H-A.  This finds four hits as shown above.
    You may prefer to use Van der Waals correction on the distance constraint, which will automatically take care of the element types involved in the match:

    searcher.add_distance_constraint('DIST1', (0, 1), (1, 0), (-5, 0), 'intermolecular', vdw_corrected=True)

    Hope this is helpful, and please continue to ask me anything.

     

    Best wishes

    Richard