![]() |
| ||||||||||||||||||
![]() |
| ||||||||||||||||||
|
For Yanaconda plugins this is trivial, as they are just macros. For Python plugins,
the YASARA functions are wrapped so that they can be accessed with a syntax that matches Python's requirements.
Examples: Font Arial,Height=2,Spacing=1.5,Color=Yellow,Depth=5,DepthCol=Redbecomes
yasara.Font("Arial",height=2,spacing=1.5,color="Yellow",depth=5,depthcol="Red")
The documentation page of each YASARA command lists the prototype of the corresponding Python function,
e.g. the Font command (look at the 'Python:' row in the table at the top of each page).
A few YASARA commands support more than one format with different argument types. This is not possible in Python,
the command thus has to be wrapped by different Python functions. The names of these Python functions differ at the end,
using either an increasing number or the name of the first argument. More details
are available here. Many YASARA commands return results, which can at the moment not be passed to Python plugins
(however they can be passed to Python scripts that use the YASARA module
). Making this possible also for plugins is a top priority, in the mean time you have to use a Yanaconda-based workaround. Instead of passing the results to Python variables,
you use yasara.run to store them in Yanaconda variables: So instead of the obvious way:
# Load a PDB file and color it red, THIS DOES NOT WORK, JUST FOR FUTURE REFERENCE
obj=yasara.LoadYOb("1crn")
yasara.ColorObj("%d,Red"%obj)
you have to use:
# Load a PDB file and color it red
yasara.run("obj = LoadPDB 1crn")
yasara.ColorObj("(obj),Red")
If the YASARA command returns a list of results, and you need to loop over this list,
the currently only solution is to run the entire loop in Yanaconda, using the no-operation command
'pass' to move the indentation level back and indicate the end of the loop:
# Get a list of all residue numbers
yasara.run("reslist() = ListRes all")
# Print it in the YASARA console
yasara.run("for i=1 to count reslist")
yasara.run(" print 'Residue number (i) is (reslist(i))'")
yasara.run("pass")
As mentioned above, these workarounds are no longer needed in the YASARA Python module
.
| ||||||||||||||||||