Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
WrtCSSR.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file WrtCSSR.c
5 
6  \version V1.4
7  \date 07.07.14
8  \brief Write a CSSR file
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1991-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39  blWriteCSSR(fp,cssr,name,title)
40 
41  This subroutine will write a CSSR file from a linked list of structures
42  of type cssr_entry.
43 
44  The strucure is set up by including the file "cssr.h". For details of
45  the structure, see this file.
46 
47 **************************************************************************
48 
49  Usage:
50  ======
51 
52 \code
53  WriteCSSR(fp,cssr,name,title)
54 \endcode
55 
56  \param[in] *fp A pointer to type FILE in which the
57  CSSR file is stored.
58  \param[in] *cssr A pointer to the first allocated item of
59  the CSSR linked list
60  \param[in] *name The molecule's name.
61  \param[in] *title Title on the molecule.
62 
63 **************************************************************************
64 
65  Revision History:
66  =================
67 - V1.0 22.09.91 Original
68 - V1.1 01.06.92 Autodoc'd. Added FPU check.
69 - V1.2 10.06.93 void return; float->REAL
70 - V1.3 27.07.93 %f -> %lf
71 - V1.3 01.03.94 %lf -> %f (!)
72 - V1.4 07.07.14 Use bl prefix for functions By: CTP
73 
74 *************************************************************************/
75 /* Doxygen
76  -------
77  #GROUP Handling CSSR Data
78  #SUBGROUP File IO
79  #FUNCTION blWriteCSSR()
80  Write a CSSR file from a CSSR linked list.
81 */
82 /************************************************************************/
83 /* Includes
84 */
85 #include <stdio.h>
86 #include <string.h>
87 #include <math.h>
88 #include <stdlib.h>
89 
90 #include "MathType.h"
91 
92 #include "cssr.h" /* Note cssr includes pdb */
93 #include "macros.h"
94 
95 /************************************************************************/
96 /* Defines and macros
97 */
98 #define CR 13
99 #define LF 10
100 
101 /************************************************************************/
102 /* Globals
103 */
104 
105 /************************************************************************/
106 /* Prototypes
107 */
108 
109 /************************************************************************/
110 /*>void blWriteCSSR(FILE *fp, CSSR *cssr, char *name, char *title)
111  ---------------------------------------------------------------
112 *//**
113 
114  \param[in] *fp A pointer to type FILE in which the
115  CSSR file is stored.
116  \param[in] *cssr A pointer to the first allocated item of
117  the CSSR linked list
118  \param[in] *name The molecule's name.
119  \param[in] *title Title on the molecule.
120 
121  Write a CSSR file from a CSSR linked list.
122 
123 - 22.09.91 Original
124 - 01.06.92 Autodoc'd
125 - 10.06.93 void return; float->REAL
126 - 27.07.93 %f -> %lf
127 - 01.03.94 %lf -> %f (!)
128 - 07.07.14 Use bl prefix for functions By: CTP
129 */
130 void blWriteCSSR(FILE *fp,
131  CSSR *cssr,
132  char *name,
133  char *title)
134 {
135  REAL cell[3],
136  alpha, beta, gamma;
137  int natom;
138  CSSR *p;
139 
140  /* Initilialise cell parameters */
141  cell[0] = cell[1] = cell[2] = 1.0;
142  alpha = beta = gamma = 90.0;
143 
144  /*** Record 1, assume no REFCODE ***/
145  fprintf(fp," %8.3f%8.3f%8.3f\n",
146  cell[0],cell[1],cell[2]);
147 
148  /*** Record 2 ***/
149  fprintf(fp," %8.3f%8.3f%8.3f\n",
150  alpha,beta,gamma);
151 
152  /*** Record 3 ***/
153  /* Assume orthogonal.
154  Count the atoms
155  */
156  for(p=cssr, natom=0; p; NEXT(p)) natom++;
157  fprintf(fp,"%4d 1 %-60s\n",natom,name);
158 
159  /*** Record 4 ***/
160  /* We'll assume the charges are valid (even if 0.0) */
161  fprintf(fp," 2 %-60s\n",title);
162 
163  /*** Remaining records represent the atoms... ***/
164  for(p=cssr; p; NEXT(p))
165  {
166  fprintf(fp,"%4d %-4s %9.5f %9.5f %9.5f \
167 %4d%4d%4d%4d%4d%4d%4d%4d %8.4f %2d\n",
168  p->atnum,
169  p->atnam,
170  p->x,
171  p->y,
172  p->z,
173  p->link[0],
174  p->link[1],
175  p->link[2],
176  p->link[3],
177  p->link[4],
178  p->link[5],
179  p->link[6],
180  p->link[7],
181  p->charge,
182  p->group);
183  }
184 }
185 
Defines for CSSR handling.
char atnam[8]
Definition: cssr.h:71
#define NEXT(x)
Definition: macros.h:249
REAL x
Definition: cssr.h:66
Useful macros.
int link[8]
Definition: cssr.h:70
double REAL
Definition: MathType.h:67
Definition: cssr.h:63
int atnum
Definition: cssr.h:68
int group
Definition: cssr.h:69
REAL z
Definition: cssr.h:66
REAL y
Definition: cssr.h:66
REAL charge
Definition: cssr.h:65
Type definitions for maths.
void blWriteCSSR(FILE *fp, CSSR *cssr, char *name, char *title)
Definition: WrtCSSR.c:130