1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include<stdio.h>
#include<stdlib.h>
struct data
{
int chain_id;
int res_seq;
};
typedef struct
{
struct data *r1;
struct data *r2;
}
T;
void afficher_paires_scr (char const *nomfichier, int max_paires,
T * res_pair, int wireframe)
{
int k;
FILE *file;
if (nomfichier != NULL)
{
file = fopen (nomfichier, "w");
if (file == NULL)
{
fprintf (stderr, "Le fichier %s n'a pas pu etre ouvert\n",
nomfichier);
exit (1);
}
}
else
file = stdout;
fprintf (stderr, "Ecriture du fichier SCR: %s\n", nomfichier);
fprintf (file,
"select *\n wireframe off \n ribbons on \n color chain\n ");
for (k = 0; k < max_paires && res_pair[k].r1 != NULL; k++)
fprintf (file,
"select (* %c and %d) or (* %c and %d)\n"
" wireframe %d\n"
" color red\n"
" color red select *\n", res_pair[k].r1->chain_id,
res_pair[k].r1->res_seq, res_pair[k].r2->chain_id,
res_pair[k].r2->res_seq, wireframe + k);
if (nomfichier != NULL)
fclose (file);
}
int main (void)
{
struct data n11 = { 'a', 123 };
struct data n12 = { 'b', 456 };
struct data n21 = { 'c', 78 };
struct data n22 = { 'd', 90 };
T a[] = {
{&n11, &n12},
{&n21, &n22},
{NULL, NULL},
};
afficher_paires_scr (NULL, sizeof a / sizeof *a, a, 12);
return 0;
} |
Partager