Hi Eric,
I managed to figure out something by
pirating some python codes I found from chimera mailing list through googling.
I want to use the code to save my reply log, which is going to be about 3.4
million lines (by the way, is there a maximum buffer for the number of lines
reply log can take? I feared overrunning the buffer and losing my some part of
the replylog)
Below is the code; I commented away the
part I do not use from the original code.
I tried the code by opening it using the
chimera gui, and it worked just fine, producing the log file I want. But when I
tried opening the same code using command line the log file was produced, but empty.
I tried :
E:\Chimera\bin>chimera --nogui
save_replylog.py <- - doesnot show anything, no popup
command window, nothing.
E:\Chimera\bin>chimera --nogui --debug
save_replylog.py <- - shows a new pop up window
Both commands created my log file, but
were both empty files.
I would want to run the script later in
nogui mode, but I need to retrieve the log for rmsd values, therefore I need to
overcome this problem. Any advise..?
Thanks!
Cheers,
Sumitro
********************************************************************************************************************
from chimera
import runCommand
from
chimera.tkgui import saveReplyLog
#def rms2ref(ref,
pose, no):
#
runCommand('open %s; open %s' % (ref, pose))
#
i = 1
#
while i <= no:
#
# only hetatms are included --> ~@/element=h
#
runCommand('sel #1.%i & ~@/element=h' % i)
#
runCommand('rmsd #0 sel')
#
i += 1
#
#rms2ref('lig_cryst.pdb',
'poses.sdf', 10)
runCommand('open
noprefs E:\\D.combine\\receptor_models\\A-0101_1W72_A.pdb')
runCommand('open
noprefs E:\\A.Model_receptor\\PDB_MODELS\\1DUZ.pdb')
runCommand('open
noprefs E:\\D.combine\\chain_models\\A-0101_ITLVYKVYY_2CIK.pdb')
runCommand('rmsd
#0:@ca #1:2-182.A@ca')
runCommand('match
#0:@ca,n,c,o #1:2-182.A@ca,n,c,o')
runCommand('match
#2:1-3.C,7-9.C@ca #1:1-3.C,7-9.C@ca ')
runCommand('match
#2:1-3.C,7-9.C@ca,n,c,o #1:1-3.C,7-9.C@ca,n,c,o ')
runCommand('combine
#0|#2:1-9.C name A-0101_ITLVYKVYY_2CIK.C.(1DUZ.C).A-0101_1W72_A modelId 5')
runCommand('write
format pdb 5 E:\\D.combine\\complex\\A-0101_ITLVYKVYY_2CIK.C.(1DUZ.C).A-0101_1W72_A.pdb')
runCommand('close
all')
# generate output
from replyLog.txt
saveReplyLog('e:\\D.combine\\mylog.txt')
#rmsds = []
#for i in
open('mylog2.txt').readlines():
#
if i.startswith('RMSD between'):
#
rmsds.append(i.split()[-2])
#
#print rmsds
*********************************************************************************
From:
Eric Pettersen [mailto:pett@cgl.ucsf.edu]
Sent: 12 March 2010 6:24 AM
To: Sumitro Harjanto
Cc: chimera-users@cgl.ucsf.edu
Subject: Re: [Chimera-users]
Scripting to write / save multiple models into single pdf file
Hi Sumitro,
Don't
include "open" on the Unix command line. You only need that
when typing into Chimera's own command line.
--Eric
On Mar 10, 2010, at 10:28 AM, Sumitro Harjanto wrote:
That was a bull’s eye, indeed, after
turning off the autostart for Model panel, the simple command of
“>chimera --nogui” does not make anymore complain.
So I advanced a little and try to run a
.cmd file using the command prompt:
>chimera --nogui open
e:\A.Model_receptor\model_env\calc_receptor_rmsds.cmd
But again I got the same error message:
***********************************************************************
Chimera failed abnormally; the exit code
was: 1
Use –debug command line option for
the full error message.
Below is what I see after adding
"--debug" to the command:
***********************************************************************
Cannot execute 'gzip': no automatic
decompression of .Z files
Traceback (most recent call last):
File
"E:\Chimera\share\chimeraInit.py", line 425, in init
Chimera.openModels.open<a,
prefixableType=1>
File
"E:\Chimera\share\chimera\__init__.py", line 1405, in open
Raise ValueError,
"Unknown model type"
ValueError: Unknown model type
Error while processing open:
File
"E:\Chimera\share\chimera\__init__.py", line 1405, in open
Raise ValueError,
"Unknown model type"
See reply log for Phyton traceback.
Opening 2HN7.pdb…
1 model opened
Opened … … … (and
actually continues to complete my script)
***********************************************************************
Later on I tried to open a pdb instead
(>chimera --nogui open e:\A.Model_receptor\PDB_MODELS\3B3I.pdb) and the same
thing happened, even the debug window shows the same message about unknown
model type.
Any way to go around this..? I don’t
know if it helps, but below is my “preferences” file
*********************************************************************
{'Model
Panel': {'freqButs': {'2D Diagram': False,
'activate': False,
'activate all': True,
'activate only': True,
'add hydrogens...': False,
'add/edit note...': True,
'attributes...': True,
'blast protein...': True,
'clipping...': True,
'close': True,
'color by SS...': False,
'compute SS': True,
'copy/combine...': True,
'deactivate': False,
'focus': True,
'hide': False,
'match...': True,
'minimize...': False,
'rainbow...': True,
'rename...': True,
'render/sel
by attr...': True,
'select': True,
'select chain(s)...': True,
'sequence...': True,
'show': False,
'show
all atoms': True,
'show only': True,
'surface main': True,
'tile...': True,
'toggle active': True,
'trace
backbones': True,
'trace chains': True,
'transform as...': True,
'write PDB': True},
'lastUse': 1268231127.7550001},
'Nucleotides':
{'slab styles': {}},
'Ribbon
Styles': {'atoms': {}, 'scaling': {}, 'xsections': {}},
'Tools':
{'autoStart': {},
'confirmOnStart': {},
'dirList': [],
'inFavorites': {'Command Line': 2,
'Model Panel': 0,
'Reply Log': 4,
'Sequence': 3,
'Side View': 1},
'onToolbar': {}},
'command
line gui': {'remembered commands': ['select #0:2-182.A@C',
'write selected format pdb 0 E:\\A.Model_receptor\\PDB_MODELS\\1W72_c.pdb']},
'initial
size': {'Window size': (525, 513)},
'miller
browser': {'dirHistory': [u'E:\\A.Model_receptor\\Chimera_log_parser',
'C:\\Users\\wiason\\Desktop'],
'fileHistory': {'': [u'E:\\A.Model_receptor\\Chimera_log_parser\\RMSD_raw.txt',
u'E:\\A.Model_receptor\\PDB_MODELS\\peptide_chain\\reply_log',
u'C:\\Users\\wiason\\Desktop\\try_combining2.pdb',
u'C:\\Users\\wiason\\Desktop\\try_combining.pdb'],
'main chimera import dialog': [u'E:\\A.Model_receptor\\model_env\\calc_receptor_rmsds.cmd',
u'E:\\A.Model_receptor\\PDB_MODELS\\peptide_chain\\extract_peptide_from_PDB.cmd',
u'E:\\A.Model_receptor\\PDB_MODELS\\3D39.pdb',
u'E:\\A.Model_receptor\\PDB_MODELS\\3D39.fasta',
u'E:\\A.Model_receptor\\PDB_MODELS\\3DTX.pdb',
u'E:\\A.Model_receptor\\PDB_MODELS\\3B3I.pdb',
u'E:\\A.Model_receptor\\PDB_MODELS\\2JCC.pdb',
u'E:\\A.Model_receptor\\PDB_MODELS\\2J8U.pdb',
u'E:\\A.Model_receptor\\PDB_MODELS\\1LP9.pdb',
u'E:\\A.Model_receptor\\PDB_MODELS\\1B0G.pdb']},
'lastFilter': {'main chimera import dialog': 'all (guess type)'}},
'update
check': {'last time': (2010, 3, 3, 12, 50, 48, 371000, None)},
'version
tracking': {'last version': '1.4_b29093'},
'write
PDB dialog': {'multiSavePDB': 'single'}}
****************************************************************************************************
From: Eric Pettersen [mailto:pett@cgl.ucsf.edu]
Sent: 10 March 2010 3:17 AM
To: Sumitro Harjanto
Cc: chimera-users@cgl.ucsf.edu
Subject: Re: [Chimera-users] Scripting to write
/ save multiple models into single pdf file
Hmm, it seems that you have the Model
Panel set to autostart in your preferences. Now, Chimera probably should
ignore autostarting tools when it is in nogui mode, but currently it doesn't.
So what you will have to do for now (until we fix this) is to start
Chimera normally, turn off the autostart of the Model Panel (and any other
graphical tools probably), save the new preferences, and then run your script.
If you look in the "Preferences"
preference category, it will show the location of the preferences file.
You could squirrel away your original preferences file somewhere, make
the version with no autostarting, copy that somewhere, and then put your
original version back. You would then be able to use the no-autostarting
preferences by specifying it's location with the --preferences startup option.
--Eric
On Mar 8, 2010, at 7:32 PM, Sumitro
Harjanto wrote:
Hi Eric,
Thanks for the suggestion. I don’t
really script, I usually use a c++ code / excel to generate the command (.cmd)
files. Should be okay for the automation for now, if I run into any problem
then I will post it up here again. =]
Mean while I try running the command
“chimera.exe –nogui” in PATH/chimera/bin but got the
following error message. I followed the instruction and copy over the debug
message (below). any advise? I’m on a win7 X86 platform btw.
Thanks,
Sumitro
-----------------------------------------------------------------------------------------------------
Chimera failed abnormally; the exit code
was: 1
Use –debug command line option for
the full error message.
--------------------------------------------------------------------------------------------------
Cannot execute 'gzip': no automatic
decompression of .Z files
Traceback (most recent call last):
File
"E:\Chimera\share\__main__.py", line 65, in <module>
value =
chimeraInit.init(sys.argv)
File
"E:\Chimera\share\chimeraInit.py", line 401, in init
extension.startup(startExtensions)
File
"E:\Chimera\share\chimera\extension\base.py", line 1056, in startup
manager.autostartTools(extNames)
File
"E:\Chimera\share\chimera\extension\base.py", line 959, in
autostartTools
emo.activate()
File
"E:\Chimera\share\ModelPanel\ChimeraExtension.py", line 23, in
activate
display(self.module('base').ModelPanel.name)
File "E:\Chimera\share\chimera\dialogs.py",
line 77, in display
dialog = find(name,
create=1)
File
"E:\Chimera\share\chimera\dialogs.py", line 62, in find
return d()
File
"E:\Chimera\share\chimera\baseDialog.py", line 523, in __init__
BaseDialog.__init__(self, master, *args, **kw)
File
"E:\Chimera\share\chimera\baseDialog.py", line 244, in __init__
self.fillInUI(self.__top)
File
"E:\Chimera\share\ModelPanel\base.py", line 217, in fillInUI
self._addColumns()
File
"E:\Chimera\share\ModelPanel\base.py", line 436, in _addColumns
self._buildTable()
File
"E:\Chimera\share\ModelPanel\base.py", line 454, in _buildTable
% len(filter(lambda s:
s == 1, self.shownColumns)))
File
"E:\Chimera\bin\Lib\lib-tk\Tix.py", line 1306, in __init__
cnf, kw)
File
"E:\Chimera\bin\Lib\lib-tk\Tix.py", line 307, in __init__
self.tk.call(widgetName, self._w, *extra)
_tkinter.TclError: invalid command name
"tixScrolledHList"
Return code: 1
Press return or enter to to exit