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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Sequence.h"
#include "Parameters.h"
struct siRNA{
char *sequence;
long start;
int size;
double Tm;
double GC;
struct siRNA *next;
};
int window;
struct siRNA *head;
/**
* TODO
*
* Apparemment, j'ai des problèmes avec cette fonction, la chaîne de caractères
* est aberrante.
*/
char *substr(char *seq, int start, int end){
char *tmp = malloc(end*sizeof(char));
int i;
if(tmp==NULL){
fprintf(stderr, "Memory allocation error !\n");
exit(2);
}
for(i=start; i<start+(end); i++){
tmp[i] = Sequence[i];
}
return tmp;
}
double getGC(char *seq){
double percent = 0;
int cpt = 0;
int i;
for(i=0; i<strlen(seq); i++){
if(seq[i]=='G' || seq[i]=='C')
cpt++;
}
percent = (100*cpt)/strlen(seq);
return percent;
}
struct siRNA *newSI(int start){
struct siRNA *rna;
rna = malloc(sizeof(struct siRNA));
if(rna==NULL){
fprintf(stderr, "Memory allocation error !\n");
exit(2);
}
rna->start = start;
printf("Start = %ld\n", rna->start);
rna->next=NULL;
rna->sequence = malloc(window*sizeof(char));
if(rna->sequence==NULL){
fprintf(stderr, "Memory allocation error !\n");
exit(2);
}
rna->sequence = substr(Sequence, start, window);
printf("Sequence = %s\n", rna->sequence);
rna->GC = getGC(rna->sequence);
printf("GC = %lf\n", rna->GC);
return rna;
}
void makeList(void){
int i;
window = atoi(parameters[1]);
head = NULL;
for(i=0; i<strlen(Sequence); i++){
if((i+window)>strlen(Sequence))
break;
head = newSI(i);
}
} |
Partager