• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

src/cmtzlib.h

Go to the documentation of this file.
00001 /*
00002      cmtzlib.h: header file for cmtzlib.c
00003      Copyright (C) 2001  CCLRC, Martyn Winn
00004 
00005      This library is free software; you can redistribute it and/or
00006      modify it under the terms of the GNU Lesser General Public
00007      License as published by the Free Software Foundation; either
00008      version 2.1 of the License, or (at your option) any later
00009      version.
00010 
00011      This library is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014      Lesser General Public License for more details.
00015 
00016      You should have received a copy of the GNU Lesser General Public
00017      License along with this library; if not, write to the Free
00018      Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019      Boston, MA 02110-1301 USA
00020 
00021 */
00022 
00099 #ifndef __CMTZLib__
00100 #define __CMTZLib__
00101 
00102 
00103 /* defines CCP4::CCP4File */
00104 #include "ccp4_utils.h"
00105 
00106 #ifdef  __cplusplus
00107 namespace CMtz {
00108 extern "C" {
00109 typedef CCP4::CCP4File CCP4File;
00110 #endif
00111 
00112 /* needs to be here for C++ to use CCP4File typedef */
00113 #include "mtzdata.h"
00114 
00115 /**** MTZ i/o ****/
00116 
00123 MTZ *MtzGet(const char *logname, int read_refs);
00124 
00136 MTZ *MtzGetUserCellTolerance(const char *logname, int read_refs, const double cell_tolerance);
00137 
00144 int MtzRrefl(CCP4File *filein, int ncol, float *refldata);
00145 
00152 int MtzPut(MTZ *mtz, const char *logname);
00153 
00161 CCP4File *MtzOpenForWrite(const char *logname);
00162 
00170 int MtzWhdrLine(CCP4File *fileout, int nitems, char buffer[]);
00171 
00179 int MtzWrefl(CCP4File *fileout, int ncol, float *refldata);
00180 
00187 int MtzDeleteRefl(MTZ *mtz, int iref);
00188 
00189 /**** Memory allocation ****/
00190 
00202 MTZ *MtzMalloc(int nxtal, int nset[]);
00203 
00208 int MtzFree(MTZ *mtz);
00209 
00216 MTZCOL *MtzMallocCol(MTZ *mtz, int nref);
00217 
00222 int MtzFreeCol(MTZCOL *col);
00223 
00227 MTZBAT *MtzMallocBatch(void);
00228 
00233 int MtzFreeBatch(MTZBAT *batch);
00234   
00239 char *MtzCallocHist(int nhist);
00240 
00245 int MtzFreeHist(char *hist);
00246 
00252 void MtzMemTidy(void);
00253 
00254 /**** Header operations ****/
00255   
00260 int MtzNbat(const MTZ *mtz);
00261 
00266 int MtzNref(const MTZ *mtz);
00267 
00272 int MtzSpacegroupNumber(const MTZ *mtz);
00273 
00281 int MtzResLimits(const MTZ *mtz, float *minres, float *maxres);
00282 
00283 /**** Crystal operations ****/
00284 
00289 int MtzNxtal(const MTZ *mtz);
00290 
00295 int MtzNumActiveXtal(const MTZ *mtz);
00296 
00301 MTZXTAL **MtzXtals(MTZ *mtz);
00302 
00308 MTZXTAL *MtzIxtal(const MTZ *mtz, const int ixtal);
00309 
00316 char *MtzXtalPath(const MTZXTAL *xtal);
00317 
00323 MTZXTAL *MtzXtalLookup(const MTZ *mtz, const char *label);
00324 
00332 MTZXTAL *MtzAddXtal(MTZ *mtz, const char *xname, const char *pname,
00333                   const float cell[6]);
00334 
00339 int MtzNsetsInXtal(const MTZXTAL *xtal);
00340 
00345 int MtzNumActiveSetsInXtal(const MTZ *mtz, const MTZXTAL *xtal);
00346 
00352 MTZSET **MtzSetsInXtal(MTZXTAL *xtal);
00353 
00360 MTZSET *MtzIsetInXtal(const MTZXTAL *xtal, const int iset);
00361 
00362 /**** Dataset operations ****/
00363 
00368 int MtzNset(const MTZ *mtz);
00369 
00374 int MtzNumActiveSet(const MTZ *mtz);
00375 
00383 MTZXTAL *MtzSetXtal(const MTZ *mtz, const MTZSET *set);
00384 
00393 char *MtzSetPath(const MTZ *mtz, const MTZSET *set);
00394 
00401 MTZSET *MtzSetLookup(const MTZ *mtz, const char *label);
00402 
00410 MTZSET *MtzAddDataset(MTZ *mtz, MTZXTAL *xtl, const char *dname,
00411                     const float wavelength);
00412 
00419 int MtzNcolsInSet(const MTZSET *set);
00420 
00425 int MtzNumActiveColsInSet(const MTZSET *set);
00426 
00432 int MtzNumSourceColsInSet(const MTZSET *set);
00433 
00439 int MtzNbatchesInSet(const MTZ *mtz, const MTZSET *set);
00440 
00446 MTZCOL **MtzColsInSet(MTZSET *set);
00447 
00455 MTZCOL *MtzIcolInSet(const MTZSET *set, const int icol);
00456 
00457 /**** Column operations ****/
00458 
00466 MTZCOL *MtzAddColumn(MTZ *mtz, MTZSET *set, const char *label,
00467                    const char *type);
00468 
00473 int MtzAssignHKLtoBase(MTZ *mtz);
00474 
00487 int MtzAssignColumn(MTZ *mtz, MTZCOL *col, const char crystal_name[],  
00488              const char dataset_name[]);
00489 
00496 int MtzToggleColumn(MTZCOL *col);
00497 
00504 MTZSET  *MtzColSet(const MTZ *mtz, const MTZCOL *col);
00505 
00510 int MtzNcol(const MTZ *mtz);
00511   
00516 int MtzNumActiveCol(const MTZ *mtz);
00517   
00523 int MtzNumSourceCol(const MTZ *mtz);
00524 
00532 char *MtzColPath(const MTZ *mtz, const MTZCOL *col);
00533 
00540 int MtzRJustPath(char *path, const char *partial, const int njust);
00541 
00547 int MtzPathMatch(const char *path1, const char *path2);
00548 
00554 MTZCOL *MtzColLookup(const MTZ *mtz, const char *label);
00555 
00560 char *MtzColType(MTZCOL *col);
00561 
00567 void MtzDebugHierarchy(const MTZ *mtz);
00568 
00576 int MtzListColumn(const MTZ *mtz, char clabs[][31], char ctyps[][3], int csetid[]);
00577 
00585 int MtzListInputColumn(const MTZ *mtz, char clabs[][31], char ctyps[][3], int csetid[]);
00586 
00587 /**** helper functions ****/
00588 
00597 int MtzFindInd(const MTZ *mtz, int *ind_xtal, int *ind_set, int ind_col[3]);
00598 
00605 float MtzInd2reso(const int in[3], const double coefhkl[6]);
00606 
00612 int MtzHklcoeffs(const float cell[6], double coefhkl[6]);
00613 
00620 int MtzArrayToBatch(const int *intbuf, const float *fltbuf, MTZBAT *batch);
00621 
00628 int MtzBatchToArray(MTZBAT *batch, int *intbuf, float *fltbuf);
00629 
00638 MTZBAT *sort_batches(MTZBAT *batch, int numbat);
00639 
00640 /**** pseudo-mtzlib routines ****/
00641 
00648 int ccp4_lrtitl(const MTZ *mtz, char *title);
00649 
00656 int ccp4_lrhist(const MTZ *mtz, char history[][MTZRECORDLENGTH], int nlines);
00657 
00663 int ccp4_lrsort(const MTZ *mtz, int isort[5]);
00664 
00671 int ccp4_lrbats(const MTZ *mtz, int *nbatx, int batchx[]);
00672 
00678 int ccp4_lrcell(const MTZXTAL *xtl, float cell[]);
00679 
00689 int ccp4_lrsymi(const MTZ *mtz, int *nsympx, char *ltypex, int *nspgrx, 
00690        char *spgrnx, char *pgnamx);
00691 
00701 int ccp4_lrsymm(const MTZ *mtz, int *nsymx, float rsymx[192][4][4]);
00702 
00712 int MtzParseLabin(char *labin_line, const char prog_labels[][31], 
00713            const int nlprgi, char user_labels[][2][31]);
00714 
00728 MTZCOL **ccp4_lrassn(const MTZ *mtz, const char labels[][31], const int nlabels, 
00729                 char types[][3]);
00730 
00744 int ccp4_lridx(const MTZ *mtz, const MTZSET *set, char crystal_name[64], 
00745             char dataset_name[64], char project_name[64], int *isets, 
00746             float datcell[6], float *datwave);
00747 
00763 int ccp4_lrrefl(const MTZ *mtz, float *resol, float adata[], int logmss[], int iref);
00764 
00781 int ccp4_lrreff(const MTZ *mtz, float *resol, float adata[], int logmss[],
00782                 const MTZCOL *lookup[], const int ncols, const int iref);
00783 
00791 int ccp4_ismnf(const MTZ *mtz, const float datum);
00792 
00798 int ccp4_lhprt(const MTZ *mtz, int iprint);
00799 
00806 int ccp4_lhprt_adv(const MTZ *mtz, int iprint);
00807 
00815 int ccp4_lrbat(MTZBAT *batch, float *buf, char *charbuf, int iprint);
00816 
00821 int MtzPrintBatchHeader(const MTZBAT *batch);
00822 
00830 int ccp4_lwtitl(MTZ *mtz, const char *ftitle, int flag);
00831 
00841 int MtzSetSortOrder(MTZ *mtz, MTZCOL *colsort[5]);
00842 
00849 int MtzAddHistory(MTZ *mtz, const char history[][MTZRECORDLENGTH], const int nlines);
00850 
00866 int ccp4_lwsymm(MTZ *mtz, int nsymx, int nsympx, float rsymx[192][4][4], 
00867                 char ltypex[], int nspgrx, char spgrnx[], char pgnamx[]);
00868 
00869 /* Assign columns for writing. Check to see if columns already exist,
00870  * else create them. New columns are assigned to the base dataset if it 
00871  * exists, else the first dataset.
00872  * @param mtz pointer to MTZ struct
00873  * @param labels Input array of column labels to be assigned.
00874  * @param nlabels Number of columns.
00875  * @param types Input array of column types of columns.
00876  * @param iappnd If iappnd = 0, then deactivate columns which are
00877  *   not selected (allows one to write out a subset of columns). Else
00878  *   if iappnd = 1, append these columns to existing ones.
00879  * @return Array of pointers to columns in MTZ struct.
00880  */
00881 MTZCOL **ccp4_lwassn(MTZ *mtz, const char labels[][31], const int nlabels, 
00882              const char types[][3], const int iappnd);
00883 
00884 /* Add or update a dataset in the MTZ structure. If the crystal name is
00885  * not recognised, then a new crystal is created containing a single
00886  * dataset. If the crystal name is recognised, then the parameters of
00887  * the crystal are updated. The child dataset is then created if necessary
00888  * or an existing dataset updated.
00889  * Note that this function is used to update crystal parameters, as well
00890  * as add crystals. If a duplicate crystal name is used by mistake, then 
00891  * the old crystal parameters are lost.
00892  * @param mtz pointer to MTZ struct
00893  * @param crystal_name Crystal name
00894  * @param dataset_name Dataset name
00895  * @param project_name Project name
00896  * @param datcell Cell dimensions of crystal that dataset belongs to.
00897  * @param datwave X-ray wavelength associated with dataset.
00898  * @return 1 on success, 0 on failure
00899  */
00900 int ccp4_lwidx(MTZ *mtz, const char crystal_name[],  const char dataset_name[],
00901         const char project_name[], const float datcell[6], const float *datwave);
00902 
00903 
00921 int ccp4_lwrefl(MTZ *mtz, const float adata[], MTZCOL *lookup[], 
00922                  const int ncol, const int iref);
00923 
00937 int ccp4_lwbat(MTZ *mtz, MTZBAT *batch, const int batno, const float *buf, const char *charbuf);
00938 
00939 int ccp4_lwbsetid(MTZ *mtz, MTZBAT *batch, const char xname[], const char dname[]);
00940 
00941 /* -- Below here there are no implementations -- */
00942 
00943 /* COMPLEX HLToSF(float hla, float hlb, float hlc, float hld, BOOLEAN centric); */
00944 /* Returns the mean structure factor as a complex number from a structure
00945    factor probability distribution described by Hendrickson/Lattman
00946    coefficients. If `centric == TRUE`, the coefficients describe a centric
00947    distribution. */
00948 
00949 /* MTZ *MtzSort(MTZ *mtz, char *ident); */
00950 /* Sorts `mtz` using the identifiers (separated by spaces) in `ident` as
00951    keys. Sorting can be done on up to 200 columns. A pointer to `*mtz` is
00952    returned. */
00953 
00954 /* MTZ *HLCombine (MTZ *to, float toscale, MTZ *frm, float frmscale); */
00955 /* Combines extra phase information for common reflections between 'frm'
00956    and 'to' into the phase information of 'to'. The phase probabilities
00957    are described by Hendrickson Lattman coefficients, with the identifiers
00958    "HLA", "HLB", HLC", and "HLD", the indices are identified by "H", "K" 
00959    and "L". HL-coeffs from 'to' are scaled by 'toscale', the coeffs from
00960    'frm' are scaled by 'frmscale'. A pointer to `to` is returned. */
00961 
00962 /* void MtzPhiFom(MTZ *mtz); */
00963 /* Calculates the best phase and the figure of from Hendrickson Lattman
00964    coefficients. The following columns should be present in `mtz`:
00965    "H", "K" & "L" (indices); "PHIB" & "FOM" (best phase (degrees) and figure of
00966    merit); "HLA", "HLB", "HLC" & "HLD" (Hendrickson Lattman coefficients). */
00967 
00968 /* MTZ *MtzCopy(MTZ *frm); */
00969 /* Produces an exact copy of `frm` and returns a pointer to it. */
00970 
00971 /* MTZ *MtzColAppend(MTZ *mtz, char *ident, char type); */
00972 /* Appends a column to `*mtz` with identity `ident` and type `type`, provided
00973    no column with identity `ident` exists. */
00974 
00975 /* MTZ *MtzColRemove(MTZ *mtz, char *ident); */
00976 /* Removes a column from `*mtz` with identity `ident`. */
00977 
00978 /* MTZ *MtzUpdateRanges(MTZ *mtz); */
00979 /* Updates ranges of all columns in `mtz` and returns `mtz`. */
00980 
00981 /* MTZCOL *MtzColNewRange(MTZCOL *col, int nref); */
00982 /* Updates the minimum & maximum values in `col` and returns `col`. */
00983 
00984 /* int *MtzUnique(MTZ *mtz, char *ident); */
00985 /* Returns an array (k) of indices: k[j] returns the first occurrence of a set
00986    of idents, eg. MtzUnique(mtz, "H K L") returns an array from which all the 
00987    unique reflections can be determined by indexing with k: k[i] is the index
00988    of the last relection of a set which all have the same hkl indices. It is
00989    assumed that `mtz` is sorted, using `ident` as keys. */
00990 
00991 /* float PhaseProb(float phase, float hla, float hlb, float hlc, float hld,
00992                 BOOLEAN centric); */
00993 /* Returns the probability of `phase` (expressed in radians) as determined by
00994    the Hendrickson-Lattman coefficients `hla`, `hlb`, `hlc` and `hld`. If
00995    `centric == TRUE`, the coefficients describe a centric distribution. */
00996 
00997 #ifdef __cplusplus
00998 } }
00999 #endif
01000 #endif

Generated on Mon Aug 22 2011 for gpp4 by  doxygen 1.7.1