Endonuclease PvuII (1PVI) DNA - GATTACAGATTACA
CAP - Catabolite gene Activating Protein (1BER)
DNA - GATTACAGATTACAGATTACA Endonuclease PvuII bound to palindromic DNA recognition site CAGCTG (1PVI) DNA - GATTACAGATTACAGATTACA TBP - TATA box Binding Protein (1C9B)
CAP - Catabolite gene Activating Protein (1BER)
GCN4 - leucine zipper transcription factor bound to palindromic DNA recognition site ATGAC(G)TCAT (1YSA)
GCN4 - leucine zipper transcription factor bound to palindromic DNA recognition site ATGAC(G)TCAT (1YSA)
GCN4 - leucine zipper transcription factor bound to palindromic DNA recognition site ATGAC(G)TCAT (1YSA)
GCN4 - leucine zipper transcription factor bound to palindromic DNA recognition site ATGAC(G)TCAT (1YSA)
GCN4 - leucine zipper transcription factor bound to palindromic DNA recognition site ATGAC(G)TCAT (1YSA)
TBP - TATA box Binding Protein (1C9B)
 

° 

Debugging is done by adding temporary print commands

Programs contain errors, the same is true for plugins. There are two types of errors in Python plugins:

  • Errors that occur during the initial plugin registration when YASARA starts up. Most of the time these are simple syntax errors. In Linux and MacOSX, you see the error message in the console from where you started YASARA. Windows can unfortunately not display the error message, but you know that something went wrong because your plugin does not appear in YASARA's user interface. Open a command prompt, go to the yasara\plg directory and run the plugin directly with the Python interpreter to locate the problem:


c:\MyPythonInstallationPath\python.exe MyPlugin.py

This will show you a traceback. After correcting the error you have to restart YASARA.

  • Errors that occur while the plugin is running. YASARA displays the main error message on screen, and a complete traceback in the console which you can bring up by pressing <SPACE>. After correcting the error, you can simply rerun the plugin, you DO NOT have to restart YASARA.

If you want to print debug statements to trace a problem, this is easily done using
print "MyMessage"
in Yanaconda and
yasara.write(WhatEver)
in Python plugins. 'WhatEver' does not have to be a string, but just anything you can pass to Python's print function. DO NOT use Python's print function directly, because this fails under Windows unless you also flush the output buffer with sys.stdout.flush()

If your Python plugin hangs in an infinite loop, click on Options > Stop plugin. This will terminate your plugin as soon as it tries to print something or calls a YASARA command. If the plugin does not do any of these things, YASARA will also hang until you kill the Python task manually from the Windows Task Manager, with the Linux 'kill' command or with the MacOSX 'Activity Monitor' (can be found in the Applications/Utilities folder).

If you add an extra user interface to your plugin using the Tkinter framework , you may encounter the problem that fatal errors occurring in your plugin are not reported by YASARA immediately. The reason is that Tkinter does not terminate after an error, and also does not flush the output buffer properly, so that error messages get stuck and reach YASARA only when your plugin truly exits. The solution is to force Tkinter to exit when an error occurs:

  • Open the file Tkinter.py, which can usually be found at /usr/lib/python2.4/lib-tk/Tkinter.py, and append the command 'raise SystemExit' at the end of the __call__ method in class CallWrapper, so that it looks like that:


class CallWrapper:
  def __init__(self, func, subst, widget):
     self.func = func
     self.subst = subst
     self.widget = widget
  def __call__(self, *args):
     try:
         if self.subst:
             args = self.subst(*args)
         return self.func(*args)
     except SystemExit, msg:
         raise SystemExit, msg
     except:
         self.widget._report_exception()
         raise SystemExit  <<<< Newly added!