1 /*****
2 This file is part of the Babel Program
3 Copyright (C) 1992-96 W. Patrick Walters and Matthew T. Stahl
4 All Rights Reserved
5 All Rights Reserved
6 All Rights Reserved
7 All Rights Reserved
8 
9 For more information please contact :
10 
11 babel@mercury.aichem.arizona.edu
12 ----------------------------------------------------------------------
13 FILE : wrcssr.c
14 AUTHOR(S) : Pat Walters
15 DATE : 2-94
16 PURPOSE : Routines to write a CSD CSSR type file
17 ******/
18 
19 #include "bbltyp.h"
20 
21 int
write_cssr(FILE * file1,ums_type * mol)22 write_cssr(FILE *file1, ums_type *mol)
23 {
24   int i,j;
25   char type_name[5];
26   pdb_type_rec *pdb_types;
27 
28   int result;
29 
30   pdb_types = (pdb_type_rec *)malloc((Atoms + 1) * sizeof(pdb_type_rec));
31 
32   /*
33   coord_type dim;
34   dim = calc_cell_dimensions(mol);
35   make_fractional(mol,dim);
36   */
37   if (mol->fract == NULL)
38   {
39     fprintf(file1,
40 	    " REFERENCE STRUCTURE = 00000   A,B,C =  %6.3f  %6.3f  %6.3f\n",
41 	    1.0,1.0,1.0);
42     fprintf(file1,
43 	    "   ALPHA,BETA,GAMMA =  90.000  90.000  90.000    SPGR =    P1\n");
44     fprintf(file1,"%4d\n\n",Atoms);
45   }
46   else
47   {
48     fprintf(file1,
49 	    " REFERENCE STRUCTURE = 00000   A,B,C =  %6.3f  %6.3f  %6.3f\n",
50 	    mol->fract->A,mol->fract->B,mol->fract->C);
51     fprintf(file1,
52 	    "   ALPHA,BETA,GAMMA =  %6.4f  %6.3f  %6.3f    SPGR =    ??\n",
53 	    mol->fract->Alpha,mol->fract->Beta,mol->fract->Gamma);
54     fprintf(file1,"%4d\n\n",Atoms);
55   }
56 
57   for(i = 1;i <= Atoms; i++)
58   {
59     result = get_output_type(i,"XYZ",Type(i),type_name,all_caps);
60     strcpy(pdb_types[i].name,type_name);
61     assign_pdb_number(pdb_types,i);
62 
63     fprintf(file1," %3d%2s%-3d  %8.5f  %8.5f  %8.5f ",
64 	    i,
65 	    type_name,
66 	    pdb_types[i].number,
67 	    X(i),
68 	    Y(i),
69 	    Z(i));
70     for (j = 0; j < Valence(i); j++)
71       fprintf(file1,"%4d",Connection(i,j));
72     fprintf(file1,"\n");
73   }
74   return(TRUE);
75 }
76 
77 
calc_cell_dimensions(ums_type * mol)78 coord_type calc_cell_dimensions(ums_type *mol)
79 {
80   int i;
81   double Xmax = -999999.0;
82   double Ymax = -999999.0;
83   double Zmax = -999999.0;
84   double Xmin = 999999.0;
85   double Ymin = 999999.0;
86   double Zmin = 999999.0;
87   coord_type point;
88 
89   for (i = 1; i < Atoms; i++)
90   {
91     if (X(i) > Xmax) Xmax = X(i);
92     if (Y(i) > Ymax) Ymax = Y(i);
93     if (Z(i) > Zmax) Zmax = Z(i);
94     if (X(i) < Xmin) Xmin = X(i);
95     if (Y(i) < Ymin) Ymin = Y(i);
96     if (Z(i) < Zmin) Zmin = Z(i);
97   }
98   point.x = Xmax - Xmin;
99   point.y = Ymax - Ymin;
100   point.z = Zmax - Zmin;
101 
102   return(point);
103 }
104 
105 
make_fractional(ums_type * mol,coord_type dim)106 void make_fractional(ums_type *mol, coord_type dim)
107 {
108   int i;
109 
110   for (i = 1; i <= Atoms; i++)
111   {
112     X(i) = X(i)/dim.x;
113     Y(i) = Y(i)/dim.y;
114     Z(i) = Z(i)/dim.z;
115   }
116 }
117 
118 
119 
120 
121 
122 
123 
124 
125 
126