cmaplib.h

Go to the documentation of this file.
00001 /*
00002      cmaplib.h: C/C++ level API for accessing CCP4 map files
00003      Copyright (C) 2001  CCLRC, Charles Ballard
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 
00052 #ifndef __GUARD_MAPLIB
00053 #define __GUARD_MAPLIB
00054 
00055 #include "ccp4_utils.h"
00056 
00057 #ifdef __cplusplus
00058 namespace CMap_io {
00059 typedef CCP4::CCP4File CCP4File;
00060 extern "C" {
00061 #endif
00062 
00063 typedef struct _CMMFile_Skew CMMFile_Skew;
00064 typedef struct _CMMFile_Labels CMMFile_Labels;
00065 typedef struct _CMMFile_Symop CMMFile_Symop;
00066 typedef struct _CMMFile_Data CMMFile_Data;
00067 typedef struct _CMMFile_Stats CMMFile_Stats;
00068 typedef struct _CMMFile CMMFile;
00069 
00070 struct _CMMFile_Labels {
00071   unsigned int number;
00072   char *labels[10];
00073 };
00074 
00075 struct _CMMFile_Skew {
00076   float rotation[3][3];
00077   float translation[3];
00078 };
00079 
00080 struct _CMMFile_Symop {
00081 unsigned int offset;
00082 unsigned int size;
00083 unsigned int number;
00084 };
00085 
00086 struct _CMMFile_Data {
00087   size_t offset;
00088   size_t section_size;
00089   size_t header_size;
00090   size_t block_size;
00091   unsigned int number;
00092 };
00093 
00094 struct _CMMFile_Stats {
00095   float offset;                /* pseudo zero value */
00096   float min;                   /* minimum density value */
00097   float max;                   /* maximum density value */
00098   double mean;               /* sum of densities (less offset) */
00099   double rms;              /* sum of square of densities (less offset) */
00100   int total;                    /* number of summed densities */
00101 };
00102 
00103 struct _CMMFile {
00104 CCP4File *stream;
00105 char *file_name;
00106 unsigned int data_mode;
00107 unsigned int close_mode;
00108 float cell[6];
00109 int spacegroup;
00110 int map_dim[3];
00111 int origin[3];
00112 int cell_grid[3];
00113 int axes_order[3];
00114 CMMFile_Symop symop;
00115 CMMFile_Data data;
00116 CMMFile_Stats stats;
00117 CMMFile_Labels labels;
00118 CMMFile_Skew skew;
00119 int reserved[8];
00120 char user_access[24];
00121 };
00122 
00123 /* open a file for read/write */
00124 void *ccp4_cmap_open(const char *filename, int mode);
00125 
00126 /* close a file for read/write (dumping the header if write) */
00127 void ccp4_cmap_close(CMMFile *mfile);
00128 
00129 /* set the close mode (calculation of map statistics) */
00130 void ccp4_cmap_closemode(CMMFile *mfile, unsigned int closemode);
00131 
00132 /* seek to a section in the map (read mode only)*/
00133 int ccp4_cmap_seek_section(CMMFile *mfile, int offset, unsigned int seek_mode);
00134 
00135 /* seek to a row in a section (read mode only)*/
00136 int ccp4_cmap_seek_row(CMMFile *, int offset, unsigned int seek_mode);
00137 
00138 /* raw seek (read mode only)*/
00139 int ccp4_cmap_seek_data(CMMFile *, int offset, unsigned int seek_mode);
00140 
00141 /* read a map section from file to memory */
00142 int ccp4_cmap_read_section(CMMFile *mfile, void *section);
00143 
00144 /* read a row from file to memory */
00145 int ccp4_cmap_read_row(CMMFile *mfile, void *row);
00146 
00147 /* read n_items from file to memory (item determined by data mode) */
00148 int ccp4_cmap_read_data(const CMMFile *mfile, void *items, int n_items);
00149 
00150 /* write a map section from memory to file */
00151 int ccp4_cmap_write_section(CMMFile *mfile, const void *section);
00152 
00153 /* write a map row from memory to file */
00154 int ccp4_cmap_write_row(CMMFile *mfile, const void *row);
00155 
00156 /* write n_items from memory to file (item determined by data mode) */
00157 int ccp4_cmap_write_data(CMMFile *mfile, const void *items, int n_items);
00158 
00159 /* read the section header corresponding to the current section */
00160 int ccp4_cmap_read_section_header(const CMMFile *mfile, char *header);
00161 
00162 /* write the section header corresponding to the current section */
00163 int ccp4_cmap_write_section_header(CMMFile *mfile, const char *header);
00164 
00165 /* get the header parameters */
00166 void ccp4_cmap_get_cell(const CMMFile *mfile, float *cell);
00167 void ccp4_cmap_get_grid(const CMMFile *mfile, int *grid);
00168 void ccp4_cmap_get_origin(const CMMFile *mfile, int *origin);
00169 void ccp4_cmap_get_order(const CMMFile *mfile, int *axes_order);
00170 void ccp4_cmap_get_dim(const CMMFile *mfile, int *map_dim);
00171 int ccp4_cmap_get_spacegroup(const CMMFile *mfile);
00172 void ccp4_cmap_get_mapstats(const CMMFile *mfile, float *min, float* max, 
00173                            double *mean, double *rms);
00174 
00175 /* set the header parameters */
00176 void ccp4_cmap_set_cell(CMMFile *mfile, const float *cell);
00177 void ccp4_cmap_set_grid(CMMFile *mfile, const int *grid);
00178 void ccp4_cmap_set_origin(CMMFile *mfile, const int *origin);
00179 void ccp4_cmap_set_order(CMMFile *mfile, const int *axes_order);
00180 void ccp4_cmap_set_dim(CMMFile *mfile, const int *map_dim);
00181 void ccp4_cmap_set_spacegroup(CMMFile *mfile, int spacegroup);
00182 void ccp4_cmap_set_mapstats(CMMFile *mfile, const float min, const float max,
00183                            const double mean, const double rms);
00184 
00185 /* get map file datamode */
00186 unsigned int ccp4_cmap_get_datamode(const CMMFile *mfile);
00187 
00188 /* set map file datamode */
00189 void ccp4_cmap_set_datamode(CMMFile *mfile, unsigned int datamode);
00190 
00191 /* get the local header size */
00192 size_t ccp4_cmap_get_local_header(CMMFile *mfile);
00193 
00194 /* set the local header size (before data writing begins) */
00195 void ccp4_cmap_set_local_header(CMMFile *mfile, size_t size);
00196 
00197 /* get the number of symops in the file */
00198 int ccp4_cmap_num_symop(const CMMFile *mfile);
00199 
00200 /* seek among the symops strings */
00201 int ccp4_cmap_seek_symop(CMMFile *mfile, int isymop, unsigned int whence);
00202 
00203 /* read a symop string of 80 characters */
00204 int ccp4_cmap_get_symop(CMMFile *mfile, char *buffer);
00205 
00206 /* write a symop string of 80 characters */
00207 int ccp4_cmap_set_symop(CMMFile *mfile, const char *buffer);
00208 
00209 /* get the mask */
00210 int ccp4_cmap_get_mask(const CMMFile *mfile, float *skew_mat, float *skew_trans);
00211 
00212 /* set the mask */
00213 int ccp4_cmap_set_mask(CMMFile *mfile, const float *skew_mat, const float *skew_trans);
00214 
00215 /* the number of labels used */
00216 int ccp4_cmap_number_label(const CMMFile *mfile);
00217 
00218 /* set label at posn from C-string */
00219 int ccp4_cmap_set_label(CMMFile *mfile, const char *label, int posn);
00220 
00221 /* return label at posn as C-string */
00222 char *ccp4_cmap_get_label(const CMMFile *mfile, int posn);
00223 
00224 /* set title (label=0) */
00225 int ccp4_cmap_set_title(CMMFile *mfile, const char *label);
00226 
00227 /* get title (label=0) */
00228 char *ccp4_cmap_get_title(const CMMFile *mfile);
00229 
00230 #ifdef __cplusplus
00231 }
00232 }
00233 #endif
00234 
00235 #endif  /* __GUARD_MAPLIB */
00236 
00237 /*
00238   Local variables:
00239   mode: font-lock
00240   End:
00241 */

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