3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
51 #include "gmx_fatal.h"
71 static void dump_res(FILE *fp
,int indent
,t_restp
*restp
,int nah
,
72 t_hackblock
*ah
,int nres_long
,char **res_long
)
74 char *rtype
[ebtsNR
] = { "rbond", "rangle", "rdihedral", "rimproper" };
75 int ntype
[ebtsNR
] = { 2, 3, 4, 4 };
80 for(nn
=0; (nn
< nres_long
) && (strstr(res_long
[nn
],restp
->resname
) == NULL
); nn
++)
83 tmp
= res_long
[nn
] + strlen(restp
->resname
);
84 while (*tmp
&& isspace(*tmp
)) {
92 fprintf(fp
,"<residue restype=\"%s\" longname=\"%s\">\n",restp
->resname
,descr
);
95 for(i
=0; (i
<restp
->natom
); i
++) {
97 fprintf(fp
,"<ratom name=\"%s\">\n",*restp
->atomname
[i
]);
99 for(i
=0; (i
<ebtsNR
); i
++) {
100 for(j
=0; (j
<restp
->rb
[i
].nb
); j
++) {
101 pr_indent(fp
,indent
);
102 fprintf(fp
,"<%s",rtype
[i
]);
103 for(k
=0; (k
<ntype
[i
]); k
++)
104 fprintf(fp
," a%d=\"%s\"",k
+1,restp
->rb
[i
].b
[j
].a
[k
]);
108 for(i
=0; (i
<nah
); i
++) {
109 if (strcmp(restp
->resname
,ah
[i
].name
) == 0) {
110 for(j
=0; (j
<ah
[i
].nhack
); j
++) {
111 pr_indent(fp
,indent
);
112 if ((ah
[i
].hack
[j
].a
[0][0] == 'O') || (ah
[i
].hack
[j
].a
[0][0] == 'N'))
113 fprintf(fp
,"<raddh hclass=\"polar\" ");
115 fprintf(fp
,"<raddh hclass=\"aliphatic\"");
116 fprintf(fp
," addgeom=\"%d\" addnum=\"%d\"",
117 ah
[i
].hack
[j
].tp
,ah
[i
].hack
[j
].nr
);
118 fprintf(fp
," addto=\"%s",ah
[i
].hack
[j
].a
[0]);
119 for(k
=1; ((k
<= 3) && (ah
[i
].hack
[j
].a
[k
] > 0)); k
++)
120 fprintf(fp
," %s",ah
[i
].hack
[j
].a
[k
]);
121 fprintf(fp
,"\"/>\n");
127 pr_indent(fp
,indent
);
128 fprintf(fp
,"</residue>\n\n");
131 static void dump_hack_add(FILE *fp
,int indent
,t_hack
*hack
)
133 pr_indent(fp
,indent
);
134 fprintf(fp
,"<modadd addname=\"%s\" addgeom=\"%d\" addto=\"%s %s %s\"/>\n",
135 hack
->nname
,hack
->tp
,hack
->a
[0],hack
->a
[1],hack
->a
[2]);
138 static void dump_hack_del(FILE *fp
,int indent
,t_hack
*hack
)
140 pr_indent(fp
,indent
);
141 fprintf(fp
,"<moddelete delname=\"%s\"/>\n",hack
->oname
);
144 static void dump_hack_rep(FILE *fp
,int indent
,t_hack
*hack
)
146 pr_indent(fp
,indent
);
147 fprintf(fp
,"<modreplace oldname=\"%s\" newname=\"%s\"/>\n",hack
->oname
,hack
->nname
);
150 static void dump_mod(FILE *fp
,int indent
,t_hackblock
*tdb
,t_atomtype
*atype
)
154 pr_indent(fp
,indent
);
155 fprintf(fp
,"<moddef modtype=\"%s\"\n",tdb
->name
);
157 for(j
=0; (j
<tdb
->nhack
); j
++) {
158 if (tdb
->hack
[j
].oname
== NULL
)
159 dump_hack_add(fp
,indent
,&(tdb
->hack
[j
]));
160 else if (tdb
->hack
[j
].nname
== NULL
)
161 dump_hack_del(fp
,indent
,&(tdb
->hack
[j
]));
163 dump_hack_rep(fp
,indent
,&(tdb
->hack
[j
]));
166 pr_indent(fp
,indent
);
167 fprintf(fp
,"</moddef>\n\n");
170 static void dump_mods(FILE *fp
,int indent
,
171 int n
,t_hackblock tdb
[],t_atomtype
*atype
)
176 dump_mod(fp
,indent
,&(tdb
[i
]),atype
);
179 static void do_specbonds(FILE *fp
,int indent
)
184 pr_indent(fp
,indent
);
185 fprintf(fp
,"<linkdef linktype=\"peptide\" restype=\"* *\" atomprev=\"C\" atomnext=\"N\" refdist=\"0.133\"/>\n");
186 sb
= get_specbonds(&nsb
);
187 for(i
=0; (i
<nsb
); i
++) {
188 pr_indent(fp
,indent
);
189 fprintf(fp
,"<linkdef linktype=\"unknown\" restype=\"%s %s\" atomprev=\"%s\" atomnext=\"%s\" refdist=\"%g\"/>\n",
190 sb
[i
].res1
,sb
[i
].res2
,sb
[i
].atom1
,sb
[i
].atom2
,sb
[i
].length
);
192 done_specbonds(nsb
,sb
);
197 int main(int argc
, char *argv
[])
199 static char *desc
[] = {
200 "This program reads an rtp file and dumps an xml file."
227 t_atoms pdba_all
,*pdba
;
230 int chain
,nch
,maxch
,nwaterchain
;
243 char fn
[256],*top_fn
,itp_fn
[STRLEN
],posre_fn
[STRLEN
],buf_fn
[STRLEN
];
244 char molname
[STRLEN
],title
[STRLEN
];
247 t_hackblock
*ntdb
,*ctdb
;
251 gmx_bool bUsed
,bDummies
=FALSE
,bWat
,bPrevWat
=FALSE
,bITP
,bDummyAromatics
=FALSE
;
254 gmx_bool bAlldih
,bH14
,bRemoveDih
;
256 CopyRight(stderr
,argv
[0]);
258 ff
= strdup("ffgmx2");
260 /* Read long residue names */
261 nres_long
= get_file("res-long.dat",&res_long
);
263 /* Read atomtypes... */
264 atype
=read_atype(ff
,&symtab
);
266 /* read residue database */
267 printf("Reading residue database... (%s)\n",ff
);
268 nrtp
=read_resall(ff
,bts
,&restp
,atype
,&symtab
,&bAlldih
,&nrexcl
,&bH14
,&bRemoveDih
);
270 /* read hydrogen database */
271 nah
=read_h_db(ff
,&ah
);
273 /* Read Termini database... */
274 nNtdb
=read_ter_db(ff
,'n',&ntdb
,atype
);
275 nCtdb
=read_ter_db(ff
,'c',&ctdb
,atype
);
277 fp
=gmx_fio_fopen("residues.xml","w");
278 /* fprintf(fp,"<?xml version=\"1.0\"?>\n");
279 fprintf(fp,"<!DOCTYPE residues SYSTEM \"residues.dtd\">\n"); */
280 fprintf(fp
,"\n<residues>\n");
281 for(i
=0; (i
<nrtp
); i
++) {
282 dump_res(fp
,2,&(restp
[i
]),nah
,ah
,nres_long
,res_long
);
285 dump_mods(fp
,2,nNtdb
,ntdb
,atype
);
286 dump_mods(fp
,2,nCtdb
,ctdb
,atype
);
287 fprintf(fp
,"</residues>\n");