Monthly Archives: November 2010

Boto : Super easy Python library to interact with amazon web services

I had first heard of Mitch Granaats boto thanks to “Monster Muck Mashup” where he used boto to build a video transcoding service using amazons compute and storage cloud EC2 and S3. Being a relative python newbie then, I remember reading the code examples and not understanding what they were doing entirely.

After a long period of dormancy I decided to resurrect and cleanup my S3 buckets. Stupid me! , I had turned on logging for the code-itch bucket ever so long ago. Result!,tens of thousands of log entries. Every S3 browser I tried, struggled to display and scroll the massive number of files. I needed a script and quick.

Initially I considered jets3t a java based super-library for all things AWS. But after reading an answer to this question on stackoverflow I decided to try boto again. This time around , I found the syntax very easy to comprehend. Within minutes I had a script that worked. The script read like pseudocode. I will reproduce it here.

I will definitely be delving more into boto to explore amazons many offerings.

Mitch Granaat also writes an excellent blog on all things aws and boto at elastician

Boto library home on googlecode

#!/usr/bin/python
import boto
from boto import *
import re
# Regexp to match the log file names
log_key = re.compile("code-itch\.[\d]{4}\-[\d]{1,2}\-[\d]{1,2}\-[\d]{1,2}\-[\d]{1,2}\-[\d]{1,2}\-[a-fA-F\d]{16}")
f = open("listbuckets_code-itch_deleted.txt" , "w")
if __name__ == '__main__':
    s3 = boto.connect_s3()
    mybucket = s3.get_bucket("code-itch")
    for key in mybucket:
        if log_key.match(key.name):
            f.write(key.name + "\n")
            mybucket.delete_key(key.name)
            print "Deleted",key.name
            f.close()

Python scripting from within Pymol

I have been using pymol for a while , but only recently did I start using python scripts to automate my tasks within pymol.

The extreme power of pymols API allows you to call python scripts from within a Pymol session as I have done in the screencast.
This text will be replaced

Additional Links and information:Scripting in Pymol
The code segment I read into the pymol session is given here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# My list of objects in pymol session
objs = ["3org","1ots","mypdb"]
# List to keep track of pairs that have been rendered
images_done = []
for i in objs:
    for j in objs:
        if i == j :
            continue
        else:
            if (j,i) in images_done or (i,j) in images_done:
                continue
            else:
                cmd.disable("all")
                cmd.enable(i)
                cmd.enable(j)
                cmd.png("%s_%s_superpose3.png" % (i,j),640,480,72,1,1)
                cmd.disable("all")
                images_done.append((i,j))
print "all images rendered"

Crystallization reports at the RCSB or PDB : crystallization conditions for already crystallized protein

Embarking on a quest to crystallize a protein that others have already crystallized?  You need to get a detailed report of all the crystal conditions that have been used in the literature for your protein of interest.
Thanks to the many excellent features of the PDB  (RCSB)  you can use the Generate Reports drop down tab to get  a nice tabular report of all the Experimental, crystallization conditions once you have narrowed down your list of PDB files.
The above short screencast, shows you how.
Static image credit: Tabular help documentation at the RCSB/PDB