hw8.cpp

// Programmer: Bushra Anjum

// file: hw8.cpp

#include "header.h"

using namespace std;

int main()

{

char cowDNA[MISSING_COWS][DNA_LENGTH_ORIG+1];

char cowTeeth[MISSING_COWS][TEETH_LENGTH+1];

string cowName[MISSING_COWS]={"Lucie", "Marley", "Pearl", "Darla", "Nellie" };

char sampleDNA[DNA_LENGTH_SAMPLE+1];

char sampleTeeth[TEETH_LENGTH+1];

float match, maxMatchPerCow=0, maxMatchAcrossCows=0;

int cowIndex=0;

//random seeding

srand(time(NULL));

//Generate dna strings for the 5 missing cows

for(int i =0;i<MISSING_COWS;i++)

{

generateDNAOrig(cowDNA[i]);

}

//Generate teeth strings for the 5 missing cows

for(int i =0;i<MISSING_COWS;i++)

{

generateTeeth(cowTeeth[i]);

}

//Printing dna and dental record strings for the 5 missing cows

for(int i =0;i<MISSING_COWS;i++)

{

cout<<cowName[i]<<endl;

cout<<string(cowName[i].size(),'-')<<endl;

cout<<"\tDental Record : "<<cowTeeth[i]<<endl;

cout<<"\tDNA : "<<cowDNA[i]<<endl<<endl;

}

//Generating and testing the three dead cow's data

for(int i =0;i<DEAD_COWS;i++)

{

cout<<"Sample "<<i<<endl;

cout<<"--------- "<<endl;

/****************************************/

//DNA TEST

/****************************************/

generateDNASample(sampleDNA);

cout<<"\nDNA: "<<sampleDNA<<endl;

//match sample DNA with each of the missing cow's DNA

for(int k = 0;k<MISSING_COWS;k++)

{

//try finding match in the 128 char DNA string

for(int j = 0;j<DNA_LENGTH_ORIG-DNA_LENGTH_SAMPLE;j++)

{

match = getMatch(sampleDNA, cowDNA[k],j);

//keep track of the maximum match found so far

if(match>maxMatchPerCow)

maxMatchPerCow=match;

}

cout<<"Match with "<<cowName[k]<<"\t"<<maxMatchPerCow*100<<"%"<<endl;

//keep track of the maimum match found across 5 cows

if( maxMatchPerCow > maxMatchAcrossCows)

{

maxMatchAcrossCows=maxMatchPerCow;

cowIndex=k;

}

maxMatchPerCow=0;

}

cout<<"(Max match is with "<<cowName[cowIndex]<<"\t: "<<maxMatchAcrossCows*100<<"%)"<<endl;

/****************************************/

//DENTAL RECORD TEST

/****************************************/

generateTeeth(sampleTeeth);

cout<<"\nDental Record: "<<sampleTeeth<<endl;

//match sample teeth with each of the missing cow's Dental Record

for(int k = 0;k<MISSING_COWS;k++)

{

if(dentalMatch(sampleTeeth, cowTeeth[k]))

cout<<cowName[k]<<"\t: Matched"<<endl;

else

cout<<cowName[k]<<"\t: Not Matched"<<endl;

}

cout<<endl;

maxMatchAcrossCows=0;

cowIndex=0;

}

goodbye();

return 0;

}