-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathway.c
67 lines (59 loc) · 1.64 KB
/
pathway.c
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
#include <stdlib.h>
#include "enzyme.h"
#include "pathway.h"
struct pathway {
char *nom;
int taille;
ptr_enzyme *tab;
};
ptr_pathway creerpathway() {
ptr_pathway voie = (ptr_pathway) malloc (sizeof(struct pathway));
return voie;
}
void saisie_voie(ptr_pathway voie) {
int i;
voie->nom=(char *)malloc(sizeof(char) * 30);
printf("Nom de la voie métabolique?\n");
scanf("%s", voie->nom);
printf("Nombre d'enzymes\n");
scanf("%d", &voie->taille);
voie->tab=(ptr_enzyme *)malloc(sizeof(ptr_enzyme) * voie->taille);
for (i=0; i<voie->taille; i++) {
ptr_enzyme item = creerenzyme();
item = saisie_enzyme(item);
voie->tab[i]=item;
}
}
void affichage_voie(ptr_pathway voie) {
int i;
printf("-------------\n");
printf("Nom voie : %s, taille : %d\n", voie->nom, voie->taille);
if (voie->taille==0) printf("Le tableau est vide, veuillez le remplir.\n");
else {
for (i=0; i<voie->taille; i++) {
affiche(voie->tab[i]);
}
}
printf("-------------\n");
}
void ouvrir_voie(ptr_pathway voie, FILE* fichier) {
char *_nom;
int poids;
voie->nom=(char *)malloc(sizeof(char) * 30);
fscanf(fichier, "%s %d", voie->nom, &voie->taille);
int j;
voie->tab=(ptr_enzyme *)malloc(sizeof(ptr_enzyme) * voie->taille);
for (j=0; j<voie->taille; j++) {
_nom=(char *)malloc(sizeof(char) * 30);
fscanf(fichier, "%s %d", _nom, &poids);
ptr_enzyme item=creer_enzyme(_nom,poids);
voie->tab[j]=item;
}
}
void sauvegarder_voie(ptr_pathway voie, FILE* out) {
int i;
fprintf(out, "%s %d ", voie->nom, voie->taille);
for (i=0; i<voie->taille; i++) {
sauvegarde(voie->tab[i], out);
}
}