Donnerstag, 31. März 2011

Python 002: Version Introspection

When working with Python 2.x and Python 3.x at the same time, its quite probably that the version of the currently running version of Python becomes a question of interest.
One can obtain the version of the running Python instance by issueing
from sys import version_info
if version_info < (3,0):
print version_info
else:
print(version_info)

Vim 001: Editing Code

Consistent formatting of code is essential for efficient developement.
A part of the formatting also comes from introducing syntactic elements such as stars to group the code by content. In Vi this can be done in a simple way.

ESQ -> N -> a -> * -> ESQ -> RETURN

where N is the number of stars to be added, e.g. 40, or 78 to indicate the maximum width the code should take up.

Python 001: Module introspection

Python has great self introspection capabilities.
Sometimes flow of control runs through different modules. If I want to know which module is currently in the scope, here is how I can do this:


#!/usr/bin/env python3

import os.path
def getModuleName():
print("Current module:".ljust(30), os.path.abspath(__file__))

getModuleName()


Adding the above to the module should make it possible to get the location and name of the module in scope at runtime.

Mittwoch, 30. März 2011

PyMOL 003: Synchronizing Atoms in PyMOL

  1. Show both structures as lines
  2. Show the rank of the atoms.
  3. Follow the backbone ranks of both files until they loose synchronization.
  4. Adjust one to the other, from now on always adjust this one to the other. Only one of the files is changed.
The way to do it is: atom with rank b in structure B corresponds to atom with rank a in structure A. Move the line corresponding to b to the line corresponding to a.

PyMOL 002: Description of the Program

When starting the work with PyMOL, it might seem odd that there is no such thing like an 'undo' button. But I believe this only seems odd because the user has expectations towards the program which it never intended to meet in the first place. Its not a program to use as one would use Word or any other Editor. In fact, I believe its intended to be used in the way one uses a black board. One quickly fills it up with notes, and then erases it to start over again with the next part of what one wants to write down, like in a lecture. One does not want to keep the black board in the way one wrote on it. If something is required to be recalled (e.g. because one wants to be able to present something at a meeting without having to search for all kinds of files) one can prepare a PyMOL session file.
Also, PyMOL is not a modeling program (even though its modeling capabilities are already quite impressive). Instead, its a viewer and an analysing tool which is extensible. And this is the most important part about it I believe. It is extremely friendly to the user who wants to extend it by his or her own functionality. All that is required is some knowledge about Python. The PyMOL API is quite introspective, so every function documents itself and this is really makes the extension work convenient.

GAMESS 001: Files

A short introduction into the files obtained from running GAMESS calculations.
Which file containes what, where to find coordinates from optimization jobs and how to efficiently transfer them to new input files.
There is a tool called DATAGAM which can fetch various $GROUP content from GAMESS files. It's not exactly clear to me how it works, but by issuing the following command, at least I was able to transfer the equilibrium geometry to a new file.


mzh @ ~/software/DATAGAM $ datagam -G 4-2-a-1-1-rm1--rm1.log
This is optimize run
Equilibrium geometry (with unique and all coordinates) will be saved to file OPTMZ

GAMESS 001: Files

A short introduction into the files obtained from running GAMESS calculations.
Which file containes what, where to find coordinates from optimization jobs and how to efficiently transfer them to new input files.