Page width Text size

OlexSys News & Events

Be informed with important and relevant news about our software and services

Add your own Python scripts to Olex2

Author: OlexSys Ltd/11 September 2013/Categories: Documentation

Olex2 can be scripted using Python. Here are a few pointers which will help you to get started. Firstly, we recommend using a Python IDE when working with scripts. We are developing our Python code using Wing IDE. The place to put your python scripts is in the Olex2 subdirectory /etc/scripts. To register a script with Olex2, you need to add the name of your file to the list in the  file called 'customScripts.py'. We will not update this file when Olex2 updates, so your links will be safe. The only entry in this file is 'import example' - and if you look at the file called example.py, you will see the minimum imports required to work with Olex2: import olex import olx from olexFunctions import OlexFunctions OV = OlexFunctions() ''' To run this example script, type spy.example("Hello") in Olex2 ''' def example(text="No Text Provided"): print "Example Function is now printing your text: %s" %text OV.registerFunction(example) All Python scripts are called by prefexing the command with the string 'spy.' So, When you type 'spy.example' in Olex2, the text above will be printed. If you type 'spy.example(Hello!)' it will print 'Hello!'. Go on, try it! And that's it. You have now full access to ALL functions in Olex2 -- and also everything in the cctbx. Of course, you need to figure out the relevant imports for everything to work. Above, we imported olx. This gives you access to everything Olex2 knows about a structure. For example, to find everything to do with the asymmetric unit, you need to explore olx.xf.au:
  • xf.au.Fractionalise - Fractionalise arguments [1 or 3]
  • xf.au.GetAtomAfix - GetAtomAfix arguments [1]
  • xf.au.GetAtomCount - GetAtomCount arguments [none]
  • xf.au.GetAtomCrd - GetAtomCrd arguments [1]
  • xf.au.GetAtomlabel - GetAtomlabel arguments [2]
  • xf.au.GetAtomName - GetAtomName arguments [1]
  • xf.au.GetAtomOccu - GetAtomOccu arguments [1]
  • xf.au.GetAtomType - GetAtomType arguments [1]
  • xf.au.GetAtomU - GetAtomU arguments [1]
  • xf.au.GetAtomUiso - GetAtomUiso arguments [1]
  • xf.au.GetCell - GetCell arguments [none or 1]
  • xf.au.GetCellSymm - GetCellSymm arguments [none or 1]
  • xf.au.GetCellVolume - GetCellVolume arguments [none]
  • xf.au.GetFormula - GetFormula arguments [none]
  • xf.au.GetPeak - GetPeak arguments [1]
  • xf.au.GetVolume - GetVolume arguments [none]
  • xf.au.GetWeight - GetWeight arguments [none or 1]
  • xf.au.GetZ - GetZ arguments [none]
  • xf.au.GetZprime - GetZprime arguments [none]
  • xf.au.IsAtomDeleted - IsAtomDeleted arguments [1]
  • xf.au.IsPeak - IsPeak arguments [1]
  • xf.au.NewAtom - NewAtom arguments [4]
  • xf.au.NPDCount - NPDCount arguments [none]
  • xf.au.Orthogonalise - Orthogonalise arguments [1 or 3]
  • xf.au.SetAtomCrd - SetAtomCrd arguments [4]
  • xf.au.SetAtomlabel - SetAtomlabel arguments [2]
  • xf.au.SetAtomOccu - SetAtomOccu arguments [2]
  • xf.au.SetAtomU - SetAtomU arguments [2 or 7]
  • xf.au.SetZ - SetZ arguments [1]
  • xf.au.SetZprime - SetZprime arguments [1]
In order to explore the cctbx, you need to import OlexCctbxAdapter. from cctbx_olex_adapter import OlexCctbxAdapter oca = OlexCctbxAdapter() In your IDE, you can now explore the contents of oca.
Print

Number of views (2757)/Comments (0)

Comments are only visible to subscribers.

Theme picker

Did You Know?

The latest version of ShelXL is fully supported by Olex2. 

Please use the latest versions of ShelXL. If you haven't updated to ShelXL-20XX yet, then please get your copy now by searching for SHELX on the web!

What's New

Olex2 Workshop at the IUCr in Prague 2020

Olex2 Workshop at the IUCr in Prague 2020

This workshop has now been postponed to the IUCr in 2021 There will be an official Olex2 Workshop at the start of this year's IUCr on Saturday, 22nd August in Prague. Registration now...
10 February 2020/Author: OlexSys Ltd/Number of views (1033)/Comments (0)/
Tags:
RSS

Theme picker

How to Find OlexSys

OlexSys Ltd
Chemistry Department

Durham University, DH1 3LE , UK

+44 (0) 191 334 2004
www.olexsys.org
info@olexsys.org