4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * GROningen Mixture of Alchemy and Childrens' Stories
32 static char *SRCID_pdb2gmx_c
= "$Id$";
66 static void dump_res(FILE *fp
,int indent
,t_restp
*restp
,int nah
,
67 t_hackblock
*ah
,int nres_long
,char **res_long
)
69 char *rtype
[ebtsNR
] = { "rbond", "rangle", "rdihedral", "rimproper" };
70 int ntype
[ebtsNR
] = { 2, 3, 4, 4 };
75 for(nn
=0; (nn
< nres_long
) && (strstr(res_long
[nn
],restp
->resname
) == NULL
); nn
++)
78 tmp
= res_long
[nn
] + strlen(restp
->resname
);
79 while (*tmp
&& isspace(*tmp
)) {
87 fprintf(fp
,"<residue restype=\"%s\" longname=\"%s\">\n",restp
->resname
,descr
);
90 for(i
=0; (i
<restp
->natom
); i
++) {
92 fprintf(fp
,"<ratom name=\"%s\">\n",*restp
->atomname
[i
]);
94 for(i
=0; (i
<ebtsNR
); i
++) {
95 for(j
=0; (j
<restp
->rb
[i
].nb
); j
++) {
97 fprintf(fp
,"<%s",rtype
[i
]);
98 for(k
=0; (k
<ntype
[i
]); k
++)
99 fprintf(fp
," a%d=\"%s\"",k
+1,restp
->rb
[i
].b
[j
].a
[k
]);
103 for(i
=0; (i
<nah
); i
++) {
104 if (strcmp(restp
->resname
,ah
[i
].name
) == 0) {
105 for(j
=0; (j
<ah
[i
].nhack
); j
++) {
106 pr_indent(fp
,indent
);
107 if ((ah
[i
].hack
[j
].a
[0][0] == 'O') || (ah
[i
].hack
[j
].a
[0][0] == 'N'))
108 fprintf(fp
,"<raddh hclass=\"polar\" ");
110 fprintf(fp
,"<raddh hclass=\"aliphatic\"");
111 fprintf(fp
," addgeom=\"%d\" addnum=\"%d\"",
112 ah
[i
].hack
[j
].tp
,ah
[i
].hack
[j
].nr
);
113 fprintf(fp
," addto=\"%s",ah
[i
].hack
[j
].a
[0]);
114 for(k
=1; ((k
<= 3) && (ah
[i
].hack
[j
].a
[k
] > 0)); k
++)
115 fprintf(fp
," %s",ah
[i
].hack
[j
].a
[k
]);
116 fprintf(fp
,"\"/>\n");
122 pr_indent(fp
,indent
);
123 fprintf(fp
,"</residue>\n\n");
126 static void dump_hack_add(FILE *fp
,int indent
,t_hack
*hack
)
128 pr_indent(fp
,indent
);
129 fprintf(fp
,"<modadd addname=\"%s\" addgeom=\"%d\" addto=\"%s %s %s\"/>\n",
130 hack
->nname
,hack
->tp
,hack
->a
[0],hack
->a
[1],hack
->a
[2]);
133 static void dump_hack_del(FILE *fp
,int indent
,t_hack
*hack
)
135 pr_indent(fp
,indent
);
136 fprintf(fp
,"<moddelete delname=\"%s\"/>\n",hack
->oname
);
139 static void dump_hack_rep(FILE *fp
,int indent
,t_hack
*hack
)
141 pr_indent(fp
,indent
);
142 fprintf(fp
,"<modreplace oldname=\"%s\" newname=\"%s\"/>\n",hack
->oname
,hack
->nname
);
145 static void dump_mod(FILE *fp
,int indent
,t_hackblock
*tdb
,t_atomtype
*atype
)
149 pr_indent(fp
,indent
);
150 fprintf(fp
,"<moddef modtype=\"%s\"\n",tdb
->name
);
152 for(j
=0; (j
<tdb
->nhack
); j
++) {
153 if (tdb
->hack
[j
].oname
== NULL
)
154 dump_hack_add(fp
,indent
,&(tdb
->hack
[j
]));
155 else if (tdb
->hack
[j
].nname
== NULL
)
156 dump_hack_del(fp
,indent
,&(tdb
->hack
[j
]));
158 dump_hack_rep(fp
,indent
,&(tdb
->hack
[j
]));
161 pr_indent(fp
,indent
);
162 fprintf(fp
,"</moddef>\n\n");
165 static void dump_mods(FILE *fp
,int indent
,
166 int n
,t_hackblock tdb
[],t_atomtype
*atype
)
171 dump_mod(fp
,indent
,&(tdb
[i
]),atype
);
174 static void do_specbonds(FILE *fp
,int indent
)
179 pr_indent(fp
,indent
);
180 fprintf(fp
,"<linkdef linktype=\"peptide\" restype=\"* *\" atomprev=\"C\" atomnext=\"N\" refdist=\"0.133\"/>\n");
181 sb
= get_specbonds(&nsb
);
182 for(i
=0; (i
<nsb
); i
++) {
183 pr_indent(fp
,indent
);
184 fprintf(fp
,"<linkdef linktype=\"unknown\" restype=\"%s %s\" atomprev=\"%s\" atomnext=\"%s\" refdist=\"%g\"/>\n",
185 sb
[i
].res1
,sb
[i
].res2
,sb
[i
].atom1
,sb
[i
].atom2
,sb
[i
].length
);
187 done_specbonds(nsb
,sb
);
192 int main(int argc
, char *argv
[])
194 static char *desc
[] = {
195 "This program reads an rtp file and dumps an xml file."
222 t_atoms pdba_all
,*pdba
;
225 int chain
,nch
,maxch
,nwaterchain
;
238 char fn
[256],*top_fn
,itp_fn
[STRLEN
],posre_fn
[STRLEN
],buf_fn
[STRLEN
];
239 char molname
[STRLEN
],title
[STRLEN
];
242 t_hackblock
*ntdb
,*ctdb
;
246 bool bUsed
,bDummies
=FALSE
,bWat
,bPrevWat
=FALSE
,bITP
,bDummyAromatics
=FALSE
;
251 CopyRight(stderr
,argv
[0]);
253 ff
= strdup("ffgmx2");
255 /* Read long residue names */
256 nres_long
= get_file("res-long.dat",&res_long
);
258 /* Read atomtypes... */
259 atype
=read_atype(ff
,&symtab
);
261 /* read residue database */
262 printf("Reading residue database... (%s)\n",ff
);
263 nrtp
=read_resall(ff
,bts
,&restp
,atype
,&symtab
,&bAlldih
,&nrexcl
);
265 /* read hydrogen database */
266 nah
=read_h_db(ff
,&ah
);
268 /* Read Termini database... */
269 nNtdb
=read_ter_db(ff
,'n',&ntdb
,atype
);
270 nCtdb
=read_ter_db(ff
,'c',&ctdb
,atype
);
272 fp
=fopen("residues.xml","w");
273 /* fprintf(fp,"<?xml version=\"1.0\"?>\n");
274 fprintf(fp,"<!DOCTYPE residues SYSTEM \"residues.dtd\">\n"); */
275 fprintf(fp
,"\n<residues>\n");
276 for(i
=0; (i
<nrtp
); i
++) {
277 dump_res(fp
,2,&(restp
[i
]),nah
,ah
,nres_long
,res_long
);
280 dump_mods(fp
,2,nNtdb
,ntdb
,atype
);
281 dump_mods(fp
,2,nCtdb
,ctdb
,atype
);
282 fprintf(fp
,"</residues>\n");