Esempio n. 1
0
int main() 
{
   int char_count1, char_count2, char_count3;
   double overlap_percent1, overlap_percent2, overlap_percent3;

   input = fopen("dna_input.dat","r");
  output = fopen("dna_output.dat", "w");

  /* Reading DNA sequences */
  //each of char counts should have the same value.
  char_count1 = read_DNA(DNAseq1);
  char_count2 = read_DNA(DNAseq2);
  char_count3 = read_DNA(DNAseq3);

  /* Comparing DNA sequences and computing their overlap percentage */
  overlap_percent1 = compare_DNA(DNAseq1, DNAseq2, DNAcomp12, char_count1);
  overlap_percent2 = compare_DNA(DNAseq1, DNAseq3, DNAcomp13, char_count2);
  overlap_percent3 = compare_DNA(DNAseq2, DNAseq3, DNAcomp23, char_count3);

  /* Prints comparison between sequence 1 and sequence 2 */
  fprintf(output, "Comparison between sequence #1 and sequence #2:\n\n");
  print_DNA(DNAseq1, DNAseq2, DNAcomp12, char_count1);
  fprintf(output, "The overlap percentage is %.1lf%%\n\n", overlap_percent1);

  /* Prints comparison between sequence 1 and sequence 3 */
  fprintf(output, "Comparison between sequence #1 and sequence #3:\n\n");
  print_DNA(DNAseq1, DNAseq3, DNAcomp13, char_count2);
  fprintf(output, "The overlap percentage is %.1lf%%\n\n", overlap_percent2);
  
  /* Prints comparison between sequence 2 and sequence 3 */
  fprintf(output, "Comparison between sequence #2 and sequence #3:\n\n");
  print_DNA(DNAseq2, DNAseq3, DNAcomp23, char_count3);
  fprintf(output, "The overlap percentage is %.1lf%%\n\n", overlap_percent3);

  fclose(input); fclose(output);
  
  return 0;
}
Esempio n. 2
0
int main(){
   char seq1[MAX_IN_LENGTH],seq2[MAX_IN_LENGTH],seq3[MAX_IN_LENGTH],seq4[MAX_IN_LENGTH],
        seq5[MAX_IN_LENGTH],seq6[MAX_IN_LENGTH];
   for(int i = 0; i < MAX_IN_LENGTH; i++){
      seq1[i] = 0;
      seq2[i] = 0;
      seq3[i] = 0;
      seq4[i] = 0;
      seq5[i] = 0;
      seq6[i] = 0;
   }
   input = fopen(INPUT_FILE, "r");
   int numRead = read_DNA(seq1);
   read_DNA(seq2);
   read_DNA(seq3);

   fclose(input);
   output =fopen(OUTPUT_FILE, "w");
   fprintf(output,"Comparison between sequence #1 and sequence #2:\n");
   double ratio = compare_DNA(seq1,seq2,seq4,numRead);
   print_DNA(seq1,seq4,seq2,numRead);
   fprintf(output, "The overlap percentage is %.1lf%%\n\n",ratio);

   fprintf(output,"Comparison between sequence #1 and sequence #3:\n");
   ratio = compare_DNA(seq1,seq3,seq5,numRead);
   print_DNA(seq1,seq5,seq3,numRead);
   fprintf(output, "The overlap percentage is %.1lf%%\n\n",ratio);

   fprintf(output,"Comparison between sequence #2 and sequence #3:\n");
   ratio = compare_DNA(seq2,seq3,seq6,numRead);
   print_DNA(seq2,seq6,seq3,numRead);
   fprintf(output, "The overlap percentage is %.1lf%%\n\n",ratio);

   fclose(output);
   
return 0;
}