gpp4  1.3.1
Functions
cmtzlib.h File Reference

C-level library for input, output and manipulation of MTZ files. More...

#include "ccp4_utils.h"
#include "mtzdata.h"

Go to the source code of this file.

Functions

MTZMtzGet (const char *logname, int read_refs)
 
MTZMtzGetUserCellTolerance (const char *logname, int read_refs, const double cell_tolerance)
 
int MtzRrefl (CCP4File *filein, int ncol, float *refldata)
 
int MtzPut (MTZ *mtz, const char *logname)
 
CCP4FileMtzOpenForWrite (const char *logname)
 
int MtzWhdrLine (CCP4File *fileout, int nitems, char buffer[])
 
int MtzWrefl (CCP4File *fileout, int ncol, float *refldata)
 
int MtzDeleteRefl (MTZ *mtz, int iref)
 
void MtzRewdInput (MTZ *mtz)
 
MTZMtzMalloc (int nxtal, int nset[])
 
int MtzFree (MTZ *mtz)
 
MTZCOLMtzMallocCol (MTZ *mtz, int nref)
 
int MtzFreeCol (MTZCOL *col)
 
MTZBATMtzMallocBatch (void)
 
int MtzFreeBatch (MTZBAT *batch)
 
char * MtzCallocHist (int nhist)
 
int MtzFreeHist (char *hist)
 
void MtzMemTidy (void)
 
int MtzNbat (const MTZ *mtz)
 
int MtzNref (const MTZ *mtz)
 
int MtzSpacegroupNumber (const MTZ *mtz)
 
int MtzResLimits (const MTZ *mtz, float *minres, float *maxres)
 
int MtzNxtal (const MTZ *mtz)
 
int MtzNumActiveXtal (const MTZ *mtz)
 
MTZXTAL ** MtzXtals (MTZ *mtz)
 
MTZXTALMtzIxtal (const MTZ *mtz, const int ixtal)
 
char * MtzXtalPath (const MTZXTAL *xtal)
 
MTZXTALMtzXtalLookup (const MTZ *mtz, const char *label)
 
MTZXTALMtzAddXtal (MTZ *mtz, const char *xname, const char *pname, const float cell[6])
 
int MtzNsetsInXtal (const MTZXTAL *xtal)
 
int MtzNumActiveSetsInXtal (const MTZ *mtz, const MTZXTAL *xtal)
 
MTZSET ** MtzSetsInXtal (MTZXTAL *xtal)
 
MTZSETMtzIsetInXtal (const MTZXTAL *xtal, const int iset)
 
int MtzNset (const MTZ *mtz)
 
int MtzNumActiveSet (const MTZ *mtz)
 
MTZXTALMtzSetXtal (const MTZ *mtz, const MTZSET *set)
 
char * MtzSetPath (const MTZ *mtz, const MTZSET *set)
 
MTZSETMtzSetLookup (const MTZ *mtz, const char *label)
 
MTZSETMtzAddDataset (MTZ *mtz, MTZXTAL *xtl, const char *dname, const float wavelength)
 
int MtzNcolsInSet (const MTZSET *set)
 
int MtzNumActiveColsInSet (const MTZSET *set)
 
int MtzNumSourceColsInSet (const MTZSET *set)
 
int MtzNbatchesInSet (const MTZ *mtz, const MTZSET *set)
 
MTZCOL ** MtzColsInSet (MTZSET *set)
 
MTZCOLMtzIcolInSet (const MTZSET *set, const int icol)
 
MTZCOLMtzAddColumn (MTZ *mtz, MTZSET *set, const char *label, const char *type)
 
int MtzAssignHKLtoBase (MTZ *mtz)
 
int MtzAssignColumn (MTZ *mtz, MTZCOL *col, const char crystal_name[], const char dataset_name[])
 
int MtzToggleColumn (MTZCOL *col)
 
MTZSETMtzColSet (const MTZ *mtz, const MTZCOL *col)
 
int MtzNcol (const MTZ *mtz)
 
int MtzNumActiveCol (const MTZ *mtz)
 
int MtzNumSourceCol (const MTZ *mtz)
 
char * MtzColPath (const MTZ *mtz, const MTZCOL *col)
 
int MtzRJustPath (char *path, const char *partial, const int njust)
 
int MtzPathMatch (const char *path1, const char *path2)
 
MTZCOLMtzColLookup (const MTZ *mtz, const char *label)
 
char * MtzColType (MTZCOL *col)
 
void MtzDebugHierarchy (const MTZ *mtz)
 
int MtzListColumn (const MTZ *mtz, char clabs[][31], char ctyps[][3], int csetid[])
 
int MtzListInputColumn (const MTZ *mtz, char clabs[][31], char ctyps[][3], int csetid[])
 
int MtzFindInd (const MTZ *mtz, int *ind_xtal, int *ind_set, int ind_col[3])
 
float MtzInd2reso (const int in[3], const double coefhkl[6])
 
int MtzHklcoeffs (const float cell[6], double coefhkl[6])
 
int MtzArrayToBatch (const int *intbuf, const float *fltbuf, MTZBAT *batch)
 
int MtzBatchToArray (MTZBAT *batch, int *intbuf, float *fltbuf)
 
MTZBATsort_batches (MTZBAT *batch, int numbat)
 
int ccp4_lrtitl (const MTZ *mtz, char *title)
 
int ccp4_lrhist (const MTZ *mtz, char history[][MTZRECORDLENGTH], int nlines)
 
int ccp4_lrsort (const MTZ *mtz, int isort[5])
 
int ccp4_lrbats (const MTZ *mtz, int *nbatx, int batchx[])
 
int ccp4_lrcell (const MTZXTAL *xtl, float cell[])
 
int ccp4_lrsymi (const MTZ *mtz, int *nsympx, char *ltypex, int *nspgrx, char *spgrnx, char *pgnamx)
 
int ccp4_lrsymi_c (const MTZ *mtz, int *nsympx, char *ltypex, int *nspgrx, char *spgrnx, char *pgnamx, char *spgconf)
 
int ccp4_lrsymm (const MTZ *mtz, int *nsymx, float rsymx[192][4][4])
 
int MtzParseLabin (char *labin_line, const char prog_labels[][31], const int nlprgi, char user_labels[][2][31])
 
MTZCOL ** ccp4_lrassn (const MTZ *mtz, const char labels[][31], const int nlabels, char types[][3])
 
int ccp4_lridx (const MTZ *mtz, const MTZSET *set, char crystal_name[64], char dataset_name[64], char project_name[64], int *isets, float datcell[6], float *datwave)
 
int ccp4_lrrefl (const MTZ *mtz, float *resol, float adata[], int logmss[], int iref)
 
int ccp4_lrreff (const MTZ *mtz, float *resol, float adata[], int logmss[], const MTZCOL *lookup[], const int ncols, const int iref)
 
int ccp4_ismnf (const MTZ *mtz, const float datum)
 
int ccp4_lhprt (const MTZ *mtz, int iprint)
 
int ccp4_lhprt_adv (const MTZ *mtz, int iprint)
 
int ccp4_lrbat (MTZBAT *batch, float *buf, char *charbuf, int iprint)
 
int MtzPrintBatchHeader (const MTZBAT *batch)
 
int ccp4_lwtitl (MTZ *mtz, const char *ftitle, int flag)
 
int MtzSetSortOrder (MTZ *mtz, MTZCOL *colsort[5])
 
int MtzAddHistory (MTZ *mtz, const char history[][MTZRECORDLENGTH], const int nlines)
 
int ccp4_lwsymm (MTZ *mtz, int nsymx, int nsympx, float rsymx[192][4][4], char ltypex[], int nspgrx, char spgrnx[], char pgnamx[])
 
int ccp4_lwsymm_c (MTZ *mtz, int nsymx, int nsympx, float rsymx[192][4][4], char ltypex[], int nspgrx, char spgrnx[], char pgnamx[], char spgconf[])
 
int ccp4_lwsymconf (MTZ *mtz, char spgconf[])
 
MTZCOL ** ccp4_lwassn (MTZ *mtz, const char labels[][31], const int nlabels, const char types[][3], const int iappnd)
 
int ccp4_lwidx (MTZ *mtz, const char crystal_name[], const char dataset_name[], const char project_name[], const float datcell[6], const float *datwave)
 
int ccp4_lwrefl (MTZ *mtz, const float adata[], MTZCOL *lookup[], const int ncol, const int iref)
 
int ccp4_lwbat (MTZ *mtz, MTZBAT *batch, const int batno, const float *buf, const char *charbuf)
 
int ccp4_lwbsetid (MTZ *mtz, MTZBAT *batch, const char xname[], const char dname[])
 

Detailed Description

C-level library for input, output and manipulation of MTZ files.

Functions defining the C-level API for accessing MTZ files. MtzGet and MtzPut read and write MTZ files to/from a data structure defined in mtzdata.h Other functions allow one to access data structure members, and to manipulate the structure and the values of structure members. Functions with names beginning ccp4_lr or ccp4_lw are primarily to support the Fortran API.

Author
Martyn Winn

Function Documentation

int ccp4_ismnf ( const MTZ mtz,
const float  datum 
)

Checks whether a particular reflection value represents missing data.

Parameters
mtzPointer to the MTZ struct, which holds the value representing missing data (the Missing Number Flag) against which the input datum is compared.
datumReflection value to be checked.
Returns
Returns 1 is datum is the MNF, and 0 otherwise.

References ccp4_utils_isnan(), and MTZ::mnf.

Referenced by ccp4_lrreff(), ccp4_lrrefl(), ccp4_lwrefl(), and FORTRAN_SUBR().

int ccp4_lhprt ( const MTZ mtz,
int  iprint 
)
int ccp4_lhprt_adv ( const MTZ mtz,
int  iprint 
)

Function to print header information in format appropriate to data structure hierarchy.

Parameters
mtzPointer to MTZ struct
iprintPrint level
Returns
1 on success, 0 on failure

References MTZXTAL::cell, MTZSET::col, MTZSET::dname, MTZ::hist, MTZ::histlines, float_uint_uchar::i, MTZCOL::label, MTZ::mnf, MTZRECORDLENGTH, MTZ::mtzsymm, MTZSET::ncol, MTZ::nref, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::pname, MTZXTAL::set, SYMGRP::spcgrp, MTZ::title, MTZCOL::type, MTZSET::wavelength, MTZXTAL::xname, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

MTZCOL** ccp4_lrassn ( const MTZ mtz,
const char  labels[][31],
const int  nlabels,
char  types[][3] 
)

Finds columns in an MTZ struct according to column labels. Column types are checked for agreement between requested type (in argument 'types') and file type. If requested type is blank, file type is returned in argument 'types'. Note, this function is different from Fortranic LRASSN, in that any conversion from program labels to user labels should have been done previously.

Parameters
mtzPointer to MTZ struct.
labelsInput array of column labels to be found in MTZ struct.
nlabelsNumber of columns to be found.
typesInput array of column types of columns to be found.
Returns
Array of pointers to columns in MTZ struct. Array element is NULL if column not found.

References ccp4_signal(), ccp4_utils_malloc(), MTZCOL::label, MtzColLookup(), and MTZCOL::type.

Referenced by FORTRAN_SUBR().

int ccp4_lrbat ( MTZBAT batch,
float *  buf,
char *  charbuf,
int  iprint 
)

Function to return batch header data for a specified batch.

Parameters
batchPointer to requested batch.
bufOn return, real and integer batch data.
charbufOn return, character batch data (title and axes names).
iprint=0 no printing, =1 print title only, >1 print full header.
Returns
1 on success, 0 on failure

References bathead::gonlab, MtzBatchToArray(), MtzPrintBatchHeader(), NBATCHINTEGERS, NBATCHREALS, NBATCHWORDS, bathead::num, and bathead::title.

Referenced by FORTRAN_SUBR().

int ccp4_lrbats ( const MTZ mtz,
int *  nbatx,
int  batchx[] 
)

Get batch numbers from MTZ structure.

Parameters
mtzPointer to MTZ struct.
nbatxNumber of batches in input file.
batchxReturned array of batch numbers.
Returns
Number of batches.

References MTZ::batch, MTZ::n_orig_bat, bathead::next, and bathead::num.

Referenced by FORTRAN_SUBR().

int ccp4_lrcell ( const MTZXTAL xtl,
float  cell[] 
)

Get cell dimensions for a particular crystal.

Parameters
xtlPointer to crystal.
cellOutput cell dimensions.
Returns
1 on success, 0 on failure.

References MTZXTAL::cell.

Referenced by FORTRAN_SUBR().

int ccp4_lrhist ( const MTZ mtz,
char  history[][MTZRECORDLENGTH],
int  nlines 
)

Get history lines from MTZ structure.

Parameters
mtzPointer to MTZ struct.
historyReturned history lines.
nlinesRequested number of history lines.
Returns
Actual number of history lines returned.

References MTZ::hist, and MTZ::histlines.

Referenced by FORTRAN_SUBR().

int ccp4_lridx ( const MTZ mtz,
const MTZSET set,
char  crystal_name[64],
char  dataset_name[64],
char  project_name[64],
int *  isets,
float  datcell[6],
float *  datwave 
)

Report information on a particular dataset. This represents the collection of data held in one series of dataset records in the MTZ header. It is mainly useful for supporting old Fortran calls.

Parameters
mtzpointer to MTZ struct
setpointer to dataset
crystal_nameCrystal name
dataset_nameDataset name
project_nameProject name
isetsDataset ID.
datcellCell dimensions of crystal that dataset belongs to.
datwaveX-ray wavelength associated with dataset.
Returns
1 on success, 0 on failure

References MTZXTAL::cell, MtzSetXtal(), MTZXTAL::pname, and MTZXTAL::xname.

Referenced by FORTRAN_SUBR().

int ccp4_lrreff ( const MTZ mtz,
float *  resol,
float  adata[],
int  logmss[],
const MTZCOL lookup[],
const int  ncols,
const int  iref 
)

Returns iref'th reflection from file held in MTZ struct mtz. Returns data for certain columns held in input file, as specified by the column pointers held in lookup. In "in-memory" mode, reflection data is taken from arrays held in memory. In the traditional file-based mode, a reflection record is read from the input file.

Parameters
mtzpointer to MTZ struct
resolresolution of reflection (output).
adataarray of requested values (output).
logmssarray of flags for missing data (output). A value of 1 indicates a Missing Number Flag, and a value of 0 indicates usable data.
lookuparray of pointers to requested columns
ncolsnumber of requested columns
irefindex of requested reflection (starting at 1).
Returns
1 if past last reflection, else 0

References ccp4_ismnf(), ccp4_nan(), ccp4_utils_malloc(), MTZXTAL::cell, MTZSET::col, float_uint_uchar::f, MTZ::filein, MTZ::mnf, MtzFindInd(), MtzHklcoeffs(), MtzInd2reso(), MtzRrefl(), MTZ::ncol_read, MTZ::nref_filein, MTZ::nxtal, MTZCOL::ref, MTZ::refs_in_memory, MTZXTAL::resmax, MTZXTAL::resmin, MTZXTAL::set, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int ccp4_lrrefl ( const MTZ mtz,
float *  resol,
float  adata[],
int  logmss[],
int  iref 
)

Returns iref'th reflection from file held in MTZ struct mtz. Returns data for all columns held in input file, in the order that they are held in the source file. The value of col->source can be used to find particular columns. In "in-memory" mode, reflection data is taken from arrays held in memory. In the traditional file-based mode, a reflection record is read from the input file.

Parameters
mtzpointer to MTZ struct
resolresolution of reflection (output).
adataarray of requested values (output).
logmssarray of flags for missing data (output). A value of 1 indicates a Missing Number Flag, and a value of 0 indicates usable data.
irefindex of requested reflection (starting at 1).
Returns
1 if past last reflection, else 0

References ccp4_ismnf(), ccp4_utils_malloc(), MTZXTAL::cell, MTZSET::col, MTZ::filein, MTZCOL::label, MtzHklcoeffs(), MtzInd2reso(), MtzRrefl(), MTZSET::ncol, MTZ::ncol_read, MTZ::nref_filein, MTZXTAL::nset, MTZ::nxtal, MTZCOL::ref, MTZ::refs_in_memory, MTZXTAL::resmax, MTZXTAL::resmin, MTZXTAL::set, MTZCOL::source, MTZCOL::type, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int ccp4_lrsort ( const MTZ mtz,
int  isort[5] 
)

Get sort order from MTZ structure.

Parameters
mtzPointer to MTZ struct.
isortReturned sort order.
Returns
1 on success, 0 on failure

References MTZSET::col, MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZ::order, MTZXTAL::set, and MTZ::xtal.

Referenced by ccp4_lhprt(), FORTRAN_SUBR(), and MtzPut().

int ccp4_lrsymi ( const MTZ mtz,
int *  nsympx,
char *  ltypex,
int *  nspgrx,
char *  spgrnx,
char *  pgnamx 
)

Get spacegroup information as held in MTZ header.

Parameters
mtzPointer to MTZ struct.
nsympxNumber of primitive symmetry operators.
ltypexLattice type (P,A,B,C,I,F,R).
nspgrxSpacegroup number.
spgrnxSpacegroup name.
pgnamxPointgroup name.
Returns
Spacegroup number.

References ccp4_lrsymi_c().

Referenced by FORTRAN_SUBR().

int ccp4_lrsymi_c ( const MTZ mtz,
int *  nsympx,
char *  ltypex,
int *  nspgrx,
char *  spgrnx,
char *  pgnamx,
char *  spgconf 
)

Get spacegroup information as held in MTZ header. Extended version of ccp4_lrsymi to return confidence flag as well.

Parameters
mtzPointer to MTZ struct.
nsympxNumber of primitive symmetry operators.
ltypexLattice type (P,A,B,C,I,F,R).
nspgrxSpacegroup number.
spgrnxSpacegroup name.
pgnamxPointgroup name.
spgconfOne-character flag indicating confidence in nominal spacegroup.
Returns
Spacegroup number.

References MTZ::mtzsymm, SYMGRP::nsymp, SYMGRP::pgname, SYMGRP::spcgrp, SYMGRP::spcgrpname, SYMGRP::spg_confidence, and SYMGRP::symtyp.

Referenced by ccp4_lrsymi(), and FORTRAN_SUBR().

int ccp4_lrsymm ( const MTZ mtz,
int *  nsymx,
float  rsymx[192][4][4] 
)

Get symmetry matrices from MTZ structure. Note: ordering of matrices in rsymx was changed in April 2004.

Parameters
mtzPointer to MTZ struct.
nsymxNumber of symmetry operators held in MTZ header.
rsymxSymmetry operators as 4 x 4 matrices, in the order they are held in the MTZ header. Each matrix has translations in elements [*][3].
Returns
Number of symmetry operators.

References MTZ::mtzsymm, SYMGRP::nsym, and SYMGRP::sym.

Referenced by FORTRAN_SUBR().

int ccp4_lrtitl ( const MTZ mtz,
char *  title 
)

Returns title of MTZ structure 'mtz'

Parameters
mtzpointer to MTZ struct
titleMTZ title as character string
Returns
length of title excluding trailing blanks and terminating null character.

References MTZ::title.

Referenced by FORTRAN_SUBR().

int ccp4_lwbat ( MTZ mtz,
MTZBAT batch,
const int  batno,
const float *  buf,
const char *  charbuf 
)

Write new batch information to 'batch' or if 'batch' is NULL create new batch header with batch number 'batno'. If you try to create more than one new batch header with the same batch number, the function will complain and return. It is OK to create a new batch with the same number as one read from file - this is the mechanism for changing batch headers.

Parameters
mtzpointer to MTZ struct
batchpointer to batch
batnobatch number
bufpointer to batch array
charbufpointer to character batch array
Returns
1 on success, 0 on failure

References MTZ::batch, bathead::gonlab, float_uint_uchar::i, MtzArrayToBatch(), MtzMallocBatch(), MtzSetLookup(), MtzXtalLookup(), MTZ::n_orig_bat, NBATCHINTEGERS, bathead::nbsetid, bathead::next, bathead::num, bathead::title, and MTZXTAL::xname.

Referenced by FORTRAN_SUBR().

int ccp4_lwrefl ( MTZ mtz,
const float  adata[],
MTZCOL lookup[],
const int  ncol,
const int  iref 
)

Function to output reflection values for iref'th reflection. The reflection values are provided in an array "adata". The value in adata[i] will be assigned to the MTZ column pointed to by lookup[i]. Typically, lookup[i] is a pointer returned from an earlier call to MtzAddColumn(). In "in-memory" mode, values are added/updated to column data held in memory. In the traditional file-based mode, a reflection record is written to file. This function will also update the column ranges and the crystal/file resolution limits.

Parameters
mtzpointer to MTZ struct
adataarray of reflection column values.
lookuparray of pointers to columns.
ncolnumber of columns.
irefReflection number such that 1st reflection is iref=1.
Returns
1 on success, 0 on failure

References MTZCOL::active, ccp4_ismnf(), ccp4array_resize, ccp4array_size, MTZXTAL::cell, MTZSET::col, MTZ::fileout, float_uint_uchar::i, MTZCOL::max, MCOLUMNS, MTZCOL::min, MtzFindInd(), MtzHklcoeffs(), MtzInd2reso(), MtzWrefl(), MTZSET::ncol, MTZ::nref, MTZXTAL::nset, MTZ::nxtal, MTZCOL::ref, MTZ::refs_in_memory, MTZXTAL::resmax, MTZ::resmax_out, MTZXTAL::resmin, MTZ::resmin_out, MTZXTAL::set, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int ccp4_lwsymconf ( MTZ mtz,
char  spgconf[] 
)

Write or update symmetry confidence information for MTZ header.

Parameters
mtzPointer to MTZ struct
spgconfOne-character flag indicating confidence in nominal spacegroup.
Returns
1 on success, 0 on failure

References MTZ::mtzsymm, and SYMGRP::spg_confidence.

Referenced by FORTRAN_SUBR().

int ccp4_lwsymm ( MTZ mtz,
int  nsymx,
int  nsympx,
float  rsymx[192][4][4],
char  ltypex[],
int  nspgrx,
char  spgrnx[],
char  pgnamx[] 
)

Write or update symmetry information for MTZ header. This provides support for the Fortran API, and is not particularly convenient for C programs. Note: ordering of matrices in rsymx was changed in November 2003.

Parameters
mtzPointer to MTZ struct
nsymxNumber of symmetry operators. If zero, symmetry operations are not updated.
nsympxNumber of primitive symmetry operators.
rsymxArray of symmetry operators (dimensions ordered in C convention, with translations in elements [*][3])
ltypexLattice type. If blank, not updated.
nspgrxSpacegroup number. If zero, not updated.
spgrnxSpacegroup name. If blank, not updated.
pgnamxPoint group name. If blank, not updated.
Returns
1 on success, 0 on failure

References ccp4_lwsymm_c().

Referenced by FORTRAN_SUBR().

int ccp4_lwsymm_c ( MTZ mtz,
int  nsymx,
int  nsympx,
float  rsymx[192][4][4],
char  ltypex[],
int  nspgrx,
char  spgrnx[],
char  pgnamx[],
char  spgconf[] 
)

Write or update symmetry information for MTZ header. This provides support for the Fortran API, and is not particularly convenient for C programs. Extended version of ccp4_lwsymm to set confidence flag as well. Note: ordering of matrices in rsymx was changed in November 2003.

Parameters
mtzPointer to MTZ struct
nsymxNumber of symmetry operators. If zero, symmetry operations are not updated.
nsympxNumber of primitive symmetry operators.
rsymxArray of symmetry operators (dimensions ordered in C convention, with translations in elements [*][3])
ltypexLattice type. If blank, not updated.
nspgrxSpacegroup number. If zero, not updated.
spgrnxSpacegroup name. If blank, not updated.
pgnamxPoint group name. If blank, not updated.
spgconfOne-character flag indicating confidence in nominal spacegroup.
Returns
1 on success, 0 on failure

References MTZCOL::active, ccp4_utils_malloc(), MTZSET::col, float_uint_uchar::i, MAXSPGNAMELENGTH, MtzAddColumn(), MtzColLookup(), MtzSetLookup(), MTZ::mtzsymm, MTZSET::ncol, MTZXTAL::nset, SYMGRP::nsym, SYMGRP::nsymp, MTZ::nxtal, SYMGRP::pgname, MTZXTAL::set, SYMGRP::spcgrp, SYMGRP::spcgrpname, SYMGRP::spg_confidence, SYMGRP::sym, SYMGRP::symtyp, and MTZ::xtal.

Referenced by ccp4_lwsymm().

int ccp4_lwtitl ( MTZ mtz,
const char *  ftitle,
int  flag 
)

Write header title for later output to file.

Parameters
mtzPointer to MTZ struct.
ftitleTitle string.
flagIf 0 overwrite existing title, else append to existing title.
Returns
1 on success, 0 on failure

References MTZ::title.

Referenced by FORTRAN_SUBR().

MTZCOL* MtzAddColumn ( MTZ mtz,
MTZSET set,
const char *  label,
const char *  type 
)

Add a column to dataset set and create + fill with NAN

Parameters
mtzpointer to MTZ struct
setpointer to dataset
labelColumn label
typeColumn type
Returns
pointer to column

References ccp4_nan(), ccp4_signal(), ccp4array_resize, ccp4array_size, float_uint_uchar::f, float_uint_uchar::i, MCOLUMNS, MTZ::mnf, MtzMallocCol(), MTZ::nref, and MTZ::refs_in_memory.

Referenced by ccp4_lwsymm_c(), and MtzGetUserCellTolerance().

MTZSET* MtzAddDataset ( MTZ mtz,
MTZXTAL xtl,
const char *  dname,
const float  wavelength 
)

Add a dataset to crystal xtl

Parameters
mtzpointer to MTZ struct.
xtlpointer to crystal struct.
dnameDataset name
wavelengthX-ray wavelength of dataset
Returns
pointer to set

References ccp4_signal(), ccp4_utils_malloc(), ccp4array_new_size, ccp4array_resize, ccp4array_size, float_uint_uchar::i, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZSET::setid, and MTZ::xtal.

Referenced by MtzAddHistory(), MtzAssignColumn(), and MtzMalloc().

int MtzAddHistory ( MTZ mtz,
const char  history[][MTZRECORDLENGTH],
const int  nlines 
)

Adds history lines to the MTZ header in front of existing history lines.

Parameters
mtzpointer to MTZ struct
historylines to be added
nlinesnumber of lines to be added
Returns
total number of history lines

References MTZXTAL::cell, MTZ::hist, MTZ::histlines, float_uint_uchar::i, MtzAddDataset(), MtzAddXtal(), MtzCallocHist(), MtzFreeHist(), MTZRECORDLENGTH, MtzSetLookup(), MtzXtalLookup(), MTZXTAL::pname, and MTZXTAL::xname.

Referenced by FORTRAN_SUBR().

MTZXTAL* MtzAddXtal ( MTZ mtz,
const char *  xname,
const char *  pname,
const float  cell[6] 
)

Add a crystal to header mtz.

Parameters
mtzpointer to MTZ struct
xnameCrystal name.
pnameName of associated project.
cellCell dimensions of crystal.
Returns
Pointer to crystal.

References ccp4_signal(), ccp4_utils_malloc(), ccp4array_new_size, ccp4array_resize, ccp4array_size, MTZXTAL::cell, float_uint_uchar::i, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::pname, MTZXTAL::resmax, MTZXTAL::resmin, MTZXTAL::set, MTZXTAL::xname, MTZ::xtal, and MTZXTAL::xtalid.

Referenced by MtzAddHistory(), MtzAssignColumn(), and MtzMalloc().

int MtzArrayToBatch ( const int *  intbuf,
const float *  fltbuf,
MTZBAT batch 
)
int MtzAssignColumn ( MTZ mtz,
MTZCOL col,
const char  crystal_name[],
const char  dataset_name[] 
)

Assigns a column to a dataset identified by crystal_name and dataset_name. First, the function checks whether the column already belongs to this dataset, in which case it does nothing. Then it checks if the requested dataset exists. If not, it is created, though it is better to explicitly create it beforehand. Finally, the column is assigned to the dataset.

Parameters
mtzpointer to MTZ struct
colpointer to column
crystal_namename of crystal containing dataset
dataset_namename of dataset
Returns
1 on success, 0 on failure

References ccp4_signal(), ccp4array_resize, ccp4array_size, MTZSET::col, float_uint_uchar::i, MtzAddDataset(), MtzAddXtal(), MtzColSet(), MtzPathMatch(), MtzSetLookup(), MtzSetPath(), MtzXtalLookup(), and MTZSET::ncol.

Referenced by FORTRAN_SUBR(), and MtzAssignHKLtoBase().

int MtzAssignHKLtoBase ( MTZ mtz)

Assigns HKL columns to the base dataset.

Parameters
mtzpointer to MTZ struct
Returns
1 on success, 0 on failure

References MTZSET::col, float_uint_uchar::i, MtzAssignColumn(), MtzSetLookup(), MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZCOL::type, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int MtzBatchToArray ( MTZBAT batch,
int *  intbuf,
float *  fltbuf 
)
char* MtzCallocHist ( int  nhist)

Allocates memory for the mtz history with 'nhist' lines.

Parameters
nhist
Returns
pointer to history

References ccp4_utils_calloc(), and MTZRECORDLENGTH.

Referenced by MtzAddHistory(), and MtzGetUserCellTolerance().

MTZCOL* MtzColLookup ( const MTZ mtz,
const char *  label 
)

Returns a pointer to the column of mtz with the given label, or NULL

Parameters
mtzpointer to MTZ struct
labelColumn label.
Returns
pointer to column

References float_uint_uchar::c, MTZSET::col, MtzColPath(), MtzPathMatch(), MtzRJustPath(), MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by ccp4_lrassn(), ccp4_lwsymm_c(), and FORTRAN_SUBR().

char* MtzColPath ( const MTZ mtz,
const MTZCOL col 
)

Return the full path name of a column as "/xname/dname/label" Memory for the path name is assigned with malloc, and can be free'd by the calling function.

Parameters
mtzpointer to MTZ struct
colpointer to MTZ column.
Returns
full path name of column

References ccp4_utils_malloc(), MTZCOL::label, MtzColSet(), and MtzSetPath().

Referenced by MtzColLookup().

MTZSET* MtzColSet ( const MTZ mtz,
const MTZCOL col 
)

Get the dataset associated with a column.

Parameters
mtzpointer to MTZ struct
colpointer to column of interest
Returns
pointer to set containing column of interest, or NULL if "col" is not contained in "mtz".

References float_uint_uchar::c, MTZSET::col, MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by MtzAssignColumn(), and MtzColPath().

MTZCOL** MtzColsInSet ( MTZSET set)

For a given dataset, return array of pointers to columns in that dataset.

Parameters
setpointer to dataset
Returns
array of pointers to columns
char* MtzColType ( MTZCOL col)

Get the MTZ column type of a particular column.

Parameters
colpointer to MTZ column.
Returns
column type

References MTZCOL::type.

void MtzDebugHierarchy ( const MTZ mtz)

Print summary of current crystal/dataset/column hierarchy. This is designed for debugging purposes rather than for the user.

Parameters
mtzpointer to MTZ struct
Returns
void

References MTZCOL::active, MTZXTAL::cell, MTZSET::col, MTZSET::dname, MTZ::filein, MTZ::fileout, MTZCOL::label, MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZSET::setid, MTZCOL::source, MTZXTAL::xname, and MTZ::xtal.

int MtzDeleteRefl ( MTZ mtz,
int  iref 
)

Delete a reflection from the data structure. Beware, there is no going back!

Parameters
mtzpointer to MTZ struct.
irefindex of reflection
Returns
0 if successful, 1 otherwise

References ccp4array_delete_ordered, MTZSET::col, float_uint_uchar::i, MTZSET::ncol, MTZ::nref, MTZXTAL::nset, MTZ::nxtal, MTZCOL::ref, MTZ::refs_in_memory, MTZXTAL::set, and MTZ::xtal.

int MtzFindInd ( const MTZ mtz,
int *  ind_xtal,
int *  ind_set,
int  ind_col[3] 
)

Find where indices h, k, l are in MTZ structure. Usually, they will be first 3 columns of 1st dataset, but safest not to assume this.

Parameters
mtzpointer to MTZ struct
ind_xtalcrystal containing indices
ind_setdataset containing indices
ind_col3 columns containing indices
Returns
1 on success, 0 on failure

References MTZSET::col, MTZCOL::label, MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZCOL::type, and MTZ::xtal.

Referenced by ccp4_lrreff(), ccp4_lwrefl(), MtzGetUserCellTolerance(), and MtzPut().

int MtzFree ( MTZ mtz)

Frees the memory reserved for the MTZ header struct.

Parameters
mtzpointer to MTZ header struct.
Returns
1 on success, 0 on failure

References MTZ::batch, ccp4_file_close(), ccp4array_free, MTZSET::col, MTZ::filein, MTZ::fileout, MTZ::hist, float_uint_uchar::i, MtzFreeBatch(), MtzFreeCol(), MtzFreeHist(), MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZ::unknown_headers, MTZ::xml, and MTZ::xtal.

Referenced by FORTRAN_SUBR(), and MtzMemTidy().

int MtzFreeBatch ( MTZBAT batch)

Frees the memory reserved for 'batch'.

Parameters
batch
Returns
1 on success, 0 on failure

References bathead::next.

Referenced by FORTRAN_SUBR(), and MtzFree().

int MtzFreeCol ( MTZCOL col)

Frees the memory reserved for 'col'

Parameters
colpointer to MTZ column.
Returns
1 on success, 0 on failure

References ccp4array_free, and MTZCOL::ref.

Referenced by MtzFree().

int MtzFreeHist ( char *  hist)

Frees the memory reserved for 'hist'.

Parameters
hist
Returns
1 on success, 0 on failure

Referenced by MtzAddHistory(), and MtzFree().

MTZ* MtzGet ( const char *  logname,
int  read_refs 
)

Reads the contents of the MTZ file into an MTZ structure.

Parameters
logname(I) Logical name of MTZ file
read_refs(I) Whether to read reflections into memory (non-zero) or to read later from file (zero)
Returns
Pointer to MTZ struct

References MtzGetUserCellTolerance().

Referenced by FORTRAN_SUBR().

MTZ* MtzGetUserCellTolerance ( const char *  logname,
int  read_refs,
const double  cell_tolerance 
)

Reads the contents of the MTZ file into an MTZ structure. As for function MtzGet except for extra argument cell_tolerance.

Parameters
logname(I) Logical name of MTZ file
read_refs(I) Whether to read reflections into memory (non-zero) or to read later from file (zero)
cell_tolerance(I) User-defined tolerance for ccp4uc_cells_differ. Setting this to zero means that a new crystal is generated whenever dataset cell dimensions are different. MtzGet allows for a certain variation within a single crystal.
Returns
Pointer to MTZ struct

References MTZ::batch, ccp4_file_close(), ccp4_file_length(), ccp4_file_open(), ccp4_file_rarch(), ccp4_file_read(), ccp4_file_readchar(), ccp4_file_seek(), ccp4_file_setmode(), ccp4_file_setstamp(), ccp4_file_tell(), ccp4_keymatch(), ccp4_liberr_verbosity(), ccp4_parse_end(), ccp4_parse_start(), ccp4_parser(), ccp4_signal(), ccp4_utils_malloc(), ccp4_utils_realloc(), ccp4uc_cells_differ(), MTZXTAL::cell, MTZSET::col, MTZCOL::colsource, MTZSET::dname, MTZ::filein, CCP4PARSERTOKEN::fullstring, bathead::gonlab, MTZCOL::grpname, MTZCOL::grpposn, MTZCOL::grptype, MTZ::hist, MTZ::histlines, CCP4PARSERARRAY::keyword, MTZCOL::label, MTZCOL::max, MCOLUMNS, MTZCOL::min, MTZ::mnf, MSETS, MTZ_MAJOR_VERSN, MTZ_MINOR_VERSN, MtzAddColumn(), MtzArrayToBatch(), MtzCallocHist(), MtzFindInd(), MtzHklcoeffs(), MtzInd2reso(), MtzMalloc(), MtzMallocBatch(), MTZRECORDLENGTH, MtzRrefl(), MTZ::mtzsymm, MXTALS, MTZ::n_orig_bat, MTZ::n_unknown_headers, NBATCHINTEGERS, NBATCHWORDS, MTZSET::ncol, MTZ::ncol_read, bathead::next, MTZ::nref, MTZ::nref_filein, MTZXTAL::nset, SYMGRP::nsym, SYMGRP::nsymp, bathead::num, MTZ::nxtal, MTZ::order, SYMGRP::pgname, MTZXTAL::pname, MTZCOL::ref, MTZ::refs_in_memory, MTZXTAL::resmax, MTZXTAL::resmin, MTZXTAL::set, MTZSET::setid, SIZE1, MTZCOL::source, SYMGRP::spcgrp, SYMGRP::spcgrpname, SYMGRP::spg_confidence, SYMGRP::sym, symop_to_mat4(), SYMGRP::symtyp, bathead::title, MTZ::title, CCP4PARSERARRAY::token, MTZ::unknown_headers, CCP4PARSERTOKEN::value, MTZSET::wavelength, MTZ::xml, MTZXTAL::xname, MTZ::xtal, and MTZXTAL::xtalid.

Referenced by MtzGet().

int MtzHklcoeffs ( const float  cell[6],
double  coefhkl[6] 
)

Generate coefhkl coefficients from given cell parameters.

Parameters
cellcell dimensions to be used for resolution calculation.
coefhkldouble array of 6 coefficients
Returns
1 on success, 0 on failure

References ccp4_signal().

Referenced by ccp4_lrreff(), ccp4_lrrefl(), ccp4_lwrefl(), FORTRAN_SUBR(), MtzGetUserCellTolerance(), and MtzPut().

MTZCOL* MtzIcolInSet ( const MTZSET set,
const int  icol 
)

For a given dataset, return pointer to the icol'th column in that dataset.

Parameters
setpointer to dataset
icolnumber of the particular column (icol = 0 ... MtzNcolsInSet(set) -1
Returns
pointer to specified column
float MtzInd2reso ( const int  in[3],
const double  coefhkl[6] 
)

Calculate resolution from indices and coefhkl. coefhkl is obtained from MtzHklcoeffs.

Parameters
ininteger array of 3 indices
coefhkldouble array of 6 coefficients
Returns
resolution

Referenced by ccp4_lrreff(), ccp4_lrrefl(), ccp4_lwrefl(), FORTRAN_SUBR(), MtzGetUserCellTolerance(), and MtzPut().

MTZSET* MtzIsetInXtal ( const MTZXTAL xtal,
const int  iset 
)

For a given crystal, return pointer to the iset'th dataset in that crystal.

Parameters
xtalpointer to the crystal struct
isetnumber of the particular dataset (iset = 0 ... MtzNsetsInXtal(xtal) -1
Returns
pointer to specified dataset

References MTZXTAL::set.

MTZXTAL* MtzIxtal ( const MTZ mtz,
const int  ixtal 
)

Return pointer to the ixtal'th crystal.

Parameters
mtzpointer to MTZ struct
ixtalnumber of the particular crystal (ixtal = 0 ... MtzNxtal(xtal) -1
Returns
pointer to the specified crystal

References MTZ::xtal.

int MtzListColumn ( const MTZ mtz,
char  clabs[][31],
char  ctyps[][3],
int  csetid[] 
)

List of column information: label, type, dataset.

Parameters
mtzpointer to MTZ struct
clabsList of labels (output).
ctypsList of column types (output).
csetidList of dataset IDs (output).
Returns
number of columns in current structure.

References MTZSET::col, MTZCOL::label, MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZSET::setid, MTZCOL::type, and MTZ::xtal.

int MtzListInputColumn ( const MTZ mtz,
char  clabs[][31],
char  ctyps[][3],
int  csetid[] 
)

List of column information from input file: label, type, dataset.

Parameters
mtzpointer to MTZ struct
clabsList of labels (output).
ctypsList of column types (output).
csetidList of dataset IDs (output).
Returns
number of columns in input file.

References MTZSET::col, MTZCOL::label, MTZSET::ncol, MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, MTZSET::setid, MTZCOL::source, MTZCOL::type, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

MTZ* MtzMalloc ( int  nxtal,
int  nset[] 
)

Allocates memory for an MTZ header structure. The structure can contain 0, 1 or more crystals, and for each crystal 0, 1 or more datasets. Crystals have a name based on the time "NULL_xnameHHMMSS" to ensure uniqueness (compared to crystals defined elsewhere - all new crystals created here will (probably) have the same name). Crystals have the project name "NULL_pname", and datasets have the name "NULL_dname".

Parameters
nxtalNumber of crystals to allocate.
nsetNumber of datasets for each crystal to allocate.
Returns
pointer to MTZ header struct

References MTZ::batch, ccp4_signal(), ccp4_utils_itime(), ccp4_utils_malloc(), ccp4array_new_size, MTZ::filein, MTZ::fileout, MTZ::hist, MTZ::histlines, float_uint_uchar::i, MTZ::mnf, MtzAddDataset(), MtzAddXtal(), MTZ::mtzsymm, MTZ::n_orig_bat, MTZ::n_unknown_headers, MTZ::ncol_read, MTZ::nref, MTZ::nref_filein, MTZXTAL::nset, SYMGRP::nsym, SYMGRP::nsymp, MTZ::nxtal, MTZ::order, SYMGRP::pgname, MTZ::refs_in_memory, MTZ::resmax_out, MTZ::resmin_out, SYMGRP::spcgrp, SYMGRP::spcgrpname, SYMGRP::spg_confidence, SYMGRP::symtyp, MTZ::title, MTZ::unknown_headers, MTZ::xml, and MTZ::xtal.

Referenced by FORTRAN_SUBR(), and MtzGetUserCellTolerance().

MTZBAT* MtzMallocBatch ( void  )

Allocates memory for a single batch header.

Returns
pointer to batch

References ccp4_signal(), ccp4_utils_malloc(), and bathead::next.

Referenced by ccp4_lwbat(), FORTRAN_SUBR(), and MtzGetUserCellTolerance().

MTZCOL* MtzMallocCol ( MTZ mtz,
int  nref 
)

Allocates memory for an MTZ column. Space is allocated for the reflection data if and only if mtz->refs_in_memory is set.

Parameters
mtzpointer to MTZ header struct.
nrefnumber of reflections in column.
Returns
pointer to MTZ column.

References ccp4_signal(), ccp4_utils_malloc(), ccp4array_new_size, MTZCOL::ref, and MTZ::refs_in_memory.

Referenced by MtzAddColumn().

void MtzMemTidy ( void  )

Free all memory malloc'd from static pointers. To be called before program exit. The function can be registered with atexit.

Returns
void

References MtzFree().

Referenced by ccp4f_mem_tidy().

int MtzNbat ( const MTZ mtz)

Get the number of batches in the mtz.

Parameters
mtzpointer to MTZ struct
Returns
Number of batches.

References MTZ::batch, and bathead::next.

Referenced by ccp4_lhprt(), FORTRAN_SUBR(), MtzNbatchesInSet(), and MtzPut().

int MtzNbatchesInSet ( const MTZ mtz,
const MTZSET set 
)

For a given dataset, return number of batches in that dataset.

Parameters
mtzpointer to MTZ struct
setpointer to dataset
Returns
number of batches

References MTZ::batch, float_uint_uchar::i, MtzNbat(), MTZ::n_orig_bat, bathead::nbsetid, and bathead::next.

Referenced by ccp4_lhprt(), MtzNumActiveSetsInXtal(), and MtzPut().

int MtzNcol ( const MTZ mtz)

Get the number of columns in the MTZ data structure.

Parameters
mtzpointer to MTZ struct
Returns
number of columns

References MtzNcolsInSet(), MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int MtzNcolsInSet ( const MTZSET set)

For a given dataset, return number of columns in that dataset. This is simply set->ncol and so includes all columns irrespective of col->active

Parameters
setpointer to dataset
Returns
number of columns

Referenced by MtzNcol().

int MtzNref ( const MTZ mtz)

Get the number of reflections in the mtz.

Parameters
mtzpointer to MTZ struct
Returns
Number of reflections.

References MTZ::nref.

Referenced by FORTRAN_SUBR().

int MtzNset ( const MTZ mtz)

Get the number of datasets in the MTZ structure

Parameters
mtzpointer to MTZ struct
Returns
total number of datasets

References MtzNsetsInXtal(), MTZ::nxtal, and MTZ::xtal.

int MtzNsetsInXtal ( const MTZXTAL xtal)

For a given crystal, return number of datasets in that crystal.

Parameters
xtalpointer to the crystal struct
Returns
number of datasets

References MTZXTAL::nset.

Referenced by MtzNset().

int MtzNumActiveCol ( const MTZ mtz)

Get the number of active columns in the MTZ data structure.

Parameters
mtzpointer to MTZ struct
Returns
number of columns

References MtzNumActiveColsInSet(), MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by ccp4_lhprt(), FORTRAN_SUBR(), and MtzPut().

int MtzNumActiveColsInSet ( const MTZSET set)

For a given dataset, return number of active columns in that dataset.

Parameters
setpointer to dataset
Returns
number of active columns

Referenced by ccp4_lhprt(), MtzNumActiveCol(), MtzNumActiveSetsInXtal(), and MtzPut().

int MtzNumActiveSet ( const MTZ mtz)

Get the number of active datasets in the MTZ structure

Parameters
mtzpointer to MTZ struct
Returns
total number of datasets

References MtzNumActiveSetsInXtal(), MTZ::nxtal, and MTZ::xtal.

Referenced by ccp4_lhprt(), and MtzPut().

int MtzNumActiveSetsInXtal ( const MTZ mtz,
const MTZXTAL xtal 
)

For a given crystal, return number of active datasets in that crystal.

Parameters
xtalpointer to the crystal struct
Returns
number of datasets

References MtzNbatchesInSet(), MtzNumActiveColsInSet(), MTZXTAL::nset, and MTZXTAL::set.

Referenced by MtzNumActiveSet(), MtzNumActiveXtal(), and MtzPut().

int MtzNumActiveXtal ( const MTZ mtz)

Get the number of active crystals in the MTZ structure

Parameters
mtzpointer to MTZ struct
Returns
number of active crystals

References MtzNumActiveSetsInXtal(), MTZ::nxtal, and MTZ::xtal.

int MtzNumSourceCol ( const MTZ mtz)

Get the number of columns in the MTZ data structure which have a source in an input file (i.e. non-zero source attribute).

Parameters
mtzpointer to MTZ struct
Returns
number of columns

References MtzNumSourceColsInSet(), MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int MtzNumSourceColsInSet ( const MTZSET set)

For a given dataset, return number of columns in that dataset which have a source in an input file (i.e. non-zero source attribute).

Parameters
setpointer to dataset
Returns
number of source columns

Referenced by MtzNumSourceCol().

int MtzNxtal ( const MTZ mtz)

Get the total number of crystals in the MTZ structure

Parameters
mtzpointer to MTZ struct
Returns
number of active crystals

References MTZ::nxtal.

CCP4File* MtzOpenForWrite ( const char *  logname)

Opens a new MTZ file for writing. The output file can be specified either with a true filename, or more likely as a logical name corresponding to an environment variable or a CCP4 command line argument such as HKLOUT.

Parameters
lognamelogical name or filename for output file.
Returns
pointer to file or NULL on failure

References ccp4_file_open(), ccp4_file_seek(), ccp4_file_setmode(), ccp4_file_setstamp(), ccp4_file_warch(), ccp4_file_write(), ccp4_file_writechar(), ccp4_signal(), and SIZE1.

Referenced by FORTRAN_SUBR(), and MtzPut().

int MtzParseLabin ( char *  labin_line,
const char  prog_labels[][31],
const int  nlprgi,
char  user_labels[][2][31] 
)

Uses LABIN or LABOUT line to convert program labels to user labels. This is a helper function, but does not access reflection structure at all.

Parameters
labin_line(I) LABIN/LABOUT line from Parser.
prog_labels(I) Progam labels.
nlprgi(I) Number of program labels.
user_labels(O) On output, user-supplied file labels in corresponding positions. For unassigned program labels, user_labels is empty string.
Returns
Number of program labels matched, or -1 if there was an error.

References ccp4_keymatch(), ccp4_parse_end(), ccp4_parse_start(), ccp4_parser(), ccp4_signal(), CCP4PARSERARRAY::keyword, and CCP4PARSERARRAY::token.

Referenced by FORTRAN_SUBR().

int MtzPathMatch ( const char *  path1,
const char *  path2 
)

Test for match between two paths, including wildcards

Parameters
path1First path
path2Second path
Returns
1 if paths match, else 0.

Referenced by MtzAssignColumn(), MtzColLookup(), MtzSetLookup(), and MtzXtalLookup().

int MtzPrintBatchHeader ( const MTZBAT batch)
int MtzPut ( MTZ mtz,
const char *  logname 
)

Writes an MTZ data structure to disk. If file is already open, MtzPut uses file pointer in mtz struct, else uses logical name of file.

Parameters
mtzpointer to MTZ struct.
lognamelogical name for output file or blank.
Returns
1 on success, 0 on failure

References MTZCOL::active, MTZ::batch, ccp4_file_close(), ccp4_file_seek(), ccp4_file_setmode(), ccp4_file_write(), ccp4_file_writechar(), ccp4_liberr_verbosity(), ccp4_lrsort(), ccp4_utils_idate(), ccp4_utils_itime(), MTZXTAL::cell, MTZSET::col, MTZCOL::colsource, MTZSET::dname, MTZ::fileout, bathead::gonlab, MTZCOL::grpname, MTZCOL::grpposn, MTZCOL::grptype, MTZ::hist, MTZ::histlines, float_uint_uchar::i, MTZCOL::label, mat4_to_symop(), MTZCOL::max, MAXSPGNAMELENGTH, MCOLUMNS, MTZCOL::min, MTZ::mnf, MTZ_MAJOR_VERSN, MTZ_MINOR_VERSN, MtzBatchToArray(), MtzFindInd(), MtzHklcoeffs(), MtzInd2reso(), MtzNbat(), MtzNbatchesInSet(), MtzNumActiveCol(), MtzNumActiveColsInSet(), MtzNumActiveSet(), MtzNumActiveSetsInXtal(), MtzOpenForWrite(), MTZRECORDLENGTH, MTZ::mtzsymm, MtzWhdrLine(), MtzWrefl(), MtzXtalLookup(), MTZ::n_orig_bat, MTZ::n_unknown_headers, NBATCHINTEGERS, NBATCHREALS, NBATCHWORDS, MTZSET::ncol, bathead::next, MTZ::nref, MTZXTAL::nset, SYMGRP::nsym, SYMGRP::nsymp, bathead::num, MTZ::nxtal, SYMGRP::pgname, MTZXTAL::pname, MTZCOL::ref, MTZ::refs_in_memory, MTZXTAL::resmax, MTZ::resmax_out, MTZXTAL::resmin, MTZ::resmin_out, MTZXTAL::set, MTZSET::setid, SIZE1, sort_batches(), MTZCOL::source, SYMGRP::spcgrp, SYMGRP::spcgrpname, SYMGRP::spg_confidence, SYMGRP::sym, SYMGRP::symtyp, bathead::title, MTZ::title, MTZCOL::type, MTZ::unknown_headers, MTZSET::wavelength, MTZ::xml, MTZXTAL::xname, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

int MtzResLimits ( const MTZ mtz,
float *  minres,
float *  maxres 
)

Return the overall resolution limits of the MTZ structure. These are the widest limits over all crystals present.

Parameters
mtzpointer to MTZ struct
minresminimum resolution
maxresmaximum resolution
Returns
1 on success, 0 on failure

References MTZ::nxtal, MTZXTAL::resmax, MTZXTAL::resmin, and MTZ::xtal.

Referenced by FORTRAN_SUBR().

void MtzRewdInput ( MTZ mtz)

Position input file at start of reflections. Useful if you need to read the reflections a second time.

Parameters
mtzpointer to MTZ struct.

References ccp4_file_seek(), MTZ::filein, and SIZE1.

int MtzRJustPath ( char *  path,
const char *  partial,
const int  njust 
)

Complete a right-justified path by prefixing with wildcards

Parameters
pathCompleted path.
partialPartial right-justified path
njust
Returns
1 on success, 0 on failure.

References float_uint_uchar::i.

Referenced by MtzColLookup(), MtzSetLookup(), and MtzXtalLookup().

int MtzRrefl ( CCP4File filein,
int  ncol,
float *  refldata 
)

Reads reflection data from MTZ file.

Parameters
fileinpointer to input file
ncolnumber of columns to read
refldataarray of reflection data
Returns
istat from ccp4_file_read

References ccp4_file_read(), and ccp4_file_setmode().

Referenced by ccp4_lrreff(), ccp4_lrrefl(), and MtzGetUserCellTolerance().

MTZSET* MtzSetLookup ( const MTZ mtz,
const char *  label 
)

Returns a pointer to the dataset of MTZ with the given label.

Parameters
mtzpointer to MTZ struct.
labelLabel of desired set. This could be <dname> or <xname>/<dname>.
Returns
pointer to set or NULL if not found

References MtzPathMatch(), MtzRJustPath(), MtzSetPath(), MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by ccp4_lhprt(), ccp4_lwbat(), ccp4_lwsymm_c(), FORTRAN_SUBR(), MtzAddHistory(), MtzAssignColumn(), and MtzAssignHKLtoBase().

char* MtzSetPath ( const MTZ mtz,
const MTZSET set 
)

Return the full path name of a dataset as "/xname/dname" The pointer to MTZ is required to do reverse lookup of xname. Memory for the path name is assigned with malloc, and can be free'd by the calling function.

Parameters
mtzpointer to MTZ struct
setpointer to dataset
Returns
pointer to string containing path name

References ccp4_utils_malloc(), MtzSetXtal(), and MtzXtalPath().

Referenced by MtzAssignColumn(), MtzColPath(), and MtzSetLookup().

MTZSET** MtzSetsInXtal ( MTZXTAL xtal)

For a given crystal, return array of pointers to datasets in that crystal.

Parameters
xtalpointer to the crystal struct
Returns
array of pointers to datasets

References MTZXTAL::set.

int MtzSetSortOrder ( MTZ mtz,
MTZCOL colsort[5] 
)

Sets the sort order in the MTZ header. The sort order is a list of columns to be used for sorting, to be applied in the order they appear in the list, i.e. sort first on colsort[0], then on colsort[1], etc. If there are less than 5 columns to be used for sorting, some of colsort[] may be NULL.

Parameters
mtzPointer to MTZ struct
colsortArray of pointers to columns.
Returns
1 on success, 0 on failure

References float_uint_uchar::i, and MTZ::order.

Referenced by FORTRAN_SUBR().

MTZXTAL* MtzSetXtal ( const MTZ mtz,
const MTZSET set 
)

Get the crystal associated with a dataset The pointer to MTZ is required to do reverse lookup of xname.

Parameters
mtzpointer to MTZ struct
setpointer to dataset
Returns
pointer to parent crystal, or NULL if "set" is not present in "mtz".

References MTZXTAL::nset, MTZ::nxtal, MTZXTAL::set, and MTZ::xtal.

Referenced by ccp4_lridx(), and MtzSetPath().

int MtzSpacegroupNumber ( const MTZ mtz)

Get the spacegroup number (likely CCP4 convention).

Parameters
mtzpointer to MTZ struct
Returns
Spacegroup number.

References MTZ::mtzsymm, and SYMGRP::spcgrp.

int MtzToggleColumn ( MTZCOL col)

Toggle active flag of column. A value of 0 means inactive and will not be written out, whereas a value of 1 means active and will be written out.

Parameters
colpointer to column
Returns
New value of col->active.

References MTZCOL::active.

int MtzWhdrLine ( CCP4File fileout,
int  nitems,
char  buffer[] 
)

Write header record to fileout. Record is filled from buffer and padded by blanks to a total length of MTZRECORDLENGTH.

Parameters
fileoutPointer to output file.
nitemsNumber of characters in buffer.
bufferCharacter buffer containing MTZ header line.
Returns
Number of bytes written on success, EOF on failure.

References ccp4_file_writechar(), float_uint_uchar::i, and MTZRECORDLENGTH.

Referenced by MtzPut().

int MtzWrefl ( CCP4File fileout,
int  ncol,
float *  refldata 
)

Write ncol column entries to fileout from refldata.

Parameters
fileoutpointer to output MTZ file.
ncolnumber of reflection data items to write.
refldataarray of reflection data items.
Returns
Number of items written. If this is less than ncol, then that indicates a write error.

References ccp4_file_write(), and ccp4_signal().

Referenced by ccp4_lwrefl(), and MtzPut().

MTZXTAL* MtzXtalLookup ( const MTZ mtz,
const char *  label 
)

Returns a pointer to the crystal of mtz with the given label, or NULL.

Parameters
mtzpointer to MTZ struct
label
Returns
pointer to crystal

References MtzPathMatch(), MtzRJustPath(), MtzXtalPath(), MTZ::nxtal, and MTZ::xtal.

Referenced by ccp4_lwbat(), FORTRAN_SUBR(), MtzAddHistory(), MtzAssignColumn(), and MtzPut().

char* MtzXtalPath ( const MTZXTAL xtal)

Return the full path name of a crystal as "/xname" Memory for the path name is assigned with malloc, and can be free'd by the calling function.

Parameters
xtalpointer to the crystal struct
Returns
pointer to string containing path name

References ccp4_utils_malloc(), and MTZXTAL::xname.

Referenced by MtzSetPath(), and MtzXtalLookup().

MTZXTAL** MtzXtals ( MTZ mtz)

Return array of pointers to crystals.

Parameters
mtzpointer to MTZ struct
Returns
array of pointers to crystals

References MTZ::xtal.

MTZBAT* sort_batches ( MTZBAT batch,
int  numbat 
)

Sort a linked list of batches on batch number. The function first checks whether batches are already in order, as they will usually be.

Parameters
batchpointer to beginning of batch list
numbatnumber of batches to be sorted
Returns
Sorted list if batches sorted, original list if batches already in order

References ccp4_liberr_verbosity(), float_uint_uchar::i, bathead::next, and bathead::num.

Referenced by MtzPut().