Created
March 9, 2016 09:56
-
-
Save hnishi/3b9a3247a4bc356e17c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 -i | |
import sys, os | |
### autocompletion | |
import readline | |
import rlcompleter | |
readline.parse_and_bind('tab: complete') | |
### pymol environment | |
moddir='/opt/pymol-svn/modules' | |
sys.path.insert(0, moddir) | |
os.environ['PYMOL_PATH'] = os.path.join(moddir, 'pymol/pymol_path') | |
### pymol launching | |
# PyMOL captures sys.stdout and sys.stderr, to control it with it's own feedback mechanism. | |
# To prevent that, save and restore both streams, | |
stdout = sys.stdout | |
stderr = sys.stderr | |
import pymol | |
pymol.pymol_argv = ['pymol','-qc'] + sys.argv[1:] | |
pymol.finish_launching() | |
sys.stdout = stdout | |
sys.stderr = stderr | |
cmd = pymol.cmd | |
### read pdb | |
r = cmd.fetch("4m61","obj1") | |
print r | |
#cmd.iterate_state(1, "obj1", "print x,y,z") | |
from pymol import stored #MUST!!! | |
stored.alphaCarbons = [] | |
cmd.iterate_state(1, pymol.selector.process("all"), "stored.alphaCarbons.append([x,y,z])") | |
print stored.alphaCarbons[0] | |
#for i in stored.alphaCarbons: | |
# print "{x:8.3f} {y:>8.3f} {z:>8.3f}".format(x=i[0],y=i[1],z=i[2]) | |
# print "{0:8.3f} {1:>8.3f} {2:>8.3f}".format(i[0],i[1],i[2]) | |
### alter coordinates | |
#print stored.alphaCarbons[123] | |
#f = lambda a:[round(a[0],3),round(a[1],3),round(a[2],3)] | |
f = lambda a:[round(a[0],3) -1000,round(a[1],3) -1000,round(a[2],3) -1000] | |
stored.rCord1 = map(f,stored.alphaCarbons) | |
print stored.rCord1[0] | |
#for i in stored.rCord1: | |
# print "{x:8.3f} {y:>8.3f} {z:>8.3f}".format(x=i[0],y=i[1],z=i[2]) | |
cmd.alter_state(1,"obj1","(x,y,z)=stored.rCord1.pop(0)") | |
cmd.iterate_state(1, "obj1", "print x,y,z") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment