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
| Read * lireFastq(char * file, int taille){
char phrase[36];
char * read;
Read * tabRead = allocateReadStuct(1000, 20, taille, taille);
//Read * tabRead = (Read*)malloc(1000*sizeof(Read));
FILE *f = fopen(file, "r");
int i=0;
int retour;
int bonId;
int bonQualite;
regex_t preg;
if(f!=NULL){
while (fgets(phrase, 36, f) != NULL){
//tabRead[i]=malloc(sizeof(Read));
regcomp(&preg, "^@", REG_EXTENDED | REG_NOSUB);
bonId=regexec(&preg, phrase, 0, 0, 0);
if(!bonId){
read=substring(phrase, 0, strlen(phrase)-1);
//tabRead[i].ID=(char*)malloc((strlen(phrase)-1)*sizeof(char));
tabRead[i].ID=read+1;
printf("id : %s\n", read+1);
}
regcomp(&preg, "^[A-Z]{35}", REG_EXTENDED | REG_NOSUB);
retour=regexec(&preg, phrase, 0, 0, 0);
if(!retour){
read=substring(phrase, 0, taille);
//tabRead[i].seq=(char*)malloc(taille*sizeof(char));
tabRead[i].seq=read;
printf("seq : %s\n", read);
}
regcomp(&preg, "^[A-Z]{10}@@@", REG_EXTENDED | REG_NOSUB);
bonQualite=regexec(&preg, phrase, 0, 0, 0);
if(!bonQualite){
//tabRead[i].qualite=(char*)malloc(strlen(phrase)*sizeof(char));
tabRead[i].qualite=phrase;
printf("qualite : %s\n", phrase);
}
i++;
//printf("%s\n", tabRead[i].ID);
//printf("%s\n", tabRead[i].seq);
//printf("%s\n", tabRead[i].qualite);
//tabRead[i]=r;
}
fclose(f);
}
else{
printf("Impossible d'ouvrir le fichier %s.\n", file);
}
return tabRead;
} |
Partager