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 
00131 MTZ *MtzGetUserCellTolerance(
00132   const char *logname, int read_refs, const double cell_tolerance);
00133 
00140 int MtzRrefl(CCP4File *filein, int ncol, float *refldata);
00141 
00148 int MtzPut(MTZ *mtz, const char *logname);
00149 
00154 CCP4File *MtzOpenForWrite(const char *logname);
00155 
00163 int MtzWhdrLine(CCP4File *fileout, int nitems, char buffer[]);
00164 
00172 int MtzWrefl(CCP4File *fileout, int ncol, float *refldata);
00173 
00180 int MtzDeleteRefl(MTZ *mtz, int iref);
00181 
00182 /**** Memory allocation ****/
00183 
00195 MTZ *MtzMalloc(int nxtal, int nset[]);
00196 
00201 int MtzFree(MTZ *mtz);
00202 
00209 MTZCOL *MtzMallocCol(MTZ *mtz, int nref);
00210 
00215 int MtzFreeCol(MTZCOL *col);
00216 
00220 MTZBAT *MtzMallocBatch(void);
00221 
00226 int MtzFreeBatch(MTZBAT *batch);
00227   
00232 char *MtzCallocHist(int nhist);
00233 
00238 int MtzFreeHist(char *hist);
00239 
00245 void MtzMemTidy(void);
00246 
00247 /**** Header operations ****/
00248   
00253 int MtzNbat(const MTZ *mtz);
00254 
00259 int MtzNref(const MTZ *mtz);
00260 
00265 int MtzSpacegroupNumber(const MTZ *mtz);
00266 
00274 int MtzResLimits(const MTZ *mtz, float *minres, float *maxres);
00275 
00276 /**** Crystal operations ****/
00277 
00282 int MtzNxtal(const MTZ *mtz);
00283 
00288 int MtzNumActiveXtal(const MTZ *mtz);
00289 
00294 MTZXTAL **MtzXtals(MTZ *mtz);
00295 
00301 MTZXTAL *MtzIxtal(const MTZ *mtz, const int ixtal);
00302 
00309 char *MtzXtalPath(const MTZXTAL *xtal);
00310 
00316 MTZXTAL *MtzXtalLookup(const MTZ *mtz, const char *label);
00317 
00325 MTZXTAL *MtzAddXtal(MTZ *mtz, const char *xname, const char *pname,
00326                   const float cell[6]);
00327 
00332 int MtzNsetsInXtal(const MTZXTAL *xtal);
00333 
00339 int MtzNumActiveSetsInXtal(const MTZ *mtz, const MTZXTAL *xtal);
00340 
00346 MTZSET **MtzSetsInXtal(MTZXTAL *xtal);
00347 
00354 MTZSET *MtzIsetInXtal(const MTZXTAL *xtal, const int iset);
00355 
00356 /**** Dataset operations ****/
00357 
00362 int MtzNset(const MTZ *mtz);
00363 
00368 int MtzNumActiveSet(const MTZ *mtz);
00369 
00377 MTZXTAL *MtzSetXtal(const MTZ *mtz, const MTZSET *set);
00378 
00387 char *MtzSetPath(const MTZ *mtz, const MTZSET *set);
00388 
00395 MTZSET *MtzSetLookup(const MTZ *mtz, const char *label);
00396 
00404 MTZSET *MtzAddDataset(MTZ *mtz, MTZXTAL *xtl, const char *dname,
00405                     const float wavelength);
00406 
00413 int MtzNcolsInSet(const MTZSET *set);
00414 
00419 int MtzNumActiveColsInSet(const MTZSET *set);
00420 
00426 int MtzNumSourceColsInSet(const MTZSET *set);
00427 
00433 int MtzNbatchesInSet(const MTZ *mtz, const MTZSET *set);
00434 
00440 MTZCOL **MtzColsInSet(MTZSET *set);
00441 
00449 MTZCOL *MtzIcolInSet(const MTZSET *set, const int icol);
00450 
00451 /**** Column operations ****/
00452 
00460 MTZCOL *MtzAddColumn(MTZ *mtz, MTZSET *set, const char *label,
00461                    const char *type);
00462 
00467 int MtzAssignHKLtoBase(MTZ *mtz);
00468 
00481 int MtzAssignColumn(MTZ *mtz, MTZCOL *col, const char crystal_name[],  
00482              const char dataset_name[]);
00483 
00490 int MtzToggleColumn(MTZCOL *col);
00491 
00498 MTZSET  *MtzColSet(const MTZ *mtz, const MTZCOL *col);
00499 
00504 int MtzNcol(const MTZ *mtz);
00505   
00510 int MtzNumActiveCol(const MTZ *mtz);
00511   
00517 int MtzNumSourceCol(const MTZ *mtz);
00518 
00526 char *MtzColPath(const MTZ *mtz, const MTZCOL *col);
00527 
00534 int MtzRJustPath(char *path, const char *partial, const int njust);
00535 
00541 int MtzPathMatch(const char *path1, const char *path2);
00542 
00548 MTZCOL *MtzColLookup(const MTZ *mtz, const char *label);
00549 
00554 char *MtzColType(MTZCOL *col);
00555 
00561 void MtzDebugHierarchy(const MTZ *mtz);
00562 
00570 int MtzListColumn(const MTZ *mtz, char clabs[][31], char ctyps[][3], int csetid[]);
00571 
00579 int MtzListInputColumn(const MTZ *mtz, char clabs[][31], char ctyps[][3], int csetid[]);
00580 
00581 /**** helper functions ****/
00582 
00591 int MtzFindInd(const MTZ *mtz, int *ind_xtal, int *ind_set, int ind_col[3]);
00592 
00599 float MtzInd2reso(const int in[3], const double coefhkl[6]);
00600 
00606 int MtzHklcoeffs(const float cell[6], double coefhkl[6]);
00607 
00614 int MtzArrayToBatch(const int *intbuf, const float *fltbuf, MTZBAT *batch);
00615 
00622 int MtzBatchToArray(MTZBAT *batch, int *intbuf, float *fltbuf);
00623 
00632 MTZBAT *sort_batches(MTZBAT *batch, int numbat);
00633 
00634 /**** pseudo-mtzlib routines ****/
00635 
00642 int ccp4_lrtitl(const MTZ *mtz, char *title);
00643 
00650 int ccp4_lrhist(const MTZ *mtz, char history[][MTZRECORDLENGTH], int nlines);
00651 
00657 int ccp4_lrsort(const MTZ *mtz, int isort[5]);
00658 
00665 int ccp4_lrbats(const MTZ *mtz, int *nbatx, int batchx[]);
00666 
00672 int ccp4_lrcell(const MTZXTAL *xtl, float cell[]);
00673 
00683 int ccp4_lrsymi(const MTZ *mtz, int *nsympx, char *ltypex, int *nspgrx, 
00684        char *spgrnx, char *pgnamx);
00685 
00695 int ccp4_lrsymm(const MTZ *mtz, int *nsymx, float rsymx[192][4][4]);
00696 
00706 int MtzParseLabin(char *labin_line, const char prog_labels[][31], 
00707            const int nlprgi, char user_labels[][2][31]);
00708 
00722 MTZCOL **ccp4_lrassn(const MTZ *mtz, const char labels[][31], const int nlabels, 
00723                 char types[][3]);
00724 
00738 int ccp4_lridx(const MTZ *mtz, const MTZSET *set, char crystal_name[64], 
00739             char dataset_name[64], char project_name[64], int *isets, 
00740             float datcell[6], float *datwave);
00741 
00757 int ccp4_lrrefl(const MTZ *mtz, float *resol, float adata[], int logmss[], int iref);
00758 
00775 int ccp4_lrreff(const MTZ *mtz, float *resol, float adata[], int logmss[],
00776                 const MTZCOL *lookup[], const int ncols, const int iref);
00777 
00785 int ccp4_ismnf(const MTZ *mtz, const float datum);
00786 
00792 int ccp4_lhprt(const MTZ *mtz, int iprint);
00793 
00800 int ccp4_lhprt_adv(const MTZ *mtz, int iprint);
00801 
00809 int ccp4_lrbat(MTZBAT *batch, float *buf, char *charbuf, int iprint);
00810 
00815 int MtzPrintBatchHeader(const MTZBAT *batch);
00816 
00824 int ccp4_lwtitl(MTZ *mtz, const char *ftitle, int flag);
00825 
00835 int MtzSetSortOrder(MTZ *mtz, MTZCOL *colsort[5]);
00836 
00843 int MtzAddHistory(MTZ *mtz, const char history[][MTZRECORDLENGTH], const int nlines);
00844 
00859 int ccp4_lwsymm(MTZ *mtz, int nsymx, int nsympx, float rsymx[192][4][4], 
00860                 char ltypex[], int nspgrx, char spgrnx[], char pgnamx[]);
00861 
00874 MTZCOL **ccp4_lwassn(MTZ *mtz, const char labels[][31], const int nlabels, 
00875              const char types[][3], const int iappnd);
00876 
00893 int ccp4_lwidx(MTZ *mtz, const char crystal_name[],  const char dataset_name[],
00894         const char project_name[], const float datcell[6], const float *datwave);
00895 
00896 
00909 int ccp4_lwrefl(MTZ *mtz, const float adata[], MTZCOL *lookup[], 
00910                  const int ncol, const int iref);
00911 
00925 int ccp4_lwbat(MTZ *mtz, MTZBAT *batch, const int batno, const float *buf, const char *charbuf);
00926 
00933 int ccp4_lwbsetid(MTZ *mtz, MTZBAT *batch, const char xname[], const char dname[]);
00934 
00935 /* -- Below here there are no implementations -- */
00936 
00937 /* COMPLEX HLToSF(float hla, float hlb, float hlc, float hld, BOOLEAN centric); */
00938 /* Returns the mean structure factor as a complex number from a structure
00939    factor probability distribution described by Hendrickson/Lattman
00940    coefficients. If `centric == TRUE`, the coefficients describe a centric
00941    distribution. */
00942 
00943 /* MTZ *MtzSort(MTZ *mtz, char *ident); */
00944 /* Sorts `mtz` using the identifiers (separated by spaces) in `ident` as
00945    keys. Sorting can be done on up to 200 columns. A pointer to `*mtz` is
00946    returned. */
00947 
00948 /* MTZ *HLCombine (MTZ *to, float toscale, MTZ *frm, float frmscale); */
00949 /* Combines extra phase information for common reflections between 'frm'
00950    and 'to' into the phase information of 'to'. The phase probabilities
00951    are described by Hendrickson Lattman coefficients, with the identifiers
00952    "HLA", "HLB", HLC", and "HLD", the indices are identified by "H", "K" 
00953    and "L". HL-coeffs from 'to' are scaled by 'toscale', the coeffs from
00954    'frm' are scaled by 'frmscale'. A pointer to `to` is returned. */
00955 
00956 /* void MtzPhiFom(MTZ *mtz); */
00957 /* Calculates the best phase and the figure of from Hendrickson Lattman
00958    coefficients. The following columns should be present in `mtz`:
00959    "H", "K" & "L" (indices); "PHIB" & "FOM" (best phase (degrees) and figure of
00960    merit); "HLA", "HLB", "HLC" & "HLD" (Hendrickson Lattman coefficients). */
00961 
00962 /* MTZ *MtzCopy(MTZ *frm); */
00963 /* Produces an exact copy of `frm` and returns a pointer to it. */
00964 
00965 /* MTZ *MtzColAppend(MTZ *mtz, char *ident, char type); */
00966 /* Appends a column to `*mtz` with identity `ident` and type `type`, provided
00967    no column with identity `ident` exists. */
00968 
00969 /* MTZ *MtzColRemove(MTZ *mtz, char *ident); */
00970 /* Removes a column from `*mtz` with identity `ident`. */
00971 
00972 /* MTZ *MtzUpdateRanges(MTZ *mtz); */
00973 /* Updates ranges of all columns in `mtz` and returns `mtz`. */
00974 
00975 /* MTZCOL *MtzColNewRange(MTZCOL *col, int nref); */
00976 /* Updates the minimum & maximum values in `col` and returns `col`. */
00977 
00978 /* int *MtzUnique(MTZ *mtz, char *ident); */
00979 /* Returns an array (k) of indices: k[j] returns the first occurrence of a set
00980    of idents, eg. MtzUnique(mtz, "H K L") returns an array from which all the 
00981    unique reflections can be determined by indexing with k: k[i] is the index
00982    of the last relection of a set which all have the same hkl indices. It is
00983    assumed that `mtz` is sorted, using `ident` as keys. */
00984 
00985 /* float PhaseProb(float phase, float hla, float hlb, float hlc, float hld,
00986                 BOOLEAN centric); */
00987 /* Returns the probability of `phase` (expressed in radians) as determined by
00988    the Hendrickson-Lattman coefficients `hla`, `hlb`, `hlc` and `hld`. If
00989    `centric == TRUE`, the coefficients describe a centric distribution. */
00990 
00991 #ifdef __cplusplus
00992 } }
00993 #endif
00994 #endif
00995 
00996 /*
00997   Local variables:
00998   mode: font-lock
00999   End:
01000 */

Generated on Wed Oct 29 21:14:36 2008 for gpp4 by  doxygen 1.4.7