[Chimera-users] Loop through hundreds of files and find HBonds
Eric Pettersen
pett at cgl.ucsf.edu
Fri Apr 15 07:03:16 PDT 2022
You need a space between saveFile and the quote that follows it.
> On Apr 15, 2022, at 6:39 AM, Samuel Kyobe <samuelkyobe at gmail.com> wrote:
>
> Hi Eric
>
> I have modified the code:
>
> hbonds_output = files[:-4] + "hbonds.txt" # change ".pdb" to "hbonds.txt"
> rc("findhbond intermodel true intramodel false relax false reveal true saveFile" + hbonds_output)
>
> But, the code returns the error below:
>
> File "/private/var/folders/y2/p069gv9n6lsf1x8w08bym32w0000gn/T/AppTranslocation/AF4918BD-D759-418D-AA97-756E6B1D941C/d/Chimera.app/Contents/Resources/share/Midas/midas_text.py", line 3396, in _parseTyped
> % typed
> MidasError: No value provided for keyword 'saveFile247_CnA1_pol_frag_1_conf_36_out_01hbonds.txt'
>
> Not sure what could be causing the error.
>
> Thank you
>
> Samuel
>
>
>
>
>> On 15 Apr 2022, at 04:02, Eric Pettersen <pett at cgl.ucsf.edu> wrote:
>>
>> Hi Samuel,
>> You know the ligand file name, so you could just modify that to make a corresponding unique output file name. So between lines 22 and 23 you could do:
>>
>> hbonds_output = files[:-4] + “.hbonds.txt” # change “.pdb” to “.hbonds.txt”
>>
>> and your findhbond command would be rc("findhbond intermodel true intramodel false relax false reveal true saveFile “ + hbonds_output)
>>
>> —Eric
>>
>>> On Apr 14, 2022, at 6:10 AM, Samuel Kyobe via Chimera-users <chimera-users at cgl.ucsf.edu> wrote:
>>>
>>> Hi Elaine
>>>
>>> Thank you so much for your responses.
>>> I have modified the recommended example as seen below:
>>>
>>> 1 import chimera
>>> 2 import os
>>> 3 import glob
>>> 4
>>> 5 from chimera import runCommand as rc
>>> 6 from chimera import replyobj
>>> 7
>>> 8 # change to folder with data files
>>> 9 os.chdir("/Volumes/Auto_chimera")
>>> 10
>>> 11 # absolute path to search all .pdb files of ligands
>>> 12 path = r'./*_out_*.pdb’ # several files with output name specified as *_out_*.pdb
>>> 13 files = glob.glob(path)
>>> 14 print(files)
>>> 15
>>> 16 file_names = files
>>> 17
>>> 18 for files in file_names:
>>> 19 my_mod=chimera.openModels.open('./HLA_5w6a_model_4.pdb',type="PDB")
>>> 20 replyobj.status("Processing " + files)
>>> 21 rc("open " + files)
>>> 22 rc("addh")
>>> 23 rc("findhbond intermodel true intramodel false relax false reveal true saveFile")
>>> 24 rc("close all")
>>> 25 rc("stop now”)
>>>
>>> My current challenge is how to save the different resultant files with unique file_names (line 25).
>>>
>>> Is there an alternative way I can call the files names after saveFile (line 25)? Your example doesn’t not work with my modified code.
>>>
>>> Thank you
>>>
>>> Samuel
>>>
>>>
>>>
>>>> On 13 Apr 2022, at 19:04, Elaine Meng <meng at cgl.ucsf.edu> wrote:
>>>>
>>>> Hi Samuel,
>>>> Although the first link I sent you shows Chimera commands, the second link shows how to put those commands together with Python for looping.
>>>> Elaine
>>>>
>>>>> On Apr 13, 2022, at 9:00 AM, Samuel Kyobe via Chimera-users <chimera-users at cgl.ucsf.edu> wrote:
>>>>>
>>>>> Dear Elaine
>>>>>
>>>>> The challenge I have is that the Command Index is not written for Python which I would prefer to use for looping in several files.
>>>>>
>>>>> I am using only Chimera I have no access to ChimeraX.
>>>>>
>>>>> Thank you
>>>>>
>>>>> Samuel
>>>>
>>>
>>>
>>> _______________________________________________
>>> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu
>>> Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-users
>>>
>>
>
>
More information about the Chimera-users
mailing list