gpp4
1.3.1
|
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 3 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with This library. If not, see 00017 <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00050 #ifndef __GUARD_MAPLIB 00051 #define __GUARD_MAPLIB 00052 00053 #include "ccp4_utils.h" 00054 00055 #ifdef __cplusplus 00056 namespace CMap_io { 00057 typedef CCP4::CCP4File CCP4File; 00058 extern "C" { 00059 #endif 00060 00061 typedef struct _CMMFile_Skew CMMFile_Skew; 00062 typedef struct _CMMFile_Labels CMMFile_Labels; 00063 typedef struct _CMMFile_Symop CMMFile_Symop; 00064 typedef struct _CMMFile_Data CMMFile_Data; 00065 typedef struct _CMMFile_Stats CMMFile_Stats; 00066 typedef struct _CMMFile CMMFile; 00067 00068 struct _CMMFile_Labels { 00069 unsigned int number; 00070 char *labels[10]; 00071 }; 00072 00076 struct _CMMFile_Skew { 00077 float rotation[3][3]; 00078 float translation[3]; 00079 }; 00080 00084 struct _CMMFile_Symop { 00085 unsigned int offset; 00087 unsigned int size; 00088 unsigned int number; 00089 }; 00090 00094 struct _CMMFile_Data { 00095 size_t offset; 00096 size_t section_size; 00097 size_t header_size; 00098 size_t block_size; 00099 unsigned int number; 00100 }; 00101 00105 struct _CMMFile_Stats { 00106 float offset; 00107 float min; 00108 float max; 00109 double mean; 00110 double rms; 00111 int total; 00112 }; 00113 00118 struct _CMMFile { 00119 CCP4File *stream; 00120 char *file_name; 00121 unsigned int data_mode; 00122 unsigned int close_mode; 00123 float cell[6]; 00124 int spacegroup; 00125 int map_dim[3]; 00127 int origin[3]; 00129 int cell_grid[3]; 00130 int axes_order[3]; 00131 CMMFile_Symop symop; 00132 CMMFile_Data data; 00133 CMMFile_Stats stats; 00134 CMMFile_Labels labels; 00135 CMMFile_Skew skew; 00136 int reserved[8]; 00137 char user_access[28]; 00138 }; 00139 00140 /* open a file for read/write */ 00141 void *ccp4_cmap_open(const char *filename, int mode); 00142 00143 /* close a file for read/write (dumping the header if write) */ 00144 void ccp4_cmap_close(CMMFile *mfile); 00145 00146 /* set the close mode (calculation of map statistics) */ 00147 void ccp4_cmap_closemode(CMMFile *mfile, unsigned int closemode); 00148 00149 /* seek to a section in the map (read mode only)*/ 00150 int ccp4_cmap_seek_section(CMMFile *mfile, int offset, unsigned int seek_mode); 00151 00152 /* seek to a row in a section (read mode only)*/ 00153 int ccp4_cmap_seek_row(CMMFile *, int offset, unsigned int seek_mode); 00154 00155 /* raw seek (read mode only)*/ 00156 int ccp4_cmap_seek_data(CMMFile *, int offset, unsigned int seek_mode); 00157 00158 /* read a map section from file to memory */ 00159 int ccp4_cmap_read_section(CMMFile *mfile, void *section); 00160 00161 /* read a row from file to memory */ 00162 int ccp4_cmap_read_row(CMMFile *mfile, void *row); 00163 00164 /* read n_items from file to memory (item determined by data mode) */ 00165 int ccp4_cmap_read_data(const CMMFile *mfile, void *items, int n_items); 00166 00167 /* write a map section from memory to file */ 00168 int ccp4_cmap_write_section(CMMFile *mfile, const void *section); 00169 00170 /* write a map row from memory to file */ 00171 int ccp4_cmap_write_row(CMMFile *mfile, const void *row); 00172 00173 /* write n_items from memory to file (item determined by data mode) */ 00174 int ccp4_cmap_write_data(CMMFile *mfile, const void *items, int n_items); 00175 00176 /* read the section header corresponding to the current section */ 00177 int ccp4_cmap_read_section_header(const CMMFile *mfile, char *header); 00178 00179 /* write the section header corresponding to the current section */ 00180 int ccp4_cmap_write_section_header(CMMFile *mfile, const char *header); 00181 00182 /* get the header parameters */ 00183 void ccp4_cmap_get_cell(const CMMFile *mfile, float *cell); 00184 void ccp4_cmap_get_grid(const CMMFile *mfile, int *grid); 00185 void ccp4_cmap_get_origin(const CMMFile *mfile, int *origin); 00186 void ccp4_cmap_get_order(const CMMFile *mfile, int *axes_order); 00187 void ccp4_cmap_get_dim(const CMMFile *mfile, int *map_dim); 00188 int ccp4_cmap_get_spacegroup(const CMMFile *mfile); 00189 void ccp4_cmap_get_mapstats(const CMMFile *mfile, float *min, float* max, 00190 double *mean, double *rms); 00191 00192 /* set the header parameters */ 00193 void ccp4_cmap_set_cell(CMMFile *mfile, const float *cell); 00194 void ccp4_cmap_set_grid(CMMFile *mfile, const int *grid); 00195 void ccp4_cmap_set_origin(CMMFile *mfile, const int *origin); 00196 void ccp4_cmap_set_order(CMMFile *mfile, const int *axes_order); 00197 void ccp4_cmap_set_dim(CMMFile *mfile, const int *map_dim); 00198 void ccp4_cmap_set_spacegroup(CMMFile *mfile, int spacegroup); 00199 void ccp4_cmap_set_mapstats(CMMFile *mfile, const float min, const float max, 00200 const double mean, const double rms); 00201 00202 /* get map file datamode */ 00203 unsigned int ccp4_cmap_get_datamode(const CMMFile *mfile); 00204 00205 /* set map file datamode */ 00206 void ccp4_cmap_set_datamode(CMMFile *mfile, unsigned int datamode); 00207 00208 /* get the local header size */ 00209 size_t ccp4_cmap_get_local_header(CMMFile *mfile); 00210 00211 /* set the local header size (before data writing begins) */ 00212 void ccp4_cmap_set_local_header(CMMFile *mfile, size_t size); 00213 00214 /* get the number of symops in the file */ 00215 int ccp4_cmap_num_symop(const CMMFile *mfile); 00216 00217 /* seek among the symops strings */ 00218 int ccp4_cmap_seek_symop(CMMFile *mfile, int isymop, unsigned int whence); 00219 00220 /* read a symop string of 80 characters */ 00221 int ccp4_cmap_get_symop(CMMFile *mfile, char *buffer); 00222 00223 /* write a symop string of 80 characters */ 00224 int ccp4_cmap_set_symop(CMMFile *mfile, const char *buffer); 00225 00226 /* get the mask */ 00227 int ccp4_cmap_get_mask(const CMMFile *mfile, float *skew_mat, float *skew_trans); 00228 00229 /* set the mask */ 00230 int ccp4_cmap_set_mask(CMMFile *mfile, const float *skew_mat, const float *skew_trans); 00231 00232 /* the number of labels used */ 00233 int ccp4_cmap_number_label(const CMMFile *mfile); 00234 00235 /* set label at posn from C-string */ 00236 int ccp4_cmap_set_label(CMMFile *mfile, const char *label, int posn); 00237 00238 /* return label at posn as C-string */ 00239 char *ccp4_cmap_get_label(const CMMFile *mfile, int posn); 00240 00241 /* set title (label=0) */ 00242 int ccp4_cmap_set_title(CMMFile *mfile, const char *label); 00243 00244 /* get title (label=0) */ 00245 char *ccp4_cmap_get_title(const CMMFile *mfile); 00246 00247 #ifdef __cplusplus 00248 } 00249 } 00250 #endif 00251 00252 #endif /* __GUARD_MAPLIB */ 00253 00254 /* 00255 Local variables: 00256 mode: font-lock 00257 End: 00258 */