Off topic:Automate Dimplot
2
0
Entering edit mode
10.3 years ago
Samihk ▴ 20

Hi, I am trying to automate running Dimplot on a list of 500 PDB ids, any suggestions? I am trying to do this using Python.

This is the code I tried 2 run..... I am using dimplot for dimer interfacing. I am using a list of pdbs and chains.....(as a dictionary)

!/usr/bin/python
read the list of PDB chains and run dimplot
Before runing dimplot an output directory for each PDB file is created
After running dimplot the output files not reqiried are removed
import re import math import os

filename1 = "/usr/local/share/ligplot/dimplot.scr /data/bio/db/pdb/pdb" pdblist = "/XXXXX/new_pdb1.txt" diroutput = "/XXXXXXXX/dimout/"; filenames = "/Desktop/fll" # list of output files 2 be deleted pdbs = {}

def read_pdb_list(pdblist, pdbs):
#read the list of PDBs and input PDB_ID and chains into dictionary
 fh = open(pdblist, 'r') 
all_line=fh.read() fh.close()

lines=all_line.split("\n")
for line in lines:
    if 'ent' in line:
        columns =line.split()
        chains= columns[1:3]
       # print chains
        chains.sort()

        pdbs.setdefault(columns[0],{})
        pdbs[columns[0]].setdefault(chains[0],{})
        pdbs[columns[0]][chains[0]].setdefault(chains[1],line)
read_pdb_list(pdblist,pdbs)

for p in pdbs.keys(): print p

a = os.getcwd()
if p[0:5] in a:
    print a
    work_dir= a
    os.chdir(work_dir)
    for c1 in pdbs[p].keys():
        for c2 in pdbs[p][c1].keys():
            print p,c1,c2

            run = filename1 + pdbs[p][c1][c2]
            print run
            os.system(run)

            os.rename("dimplot.hhb", pdbs[p][c1][c2]+".hhb")
            os.rename("dimplot.nnb", pdbs[p][c1][c2] +".nnb")
            os.rename("ligplot.sum" , pdbs[p][c1][c2]+".sum")
            os.remove("dimplot.pdb")

            fh = open(filenames, 'r')
            all_line=fh.read()
            fh.close()

            lines=all_line.split("\n")
            for line in lines:

                line = line.rstrip('\r\n')
                 #print line
                 os.chdir(work_dir)

                 try:
                     os.remove(line)
                 except OSError, detail:
                     print "%s %s" % (detail[1],line)
python • 2.2k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2789 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6