• RE: Coordinates of all the molecules in the unit cell

    Hi Tahereh,

    in the API a component is a connected set of atoms and the bonds connecting them.  These can be copies of the fundamental molecular structure as is the case with PENCEN03 where there are two copies of pentane, or different structures as in the case of ABEBUF.  These may be solvent molecules, coformer molecules, cocrystals or salts. 

    When we pack the unit cell, we can get copies of all these components in a single molecule.  So in PENCEN03 you will get 10 copies of the pentane molecule.  When we pack ABEBUF, we get eight copies of each of the two structures of the crystal.

    I hope this is clear.  If not, I'll try to expand on it, or ask a crystallographer here to make things clearer.

    I really don't mind whether you open another topic or keep it here, but since it naturally follows on from your earlier question, perhaps here is best.

    Best wishes

    Richard

  • RE: Coordinates of all the molecules in the unit cell

    Hi Tahereh,

    as long as the mol2 file contains the crystallographic information, i.e. a CRYSIN line, then we can do this very easily:

    from ccdc import io

    reader = io.CrystalReader('/path/to/crystals.mol2')

    for c in reader:
        unit_cell_molecule = c.packing()
        coordinates = [a.coordinates for a in unit_cell_molecule.atoms]

    The packing method of the crystal will return a molecule, which may be several disconnected structures, which are found in the specified box, which by default is the unit cell.  There is an optional inclusion paramter to this method which controls whether or not to include atoms.  By default this is to include the whole molecule if the centroid is found in the unit cell.  Other options are, 'AllAtomsIncluded', 'AnyAtomIncluded' and 'OnlyAtomsIncluded'.

    Hope this is helpful.

    Best wishes

    RIchard

  • RE: Jupyter notebook for CSD-python-API

     Hi Frank,

    It looks as if you've spelled csd_licence.dat as csd_licencw.dat, so that may be the source of the problem.

    Incidentally, you're a brave man to be running these things as root!

    Best wishes

    Richard

  • RE: WARNING: Matching failed for one 3D molecule

    Hi Vladimir,

    the warning is issued by the underlying C++ code, and is not under the control of the python API.  The only thing I can think of is to record the identifiers of the molecules involved before performing the search, possibly using ccdc.utilities.Logger, then inspecting the output.

    I'm sorry I can't be any more helpful at the moment.

    Best wishes

    Richard

  • RE: Jupyter notebook for CSD-python-API

     HI Frank,

    can you run mercury successfully?  If so, the Help->About mercury should say where it found the licence.  If the licence is in a non-standard place, i.e. not in CSD_2018/CSD_539/csd_licence.dat or /home/.../csd_licence.dat then you may need to set the environment variable CCDC_CSD_LICENCE_FILE to point to its location.

     

    Let me know if this works.

     

    Best wishes

    Richard

  • RE: Jupyter notebook for CSD-python-API

    Hi Frank,

    I think you need to set the environment variable, CSDHOME so the API can find where the CSD is located:

    export CSDHOME=/path/to/CCDC/CSD_2018

    Try this, and see if that works, please.

    Best wishes

    Richard

  • RE: Jupyter notebook for CSD-python-API

    Hi Frank,

    yes, that should be the full path to the miniconda under your CSD installation.  So on my network it was:

    source CCDC_MAC/Python_API_2018/miniconda/bin/activate

    This sets your path to include the miniconda bin directory at the front, so things like python and conda will be those in that directory.  You can call these directly from this bin directory without activating the miniconda, but it's usually easier to activate and make sure that you are using a consistent set of programs.
    You can deactivate, i.e. return to your normal path settings by:

    source deactivate

    Best wishes

    Richard

     

  • 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