[phenixbb] executing Phenix in a python script on a Windows OS

Robert Oeffner rdo20 at cam.ac.uk
Tue Mar 2 11:21:27 PST 2021


Dear Muriel,

The file 
C:\Users\MG\Phenix\phenix-installer-1.19.1-4122-intel-windows-x86_64\phenix_env.bat 
should not be run from a python subprocess. It is only used once for 
initialising the pheinix environment in your command prompt so that you 
may start phenix.python, phenix.refine or any other phenix.some_command 
from there.

Once you have started a phenix.python session from a command prompt you 
then need to import various modules such as the phenix, iotbx, cctbx, 
etc in order to use functions available from these.

If you're not used to write and work with python scripts it's not 
productive use of time to write python scripts for phenix.refine. It may 
be easier to do what you want just using the command line interface of 
phenix.refine.

Regards,

Robert



On 02-03-2021 16:36, Muriel Gelin wrote:
> Here is what I have:
>
> In a prompt:
>
> C:\Users\MG>C:\Users\MG\Phenix\phenix-installer-1.19.1-4122-intel-windows-x86_64\phenix_env.bat 
>
>
> C:\Users\MG>phenix.refine
> Usage: phenix.refine [options] [reflection_file] [pdb_file] 
> [parameter_file]
>
> -------------------------------------------------------------------------------- 
>
>
> In python:
>
> source = 
> subprocess.Popen(str(r"C:\Users\MG\Phenix\phenix-installer-1.19.1-4122-intel-windows-x86_64\phenix_env.bat"), 
> stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
> >>> phenix.refine
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'phenix' is not defined
> >>> py phenix.refine
>   File "<stdin>", line 1
>     py phenix.refine
>        ^
>
> -------------------------------------------------------------------------------- 
>
>
> If somebody see what is the problem. I'm afraid I am stuck ...
>
> Thank you all.
>
> Muriel
>
>
>
> Le 02/03/2021 à 11:03, gelin a écrit :
>> Dear Bernhard,
>>
>> Thank you for your answer.
>>
>> Executing phenix_env.bat in Windows command prompt works well, since 
>> I can then execute phenix.refine in the prompt.
>>
>> So I tried to add in my python script something like that:
>> source = subprocess.Popen(my_path\phenix_env.bat, 
>> stdin=subprocess.PIPE, stdout=subprocess.PIPE,
>>                               stderr=subprocess.PIPE)
>> Unfortunately, it doesn't work. I suppose the prompt environment is 
>> not modified.
>>
>> Do you know how to do that in my python script so that I can then 
>> execute something like:
>> xtriage = subprocess.Popen(["phenix.xtriage", my_mtz, 
>> "parameters.reporting.log=" + "xtriage.log")],
>>                                stdin=subprocess.PIPE, 
>> stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>>
>> Thank you for you help.
>>
>> Muriel
>>
>> Le 2021-03-01 18:36, Bernhard Rupp a écrit :
>>> Here is what I did:
>>>
>>> Install phenix
>>>
>>> make a batch command in your path (eg phx.bat) that executes the
>>> environment setup, eg.
>>> C:\Phenix\phenix-installer-1.19-4092-intel-windows-x86_64\phenix_env.bat 
>>>
>>>
>>> Open terminal, execute that batch (modify as you like), and there 
>>> you go
>>>
>>> c:\data\Dropbox\Refinements\5okl>phenix.refine
>>> Usage: phenix.refine [options] [reflection_file] [pdb_file] 
>>> [parameter_file]
>>> ....
>>>
>>> Best, BR
>>>
>>> -----Original Message-----
>>> From: phenixbb-bounces at phenix-online.org
>>> <phenixbb-bounces at phenix-online.org> On Behalf Of Muriel Gelin
>>> Sent: Monday, March 1, 2021 09:08
>>> To: phenixbb at phenix-online.org
>>> Subject: [phenixbb] executing Phenix in a python script on a Windows OS
>>>
>>> Dear Phenix community,
>>>
>>> I wrote a python script to automate the processing of our data with
>>> Phenix. I'm not a developer by profession, but a crystallographer, and
>>> write scripts usually under Linux. My colleagues working under Windows
>>> asked me to share my script.
>>>
>>> I managed to run a simple python script under windows, no problem. But
>>> for a script that executes Phenix, it's not so easy (for me).
>>>
>>> Under Linux, I manage to source phenix_env.csh, but under Windows what
>>> is the command to setup Phenix  in order to simply use phenix.refine
>>> or phenix.xtriage in my script?
>>>
>>> All I can find is this page
>>> https://www.mrc-lmb.cam.ac.uk/public/xtal/doc/phenix/install-setup-run.html 
>>>
>>>
>>> but I don't think it answers my question.
>>>
>>> Thank you in advance for your help!
>>>
>>> Muriel
>>>
>>> -- 
>>> Dr Muriel Gelin
>>>
>>> Research Engineer
>>> Centre de biochimie Structurale de Montpellier Team "ABCIS: Avanced
>>> Biology, Chemistry, Informatics Studio"
>>>
>>> CNRS UMR 5048 - UM - INSERM U 1054
>>> 29 rue de Navacelles
>>> 34090 MONTPELLIER Cedex - FRANCE
>>> http://www.cbs.cnrs.fr
>>>
>>> Tel: (33) 04 67 41 77 12
>>>
>>>
>>> -- 
>>> This message has been scanned for viruses and dangerous content by
>>> MailScanner, and is believed to be clean.
>>>
>>> _______________________________________________
>>> phenixbb mailing list
>>> phenixbb at phenix-online.org
>>> http://phenix-online.org/mailman/listinfo/phenixbb
>>> Unsubscribe: phenixbb-leave at phenix-online.org
>>
-- 
Robert Oeffner, Ph.D.
Research Associate, The Read Group
Department of Haematology,
Cambridge Institute for Medical Research
University of Cambridge
Cambridge Biomedical Campus
The Keith Peters Building
Hills Road
Cambridge CB2 0XY
www.cimr.cam.ac.uk/investigators/read/index.html
tel: +44(0)1223 763234


-- 
This email has been checked for viruses by AVG.
https://www.avg.com



More information about the phenixbb mailing list