// ----------------------------------------------------------------------
//
// File:        Samples.h
//
// Description: 
//
// Date:        January 29, 2004
//
// Author(s):   Giri Narasimhan, Florida International University 
//
// ----------------------------------------------------------------------

#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

const int NAMELENGTH = 40;

#define MIN(a,b)  ((a < b) ? (a) : (b))
#define MAX(a,b)  ((a > b) ? (a) : (b))

struct individual
{
  char name[NAMELENGTH];
  float t1b1, t1b2, t1g1, t1g2, t2b1, t2b2, t2g1, t2g2;
  bool isHom; 
};

const int MAXSAMPLES = 100;

class Samples{
  individual HoS[MAXSAMPLES];
  individual HeS[MAXSAMPLES];
  int SampleCount, HoSCount, HeSCount;
  float TRACETHRESHOLD; // threshold for trace to decide homozygosity
  bool DEBUG;

 public: 
  Samples::Samples ()
  {
	SampleCount = 0;
	HoSCount = 0;
	HeSCount = 0;
	TRACETHRESHOLD = 20; //default
	DEBUG = false; //default
  }

  Samples::~Samples ()
  {
  }

  int getSampleCount ();
  int getHoSCount ();
  int getHeSCount ();
  float getThreshold ();
  void setThreshold (float f);
  void ReadOneSample (ifstream& fIn);
  void ReadAllSamples (ifstream& fIn);
  void ReadOneHSample (ifstream& fIn);
  void ReadAllHSamples (ifstream& fIn);
  bool testHomozygosity (individual ind);
  int HomoSameAllele (individual hoP1, individual hoP2);
  int HomoHeteroSameAllele (individual hoP1, individual heP2);
  int HeteroHeteroCommonAllele (individual heP1, individual heP2);
  float computeTrace (individual ind1, individual ind2);
  void ProcessAllSamples ();
  void OutputResults ();
  float computeThreshold (ofstream& fOut);
  void setDEBUG(bool b); 
};
