"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "examples/cookbook/dali.py" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

dali.py  (pymol-v1.8.6.0.tar.bz2):dali.py  (pymol-v2.1.0.tar.bz2)
dali_file = "dali.txt" dali_file = "dali.txt"
pdb_dir = "dali_pdb" pdb_dir = "dali_pdb"
max_pairs = 10 max_pairs = 10
def fetch_pdb(pdbCode,outFile): def fetch_pdb(pdbCode,outFile):
import urllib try:
import urllib.request as urllib
except ImportError:
import urllib
import gzip import gzip
import os import os
import string
remoteCode = string.upper(pdbCode) remoteCode = pdbCode.upper()
if not os.path.exists(pdb_dir): if not os.path.exists(pdb_dir):
os.mkdir(pdb_dir) os.mkdir(pdb_dir)
if not os.path.exists(outFile): if not os.path.exists(outFile):
try: try:
filename = urllib.urlretrieve( filename = urllib.urlretrieve(
'http://www.rcsb.org/pdb/cgi/export.cgi/' + 'http://www.rcsb.org/pdb/cgi/export.cgi/' +
remoteCode + '.pdb.gz?format=PDB&pdbId=' + remoteCode + '.pdb.gz?format=PDB&pdbId=' +
remoteCode + '&compression=gz')[0] remoteCode + '&compression=gz')[0]
except: except:
print "warning: %s not found.\n"%pdbCode print("warning: %s not found.\n"%pdbCode)
else: else:
if (os.path.getsize(filename) > 0): # If 0, then pdb code was invali d if (os.path.getsize(filename) > 0): # If 0, then pdb code was invali d
try: try:
abort = 0 abort = 0
open(outFile, 'w').write(gzip.open(filename).read()) open(outFile, 'w').write(gzip.open(filename).read())
print "fetched: %s"%(pdbCode) print("fetched: %s"%(pdbCode))
except IOError: except IOError:
abort = 1 abort = 1
if abort: if abort:
os.remove(outFile) os.remove(outFile)
else: else:
print "warning: %s not valid.\n"%pdbCode print("warning: %s not valid.\n"%pdbCode)
os.remove(filename) os.remove(filename)
from pymol import cmd from pymol import cmd
from string import strip strip = lambda s: s.strip()
import os import os
seen = {} seen = {}
input = open(dali_file).readlines() input = open(dali_file).readlines()
input_state = 0 input_state = 0
while 1: while 1:
try: try:
line = input.pop(0) line = input.pop(0)
except IndexError: except IndexError:
break break
skipping to change at line 64 skipping to change at line 67
if line[0:12]==' NR. STRID1': if line[0:12]==' NR. STRID1':
input_state = 1 input_state = 1
elif input_state == 1: elif input_state == 1:
if strip(line)=='': if strip(line)=='':
input_state = 2 input_state = 2
elif line[4:5]==':': elif line[4:5]==':':
trg = strip(line[6:12]) trg = strip(line[6:12])
src = strip(line[13:19]) src = strip(line[13:19])
trg_code = trg[0:4] trg_code = trg[0:4]
src_code = src[0:4] src_code = src[0:4]
if not seen.has_key(trg_code): if trg_code not in seen:
trg_file = pdb_dir+os.sep+trg_code+".pdb" trg_file = pdb_dir+os.sep+trg_code+".pdb"
fetch_pdb(trg_code,trg_file) fetch_pdb(trg_code,trg_file)
cmd.load(trg_file) cmd.load(trg_file)
seen[trg_code]=1 seen[trg_code]=1
if not seen.has_key(src_code): if src_code not in seen:
src_file = pdb_dir+os.sep+src_code+".pdb" src_file = pdb_dir+os.sep+src_code+".pdb"
fetch_pdb(src_code,src_file) fetch_pdb(src_code,src_file)
cmd.load(src_file) cmd.load(src_file)
seen[src_code]=1 seen[src_code]=1
matrix = [] matrix = []
for a in range(0,3): for a in range(0,3):
matrix.append(float(strip(line[29:38]))) matrix.append(float(strip(line[29:38])))
matrix.append(float(strip(line[39:48]))) matrix.append(float(strip(line[39:48])))
matrix.append(float(strip(line[49:58]))) matrix.append(float(strip(line[49:58])))
matrix.append(float(strip(line[59:78]))) matrix.append(float(strip(line[59:78])))
 End of changes. 9 change blocks. 
9 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)