Register New User | Download | Documentation | Tutorials | FAQ | Top Tips | Bugs | Publications | Developers |
As an alternative to keyword input, Phaser can be called directly from a python script. This is the way Phaser is called in Phenix and we encourage developers of other automation pipelines to use the python scripting too. In order to call Phaser in python you will need to have Phaser installed from source.
Functionality | Input-Object | Run-Job | Results-Object |
Anisotropy Correction | i = InputANO() | r = runANO(i) | ResultANO() |
Cell Content Analysis | i = InputCCA() | r = runCCA(i) | ResultCCA() |
Normal Mode Analysis | i = InputNMA() | r = runNMA(i) | ResultNMA() |
Automated MR | i = InputMR_AUTO() | r = runMR_AUTO(i) | ResultMR() |
Fast Rotation Function | i = InputMR_FRF() | r = runMR_FRF(i) | ResultMR_RF() |
Brute Rotation Function | i = InputMR_BRF() | r = runMR_BRF(i) | ResultMR_RF() |
Fast Translation Function | i = InputMR_FTF() | r = runMR_FTF(i) | ResultMR_TF() |
Brute Translation Function | i = InputMR_BTF() | r = runMR_BTF(i) | ResultMR_TF() |
Refinement and Phasing | i = InputMR_RNP() | r = runMR_RNP(i) | ResultMR() |
Log-Likelihood Gain | i = InputMR_LLG() | r = runMR_LLG(i) | ResultMR() |
Packing | i = InputMR_PAK() | r = runMR_PAK(i) | ResultMR() |
Automated Experimental Phasing | i = InputEP_AUTO() | r = runEP_AUTO(i) | ResultEP() |
SAD Experimental Phasing | i = InputEP_SAD() | r = runEP_SAD(i) | ResultEP() |
The major difference between running Phaser though the keyword interface and running Phaser though the python scripting is that the data reading and Phaser functionality are separated. For the Phaser "run-job" functions, the reflection data (for Miller indices, Fobs and SigmaFobs) are simply arrays, the space group is given as a Hall string, and the unitcell is given as an array of 6 numbers. This is an important feature of the Phaser python scripting as it means that the Phaser "run-job" functions are not tied to mtz file input, but the data can be read in python from any file format, and then the data passed to Phaser.
For the convenience of developers and users, the python scripting comes with data-reading jiffies to read data from mtz files. (These are the same mtz reading jiffies that are used internally by Phaser when calling Phaser from keyword input.)
Functionality | Input-Object | Run-Job | Result-Object |
Read Data for MR | i = InputMR_DAT() | r = runMR_DAT(i) | ResultMR_DAT() |
Read Data for EP | i = InputEP_DAT() | r = runEP_DAT(i) | ResultEP_DAT() |
Note that setting the space group by name or number does not specify the setting. It is best to set the space group via the Hall symbol, which is unique to the full definition of the space group.
Input Objects | Python Set Function | |
ROOT filename | i.setROOT(filename) | |
MUTE [ON|OFF] | i.setMUTE(True|False) | |
TITLe title | i.setTITL(title) | |
VERBose [ON|OFF] | i.setVERB(True|False) | |
VERBose [ON|OFF] EXTRA | i.setVERB_EXTRA(True|False) | |
* | SPACegroup name | i.setSPAC_NAME(name) |
* | SPACegroup number | i.setSPAC_NUM(number) |
* | SPACegroup Hall | i.setSPAC_HALL(hall) |
* | CELL a b c alpha beta gamm | i.setCELL(a,b,c,alpha,beta,gamma) |
* | Cell set from array of 6 numbers | i.setCELL([a,b,c,alpha,beta,gamma]) |
* except InputNMA |
Data are extracted from the "result-objects" with get-functions. The get-functions are mostly specific to the type of "result-object" (described in sections below), but some are common to all "result-objects" (described in table below).
Ralf Grosse-Kunstleve's scitbx::af::shared<double> array type is heavily used for passing of arrays into the Phaser "input-objects" and extracting arrays from the Phaser "result-objects". This is a reference counted array type that can be used directly in python and in C++. It is part of the Phaser installation, when Phaser is installed from source. The scitbx (SCIentific ToolBoX) is part of the cctbx (Computational Crystallography ToolBoX) which is hosted by sourceforge
Results Objects | Python Get Function | |
Exit status "success" | r.Success() | |
Exit status "failure" | r.Failure() | |
Type of Error (see error table). SYNTAX errors are not thrown in python as they are generated by keyword input | r.ErrorName() | |
Message associated with error | r.ErrorMessage() | |
Text of Summary | r.summary() | |
Text of Logfile | r.logfile() | |
Text of Verbose Logfile | r.verbose() | |
* | SpaceGroup Hall Symbol | r.getSpaceGroupHall() |
* | SpaceGroup Name (Hermann Mauguin, edited for CCP4 compatibility in R3 H3 R32 H32) | r.getSpaceGroupName() |
* | SpaceGroup Number | r.getSpaceGroupNumber() |
* | Number of symmetry operators | r.getSpaceGroupNSYMM() |
* | Number of primative symmetry operators | r.getSpaceGroupNSYMP() |
* | Symmetry operator #s, Rotation matrix element i,j (range 0-2) | r.getSpaceGroupR(s,i,j) |
* | Symmetry operator #s, Translation vector element i (range 0-2) | r.getSpaceGroupT(s,i) |
* | Unit Cell (array of 6 numbers) | r.getUnitCell() |
* except ResultNMA |
Exit status is indicated by Success() and Failure() functions of the "result-objects". Success indicates successful execution of Phaser, not that it has solved the structure! For molecular replacement jobs, the foundSolutions() function indicates that Phaser has found one or more potential solutions, the numSolutions() function returns how many solutions were found and the uniqueSolution() function returns True if only one solution was found. More detailed error information in the case of Failure is given by ErrorName() and ErrorMessage().
Advanced Information: All errors are thrown and caught internally by the "run-jobs", and so do not generate "Runtime Errors" in the python script. In particular "INPUT" errors are not thrown by the set- or add-functions of the "input-objects", but are stored in the "input-object" and passed to the "result-object" once the "run-job" is called. Results objects are derived from std::exception, and so can be thrown. Function what() returns ErrorName() (not the ErrorMessage()).
Writing of the logfile to standard output can be silenced with the i.setMUTE(True) function. The logfile or summary text can then be printed to standard output with the print r.logfile() or print r.summary() functions.
Advanced Information: Setting i.setMUTE(True) prevents real time viewing of the progress of a Phaser job. This may present an inconvenience for users. If you want to view the logfile information but not have it go to standard output, Logfile text can be redirected to a python string using an alternative call to the "run-job" function that includes passing an "output-object" (which controls the Phaser logging methods) on which the output stream has been set to a python string. This feature of Phaser was developed thanks to Ralf Grosse-Kunstleve.
beta_blip_logfile.pyBelow are the detailed instructions for running the most popular modes of Phaser: anisotropy correction, automated molecular replacement, cell content analysis, normal mode analysis, and SAD phasing. Note that not all the functionality is available through the python interface, particularly the "expert" functionality available through the keyword interface, marked with an asterix in the keyword list.
Input Object Type: InputMR_DAT
Keyword Input | Python Set/Add Function |
HKLIn filename | i.setHKLI(filename) |
LABIn F=Fobs SIGF=Sigma | i.setLABI(Fobs,Sigma) |
RESOlution lim | i.setHIRES(lim) |
RESOlution lim1 lim2 | i.setRESO(lim1,lim2 |
SORT [ON|OFF] | i.setSORT(True|False) |
Result Object Type: ResultMR_DAT
Result | Python Get Function |
Miller Indices (array) | r.getMiller() |
F values (array) | r.getF() |
SIGF values (array) | r.getSIGF() |
Example script for reading data from MTZ file beta_blip.mtz
Note that by default reflections are sorted into resolution
order upon reading, to achieve a performance gain in the molecular replacement routines. If reflections are not being read from
an MTZ file with this script, reflections should be pre-sorted into resolution order to achieve the same performance gain. Sorting is turned off with the setSORT(False) function.
Input Object Type: InputANO
Keyword Input | Python Set/Add Function |
Read from MTZ file | i.setREFL(HKL,F,SIGF) |
HKLIn filename MTZ file to which output is appended Data are not read from this file |
i.setHKLI(filename) |
LABIn F=Fobs SIGF=Sigma Column label in output MTZ file Fobs_ISO and Sigma_ISO Defaults F_ISO and SIGF_ISO |
i.setREFL_ID(Fobs,Sigma) |
HKLOut [ON|OFF] | i.setHKLO(True|False) |
SORT [ON|OFF] | i.setSORT(True|False) |
Result Object Type: ResultANO
Result | Python Get Function |
Miller Indices (array) | r.getMiller() |
F values (array) | r.getF() |
SIGF values (array) | r.getSIGF() |
Corrected F (array) | r.getCorrectedF() |
Corrected SIGF (array) | r.getCorrectedSIGF() |
Correction Factor | r.getCorrection() |
Apply scale and correction factors to array | new_array = r.getScaledCorrected(array) |
Factor to put data on absolute scale | r.WilsonK() |
Wilson B factor | r.WilsonB() |
Measure of anisotropy | r.getAnisoDeltaB() |
Eigenvalues of anisotropy | r.getEigenBs() |
Eigenvectors and Eigenvalues or anisotropy | r.getEigenSystem() |
Name of output MTZ file | r.getMtzFile() |
Output MTZ file corrected F label | r.getLaboutF() |
Output MTZ file corrected SIGF label | r.getLaboutSIGF() |
Name of output XML file | r.getXmlFile() |
Example script script for anisotropy correction of BETA-BLIP data
beta_blip_ano.py
Input Object Type: InputCCA
Keyword Input | Python Set/Add Function |
COMPosition PROTein MW mw NUM num | i.addCOMP_PROT_MW_NUM(mw,num) |
COMPosition PROTein SEQ file NUM num | i.addCOMP_PROT_FASTA_NUM(file,num) where sequence is in a fasta file i.addCOMP_PROT_SEQ_NUM(sequence,num) where sequence is a string, one letter code |
COMPosition NUCLeic MW mw NUM num | i.addCOMP_NUCL_MW_NUM(mw,num) |
COMPosition NUCLeic SEQ seq NUM num | i.addCOMP_NUCL_FASTA_NUM(file,num) where sequence is in a fasta file i.addCOMP_NUCL_SEQ_NUM(sequence,num) where sequence is a string, one letter code |
COMPosition ATOM atomtype NUM num | i.addCOMP_ATOM_NUM(atomtype,num) |
COMPosition ENSEmble ens FRAC frac | i.addCOMP_ENSE_FRAC(ens,frac) |
Result Object Type: ResultCCA
Result | Python Get Function |
Molecular weight of the assembly used for VM calculations | r.getAssemblyVM() |
Number of multiples of the assembly within allowed VM range | r.getNum() |
Array of the multiples (Z) of the assembly within allowed VM range | r.getZ() |
Array of the values of VM corresponding to the multiples (Z) of the assembly | r.getVM() |
Array of the probabilities of VM corresponding to the multiples (Z) of the assembly | r.getProb() |
Most probable multiple (Z) of the assembly | r.getBestZ() |
VM of the most probable multiple (Z) of the assembly | r.getBestVM() |
Probability of the most probable multiple (Z) of the assembly | r.getBestProb() |
XML file name | r.getXmlFile() |
Optimal VM for space group, unit cell and resolution | r.getOptimalVM() |
Optimal MW for space group, unit cell and resolution | r.getOptimalMW() |
Example script for cell content analysis of BETA-BLIP
beta_blip_cca.py
Input Object Type: InputNMA
Keyword Input | Python Set/Add Function |
ENSEmble | As for InputMR_AUTO |
NMAPdb MODE m1 MODE m2 | i.setNMAP_MODES([m1,m2 ]) |
NMAPdb RMS step | i.setNMAP_RMS(step) |
NMAPdb MAXRms distance | i.setNMAP_MAXRMS(distance) |
NMAPdb BACKward | i.setNMAP_BACKWARD() |
NMAPdb FORWard | i.setNMAP_FORWARD() |
NMAPdb TOFRo | i.setNMAP_TO_AND_FRO() |
NMAPdb COMBination nmax | i.setNMAP_COMBINATION(nmax) |
NMAPdb CLASh distance | i.setNMAP_CLASH(distance) |
NMAPdb STREtch distance | i.setNMAP_STRETCH(distance) |
NMAPdb DQ dq1 DQ dq2 | i.setNMAP_DQ([dq1,dq2 ]) |
NMAMethod RTB | i.setNMAM_RTB() |
NMAMethod CA | i.setNMAM_CA() |
NMAMethod ALL | i.setNMAM_ALL() |
NMAMethod NRESidues nres | i.setNMAM_NRES(nres) |
NMAMethod MAXBlocks maxblocks | i.setNMAM_MAXBLOCKS(maxblocks) |
NMAMethod RADIus radius | i.setNMAM_RADIUS(radius) |
NMAMethod FORCe force | i.setNMAM_FORCE(force) |
SCRIpt [ON|OFF] | i.setSCRI(True|False) |
XYZOut [ON|OFF] | i.setXYZO(True|False) |
Result Object Type: ResultNMA
Result | Python Get Function |
Number of total perturbations along combinations of normal modes | r.getNum() |
Array of all pdb files | r.getPdbFiles() |
Name of pdb file for perturbation #i | r.getPdbFile(i) |
Array of normal modes contributing to perturbation #i | r.getModes(i) |
Array of displacements along modes contributing to perturbation #i | r.getDisplacements(i) |
Script output file | r.getSolFile() |
Xml output file | r.getXmlFile() |
Example script for normal mode analysis of BETA-BLIP. Note that the space group and unit cell are not required, and so the MTZ file does not need to be read to extract these parameters.
beta_nma.py
Input Object Type: InputMR_AUTO
Keyword Input | Python Set/Add Function |
Read from MTZ file | i.setREFL(HKL,F,SIGF) |
SGALternative num | i.addSGAL_NUM(num) |
SGALternative name | i.addSGAL_NAME(name) |
SGALternative HAND | i.addSGAL_HAND(True|False) |
SGALternative ALL | i.addSGAL_ALL(True|False) |
ENSEmble ens PDB pdbfile ID id | i.addENSE_PDB_ID(ens,pdbfile,id) |
ENSEmble ens PDB pdbfile RMS rms | i.addENSE_PDB_RMS(ens,pdbfile,rms) |
COMPosition | As for InputCCA |
SEARch ENSEmble ens NUM num | i.addSEAR_ENSE_NUM(ens,num) |
SEARch ENSEmble ens1 {OR ENSEmble } NUM num | i.addSEAR_ENSE_OR_ENSE_NUM([ens1, ],num) |
HKLOut [ON|OFF] | i.setHKLO(True|False) |
SCRIpt [ON|OFF] | i.setSCRI(True|False) |
XYZOut [ON|OFF] | i.setXYZO(True|False) |
Result Object Type: ResultMR
Result | Python Get Function |
Solutions were found (boolean) | r.foundSolutions() |
Number of Solutions that were found (int) | r.numSolutions() |
Only one solution found (boolean) | r.uniqueSolution() |
LLG values for all solutions in decreasing order | r.getValues() |
Script output file | r.getSolFile() |
Xml output file | r.getXmlFile() |
PDB files corresponding to solutions in decreasing LLG order | r.getPdbFiles() |
MTZ files corresponding to solutions in decreasing LLG order | r.getMtzFiles() |
LLG of top solution | r.getTopValue() |
PDB file of top solution | r.getTopPdbFile() |
MTZ file of top solution | r.getTopMtzFile() |
List of details of solutions (rotation, translation) in decreasing LLG order in "mr_solution" type |
r.getDotSol() |
Example script for automated structure solution of BETA-BLIP
beta_blip_auto.py
Input Object Type: InputEP_DAT
Keyword Input | Python Set/Add Function |
HKLIn filename | i.setHKLI(filename) |
RESOlution lim | i.setHIRES(lim) |
RESOlution lim1 lim2 | i.setRESO(lim1,lim2) |
CRYStal xtal DATAset wave LABIn F = F SIGF = SIGF | i.addCRYS_NORM_LABI(xtal,wave,F,SIGF) |
CRYStal xtal DATAset wave LABIn F+ = Fp SIG+ = SIGp F- = Fn SIG- = SIGn | i.addCRYS_ANOM_LABI(xtal,wave,Fp,SIGp,Fn,SIGn) |
CRYStal xtal DATAset wave RESOlution lim1 lim2 | i.setCRYS_RESO(xtal,wave,lim1,lim2) |
Result Object Type: ResultEP_DAT
Result | Python Get Function |
Miller Indices (array) | r.getMiller() |
Non-anomalous F values for crystal "xtal" and dataset "wave" (array) | r.getF(xtal,wave) |
Non-anomalous SIGF values for crystal "xtal" and dataset "wave" (array) | r.getSIGF(xtal,wave) |
Boolean flags for F (and SIGF) present for crystal "xtal" and dataset "wave" (array) | r.getP(xtal,wave) |
Anomalous F+ values for crystal "xtal" and dataset "wave" (array) | r.getFpos(xtal,wave) |
Anomalous SIGF+ values for crystal "xtal" and dataset "wave" (array) | r.getSIGFpos(xtal,wave) |
Boolean flags for F+ (and SIGF+) present for crystal "xtal" and dataset "wave" (array) | r.getPpos(xtal,wave) |
Anomalous F- values for crystal "xtal" and dataset "wave" (array) | r.getFneg(xtal,wave) |
Anomalous SIGF- values for crystal "xtal" and dataset "wave" (array) | r.getSIGFneg(xtal,wave) |
Boolean flags for F- (and SIGF-) present for crystal "xtal" and dataset "wave" (array) | r.getPneg(xtal,wave) |
Below is a python script for reading SAD data from MTZ file S-insulin.mtz
Input Object Type: InputEP_AUTO
Keyword Input | Python Set/Add Function |
HKLIn filename
MTZ to which output data are appended Data are not read from this file |
i.setHKLI(filename) |
Input Data from array | i.setCRYS_MILLER(miller) |
Input Non-anomalous data for xtal/wave from array | i.addCRYS_NORM_DATA(xtal,wave,F,SIGF,P) |
Input Anomalous data for xtal/wave from array | i.addCRYS_ANOM_DATA(xtal,wave,Fp,SIGp,Pp,Fn,SIGn,Pn) |
CRYS xtal DATA wave SCAT CUKA | i.setCRYS_SCAT_CUKA(xtal,wave) |
CRYS xtal DATA wave SCAT WAVE lambda | i.setCRYS_SCAT_WAVE(xtal,wave,lambda) |
CRYS xtal DATA wave SCAT MEAS FP=fp FDP=fdp | i.setCRYS_SCAT_MEAS(xtal,wave,fp,fdp) |
CRYS xtal DATA wave SCAT ATOM type FP=fp FDP=fdp | i.addCRYS_SCAT_ELEM(xtal,wave,type,fp,fdp) |
CRYS xtal DATA wave SCAT FIXP FIXDP | i.addCRYS_SCAT_FIX(xtal,wave,True,True) |
LLGC CRYS xtal COMPLETE [ON|OFF] | i.setLLGC_CRYS_COMPLETE(xtal,True|False) |
LLGC CRYS xtal SCATTERING ELEMENT type | i.addLLGC_CRYS_SCAT_ELEMENT(xtal,type) |
LLGC CRYS xtal CLASH DEFAULT | i.setLLGC_CRYS_CLASH_DEFAULT(xtal) |
LLGC CRYS xtal CLASH DISTANCE distance | i.setLLGC_CRYS_CLASH_DISTANCE(xtal,distance) |
LLGC CRYS xtal SIGMA cutoff | i.setLLGC_CRYS_SIGMA(xtal,cutoff) |
ATOM CRYS xtal ELEM type FRAC x y z OCC occ | i.addATOM(xtal,type,x,y,z,occ) |
ATOM BFAC WILSON | i.setATOM_BFACTOR_WILSON() |
ATOM BFAC VALUE bfactor | i.setATOM_BFACTOR_VALUE(bfactor) |
ATOM CRYS xtal PDB pdbfile | i.setATOM_PDB(xtal,pdbfile) |
ATOM CRYS xtal HA hafile | i.setATOM_HA(xtal,hafile) |
HAND [ON|OFF] | i.setHAND(True|False) |
COMPosition | As for InputCCA |
Result Object Type: ResultEP
Result | Python Get Function |
Log-likelihood of refined solution | r.getLogLikelihood() |
Miller Indices (array) | r.getMiller() |
Boolean array flagging reflections included in electron denisty | r.getSelected() |
Figures of merit for phased dataset (array) | r.getFOM() |
Amplitudes for weighted electrion density of phased dataset (array) | r.getFWT() |
Phases for weighted electrion density of phased dataset (array) | r.getPHWT() |
Phases for electrion density of phased dataset (array) | r.getPHIB() |
Amplitudes for log-likelihood gradient map | r.getFLLG() |
Phases for log-likelihood gradient map | r.getPHLLG() |
Atoms included in final solution for crystal xtal | r.getAtoms(xtalid) |
Atoms rejected from final solution for crystal xtal | r.getRejectedAtoms(xtalid) |
f' for atomtype "type" in crystal "xtald" dataset "wave" | r.getFp(xtalid,wave,type) |
f" for atomtype "type" in crystal "xtald" dataset "wave" | r.getFdp(xtalid,wave,type) |
Name of output MTZ file | r.getMtzFile() |
Name of output PDB file | r.getPdbFile() |
Name of output SOL file | r.getSolFile() |
Name of output XML file | r.getXmlFile() |
There are also functions for extracting phasing statistics
Result | Python Get Function |
Overall low resolution limit | r.stats_lores() |
Overall high resolution limit | r.stats_hires() |
Overall figure of merit for all reflections | r.stats_fom() |
Overall figure of merit for acentrics | r.stats_acentric_fom() |
Overall figure of merit for centrics | r.stats_centric_fom() |
Overall figure of merit for singleton | r.stats_singleton_fom() |
Overall number of reflections | r.stats_num() |
Overall number of acentric reflections | r.stats_acentric_num() |
Overall number of centric reflections | r.stats_centric_num() |
Overall number of singleton reflections | r.stats_singleton_num() |
Number of resolution bins for statistics | r.stats_numbins() |
Binwise low resolution limit | r.stats_by_bin_lores(bin_number) |
Binwise high resolution limit | r.stats_by_bin_hires(bin_number) |
Binwise middle of resolution range | r.stats_by_bin_midres(bin_number) |
Binwise figure of merit for all reflections | r.stats_by_bin_fom(bin_number) |
Binwise figure of merit for acentrics | r.stats_by_bin_acentric_fom(bin_number) |
Binwise figure of merit for centrics | r.stats_by_bin_centric_fom(bin_number) |
Binwise figure of merit for singleton | r.stats_by_bin_singleton_fom(bin_number) |
Binwise number of reflections | r.stats_by_bin_num(bin_number) |
Binwise number of acentric reflections | r.stats_by_bin_acentric_num(bin_number) |
Binwise number of centric reflections | r.stats_by_bin_centric_num(bin_number) |
Binwise number of singleton reflections | r.stats_by_bin_singleton_num(bin_number) |
Example script for SAD phasing for insulin
insulin_sad.py