# Presentation: 548862

## Phenix Infrastructure

**Core Components:**
**Computational Crystallography Toolbox**
**boost**
**SCons**

## Phenix top level

## Phenix Strategies and Tasks

**  ****def __init__(self):**
**    ****...**
**    ****task_parameters = parameters(**
**      ****group(**
**        ****...**
**        ****name = 'file_group',**
**        ****...**
**        ****parameters = parameters(**
**          ****define(**
**            ****...**
**            ****name = 'scalepack_file',**
**            ****...**
**          ****),**
**        ****),**
**      ****)      **
**    ****)**
**	****task_branches = {...}**
**   ****def Run(self):**
**     ****inp = self.get_parameters()**
**     ****for i in xrange(len(inp.file_group)):  **
**       ****print inp.file_group[i].scalepack_file.get_value()**

## Tasks and Strategies

**Design of tasks, strategies, and parameter definitions is based on two fundamental technologies provided by Python:**
**Object oriented design**
**A uniform generic mechanism for storing objects (pickle)**
**A strategy is **_**one**_** Python object that includes the values for the parameters of all tasks**
**A strategy object is a dynamic data structure that can easily be**
**Stored in and retrieved from a database**
**Used, represented, and manipulated in multiple ways**

## Phenix Architecture

**Flexible: can automate the whole structure solution process but also allow user input and control**

**Project Data Storage (PDS): for each structure maintains a history of the structure solution and all the data generated. **

**Built around a scripting language: efficient development of new ideas**

## Programmer Efficiency & Performance

**Performance**

## Choice of implementation languages

**Python **
**Very high-level programming**
**Easy to use (dynamic typing)**
**Fast development cycle (no compilation required)**
**Too slow for certain tasks**
**C++ **
**High-level or medium-level programming**
**Many arcane details (strong static typing)**
**Largely automatic dynamic memory management (templates)**
**Much faster than Python**
**With enough attention, performance even rivals that of FORTRAN**

## Happy marriage: Python and C++

**Syntactic differences put aside, Python and C++ objects and functions are very *****similar*****.**
**Flexibility (interpreted, dynamically typed) and****Efficiency (compiled, statically typed) are *****complementary*****.**
**Boost.Python (C++ library) provides the link:**
**Non-intrusive on the C++ design**
**Pseudo-automatic wrapping using C++ template techniques**
**Uses “new style” Python classes**
**Python bindings are concise and maintainable**

## The Computational Crystallography Toolbox

**Building blocks for Phenix:**

**cctbx**

## The Computational Crystallography Toolbox

**Building blocks for ****everybody****:**

***Open source tools for crystallographic software development***

**cctbx**

## cctbx SourceForge Project

## Collaboration via SourceForge

**Collaboration via SourceForge**

## cctbx SourceForge Project

## scitbx module

**scitbx/array_family – Array family for scientific applications**
**scitbx/fftpack – Fast Fourier transform toolbox**
**Port of FFTPACK (Fortran)**
**Pure, generic C++**
**scitbx/lbfgs – LBFGS conjugate gradient minimizer**
**Port of Fortran LBFGS**
**Pure, generic C++ incl. Exception Handling**

## scitbx array family

**Initially: collection of ad hoc and incomplete array types.**
**Inconsistent ad-hoc solutions**
**Clutter**
**Now: comprehensive and uniform array family:**
**Selection of memory management models**
**Types: tiny, small, shared**
**Access scheme = parameter**
**Type: versa**
**Algebras (+,-,*,/,sin,floor,etc.)**
**Python: from scitbx.array_family import ****flex**

## array_family accessors

**grid_accessor<3>(10,20,30);**
**periodic_grid_accessor<3>(10,20,30);**
**hermitian_symmetry_accessor<3>(10,20,30);**
**asymmetric_brick_accessor<3>(space_group, 10,20,30);**
**af::versa<double, periodic_grid_accessor<3> > a_p1(10,20,30);**
**af::versa<double, grid_accessor<3> >****  a_plain(a_p1, grid_accessor<3>(a_p1.accessor());**

## cctbx module

**uctbx – Unit cells**
**sgtbx – Space groups**
**miller – Structure factor algebra incl. selections and binning**
**adptbx – Atomic anisotropic displacement parameters**
**eltbx – Scattering factors, ionic radii, etc.**
**sftbx – Structure factor toolbox incl. calc. of gradients**
**mintbx – Minimization toolbox (currently partially in phenix)**
**Generic map handling algorithms (currently mainly C++)**
**Experimental: dmtbx – triplet generation for direct methods**
**Euclidean model matching (pure Python)**

## libtbx module

**libtbx module**

**Replaces the home-grown “fast-track” build system.**
**Thin wrapper around SCons (<500 lines of Python code)**
**python $HOME/libtbx/configure.py scitbx cctbx**
**source setpaths.csh**
**libtbx_scons –j 12 .**
**Scons – Software Construction Tool**
**Pure Python**
**No new syntax to learn**
**Completely replaces make**
**Uses MD5 check-sums instead of time-stamps**
**Check-sums include the compiler/linker options**
**Automatic global dependency analysis**
**Optimal utilization of multi-CPU machines (parallel compilation)**

## Anticipated Python/C++ ratio

## Summary

**Phenix core components are reaching a mature state.**
**C++ compiler are significantly better now (gcc 3, VC7).**
**Boost.Python V2 will be released next month.**
**SCons replaces the home-grown fast-track system.**

## Acknowledgements

**Paul Adams, LBNL, Phenix program director**
**David Abrahams, principal Boost.Python author**
**Nigel Moriarty, LBNL, Phenix GUI & daemon**
**Nick Sauter, LBNL, Beamline automation**
**Airlie McCoy, Cambridge, FFT structure factor calculation**
**Kevin Cowtan, York, Reciprocal space asymmetric units**
**Sacha Urzhumtsev, Rotation function parameter conversion**
**Vincent Favre-Nicolin, contributions to the eltbx**
**J. Nocedal, original Fortran LBFGS, R. Dodier, Java port**