• RE: Python3 Version of the Python API

    We do not currently support Python3 but intend to do so during 2019.

    Best wishes

    Richard

  • RE: Change spacegroup to subgroup

    Could you post it here as well, please Jonas.  It seems the sort of script that other people would be interested in.

    Thanks

    Richard

  • RE: Change spacegroup to subgroup

    Sorry, Aurora, it's not available yet.  I'll make a note that you would like it and see if I can get it into a release sometime.

    Best wishes

    Richard

  • RE: Writing crystals

    Hi Puck,

    always happy to help.  Let me know if there are any other problems.

    Best wishes
    Richard

  • RE: Writing crystals

    Hi Puck,

    it sounds as if you are trying to write the refcodes directly to the CrystalWriter instance, but this needs a crystal structure.  If you have the refcodes in a list you can create the crystals from the CSD as follows:

    csd = io.EntryReader('csd')
    for refcode in list_of_refcodes:
        with io.CrystalWriter('/path/to/pdb/directort/%s,pdb' % refcode) as writer:
            writer.write(csd.crystal(refcode))

    Alternatively, if you have the refcodes in a file, they can be read through a CrystalReader instance:

    with io.CrystalReader('/path/to/refcode/file', format='identifiers') as reader:
        for crystal in reader:
            with io.CrystalWriter('/path/to/pdb/directory/%s.pdb' % crystal.identifier) as writer:
                writer.write(crystal)

    Hope this is helpful.  Please let me know if I've misunderstood your problem.

    Best wishes
    Richard

  • RE: Compare Molecule Similarity Pseudocode

    Hi Hope,

    Can you tell me which methods you have used and for which you would like documentation and pseudocode?  Is it the similarity searching that Alex used, where the reference given above should be sufficient?

    Best wishes

    Richard

  • RE: Downloading a long list of structures

    Dear Anthony,

    I'm very sorry about the long delay in getting back to you.

    It sounds as if you need to do a substructure search on the CSD which for 22,000 structures is going to take some time.

    This script will do something like what you want.  It will process your target file, search the CSD for structures containing your target molecule and will write the hits to a results file.  The hits will contain matches where your target molecule is a proper substructure of the matched structure; if you need exact matches, then please let me know.

    --


    import time

    from ccdc import io, search, utilities

    target_file = '/path/to/your/file/of/structures.mol2'
    hit_file = '/path/to/where/you/want/to/put/results.gcd'

    def one_search(m):
        searcher = search.SubstructureSearch()
        searcher.add_substructure(search.MoleculeSubstructure(m))
        hits = searcher.search()
        print 'CSD contained %d hits for %s' % (len(hits), m.identifier)
        return [h.identifier for h in hits]

    reader = io.MoleculeReader(target_file)
    start = time.time()
    with open(hit_file, 'w') as gcd_writer:
        for i, m in enumerate(reader):
            gcd_writer.write('\n'.join(one_search(m)))
            utilities.Timer.progress(start, i+1, len(reader), '')
    --

    As I say, 20,000 structures is a lot of searching.  It may be advisable to split the input file into smaller chunks and process them separately.

    Once again, I am terribly sorry about the delay in answering.

    If you need any more help, please get back in touch.

    Best wishes

    Richard

  • RE: Compare Molecule Similarity Pseudocode

    Hi Alex,

    similarity searching of the CSD follows the implementation described in:

    http://scripts.iucr.org/cgi-bin/paper?S0021889810000452

    that is to say by comparing fingerprints of the probe molecule and of a structures from the CSD.

    I hope this is enough for your project; if not, please get back to me and I will happily provide more information.

    Best wishes

    Richard

     

     

     

  • RE: Searching the database based on structure void space

    Hi Martin,

    if you want to run scripts which take longer than three minutes, you can invoke python directly from a shell prompt:

    C:\Program Files (x86)\CCDC\Python_AP I_2018\miniconda\Scripts\activate

    python name_of_your_script.py

    This will not need the mercury interface.

    Best wishes

    Richard

     

  • RE: Searching the database based on structure void space

    Hi Martin,

    There is no direct method in the API to search on spacegroup, so one has to fall back on enumeration of the database.  I believe the following will do what you want:


    import time

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

    start = time.time()
    hits = []

    for i, e in enumerate(csd):
        if i and i % 1000 == 0:
            utilities.Timer.progress(start, i, len(csd), '%d hits' % len(hits))
        if not e.has_3d_structure:
            continue
        c = e.crystal
        if not c.spacegroup_symbol.startswith('R'):
            continue
        hits.append((c.void_volume(), e.identifier))

    hits.sort()

    This works by rejecting structures with no 3d information (they won't support a void volume calculation) and rejecting structures which do not have a rhombohdral space group.  If you like you can change this line to test different space groups.

    At the end you will have a list of void_volume, refcode pairs which you can write in any format you care.

    Hope this is helpful,

    Best wishes
    RIchard