#include "ccp4_utils.h"
Go to the source code of this file.
Classes | |
struct | _CMMFile_Labels |
struct | _CMMFile_Skew |
struct | _CMMFile_Symop |
struct | _CMMFile_Data |
struct | _CMMFile_Stats |
struct | _CMMFile |
Typedefs | |
typedef struct _CMMFile_Skew | CMMFile_Skew |
typedef struct _CMMFile_Labels | CMMFile_Labels |
typedef struct _CMMFile_Symop | CMMFile_Symop |
typedef struct _CMMFile_Data | CMMFile_Data |
typedef struct _CMMFile_Stats | CMMFile_Stats |
typedef struct _CMMFile | CMMFile |
Functions | |
void * | ccp4_cmap_open (const char *filename, int mode) |
void | ccp4_cmap_close (CMMFile *mfile) |
void | ccp4_cmap_closemode (CMMFile *mfile, unsigned int closemode) |
int | ccp4_cmap_seek_section (CMMFile *mfile, int offset, unsigned int seek_mode) |
int | ccp4_cmap_seek_row (CMMFile *, int offset, unsigned int seek_mode) |
int | ccp4_cmap_seek_data (CMMFile *, int offset, unsigned int seek_mode) |
int | ccp4_cmap_read_section (CMMFile *mfile, void *section) |
int | ccp4_cmap_read_row (CMMFile *mfile, void *row) |
int | ccp4_cmap_read_data (const CMMFile *mfile, void *items, int n_items) |
int | ccp4_cmap_write_section (CMMFile *mfile, const void *section) |
int | ccp4_cmap_write_row (CMMFile *mfile, const void *row) |
int | ccp4_cmap_write_data (CMMFile *mfile, const void *items, int n_items) |
int | ccp4_cmap_read_section_header (const CMMFile *mfile, char *header) |
int | ccp4_cmap_write_section_header (CMMFile *mfile, const char *header) |
void | ccp4_cmap_get_cell (const CMMFile *mfile, float *cell) |
void | ccp4_cmap_get_grid (const CMMFile *mfile, int *grid) |
void | ccp4_cmap_get_origin (const CMMFile *mfile, int *origin) |
void | ccp4_cmap_get_order (const CMMFile *mfile, int *axes_order) |
void | ccp4_cmap_get_dim (const CMMFile *mfile, int *map_dim) |
int | ccp4_cmap_get_spacegroup (const CMMFile *mfile) |
void | ccp4_cmap_get_mapstats (const CMMFile *mfile, float *min, float *max, double *mean, double *rms) |
void | ccp4_cmap_set_cell (CMMFile *mfile, const float *cell) |
void | ccp4_cmap_set_grid (CMMFile *mfile, const int *grid) |
void | ccp4_cmap_set_origin (CMMFile *mfile, const int *origin) |
void | ccp4_cmap_set_order (CMMFile *mfile, const int *axes_order) |
void | ccp4_cmap_set_dim (CMMFile *mfile, const int *map_dim) |
void | ccp4_cmap_set_spacegroup (CMMFile *mfile, int spacegroup) |
void | ccp4_cmap_set_mapstats (CMMFile *mfile, const float min, const float max, const double mean, const double rms) |
unsigned int | ccp4_cmap_get_datamode (const CMMFile *mfile) |
void | ccp4_cmap_set_datamode (CMMFile *mfile, unsigned int datamode) |
size_t | ccp4_cmap_get_local_header (CMMFile *mfile) |
void | ccp4_cmap_set_local_header (CMMFile *mfile, size_t size) |
int | ccp4_cmap_num_symop (const CMMFile *mfile) |
int | ccp4_cmap_seek_symop (CMMFile *mfile, int isymop, unsigned int whence) |
int | ccp4_cmap_get_symop (CMMFile *mfile, char *buffer) |
int | ccp4_cmap_set_symop (CMMFile *mfile, const char *buffer) |
int | ccp4_cmap_get_mask (const CMMFile *mfile, float *skew_mat, float *skew_trans) |
int | ccp4_cmap_set_mask (CMMFile *mfile, const float *skew_mat, const float *skew_trans) |
int | ccp4_cmap_number_label (const CMMFile *mfile) |
int | ccp4_cmap_set_label (CMMFile *mfile, const char *label, int posn) |
char * | ccp4_cmap_get_label (const CMMFile *mfile, int posn) |
int | ccp4_cmap_set_title (CMMFile *mfile, const char *label) |
char * | ccp4_cmap_get_title (const CMMFile *mfile) |
Functions defining the C-level API for accessing CCP4 map files.
void ccp4_cmap_close | ( | CMMFile * | mfile | ) |
Close the file. In write mode the header is output, along with the machine stamp. In read mode the file is just closed. Write mode supports ways of updating the map statistics ( only active for FLOAT32). /param mfile (CMMFile *) /return void
References ccp4_file_close(), ccp4_file_is_write(), ccp4_file_warch(), and float_uint_uchar::i.
void ccp4_cmap_closemode | ( | CMMFile * | mfile, | |
unsigned int | mask | |||
) |
Set the close mode: 0: calculate based on stored values (default) 1: just dump the current values /param mfile (CMMFile *) /param mask (unsigned int) close mode /return void
void ccp4_cmap_get_cell | ( | const CMMFile * | mfile, | |
float * | cell | |||
) |
Get the cell parameters
mfile | (const CMMFile *) | |
cell | (float *) contains the cell parameter on exit (dim 6) |
unsigned int ccp4_cmap_get_datamode | ( | const CMMFile * | mfile | ) |
Return the datamode
mfile | (const CMMFile *) |
void ccp4_cmap_get_dim | ( | const CMMFile * | mfile, | |
int * | map_dim | |||
) |
Get the stored map dimension (rows,sections,columns)
mfile | (const CMMFile *) | |
map_dim | (int *) contains the map dimension on exit (dim 3) |
void ccp4_cmap_get_grid | ( | const CMMFile * | mfile, | |
int * | grid | |||
) |
Get the grid for the complete cell (X,Y,Z) ordering
mfile | (const CMMFile *) | |
grid | (int *) contains the grid dimension on exit (dim 3) |
char* ccp4_cmap_get_label | ( | const CMMFile * | mfile, | |
int | posn | |||
) |
Get the label corresponding to position posn
mfile | (const CMMFile *) | |
posn | (int) desired label number |
References ccp4_signal().
size_t ccp4_cmap_get_local_header | ( | CMMFile * | mfile | ) |
Return the local header size
mfile | (CMMFile *) |
void ccp4_cmap_get_mapstats | ( | const CMMFile * | mfile, | |
float * | min, | |||
float * | max, | |||
double * | mean, | |||
double * | rms | |||
) |
Get the map statistics, including maximum, minimum, mean and standard deviation. This is only meaningful for datamode FLOAT32.
mfile | (const CMMFile *) | |
min | (float *) | |
max | (float *) | |
mean | (double *) | |
rms | (double *) |
References ccp4_file_is_write().
int ccp4_cmap_get_mask | ( | const CMMFile * | mfile, | |
float * | skew_mat, | |||
float * | skew_trans | |||
) |
Get the values of the translation and rotation elements of the skew matrix. Note: the stored file is in FORTRAN order mat[fastest][slowest], the returned values are in C mat[slowest][fastest] ordering
mfile | (CMMFile *) | |
skew_mat | (const float *) the skew translation vestor | |
skew_trans | (const float *) the skew rotation matrix (C ordering) |
References ccp4_signal().
void ccp4_cmap_get_order | ( | const CMMFile * | mfile, | |
int * | axes_order | |||
) |
Get the stored map axes order (rows,sections,columns) where 1=X, 2=Y, 3=Z
mfile | (const CMMFile *) | |
axes_order | (float *) contains the ordering on exit (dim 3) |
void ccp4_cmap_get_origin | ( | const CMMFile * | mfile, | |
int * | origin | |||
) |
Get the stored map origin (rows,sections,columns)
mfile | (const CMMFile *) | |
origin | (int *) contains the origin on exit (dim 3) |
int ccp4_cmap_get_spacegroup | ( | const CMMFile * | mfile | ) |
Return the spacegroup listed in the map header. This is overriden by the symops.
mfile | (CMMFile *) |
int ccp4_cmap_get_symop | ( | CMMFile * | mfile, | |
char * | buffer | |||
) |
get a symop string of 80 characters
mfile | (CMMFile *) | |
buffer | (char *) array of bytes which will contain the symop string. This must be at least 81 characters long (including space for null terminator). |
References ccp4_file_readchar(), ccp4_file_tell(), and ccp4_signal().
char* ccp4_cmap_get_title | ( | const CMMFile * | mfile | ) |
Get the label corresponding to the title wrapping ccp4_cmap_get_label.
mfile | (const CMMFile *) |
int ccp4_cmap_num_symop | ( | const CMMFile * | mfile | ) |
Return the number of symops (estimated as the size/80)
mfile | (const CMMFile *) |
int ccp4_cmap_number_label | ( | const CMMFile * | mfile | ) |
Return the number of labels.
mfile | (CMMFile *) |
void* ccp4_cmap_open | ( | const char * | filename, | |
int | mode | |||
) |
The file is opened.
filename | (char *) the filename | |
mode | (int) the i/o mode , possible values are O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_TMP, O_CREAT, O_TRUNC - see ccp4_sysdep.h |
References ccp4_file_close(), ccp4_file_open(), ccp4_file_rarch(), ccp4_file_raw_setstamp(), ccp4_signal(), init_cmap_read(), init_cmap_write(), and is_cmap().
int ccp4_cmap_read_data | ( | const CMMFile * | mfile, | |
void * | items, | |||
int | n_items | |||
) |
raw read of nelements items from file according to the datamode at current location
mfile | (const CMMFile *) | |
items | (void *) values read to here, so should have enough space for nelements items | |
n_items | (int) number of items to be read |
References ccp4_file_is_read(), ccp4_file_read(), and ccp4_signal().
int ccp4_cmap_read_row | ( | CMMFile * | mfile, | |
void * | row | |||
) |
read current map section from file to section. Some checking is performed to ensure we are at the start of a legitimate map row.
mfile | (CMMFile *) | |
row | (void *) array large enough to hold the map row |
References ccp4_file_is_read(), ccp4_file_itemsize(), ccp4_file_raw_seek(), ccp4_file_read(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_read_section | ( | CMMFile * | mfile, | |
void * | section | |||
) |
read current map section from file to section. Some checking is performed to ensure we are at the start of a legitimate map section.
mfile | (CMMFile *) | |
section | (void *) array large enough to hold the map section |
References ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_read(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_read_section_header | ( | const CMMFile * | mfile, | |
char * | header | |||
) |
read current section header (character array) After reading we are at the end of the local header
mfile | (CMMFile *) | |
header | (char *) character array large enough to hold the local header (raw read so not string) |
References ccp4_errno, ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_readchar(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_seek_data | ( | CMMFile * | mfile, | |
int | offset, | |||
unsigned int | whence | |||
) |
raw seek in items
mfile | (CMMFile *) | |
offset | (int) number of items | |
whence | (unsigned int) SEEK_SET, SEEK_CUR, SEEK_END; |
References ccp4_errno, ccp4_file_seek(), and ccp4_signal().
int ccp4_cmap_seek_row | ( | CMMFile * | mfile, | |
int | row, | |||
unsigned int | whence | |||
) |
seek a row within a map section
mfile | (CMMFile *) | |
row | (int) | |
whence | (unsigned int) SEEK_SET, SEEK_END, SEEK_CUR |
References ccp4_file_itemsize(), ccp4_file_raw_seek(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_seek_section | ( | CMMFile * | mfile, | |
int | sec, | |||
unsigned int | whence | |||
) |
seek among the map sections. The units are of size block_size.
mfile | (CMMFile *) | |
sec | (int) section number | |
whence | (unsigned int) SEEK_SET, SEEK_CUR or SEEK_END |
References ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_tell(), and ccp4_signal().
int ccp4_cmap_seek_symop | ( | CMMFile * | mfile, | |
int | isymop, | |||
unsigned int | whence | |||
) |
navigate around the symops, seeking in 80 byte units The result must lie within the symop strings in the file.
mfile | (CMMFile *) | |
isymop | (int) the number of the symop "string" of interest | |
whence | (unsigned int) mode of seek |
References ccp4_file_is_read(), ccp4_file_raw_seek(), ccp4_file_tell(), and ccp4_signal().
void ccp4_cmap_set_cell | ( | CMMFile * | mfile, | |
const float * | cell | |||
) |
Set the cell parameters. Only allowed when file is opened in write mode.
mfile | (CMMFile *) | |
cell | (const float *) the cell parameters |
References ccp4_file_is_write().
void ccp4_cmap_set_datamode | ( | CMMFile * | mfile, | |
unsigned int | datamode | |||
) |
Set the datamode. This is only allowed if the file is opened in write mode, and no data has been written.
mfile | (CMMFile *) | |
datamode | (unsigned int) major mode of map |
References ccp4_file_is_write(), ccp4_file_itemsize(), and ccp4_file_setmode().
void ccp4_cmap_set_dim | ( | CMMFile * | mfile, | |
const int * | map_dim | |||
) |
Set the stored map dimension (rows,sections,columns) Only allowed when file is opened in write mode before any data is written. Note: the row dimension will be overridden during writing
mfile | (CMMFile *) | |
map_dim | (const int *) the map dimension |
References ccp4_file_is_write(), and ccp4_file_itemsize().
void ccp4_cmap_set_grid | ( | CMMFile * | mfile, | |
const int * | grid | |||
) |
Set the cell grid dimension. Only allowed when file is opened in write mode.
mfile | (CMMFile *) | |
grid | (const int *) the cell grid dimension (X,Y,Z) |
References ccp4_file_is_write().
int ccp4_cmap_set_label | ( | CMMFile * | mfile, | |
const char * | label, | |||
int | posn | |||
) |
Set the label in the map header. Headers are 80 characters long. The labels are written to the file when it is closed. Therefore, the file must be in write mode. If label == NULL the element corresponding to posn is removed. The number of labels is recalculated on each call.
mfile | (CMMFile *) | |
label | (const char *) the C-style character array | |
posn | (int) the label number (C-style, 0 -> 9) |
References ccp4_file_is_write(), ccp4_signal(), and float_uint_uchar::i.
void ccp4_cmap_set_local_header | ( | CMMFile * | mfile, | |
size_t | size | |||
) |
Set the local header size (in bytes)
mfile | (CMMFile *) | |
size | (size_t) header size associated with each section (in bytes) |
References ccp4_file_is_write().
void ccp4_cmap_set_mapstats | ( | CMMFile * | mfile, | |
const float | min, | |||
const float | max, | |||
const double | mean, | |||
const double | rms | |||
) |
Set the map statistics, including maximum, minimum, mean and standard deviation. This is only meaningful for datamode FLOAT32 and the file open in write mode.
mfile | (CMMFile *) | |
min | (float) | |
max | (float) | |
mean | (double) | |
rms | (double) |
References ccp4_file_is_write().
int ccp4_cmap_set_mask | ( | CMMFile * | mfile, | |
const float * | skew_mat, | |||
const float * | skew_trans | |||
) |
Set the values of the translation and rotation elements of the skew matrix. Note: the stored file is in FORTRAN order mat[fastest][slowest]
mfile | (CMMFile *) | |
skew_mat | (const float *) the skew translation vestor | |
skew_trans | (const float *) the skew rotation matrix (C ordering) |
References ccp4_signal().
void ccp4_cmap_set_order | ( | CMMFile * | mfile, | |
const int * | axes_order | |||
) |
Set the stored map axes order (rows,sections,columns) where 1=X, 2=Y, 3=Z. Only allowed when file is opened in write mode.
mfile | (CMMFile *) | |
axes_order | (const float *) the axes ordering |
References ccp4_file_is_write().
void ccp4_cmap_set_origin | ( | CMMFile * | mfile, | |
const int * | origin | |||
) |
Set the stored map origin (rows,sections,columns) Only allowed when file is opened in write mode.
mfile | (CMMFile *) | |
origin | (const int *) the origin |
References ccp4_file_is_write().
void ccp4_cmap_set_spacegroup | ( | CMMFile * | mfile, | |
int | spacegroup | |||
) |
Set the spacegroup listed in the map header. Only allowed when file is opened in write mode.
mfile | (CMMFile *) | |
spacegroup | (int) spacegroup number |
References ccp4_file_is_write().
int ccp4_cmap_set_symop | ( | CMMFile * | mfile, | |
const char * | symop | |||
) |
write symops to file. This wraps a raw write. It is up to the calling program to ensure the positioning (effectively assume appends). Writing is blocked if data has alread been written to the file. 80 bytes of continuous memory is written to the file.
mfile | (CMMFile *) | |
symop | (const char *) character array containing the symop string (at least 80 characters in length |
References ccp4_file_is_write(), ccp4_file_writechar(), and ccp4_signal().
int ccp4_cmap_set_title | ( | CMMFile * | mfile, | |
const char * | title | |||
) |
Set the label corresponding to the title, wrapping ccp4_cmap_set_label
[in] | mfile | (CMMFile *) |
[in] | title |
int ccp4_cmap_write_data | ( | CMMFile * | mfile, | |
const void * | items, | |||
int | n_items | |||
) |
raw write of nelements items to file, according to the datamode, at current location
mfile | (const CMMFile *) | |
items | (void *) values written, should contain at least n_items items | |
n_items | (int) number of items to be written |
References ccp4_file_is_write(), ccp4_file_write(), and ccp4_signal().
int ccp4_cmap_write_row | ( | CMMFile * | mfile, | |
const void * | row | |||
) |
write map row to file. Note: this wraps a raw write, with no location checking. It is therefore the responsibility of the calling program to ensure that everything is correct. Effectively assume appending to file.
mfile | (CMMFile *) | |
row | (const void *) data to be written |
References ccp4_file_is_write(), ccp4_file_write(), and ccp4_signal().
int ccp4_cmap_write_section | ( | CMMFile * | mfile, | |
const void * | section | |||
) |
write map section to file. Note: this wraps a raw write, with no location checking. It is therefore the responsibility of the calling program to ensure that everything is correct. Effectively assume appending to file.
mfile | (CMMFile *) | |
section | (const void *) |
References ccp4_file_is_write(), ccp4_file_write(), and ccp4_signal().
int ccp4_cmap_write_section_header | ( | CMMFile * | mfile, | |
const char * | header | |||
) |
write the local section header to the file. This must be of size mfile->data.header.size. Note: no checking is done so it is up to the calling program to ensure that the file is in the correct location. As seeking is turned off, this assumes we are appending to the file.
mfile | (CMMFile *) | |
header | (const char *) the local header character array (not necessarily a string) |
References ccp4_errno, ccp4_file_is_write(), ccp4_file_writechar(), and ccp4_signal().