#pragma once

#ifndef _UTILITY_H
#define _UTILITY_H

#include<vector>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string.h>
#include<ctype.h>
#include<string>
#include<fstream>
#include<list>
#include<Windows.h>
#include<process.h>
using namespace std;



typedef long long int64;
typedef unsigned long long uint64;
const int LengthLongType = 64;
const int NumOfGenotype = 3;
const int NumOfCell = 9;
static unsigned char wordbits[65536];

#define MarginalDistrSNP_Y_DimensionX 4
#define MarginalDistrSNP_Y_DimensionY 3

#define THREAD_NUM 256
#define BLOCK_NUM 128

class para_data {
public:
	uint64 **genoY_G;
	int *pMarginalDistrSNP;
	int *pMarginalDistrSNP_Y;
	int *nlongintY_G;
	vector<pair<int, int> >* Partial_InterPairs;
	vector<double>* Partial_InterMeasure;
	int start_snp, end_snp, nsnps;
	int numofCov;
	int nsamples;
	int index;
	double thresholdRecord;
};



int popcount(uint64 i);

int bitCount(uint64 i);

double Abs(double a);

void CalculateMarginalDistr(uint64 **genoY_G, int nsnps, int nsamples, int* nY_G, int* pMarginalDistrSNP, int* pMarginalDistrSNP_Y);

int BOOST2(char* filelistname, char* outputfileprefix, int numofCov, float testThreshold, int numofThread);

void GetInteractionPairs(uint64** genoY_G, int nsnps, int nsamples, int numOfCov, int* nlongintY_G, int* nY_G, int* pMarginalDistrSNP, int* pMarginalDistrSNP_Y,
	const unsigned char* wordbits, int wordBitCount, vector<pair<int,int>>&interactionPairs, vector<double>&interactionMeasure, double thresholdRecord,int numofThread);


double postCorrection_1(int* localGenoDistr, bool flag);
double postCorrection_2(int* localGenoDistr, bool flag);
double postCorrection_3(int* localGenoDistr, bool flag);
double postCorrection_4(int* localGenoDistr, bool flag);
double postCorrection_5(int* localGenoDistr, bool flag);



#endif