[chimerax-users] alphafold block
Tom Goddard
goddard at sonic.net
Tue Feb 15 13:43:43 PST 2022
Hi Roberto,
In general new windows are not going to appear until the Qt event loop is run. It is unusual for scripts to run GUIs, and most all ChimeraX commands run without a GUI. But Google Colab is a GUI service. It is a very bad idea to run the Qt event loop in your script, but it could be done. But that only gets you to the next problem, that the Google Colab script will not run until you press a GUI button saying it is ok to run the code that did not come from Google. I don't think you will be able to press that button with any Python (unless you do an extreme Python / Javascript hack).
I think scripting ChimeraX AlphaFold prediction using Google Colab looks like a mine field. If you want to run a lot of AlphaFold jobs it really calls out for you to setup your own AlphaFold installation and not use ChimeraX or Google Colab.
I believe I read on the Google Colab AlphaFold github that you can run multiple sequential predictions by simply putting multiple sequences in the FASTA file and running monomer mode -- never tried it. If you are using free Google Colab sessions are limited to 12 hour so you won't get very far. I think Colab Pro gives you 24 hours. Google Colab is not intended to do high throughput calculations, and it would probably be considered an abuse of the service if you scripted it to run jobs continuously.
Tom
> On Feb 15, 2022, at 1:05 PM, Roberto Marabini via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Hi,
>
> Thanks for the suggestion but I do not think it will work. The main
> problem here is that
> Colab window does not appear, and therefore can not be launched, until
> the python script is done.
> That is, if I write some code as
>
> run(session, "alphafold predict %s" % sequence_data)
> ...
> print("test")
>
> Colab window will not pop up until the print statement is executed.
>
> Where can I find the documentation related to callbacks?
>
>
> On Tue, Feb 15, 2022 at 7:34 PM Tom Goddard <goddard at sonic.net> wrote:
>>
>> Hi Roberto,
>>
>> When the AlphaFold prediction completes it loads the best model into ChimeraX. So I suggest checking periodically if any model has been loaded, for example,
>>
>> if len(session.models) > 0:
>> break # AlphaFold model has been opened.
>>
>> Another method is to ask ChimeraX to call a callback when a model gets opened, but that would not let you detect the case where AlphaFold fails and a model is never opened. Currently Colab does not tell ChimeraX if an error occurs in sequence alignment or energy minimization -- it only appears in the AlphaFold Run html panel. Errors in the prediction phase are caught and sent to ChimeraX. I should improve this so all errors get sent back to ChimeraX. It is not obvious how to ask Colab if the jobs is still running -- Colab is meant to be run interactively through a web browser so Colab APIs are not documented to programmatically talk to it as far as I know.
>>
>> Tom
>>
>>
>>> On Feb 15, 2022, at 5:14 AM, Roberto Marabini via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>>>
>>> Hi,
>>>
>>> I would like to write a script that executes
>>> "alphafold predict SEQUENCE"
>>> and then postprocess the results.
>>>
>>> The script would be similar to:
>>>
>>> from chimerax.core.commands import run
>>> run(session, "alphafold predict %s" % sequence_data)
>>> # wait until alphafold is done
>>> # and postprocess the file best_model.pdb
>>>
>>> but I do not know how to implement the part "wait until alphafold is done"
>>> if, after launching alphafold, I create a loop similar to:
>>>
>>> ===
>>> counter = 0
>>> current_size = _getSize(file_path)
>>>
>>> while current_size !=_getSize(file_path) or _getSize(file_path)==0
>>> or not os.path.exists(file_path):
>>> current_size =_getSize(file_path)
>>> time.sleep(60)
>>> counter += 1
>>> if counter > 240: # break after four hours if file is not created
>>> break
>>> ====
>>>
>>> the loop is executed as soon as the alphafold command has been sent to
>>> google, the alphafold-colab window is not shown until the loop is
>>> finished and therefore, alphafold execution never starts.
>>>
>>> So the question is: how can I write a script that waits until the
>>> command "alphafold predict ..." finishes and then executes some code.
>>>
>>> Thanks
>>>
>>>
>>> Roberto
>>> _______________________________________________
>>> ChimeraX-users mailing list
>>> ChimeraX-users at cgl.ucsf.edu
>>> Manage subscription:
>>> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
>>>
>>
>
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
>
More information about the ChimeraX-users
mailing list