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