46
45
#define CSYMERR_NullSpacegroup 3
47
46
#define CSYMERR_NoAsuDefined 4
48
47
#define CSYMERR_NoLaueCodeDefined 5
51
Find the path of the SYMINFO file. We will try to locate the file
52
in several places (in increasing order of significance):
53
-# $SYMINFO environment variable
55
-# $prefix/share/gpp4/syminfo.lib
56
-# $prefix/lib/syminfo.lib
57
-# $CCP4/lib/data/syminfo.lib
58
where $prefix is defined by the --prefix switch to the configure script.
59
The function allocates memory for the pathname that must be free'd
60
by the caller in order to avoid a memory leak.
61
@return path to syminfo.lib file.
63
static char *open_syminfo_file()
67
char *fnam = (char *)ccp4_utils_malloc(512);
69
if ((str = getenv("SYMINFO"))) {
70
/* SYMINFO was defined, now check to see if file exists */
71
strncpy (fnam, str, 512);
72
if( stat(fnam,&statbuf) == 0) {
73
printf("\n Spacegroup information obtained from library file: \n");
74
printf(" Logical Name: SYMINFO Filename: %s\n\n", fnam);
79
printf("Environment variable SYMINFO not set ... guessing location of symmetry file.\n");
81
strncpy (fnam, "./syminfo.lib", 14);
82
if( stat(fnam,&statbuf) == 0) {
83
printf("\n Spacegroup information obtained from local file: %s\n", fnam);
87
strncpy (fnam, GPP4_PREFIX, 512-24);
88
strncat (fnam, "/share/gpp4/syminfo.lib", 24);
89
if( stat(fnam,&statbuf) == 0) {
90
printf("\n Spacegroup information obtained from system file: %s\n", fnam);
94
strncpy (fnam, GPP4_PREFIX, 512-17);
95
strncpy (fnam, "/lib/syminfo.lib", 17);
96
if( stat(fnam,&statbuf) == 0) {
97
printf("\n Spacegroup information obtained from system file: %s\n", fnam);
101
/* Hmmm. Try one last time in the CCP4 installation */
103
if (!(str = getenv("CCP4"))) {
104
printf("Environment variable CCP4 not set ... big trouble! \n");
109
strncpy(fnam, str, 512);
110
strncat(fnam,"/lib/data/syminfo.lib", 22);
111
if( stat(fnam,&statbuf) == 0) {
112
printf("\n Spacegroup information obtained from CCP4 library: %s\n", fnam);
48
#define CSYMERR_SyminfoTokensMissing 6
121
51
CCP4SPG *ccp4spg_load_by_standard_num(const int numspg)
143
73
return ccp4spg_load_spacegroup(0, 0, NULL, NULL, nsym1, op1);
77
char *gpp4_open_syminfo_file();
146
80
CCP4SPG *ccp4spg_load_spacegroup(const int numspg, const int ccp4numspg,
147
81
const char *spgname, const char *ccp4spgname,
148
82
const int nsym1, const ccp4_symop *op1)
150
84
{ CCP4SPG *spacegroup;
151
85
int i,j,k,l,debug=0,nsym2,symops_provided=0,ierr,ilaue;
152
float sg_chb[4][4],limits[2],rot1[4][4],rot2[4][4];
86
float sg_chb[4][4],limits[2],rot1[4][4],rot2[4][4],det;
154
88
char *symopfile, *ccp4dir, filerec[80];
155
89
ccp4_symop *op2,*op3,opinv;
91
static int reported_syminfo = 0; /* report location of SYMINFO first time only */
157
93
/* spacegroup variables */
158
94
int sg_num, sg_ccp4_num, sg_nsymp, sg_num_cent;
159
95
float cent_ops[4][4];
230
168
printf(" parser initialised \n");
232
170
while (fgets(filerec,80,filein)) {
172
/* If syminfo.lib comes from a DOS platform, and we are on
173
unix, need to strip spurious \r character. Note this is
174
necessary because we have removed \r as parser delimiter. */
175
if (strlen(filerec) > 1){
176
if (filerec[strlen(filerec)-2]=='\r') {
177
filerec[strlen(filerec)-2]='\n';
178
filerec[strlen(filerec)-1]='\0';
233
182
if (strlen(filerec) > 1) {
235
184
ccp4_parser(filerec, 80, parser, iprint);
237
186
if (ccp4_keymatch(key, "number")) {
238
sg_num = (int) token[1].value;
187
if (parser->ntokens < 2) {
188
printf("Current SYMINFO line = %s\n",filerec);
189
ccp4_signal(CCP4_ERRLEVEL(2) | CSYM_ERRNO(CSYMERR_SyminfoTokensMissing),"ccp4spg_load_spacegroup",NULL);
191
sg_num = (int) token[1].value;
241
195
if (ccp4_keymatch(key, "basisop")) {
245
199
if (ccp4_keymatch(key, "symbol")) {
246
if (strcmp(token[1].fullstring,"ccp4") == 0)
247
sg_ccp4_num = (int) token[2].value;
248
if (strcmp(token[1].fullstring,"Hall") == 0)
249
strcpy(sg_symbol_Hall,token[2].fullstring);
250
if (strcmp(token[1].fullstring,"xHM") == 0)
251
strcpy(sg_symbol_xHM,token[2].fullstring);
252
if (strcmp(token[1].fullstring,"old") == 0)
253
strcpy(sg_symbol_old,token[2].fullstring);
254
if (strcmp(token[1].fullstring,"patt") == 0)
255
strcpy(sg_patt_group,token[3].fullstring);
256
if (strcmp(token[1].fullstring,"pgrp") == 0)
257
strcpy(sg_point_group,token[3].fullstring);
200
if (parser->ntokens < 3) {
201
printf("Current SYMINFO line = %s\n",filerec);
202
ccp4_signal(CCP4_ERRLEVEL(2) | CSYM_ERRNO(CSYMERR_SyminfoTokensMissing),"ccp4spg_load_spacegroup",NULL);
204
if (strcmp(token[1].fullstring,"ccp4") == 0)
205
sg_ccp4_num = (int) token[2].value;
206
if (strcmp(token[1].fullstring,"Hall") == 0)
207
strcpy(sg_symbol_Hall,token[2].fullstring);
208
if (strcmp(token[1].fullstring,"xHM") == 0)
209
strcpy(sg_symbol_xHM,token[2].fullstring);
210
if (strcmp(token[1].fullstring,"old") == 0)
211
strcpy(sg_symbol_old,token[2].fullstring);
212
if (strcmp(token[1].fullstring,"patt") == 0)
213
strcpy(sg_patt_group,token[3].fullstring);
214
if (strcmp(token[1].fullstring,"pgrp") == 0)
215
strcpy(sg_point_group,token[3].fullstring);
260
219
if (ccp4_keymatch(key, "hklasu")) {
261
if (strcmp(token[1].fullstring,"ccp4") == 0)
262
strcpy(sg_asu_descr,token[2].fullstring);
220
if (parser->ntokens < 3) {
221
printf("Current SYMINFO line = %s\n",filerec);
222
ccp4_signal(CCP4_ERRLEVEL(2) | CSYM_ERRNO(CSYMERR_SyminfoTokensMissing),"ccp4spg_load_spacegroup",NULL);
224
if (strcmp(token[1].fullstring,"ccp4") == 0)
225
strcpy(sg_asu_descr,token[2].fullstring);
265
229
if (ccp4_keymatch(key, "mapasu")) {
266
if (strcmp(token[1].fullstring,"zero") == 0) {
267
strcpy(map_asu_x,token[2].fullstring);
268
strcpy(map_asu_y,token[3].fullstring);
269
strcpy(map_asu_z,token[4].fullstring);
270
} else if (strcmp(token[1].fullstring,"ccp4") == 0) {
271
strcpy(map_asu_ccp4_x,token[2].fullstring);
272
strcpy(map_asu_ccp4_y,token[3].fullstring);
273
strcpy(map_asu_ccp4_z,token[4].fullstring);
230
if (parser->ntokens < 5) {
231
printf("Current SYMINFO line = %s\n",filerec);
232
ccp4_signal(CCP4_ERRLEVEL(2) | CSYM_ERRNO(CSYMERR_SyminfoTokensMissing),"ccp4spg_load_spacegroup",NULL);
234
if (strcmp(token[1].fullstring,"zero") == 0) {
235
strcpy(map_asu_x,token[2].fullstring);
236
strcpy(map_asu_y,token[3].fullstring);
237
strcpy(map_asu_z,token[4].fullstring);
238
} else if (strcmp(token[1].fullstring,"ccp4") == 0) {
239
strcpy(map_asu_ccp4_x,token[2].fullstring);
240
strcpy(map_asu_ccp4_y,token[3].fullstring);
241
strcpy(map_asu_ccp4_z,token[4].fullstring);
393
362
strncpy(filerec,sg_symop[j],80); /* symop_to_mat4 overwrites later sg_symop */
394
363
symop_to_mat4(filerec,filerec+strlen(filerec),rot2[0]);
395
364
ccp4_4matmul(rot1,(const float (*)[4])cent_ops,(const float (*)[4])rot2);
396
invert4matrix((const float (*)[4])rot1,rot2);
365
det=invert4matrix((const float (*)[4])rot1,rot2);
366
if (debug) printf("symop determinant: %f\n",det);
397
367
for (k = 0; k < 3; ++k) {
398
368
for (l = 0; l < 3; ++l) {
399
369
spacegroup->symop[i*sg_nsymp+j].rot[k][l]=rot1[k][l];