Hello dear coot-cracks,
Sorry for bothering you again :
I could generate the .coot.py file by copying the coot.py file from
share/coot/python/ into my home folder and adding the mentioned code:
------------
def key_binding_func_1():
from types import ListType
active_atom = active_residue()
if (not active_atom):
add_status_bar_text("No active residue")
else:
imol = active_atom[0]
chain_id = active_atom[1]
res_no = active_atom[2]
ins_code = active_atom[3]
atom_name = active_atom[4]
alt_conf = active_atom[5]
centred_residue = active_atom[1:4]
other_residues = residues_near_residue(imol, centred_residue, 5)
all_residues = [centred_residue]
if (type(other_residues) is ListType):
all_residues += other_residues
print "imol: %s residues: %s" %(imol, all_residues)
refine_residues(imol, all_residues)
add_key_binding("Refine residues in a sphere", "R", lambda:
key_binding_func_1())
-----------------------------------------------------------------
However, there is this error message on starting up coot:
Loading ~/.coot.py...
Running python script /home/szueger/.coot.py
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/szueger/.coot.py", line 25, in <module>
_coot = swig_import_helper()
File "/home/szueger/.coot.py", line 15, in swig_import_helper
fp, pathname, description = imp.find_module('_coot',
[dirname(__file__)])
NameError: global name '__file__' is not defined
But this has nothing to do with the code snippet I copied at the end of
.coot.py (right?) and I did not change anything else... ?? (I copied the
coot.py file from share/coot/python/). Also the key binding is not displayed
under extensions/settings/key_bindings.
This error message appears either under shared or under home environment.
But not if I remove .coot.py.
Do I have to change something else in .coot.py?
Thanks a lot again!
Sara
PS: these are the first 25 lines from the .coot.py:
-------------------------------
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_coot',
[dirname(__file__)])
except ImportError:
import _coot
return _coot
if fp is not None:
try:
_mod = imp.load_module('_coot', fp, pathname, description)
finally:
fp.close()
return _mod
_coot = swig_import_helper()
del swig_import_helper
else:
import _coot
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
------------------------------------------------
On Mon, 11 Jan 2010 09:43:19 -0800
Nathaniel Echols <[log in to unmask]> wrote:
> 2010/1/11 Sara Züger <[log in to unmask]>
>
>> Thanks Miguel,
>>
>> but is there another way to do this sphere refinement? I'm working on a
>> shared computer and have no administrator rights and also no experience
>> with
>> python/file handling of coot.
>>
>> Or else, if there is no other way, can somebody explain me exactly what I
>> have to do/type (like copying a coot.py file into a local folder and
>>change
>> that, but how then to tell coot to use this file?)
>>
>
> Coot will automatically use ~/.coot.py if present - all you need to do is
> copy-and-paste Miguel's code snippet. You don't need administrator
>rights,
> since you're only modifying your home directory.
>
> -Nat
|