1 | /** \file pdbformat.c
|
---|
2 | * Output in protein data bank (pdb) format
|
---|
3 | \author Marcel Arndt
|
---|
4 | $Id: pdbformat.c,v 1.9 2006/03/30 22:19:52 foo Exp $
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include<stdio.h>
|
---|
8 | #include<string.h>
|
---|
9 |
|
---|
10 |
|
---|
11 | #if 0
|
---|
12 | /** Output lines in PDB format.
|
---|
13 | * The PDB line includes:
|
---|
14 | * \param id atom serial number
|
---|
15 | * \param atomname atom nam
|
---|
16 | * \param residuename residue name
|
---|
17 | * \param residuenr residue sequence number
|
---|
18 | * \param x position X in Angstroem
|
---|
19 | * \param y position X in Angstroem
|
---|
20 | * \param z position X in Angstroem,
|
---|
21 | * \param occupancy occupancy
|
---|
22 | * \param tempfact temperature factor
|
---|
23 | * \param segid segment identifier
|
---|
24 | * \param elementsymbol element symbol
|
---|
25 | * \param charge charge
|
---|
26 | */
|
---|
27 | static int WritePDBLine(FILE *f, unsigned id, const char* atomname, const char* residuename,
|
---|
28 | unsigned residuenr, double x, double y, double z,
|
---|
29 | double occupancy, double tempfact, const char* segid,
|
---|
30 | const char* elementsymbol, const char* charge)
|
---|
31 | {
|
---|
32 | char atomname2[5];
|
---|
33 | char residuename2[4];
|
---|
34 | char segid2[5];
|
---|
35 | char elementsymbol2[3];
|
---|
36 | char charge2[3];
|
---|
37 |
|
---|
38 | if (id > 99999)
|
---|
39 | id = 99999;
|
---|
40 |
|
---|
41 | if (strlen(atomname)>0 &&
|
---|
42 | ( ( atomname[0]=='0' ) ||
|
---|
43 | ( atomname[0]>='1' && atomname[0]<='9' ) ) )
|
---|
44 | strncpy(atomname2, atomname, 4);
|
---|
45 | else
|
---|
46 | {
|
---|
47 | atomname2[0] = ' ';
|
---|
48 | strncpy(atomname2+1, atomname, 3);
|
---|
49 | }
|
---|
50 | atomname2[4] = '\0';
|
---|
51 |
|
---|
52 | strncpy(residuename2, residuename, 3);
|
---|
53 | residuename2[3] = '\0';
|
---|
54 |
|
---|
55 | if (residuenr > 9999)
|
---|
56 | residuenr = 9999;
|
---|
57 |
|
---|
58 | if (x < -999.999)
|
---|
59 | x = -999.999;
|
---|
60 | if (x > 9999.999)
|
---|
61 | x = 9999.999;
|
---|
62 |
|
---|
63 | if (y < -999.999)
|
---|
64 | y = -999.999;
|
---|
65 | if (y > 9999.999)
|
---|
66 | y = 9999.999;
|
---|
67 |
|
---|
68 | if (z < -999.999)
|
---|
69 | z = -999.999;
|
---|
70 | if (z > 9999.999)
|
---|
71 | z = 9999.999;
|
---|
72 |
|
---|
73 | if (occupancy < -99.99)
|
---|
74 | occupancy = -99.99;
|
---|
75 | if (occupancy > 999.99)
|
---|
76 | occupancy = 999.99;
|
---|
77 |
|
---|
78 | if (tempfact < -99.99)
|
---|
79 | tempfact = -99.99;
|
---|
80 | if (tempfact > 999.99)
|
---|
81 | tempfact = 999.99;
|
---|
82 |
|
---|
83 | strncpy(segid2, segid, 4);
|
---|
84 | segid2[4] = '\0';
|
---|
85 |
|
---|
86 | strncpy(elementsymbol2, elementsymbol, 2);
|
---|
87 | elementsymbol2[2] = '\0';
|
---|
88 |
|
---|
89 | strncpy(charge2, charge, 2);
|
---|
90 | charge2[2] = '\0';
|
---|
91 |
|
---|
92 | return fprintf(f,
|
---|
93 | "ATOM %5u %-4s %3s %4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n",
|
---|
94 | id, /*<! atom serial number */
|
---|
95 | atomname2, /*<! atom name */
|
---|
96 | residuename2, /*<! residue name */
|
---|
97 | residuenr, /*<! residue sequence number */
|
---|
98 | x, /*<! position X in Angstroem */
|
---|
99 | y, /*<! position Y in Angstroem */
|
---|
100 | z, /*<! position Z in Angstroem */
|
---|
101 | occupancy, /*<! occupancy */
|
---|
102 | tempfact, /*<! temperature factor */
|
---|
103 | segid2, /*<! segment identifier */
|
---|
104 | elementsymbol2, /*<! element symbol */
|
---|
105 | charge2); /*<! charge */
|
---|
106 | }
|
---|
107 | #endif
|
---|