

#include "SNPSelTools.h"
//#include "RandomFuncs.h"

ofstream ferr;


void SNPSelTools::printHelp (ostream& fp, const float& version)
{
	fp<<"\n\n";
	fp<<" iHDivSel v"+NtoS(version)+"\n\n";

	fp<<"\t [-cutoff cutoff for EOS test]\n";
	fp<<"\t [-help | -h]\n";
    fp<<"\t [-format format of the input file]\n";
	fp<<"\t [-input input file]\n";
	fp<<"\t [-input2 input a second file]\n";
	fp<<"\t [-maf MAF]\n";
	fp<<"\t [-maxwin MaxWinSize]\n";
	fp<<"\t [-minwin minWinSize]\n";
	fp<<"\t [-onlyEOS do nvdFST or not]\n";
    fp<<"\t [-onlyrsidInfo]\n";
	fp<<"\t [-output output file]\n";
	fp<<"\t [-path path]\n";
	//fp<<"\t [-runs numruns]\n"; // (this is useful for windows) for a default base file name e.g name it performs automatically a number of files e.g name0, name 1 ...
    fp<<"\t [-sample sample size]\n";
    fp<<"\t [-sample2 sample size]\n";
    fp<<"\t [-selectives]\n";
	fp<<"\t [-singlepopfile]\n";
	fp<<"\t [-SL significance level]\n";
	fp<<"\t [-verbose]\n";
	fp<<"\t [-window window size]\n";

	fp<<"\n\n";

    fp<<"\t-cutoff <DOUBLE>\n. Define the value numdesvs in the computation of cutoff = fsttot+numdesvs*maxdev for the EOS test. Default is 1.\n";
    fp<<"\t-help|-h\nDisplays this help message.\n";
    fp<<"\t-format <STRING>\n. Specifies the format of the input file]\n";
    fp<<"\t-input <STRING>\n. Specifies the name of the input file. If defined when runs > 1 the run number from 0 to runs-1 will be added to it. \n";
    fp<<"\t-input2 <STRING>\n. Specifies the name of the second input file. It is considered only when the argument -singlepopfile is set to 1. \n";
    fp<<"\t-maf <DOUBLE>\n. Defines the minor allele frequency in the sample to consider a site as informative  (default is 0.05).\n";
    fp<<"\t-maxwin <INTEGER>\n. Defines the maximum window size (default is the total number of SNPs) under the variable window size setting. \n";
    fp<<"\t-minwin <INTEGER>\n. Defines the minimum window size (default is 11, the minimum available is 7).\n";
    fp<<"\t-onlyEOS <INTEGER>\n. By default is 0 and both tests are performed. If set to 1 then only the EOS test is performed. In any case, if the input formats are BS or GP only the EOS test is performed. \n";
    fp<<"\t-onlyrsidInfo <INTEGER>\n. By default is 0. When set to 1 the program generates an output file with the names, positions and frequencies of the whole set of analyzed SNPs.\n";
    fp<<"\t-output <STRING>\n. Specifies the header for the name of the output file.\n";
   	fp<<"\t-path <STRING>\n. Specifies the path to the input file.\n";
    //fp<<"\t-runs <INTEGER>\n. Specifies the number of files (1 by default) to analyze.\n";
    fp<<"\t-sample <INTEGER>\n. Defines the number of alignments for each population sample (50 by default).\n";
    fp<<"\t-sample2 <INTEGER>\n. Under the MS format, defines the number of alignments for a second population sample (0 by default).\n";
    fp<<"\t-selectives <DOUBLE>\n. User defined candidate sites to look for selection (if there are more than one value they must be separated by spaces).\n";
    fp<<"\t-singlepopfile <INTEGER>\n. By default is 0 so it is assumed that there are two populations in a file. When set to 1 under HM format, two different filenames (-input and -input2, one for each population) are needed. \n";
    fp<<"\t-SL <DOUBLE>\n. Defines the significance level(0.05 by default).\n";
    fp<<"\t-verbose <INTEGER>\n. By default is 0. If set to 1 then the program gives explicit information as the different steps are performed through the program. A log file is output at the end.\n";
    fp<<"\t-window <INTEGER>\n. Defines the fixed window size (0 by default). If 0 the window size will be variable.\n";

    fp<<"\n"<<endl;
}


void SNPSelTools::ParseArgs(int argc, char** argv,
                string& tag,
                bool& nogaps,
                bool& store,
                bool& old,
                string& path,
                string& format,
                bool& onepopfile,
                string& infile,
                string& infile2,
				string& outfile,
                bool& userfilename,
                int& numruns,
                int& popforHB,
                vector<double>& selectives,
                int& windowsize,
                int& samplesize,
                int& samplesize2,
				int& minWinSize,
                int& MaxWinSize,
                double& MAF,
                double& SL,
                bool& doEOS,
                bool& soloEPO,
                bool& EPOH,
                double& numdesvs,
                bool& fixseed,
                bool& useblocks,
                bool& verbose,
                bool& writersidInfo,
                bool& onlyrsidInfo,
                const float& version)
{

    bool pass=true;
    int errcode=0;
	for(int i=1; i<argc; ++i)
	{

        if(argv[i]== string("-tag"))
		{
			if (i!=argc-1)//
			{
				tag=(argv[++i]);
			}
			continue;
		}
        if(argv[i]== string("-nogaps"))
		{
			if (i!=argc-1)//
			{
				nogaps=atoi(argv[++i]);

			}
			continue;
		}
        if(argv[i]== string("-store") || argv[i]== string("-save"))
		{
			if (i!=argc-1)//
			{
				store=atoi(argv[++i]);

			}
			continue;
		}
        if(argv[i]== string("-old"))
		{
			if (i!=argc-1)//
			{
				old=atoi(argv[++i]);
			}
			continue;
		}
		if((argv[i]== string("-path")) )
		{

			if (i!=argc-1) // it is not the last argument
			{
				path=argv[++i];
			}
			continue;
		}
		if((argv[i]== string("-format")) )
		{

			if (i!=argc-1) // it is not the last argument
			{
				format=argv[++i];
			}
			continue;
		}
		if(argv[i]== string("-singlepopfile"))
		{
			if (i!=argc-1)//
			{
				onepopfile=atoi(argv[++i]);
				//if(onepopfile<0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-rsidInfo"))
		{
			if (i!=argc-1)//
			{
				writersidInfo=atoi(argv[++i]);
				//if(writersidInfo<0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-onlyrsidInfo"))
		{
			if (i!=argc-1)//
			{
				onlyrsidInfo=atoi(argv[++i]);
				//if(onlyrsidInfo<0) pass=false;
			}
			continue;
		}
		if((argv[i]== string("-inputfile")) || (argv[i]== string("-inputfile1")) || (argv[i]== string("-input")) || (argv[i]== string("-input1")))
		{

			if (i!=argc-1) // it is not the last argument
			{
				infile=argv[++i];


				userfilename=true;

			}
			continue;
		}
		if((argv[i]== string("-inputfile2")) || (argv[i]== string("-input2")))  // this only matters if onepopfile=true
		{

			if (i!=argc-1) // it is not the last argument
			{
				infile2=argv[++i];

			}
			continue;
		}
		if((argv[i]== string("-outputfile"))|| (argv[i]== string("-output")))
		{

			if (i!=argc-1) //
			{
				outfile=argv[++i];

			}
			continue;
		}
		if((argv[i]== string("-runs")))
		{
			if (i!=argc-1)//
			{
				numruns=atoi(argv[++i]);
				if(numruns<1) {pass=false;errcode=i;}
				else if(numruns> (numeric_limits<int>::max()-1) ) {pass=false;errcode=i;}
			}
			continue;
		}
		if( argv[i]== string("-reference") )
		{
			if (i!=argc-1)//
			{
				popforHB=atoi(argv[++i])-1;

				if(popforHB<-1 || popforHB>1) {pass=false;errcode=i;} // si se pasa 0 se convierte en -1 y se ignora y se calculará la de mayor muestra o la primera si son iguales

			}
			continue;
		}
		if((argv[i]== string("-selectives"))){

            if (i!=argc-1)//
			{
                double selpos = 0; // strtod return 0 if no number is encountered: https://www.cplusplus.com/reference/cstdlib/strtod/
                // https://man7.org/linux/man-pages/man3/strtol.3.html
                char *endptr;
                while(i!=argc-1){
                    //selpos = strtod(argv[++i], &endptr); //char* p; long converted = strtol(s, &p, 10);
                    selpos = strtod(argv[i+1], &endptr); // v0.5.3 April 2026
                    //if (endptr == argv[i]) // argument was not a number
                    if (endptr == argv[i+1] || *endptr != '\0' || std::isnan(selpos))  // v0.5.3 April 2026 argument was not a number el || es porque strtod se come 12abc lee el 12 y deja endptr como abc y no hay break si no añadimos la condicion tras el or lo mismo con nan, tb se como -inf e inf pero estos los voy a usar
                        break;
                    ++i; // v0.5.3 April 2026
                    selectives.push_back(selpos); // positions are assumed to begin with 0 if not, the user should substract 1 to the original position i.e. if user wnat to test first position 1 it should pass 0
                //cout<<selpos<<endl;
                };
//                if(i!=argc-1)
//                    --i; // if we are not i the last arg when selpos==0 we must recover the previous argument to continue the for
                continue;
            }

		}

		if(argv[i]== string("-sample"))
		{
			if (i!=argc-1)//
			{
				samplesize=atoi(argv[++i]);
				if(samplesize<3) {pass=false;errcode=i;}
				else if(samplesize> (numeric_limits<int>::max()-1) ) {pass=false;errcode=i;}
			}
			continue;
		}
		if(argv[i]== string("-sample2"))
		{
			if (i!=argc-1)//
			{
				samplesize2=atoi(argv[++i]);
				if(samplesize2<0) pass=false;
				else if(samplesize2> (numeric_limits<int>::max()-1) ){pass=false;errcode=i;}
			}
			continue;
		}

		if(argv[i]== string("-window"))
		{
			if (i!=argc-1)//
			{
				windowsize=atoi(argv[++i]);
				if(windowsize!=0 && windowsize<MinforWindows) {pass=false;errcode=i;}
				else if(windowsize> MaxforWindows ) {pass=false;errcode=i;}
			}
			continue;
		}

		if(argv[i]== string("-minwin"))
		{
			if (i!=argc-1)//
			{
				minWinSize=atoi(argv[++i]);
				if(minWinSize<MinforWindows) {pass=false;errcode=i;}
				else if(MaxWinSize> MaxforWindows ) {pass=false;errcode=i;}
			}
			continue;
		}
		if(argv[i]== string("-maxwin"))
		{
			if (i!=argc-1)//
			{
				MaxWinSize=atoi(argv[++i]);
				if(MaxWinSize<numeric_limits<int>::min()+1) {pass=false;errcode=i;}
				else if(MaxWinSize> MaxforWindows ) {pass=false;errcode=i;}
			}
			continue;
		}
		if(argv[i]== string("-maf"))
		{
			if (i!=argc-1)//
			{
				MAF=atof(argv[++i]);
				if(MAF<MinMAF || MAF >1) {pass=false;errcode=i;}
			}
			continue;
		}
		if(argv[i]== string("-SL"))
		{
			if (i!=argc-1)//
			{
				SL=atof(argv[++i]);
				if(SL<0.0) {pass=false;errcode=i;}
			}
			continue;
		}
		if(argv[i]== string("-cutoff"))
		{
			if (i!=argc-1)//
			{
				numdesvs=atof(argv[++i]);
				//if(numdesvs<0.0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-doEOS") || argv[i]== string("-DOEOS") || argv[i]== string("-DoEos") || argv[i]== string("-DoEOS") || argv[i]== string("-doEos") || argv[i]== string("-doeos") )
		{
			if (i!=argc-1)//
			{
				doEOS=atoi(argv[++i]);
				//if(soloEPO<0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-onlyEOS"))
		{
			if (i!=argc-1)//
			{
				soloEPO=atoi(argv[++i]);
				//if(soloEPO<0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-EPOH"))
		{
			if (i!=argc-1)//
			{
				EPOH=atoi(argv[++i]);
				//if(EPOH<0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-fixseed"))
		{
			if (i!=argc-1)//
			{
				fixseed=atoi(argv[++i]);
				//if(fixseed<0) pass=false;
			}
			continue;
		}
		if(argv[i]== string("-useblocks"))
		{
			if (i!=argc-1)//
			{
				useblocks=atoi(argv[++i]);
			}
			continue;
		}
		if(argv[i]== string("-verbose"))
		{
			if (i!=argc-1)//
			{
				verbose=atoi(argv[++i]);
				//if(verbose<0) pass=false;
			}
			continue;
		}
		if((argv[i]== string("-help")) || (argv[i]== string("-h")))
		{

			SNPSelTools::printHelp (cout,version);

			exit(0);
		}

		cerr<<"\n iHDS ERROR:"<<argv[i]<< " is not a valid command line parameter\n"<<endl;
		exit(1);
	}
/*
    if(userfilename){
        cout<<"HACSel warning:"<< "With user defined file name only one replicate allowed, -runs argument is ignored"<<endl;
        numruns=1;
    }
*/

    if(!pass){
            string msg = "\niHDS CONSOLE ARGUMENT ERROR: Check argument "+NtoS(errcode/2)+ ".\n";
            cout<<msg<<endl;
            texterr(errcode,msg,true);
    }
}

// Read just 1 run.
//the file contains two populations not necessarily with equal sample size in ms format
//It assumes each segsites tag inside the file represents two populations with sample size n1 and n2 being n1+n2 = samplesize sequences
bool  SNPSelTools::readmspopsdata(const string& path,const string& filename0, const int& samplesize,const int& n1,const int& n2, deque < deque<bool> >& data,vector < vector<double> >& snpositions)
{
	int tries=0, contsample=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size
    if(samplesize != n1+n2){
		string msg = "\nERROR: bad sample size "+ NtoS(n1) +"+"+NtoS(n2)+" <> "+NtoS(samplesize)+" in " +filename+"\n";
		cout<<msg<<endl;
		return false;
    }

	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

	string temp;
	vector<string> words;
    vector<int>segsites;

	datafile >> boolalpha;
	cout<<boolalpha;


   // the dimension of snpositions is two populations
   if(!snpositions.empty())
        snpositions.clear();
    snpositions.resize(2);

    int pop{0};
	while(!datafile.eof())
	{
		datafile.clear();
		temp.clear();
		words.clear();

		// Read lines until 's' the first char of segsites
		do{
            getline(datafile, temp);

		}while((temp[0]!='s') && !datafile.eof() );
        if(datafile.eof()) break;

// this is ms format

        words=get_words(temp);
        segsites.push_back(atoi(words[1].c_str()));
        cout<<"Read segsites "<<segsites.back()<<endl;

        if(segsites.back()> (numeric_limits<int>::max()-1) ){
            string msg = "ERROR: There is an excessive number of segregating sites in pop "+ NtoS(segsites.size())+ "\n";
            cout<<msg<<endl;
            texterr(0,msg,true);
        }
        vector<double>positions(segsites.back());

		// Read lines until 'p' the first char of positions
        cout<<"Reading positions..."<<endl;
		do{
            getline(datafile, temp);

		}while((temp[0]!='p') && !datafile.eof() );

        if(datafile.eof()) break;

        words.clear();
        words=get_words(temp);

        if(words[0]!="positions:"){
            string msg = "ERROR: There is a format problem reading positions in file "+ filename+ "\n";
            cout<<msg<<endl;
            texterr(2,msg,true);
        }
        if( ((int)words.size()-1) !=segsites.back()){
            string msg = "ERROR: There is a problem reading positions in file "+ filename+" Expected number of positions "+NtoS(segsites.back())+" was different of observed "+NtoS(words.size()-1)+ "\n";
            cout<<msg<<endl;
            texterr(3,msg,true);
        }
        double prevpos{-1};
        for(size_t pos=0; pos<positions.size(); ++pos){
            positions[pos]=atof(words[pos+1].c_str());
            if(positions[pos]<= prevpos){
                string msg = "ERROR: There is a problem with repeated positions in file "+ filename+" Positions "+NtoS(positions[pos])+" is equal to previous one "+NtoS(prevpos)+ "\n";

                msg+="The position is updated to "+ NtoS(positions[pos]+=0.0000001) +"\n";
                prevpos =positions[pos];
                cout<<setprecision(outputprecision)<<msg<<endl;
                texterr(4,msg,false);


            }
            else
                prevpos =positions[pos];
        }
//cout<<"Read postions "<<positions.size()<<endl;


        snpositions[pop]=(positions);

    // Read the SNP sequences
        deque<bool> haplotype(segsites.back());

        contsample=0;

        cout<<"Reading sample of size "+NtoS(n1)<<endl;
        for(int smp=0; smp<n1; ++smp){
        // each line is an haplotype of snps
            getline(datafile, temp);

            ++contsample;
            if((int)temp.size()!=segsites.back()){
                string msg = "ERROR: In sample "+NtoS(contsample)+ " there is a problem with haplotype size in pop "+ NtoS(pop)+" Expected haplo size "+NtoS(segsites.back())+" was different of observed "+NtoS(temp.size())+ "\n";
                cout<<msg<<endl;
                texterr(5,msg,true);
            }

            for(size_t bit=0;bit<temp.size();++bit)
                if(temp[bit]=='1') haplotype[bit]=1;
                else haplotype[bit]=0;

           // Introduce this haplo as a new row in data
            data.push_back(haplotype);

        } // close for smp
        ++pop;
        snpositions[pop]=(positions); // the same positions
        cout<<"Reading sample of size "+NtoS(n2)<<endl;
        for(int smp=0; smp<n2; ++smp){
        // each line is an haplotype of snps
            getline(datafile, temp);

            ++contsample;
            if((int)temp.size()!=segsites.back()){
                string msg = "ERROR: In sample "+NtoS(contsample)+ " there is a problem with haplotype size in pop "+ NtoS(pop)+" Expected haplo size "+NtoS(segsites.back())+" was different of observed "+NtoS(temp.size())+ "\n";
                cout<<msg<<endl;
                texterr(6,msg,true);
            }

            for(size_t bit=0;bit<temp.size();++bit)
                if(temp[bit]=='1') haplotype[bit]=1;
                else haplotype[bit]=0;

           // Introduce this haplo as a new row in data
            data.push_back(haplotype);

        } // close for smp
        //cout<<"Read sample "<<contsample<<endl;

        // Clean haplotype because the two populations from a given run were read
        haplotype.clear();
        deque<bool>().swap(haplotype);

        positions.clear();
        vector<double>().swap(positions);

        break; // we do not need to continue because this function just read one run so break here
	} // close while not eof

    if(segsites.empty()) return false;

    int datadim=segsites.size()*samplesize;

    words.clear();
    vector<string>().swap(words);
    segsites.clear();
    vector<int>().swap(segsites);



    if(data.size()!= (size_t)datadim){
        string msg = "ERROR: In file " +filename+ ". There is a problem with data size which is "+ NtoS(data.size())+" and should be "+NtoS(datadim)+ "\n";
        cout<<msg<<endl;
        texterr(7,msg,true);
    }


//	if(!datafile.eof())
//		{texterr(6,"ERROR READING INPUT FILE\n",true);}

cout<< "------------------------------------------------------------\n"<<endl;
	datafile.close();

	return true;
}

// the file contains two populations with equal sample size in ms format
bool  SNPSelTools::readmsdata(const string& path,const string& filename0, const int& samplesize,deque < deque<bool> >& data,vector < vector<double> >& snpositions)
{
	int tries=0, contsample=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable row length in different pops
	// and as much rows as numpops x sample size


	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

	string temp;
	vector<string> words;
    vector<int>segsites;

	datafile >> boolalpha;
	cout<<boolalpha;

    if(!snpositions.empty()){
        snpositions.clear();
    }

	while(!datafile.eof())
	{
		datafile.clear();
		temp.clear();
		words.clear();

		// Read lines until 's' the first char of segsites
		do{
            getline(datafile, temp);

		}while((temp[0]!='s') && !datafile.eof() );
        if(datafile.eof()) break;

// this is ms format

        words=get_words(temp);
        segsites.push_back(atoi(words[1].c_str()));
        cout<<"Read segsites "<<segsites.back()<<endl;

        if(segsites.back()> (numeric_limits<int>::max()-1) ){
            string msg = "ERROR: There is an excessive number of segregating sites in pop "+ NtoS(segsites.size())+ "\n";
            cout<<msg<<endl;
            texterr(0,msg,true);
        }

        vector<double>positions(segsites.back());

		// Read lines until 'p' the first char of positions
        cout<<"Reading positions..."<<endl;
		do{
            getline(datafile, temp);

		}while((temp[0]!='p') && !datafile.eof() );

        words.clear();
        words=get_words(temp);

        if(words[0]!="positions:"){
            string msg = "ERROR: There is a format problem reading positions in pop "+ NtoS(segsites.size())+ "\n";
            cout<<msg<<endl;
            texterr(2,msg,true);
        }
        if(((int)words.size()-1)!=segsites.back()){
            string msg = "ERROR: There is a problem reading positions in pop "+ NtoS(segsites.size())+" Expected number of positions "+NtoS(segsites.back())+" was different of observed "+NtoS(words.size()-1)+ "\n";
            cout<<msg<<endl;
            texterr(3,msg,true);
        }
        for(int pos=0; pos<segsites.back(); pos++){
            positions[pos]=atof(words[pos+1].c_str());
        }
        // the size of snpositions if the number of pops
        snpositions.push_back(positions);

        //cout<<"Read postions "<<positions.size()<<endl;

    // Read the SNP sequences
        deque<bool> haplotype(segsites.back());

        contsample=0;

        cout<<"Reading sample of size "+NtoS(samplesize)<<endl;
        for(int smp=0; smp<samplesize; ++smp){
        // each line is an haplotype of snps
            getline(datafile, temp);
            trim(temp);

            ++contsample;
            if((int)temp.size()!=segsites.back()){
                string msg = "ERROR: In sample "+NtoS(contsample)+ " there is a problem with haplotype size in pop "+ NtoS(segsites.size())+" Expected haplo size "+NtoS(segsites.back())+" was different of observed "+NtoS(temp.size())+ "\n";
                cout<<msg<<endl;
                texterr(4,msg,true);
            }

            for(size_t bit=0;bit<temp.size();++bit)
                if(temp[bit]=='1') haplotype[bit]=1;
                else haplotype[bit]=0;

           // Introduce this haplo as a new row in data
            data.push_back(haplotype);

        } // close for smp

        //cout<<"Read sample "<<contsample<<endl;

        // Clean haplotype because one pop was finished
        haplotype.clear();
        deque<bool>().swap(haplotype);

        positions.clear();
        vector<double>().swap(positions);

	} // close while not eof

    if(segsites.empty()) return false;

    int datadim=segsites.size()*samplesize;

    words.clear();
    vector<string>().swap(words);
    segsites.clear();
    vector<int>().swap(segsites);

    if(data.size()!= (size_t)datadim){
        string msg = "ERROR: In file " +filename+ ". There is a problem with data size which is "+ NtoS(data.size())+" and should be "+NtoS(datadim)+ "\n";
        cout<<msg<<endl;
        texterr(5,msg,true);
    }


	if(!datafile.eof())
		{texterr(6,"ERROR READING INPUT FILE\n",true);}

cout<< "------------------------------------------------------------\n"<<endl;
	datafile.close();

	return true;
}



///Read Format VCF for phased genotypes. Cada fichero representa una población a comparar.
///WARNING: The samples from a file are considered to be from the same population.

bool  SNPSelTools::readphasedVCF(const string& path,const string& filename1,const string& filename2, vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, int& pref)
{
try{

    /// *************************** Read the first file

    //int tries=0;

	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable length column in different pops
	// and as much as rows as numpops x sample size

	if(filename1==filename2){
        string msg = "\nERROR: same two files under VCF format: " +filename1+" and "+filename2+"\n";
		cout<<msg<<endl;
		return false;

	}


    if(!openfile(path, filename1,datafile, false))
    {

        string msg = "\nERROR: can not find input file " +filename1+"\n";
		cout<<msg<<endl;
		return false;

    }

    string temp="";

// skip blank lines and commentaries
    while((temp.empty()||temp.find("##")==0) && !datafile.eof() ){
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

// store info and skip first line
    vector<string> firstline, columns; // the data is transposed in the file

/// Header line is
/// #CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	sample1 sample2 ...
    firstline=get_words(temp);
    if(firstline[0]!="#CHROM"){
        string msg = "ERROR #CHROM header tag lacking: "+firstline[0]+ ". Bad VCF format in file "+ filename1+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }
    if(firstline[8]!="FORMAT"){
        string msg = "ERROR FORMAT header tag lacking: Bad VCF format in file "+ filename1+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }
    int numsamples{static_cast<int>(firstline.size())-9};
    int totsamples{numsamples};
    vector<string> sequences1(numsamples,""); // sequences by columns for one homolog
    vector<string> sequences2(numsamples,""); // sequences for the other homolog
    vector<double>positions;
    vector<string>genotype(2);

    int  numpopulations{2};
    vector<vector<string>> REF(numpopulations); // THE REFERENCE FOR EACH POPULATION


    samplesizes.resize(numpopulations);
    samplesizes[0]= numsamples;
// Read lines with the information: rsid position A A A ..A (composition of this rsid in the sample)
    int pos=0, crom=0;
    do{
        getline(datafile, temp);
        trim_left(temp);
//cout<<temp.find(comment_tag)<<endl;
        if(!temp.empty() && (temp.find(comment_tag)!=0)){ // it is not a line beginning by #
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
            columns = get_words(temp);
            if(pos==0){ // first position
                crom=atoi(columns[0].c_str());

            }

            if(atoi(columns[0].c_str())!=crom){
                string msg = "ERROR there is more than one chromosome in the file: Bad VCF-iHDivSel format in file "+ filename1+ "\n";
                cout<<msg<<endl;
                texterr(0,msg,true);
            }

assert(columns[8]=="GT"); // check is genotype format

            positions.push_back(atof(columns[1].c_str()));
            //Reference for the first population
            REF[0].push_back(columns[3]);

            //snpstable.emplace(atof(columns[1].c_str()),columns[0]); // unsorted_map with key the snp position and value the rsid

            for(size_t c=9; c < columns.size(); ++c){
                genotype=get_words(columns[c],'|');

                sequences1[c-9] += genotype[0];
                sequences2[c-9] += genotype[1];
            }
            ++pos;
        }
    }while(!datafile.eof() );

    datafile.close();

    if(sequences1[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename1+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

assert(sequences1[0].size()==sequences1.back().size());
assert(sequences1[0].size()==sequences2[0].size());



    cout<<"\nFile "<<filename1<<" was read"<<endl;


/// *************************** Read the second file

    if(!openfile(path, filename2,datafile, false))
    {

        string msg = "\nERROR: can not find input file " +filename2+"\n";
        cout<<msg<<endl;
        return false;

    }
    temp="";
    // skip blank lines
    while((temp.empty()||temp.find("##")==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

/// Header line is
/// #CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	sample1 sample2 ...
    firstline=get_words(temp);
    if(firstline[0]!="#CHROM"){
        string msg = "ERROR #CHROM header tag lacking: Bad VCF format in file "+ filename2+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }
    if(firstline[8]!="FORMAT"){
        string msg = "ERROR FORMAT header tag lacking: Bad VCF format in file "+ filename2+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }


    int numsamples2 = firstline.size()-9;
    samplesizes[1]= numsamples2;
    totsamples+= numsamples2;

    for(auto ar=0; ar< numsamples2; ++ar){ // add the necessary columns for the second sample
        sequences1.push_back("");
        sequences2.push_back("");
    }

    pos=0;
    do{
        getline(datafile, temp);
        trim_left(temp);
//cout<<temp.find(comment_tag)<<endl;
        if(!temp.empty() && (temp.find(comment_tag)!=0)){ // it is not a line beginning by #
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);

            columns = get_words(temp);

            if(atoi(columns[0].c_str())!=crom){
                string msg = "ERROR there are different chromosomes in file: "+ filename1+" and file "+ filename2+ ". Bad VCF-iHDivSel format.\n";
                cout<<msg<<endl;
                texterr(0,msg,true);
            }

            //Reference for the second population
            REF[1].push_back(columns[3]);

assert(columns[8]=="GT"); // check is genotype format

//assert(positions[pos]==atof(columns[1].c_str()));
            /// v0.5.3 April 2026
            double pos2 = atof(columns[1].c_str());

            if (pos >= static_cast<int>(positions.size())) {
                string msg = "ERROR: file " + filename2 +
                             " has more variant records than file " + filename1 +
                             ". First extra record:\n";
                msg += "File 2 -> CHROM=" + columns[0] + ", POS=" + NtoS(pos2) +
                       ", ID=" + columns[2] + ", REF=" + columns[3] +
                       ", ALT=" + columns[4] + "\n";
                cout << msg << endl;
                texterr(0, msg, true);
            }

            if (positions[pos] != pos2) {
                string msg = "ERROR: VCF position mismatch between files at record " +
                             NtoS(pos+1) + ".\n";
                msg += "File 1 -> CHROM=" + NtoS(crom) +
                       ", POS=" + NtoS(positions[pos]) + "\n";
                msg += "File 2 -> CHROM=" + columns[0] +
                       ", POS=" + NtoS(pos2) +
                       ", ID=" + columns[2] +
                       ", REF=" + columns[3] +
                       ", ALT=" + columns[4] + "\n";
                cout << msg << endl;
                texterr(0, msg, true);
            }
            for(size_t c=9; c < columns.size(); ++c){
                genotype=get_words(columns[c],'|');

                sequences1[samplesizes[0]+c-9] += genotype[0];
                sequences2[samplesizes[0]+c-9] += genotype[1];
            }
            ++pos;

        }
    }while(!datafile.eof() );

    datafile.close();

    if (pos != static_cast<int>(positions.size())) {
        string msg = "ERROR: file " + filename2 +
                     " has fewer variant records than file " + filename1 +
                     ". File 1 has " + NtoS(positions.size()) +
                     " records, but file 2 has " + NtoS(pos) + ".\n";
        cout << msg << endl;
        texterr(0, msg, true);
    }


    if(sequences1[samplesizes[0]].size()> (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename2+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

assert(sequences1[samplesizes[0]].size()==sequences1.back().size());
assert(sequences1[samplesizes[0]].size()==sequences2[samplesizes[0]].size());

    cout<<"\nFile "<<filename2<<" was read"<<endl;


assert (totsamples == samplesizes[0]+samplesizes[1]);

/// ************************* PARSE DATA INFORMATION

    ///The haplotype length sequences1[x].size() should be the same for each population
    cout<<"\nBegin to parse data\n"<<endl;
    int L = sequences1[0].size(); //The haplotype length must be the same in both populations and in every sample

    cout<<"\n Number of SNPs is "<<L<<endl;

    //snpfreqs.resize(numpopulations); /// no entiendo porque falla snpfreqs.resize(numpopulations, vector<double>(L,0));
    snpfreqs[0]= vector<double>(L,0);
    snpfreqs[1]= vector<double>(L,0);

    //snpositions.resize(numpopulations);
    snpositions[0]=positions;
    snpositions[1]=positions;
//cout<<setprecision(outputprecision);
//printcol(positions);
//exit(1);
    int indexsampl{0};

    cout<<"\n Sample sizes are "<<samplesizes[0]<<" and "<<samplesizes[1]<<endl;
    if(samplesizes[0]!=samplesizes[1]) // choose as ref that having the highest sample size
        pref = distance(samplesizes.begin(),max_element(samplesizes.begin(),samplesizes.end()));

/// Gather the information for data etc:
  	data.clear();
    data.resize(2*totsamples,deque<bool>(L,false)); // multiply by two to store both homologs in the sample

///The reference haplotype when different between populations is fixed by the reference population pref (the one with highest sample size)

    vector<string> nonref(numpopulations,string(L,'1'));
    for(auto pos=0; pos<L; ++pos){
        if(REF[0][pos]!=REF[1][pos]){
            nonref[1-pref][pos]='0';
        }

    }

    for(auto p=0; p<numpopulations; ++p){
        indexsampl = p>0? samplesizes[p-1]:0;

        for(auto s=0; s<samplesizes[p]; ++s){

            for(int pos=0; pos < L; ++pos){
//cout<<"\nHERE "<<p<<"-"<<s<<"-"<<pos<<"-"<<sequences1[s+indexsampl][pos]<<"-"<<sequences2[s+indexsampl][pos]<<endl;
                if(sequences1[s+indexsampl][pos] == nonref[p][pos]){
                    data[indexsampl + s][pos]=true;
                   // the frequency of the alternative allele
                   snpfreqs[p][pos]++;
                }
//if(pos==17){cout<<snpfreqs[p][pos]<<endl;cout<<"que???"<<endl;cout<<nonref[p][pos]<<endl;}
                if(sequences2[s+indexsampl][pos] == nonref[p][pos]){
                    data[indexsampl + s][pos]=true; /// BUG
                   // the frequency of the alternative allele
                   snpfreqs[p][pos]++;
                }

//if(pos==17){cout<<"que coooog???"<<endl;}
            } // close for pos

        } // close for sample

        cout<<"\nParsed pop " <<(p+1)<<endl;

       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (2*samplesizes[p]);});

    } // close for p
    /// Update sample sizes because is diploid
    samplesizes[0]*=2;
    samplesizes[1]*=2;

} catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
} catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename1 <<endl;
    return false;
} catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename2 <<endl;
    return false;
}
    return true;
}


/// v5.0.3 April 2026: Implementación de readphasedVCF que para dos los dos ficheros vcf se queda solo con la intersección de snps comunes
bool SNPSelTools::readphasedVCF_intersec(const string& path,
                               const string& filename1,
                               const string& filename2,
                               vector<int>& samplesizes,
                               deque< deque<bool> >& data,
                               vector< vector<double> >& snpfreqs,
                               vector< vector<double> >& snpositions,
                               int& pref)
{
try{
    struct VCFRecord {
        int chrom{0};
        double pos{0.0};
        string id;
        string ref;
        string alt;
        vector<char> hap1;   // one allele per sample: '0' or '1'
        vector<char> hap2;   // idem
    };

    auto share_allele = [](const string& ref1, const string& alt1,
                           const string& ref2, const string& alt2) -> bool
    {
        return (ref1 == ref2 || ref1 == alt2 || alt1 == ref2 || alt1 == alt2);
    };

    auto open_vcf_and_read_common_header =
        [&](const string& fname,
            ifstream& datafile,
            vector<string>& header_cols,
            int& numsamples) -> bool
    {
        if(!openfile(path, fname, datafile, false)) {
            string msg = "\nERROR: can not find input file " + fname + "\n";
            cout << msg << endl;
            return false;
        }

        string temp = "";
        while((temp.empty() || temp.find("##") == 0) && !datafile.eof()) {
            getline(datafile, temp);
            trim_left(temp);
        }

        if(datafile.eof()) return false;

        header_cols = get_words(temp);

        if(header_cols.empty() || header_cols[0] != "#CHROM") {
            string msg = "ERROR #CHROM header tag lacking: Bad VCF format in file " + fname + "\n";
            cout << msg << endl;
            texterr(0, msg, true);
        }
        if(header_cols.size() < 9 || header_cols[8] != "FORMAT") {
            string msg = "ERROR FORMAT header tag lacking: Bad VCF format in file " + fname + "\n";
            cout << msg << endl;
            texterr(0, msg, true);
        }

        numsamples = static_cast<int>(header_cols.size()) - 9;
        return true;
    };

    auto read_all_records =
        [&](ifstream& datafile,
            const string& fname,
            int expected_samples,
            vector<VCFRecord>& records,
            int& chrom_out) -> bool
    {
        string temp = "";
        vector<string> columns;
        vector<string> genotype;
        int poscount = 0;
        chrom_out = 0;

        do{
            getline(datafile, temp);
            trim_left(temp);

            if(!temp.empty() && temp.find(comment_tag) != 0) {
                transform(temp.begin(), temp.end(), temp.begin(), (int(*)(int))toupper);
                columns = get_words(temp);

                if(columns.size() < 9 + static_cast<size_t>(expected_samples)) {
                    string msg = "ERROR: malformed VCF line in file " + fname + "\n";
                    cout << msg << endl;
                    texterr(0, msg, true);
                }

                if(poscount == 0)
                    chrom_out = atoi(columns[0].c_str());
                else if(atoi(columns[0].c_str()) != chrom_out) {
                    string msg = "ERROR there is more than one chromosome in the file: Bad VCF-iHDivSel format in file " + fname + "\n";
                    cout << msg << endl;
                    texterr(0, msg, true);
                }

                if(columns[8] != "GT") {
                    string msg = "ERROR: FORMAT is not GT in file " + fname + " at position " + columns[1] + "\n";
                    cout << msg << endl;
                    texterr(0, msg, true);
                }

                VCFRecord rec;
                rec.chrom = chrom_out;
                rec.pos   = atof(columns[1].c_str());
                rec.id    = columns[2];
                rec.ref   = columns[3];
                rec.alt   = columns[4];
                rec.hap1.resize(expected_samples, '0');
                rec.hap2.resize(expected_samples, '0');

                for(int c = 0; c < expected_samples; ++c) {
                    genotype = get_words(columns[9 + c], '|');
                    if(genotype.size() != 2) {
                        string msg = "ERROR: non-phased or malformed genotype in file " + fname +
                                     " at position " + columns[1] + "\n";
                        cout << msg << endl;
                        texterr(0, msg, true);
                    }

                    // Keep only biallelic phased genotypes coded as 0|0, 0|1, 1|0, 1|1
                    if( (genotype[0] != "0" && genotype[0] != "1") ||
                        (genotype[1] != "0" && genotype[1] != "1") ) {
                        string msg = "ERROR: unsupported genotype state in file " + fname +
                                     " at position " + columns[1] +
                                     ". Expected only phased biallelic GT values 0|0, 0|1, 1|0 or 1|1.\n";
                        cout << msg << endl;
                        texterr(0, msg, true);
                    }

                    rec.hap1[c] = genotype[0][0];
                    rec.hap2[c] = genotype[1][0];
                }

                records.push_back(rec);
                ++poscount;
            }
        }while(!datafile.eof());

        return !records.empty();
    };

    if(filename1 == filename2) {
        string msg = "\nERROR: same two files under VCF format: " + filename1 + " and " + filename2 + "\n";
        cout << msg << endl;
        return false;
    }

    ifstream datafile1, datafile2;
    vector<string> header1, header2;
    int numsamples1 = 0, numsamples2 = 0;

    if(!open_vcf_and_read_common_header(filename1, datafile1, header1, numsamples1))
        return false;
    if(!open_vcf_and_read_common_header(filename2, datafile2, header2, numsamples2))
        return false;

    vector<VCFRecord> recs1, recs2;
    int chrom1 = 0, chrom2 = 0;

    if(!read_all_records(datafile1, filename1, numsamples1, recs1, chrom1))
        return false;
    datafile1.close();

    if(!read_all_records(datafile2, filename2, numsamples2, recs2, chrom2))
        return false;
    datafile2.close();

    if(chrom1 != chrom2) {
        string msg = "ERROR there are different chromosomes in file: " + filename1 +
                     " and file " + filename2 + ". Bad VCF-iHDivSel format.\n";
        cout << msg << endl;
        texterr(0, msg, true);
    }

    cout << "\nFile " << filename1 << " was read" << endl;
    cout << "\nFile " << filename2 << " was read" << endl;

    // Determine reference population exactly as in the original logic:
    const int numpopulations = 2;
    samplesizes.resize(numpopulations);
    samplesizes[0] = numsamples1;
    samplesizes[1] = numsamples2;

    if(samplesizes[0] != samplesizes[1])
        pref = distance(samplesizes.begin(),
                        max_element(samplesizes.begin(), samplesizes.end()));

    // Intersect by (chrom,pos) and require at least one allele in common.
    // Two-pointer scan assumes both VCFs are position-sorted.
    vector<pair<size_t,size_t>> common_idx;
    common_idx.reserve(min(recs1.size(), recs2.size()));

    size_t i = 0, j = 0;
    while(i < recs1.size() && j < recs2.size()) {
        if(recs1[i].pos < recs2[j].pos) {
            ++i;
        }
        else if(recs2[j].pos < recs1[i].pos) {
            ++j;
        }
        else {
            // Same position. Keep only if alleles overlap.
            if(recs1[i].chrom == recs2[j].chrom &&
               share_allele(recs1[i].ref, recs1[i].alt, recs2[j].ref, recs2[j].alt)) {
                common_idx.push_back(make_pair(i, j));
            }
            ++i;
            ++j;
        }
    }

    if(common_idx.empty()) {
        string msg = "ERROR: no common SNP positions with at least one shared allele were found between files " +
                     filename1 + " and " + filename2 + "\n";
        cout << msg << endl;
        return false;
    }

    const int L = static_cast<int>(common_idx.size());
    cout << "\nNumber of common SNPs retained is " << L << endl;
    cout << "\nSample sizes are " << samplesizes[0] << " and " << samplesizes[1] << endl;

    // Prepare outputs
    snpfreqs[0] = vector<double>(L, 0.0);
    snpfreqs[1] = vector<double>(L, 0.0);
    snpositions[0].resize(L);
    snpositions[1].resize(L);

    const int totsamples = samplesizes[0] + samplesizes[1];
    data.clear();
    data.resize(2 * totsamples, deque<bool>(L, false));

    // Reference/non-reference coding:
    // for each common SNP, define allele '1' as the allele that is NOT the reference allele
    // in the reference population 'pref'. This mirrors the original VCF logic.
    vector<string> REF(numpopulations, string(L, 'N'));
    vector<string> NONREF(numpopulations, string(L, '1'));

    for(int k = 0; k < L; ++k) {
        const VCFRecord& r1 = recs1[common_idx[k].first];
        const VCFRecord& r2 = recs2[common_idx[k].second];

        snpositions[0][k] = r1.pos;
        snpositions[1][k] = r2.pos;

        REF[0][k] = r1.ref.empty() ? 'N' : r1.ref[0];
        REF[1][k] = r2.ref.empty() ? 'N' : r2.ref[0];
    }

    for(int k = 0; k < L; ++k) {
        if(REF[0][k] != REF[1][k]) {
            NONREF[1 - pref][k] = '0';
        }
    }

    // Fill population 1: first 2*n1 rows are population 1
    for(int s = 0; s < samplesizes[0]; ++s) {
        for(int k = 0; k < L; ++k) {
            const VCFRecord& r = recs1[common_idx[k].first];

            if(r.hap1[s] == NONREF[0][k]) {
                data[s][k] = true;
                snpfreqs[0][k]++;
            }
            if(r.hap2[s] == NONREF[0][k]) {
                data[samplesizes[0] + s][k] = true;
                snpfreqs[0][k]++;
            }
        }
    }

    // Fill population 2: next 2*n2 rows are population 2
    const int pop2_offset = 2 * samplesizes[0];

    for(int s = 0; s < samplesizes[1]; ++s) {
        for(int k = 0; k < L; ++k) {
            const VCFRecord& r = recs2[common_idx[k].second];

            if(r.hap1[s] == NONREF[1][k]) {
                data[pop2_offset + s][k] = true;
                snpfreqs[1][k]++;
            }
            if(r.hap2[s] == NONREF[1][k]) {
                data[pop2_offset + samplesizes[1] + s][k] = true;
                snpfreqs[1][k]++;
            }
        }
    }

    // Convert sample sizes to haplotype counts, as in the original function
    for_each(snpfreqs[0].begin(), snpfreqs[0].end(),
             [=](double& freq){ freq /= (2.0 * samplesizes[0]); });
    for_each(snpfreqs[1].begin(), snpfreqs[1].end(),
             [=](double& freq){ freq /= (2.0 * samplesizes[1]); });

    samplesizes[0] *= 2;
    samplesizes[1] *= 2;

    return true;

} catch(const std::overflow_error& e) {
    cout << e.what() << endl;
    return false;
} catch(const std::exception& ex) {
    cout << "An exception occurred when reading VCF files" << endl;
    return false;
} catch(...) {
    cout << "Unexpected problem occurred when reading VCF files" << endl;
    return false;
}
}


/*
Format HapMap

Files are organised in a SNPs x haplotypes format, so every row represents a SNP and every column a haplotype.

•	The first row (header row) contains the Ids of the individuals that have been phased.
•	Suffixes _A and _B represent transmitted and untransmitted alleles, respectively, for a particular genotype.
For instance, NA19009_A would be the transmitted allele of genotype NA19009 at that site.
•	The first column (header column) contains the rsID of the SNPs were the individual genotypes have been typed.
•	The second column contains the physical position of these SNPs in the particular chromosome.
•	Entries with anything other than A, C, G, or T represent unresolved haplotypes.

Example:

rsID position NA19175_A NA19175_B NA19176_A NA19176_B ...
rs10181821 5703 A A A A A G A A A A A G A A A A A A
rs11901199 8856 G G G G G G G G G A G G G A G G G G
.
.
.
rs11895691 242710183 A G A G A A A G A A A A A A A A A A


Main difference with respect to readfasta is that fasta is assumed that every population has the same SNP positions and if not,
that the largest sequence with L2 positions has the same L1 first positions and the remaining n are at the end of the sequence L2 = L1 + n
Under hapmap format that is not necessarily true because we have information about the real physical SNP positions
*/

bool  SNPSelTools::readhmphased(const string& path,const string& filename0,const string& filename1,const bool onepopfile, vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, HapMapTable& snpstable, int& pref)
{
try{

    /// Open file

    //int tries=0;

	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable length column in different pops
	// and as much as rows as numpops x sample size

    if(!openfile(path, filename0,datafile, false))
    {

        string msg = "\nERROR: can not find input file " +filename0+"\n";
		cout<<msg<<endl;
		return false;

    }

    //const int ploidy=2;
    string temp="";

// skip blank lines and commentaries
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

// store info and skip first line
    vector<string> firstline, columns; // the data is transposed in the hapmap file
    firstline=get_words(temp);
    int numsamples{static_cast<int>(firstline.size())-2};
    int totsamples{numsamples};
    vector<string> sequences(numsamples,""); // first store the sequences then transform to data, positions and frequencies
    vector<double>positions;

// Read lines with the information: rsid position A A A ..A (composition of this rsid in the sample)
    do{
        getline(datafile, temp);
        trim_left(temp);
//cout<<temp.find(comment_tag)<<endl;
        if(!temp.empty() && (temp.find(comment_tag)!=0)){
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
            columns = get_words(temp);

            positions.push_back(atof(columns[1].c_str()));

            snpstable.emplace(atof(columns[1].c_str()),columns[0]); // unsorted_map with key the snp position and value the rsid

            for(size_t c=2; c < columns.size(); ++c)
                sequences[c-2] += columns[c];
        }
    }while(!datafile.eof() );

    if(sequences[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

    datafile.close();
    int  numpopulations{2};
    samplesizes.resize(numpopulations);
// redimension the snpfreqs and snpositions vector
    //snpfreqs.resize(numpopulations);
    //snpositions.resize(numpopulations);
    int acum{0};
    if(onepopfile){ // we still need to read another file
        samplesizes[0]= numsamples;
        if(!openfile(path, filename1,datafile, false))
        {

            string msg = "\nERROR: can not find input file " +filename1+"\n";
            cout<<msg<<endl;
            return false;

        }
        // skip blank lines
        while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
            getline(datafile,temp);
            trim_left(temp);
        }

        if(datafile.eof()) return false; // the file is empty

        firstline=get_words(temp);
        int numsamples2 = firstline.size()-2;
        samplesizes[1]= numsamples2;
        totsamples+= numsamples2;

        for(auto ar=0; ar< numsamples2; ++ar) // add the necessary dimension for the second sample
            sequences.push_back("");

        do{
            getline(datafile, temp);
            trim_left(temp);
            if(!temp.empty() && (temp.find(comment_tag)!=0)){
            // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                columns = get_words(temp);
                positions.push_back(atof(columns[1].c_str()));
                snpstable.emplace(atof(columns[1].c_str()),columns[0]);
                for(size_t c=2; c < columns.size(); ++c)
                    sequences[numsamples+c-2] += columns[c];
            }
        }while(!datafile.eof() );
        datafile.close();

        if(sequences[numsamples].size()> (numeric_limits<int>::max()-1) ){
            string msg = "ERROR: There is an excessive number of SNPs in file "+ filename1+ "\n";
            cout<<msg<<endl;
            texterr(0,msg,true);
        }

assert (totsamples == samplesizes[0]+samplesizes[1]);

    } //close if pofile
    else{
        // in this case positions of both populations are the same (half of the sample if from one pop and the other half from the other pop)
        vector<double> tempos=positions;
        copy(tempos.begin(),tempos.end(), back_inserter( positions));
        for(auto p=0; p<numpopulations; ++p){
            samplesizes[p]= totsamples/numpopulations;
            acum+=samplesizes[p];
        }
        samplesizes[samplesizes.size()-1]+= (totsamples-acum);

numsamples=0;
for(auto p=0; p<numpopulations; ++p){
    numsamples+=samplesizes[p];
}
assert (totsamples == numsamples);

    }

// not sure why this fails under 32bit system in lines 1106 and 1113 when defining indexsampl as auto
    int indexsampl{0};
    acum=0;
    if(samplesizes[0]!=samplesizes[1]) // choose as ref that having the highest sample size
        pref = distance(samplesizes.begin(),max_element(samplesizes.begin(),samplesizes.end()));

    for(auto p=0; p<numpopulations; ++p){
        snpfreqs[p].resize(sequences[indexsampl].size(),0);
        snpositions[p].resize(sequences[indexsampl].size(),-1);

        indexsampl+=samplesizes[p];

    // pref will be the population with largest sample

    // identify positions at each population
        auto indexpos = p>0? snpositions[p-1].size():0;

//cout<<indexpos<<" "<<snpositions[p].size()<<"\t"<<positions.size()<<" "<<sequences.size()<<endl;

        for(size_t pos=0; pos< snpfreqs[p].size();++pos)
            snpositions[p][pos]= positions[indexpos+pos];

        acum+=snpositions[p].size();

    }

assert((int)positions.size()==acum);

// Compute the largest number of snps in any population sample
    size_t maxnumpos{0};
    for_each(snpositions.begin(),snpositions.end(), [&](vector<double> element){maxnumpos= max(maxnumpos,element.size());});

  // transform the sequences in biallelic data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    string minor=""; //
    string major="";
    vector<int> contnuc(5,0); // 0 for A, 1 C, 2G, 3 T, 4 N
    vector<vector<int>> postodelete(numpopulations);
  // the major reference sequence is defined with respect the population pref
/// Major allele will be any other than the minor
  // for each position
    indexsampl = pref>0? samplesizes[pref-1]:0;

    for(size_t pos=0; pos< snpfreqs[pref].size();++pos){

        for(auto s=0; s<samplesizes[pref]; ++s){
            if(sequences[s +indexsampl][pos]=='A')
                ++contnuc[0];
            else
            if(sequences[s +indexsampl][pos]=='C')
                ++contnuc[1];
            else
            if(sequences[s +indexsampl][pos]=='G')
                ++contnuc[2];
            else
            if(sequences[s +indexsampl][pos]=='T')
                ++contnuc[3];
            else    // this position is unresolved
                ++contnuc[4];

        } // close for sample
        auto maxeliter = max_element(contnuc.begin(), contnuc.end());
        switch (distance(contnuc.begin(),maxeliter)){ // the most frequent is
            case 0: major+="A"; break;
            case 1: major+="C"; break;
            case 2: major+="G"; break;
            case 3: major+="T"; break;
            case 4: major+="N"; postodelete[pref].push_back(pos); break; // pos correspond to the index of snpositions[pref][pos]
        }

        if(*maxeliter+postodelete[pref].size() ==(size_t)samplesizes[pref]) // the position is fixed
            minor+="N";
        else{ // this position is not fixed so there are at least a minor at freq >0
            auto mineliter = min_element(contnuc.begin(), contnuc.begin()+4); // do not count N
            while(*mineliter == 0){
                contnuc[mineliter-contnuc.begin()]=samplesizes[pref]+1;
                mineliter = min_element(contnuc.begin(), contnuc.begin()+4);
            }

            switch (distance(contnuc.begin(),mineliter)){ // the less frequent is
                case 0: minor+="A"; break;
                case 1: minor+="C"; break;
                case 2: minor+="G"; break;
                case 3: minor+="T"; break;
                case 4: throw;
            }
        }

    // reset nucleotide counts for each position
        contnuc.assign(contnuc.size(),0);
    } // close for positions

    // Update positions to delete in other pops than pref
    for(auto p=0; p<numpopulations; ++p){

        if(p!=pref) // we assume that snpositions[] collections are sorted from minor to major position

            for(const auto& delpos:postodelete[pref]){
                int newindx = get_indxtoindx<double>(snpositions[pref],delpos, snpositions[p]);
                if(newindx>=0)
                    postodelete[p].push_back(newindx);
            }
    }

    // check
    for(auto s=0; s<samplesizes[pref]; ++s){
        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
        assert(sequences[s +indexsampl].size() == major.size() );
    }

/// Gather the information for data etc:
  	data.clear();
    data.resize(totsamples);

    //size_t largernumsnps=0;
    //for_each(snpositions.begin(),snpositions.end(), [&](vector<double> element){largernumsnps= max(largernumsnps,element.size());});

    for(auto p=0; p<numpopulations; ++p){
        indexsampl = p>0? samplesizes[p-1]:0;
        for(auto s=0; s<samplesizes[p]; ++s){

            data[s +indexsampl].resize(snpfreqs[p].size(),false);

            for(size_t pos=0; pos < snpfreqs[p].size(); ++pos){
// for the pref pop the non-minor alleles are 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N count as major one. If the majority of samples in a position have N this position will be deleted
// **Note** we count those equal to the reference minor instead those distinct to the reference major
// since we are looking for divergent selection we expect the selective to be minor in one pop and major in the other
// if the minor in the reference pop is A and the major is T and we count in the other pop the non-major it is possible that we are counting other alleles as C or G so inflating the minor frequency and so giving an spurious divergent selection signal
                if( (sequences[s+indexsampl][pos] == minor[pos]) && (sequences[s+indexsampl][pos] !='N') ){
                    data[indexsampl + s][pos]=true;
                   // the frequency of the allele 1
                   snpfreqs[p][pos]++;
                }

            } // close for pos

            del_elements(data[s+indexsampl],postodelete[p]);

        } // close for sample

    // delete sites with major unknown allele
        del_elements(snpfreqs[p],postodelete[p]); // if the positions is too higher for a given population then is ignored
        del_elements(snpositions[p],postodelete[p]);

       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});





    } // close for p

} catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
} catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename0 <<endl;
    return false;
} catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename0 <<endl;
    return false;
}
    return true;
}


/**
Format readfastPHASE 1.4.8

Each file is a population so, two files must be read.
Files are organised in summary information such as a recapitulation of some of the parameters from the fastPHASE run,
and the command line supplied by the user..
then contain two lines per given diploid individual, with the order of individuals corresponding to
that supplied in the input file

For reading the haplotype, all the text until the line BEGIN GENOTYPES can be skipped.
From this line two haplotypes per individual appear

Example:

BEGIN GENOTYPES
# ID 1
A T G G G G G C G C A T G G T T G G G T G T T G G T C C A C T C C A A T G C C T T A G G C A A T C C C C A C A A G A T C G C A C C T T T A C T T G C C G G G A G A C G A G G C G C T T C G C A T C C C T A C A A G G A T G C T A T T T C T T C T C A C A C T G T G T G A C A A C G A C C T C T T A G A C G T T G C T T T A T A C T A G A G C T A C A T A T A T C C A C G T T A G C C A A A G C A T T A A A G T A C G G C A T A C T C G C G A A A G T C G A C T G T G G C T G G T A T T C C G G A G C T T T G C A A A A T G T C G T T T T C T A G G C C A T G G T G T G C G A G C C C G G A G A G C C C C T G G C A C G T T T C A C T A G G C A G G G T T C G A A G G G T G C G A T G A G A G C T C A C G C A C C G G G G C T T A A A G C A A C G G C G C G T A A C T A C G A A G C A A C T G T A T T G C C A T A G T C C G G G T C G C C G G A C G G C A T T C C A G G C G T T G G A A A T A T C G C T T C C G A C A G G G T A G G C T T A T T G G G C A G A G T G A G G T G G G G T T T C G G T T G C T C A A G G G G C A G T T G T T C C G T C G G T T A C T G C A A A C C G G G C T G G C G C T T A C C G A C T G G A A A G C T C C G G T G C C A A T G C C T C T C C T T G A T T T A T T A A C A C C A T G G C T C G T G C G C G A A G T G C G T A A T G G C C G C C A T G A A G C G A G C A A G A G C A G C T G A T A C T C G T C T C A G G T C G T G C C T T T G G G C G A C T G G G C T T G G G G G G C G G T G A T G C C G G T A C A A T T T A G C C A G C T A C A A A G C G C C T A T A T C T G A C A A C T G C C T C C A C G A T T C C A T G G G A A A C G G T G C T C T C A A C C T A G G G A G A G G C G A C A T G C T A A A T C G A G A C T T A T A G A C T C G G T G C G G C G G T C G C A G C C G T G G G G C T C G A T C G T T G G C A C C G C G G T T G A A G A G G T C C C T T C A G A G A T C C T G C G A T T A T G T A G T A C T C A T C C G T C A C C A C G T T C C A A C C C G T G T T A G T T C A G A C A G T C C C G C T T A C G T G G A C G C C T C C A A A C A T T C C T C G G G A G C C A G A G G T A C T G A C G T C G C G G T T T T C T T A G C A G C A A T C G C C G T A T C C T G A T G G C C C G T G C C C A A G A C C T C T G C T C G G C C C C G G A C C T G C G T G C G T A G A G C A C T G G G G A A C G G G G C A T C T G G C T C A A G G G C C C G T G A G T A T T C A T G A A A G G T T G G C T G G G A G A A A C A A C T C A T C T T C G G T T A T G C G T C C C A A A A A T G C A T A G C G A G C A G A T G T G T G C G C T A T T T G T T A G T A A G T A G G T C T C C C A C A T A C T T G G C C C T C G C G A T A T A A T T C G A T A G C A C G G A G C T A A A A T C A T G G G C C C A G T G A G A T G A A G A G G C C G A G C C C C A G T A A G C T A A C T C A G G C A A A A G A A G T T A C C A G C C G C A C A C G A A A C A A T C C G G G T T A T C C G A A C A A T G T G A G G C G A C C T T G T A C T G C C G G G T G T G A C G G G T G T T C A G G A A C C T C T C G T C C C G G T G T G A T T A G C C G G C T A C A T C C T G G T C G A C T C G C G A C C T A G G A A A G G C C A G T G T C G G A T T A G A G G T T G G C T C C A C A G T G G C G G T G T C T G T T A T C G T G G G T G A C C T G A T G T G A T G T A C A C C T T T T T A C G G G C C A C A G C A A T G A T C G C A C C G A A A C T T C C A A A C C C G T C A C C G G T C C G G T G A G A A C G A T G T T A A A A A T T G G G T G C G A A C C C T A A G T G A A T A C A T C A C A A G C C A G T C G A G T G A A A G G A A T A T C C G T A G A A G C C C C G T A A A C C T A A T G C T T T A A C T G A G G G A A T T C T G G A T T A T A C C T G C A C G C A C A T G C A A G C G A G G T T G C T C G A A G T A G A T A T G C C T T G A G C G T C T C A T G A C C C T T A G G T A A C C G C T T G C G C G G A C T A T A G T G C G T A G C G G T G C A A A A C T C C C G G T G C A T A T G T C G G C C G T A T C T G C G G A A T C A C G G A T T G A G C T T G T G G G G T G T G G T C C A C G G G A T C A T T C T A G T C A G A A G G C C A T G A G C C C C C C G C T T A G G C T T T T G A G T T A G C A G T G A G T C G C G C G C G C T G G C T T T A T C T C A C G A A G C T C A T G C T C C A G T T A C A A G G C G T C G T T T A C G C C G A C A A T C C C G G A A T G T A A T T G T T C A G G A A C A C C A T C C G G A C C T C A G A T C C G A T G C C A T G G C C C G G T A G G A G C G A G G A C T C C A G A T G A T G G G G G G T T T C C G T A A T T G T A A G T T A C C T C T A C G A C A T A T A G T G C A G A C G G C C T G T C C A T C C A T T G A T T C A C G G T T T T T A T T C T C C C T C C C G C T C A A T A G T C G T A A C G G C C G A C C T C G G A T A C A G T T T G C C G A G C G A A A C G C G T C A A C C T C G G T A C A T A G A A T T G C C C T G T G A T C G A T C   T A T G T C T G C T A G A G T C G C T T T A A G G C T C C T T G A G G G A C C A A C T C T C C G T C C C G C C C A G T A A G T T C C G T G T T T A C G C A A A A T T C G A C T C C A G T A G A A G A C G C C G G C A A C G T T G A G T T A G G A G C A G G G T G G C A A T T C T T T T T A G A C T G C T G A T T C G A T G A T A G A A G G T G C T G C T C T A C C G G T T G T G T C G C C T A G T G T G G G A C T A A T T C G G T C T C T A G C G C C A G G G T A A G T T C C G C A A A A A C T A G A T A A A C C A T C A A G G G C G G C G T G A G G G T C G A T G C C G T A C C T G A G T G C A A A C C G G A A A T A T G C G G T C T G T C A C A T T C T C T C G T A A T C G G C A G A A G G A C T T T G A C G C C C T A C T A G A C T G G C C G T A G A G A C G C C C T T A G G A C T A C T C C C C G G C A A A G C C T C A G A G C A A T A C C A C G C T A T G A C C G C A G G G C A G C A T C C C G C G T A A A C C C G A C G T A A C T G C C T G A T C G C A G G T C T T A A A G G T T G A C T C G A C T C G C G T T G G A C A A C A C A G C G G A G A G C C G A C A G G G A C G T T G A T A C C G C T G T A G T C A T A G T A C T T T G G C A G A A A T C T A G A G A T T A T A A A G G G C C C C T A T G G A C A G C G C C G T G C G T T G G C C C T T G G C T C G T C G T T A C A T G   G T C G C G A C G T C A A T A G C A G G A T A G G C G G G C C T C A G C G A C G G A A T G T G C T C A C G T T A G A A T A G G T G A A C T C T A G A A T T T A C G T C G G C C T T A A T A G A C G T C T G G A C G T A A A A T G C C T G C T A G G C C A A G C T T A C A T C C C G C C G C G A A C A A T A C T C A T A C G C A G A G G T A G A G C T T C C A G T A C T C C T G A T A G T T G T G T C T A A G A T G A A G A A T T T T T A C T G C G T T A G A T A G T G T C G G T G G A C A G C A C G T T A T C A G T A A T A C A T T A G G C T G A T T T T A G G C A T G C G C A G C C G T A C T A A A A G T A A A C T C T G G T A T C G T A G A T A T C C C G T C A G T T T T G A C G G G C A G G A A T C C G T C T C C G A G G T A A G T C A C C C G G T G T T T C C C G T G A C C C A A G A T T G C A G A A G A A A C A A C C C G T C C T G A C T G T A G A G C T T G T C G T C T T A A A G A G C G A G T T T G A A G A C T C G G G G C C T C G C A G G G A A G A C C C G T G G A G T C G C C A G C A C C C G C C C A C T C A T G A G G C T T C T C C T T G A G T A T G T A T A T G C C G C T C T T T A C A G A A G C G C C G G C G A G T A A A T G G A C T A G T G T G C G C A T C T C A A G G G T T A T G A T C A A T A T G T G T T G G T T A A A A T A T G T G G C G T C A A T C G C A A T C C C C C G C T A G T G G T G G G G A A C G C C G G T C T T C T T A A A C A T C A C A T C G T A A C T T G G T T A A C G C A G G G T C G A A A G G G C T C C G A A C A T A A A C G C G A C A C T T A C T C A C C G G C G T A C G C T C C G A C A G T A A A G G C C A T C G C C G A G A T A A A T T C G G C A G A T C C C A A A C G A T T A C T C G C C G G C A G G C C C T G C G T A T C G C G G T A A T G C A C G A T C G C A C C T T C A C C C C G C C A C C T T C C T T G T A A A C T T C G C T C T A C T A C G T C G T A T C C C A G A C C C T G T C A C T C A G G A A A C G C C C G T T A G G T A A G C G G T T G C A C A G A T T T A A G G G T C A G T T G G A C G C T G A C C T G G G T C C C T A G T A G G G G G T T T T T T T T G G C G C C T G T A G T T C G G C C A T T C A T A G A G T G A A C C A G C T A C T T C A C G C T A T A T T A T C G T C A G A A T T A A C G T A A C A T C G G G C C T A G A T G C A G C T G C T A T T A G A G C G G T G C A A A T A T C G A A A T A G T C G C G C A C C T C A C A C C A G C G T C C C G C C T A G G T A A C A G A T T G G G T A G G G T A A C A C G G T T T T A G G G C T G C G A C A A T T G G T G C T A C C C G T C A G A A G C A T C T C T C C T G T A A C A T A G G G T T C T A C T C C C T C T G C A C A A A T A T G C G T A G A T T G G C A A G T T G A C A A T A T C G A G T T C C T A C G C G G A G C T A T G G T A C C A A A T A C T C G A C T C T A G C A T C A A G C T C G G G C T A T C C G G A A C T G T T T G T A T G C A C G C C G C G A G G C C T A C A A T C G G C A G C A A A G A G G C G C A C G G G T T A A A C A T T G C G A A A T T A T T G A T C C A A T C A A C T T A C G T A T C A T C G T C T A C C A C C G G T C C C C C C C G A C T G T G T C A C C C T T T A A A A A C C T T T T T T A T T T A C C C T C A C T T A T G T T T T G C G G G G C G A C C C   T C T G C T C C A T A A T C A T G G A A A C T C A C A G T G T T T A T A G C T A C C T T T C T G C A C T G C T T C G A T C T G T G A A T G T T T T T C C T G G T C T T A T C T C A T G G T T G C G G A T T A G G A G C G T C A G G G T T T T T A A C G G G G T T C A A C G T T A A G C T G T C C G C A T G A T T A A G C C A C A G C G C A C T A G A A G C C G G A G T G G C A C G A G C A A A A T G T G G T C A A T C C T A G C A T C A A T A A C G G G A A G T C T T G C C T A T A T C G G G G T C A G G G A A G A A T A C C G T A C A T G G T G C A T A A A G T T G G C T C A A C C T A G G G G C G T C T G A A C G A T T C A A T T A C T G C G A A A G T T C A C C C G T C A C A C G G G G G G C T A G A C C T T A G C G A G C A G A C T A A T T C T T G A G T G G C T A T G G T A G G T G T C T G C G G C C G A C G G A C T A C T G G G G G G T T A A T A G G A T G A G G A C C C A C A C C A A G C T A A G G T T T C T C C G G A T A T G T A G T C A C G G A G C G C T C A G C T G T G C G C T A T T C G A T C G T A A G G G G C C A C G G G G T C G T C C C G A C T C A T C G G T G T C T G G G A C A C A C A A G A C C G T T G C G T C G G G A T C C G G T C G G T T C A T G T G C A A G T G C C C A A C C C C C G C A A G C C G T A C G T C G C C G A C T T T G A A A G G G C C C T T G T A C C C A A G C A T C G T A A G G G A A G C T A T G G A A G C C G A C G C G C T T G C G G A T A T C A C A T G C A A A A A T C T T T G G C G C G A C C G G G C A G T C A G G C T C T A C C T G G T G T T C C A C C G G A T C C A G T C T A C T T C T T T C G G T T A A A A C A G T C G G G G T G G A A T C T T C C T A G C C G A T G A G C C G C G G T C C A G T A C T C A C A T T A T G C C C A G T C G C C T T G G G C T C C T T G C C C A T G A C T A A T C T G C C C A G C C C A G T G A T C G G G T G A A G A A A C G G G T A A A T T T A A A G C G T G G A T T T T A G C G T C C A G T A T G G G C G C C A T A C C T T G G C G C C G T C A A C C T C T A T G T T T A T T G C G C A G C G T G A A A A T G C C A A C G C T A G G C A C G A T G C G T A C C G G T G G A C C G A A A T A A A T G A C A C G G C A C T C T T G A G C C T G G T T G A T A C C C T G T A A G G T C C G T G G A C C A A G C G T T T A T G C G T A C T T A G T T A A T G T C G A T C G A C A T G T T A A C A A G C C C G T A C G C G G G A G A G G G C T A T T C G C T T C C G C G A T G T A C C C C T G G C G T G A C G A A C A G G T T G C C A T C C C C C A G T T T C G T C G C G C C C C A T C A C C G T G T G A C T C T C T G A C C A T A T A A C C C G G G G C A G T T A T A A C G C G T G C T T A C C A A C T G G T A T A C G T C T A A G A G C G T A G G C C G A T A T A G C G C C G T T G A C G G C G G T A T A C T A C T T C A G A T T T C A T C T G T A G A C G A T A C G A T T A A C G T G C T C T A C G C G G C T G C C C G C C G C C C T A C G C G G G A C C C C C T T T C T G A G C T A C T A T A C A C T G G A G C G A C T T G T T T A A A C T T C A T C C T T T C A A T G T G C A C G A T G A A C G G C T A A A C G C A G C C A T G G T G A G T G A C A T T G T C C A T C A G C T A A T C T C C A T C T G A A A C G G A G C C G T C T G A C T G T T G T G A C A C C C T C T G C C G C C T G A G T C T G A T G A A C T T A A A T T T G C C T G G G A T A C C G T A A T G T T A G A T C C C A G T G T C G A G A G G T G G T T A G C C C T A T G G G C T C A G T A A T G C G T C C T A C C C C G C A C A G A C A C C A G C C C C G C T G C T T G T C A C C C A T T G C C A C G A A T A G A A A C C A C A G A T G A C T C T A T G G T C T G C C G A G G G T C C G T G G C C T A G A C A A G G G C G G A G T T A G T C A G C A T G C A C A G G G A T T T G G C C T C T C T T C C A C C C T G C G G T A A T C G C T C G C A T A A C T A C G T A G G A A C C C G T A G G C C T G A T C A G T C A T A T A T C C A C C C C G G A C G G C C A C C C T C C T C T T A C G T T A C C A C C C T C T T T C T C G A G A T G T C C A C C C C G T A G T C A A C C C C A A C A A T G C C A T G A G G A C G T C T G A T C G C C G C T A G C G A G C G C C A T G C T G T T G A G G G T A G G G T T A A T A A A C G T C C T A G T A C G G G C C A T T T C G G G C G C A T G T G G G A C C G C A G C T G C T G T A C A C T C C C G C G C T T C G T T C A T T G G A A G A A C G G T T G A C C T A C G A T A C T A C G T A T T A C C T T C C A T A T A C A T C C G C C G A A C A C A G T A C A C C A A C A T G G A C C C A G A C T T C T C A A C T A C C T G T C T T C G G G A A A A G A T C T A T T G G C A G T G C C C G C T A A C G A T G C A G C C G T C G A T T T T G C T A A G A G C T G G A T C A A T T G G A T A G G T C A A T A T C T T T C T C A G T T T T T C G C A T A A G A A C T T C T G C A C G C C C A A A T G G G A A G T C C G A A T G G A T T T G T C T A G T A A C C C G A G C T T T C C G G G A C C G T G G A G G C C C A A C A A G A A G G G T C C C G A A G G C C G A T C C T A T T G G A T T A C T G G G A G T A A T C C T G C G A G T C G G T G G G G C T C C G T T A C C T G T A A A G T T T G C A A C A G G G C T G G C C C G C A C T T A C A A C A G G C A G T C C G T G A C T C A A C C T G G C A C T T A T G A C A T T C C T C A T A C A A G C C C C G G A C T G A C T A T A G A T C T T G G G T C A T C C G T C G C T T G G A T C C G G T A C A T G A A T G T T C G C T C A C G T G T T G C G C C T G A T C C C C T G A C C T C T A C T G A T A T C C A G T T G G A T G T C G C T C T G G C A T G A C G T G C C G A G T G T A A G G G A A A C G T C T C T G A C T T T G C G G C G G C T T C G C A T C C G T T T G G G C G T C C C A A T G T A C C G G A C G T A T A G A C C G G C A A T C T A G T C G T T C G C T A C C C T T C T C T G A C C A A A T G G T T C G C C G T G T C G T T C A G G T T C C T C C A A G G C G T G G T A A G C A G C A T T C C G C G T T T A G C A G G G C A A C A A G A A A T A A G A A G C A C A G G A C A A G T A C G C C T T A C T A A G G G G T T G C T G A G T T G G T A C G C G G C C C T A T A C C C T A T G G C C T G A C T T A A T G T A A G T C G G T G   G C C A C C C C G G C G C A A C T G T A T G T A T G A G T G A C C T T A A T T A T A G G T C A C T A A G A G G A T T G A T A A G C A G C T T G A C C C A T A G G A G C T T A C C T G A T A C C C T C C A T G G C T T G A A C G G C C G G A T A G T T A G C C C C C T C T G G G C G T T T A C G A G T G G A G C A C C C A G G G T G C C T A T C G C C A T G G A T G C G A G G C T G T A C G T A G T T T C A G C T C C C C A A A G A A T T C A G T A T C T G C A C C G C G G C A C C A T T A T C T T G A A G A A A T A C T C T T T C G C A G G C A G G C C C A C T T A G C G C G A G T A A C C A G C G A T G T G C A G A A G C G T C T A C A C C G G C C C T T T   A C C G C G T G G A A T T C A A G G G C A A T G A A A A C C A T T G G G G A G G C C T T A C G G G G A C G A T T G A C G C T T G G G C T G A G C A C T C C T G T C A C T C G T C G C A T C A G T C G A G T C C C A A T G T C C G G A G A G T T G T A T C T C A G A C T C T C G C G G T A C A G T C C A A A C G G T C T A G T A T T C T A T G C A A G A G G T C C G C G A C C T T C   A G G T C C G T T T G G G C A A A G G C T C C A C G G C C T C C G T G T A G T A A C T C A G T T C C G G A C T G T G A A C G C C G G T A A G G G A T A T A T T T T C G C C G G T C C A T A C T T A C A A A C A G C A C T G C C A G C G A G G A G T A T A C G A C A G T A G T C T T A T C G A T T T C T G A T C A G C C G T G C G C C G C G C G C C A G   A G A A C A T A T C C C C C G A G G A A G A G G G A C T G T G C G G C A A C C A T G G C T A G T A C A C G A G C G G C G G T C C G A G G G G A G A A G T T T G C G T G G C G T C C C G A A G A G A C T G G A T A A G C T T A T T A T C T T G T A C G T A G G C G A A C C A C A G C G T A C C A C T C A C C A C A G G C G G A G C G A C A A T C C A A T G G A G C C A C C T C G G A G T A C G G A A A C C T A C C C G C T G T C G G A G T C C C A G G T A C T G C T C C A A C G G A T T T C T A T A C C C A A G C G T C C C T G G G C C A C T T G C A T A C T A G C C C T C A C C T T G A T C C C T T T T T A G C C G C C C G A T A C A C A A A C A C G C T A G T T T G A T A C C T G G G C A A C G C A A C G T A A T T C A C T C G T C C C G C A C C C C G G C A C G T G T A C T C C T T T A T C C A G G A T T C C G A C T T A C T G G G G T G C G C A G C G G A A T G C A C C T C A C T G C C A G G G T A A A C T T G G G T A T T C A G C C T T C A C A G C T T C T G G T T C G G A C G T C T C C G A G G G G G C C C T G A C C T C T G C T C G C T A A C G G C G C A A A A G G A C G T T G A A A G C G A C C A G A A C C T G G A A G G G C T T T G G C G T T C A T C T C T A A C T A T T T T C T C C A G C T G G G G G C T G G A C G C A A G G C T G A G G T A A C T A G G C T T C A T A C C T C C T G A C A A C G A G T G A C T G T G C T A T G C C A C G C C C T G C C G A C G A G T A T C C T C T C C C T T G C A A C T G C A T G A C G A T C T C A G C G A C T A C T G C A T C G A C A T C T T C T G C G T G T A G G G A G C A T T T T G C A A A G C C A C C G T C C A T C C A C C C C C T G C T G C G C T T G A C G T C T A G A T C A C G G A A C T G G G A A A G T T G C C A A C A T T G G A C T C C G G A G C C T G A C G G T G G C G C A C C C C A C G C A G G A C A G A T A G C A T T T C A C A G G A A A T T G A G G C A G A A T A T A T G G T C G C T C G G C C C C C C T C A C T T A G C G A C T G C G C A C C C T G A T A G G G C A T C C G C C A G T T T A A G G C G C T C C T C G G T G G T T T A C A A T T T A C G A T C C T A G T T A G T C C G T A A A A G G C T A G G A C C G C G G A G C C G A T G C T G T A T T T G C G T A A C C A G C C G A C T A C G G G T A A A C T A C G G T T A T C A C C C G C G C A T G T G A T C C C G T A T A G C C C A T C A T T G C T C G C C A C T G A A G G C G G T C G A C C C C G G C G T G T C T C G T A C C G T A A G C C C T G A G A A G T A G C G G G T G T C T C A C A A C C C A C A G T C C A G A G A G T C T A A A C C C T T A T A T G A G C C T A C T G C C C T C A C A T T A A T G T C G C C C A G C C C G A A A T C C A T G C G T C C G G G A C C T T C G T C C T C C C C A A G G C T A G T G C C C G A G T T T G G A C A C A C A T T C C C G G C C C C T C C G A C T C A A T C T G C A C T G A T C A A A A G G T C C C A A G T T A C G A G A A A T G C T C G A G G C G C C C T A C C T T G G A T A T T C G T C C C C C A G T A C T T T G C G A C C A C G C T G G C T T A A A G A A T T A C A A T G T C T A A T A C G G T C C C G G T A A A T G G T T C G G T G G T T T T G C A A G G A C A T G A C A T T T G T C C C T A A G T C G T C G A G G T T C G T A G C T G G G T C G T T C G T G G C C T G C G C G C A T T C G T C C A C T A G T G C G G T C C G A G T T A T C A T C A A A T A G G G T C G C T C A T C T T T G T C C C G G G T T A C A A A A T C T C A A C G T C A A A C T A T T G A A G A A C G T T A T C A A C T T T G T T G C A T A G C T T G T T A T T C G T T C C C A A T T C G C C G C T T T A G C T T T A A A G T T G T T T A A C T C G T T T A C C C C A T C T T T T G T A G T G G C C T C T T T A T T A G A A G G A A C G C G C A G T A C G T A A G A A G C C T C C G G C T G T T G A C A G A G A T G G G C A T C T C T A C A T G T T G C T A T T T T G A T A G T G A A C A A A C C G C C C C T T C A T T T A A G G C G G G T C A C G G G G C G G T G G C A C A G C C A C A G C C T G G A A C G A A C T A G C G G T T G A G A C C T T C T A G T G C G C A G G C G T C A C A T G A G T G T T A G A C A C A A T C G G G A G C G G G C T T C G G C G G A T A A A G G A T A A T T T A A C T G T A T G G T C G T A C C C A T G C G G T T C T G A T C C T C C G A T T G A G G T C C A T C T C A C G G T G T C A T C T G T A A C A C C G C G C T C G G C C G C T C T G T A T A T G T G G C C C C A T C G G C C T A C T T G C T G T C T C T C T C C T T T A T A C G T C C C T T G A T A A C C C G T A G G C C A A A G T A C A G G T T A A G T A C T C A C G G T A A G A C T A G C A C A T G G G G A A G C A T G C A G G A C C T G G T A G C T C T T G G T C C T T G G A T T T G G A C T C G C T T G T A A C A T G G G A T A C C C A C C T G A C T G T A G A T T T G G A C T C C G C G C C G A A A T T T G T T C C C C G G A A T C A C A G C C T G G T G G A C A G C T G C G A T C C T G A A A A A A G A C G G G G G C C A A C G A T A T A C T C A C T A T C T A A A G A T G T A T T T C C G T C G T A C T G C A A C C G A G G A T A A C A G C G C C T C T C G G T C A A T A T T A A A T T T T C A A T C A G G T C C A A G C A G G G A T A G G A A C G G A C T G T G G C A G T C C A G C A T T C A A G G T A A A G T C C T T T G G C G A C G C C A G A A A G G T C G G A A A T G C G T G G C G G G T G C G G C A T G C C C C C C C A G G T C G C C G G G G C G T T A G T G A C T T A T G G T C T A A T G A G T G A T A T A A T C G C A C T C T G T G T T C C A T G A A A T C C A C T T G T C G T G C A C T C G T C A G G G C C A T A T A G A C T T C T A A C G C T T G T A C A A C C T C A A C T T T A T A C C G T G A C A C G G C G A A C T T C C A T G A   A A G A C A C A C T G G C C G C A G A T T A C C C T C T C G G A C A G C T T C C C A G T C A G G G A C T C G A C C T G A C C C A C A T C T T G T C T A G T C G G G C A A A G C T C A G T C T G T C G T A A C T T C G C G G A T T T T A G T A A C T C A G A G G C C C C A C C C A G A A G A G C T C G G T A T T C A G T T C C C A T A A T C C G A G T A A G A A A T C A A T A A A A G G G T C T C G A G C A G G C T C A C A C T T G A A C C C T G A T A G T T G G C C G A G A T C G T G G A G A T G T G A G C A C A A T G A G G C T G C C T C C C G A C T T C A G T A A C T T T T C T T T T A C G T G T G G G A G A C G C T C C A G C C G G C C A G G A C C G T A G A T A G C T A G A A G A C G T A G C C A A C G A C T T A T G G C G T T A T G C A C G G A G G A C T A A T G C A A G A G A T T C T A G G C T G T A C G A G G C G G C A G T A C T A G C A G C C T T C G A G G A C G A C A A C G G T T G C G C A T T C G G G T T A G C A G G C G T A C C T C G T C T A C G G C C C A T T C A G A A C T G A G T G G G T C C C C C A T T T T A A A A A A G T C T A T G G A G T G T C A G T A G C A T C T C A G G C A T G G T T T C T A G G C C A C C C G G T T G T T C A A C A C A C G C T G G T C A A A C C G G C T G A C T C A A G G T C C C G G C A A A T T G T T C T A A T G C A G T T C C G C T G G T T G C A C G A A T C T C C C C T G T A G A G C G G C G G T A G A C G G A A C A C A G G T A A A A A G G A G C G A A A T A C G C G G A A T G G G A C T T C T A T C A A G G T C A G T C G A T C G G C G A G G T C G T G T C A T A C C A A A T C A T C A A C G C G G G C A C C G G G C G A G A G G G T C G C C C G T C A G C T G T C A G A C A T T T C C G C A A T C T T C G C G T A A G T G T C T C G G C C G T A T G C G T G T C T C A A C A G C T C T T A A C C A G A G G C C A G G G C C T T G T G C G C G T G A T A A G A T A A A G G A A A T G T A T G G C G G G G A G C G G G A T G G T G C G C G A G C C C G T C A C A G T C C A G G A A G T A A A C A C G C C G G C G G G A C C G T G T G A A T G G C T A G A G C T T C T G C C G C A C G G A G C A T A C C T G A A A G C G G G A G T G G C A A G G C A C G G A C C T T A T C A C T G C G T C A C A C C T C A A A T C C T G G G G G C T T T C C G T A C G C C C A C C T C A C A A T C G G G A G A A C T C C G T T T C T G T C C A C C A C C T A A G C C C G G T A A G G C T T T A T G A A G C A G G T G G C A G C T G C C T T G A T T T T T A G T A A A T T G T G A T C G C C G T G G C G C C T G T T G T C C G T T T T G T A A G G A T C T G T C C G C C A A G G T T G G A A A A G T G A G G C A G C A C G C T C G G T T C C A G C A C T T G T C C A A A T C T A C C A T A A C A C C A G A G A T G C G A G A A G G A C T C G T G A G G A C G C A G A C T G G A G A C T A A G A A C T G C C T T A G A G T A C C A G G T G C G G A G A A G A A T C T A A A C A T A T G A G G A A G G A C T T A C T G T C C T G C A T C C A A C G T C C C C C T A G A G T T T T G T T G C G G T A T T T G T G G T G C G G G G T T A C A G A G G C A A T C A C C C A A C C A A T G G G G G T T C T T C C T G A C C T C C T A G A C T G G C A G C C G G T G C C A T T C C G T T G G C G G C G T A G T G G T G G C G C G A G T G T G A T G A A T G T A T T A C A G A G G A C A C A G C G T G G A A G C T T C A C A G C C T G C T C T T G G G A T G G G G T A T A C A C A C G G T A A C A T G A C C A G A G T A G G G G T G G T G G G G A G A A G C T T T G T G C G C C C C G T G T T T T G G T G G T T G T A G C T G G G A A A C G A G C G T T T G A C G C A T T C G T G T A A T A C T A T C C G T C T C A C T T C C A A T A T C A A G C C C A G T T T G C C G C T T G C G C A T A C A G G T C A T A T C A T T T C T T A C C C C A T A T G A C T C C C G A C A G A T G A C G G T A A C T A C G C C T C T A T G A T C C G A C T G A C G C C A T G G A G T G A C C T G A T T A G G T C T G G G A A T C G C T A C T G A C G C A T G C A A C T A C A G G T C C G G A G G T C C T T C A C A T T T G C T A C C T C C T G A A A C A G A T A T A A T T A A A T T G C A C G A G C G C A C A A A T T A A C T A A A C C C A A G G G T G G G G G A G A A T C T T A C G C A A C A G G T G G T A T T C C T G C A T T A T A T C C T T C C G G T G G A C G A G G T T G A C T A G G T C G T T A A A G G T G C A C C T G T C
G T G A G G G C G C G T G G T T G G G T G T C A G C C A G A T A A A A T A C C G G G A T T A G C A T C C G C C A G A T A G C A C T T C T G C C T G T A A T G G G A C G G T T C G C C C A G C A C C C C T A C A G A A A T G C T A T T G A T T T T T G T G T C A T G T A G C A G C T G T T C A C G A T G C G T T G C T T T A G A C T G G A G C T C C A T C C A T A C A C G T G G G C C A C G T C A T T G C A A G A T G T C G C G T T C T A G A A A G T C G A C T G T G A T C T G T A T T T C G G C G C C C G G C G G A A T G G C G T T T T C T A G T T T G G A T C G C A C T G A T T A G A C A A T C C C C T A A T G T A C T T C A C G C G A T G G G G G T C A A A G G G G G T A G G G G A A A T C C A C G C A C C G G G G C T T A A A G C A A C G G C G C G T A G C T A C G A A G C A A C T G T A T T G C C A T A G T C C G G G T C G C C A G A C G G C A T T C C A G G C G G C G A G G C C C C A A C C T T C G A C A G G G C C A G A G C G C G T A A T G A G T C G C A A C G A A T T G T A A G C T G T T T C A G G G G C G G C C G T T C C G T C G G T T A C T G C A A A C C G G G C T A G C T T C C C T C A C T C G A A A G G A C C C G G T G C C A A T G C C T C T C C C T G A T T T A T T A A T G T T G C G A T C T A C A C G C A C G G T A A T C G G C T T T C G C C G T A A G G C G C T C A C A C A A A G C T G A T A C T C G T C T T G A G G T G C A C C T C C A A A T G A C T G G G C T T G G G G G G C G G T G A T G C C G G T A C A A T T T A G C C A G C T C C A C A G C G C C C C G G T C T G A T A A C C G C C T T C A C A G T C C C A T A G A G C G A G A C A A T A T C A A C C T A G G G A G C T G C G G C A T G T C A A G C A G C G A C T C C C G A G A G A A A T G C G G C G G T C G C A A C T A G G T A T C T C A G T T A T G G G C A C C G C G G T T G C G A G A T C A T C C C C A G A G C G T C C T C T G T C A G T T A G T A C T C A T C T G C C A T T A C G G G C C A A C C C G T G T T A G T T C A G A C A G T C C C G C T T A C G T G G A C G C C T C T G C G T G C C C C T C G G G A A C C A G A G G T A C T G A C A T C G C G G T T T T C T C G A A C G C A A T C G C T A T G G T C C T C T A A T A C A G G C C A G C A C T T T C T A G G T G G C T T A G A G A T C G C G C A T T G C A G G C A C T G T G G C G C T T G A T A T C T G A C T C G G A T G C C T T A T G A G G C C T G C T C C C A A T T G G T C G G G G T G C A C A A C T C A T C T T C G G T T A T G C G T C C C A A A A A T G C A T A A C G G G A A G A C G G A C G A T A T G G C C G G C A A G C C A C G A A G T T C C C A C C T A C T T G G C C C T C G C G A T A T A A T T C G A T A G C A C G G A G C T A A A A T C A T G G G T C C G G T G A A G G T C A G A G G C T G C G T C T A G G T A A G C T A A C T C A G G C G G G G A A A A C C G C C A A C C G C A T G T T C C G T A A C C C G G A T T C T C C G G C T A C C G T G A G A C A A C C T T A G C T C G A A A C A C T T A G G A A G T G T T C A G G A A C C T C T C G T A C C G G T G T G A T T A G C C G T T G G T G G A T C A A G C A G C C T G A A G A T C G G A A G C G G A C A A T A C C A G G C C G A G G A C T G A A G C C C C G A G G A C A T T A T A C T C C G T C A C T G G T A G T C T G A T G G A A T G T C C A C C C G C G G G C A G G A C A C G G C A A T G C C C G C A C C G A A G C T T C T G G A C C C A T C C C A G A T C C G G T G A G A A T G C C T C G G G G C A C C A A T C G C G C A C C T G A A A T G A C T A C A C C A A G C A C C A G T C G A T C A G G C A T G G T A C A C G T G G C A G C C T C G T A A A C C T A G T A C C T T G C T G T C A A G C A C C A T T G G C C A T A C C T G C A C G C A T G T G C A A T C G C G A G C A T C T G G G T C G A C G C C T T T G C A G A A A C T T T G C T C A C T C G G A G T C G A A T C G C G T A T G G G T C A C G G G G C G T A G C G G T G C A A A A C T C C C A A T T A C C G T G T C G G C C G T A T A G G C G G A A T C A C G G A T T G A G C T T G C A T A T C T G A T C T C G C G G T A T C A T T C T A T T T C G A G T A C C A C G A G C C T T T A G A T C A G G C T T C G A G T G G G G T C T C A A G T C A T A A G C G C T G G A C G T G C T T C G A T G A A T G T G C G T T T C A G C G G C C C A A T T C T T C C C G C A T C G G C A A T T T T A A C C G G T A G C T T G T C A G A C C T G T A G G C C G T A C C C C C G C C C C G A T G C C A T G G T A C T A C G G G A G C G A G G C A G C T A G A T G A T G G G G A A T T T C C A T C A T T G T G G G T T A C C T A C A C G G T G T G C A G T G T A G A C T A T C T G T T A G C A A G C C A A T T T G C G G C C T C G C T T C T C C C T C C C G C T C A A T A G T C G T A A C T A T T T C C A C C G G A T A C G G T T T G C C G C T C C C C C T G C A C C C G A C G C A T G C A G T G T A A T G G C C T T T G G C T C G G T C   T A G G T T T G C T G G A G T C A T G C T G C T G C T C C T T G A G G G A C C A C C G C T C C G T A A A G T A T G G T A A G T T C C A T T C G C C A A T C G C C C T C T A C T C C A A C A G G A G A C G C C G G C A A C G T T G A A C G G A T A A C G G A G C A T C A A T T C T T T T T A G A C T G C T G A T G T T G G G A G A A G G A G T A C T G C C T T C T T T A C G T G A G C A T T C G G C T T G G A C C T A A T T C G G T C T C T A G C G C C A G G G T A A G T T C C G C A A A A A C T A G A T A A A C C A T C A A G G G C G G C G T G G G A A G T T G T G C C G C G C C C G A G G G C A A A C T A A C A C C A C G C G G C T C T C T G T G T T C T C T C G T A A T C G G T G T C C G G A C T T G G A C A T T A T G C T A G G C G A A C C G T G A C T G T A C C C T T A G G G T C G C C T T T T T A T G C A A C C T C G A G G C A A T A A T G T G C C G T A C A T A T G T G G C A G C A T C C T T C G C C G G A A T T G C T G G A T C A C C G A G T A G T A G G T C T G A A A T A C G A A C C T G C T G A T A T C C A G G T G G C A C G G T A A C A G A T A A A C A A A T C A T C C A G G G A C G C C T C A G T C G T A A G G T T T T A T A C A G C C C C C A G A G A T T A T A C G T G A C C A C T A C G G G C G A A A C C G T T C T T C A A A A T C C T A T C C C T C T T T G C A T G   G C A A A T G T T C C C G G C G C A G G A T A A G C A A A T T C C A G T A C C G G A A T G T G C T C A C G T T A G A A T A G G T G A A C T C T A G A A T T T A C G T C G G C C T T A A T A G A C G T C T G G A C G T A A A A T A T A C A T G C A A T C G C T T C T G C A T C C C A C T T T T A A C A A T A A G C G T A C A C A G G G A C G T G A C G T T T G A T G C C T C C G A T A G T T G T G T C T A A G C C G A A G A A T T T T T A C T G C G T T A G A T A G T G T C G A T G G A C C G C A C T G C G C C A G T A A T A C A T T A G G C T G A T T T T A G G C A T G C G C A G C C G T A C T A A A A G C A G G T G A C A A G G T C G T A A G G A C T A A A G T G T C G C T T A C G T G C G A A A A T C C G T C T T C G A A G C G A G T C A C C T G G C G T C T C C C G T G A C C C A A A G C C A T G A C G T C C G C G C T A C G C T T C G G T G A C A A A T A G G G G T T C T C T C G C G C A T T G A C G C T G C A G A C T A A A T C T C T G C A G A T G G A C C T T G G A G G A C C G C C A G T A C C C G A C C A C T C A C G A G G C T T C T C A C C G A G T A C T G A T G T G C T A T G T C T T A C G G C G A T A C C G T C A A G T A G C G A T G C C A G T G C T T G T G T C T C A A G G G T T A C G C T C A A C G T G T G T T G G T G A G G C C C C G T G A C A C C G G C T A T G G C A T T T T A T C G G T G A G G A A G A A C G C T A A T C T T C T T A A A C A T T G T A T C G G A A C T T G G T C G C A T T C A T A G C G A C G A A T C T A C G A A C A T A A A C G T G A C C C T T A C T C A C C G G C G C A A G C T T C G C C A G T C A G A T T T G T C G C T A G A G T A A A C T C G A A G G A T C T C A A A C G A T T A C T A G T A G A T A G G C C C T G C G G G T T A T A G C G C T G T A A G C T T T T G T C T C A A C C T T A A T G T A G C C C T T G T A A A C C T C G C T T T A C T G C G T C G T C T C C T G A A C A T C G G C A A T T A A A C G G A A A T A T T C A A A C A A A T A G T C A C C C A G A T T C C A G G A T C G A G C G A G T G T T G A T T T A A A T C C C C A A C C G A A T G T C C C T C C G A A T T T T T G C C A G C T A A T T G C G T G G C T G T T A G G A C G A T C A T T G A C T T A G G C G G C G C T A T C G G A A T T A A C G T G G A C C T G A G T C T A A A A C C A A C T T C T A T T A T G A T A A C T T A A A T A G T A G G G C G G T C G C G C C C C C A A C A C T C A A G T C C C G T T G G A A G C G A C A A T C T T A T G A T A C G G T G T A A G C G T A A A A T C T T C G C G G T T A T C C T G C C C C G G T G A A A G C A T C T C T C C T G T A A C A T A G G G T G T C G T C T A A G T C A C A C A A A T A T A T A G G A G T T A A T G G A G G T A C G G C G G A T A A T T C C T A C G C G G A A C T A T G G T A C C A A A T A C T C G A C T C T A G C A T C A A G C T C G G G C T A T C C G G A A C T G T T T G T A T G C A C G C C G C G A G G C C T A C A A T C G A T G A C G A A G A G G C G C A C G G G T T A A A C A T T G C G A A A G G G C C G C G T A A A T C A A C T T A C G T A T C A T C G T C T A C C A C C G G T C C C C C C C G A C T G T G T C A C C C T T T A A A A A C C T T T T T T A T T T A C C C T C A C T T A T T C G G C A T A T T G A G A C C C   T T T G C T C A G T A C G C A C A G A A A A T C G T G A C A G C G G C C G C G A C C C G C T G G A A C G T A G C C A G G C T G T G A A T G T T T T T C C T G G G C T T A T C T C G T G G T C G C G G A C C C T G A G T A C C G T T A G G T T T C G C G T G G T G C A G A T T G G C G C T A G A C A C A T A C T C A G T C T G C A G C T C A C T A G A A G C C G G A G T G G C A C T G T T C G C A T G T A G T T C G C A C T C A C A T C A A C G C T A T T A A T C T C C G C T C A G C C T G T T G T T A G G A C C A A A C G A C T C C C A T G G T G C A T A A A T C C T A A C A C C T A C G G G G G C G T C T T C C C G A C T C A G C T A C T A C G A A A G T T C A C C C G T C G C G C G G G G G G C T A G A C C T T A G C G A G C A G A C T A A T T C T T G C G C A G C T A T G G T A G G T G T C T G C G G C C T G A A A G C T G T C T G A A A A G T C G T G A A C C T A T T C T C T G A C C C A A G C C G G G G G C G T C T C A A G G G C G C C A C C C C T A A G C G C C A G A T T A T G C G C T C C C C G A T C G T A A G G G G C C A C G G G G T C G T C C T G A C T C C C C A G T A G A G G A A C T G C C C A A G A C C G T T G C G T A G A G A T T C T T G T A G T T C A G A C G T A A A T G T A C A A A C T C C G C A A G C C G T A T G T C G A A G C T C T T G A A A G G G C C C T T G T A C C C G A A A C C T A G A C A A G G A G T T C C G G A A G T C G A C G C G A G C G A T G C G A C A A T G G T T A A A A A T C T T T G G C G C G A C C G G G C A G T C A G G C T C T A C C T G G T G T T C C G A C G G C C A A C A C T G C A C C T T G T C G G T T A A A A T C T C T T G A A T G G A A T C T T C C T A G C C G A T G A G A C G C A A C A C A G C C A G C A T A T T A C G C T T C A G C G C T C T G A G C G T T G C G C C C A T G A C T C G T C T G C C C A G C C T C T G T C C A T A T C A G A G A G A C G G G T A C C C C C G C A A T A C A A G C C G T A A T A C A T A G C G T G G G C G C C A T A C C T T G G C G A C G T A G G T T G C T G C A C G G C C T G C T A C A A A T A A A A A T G C C A A C G C T A G A A G T T G T A C G C G T T G G C G G A C C G C C G G G G G G T A C G C T T T G C T C T G G A G C C G T A C G G A G A C C C T G T A A G G T C C G T G G A C T G G G C G T T T A T G C G T A C T T G G T T G A C G G T A C T C A A C A T G T T A G C A A G C C C G C C T T T T T G A G A G G G C T A T T C T C G G T C A C G C T A G C T T C C T G G C T G A C C G A A C A G G T T T C C A T C C A T T C G T T C C G T C G C G C C T T G C A G T T A G T T T G C T C T C T G A C C A T A T A A C C C G G G G C A G T T A T A A C G C G T G C T T A C C A A C T G A G G G C T G T C T A A G A G C G T A G G C C G A T A T A G C G C C G T T G A C G G C G G T A T A C T A C T T C A G A T T T C A T C T G T A G A C G A T A C G A T T A A C G T G C T C T A C G C G G C T G C C C G C C G C C C T A C G C G G G A C C C C C T T T C T G A G C T A C T A T A C A C T G G A G C G A C T T G T T T A G C T T T C A T C C T T T C G A T G T G C A C G C T A C C T A G C T A A C T T T A G C C G G G A G G C G T G A C A T T G T T A A C C G A C T A A T C G A T A C C G A C A A C G G A G C C G T C C A C C T G T T T G A A T G C T A G T T G C T G C C T G A G T T T G A C A A G C T T A A A T T T G C C C G G G G T A C C G T A A T G T T A G C T C C C A G T G T C G A G A G G T G A C C A A C T T C A C A T A C T C A G C A C G G A G T C A T C T T T T T T G T A G G T A C C G T A C C T A T G T A G C G T C A C T T A C C A C A G T A A A T A G A A C T C C C C G A T G C T G T C G C A A T C T G T A G G T T G C T A T C G G C A C G T C C C G A T G C A A G G C C G G T C A T T C G A T G C A G A T A T G T G G C C T C T C C C T C A T A A T T T A A C G G G A A A T C G T G T G A C T A C G T G T G A G C C T T C G T G C C T G A T C A G T C A T A T A C T C G C C C C G T G T G G C C A C C C T C A C C T T A C G T T A C C A C C C T C T T T C T C G A G A T G T C C A C C C C G T A G T C A A C C C C A A C A A T G C C A T G A G G A C G T C T G A T C G A C T A G G A C T G G C A C C A T G C T T G G A A G G G T G A A A C T C A T A A A C G T C C T A T C A C A A A T C G T G T A G A G T A A G C T C T T G G T A A A G G C C T A T T T C T G T T C C C T C G A C T C G T T C A T T G A G C T C G T T A C C A A C C T A T G A G G A C G C G C A T G G T C T T C C A C A T A C G C T C G T C A T G A A C A G C A C A C C G A C A T G G G C C C A G G C T T C T C G A C T A C C T G T C T T C G G G C G C G A G C C T G G T G T T G G T A C A T A A T G G C G A T A C G A T T G T A G C C T T C T C T G A G A G C G G G A T C G G T C G G A T A G G T C A C C A T C T T T C C C A G T T T T T C G C G C G G A C C T G G C T A T C T T C C C C A A C A A A A G T C C C G G A T G G G G C G G T C T A G C A A C C C G A T C T T C C C G G G A C T A T T A A G G C C C A C C G G T A A G G G T C C G G G A G T A C A G C C C T A T T G T G T C C C T A G G G G T A G C C C G G C G G A T C G G T G G T G C C C C G G T A C C T A T A A G A G T T G C A A C A G G G T T G G C C C T A A C C T A C A A C G C G A C A G C C T G G G T T A G C C T T T G C G C C C G T G A C A T C T A G C A T A C A A G C C C C G G A A T G G A G G G A G A T C T T G G G G C C T C C G T C G C G C T A G G C C G G T A T A T G A A T G T T C G C T C A C G C T T C G T G C A T G A T C C C C C G G T C G A T A C T G A G A T C C A G T T G G A T A G T A A G A T A G C A T G A C G T G C C G A G T G T A A G G G A A A C G T C T C T G A C T T T G C G A C A G T T T C G C A T C C G T T T G G G C G T C C C A A T G T A C C G G A C G T A T A G A C C T A T G G C T G G G C T G T T C G A T A C C C T T C T C T G A C C A G G G A A T T C G C C G T G T C A T T C A G G T T C C T C C A A G G C G T G T C G C T C C A A C T T C T A C G T T T A G C C T G G C A A T C G G C A A T A A G A A G C A C A T G C C A A G T A C G C C T T A C T A A G G G G T T G C T G A G T T G G T A C G C G G C C C T A C C T T C C G C A G C C C T G T G C G A G A G A A G C C T G T G   G A A C T T T C G T C A C A A T C A C C G A T C G A G A C T C T C G C A A G T C T A G G T C A C C C G T G G G A T C G A T A A G C C A C G T T G T C C C T C G A C G C T T A C C T G A T G A A T C C C A C G G C T T G G C C G A A C A G G G C T C G G A C C A C C G A G T T G C G T T C C T G A G C G G A G C A C C C A G G G T G C C T G G T A C C A C G G C G G C G A G G C C A G A C T C G G T C T C A T A T C T C T A A C T G G T T C A G G C C C G G C G C C A T G G C A C A C G C C T C T T A A A G A C A T A A G T G C C T T T G T G A A G G C C C A C T T A G C G C G A G C A G C A G G C A C G G C G C G G A A A C A T C C C C A C T A G C C T C G C   A C C G A T C A A G C G C T A G T A G C C G T G A A G G A A G G T G G A A C T A A T C C C T G G T A C A A C C T G G C G C T T G G T C C G G G C C T C C C T G T C A C T C G T C G C A T C A G C T A C A C C C C C C T A C T T A T G G A G T C G T A T C G T G G G A T T T C G C G A T A C C T T A T A A A C G G T C T A G T A T T C T A T G C A A G A G G T C C G C G A C C T T C   A G G T C C G T T T G G G C A A A G G C T C C A C G G C T C A C G T G C G G T G A C T A A G T T C T A A G T G G T T G G C G T T A T C G G A A G A T A T A C G G G T A C C G G T C T A T A C T G A C A A A C A G C C A G G A C G A T A C T T A T T A T A C G A C A G T A G T T T T A T C G A T T G C T G A T C A G C C G T G C G C C G C G C G C C A G   G A G G C A T G T T T C C C G A G G A A G A G G G A A G A C A C G G C A A C C A T T T G G G A T A C A C G A G C A A T T G T C T G A G G G G A G A G G C T C G C G C T G C A G C C C A C G T G A G T T G G A T C C T T C T G C G G T C T C A C G C G T A G G A G A A C C A T G G A A G G C C G C T C A A C C C G G T T A A A G C G A T C G G T T G G T G G A A T A G T C T C G G G A C A T A A C A G T T T C T A T T C T G T C G G A G C T T T C G G T A C T G T G T A G A A A A A T T T C T A C A T T A A G A A G T C C C C T A G A T C C T T G C A C G T T A A C A C T C C A C C C G A G C C T C C G C G G A T T A T T T A G C G A G T C A A C C C G C G G A T C G A A G A C C T G G G C A A A G C A G A G C C G C C C A C T C G T T C C G C A A C T C G G T A C G G G T G C T C C C C C C T C T A A G A T T C T T A T T C A A G G A A G C A C G T G A C G G A A T G C A A A C C A C T T C C A G G G T A A G C C T G A A T A T C T C A T T C G C A C A G C T T C T T A T T C T G A T G G T G T C G G A T G T A A T A C T G C C T C G G A T T A C G A A C G G T G A A A A A T G A C G T T G C C G G C G C C A C T C G A T C A A A G G G G C T T T G G C G T T C A T C T C T A A C T A T T T T C T C C A G A C A A A A G C T G G G T A T G G T A A T G A A G T A A T T A G G C T T C G T A C C T C C T G A T A C T G C G T G A C T G T A T C A C T A C C T A A T T G T T A A G C G G G T A T C C T C T C C C T C A C G C T C A T C C A A A C A T C T C C T C G A C T G C T G T G T C G A C A T C T T C T G T G T G T C A G A A G A G C T T C T C A A A G C C A C C A C A A G C T C A C C A C T T G A C G T A C T G A C A G C C C A G C G C C T G T C G C T G G G A A A A T T G C C A C C G C C T T C C T A T A A A G A T G G A C A G C A A C G C A C C C C A C G C G G G G T A G A T A G C A T T T C A C A G G A A A T T G G G G A G A G G G G C G G G G T T G A T C G G C C T C C C T A C C T T A A C G A C T G C G C A C C C T G A T A G G G C A T C C G C C A G C T T A C G G T T T C C T C C T A G T G T T T C C A C T T G A C G A T C T T A G G T G T C T C A T A A A A G G C T A T G A C T T T A A G A T A T G T G T T G T A T T T G T A G A G T C A G T C G A C T A C G G G T A A A T T G T A A C C G T C A C C C G C G C A T G T G A T C C C G G C G G G C C C G T C A C T G T G C G T C C A T G A A G G C G G T C A A C C C A A G C A C T C A C C A T C T T T C A A G C C C T G A G A A G T A G C G A G T G T T C T G T G G T A C C C G A G A T C A G T G G C T C C G C A T C T T A T A T G A G C T C C C T G C T A C T G A A T T A A T G T A T C C C A G C C C T A A A T C A G T G C G T C C G G G A C C T T C G T C C T C C C C A A G G C T A G G A C T C A C A G G C G G A C G T G C C C C A C C A T A T T T T C C A C A C T G C C C C G C C T G T C C T G G G G G G C T A A G C G T T A T T A G A A A T G C T C A A A G A T C C C T C C C T C G G A T A G C C G T C A A A T A A C C A C G C A T A G T T G T A A C G G C T G G A A G A A C C A T C A T G T C T A A A A C G G C C A T A A T A G G G T G T C T A A C T A C C T G G C A G T G C C G T A C A C C C C A C C A T G C A G T C G T C G A G G T T C G T A G C T G G T G T A G G T T C G T C C G A C A T G C A T T T G T C C A C C A G T A A A A C C C A C G T T A T T G T T C G G C C T A T G T G C T C A T T T T T G T C C C G G A C T C C A C G G C T C A G G T G G T G G G A C A T T G A A G G G A G G T G C T G G C T T T G T T G T A T G G C T T G T C G T C C G T T C C C A A T T C G C C G C T T T A G C T T T A A A G T T G T T T A A C T C G T T T A C C C C A T C T T T T G T G T G A T T C G C G C C C G C G T G C T T G C T T C A A C G T A C G T A A G A A T C C G C C A T T C A G C T G T G A G A A T G G G A G G T G T C A C G G A C C A T C G T T T T G C G G T G T G C T G A A C C A T C C C T T C A T T T A A G G C G G G T C A C G G G G C G G T G G C A C A G C C A C A G C C T G G A A C G A A C T A G C G G T T G A G A C C T T C T A G T G C G C A G G C G T C A C A T G A G G G G G C A G C G A C C C C T A A G G T A G G C T C T A A T T A G T A A A G G C T C G C C T A A C T G T A T G G T C G T A C C C A T G C G T T T C T G G T T A T C C G A T T G G A T C G T A T T C T G C G G T G T C A T C T G T A A C C C C G T A C T C G G C C G C T C G T T G C G T A T G T C T C C A T C T G C C T A C C C A T T G T C C C T C G T T C T T G T G C G T T C T T T G G C A A C C C T T A G T T T A A A T C A C A G G T T A A G T A C T C A C A G T A A G G T C G A C A C A T G G G G A C G C A T G C A G G A C C T G G T G A T T C T T G A T C C T T G G A T T T G G A C T C G C T T G T A A C A T G G G A T A C C C A C A C A C C T G T A G A T T T G G A C T C C G C G T T T C A A T T T G T T C C C C G A G G C A C C G A C C C A A T G G A C A G C T G C T G T T C T G A G G G G G T C T A G T A G T C A A C G G C G C G T C A C C T A C C T C C G G A C G C A T C T C C G T C G T A T G G A A A C C G A G T C C G C C A G C G C C T C T C G G T C A A T A T T A A A T C C C T C A T C A G G T C T G A A T G G G G A T A G G A A C G G A C G A T G G A C A G T T T G C G C T C A A G A G A C C G T T C T C G G G A A A C G C C C T A G A G G T A G A G G G C T T A T T A T T A G C G A G G A G G G C T T C T T C G A G T C T A C G G A G C G C C A A G A G C C T G C G A T T T G A T G A G T G A T A T A A T C G C A C T C T G T G T T C C A T G A A A T C A G A T T G T C G T G C A C C T T G T G T T T C C A T A T A G A C T T C T A A C G C T T G T A C A A C C C A G A A T T T G T A C C G C A A C A C G T A A G G T C C C C G C G G   G A G C T C C A C T G G C C T T C A G T C A C C T G A T T G A C C G T C T C A T T C A T T A A A A G A C A A A A A C A A C T T C C G T C C G G G T C C G G C T A A T G C G A T G T C A C T T G T C G C A C T G G A T T A A G T T T C G T C G C T G C A G G T T A T C C A C C C G A A A G A G C T C G G T A T T C A G T T C C C A T A A T C T G G G G A A G A C G C C A A T A A A A G G G T T C A A A A C A G G C T C A C A C T T G A A A C C T A A G G T T T T G C C G G G G C A G T G G A G A T G T G A G C A C A A T A A G A A T G T A C T T T T G T C G A A G G C C T G C C C T C T G C G A A C G T G G G A G A C G C T C C A G C C G G C C G G G G T C G T A G A T A G T C C G A A G A C G T A G A C A C C G C T C C A G G G T G T C C T G C A C G G A G G A C T A A T G C A A G A G A T T C G G T G T T A C C C T C T A T G A C A G T A A T A T T A G A T C T C G A T G A A G A C A A C G G T T G C G C A T T C G G T C G A G A G A T C G T A C C T A A T C C A C T G T T T C G G T G A G G C T G A G C G A G C C C C C C A T T T T C G G C A G T C C G A G A A C A C T C C A G T A G C A C C C C A G G C A C G A T T C T C C A A T T G C A C G G T G G T C A C C C G C C A G T T G G C C C G G T A A A C T A G T T C A A G G T T A C G A C A A A T G A C T T C G G G T C A A C G T C G T C T G T T G T A C G G A T C T T C C T G A C A A G A T G G T T T C A G A C A G C C T C T A G G G C A A G A G G G A T T A G A T A C G C G G A A T G G G A C C G A G G C T C G T T C T G G C T G A T T A A T G A T A G T A T G C C G G A C C A A A C A G G C C G T T A G T G T A C T A G G C G G A G T A G C A G C A T A T C A G T G A T A G A G A G C G G C C G C G C C T C G C A C G T C A G T G T C T C G A A C T C C C G C G T G C C G C A G C A G T T C T T A A C C A G G T A A T G T G A C C T C T C A C G T G T A A T G A G A T C G G A T C G G T A C G G T G C G G T A C T T G G G A T G A C G C G A A A G C C C G T T C C C G T C A A G G G A G G G G G T A A G C A G T T A T T C C A G G A C T C C C A A T G C T G G C T T C T G C C G T C T A G C G C A T A C C C G A A A T C G A G G A C T G C G C G G C A C G G A C C T T G T C C C C T C G T C A C G C A C T C G G G A T C G T A T T T G C G T C A C G T G C C C A C C T C A C A A T C G G G A G A A C T C C G T T T C T G T C C A C C A C C T A A G C C C G G T A C A T C T T T C T A A A G T G G A G G G C A G C G A A T T T T C C C C G C C A G G A C C C A T C A C T G A C G G G G C T T T G G T T G T C C G T T T T G T A A G G A G A G T C T T A T A G C A G G T G G A A G G A G G A G G C A A C A T A A C T T G C G C C A A T G T C T G T C C A A G C A T G T T G C G A T C C T A G A G G T T T A G T G G A G A C T C G T T C G G A C G C A G A C C A A A G A C T A G A A G C G A T A G C C A A G C A T T A G G T A T G A G A G G T C C C C T A G C A G C A T G A G G C C T A G C T T A C T G T A C T T A A T T C A A C G T C C C C C T A G G A G G C G T G G T C A G T G G T T G T G G T A T T T A G C G A C A G A A G A G G C T G T A T G G C T A A T G G G G G T T C T T C C T G A T C C C A T A G C A G A A C C A T C G G T G C T A C G C T G T T G G C G G C G C G G C G G C G G T A C G A G C A C G G T G A G T G C A C G A C A G A T G A C A T G T C T C G T G A G C C C T C C A G T T T G C T C T T G G A A G A G G G T G C G T G T C A A G T G A C A T G A C C A G A G T A G G G A G G G T G G G A G A C A G C C T T A T G C G C C T T T C G T T T T G G T A A C C G T C A A T T T G A C G C G A A A G T C C C C C G A C T T T A C T T G A T A C C A T C C G T C T C G A C G A T G C T A T A A A A T G T G A C C C A T T T C T C A A A C A T A C G G G T C A T A T C A T C G A C C A C C C C A T A T G G T T C C T G A A C G A T G G T A G T A A T C G C G C C T C T A T T G C C C G C T T G A T G C C A T G G A G T G C C T C T A T T C G A G C C A G G G A T C T T T G C T A A T G C C C A T C A A C A C A G G C C C G G G A T C T T T C T C C A T T C A T C A C C T T C T G G A A T G A G T A T A A T T A A G C T G C G A A A G T G A A T A A A T T A G C T A A A T C T C C A G G T G G G G G A G A A T C T T A A A T G G T G T A C G G G C G T T T C T T A T T G T G C C A T G T T G A G G G A C A A G G T C A C C C G G G C T A T T A G G G A G G C A C C C G C C
# ID 9
A T G G A G T T T T A T G G C C A T G T G T C A G C C C G A T A A A G T G C T T G G A G C G A T A C C C G C C G G A C A T A G T T T T T A C T C T T A A T G G G A C G G T T C G C T C C G T C T C C C T A C A G A A A G G C C G T T T C T T T T T G T G T T G C G A A G C A A C G A T C T C C G G T A C G G C T T T T T A T A C T A G A G C T A C A T A T A T C C A C G T G G T T A G C G T C A T T A A A A G A T T G T A C G C C T T A T A A A G C A G A C T G T G G T C T A C G C T C C A T A G C C C G G C G G A A T G G C G T T T T C T A G T T T G G A T C G C A C T G A T C C G A C A A G A T C C T A A T G T A T T C C A T T A G G T G G G G T C T A A A G G G T G C G G G G G A A A T C C A C G C A C C A G G G C T T A A A G C A G A T T A G C G T A G C G A C G A C A C C G T T G T A G C G C C A T A G T C C G A G T C G C C G G A C G G C A T T C C A G G C G T T G G A A A T A T C G T T C C C T A C G G G G C C G C C T T A T T T A A C A G A T C G C A A C T G G G T T T C G G T T G C T C A A G G G G C A G T T G T T C C G T C G G T T A C T G C A A A C C G G G C T A G C T T C C C T C A C T C G G C C A G A C C C G G C T C A G G C A T A T C T C C C T G A C T C G G G C C C G T C A T G G T C T A T G C G C G A G G T G C G C G G C T T T C G C C G T A A A G C G C T C A A G A A A A G C T G A T A C T C G C T G C A A G G T G T G C C T T T G G G C G A C G G G G C T T A A A T A A A G G T G G G G T A G G T A C A A T T T A G C C A G C T A C A A A G C G C C T A T A T C T G A C G G A T A T T G C T G A G G C C T T G G G A G A A A C A G T G C T C T A C G T T T A G G G A G A G G T A A C C T A T C C C G T C G C A C T C C C C G A G A G A A G C T A A A A A A C T G C A A C T A G A T A G A C T G G G C G C G G A A G A C G C G G C T G A A G A G G T C C C T C A G A A T C G T A C T T G G G T G G G C G T C G T G C C T C C A C C A C C A C G G T T A G A T C C G T G T T A G T T C A G A C A G T C C C G C T T A C A G A T C T A T A C T T G C G T G C C C C T C G G G A A C C A G A G G T A C T G A C A T C G C G G T T T T C T C G A A C G C A A T C G C C G C A G T T T G A T A A T A C A G G C C A G C A C C C T A C A G G T   G C T T A G A G A T C G C G C G C G T A G A G C A C C G G G G A G A G T G G T G G A G A A C T C G G A T A A C C T T G G G T G C C T A T G A C C A A T T G G T C G G G A G A A A C A A C T C A T C T T C G G T T A T G C G T C C C A A A A A T G C A T A G C G A G C G G G T G T G T G C G C C A G C C A G T G A G A A G T A G G T C T C C T C C A T A C G T G G C C C C C G C G A C G C G C C C A G A T A G C A C G T A G C T A A A A T T C G G G G T A C G G T G A A G G T C A G A G G A T G C C C C C C G A G G A G T C A A T T T G T G C A A G G A G A G T T A C C G A C C G C A C A C G A C A C G C C T A A G A C T A T C C G A A C A A T G T G G G G C G G A T C G A T A C C G C C G C A C G G A G G A A G T G T T C C A A C G C C T C T C G T A C C G G T G T G A T T A G C C G T T G G T G G A T C A A G C A G C C T G A A G A T C G G G A G C G G A C A A T A C C A G G C C G A G A G C T A G A G A C A C A G T G A T A G T A T C T G T T G C A G C G T T G G G T G T G C C T T G A T G T C C A C C C G C G G G C A G G A C A C G G C A A T G A T C G C A C C G A G G T C G C C A G C T T A G C T A C C T G T C T A A C T G A G G C T A T G T T A A A A A T T G G G T T C G A C A   C G A A A T G A C T A C A C C A A G C A C C A G T C G A G T G A A A G G A A C C C A A G G G G A G G A T T C G T A G G T T G G A T G C T G G A A C G T C A A G A G C C A C T A G C T A T A C C T G C C A A T G T G C G C A A G C G A G G T C A T C T A A A T C G G C G A T G C C T T G A G C G C T T C A C T A A C C T T A G G T A A C C T C G C C T A C A G G T C C C G A G T A T C C G C G A C G C A A A A C T C C C G G T G C A T A T G T C G G C C G T A T C G G C G G A A T C A C G G A T T G A G C C C T C A T G G C T G G G T T C A C G G G C C T G T T T G A G T C A G A A G G C C A T G A G C C C C C C G C T C A G G C T T T T G A G T T A G C A G T G G G T C A T A A G C G C T G G A C G T G C C T T G A T G G A T G T G C A T C C T G T C G A T C C A G T G T C G T T C G C G C T G A C A A T T T T A A C C T G T G A C C G T C C C G A C C T G T A G G C C G G A C C T C A G A T C T G A T G C C A C G G C C A G G T G G G A G C G A G G C A G C T A G A T T G T G G G G G G T G C A T G G A C C G G T G G A G G A C C C A C A C G G T G T G C A G T G T A G A C T A T C T G T T A G C A A G C C A A T T T G C G G C C T C G C T T C T C C C T C C C G C T C A A T A G T C G T A A C T A T T T C C A C C G G A T A C G G T T T G C C G C T C C C C C T G C A C C C A C C G C G T G C A G G G T C G G T A T T T C T T A C C C G A C A T C A T G T C T G C T G G A G T C A T G C T A A T T C G T T G T G A G G G A C T C C T G C T C C G T A A A G T A T G G T A A G T T C C A T T C G C C A A T C G C C C T T T A A C C C G G C C A G G T C T A A C T T T A A C G T T G A G C G A A G G G C A T A G C A G C A A T T C T T T T T A G A C T G C T G A T T C G A G G A G A A G G A G T A T T G T C T T C T C T A C T G T G T T A C C T G G C T T G G A C C T A A T T C G G T C T C T A G C G C C A G G G T A A G T T C C G C A A A A A C T A G A T A A A C C A T C A A G G G C G G C G T A G T A G G T T G T T A C A C A C C T G A G T G C A A A C C G G A A A T A T G C G G C T C T C T G T G T T C T C T C G T A A T C G G T G T C C G G A C T T G A C T A T T A C A T G C A G T G G G A T A G A G C T G T G T T A C C C T T G T T G C C T C C C G G C A A A G C C T C A G A G A G A T C C T A T G C T A T G A C C G C A G G G C A G C A T C C T T C G C C G G A A T T A T G T A C C C G C C T G A C C G T A G G T C T G A A A T A C G A A C C T A A T G A G A T C C A G A C G G C A C G T C A G A G A G C C G A C A G G G A C G T T G A T G C A G A T G T A A C C A T A G T G T C C C G T A C A G C C C C C A G A G A T T A T A C A G G G C C C C T A C G G A C A G C G A A A G T C G C C A A A A T C C T A T C A C C C G C G G T G G A T G C A A A T A T T C C C G G C G C A G G A T A A G C A A A T T C C A G T A C C G G A A T G T G C T C A C G T T A G A A T A G G T G A A C T C T A G A A T T T A C G T C G G C C T T A A T A G A C G T C T G G A C G T A A A A T A T A C A T G C A A T C G C T T C T G C A T C C A G C T T T T A A C A A T A A G C G T A C A C A T G A G T G T G A C G G C T G A G G T T T T T G A T A G T T G T G T C T A A G A C G A G G A A T T T T T A C T G C G T T A G A T A G T G T G G G T G G A C A T C A C G T T A C C A T C A G T G T A T T A G G C T G A G G C T G G G A C T T C G C A G T A G T A T C G C A A A T C G G T G A C A A T G T C G T A G A T A T C C A G T C A G T T T T T A C G T G C G A A A A T C C G T C T T C G A A G C G A G T C A C T T A A C G T C C C C T A T G A C C C A G A G T C A T G A A A G A A G C G C C C C G C T T C G G T G A C A A A T A G G A G C G T C T T A G C A A G T T G A C G C T G C G A C T C G G G T T C T T G T G A G G A A A C A T T G G A G G A C C G C C G T T A T C C G C C C A C T C A T G A G G C T A C T T C T T G C T C A C T G A T A C G C T A T G T C C G C T G T C G A C G C C G G C A G A C G G C G A T G T C A A G A T T T G T G T C T C A A G G G T T A T G C T C A A T A C G T G T T G G T G A G G C C C C G T G A C A C C G A T C G C A A C C C C C C G C T A G T G G T G A A G A A C G A T G G T A T T T G C G C G T C G T A C G C A   T G C T T C G G C C G C C G C A G G G T C G A A A A G G C T C C G A A C A T A A A C G C A G C C T C C A C T C A C C G G C G C A C A A G T C G A C A G T A A A G G C C G C A A T T A G A G T A A A C C C G G A G G A T C T C A A A C G A T T A C T A G T A A G T A G G C C C T G C G G G T T A T A G C G C T G T A A G A T C T T G T C T C C C A T C T A C C G C A G C C C T T G C A G C A C G A A C C C T A C T G C G T C G T A T C C T G A A C A T C G G C A A T T A A A C G G A A A T A T T C A A A C C A G C G G T T A A A T C G G T C T C A G G A T C G A G C G A G T G T T G G T C C A A A T C C C C G A C A G G A G T C C T T T T T G A A T T T C C A C C G T C T A G C C A C G T G G A G G G T G A G C T A G C C G C T T C A C G C T A T A T C G T C G C A A T C C C C G C A T C A A C A T C A A A C T G C G G T G A A G C T G C T A T T A G G A T A A C T C A C G G A G T A G G G C G G T C G C G C C C C C A A C A C T C A A G T C C C T T T G G A A G C G A C A A T C T T A T G A T A C G G T G T A A G C G T A A A A T C T T C G C G G T T A T C C T G C C C C G G T G A A A G C A T C T C T C C T G T A A C A T C G G T C T T C G T C T A A G T C A C A C A A A T A T A T A G G A G T G A A T G G A G G T A C G G C G G A T C A G C T A C G T T T A T G G C C G T A G T G C C G C A T A C T C G A C T C T A G T A T C A A G C T C G G G C T A T T T A G A A C T A T T T G G A C G A A A A A A A T T G G A A T C A C A C G A A G C A G C A A A G A G G C G C A C G G G T T A A A C A T T G C G A A A G T G C C A C T T C A A T C A A C T T A C G T A T C A T C G T C T A C C A C C G G T C C C C C C C G A C T G T G T C A C C C T T T A A A A A C C T T T T T T A T T T A C C C T C A C T T A T T C G G C G C G G G G A G A C C C G T T T G C T C A G T A C G C A C A G A A A A T C G T G A C A G C G G C C G C G A C C C G C T G G A A C G T A G C C A G G C T G T G A A T G T T T T T C C T G G G C T T A T C T C G T G G T C G C G G A C C C T G A G T A C C G T T A G G T T T C G C G T G G T G C A G A T T G G C G C T A G A C A C A T A C T C A G T C T G C A G C G A A T C G T G G T C C A G A G T G G C A C G A G C C A A A G A G A A C T C G C A C T C G C G C C A A C G C T A T T A A T C T C C G C T T C T C T T G T T G T T A G G A C C A A A C G A C T C C C A T G G T G C A T A A A T C C T A A C A C C T A T G G G G G C G T C T G A A C G A T T C A A T T A C T G C G A A A G T T C A C C C G T C A C A C G G G G G G C T A G A C C T T A G C G A G C A G A C T A A T T C T T G A G T G G C T A T G G T A G G T G T C T G C G G C C G A C G G A C T A C T G G G G G G T T A A T A G G A T G A G G A C C C A C A T C A A G C T A A G G G C G T C T T A A A G G C G C C A T T C C T A A G C G T T C A A C T G C G C G C T C C C C A C C T G T C G A C A T T A C C G G T G C A G C C C T G A C T C C C C A G T A G A G G A A C T G C C C A A G A C C G T T G C G T A G A G A T T C T T G T A G T T C A G A C G T A A A T G C C C A A A C T A T T T G G A T T G T A T T C T A A C G A T C T T A A A A G G G A C C G C A C C A C C G G G C A T C G T A A G G G A A G C T A T G G A A G C C G A C G C G C T T G C G G A T A T A A C G G T T A A A A C T C T T C G A T A T G A T C G G A T G G G C A G G C C C C G A T G G A T G T T C C G A C G G A T C C A G T C T A C T T T T G T C A T C T G C G C C A T C C T G A G T A T G A T C G G C C T A G A T G G C A C A C T G C G G T C C A G T A C T C A T A T T A C G C T T C A G C G C C T T G G G C T C C T T G C C C A T G A C T A A T C T G C C C A G C C C A G T G A T C G G G C G A A G A A A C G G G T A A A T T T A A A G C G T G G A T T T T A G C G T C C G T T A C G A G C G T C C T G T T G T A G T T C C G T C A A T T G C G G C A C G G C C T G C G C A G C G G G G A A A T G C C A A C G C T A G G C A C G G T A C G C G T T G G C G G A T C T C C G G G A A T G A C G C T T T G C T C T G G A G C C G T A C G G A G A C C C T G T A A G G T C C G T G G A C T G G G C G T T T A T G C G T A C T T G G T T A A C G T C G A T C A C T A T G C C G G A A A G C C C G T A C T C G G G A G A G G G C T A T T C G C T T C C G C G A T A G C C C C C T G G C G T G A C T A A C G G A C T G C C A T C C C C C A G T C T C G T C G C T C C C C A T C A C C G T G T T G C T C C C T G A C C A T A T A A T C C G G G G C A G T T A T A A C G C G T G C T T A C C G G A T A G T A T A C G T C T A G G A A C T T G T A T C G A T G T A A T A T T A T T G A C G G C G G T A T A C T A C T T C A G A T T T C A T C T A T A T G G T G G A A G A T T A A C G T A T C T G G A T T A T A T G C C C G C C G C C C T A C G C G T G C C C C C C T G T C C T G A T C C A G A T A C A C T G G A G C G C T G C T C T G G G A T G C T A T C A G G C A G C G A C A T G A T C C G A A C A A T G G G C C T T G A C T A T A G T A A A G A G A G G C A G C C G C C A A A C G G C C T C C G C C G A C A A C G G A G C C G T C T G A C T G T T G T G A C A C C C T C T G C C G C C T G A G T C T G A T G A A C T T A A A T T T G C C T G G G A T A T T A C C G C T C C G T A T A C C A G T G T C G A G A G G T G A C C C A A T T C A T G G A T G T G G C A A T G C G T C A T C T T T T T T G T A G G T G T C A G C C C C A T T T A G C G G C A C T T A C C A C   A C G G A G G T G A C C C A A A G A T G A C T C C G C A A C T C A T A T A G T G T C C G T G G C C T A G A C C A G G T C G G A G T T G A G T C T C A T G T G T G A G G G C T T G G C C T T C A C C T A G C C C T G C G G T A A T C G C T C A C A T A C T G G A T G A G T A A T A C G T A G T A T C T C G T C G T A A T C G G C T C G A A T A T T G C T A T T G C C T C A A C C T T A C G T T A C C A C C C T C T T T C T C G A G A T G T C C A C C C C G T A G T C A A C C C C A A C A A T G C C A T G A G G A C G T C T G A T C G A C T A G G A C T G G C A C C A T G C T T G G A A G G G T G A A A C T C A T A A A C G T C C T A T C A C A A G C C G T G T A G A G T A A G C T C T T G G T A A A G G C C T A T T T A C A C T C C C T C G A C G T A C T C G T T G A G C T C G T T A C C A A C C T A T G A G A A C G C G C G G T A T C T T C C A C A T A C G C T C G T C A T G A A C A G C A C A C C A A C A T G A A C A T A G A A G G A C T G G C T A C T T T C T T T A A G G A A A A G A T C T G G T G G C A G T G T A T A A C G A T A G G G C A G C C G C C T C T T T T T C G G A A C A T G G G A T C G G T C G G A T G G G T C A A T C C C T T T C C C A G T T T T T C G C A T A A G C C C G G A T G C A C T C T C C G C C A A G A G T C C C G G A T G G G G C G G T C T A G C A A C C A G C T C G T C C C G G G A T T G T T A C T A C C T G A C G G T A C A T G T C C G T G A G G C C G A T C C T A T C A T G C T A A C A T G G G T A A T C C T A T G G G T C A A C G A T G T C C C G G T A C C T A T A A G A G T T G C A A C A G G G C T G G C C C T A C T T T A C A A C G C G A C A G C C G G G A T C C G C T C C G T T G A C C G G T C T C C C T A G C A T G T G G G A C T T A A A A T A G A G G G A T A T C T T G G G T C A T C A G C A A T G C T A G T C C G G T A C A C G A A T G T T C G C T C A C G C T T C G T G C A T G A T C C C C C G G T C G A T A C T G A G A T C C A G T T G G A T A G T A A G A T A G C A T G C C G T G C C G A G G G T A A G G G A G C A T G T G C C A C T C C G A A A A T G G T G C T A C A G T T A C T T G A G C G T T C C A A T G T A C C G G A C G C C C G A G T C G G C A A T C T A G T C G T T C G A T A C C T T T C T C T G A C C A A A T A A C G C A T C G T G C C G T T T G G G C C C A G T A A A G G A A T T T C G C T C A G C A T T C C G C G C C C G T T A G A A T A A C C G G A A G C G G A A G G C A C A T G C C G G A G C T G C C T T A T T A A G T G T T T T T T G A T T T A G T A C G C G A T C A T A C C T T A C G C A T T A T T G T G C A A T G T C A G T C G G T G C G A C A C C C C G G C G T G A C T G T A T A T C G G G A C T C T C G C A A G T C T A G G T C A C C C G T A G G A T T G A T A A G C A G C G C G A C C C A C A G G A G C T C G C C T G A T G A A T C C C A C G G C G C T G C T G A A C A G G G C G C G G A C C A C C G A G T T G C G T T C C T G A G C G G A G C A C C C A G G G T G C C T G G T A C C A C G G C G G C G A G G C C A G A C T C G A C C T C A T A G T T C T G G C T G G T T C A T G A C C G A C G C C G T A A T G T A A T T A G C C C G A A G A A A T A A G T G C C T T T G T A A G A G C C C A C T T A G C G C G A G T A A C C A G C G A T G T G C G G A G G A G C C C C T C T C G G C C T C G C G G C T T A G C A G G C G C T A A T A A A A G T G A A G G C A G G T A T G G A G G C C T T A C A G T A C A A C C G A G T A T C G A G T C T G G G C A C C C C T T T C A C T C G T C G C A T C A G C T A C A C T A T A A T G C C C A T G G G A C C G T A T C G T G G G A T T G T G T T G T A T C G T C C G C C A A T G T G A G T A C C A G C C T A G G A C A A C T C G C G A C C T C C G G G A G T T A C G T G G G C G G G T G C T C T C A T A A T C A T T G A T A G T A A C T C C A G G C T A A G T G G T T G G T G T T A G C A A G A A A G C T A C G G G T A T T G T T T T G C G A C G G T C C G T C A A C C T A A C G A C G A G G G G G G C G A A G T G A C G A C C C C C G T G A T T T C T G A T C A A C C G G T T A C C G A T T A T T G A T A A A A T A T G T T T A T A A G A T A G T C A A A G C T G T G C G G C G A C C A T G T G G G A T G T A C G G G C A A C G G T T T G A G G G G A A A G A T C C A A A C G T T G G T C C G A A G A G A C G G A A T C C T T C G G T G A C T T T G T A C G T A G G C G A A C C A C A G C G T A C C A C T C A C C A C A G G C G G A G C G A C A A T C C A A T G G A G C C A C C T C G G A G T A C G G A A A C C C A C C C G C T G T C G G A G T C C C A G G T A C T G C T C C A G C A A A T T T C T A C A T T A A G A A G T C C C C T A G C T C T C C A T G T A C T G A T A A G T A C C T C G A T C C C T T T T T A G C C G C C C G A T A C A C A A A C A C G C G A G T T T G A T A C C T G G A C G G A G C C A A A C C A T T C A A G C G T C C C G C A C C C T G G C A C G G G C G C T C A C T T A C C C A G G C T T A C G A C G C A A T A G G G C G T G T G G C G G A A T T T G A A T T A C T G C C A G G G T A A G T C T G G G C G C T C A A T T C G A G C G A A T C C T G A C C C T G A T G G T G T C G G A T G T A A T A C T G C C T C T G A T T G C G G A C A G C G A A A A A G G A C G T G T A A G G T G C C A C G A A C C T G G G G G G G C T T T G G C G T T C A T C T C T A A C T A T T T T C T T T A G C T G G G G A T C T A A T A C A G T A A T A C G T T A A C T A A G A T T T A T A C C T T A T G A T A A T G A G T G A C T G C G C C A C T A T C T A A T T G T T C A G C G A G T A T C T G A C T A C C C A C G C T C G C A T G A A C A T C C A C T C T G C G G C G G C A T C G A C A T C T T C T G C G T G T A A G G A G C G C T G C G C G G G A T A G A T G C A A G C T T G T T C C C T T A C G T A C T G A C A G C T C G T C G T C T A G A A C T G G G A A A A T T G C C A A C A T T T T A C T A T A A C A C T G G A C A G C A A C G C A C C C C C A T A A T A A C G T A T A G C C G C C T C A G G G A A A T T G A G G C A G A A T A T A T G G T C G C T C G G C C C C C C T C A C T T A A T T G C T G C A C G A T C T G A T A G G G C A T C C G C C A G C T T A C G G T T T C C T C C T A T T G T T T C C C A T T T A T A G T T T T A A T T A G T C C G T A A A A G G C T A G A C A C G C A A G G C C G A T G C T G T A T T C G C A G A A C C A G C C G A C T A C G G T G G C A T T A T A A C C G C C A C C T A T A A C G A C A G C T T C G T C G A A T C A A T T A T T G C G C T C C A C T G A A T G C G G T C G A C C A A G G C G T G T C T C G T A C C T C A A G C C T C G G A C C A G G T T A A G T G T C T T G C G G T A C C C G A G A T C A G T G G C T C C G C C C C C C C T G C G A G C T C C T G T A T C T C A C A C T A A T G T C G T T C C A T C A T G G G C C A G T G C G T C C G G G A C C T T C G T C C T C C C C A A G G C T A G G A C T C A C A G G C G G A C A C A C C C C A C C A T A T T C G T C G A A T C A C C A C A A C C G T C   C A G G G T T T C C C A A G T T C T G C A C G C C A C T C A A A G A T C C C T C C C T C T G A T G T T C G T C C C C C A G T A C T T T G C G A C C A C G C T A G A C T G A A G A G C C A T A A C A C T C A A A C T T G T C C T A A G A G G G T G C T C G G T G G T T T T G C A A G G A C A T G A A A C C T A C C A T G C C A G T G T T G G T T T T C A G G A A T T A G T C G G T T T T G T C C G A A G C T C G G C C G C A C A C T A G T G C G G T C C G A G C C A T T G T C A A A T A G G G T C G C T T G C T T T T G T C C C G G A C T C C A C G G C T C A G G T G G T G G G C C G C C A A A G A A C G T T A T C A A C T T T G T T G T A T A A T C C T G T A G T C A T T C A C A A T C T A C T G A T T C G T C T T T A A A G C C G G C C G G C C C G T T T A C C T T A T T G G C C T G G T T A G C C G C G C C C T C G T G C T T G C T T T G A A G C A T G T A C G C C T C C T C C G T T C A T T G A C A G A G A T G G G A G G T G T C A C A T G T T G C T A T T T T G C T A T T G A A C A C C A C A T C C C T T C A T T T A A G G C G G G T C A C G G G G C G G T G G C A C A G C C A C A G C C T G G A A C G A A C T A G C G G T T G A G A C C T T C T A T C A A G T A A A T G T C A C A T G A A G A G G C G G T G C C A C T G G A G A T A T A T G C T A A T T A G T A A A G G C T C G T C C A A C T G T A T G G T C G T A C A A G C T T G T T T C G G G T T A T C C G A T T G G A T C G C G T C C C A C G G T T G T C T C T G T A A C A C C G C G C C C G A C T A T C T G T T G C G G G T G T T T C T G C T T A C C T A A C C G C C A C C T C T C T C C T T T A T A C G T C C C T T G A T A A C C C G T A G G C C A A A G T A C A G G T T A A G T A C T C A C G G T A A G A C T A G C A C A T G G G G A A G C A T G C A G G A C C T G G T A G C T C T T G G T C C T T G G A T T T G G A C T C G C T T G T A A C A T G G G A T A C C C A C C T G A C T G T A G A T T T G G A C T C C G C G C C G A A A T T T G T T C C C C G G A A T C A C A G C C T G G T G G A C A G C G G A G A T C C T G A A A A A A G A C G G G G G C C A A C G A T A T A C T C A C T A T C C C A A G A C G C A T T T C C G T C G T A C T G C A A C C G A G G A T A A C A G C G C C C C T C T A C A A A T A T T A A A T C C C T C C C C A G G T T T G A A T G G G A C G G G G C A C G G A C G A C A T C C A G T C T A A G C T C A G A A G G C C A G T T C C G A A A A A C G A A A G C G G T G C A G A G G G C T T A T G G T T A T C T C A T A G G G T C T A T T C G G G T C G C T T T G G C G C C A A G A G C T C G C G A T T T G A T G A G T G A T A T A A T C G C A C T C T G T G T T C C A T G A A A T C A G A T T G T C G T G C A C C T T G T G T T T C C A T A T A G A C T T C T A A C G C T T G T A C A A C C C A G A A T T T G T A C C G C A A C A C G T A A G G T C C C C G C G G T G A G C T C C A C T G G C C T T C A G T C A C C T G A T T G A C C G T C T T A T T C A C T G A A A G A C C A A C C T G C A T T A C A T C C G A G C T A G T T G G A C A A A G C T C A G T C T G T C G T A A C T T C G C G G A T T G C G T C G C T G C A G A G G C T C C A C C C G A A A G A G C T C G G T A T T C A G T T C C C A T A A T C C A G A T C G T C A G C T A G C C G G G T G G T T C A A A A C A A G A C T A C A A T C G A A A C C T G A T A G C C G G C C G G G G C A G T G G A G A T G T G A G C A C A A T A G A G C T G T A C T T T T G T C G A A G G A C C T T T T C T C G T A C G T A T G A G G G G C G C T C C C T A A A G C T A G A G T C G T A A G T A A T T A A A G T G C G G C T C C C A T G C T C C A T G A C G T C C C G C A T A T G G A C T T A A T G C A C A C A G G C T T A G A C T G T A T G A G G C G G C G G C G C T A T T C A C T C C C G A G G A A G G C A A C G T G G G C G C G C C T A A G T T A A A G A T C G T A C C T C G T C T A C G G C C C C T T C A G A G C T G A G T G G G T C C C T A G G G C G C G G C A G G C T T A T G G A G T G T C G A T A G A C C T C C A A A C A C G G T T C T C C A A T T G C A C G G T G G T C A C C C G C C A G C T G G C C C A A C C G G A G G A T C C A A G G T T A C G A C A A A T G A C T T C G A T G C A G C G C C T C C T G T T G T A C G G A T C T T C C T G A C A A G A T G G T T T C A G A C A G C C T C C A G G G C A A G A T G A G C G C A C T G T T C G G A A T G A T G C T G A G A T T C G T T T C A G T C G A T C A A T G G T A G T G T G T C A T A C C A A A T C A T C A A C G C G T T T G A T A G G C G G A G T A G C C G C C T A C C A T C T G T A G A G A G C G G C C G C G C C C C G A A C G T C A G T G T C T C G A A C T C C C G C G T G C C G C A G C A G T T C T T A A C C A G G T A A T G T G A C C T C T C A C G T G T A A T A A G A T A A A G G A A A T G T A T G G C G G G G A G C G G G A T G G T G C G C G G G C A C G T T C C A G T C C A G T G G G T A A A C A C G C C G G C G G G A C C G T G T G A A T G G C T A G A G C C T C C T C C A C A C G G A G C A T A C C T G A A A G C G G G A G T G G C A A G G C A C G G A C C T T A T C A C T G C G T C A C A C C T C A A A T C C T G G G G G C T T T C C G T A C G C C C A C C T C A C A A T C G G G A G A A C T C C G T T T C T G T C C A C C A C C T A A G C C C G G T A A G G C T T T A T G A A G C A G G T G G C A G C T G C C T T G A T T T T T A G T A A A T T G T G A T C G C C G T G G C G C C T G T T G T C C G T T T T G T A A G G A T C T G T C C G C C A A G G T T G G A A A A G T G A G G C A G C A C G C T C G G T T C C A G C A T T C G T C C G A G C A T G T T G C G C C A T T G A G A G C T T A G T G A G G G C T T T G T C G G G C G A A G A C C A A A G G C G A G A C A C G G C C T T A G A G T A C C G A T G G T G A G G A A G C A T A T C G A C G C A G A G T T C C T A G C T T A C T G T A T C T A C T C C A A C G T C C C T C C A G G A G G C G T G T G C G G T A T T C A G G G T A T T T A A C T C T G A G G G A G G C T G T A T G G C C G G C A T G T G T T C T T C C T G A T C T C C C G G A A T G G C C A T C G G T A A C G T T C C G T T G G C G G C G T A G T G G T G G C G T G C A C A C G G T T G G C T T C T T A C C G C T T C T G C A G C G T G G A A G C T T C A C A G C C T G C T C T T G G G A T G G G G T A T A C A C A C G G T A A C A T G C A T G T C G T G G G G A G A A C T T G A A G A A G C T T T A T G C G C C C C T C G G C C G A A C A A C T G T C G C T G G G A A A C G A G C G T T T G A C G C A T T C G T G T A A T A C T A T C C G T C T C A C T T C C A A T A T C A A G C C C A G T T T G C C G C T T G C G C A T A C A A G T C A C A T C A T T T A C C A C T C C A T A C A G C C C T T A A A C G A T G G C G T T A A C T G C G C C T C T A T G A T C C G C T T G A C T A T G T G G A G T G C C C C T A T G A A G T T C A G G G G T T G C T A A T A A C G C A T G C A A C T A C A G G C C C A T A G T C T T T C T C T A T T C A T T A C T G T T G G A A A C A G G G A T G G C C C C A T T A T G A A C A T G A A T A C G G C A A C T A A A C C C C C A T G T G G G G G A G A A T C T T A A A T G G T G T A C G G G C G T T T C T T A T C G T A T C A C T T C G G G G G A C G G G A T T G C C T A G G T C G T T G A A G G G G C A C C C G T T
A T G A A G G C G C G T G G C C A T G T G T C A G C C C A C T C C A A T G C T T G G A G C G A T A C C C G C C A G A T A G C A C C T T T A C T C T T A A T G A A A T G G T T C G C C C C G C A T C C C T A C A G A A A T G C T A C C T C T T C T T A C A C C G C G T A G C A A C G A T C T C C G G T A C G G T G C C T T A T C G C G A A G C T C T A T A C A T A C A C G T G G G C C A C G T C A T T A A A G T A T G T C G C G T T C T A G A A A G T C G A C T G T G A T C T A C G C G T T G T C G C C C G G C G G A A T G G C G T T T T C T A G T T T G G A T C G C A C T G A T T A G A C A A G A T C C T A A T G T A T T C C G T T A A G T G G A T T T C A A A G G G T T C G A T G A G A G C T C A C G C A C C A A G A C T T A A A G C A A C G G C G C G T A G C G A C T A C A C A A C T G T A G C G C C A T A G T C C G A G T C G C C G G A C G G C A C T T C G G T C G G C G A G G C C C C A A C C T T C G A C A G G G C C A G A G C G C G T A A T G A G T C G C A A C T A A T T G T A G T T C T C T T C A A A G T C A G T T G T T C C G T C G G T T G T T G C A A A C C G G G C T G G C G C T T A C C G A C T G G A A A G A C C C G G C T A C A A T G C C T C T T T C C G A C T C G G G C A T G C C A T G G C T C G T A C G C A C G G T G C G C G G C T T T T T T A G C G C G T T A C T C A A G C G C G A A C A C C G T C T G T C T C A A G T C G C A C A G T C A A A T A G T G G G G T C T A A A T A A A G G T G G G G T A G G T A C A A T T T A G C C A G C T A C G C G G C G T C C C G A G C T G A C A A C C A T T T C C A C G G T C C C A T A G A G C G A G A C A A C C T A C G T T C G T G G A G A G G T G G C A T G T C A A G C A G C A C T C T A T A G A C T A A A T G C G G C G G T C G C A A C T G T G G G G A C T G G G C G C G A G A G A A A T A A C G A A A G A G T C A T C C C C A G G G C G T C C T C T G T C A G T T A G T A C T C A T C T G C C A T T A C G G G C C A G T A A T C T C C C G C C T G T G C A G T C C C G C C G G T A G A T C T A T A C T T G C G T A T C C C T C G G G A A C C A G A G G T A C T G A C A T C G C G G T T T C C T C G A C C T C A A T C G C C G C A G T T T G A T A A T A C A G G C C A G C A C C C T A C A G G T   G C C C C G G A A C T G C G C A T T G C G A G C C A C G T A G C G C G G G G C A G A G A A C G A G G A T A A C C T T G G G T G C C T A T G A C C A A T T G G T C G G G A G A A A C A A C T C A T C T T C G G T T A T G C G T C C C A A A A A T G C A T A G C G A G C G G G T G T G T G C G C C A G C C A G T G A G C C A C G A A G T T C C C A A C T G T T C T A A T C T C G C G A T A T A A T T C G A T A G C A C G G A G C T A A A A T C A T T A G T A C G G T A G G A T G A C G A G G A T G C C C C C C G A G G A G T C A A T T T G T G C A A G G A G A G T T A C C G A C C G C A C A C G A C A C G C C T A A G A C T A T C C G A A C A A T G T G G G G C G G A T C G A T A C C G C C G C A C G G A G G A A G T G T T C C A A C G C C T C T C G T A C C G G T G T G A T T A G C C G T T G G T G G A T C A A G C A G C C T G A A G A T C G G G A G C G G A C A A T A C C A G G C C G A G A G C T A G A G A C A C A G T G A T A T T A T C T G T T G C A G C G T T G G G T G T G C C T T G A T G T C C A C C C G C G G G C A G G A C A C G G C A A T G A T C G C A C C G A G G T C G C C A G C T T A G C T A C C T G T C T A A C T G A G G C T A T G T T A A A A A T T G G G T T C G A C A   C G C A A T G A C T C C A T C A A G C A C C A G T C G A G T A G G C A T G G T A C A C G T G G C A G C C T C G T A A A C C T A A T A C C T T G C T G T C A A G A G C C A C T A G C T A T A C C T G C A C G C A T G T G C A A T C G C G A G C A T C T G G G T C G A C G C C T T T G C A G A A A C T T C A C T A A C C T T A G G T A A C C G C T T G C G C G G A C T A T A G T G A T C C T A G A C A T G A G G A C A T C G G C T A C C A T G T C G G C C G T A T C T G C G G A A T C A C G G A T T G G A T T C T C A T G G C G G G G T C C A C G G T C C T G T T T G A G T C A G A A G G C C A T G A G C C C C C C G A T C A G G C T T C G A G T G G G G T C T C A A G T C A T A A G C G C T G G A C G T G C T T C G A T G A G C T C G T A T T T C A T C G G C A A G A T T C T T C C C G C A C C A G C A A C C C C G G A A T G T G A C T T G T C A G A C C T G T A G G C C G T A C C T C A G A T C C G A T G C C A T G G T A C T A C G G G A G C G A G G C A G C T A G A T G A T G G G G A A T T T C C A T C A T T G T A A G T T A C C C A C A C G G T G T G C A G T G T A G A C T A T C T G T T A G C A A G C C A A T T T G C G G C C T C G C T T C T C C C T C C C G C T C A A T A G T C G T A A C T A T T T C C A C C G G A T A C G G T T T G C C G A G C G C C C T G C A C C A G C T G A G G T A C A T A G C G G T A T T T C T G G C T C G G T C T T A G G T T T G C T A G A G T C A T G C T A A T T C G T T G T G A G G G A C T C C T G C T C C G T A A A G T C T G G T A A G T T C C A T G C T C C C G C C A A A T T T T A A C C C G G C C A G G T C T A A C T T T C G T A G C A G A C G G A T A A T G T A G C A T C A A T G C T G T C C A G A C T A T G A A G T C G A G G A G A A G G A G T A T T G T C T T C T C T A C T G T G T T A C C T G G C T T G G A C C T A A T T C G G T C T C T A G C G C C A G G G T A A G T T C C G C A A A A A C T A G A T A A A C C A T C A A G G G C G G C G T G A G G G T C G A T G C C G T A T C T G A G T G C A A A C C G G A A A T A T G C G G C T C T C T G T G T T C T C T C G T A A T C G G T G T C C G G A C T T G G A C A T T A T G C T A G G C G A A C C G T G A C T G T A C C C T T A G G G T C G C C T T T T T A T G C A G C C T C A G A G C A G C A A C A T G T C G T G A C C G T G T G G C A A C A T C T C T C G C C G G A A T T A T G T A C C C G C C T G A C C G T A G T G C T G A A A T A C G A A C C T A C T G A T A T C C A G G T G G C A C G G T G G A G A G C C G A C A A G G A C T T C G A T A A C G C C T C C G C C G C A A G G T C T C G T C A G A A A T C T A G A G A T T A C G C A T G A C C C A C C C G G G C A A A G A C G T G T T T T G G A C C T C T A T C C C C C T T T G C A G G T G C A A A T A C T C C C G G C G C A G G A T A A G C A A A T T C C C A T A C T A G A A T A T T C T C A C G T T A G A A T A G G T G A A C T C T A G A A T T T A C G T C G G C C T T A A T A G A C G T A C A A G T A C A A A A T A T A C A T G C A A T C G C T T C T G C A T C C A G C C G C G A A C A A T C C G T A C G A G C A G G G A C G T G A T T G C C A G T A T T T C C A G C G T C G A G G T T C A A G A C G A A G G A C T T G C C C T G C G G G C G A T A G T G T C A A G A T G C A T C A C G T T A C C A G T A A T A C A T T A G G C T G A T T T T A G G C A T G C G C A G C C G T A C T A A A A G T A A A C G A C A G T G G C G T A A G G A C T A A A G C A T T T T T G A C G T G C G A A A A T C C G C T C C C G A G G T A G G T T G C C C G G T G T T T C C C G T G A C A T C G G A T C A T A A A A G A A A A G C T C A T C C C C A G T G A C A A A T A G G G G T T C T C T C G C G C A T T G A C G C T G C A G A C T A A A T C T C T G C A G A T G G A C C T C G G A G G A C C G C C G G T A C C C T A A T C C T C G C G C T T T G A C T T C T T T C T C A C T G A T G T G C T A T G T T C G A C G T C G A T A A T A T C A A G T A G C T A G G C C A G T G C T T G T G T C T C A A G G G T T A C G C T C A A C G T G T G T T G G T G A G G C C C C G T G A C A C C G G C T A T G G C A T T T T A T C G G T G G T G A A G A A C G A T G G T A T T T G C G C G T C G T A C G C A   T G C T T C G G C C G C C G C A G G G T C G A A A A G G C T C C G A A C A T A A A C G C A G C C T C C A C T C A C C G G C G C A C A A G T C G A C A G T A A A G G C C G C A A T T A G A G T A A A C C C G G A G G A T C T C A A A C G A T T A C T A G T A G A T A G G C C C T G C G G G T T A T A G C G C T G T A A G C T T T T G T C T C A A C C T T A A T G T A G C C C T T G C A G C A C T C G C T T T A C T G C G T C G T A T C C T G A A C A T C G G C A A T T A A A C G G A A A T A T T C A A A C C A A T A G T T A C C T A G A T T C C A G G A T C G A G C G A G T G T T G A C C T G G G G A A C T A G C A A G G G T C C T T T T T G A A T T T C C A C C G T C T A G C C A C G T G G A G G G T G A A C C A G C T A C T T C A C G C T A T A T C G T C G T C A G A A T T A A C G T A A C A T C G G G C C T A G A T G C G G C T G A G G C C C G A G T G G T G C C C G T C G T A G G G C G G T C G T T C C C C C A A C A C T C A A T T C T C T T C T G G G T A A C A G G G T G G A C G G G G C A A C G C A A G C G T A A A A T T G C G G T G A C C A G T C T G C T C T A G C G G G G A T C G T G T C A C C A T A A C G C C A T G C G C T A C T C C C G T C A C G A C G G G C G G C G G A G A T T G G C A A G T T T A C G G C G T A G A A G C T A C G T T T A T G A A C A T A G C G C C G C A T A C T C A G C T T T G G T A T C A A G C T C G G G C T A T C T A G A G A G G G C G T G G C G C A C G C C G C G A G G C C T A A A A G A G G C A G C A A A G A G G C G C A C G G G T T A A A C A T C G C G A A A G T G C C A C T C A C C G C A A A T C G A T T A T C A G T G T C T A C C A C C G G T G C C C C C C G G T G A T A T C A T T T C C C C A A A A A T T C G T C G G C G T A C C C T C C C T T C T G T T T T A T A T T G A A G T T T T C C T G T G T C G C A C T C A T G G A A A C T C G T G A C A G C G G C C T T G A C C T T T C T G C A C T G C T T C G A T C T G T G A A T G T T T T T C C T G G T C T T A T C T C A T G G T T G C G G A T T A G G A G C G T C A G G G T T T T T A A C G G G G T T C A A C G T T A A G C T G T C C G C A T G A T T A A G C C A C A G C G C A C T A G A A G C C G G A G T G G C A C G A G C A A A A T G T G G T T C G C A C T C G C G C C A A C G C T A T T A A T C T C C G C T C A G A C T T G G G T T A G G A C C A A A C G A C T C C C A T G G T G C A T A A A T C C T A A C C C A T A C A G A T G C G T C T G A A C G C C C C A G C C G A C G T G A A A G T T C A C C C G T C A C A A A T T G G T T C G T G C C T T A G T G C A A G T G A C G C C C C C C T A G C G A T C A T G G C G A A T A C T C G C G A C A G A C G G A A C A C T G G G G A A G T A G T A G G A T G A G G A C A C A C A T C A A G C T A A G G G C G T C T T A A A G G C G C C A T T C C T A A G C G T T C A A C T G C G C G C T C C C C G A T C G T A A G G G G C C A C G G G G T C G T C C C G A C T C A T C G G T G T C T G G G A C A C A C A A G A C C G T T G C G T C G G A A T C A G G T C G T C C T G G A T A C G G G C G C C C A G A T C C C G C A A G C C T G G C G T C G C C G A C T T T G A A A G G G C C C T T G T A C C C A A A A C C T G T A C A G T G G G T T C C G G A G G C T A G T T C G C T T A A T G A G A C A A T G G T T C G A A C T C T T C G G C G C G A C C A G G T G G G C G G G C C C C G A C T G G T G C T T T G A C A G C C A A C A C T G C A C C T T T T C G G T T A A A A C A G T C G G G G T A T G A T C G G C C T A G A T G G C A C A C T G C G G T C C A G T A C T C A T A T T A C G C T T C A G C G C T C T G A G C G T T G C G C C C A T G A C T C G T C T G C C C A G C C T C T G T C C A T A T C A A A G A A A C G G G T A A A T T T A A G G C A C A A G C C G G C A T A C C C G T T A C G A G C G T C A T G T T G T A G T T C C G T A G G T T G C G A T A C G G C C T G T T A C A A A T A A A A A T G C C A A C G C T A G A A G T T G C G A A C G T T G G C G G A C C G C C G G G G G G T A C G C G G C A C T C T G G A G C C G T A T T G A G A C C C T G T A A G T G A A A C G G G C C A G A C G T T T A T G C G C C A C G A G T T G G C G T C G A T C A C T A C A C C G G A A A G C C C G C C T T T T T G A G A G A G C T A C T C T C G T C C G C G A T G T A T C C C T G G C G G A C T G A A T G A A C C T C C G C C C A C C A G T T T C G T C G C T C C C T A T C G T T A G T T T G C T C T C T G A C C A T A T A A C C C G G G G C A G T T A T A A C G C G T G C C T A C T A A C T A G T A T A C G T C T A G G A A C T T G T A T C G A T G T A A T A T T A T T G A C G G C G G T A T A C T A C T T C A G A T T T C A T C T A T A T G G T G G A A G A T T A A C G T A T C T G G A T T A T A T G C T C G C C A C C C T A C G C G G G A C C C C C T G C C C T G A T C C C T C T A C A C T A G A G C G C T G C T C T T G G C T T T C A T C A G G C A G A T G T G C A C G C T G A A C A G C T A G A C G C A G T C G T G G T G A G T G A C A T T G T T A A C C G A A T A A T C G A C G C C G A C A A T T G A G C C G C C C G C A C T C C G G A A T G C T A G T T G C C A T A C T G A G T C G G T A C A C T T A A A C C T G C C C G G T A C G C C A T A G T T C C G G C G C A A G T G A C T T C T C G A C G A C C A G C C C T C C A T A C T C G T T C A T G A A C T A T A C C C C G C A C G G A C G T C G T C C A C A T T T A G C G G C A C T T A C C A C   A C G G A G G T G A C C C A A A G A T G A C T C C G C A A C T C A T A T A G T G T C C G T G G C C T A G A C C A G G T C G G A G T T G A G T C T C A T G T G T A G G G A T T C A A A T G C T C T T C C A T A A G G T A A C G A T C G C T C G C A T A A C T A C G T A G T C A T A C G T A G T A T C T C G T C G T C A T A T A T C A A A A T A G G A T G G C C A C C C T C A C T C T A C A T T A C T G C A A T C T T G A C T A C G A T G C C C A C C C C G C A G T C A A C T C C A A C A A T G C C A T G A G G A C G T C T G A T C G A C T A G G A C T G G C A C C A T G C T T G G A A G G G T G A A A C T C A T A A A C G T C C T A T C A C A A A T C G T G T C G G A C G C A T G T G G G A C C G C A G C T G C T T T C T A C T T T A T C G C T T C A C C T G T T G A A A G A A C G G T T G G T T C C C T G G G A C G C A C G G G G C T C C T T G C A T A A A C C C G T T G A A C A C A G C A C A C C A A T C C A G G C A T A G A A G G A C T G G C T A C T T G C T G C A A G G A A A A G A C C T G G T G T T G T C A C A T A A C G G C A A T G T A G C C A T A G C C T G T T T T G A G A G C G G G A T C A A G T T T G T G T G T C G C C C C T T T T C C C G T G C G C C A A A A T A A G C C C G G A C A T C C G C C C A A A T G G G A A G T C C G A A T G G G T C G G T C T G T C A A C C C G A T C T T C C C G G G A C T A T T A A G G C C C A C C G G T A A G G G T C C G G G A G T A G A G C C C T A T T G T G T C C C T A G G G G T A G C C C G G C G G A T C G G T G G T G C C C C G G T A C C T A T A A G A G T T G C A A C A G T G T T A G T T C G C A C T T A C A A C G C G A C A G C C T T G A C C C A A C C T G G C A C T T A T G A C A T T C C T A G C G C A A G C C C C G G C C C A G A G G G G G G G A C C A A T G A C G C C A T C G C T T G G A G T A T A G G C G T G C A C T T C T T C T C A C G T G T C G T G C A C G G G C C C C T G A C C T C T A C T G A T A C A T G G C C G T A T A G T A A G A T A A T C T A C T T G T C C G A G T G T A A G G G A A A C G T C T T T G A C T T T A C A G T G G T G C C G T G G C C A C G T G A G C G T T T C C G G A T G C C G G A C G C C C G A G T C G G C A A T C T G G T T G C C T T A T A C C C T T C C A T G A C C A G G T G G T T A G C C G T G C C G T T C G G G T T C C T C C A A G G C G T G G T A A G C A G C A T T C C G C G T T T A G C A G G G C A A C A A G A A A T A A G A A A T C A G T T C A A A G T A C G A T C T A C T A G G G G T C T T C G G A G T T G G T A C G C G G C C C T A C C T T C C G C A G C C C T G T G C G A G A G A A G C C T G T G C G A A C T T T C G T C A C A A T C A C C T A T C G G G A C T C T C G C A A G T C T A G G T C A C C C G T A A T C T C G A T A A G A C A A T T G A C T T C C A G G A G C C C A C T T A A T A C A T T C C C C G G C T C G G C T T A A T G T A G C T C G G A C C C C C G A T G G G T A G C C C T G A G C G G A G C A C C C A G G G T G C C T A G T A C C A C G G A T G C G A G G C T G T A C G T A G T C T C A G C T C C C C A A A G G A T T C A G G C C C T G C A C C G C A A T G T A A G C C G C T T G G A G A A A T A C G T G C C C G C A T A C A G G T A T C T G T G A C G T G A G C A G C C G G C A C T A T A A A A C A G C G T C T C T C T C G G C C T C G C G A T C G C G T G G A C T T C G A G G G C A A T G A A G G C C A T T G G A A C T A A T C C C T G G T A C A G C C T G G T A T C G A G G C T G G G C A C C C C T T T C A C T C G T C G C A T C A G C T A A G T C C C C C C G C T T A T G G A G T C G T A T C G T G G G A T T T C G C G A T A C C T T A T A A A C G G T C T A G T A T T C T A T G C A A G A G G T C C G C G A C C C C T G A A A G T T A C G C A G G C A A A G G C T C C A C G G C C T C C G T G T A G T A A C T C A G T T C C G G A C T A C T G G T G T T A G C A A G A A A G C T A C G G G T A T T G T T T T G C G A C G G T C C G T C A A C C T A A C G A C G A G G G G G G C G A A G T G A C G A C C C C C G T G A T T T C T G A T C A A C C G G T T A C C G A T T A T T G A T A G G G C G G A T C C C C C G A G G G G T C G G G A A G A C A A G G C G A C C A T G T C G G A G G T G C G G G C A A C G G T T C G A G G G G A G A A G T T T G C G T G G C G T C C C G A A G A G A C T G G A T A A G C T T A T T A T C C C A C A T G G G T A C T A A T A G C G G C A G G A T G C C C A A C C C G G T T A A A G C G A T A A T C C A A G T T C A T A G C C T A G G A G C A T A A A A A C C C A C C C G C T A C A A A C T C T T T C A A C C A T G C T C C A G C A A A T T T C T A C A T T A A G A A G T C C C T G G G C C A C T T G C A T A C T A G C C C T C C A T C C G A T C C C T T T T T A G C C G C C C G A T A C A C A A A C A T G C G A A C C T A A G C T T C T G G C A A A G A A G A A C C A T T C A C T C G T T C C G C A C C C C G G C G C G G A T A T C T A C C C C C T C G G A A T T C C T C C T T C A G G A G G T G T G T G A T T A G G T G C A C C C C C C T G C A G T A A G C G A C T C G A A T A T C T C A T T C G C A C A G C T T C T T A T T C T G A C T G T G C A T A G T A G G C C C T G A A C G T G A A T C G C G G A C G A C A A A A A G T T G C G T T G C C G G C G C C A C T C G A T C A A A G G G G C T T T G G C G T T C A T C T C T A A C T A T T T T C T T T A G C T G G G G A T C T G A T A T A G T A C T G C A G T A A T T A G G C C C C G T A C C T C C T G G C G C T T C G T G A C G G C G C C A T G C T C T A A T T G G T C G G T A G G T A T C C T C T C C C C T G T A A T C A C A C A A A G A T C T C A G C G A C T A C T G C A C C A C T G C T C T C T G T G T G T C A G A A G A G C T T T G C G G G A T A G A T G C A A G C T T G T T C C T T T C T G C G C T T G A C G T C T A G A T C A C G G A A C T G G G A A A G T T G C C A A C A T T G G A C T C C G G A G C C T G A C G G T G G C G C A C C C C A C G C A G G A C A G A T A G C A T T T C A C A G G A A A T T G A G G C A G A A T A T A T G G T C G C T C G G C C C C C C T C A C T T A G C G A C T G C G C A C C C T G A T A G G G C A T C C G C C A G T T T A A G G C G T C C T C C T A T T G T T T A A A C C C G C T A G T C C T A A T T A G T C C G T A A A A G G C T A G A C A C G C A A G G C C G A T G C T G T A T T C G C A G A A C C A G C C G A C T A C G G T T A A G C C A T A A C C G T A G T T T A T A A C G A C A A T C C C A T C G A G C C A G T C A C T G C T C G T C C A T G A A G G C G G T C A A C C A A A G C A C T C A C C A T C T T T C A A G T T C T A G G A A G T A G C G A G T G T T C T A C G G T A C A C A A G A T C A G T G G C T C C G C C T C T T A T A T T A G T T C C C T G C T C T C G A C T G G G T G T C G C C C A G C C C G A A A T C C A T G C G T C C G G G A C C T T C G T C C T C C C C A A G G C T A A T G T T T A C G G G C G G A A A C G C A T T C C C G G C C C C T C C G A C T C A A T C T G C A C T G A   C A A A A G G T C C C A A G T T A C G A G A A A T G C T C G A G G C G C C C T A C C T T G G A T A T T T A T C C C C C A G T A C T T T G C G A C C A C G C C G G C T G G G C A C G C T A C A A C A C T C A G A A C G T C C C T A A T A G G G T G C T C G G T G G T T T T G C A A G G A C A T G A A A C C T A C C A T G C C A G T G T T G G T T T T C A G G A A T T A G T C G T T C G T G T A T G G A G C G C A T T C G T C C A C C G T C A A A A C A C G A G C C A T T G T C A A A T A G G G T C G C T T G C T T T T G T C C C G G A C T C C A C G G C T C A G G T G G T G G G C C G C C A A A G A A C G T T A T C A A C T T T G T T G T A T A A T C C T G T A G T C A T T C A C A A T C T A C T G A T T C G T C T T T A A A G C C G G C C G G C C C G T T T A C C T T A T T G G C C T G G T T A G C C G C G C C C T C G T G C T T G C T T T G A A G C A T G T A C G C C T C C T C C G T T C A T T G A C A G A G A T G G G A G G T G T C A C A T G T T G C T A T T T T G C T A T T G A A C A C C A C A T C C C T T C A T T T A A G G C G G G T C A C G G G G C G G T G G C A C A G C C A C A G C C T G G A A C G A A C T A G C G G T T G A G C A T C C A G G T C A A G T A A A T G T C A C A T G A A G A G G C G G T G C C A C T G G A G A T A T A T G C T A A T T A G T A A A G G C T C G T C C A A C T G T A T G G T A T G C T C C A T G C G T T T C T G G T T A C T C G A C C A A G T C G T A T C T T G A A G T G T C A T C T G T A A C A C C G C G C C C G A T C G C T C T T T G C A T G T G G T T A T G C T T A C C T A C T T G C T G T C T C T C T C C T T T A T A C G T C C C T T G A T G G C C C G T A G G C C A A A G T A C A G G T T A A G T A C T C A C G G T A A G A C T A G C A C A T G G G G A A G C A T G C A G G A C C T G G T A G C T C T T G G T C C T T G G A T T T G G A C T C G C T T G T A A C A T G G G A T A C C C A C A T G A T T G T A G A T T T G G A C T C C G C G C C T C A C C G T G T T C C C C G G A A T C A T G A A A T G G T G G A C A G C G G A G A C C T C A A A A A A A G A C G G G A G C C A A C G G C G C G T C A C A G C C C C C A A A C T T T A T C T C C G T C A C A C T G C A A T T G G G G C T G C C C G T A A C C T C C G G T C A A T A T T A A A C C C T T C A T T G A A G T C A G G T G G G G A T G G G A A C G G A C G A C A G A A G T T T T G C A T C T C A G A G A C A A G T T C C G A A C G G C G C C A G A A G G A T C T G A A A T G C G C T A C G G G T G C G G C A G A C T T C C T C G G G T C T A C G G A G C G T T A G T G A C C T A T G A T T T A A T G A G T G A T A T A A T C G C A C T C T G T G T T C C A T G A A A T C A G A T T G T C G T G C A C C T T G T G T T T C C A T A T A G G A C C A C G A T T C C C A C G A C G C T T A G C C T T T A T A C T A T A A C C C G T A G A A C T T C C A T G G C G A G A C C C A C T G G A A T T A G A T C A C C T G A G C G G A C G T C T C A T T C A T T A A A A G A C A A A A A C A A C T T C T G T C C G A G C T A T T T T A G T A A A G C T C A G T C T G T C A T C C T G G A T T G G A T T T C G T C G C T G C A G G T T A C T A G T T T A G A G T C A T C T T T G G G T C A T G C C C C C G G C C A C G A G T A G T A C G C C A A T A A A A G G G T C T C G A G C A G G C T C A C A C T T G A A A C C T G A T A G C C G G C C G A G A T C T C T G G T C T G C G A G C A C A A T A A G G C T G C C T C T T T G T C T A G A T A A C G T T T C T C G T A C G C G C G A G G G G C G C T C C A G C C G G C C G G G G T C G T A A G G G A T C A A A G T A A A T A G C C C A T G C C C C A G G G T G T C C T G C A C G G A G G A C T A A T G C A A G A G A T T C G A G A C T G T A C T A G A T G G C A G T G C T A T T C G C T C C C G A G G A A G G C A A C G T G G G C G C G C T C A A G T T A A A G A T C G T A C C C A A T C C A T T G T T T A G G C G G G G C T G A G T T G G C C T C C C A T T T T C G G C A G T C C G A G A A C A C T C C A G T A G C A C C C C A G G C A C G A T T C T C C A A T T G C A C G G T G G T C A C C C G C C A G T T G G C C C G G T A A A C T A G T C C A A G G T T A C G A C A A A T G G T C T C A G G T C A G T G C C G C T G G T T G T A C G A G G C T T A A C T A T G G A G C A A C G G C A A A C G G C A C A C G A T G C A A G A T G A G C G C A C T G T T C G G A A T G A T G C T G A G A T T C G T T T C A G T C G A T C A A T G G T A G T A T G C C G G A C C A A A C A G G C C G T T A G T G T A C T A G G C G G A G T A G C C G C C T A C C A T C T G T C A G A C G C G G C C G C G C C C C G A A C G T C A G T G T C T C G A A C T C C C G C G T G C C G C A G C A G T T C T T A A C C A G G T A A T G T G A C C T C T C A C G T G T A A T A A G A T A A A G G A A A T G T A T G G C G G G G A G C G G G A T G G T G C G C G A G C C C G T C A C A G T C C A G G A A T T A A A C A C G C C G G C G G G A C C G T G T G A A T G G C T A G A G C T T C T G C C G T A C A A A T T C T C A C T G A A A G T A A A A G T G G C A A G G C A C G G A C C T T A T C A C T G C G T C A C A C C T C A A A T C C T G G G G G C T T T C C G T A C G C C C A C C T C A C A A T C G G G A G A A C T C C G T T T C T G T C C A C C A C C T A A G C C C G G T A A G G C T T T A T G A A G C A G G T G G C A G C T G C C T T G A T T T T T A G T A A A T T G T G A T C G C C G T G G C G C C T G C G A G T A A C C T T G T G G A G A G C T T T C C A T A G C A G G T G G A A A G G G A G G T T A A A G T G C C T G G T T C C A G C A C C T G T C C A G A T C T A C C G T A C C C C C A G A G G T T T A G T G A G A G T G C G T T C G G A C G C A G A C C A A G T G T G G G A A A A G A T A G T C A C G C G T T A G G T A T G A G A G A T C A T C T A A C A G C G T G A G T C C T A G C C C A C T G T A T C T A A C C T G G T A C T T T C C C A G A G T T T T G T T G C A G T G G T T G T A A T A T T T A A C G C T G A G G G A G G C T G T A T G G C C A G C A T G T G T T C T T C C T G A T C T C C C G G A A T G G C C A T C G G T A A C G T T C C G T T G G C G G C G T A G T G G T G G C G T G C A C A C G G T T G G C T T C T T A C C G C T T C T G T A G T T C G G A G A C T T C A C C G C C T G C G C T T G G A A G A G G G T A C A T A C C A G G G G A T G G G A C C A G A G T A G T G G G G G T G G G A G A C A G C C T T A T G C G C C T C T C A G C C G G G T A A C C G T A G C T G G G A A A C G A G C G T T T G A C G C A T T C G T G T A A T A C T A T C C G T C T C A C T T C C A A T A T C A A G C C C A G T T T G C C G C T T G C G C G C C T A A G T C A T G T A A T C T C T T A C C C T C C G C G G T T C C T G A C A G A T G A C G G T A A C T A T G T A C C T G T G A T C C G C T T G A T G C C A T T G G G T T C T C C T A T T A G G T C C A G G G G C T G C T A C T A A C T C C T G C A A C T A T C A A T A C G G G A T C T T T T T C C A T T T A T C G C C G T T G T A A A T A A G T A T A A T T A A A T C A T G A G C A T G A G C C C G T T A G C T A A C T T C C A A T G C A T A G T G G C A C T G G G C G C A A T G T A C A A T A T T C C T G C A T C G T A T C C T T C C T G T A G A C G A G G C T G C C C G G G T C A C C G A G A A G A C A T C C T C C
# ID 2
A T G G A G T T T T G T G A T T A G G T   G C G T T C A G A C A A A G T G C C T T A A G C G A T A C T A G T C G G A C A G C A C C T C T G C C C T T A A T G A A A T G A G G C G C T T C G C A T T A T C C C A G A A A G G C C G T T T C C G T T C A C G T T G T G T A G C A G C T G T T C A T T A T A C G G T G C T G C A T C G T A G C T C T A C A T C C A T A C A C G T G G G C C G C G T C A T T A A A G T A T T G T A C G C T C G C G G T A G T C G A C T G T G A T C T A C G C G C T G G C A T C C G G C G G A A T G G C G T T T T C T A G T T T G G A T C G C A C T G A T T C G A C A C T A T C C T G G C A C G T C T C A T T A G G T G G G G G T C A A A G G G T G C G A T G A G A G C T C A C G C A C C G G G G C T T A A A G C A G A T T A G C G T A G C G A C T A C A C A A C T G T A G C G C C A T A G T C C G A G T C G C C G G A C G G C A T T C C A G G C G T T G G A A A T A T C G T T C C C T A C G G G G C C G G A G C G C G T A A T G A G T C G A G A T T A A T C T T C G G T T G C T C A A A A G T C A G T T G T T C C G T C G G T T A C T G C A A A C C G G G C T G G C G C T T A C C G A C T G G A A A G A C C C G G C T A C A A T G C C T C T T T C C G A C T C G G G C A T G C C A T G G C T C G T A C G C A C G G T G C G C G G C T T T T T T A G C G C G T T A C T C A A G C G C G A A C A C C G T C T G T C T C A A G T C G C A C A G T C A A A T A G T G G G G T C T A A A T A A A G G T G G G G T A G G T A C A A T T T A G C C A G C T A C G C G G C G T C C C G A G C T G A C A A C C A T T T C C A C G G T C C C A T A G A G C G A G A C A A C C T A C G T T C G T G G A G A G G T G G C A T G T C A A G C A G C A C T C T A T A G A C T A A A T G C G G C G G T C G C A A C T G T G G G G A C T G G G C G C G A G A G A A A T A A C G A A A G A G T C A T C C C C A G G G C G T C C T C T G T C A G T T A G T A C T C A T C T G C C A T T A C G G G C C A G T A A T C T C C C G C C T G T G C A G T C C C G C C G G T A G A T C T A T A C T T G C G T A T C C A C T A G G G G T T G T G A A T A C C T G T G G A A A A A C G G T A C T A G C C G C A A T C G C C G C A T C C C T C C G A T A C A T G C C C A A G A T C T A C A G G T T G C C C C G G A C C T G C G T A T T T A G A A T C A C G T A G C G C G T G G T G G A G A A C T C G G A T A A C C T T G G G T G C C T A T G A C C A A T T G G T C G G G A G A A A C A A C T C A T C T T C G G T T A T G C G T C C C A A A A A T G C A T A G C G A G C G G G T G T G T G C G C C A G C C A G T G A G A A G T A G G T C T C C T C C A T A C T C T A A T C T C G C G A T A T A A T C A G A T A G C A C G T A G C T A A A A T T C G G G T T A C G G T G A A G G T C C G A A T A T T C G T C T A G A G G A G T C A A T T T G T G C A A G G A G A G T T A C C G A C C G C A C A C G A C A C G C C T A A G A C T A T C C G A A C A A T G T G G G G C G G A T C G A T A C C G C C G C A C G G A G G A A G T G T T C C A A C G C C T C T C G T A C C G G T G T G A T T A G C C G T T G G T G G A T C A A G C A G C C T G A A G A T C G G G A G C T A C C A G T G T C G G G C C G A G G A T T G G C T C C A C A G T G G C G G G A T C T G T T G C A G C T G G T G G T C C G C C T G A A T G C A A G G C C G C G G A C A G G A A G A A G T A A T G A T C G C A C C G A G G T C G C C A G C T T A G C T A C C T G T C C G G T G A G A A T G C C T C G G G G C A C C A A T C G C G C A C C T T A C G T A C C T C C A T C A A G C A A A A T G A T A G T G A A A G G A A C C C A A G T G G C A G C C T C G T A G A C C T A A T G C T G G A A C T G A A A G A G C C A C T A G C T A T A C T T G C A C G C A C A T A A C G T A A C T G T T G C T C G G G T C G G A T A C T T C G C A G A A A C C T C A C T A A C T C G G A T C C G A A T C T T G C G C G A A C T A T A G T G A T C C G C G A C G T G A A A C T C C C A A T T A C C G T G T C G G C C G T A T A T G C G G A A T C A C G G A T T G A G C T T G C A T A T C T G A T C T C G C G G T A T C A T T C T A T T T C G C A G G A A C C A G G C C C C C A G A T C A G G C T T C G A G T G G G G T C T C A A G T C A T A A G C A T C A T A C G C G T C C T G A T G A G C T C G T A T T T C A T C G G C A A G A T T C T T C C C G C A C C A G C A A C C C C G G A A T G T A A T T G T T C A G G A A C A C C A T C C G G A C C T C A G A T C T G A T G C C A C G G C C A G G T G G G A G C G A G G A C T C C A G A T G A T G G G G A A T T T C C A T C A T T G T G G G T T A C C T A C A C G G T G T G C A G T G T A G A C T A T C T G T T A G C A A G C C A A T T T G C G G C C T C G C T T C T C C C T C C C G C T C A A T A G T C G T A A C T A T T T A C A C C A A G G C C G G T T T G C C G A G C G C C C T G C A C C A G C C G A G T G C A G T G T A A T G G T T T C T G G C T C G A T C G T A T G T C T G A T A A G A C C A C G C T A A T T C G T T T T G A T A T G C C A C C G C T C C G T A A A A T A T G G T A A G T T C C A T G C T C C C G C C A A A T T T T A A C C C G G C C A G G T C T A A C T T T A A C G T T G A G C G G A T A G C A T A G C A G C G A T T T G G G C C G T C A C A T G G A T T C G A G A A G A A G A A G T A T T G T C T T A C C T A T T G T G T T A C C T G A T G T G G A C C T A A T T C A T T C C C T A G C G C C A G G G T A A G T T C C G C A A A A A C T A G A T A A A C C A T C A A G G G C G G C G T A G T G G T C G A T G C C A C A C C T G A G T G C A A A C C G G A A A T A T G A G G C T C T C T G T G T T C T C T C G T A A T C G G T G T C C G G A T T T G G A C A T T A T A T T A G G C G A A C C G T G A A G G T G T T A C C C T T G T T G C C T T T C G G C A A A G C C T C A G A G C A A T C A C A C A C T G C A C A T G C A G G G T C G T C G A C C T T A T A A A A C C G A T G T A C C C G C C T G A T A G T A G G T C T G C A A T A C G A A C C T G A T G A G A T C C A G A C G G C A C G G T A G A G A G C C G A C A G G G A C G T T G A T G C A A A T G T C G C T A T A G T G C T C C G T A C A G C C C C C A G A G A T T A T G A A T G G A T A A C C C G G A C A G C G A A A G T C G C C A A A A T C C T A T C A C C C G C G G T G G A T G C A A A T A C T C T C G G C G C A G G A T A A G C A A A T T C C C A T A C T A G A A T A T T C T C A C G T T A G A A T A G G T G A A C T C T A G A A T T T A C G T C G G C C T T A A T A G A C G T A C A A G T A C A A A A T A T A C A T G C A A T C G C T T C T G C A T C C A G C C G C G A A C A A T C C G T A C G A G C A G G G A C G T G A C G T T T G A G A T T T C T G A T A G T T G T G T C T A A G A C G A A G A A T T T T T A C T G C G G G C G A T A G T G T C A A G A T G C A T C A C G T T A T C A G T G G C G T A T T C A G T T G A T G C C G A G C A C T C G C A G C C G T C T T A C G C G C A G G T G A C A A G G T C G T A A G G A C T A A A G T G T C G C C G G C G G G C A A G C G C T T A C T C C C G A A G C G A G T C A C T T A A C G T C C C C T A T G A C C T A A A G C C A T A G C G T C C G C G C T A C G C T T C G A C T G T A G A G C T T G G T T C T C C A G A G C A C G A G T T T G A A G A C C C A A G T T C C T G C A G G G A A A C A T T G G A G G A C C G C C G G T A T T C G A A T C C T C G C G C T T T G T C T C A C C G C G T A C T G A T G T G C T A T G T T C G A C G T C G A T A A T A T C A A G T A G C T A G G C C A G T G C T T G T G T C C T A G G A T C G C T G A C C G G T A T G T A G C G A C G A G G C C A T G T G G C G T A G A T C G C A A T C C C C C G C T A G T G G T G G G G A A C G A C G A T C T T C T T A A A C A T C A C A T C G G A A C T T G G T T A A C G C A G G G T C G A A A G G G C T C C G A A C A T A A A C G T G A C A C T T A C T C A C C G G C G T A C G C T C C G A C A G T A A A G G C C A T C G C C G A G A T A A A C T C G A A G G A T C T C A A A C G A T T A C T C G T A A G T G G G C C C T G C G T A T C A T A G C G C T G T A A G C T T T T G T C T T C A C C C C G C C A C C T T T T T T G T A A A C T T C A T C C G G T G A A G C T A C A T C C T G A A C A T C G G C A A T T A A A C G G A A A T A T T C A A A C C A G C G G T T A C C T A G A T T T C A G G A T C G A G C G A G T G T T G A T T T A A A T C C C C A A C C G A A T G T C C C T C C G A A T T T T T G C C A G C T A A T T G C G T G G C T G T T A G G A C G A T C A T T G A C T T A G G C G G C G T C G T C A G A C C T A A C G T A A C A T C G G G C T T A G A T G C G A C T T C T A T T A T G A T A A C T T A A A T A G T A G G G C G A T C G C G C C C C C A A C A C T C A A G T C C C T T T G G A A G C G A C A A T C G G G T A G G G T A A C A C G G T T T T A G G G C T G C G A C A A T T G G T G C T A C C C G T C A G A A G C A T C T C T C C T G T A A C A T A G G G T T C T A C T C C C T C T G C A C A A A T A T G C G T A G A T T G G C A A G T T G A C A A T A T C G A G T T C C T A C G C G G A A C T A T G G T A C C A A A T A C T C G A C T C T A G C A T C A A G C T C G G G C T A T C C G G A A C T G T T T G T A T G C A C G C C G C G A G G C C T A C A A T C G G C A G C A A A G A G G C G C A C G G G T T A A A C A T T G C G A A A T T A T T G A T C C A A T C A A C T T A C G T A T C A T C G T C T A C C A C C G G T C C C C C C C G A C T G T G T C A C C C T T T A A A A A C C T T T T T T A T T T A C C C T C A C T T A T T C G G C A T A T T G A G A C C C G T T T G C T C A G C A C T C A T G G A A A C T C G T G A C A T C G G C C T T G A A T T T T T T A C A T G T A G C C A G G C T G T G A A T G T T T T T C C T G G T T C G G C A C C G T G G T T T T T A G T T A G G G G C G T A G G G G T G G C G C G T G G G G T T C A A C G T T G C A C T G T C C G C A T G A T C A G G C C A A C A T G A G C C A T G G T T T G G A T C G A T A C T G T T C A A A T G T G G T T C G C A C T C G C G C C A A C G C T A T T A A T C T C C G C T C A G A C T T G G G T T A G G A C C A A A C G A C T C C C A T G G T G C A T A A A T C C T A A C C C A T A C A G A T G C G T C T G A A C G C C C C A G C C G A C G T G A A A G T T C A C C C G T C A C A A A T T G G T T C G T G C C T T A G T G C A A G T G A C G C C C C C C T A G C G A T C A T G G C G A A T A C T C G C G A C A G A C G G A A C A C T G G G G A A G T A G T A G G A T G A G G A C A C A C A T C A A G C T A A G G G C G T C T T A A A G A C G C C A T T C C T A A G C G T T C A A C T G C G C G C T C C C C A C C T G T C G A C A T T A C T G G T G C A G C C C T G A C T C A T C G G T G T C T G G G A C A C A C A A G A C C G T T G C G T C G G A A T C A G G T C G T C C T G G A T A C G G G C G T C C A A C C T C C G C A A G C C G T A T G T C G A C G A C T G C A G G C T A T C C C T T G T A C C C G A G C   C T G T A C A G T G G G T T C C G G A A G T C G A C G C G A G C G A T G C G A C A A T G G T T A A A A A T C T T T G G C G C G A C C G G G C A G T C A G G C T T T A C T G G A T G T T C C G A C G G C C A A C A C T G C A C C T T T T C G G T T A A A A C A G T C G G G G T A T G A T C G G C C T A G A T G G C A C A C T G C G G T C C A G T A C T C A T A T T A C G C T T C A G C G C T C T G A G C G T T G C G C C C A T G A C T C G T C T G C C C A G C C T C T G T C C A T A T C A G A G A A A C G G G G G C C T T T G C A A T G T G G A T T G T A G C G T C C G T T A C G A G C G T C C T G T T G T A G T T C C G T C A A T T G C G A C A C G G C C T G C G C A G C G G G G A A A T G C C A A C G C T A G G C A C G G T A C G T A C C G G T G G A C C G C C G G G G G G T G C G C T T T G C T C T G G A G C C G T A C G G A G A C C C T G T A A G G T C C G T G G A C T G G G C G T T T A T G C G T A C T T G G T T A A C G T C G A T C A C T A C A C C G G A A A G C C C G C C T T T T T G A G A G A G C T A C T C G C T T C C G C G A T A G C C C C C T G G C G G A C T G A A T G A A C C T C C G C C C A C C A G T T T T T C C A T G C C C C A T C A C C G T T G T G C T C T C T G A C C A T A T A A C C C G G G G C A G T T A T A A C G C G T G C T T A C C G G A T G G T A T A C G T C T A G G A G C G T A G G C C G A T A T A G C G C C G T C A C C A A C G G G A C G C T C A G G A G G G G T T C A T C C G C G T G G T G G G A T C G G C G A T C A T T C T A C G T G G C T G C C C G C C G C C C T A C G C G G G A C C C C C T T T C T G A G C T A C T A T A C A C T G G A G C G C T G C T C T G G G A T T T C A T C A G G C A A A T G T G C A C G A C A C C T G A T T A A C T T T A G C C G T G G T G A A G G A C A T T G T C C G C C G A A T A A T C G A T A T C G A C A A C G G A G C C G T C C G A C T G T T G T A C T G A T A G T T G C C G C C T G A G T C T G A T A A G C G G G G G T C G A T T C A G G A T A C C G T A A C T C C A G C T C C C A G T G T C G A G A G G T G A C C C A A T T C A T G G A T G T G G C A A T G C G T T C T A C C C C G C A C G G A C G T C G T C C A C A T T T A G C G G C A C T T A C C A C A A C G G A G G T G A C C C A A A G A T G A C T C C G C A A C T C A T A T A G T G T C C G T G G C C T A G A C C A G T G C A A G A C C A G T C C T C A T G T G T G A G G G C T T G G C C T T C A C C T A G T A A T T C A G C A G G C G A T C G C A T A A C T A C G T A G T C A C C C G T G T G C C T G A T C A G T C A T A T A C T C G C C C C G T G T G G C C A C C C T C A C C T T A C G T T A C C A C C C T C T T T C T C G A G A T G T C C A C C C C G T A G T C A A C C C C A A C A A T G C C A T G A G G A C G T C T G A T C G A C T A G G A C T G G C A C C A T G C T T G G A A G G G T G A A A C T C A T A A A C G T C C T A T C A C A A A T T G T G T A G A G T A A G C T C T T G G T A A A G G C C T A T T T C T G T T C C C T C G A C G T A C T C G T T G A A A G A A C G G T C G G T T T A T G A G A A C G C G C G G T A T C T T C C A C A T A A A C T C G C T A T G A A C A G T A C A C C A A C A T G A A C C C A G G A G G A C C A A A T G A C T G T T G T C G T G A A A A G A C T C A T T G G C A G T G T A T A A C G A T A G G G C A G C C G T C T C T G T C T T G A A G A G T G G G A T C A A G T T T G T G T A T C A A T C C C T T T A C C A G T T T T T C G C A T A A G C C C G G A T G C A C T C T C C G C C A A G A G T C C C G G A T G G G G C G G T C T A G C G G A T C T C T C G T C C T A T T C C T G T T A A G G C C T G A C G A T A A A T A T T A G G A G T G A G A G C T T G A C C A T A T C C C T A G A A G T A G C C C G G C G G A T C G G T G G T G C C C C G G T A C C T A T A A G A G T T G C A A C A A G A C T G G C C C T C A C C T A C A A C G C G A C A G C C T T G G C C C G C T C C T G T G A C C G G T C T C C C T A G C A T G T G G G A C T T A A A A T G G A G G G G G G G A C C A A T G A C G C C G T C G C T T G G A G T A T A G G C A T G A A T G G T C G C T C A C G T G T T G C G C C T G A T C C C C T G A C C T C C A C T G A T C T C C G T T T T G G T G G T G A T C T G G C C T A C T T G T C C G A G T G T A A G G G A A A C G T C T T T G A C T T T A C A G T A G T G C C G T G G C C A C G T G A G C G T T T T A G G A G G A A A T G T A C C C G A G T C G G C A A T C T A G T C G C C T T C C C A T C C T C C A T G A C C A G G G G G T T A G C C G T G C C G T T C G G G C C C A G C C A C G G C G C G T T G C T C C G C A T T C C G C G C T T A G C C T G G C A A C A A G A A G C G G A A G A T C A G T T C A A A G T A C G A T C T A C T A G G G G T C T T C G G A G T T G G T A C G C G G C C C T A C C T T C C G C A G C C C T G T G C G A G A G A A G C C T G T G C G A A C T T T C G G C G C A A C T G T A T G T A T A G G T T C T C T T A A T T A T A G G T C A C T A G T A G G A T T G G G A A G C C A C G C G G C C C C C C G A C G C C C A C T C G C C G A A T C C C A T G T T G C G A C T G A A C G G A G C G C G G A C C A C C G A G T T G C G T T C C T G A G T A G A G C C C C C A G G G T G C C T G G T A A C A C G G C G G C G A G G C T G T A C T T A G T C T C A G C T C C T T G G C T G G G C T C G G C C C G G T G T T A T A A T G T A A G C C T T T T G A A G A A A T A C G T G C C T T T G T A A G A A T A T C T G T A G C G C G A T C C A T A A A T A C G G C G C G G A A A C G C A C C T C T C G G T C C T T T A A C C G C G T G G A A T T C G A G G G C A A T G G A G G A A G G C G G G G A G G A C T T A C G A T A C A A C C G A G T A T C G A A T T C A G T A C T C C C T G T C A C T C G T C G C A T C A G C T A C A C C A C C C T G T C C G G A G A G T C G T A T C G T G A G A C T T T T C G G G G C A G G C C G C A C G G T C T A G T A T T C T A T G C A A G A G G T C C G C G A C C T C C G G G A G T T A C G T G G G C G G G T G C T A C A C G G C C T C C G T G T A G T A A C T C A G T T C C G G A C T A C T G G T G T T A G C A A G A A A G C T A C G G G T A T T G T T T T G C G A C G G T C C G T C A A C C T A A C G A C G A G G G G G G C G A A G T G A C G A C C C C C G T G A T T T C T G A T C A A C C G G T T A C C G C G C G C C A G   G G A A C A T G T T T A T A A G A T A G T C A A G A A G A C A A A A T A C A A G C G T C G G A G A C A C G A A T G G T T G T C C G A G G G G A G A A G T T T G C G T G G C G T C C C G A A G A G A T T T A G C A A G C T T A T G A C C T C A C A T G G G T A C T A A C C A C A G C G T A C C A C T C A C C A C A G G C G G A G C G A C A A T C C A A T G G A G C C A C C T C G G A G T A C G G A A A C C C A C C C G C T G T C G G A G T C C C A G G T A C C A T G C C A G C G G C C T C C T A C A T T C A A G C G T C C C T T A T C C A C T C G C A C G T T A A C A A G T A C C T C G A T C C C T T T T T A G C C G C C C G A T A C A C A A A C C C G C T G A T T T A A G A C T C G G G C A A A G C C G A A C C G C T C A A T C G T T C C G C G C C C C A A C G T G G G C G T T C A C T T A C T C G G A A T T C C G A C T T C A T G G G G T G C G T G G T T A G G C G C A C C T T C C T G C A A G G G T A A A C T T G A A T A T C T C A T T C G C A C A G C T T C T T A T T C G G A C G T C T C C G A G G G G G C C C T G A A C T C T G A T C A C T G C C A G C G C A A A A G G A C T T T G A A A G C G A C C A G A A C C T G G G G A A A C G C T G G C A C C C C G T C T C C C A G C T C T T C T T T A G C T G G G G A T C T A A T A C A G T A A T A C G T T A A C T A A G A T T T A T A C C C T A C A A T A A T G A A C G A C G T C G C C G T G C C A C G C C C T T T A A G C G G G A C C T C T C T C C C C C A C G C T C G C A T G A A C A T C C A C T C T G C G G C G G C A T C G A C A T C T T C T G C G T G T A A G G A G C G C T G C G C G G G A T A G A T G C A A G C T T G T T C C C T T A C G T A C T G A C A G C T C G T C G T C T A G A A C T G G G A A A G T T G C C A A C A T T T T A C T A T A A C A C T G G A C A G C A A C G C A C C C C C A T A A T A A C G T A T A G C C G C C T C A G G G A A A T T G G G G A G A G G G G C G G T T C C G C T C G G C C C C C C T C A C T T A G C G A C T G C G C A C C C T G A T A G G G C A T C C G C C A G C T T A C G G T T T C C T C C T A T T G T T T A C C C T T G C C G A G T T T A A T C G T C T C G C G G G G A T C T A G G A C C G C G G A G C C G A T G C T G T A T T T G C G T A A C C A G C C G A C T A C G G G T A A A C T A C G G T T A T C A C C C G C G C A T G T G A T C T T G T C G G G C C C G T C A C T G T G A G T C C A T G A A T G C G G T C A A T T A C G G T G T G T C T T G G A C C G T G G G C C C T G A G A A G T A G C G G G T G T C T C A C A A C C C A C A G T C C A G A G A G T C T A A A C C C T T A T A T G A G C C T A C T G C C C T C A C A T T A A T G T C G C C C A G C C C G A A A T C C A T G C G T C C G G G A C C T T C G T C C T C C C C A A G G C T A G T G C C C G A G T T T G G A C A C A C A T T C C C G G C C C C T C C G A C T C A A T C T G C A C T G A T C A A A A G G T C C C A A G T T C T G C G C A A T G T G T G C G T C T T C C G C T T C C G G A T A T T C G T C C C C C A G T A C T T T G C G A C C A C G C T A G A C G G A A G A G C C A T A A C A C T C A A A C T T G T C C T A A G A G G G T G C T C G G T G G T T T T G C A A G G A C A T G A A A C C T A C C A T G C C A G T G T T G G T T T T C A G G A A T T A G T C G G T T T T G T C C G A A G C T C G G C C G C A C A C T A G T G C G G T C C G A G C C A T T G G T C G G C C T A T G T G C T C A T C T T T G T C C C G G G T T A C A A A A T C T C A A C G T C A A A C T A T T G A A G A A C G T T A T C A A C T T T G T T G C A T A G C T T G T T A T T C G T T C C C A A T T C G C C G C T T T A G C T T T A A A G T T G T T T A A C T C G T T T A C C C C A T C T T T T G T A G G A T T T G C T T T A T T A G A A G G A A C G C A A C T C G C A C G C G A A G C C G T T G G T T A T T G A T G A G A C T G G G A A T C T C T A A A T G T T G C T G C C G C A C T A G G G G C C G C C A C G C C C C T T C A T G G G G T A A A T A G T C A A T A T T A A G G G T A T C G C C G T A G C T T A A C C A G C G A C C A A A A C G G G A C A T C C A G G T C A A G T A A A T G T C A C A T G A A G A G G C G G T G C C A C T G G A G A T A T A T G C T A A T T A G T A A A G G C T C G T C C A A C T G T A T G G T A T G C T C C A T G C G T T T C T G G T T A C T C G A C C A A G T C G T A T C T T G A A G T G T C A C T T G C G A T A T A A C A C C T T A C T A T C T G T T G C G T G T G G T T A T G C T T A C C T A C T T G C T G T C T C T C T C C T T T A T A C G T C C C T T G A T G G C C C G T A G G C C A A A G T A C A G G T T A A G T A C T C A C G G T A A G A C T A G C A C A T G G G G A C G C A T G C A G A C C T C T T C G G T C T G G A A C A T T C G A G G C C T T G A C T A C C G A C G C T G G T T G A T A C C C A C A T G A T T G T A G A T T T G G A C T C C G C G C C T C A C C G T G T T C T A A T G A A T C A T G G A C C A A T A G A C A G C G G A G A T T C C A G A A A A G T C T A A T G A T A G C T T G T A C A T C A C A G C C C T A A G G A C G C G G C C T C T T C G C G T G T A C A T C G G G T A C A A T C A T A A C T C T C T A C A A A T A T T A G G T C C T T C C T C A G G T T T G A A T G G G A C T G G G C A C G G A C G A C A T C C A G T C T A C G C C T C A G A G A C C G G T T C C G A A C G G C G C C A G A A G G G T A G A A A A T G C G T G G C G G G T G C G G C A G A C T T C C T C A G G T C G C T T T G G C G C C A A G A G C T C G C G A T T T G A T G A G T G A T A T A A T C G C A C T C T G T G T T C C A T G A A A T C A G A T T G T C G T G C A C C T T G T G T T T C C A T A T A G A C T T C T A A C G C T T G T A C A A C C C A G A A G G C G C C T C G C A A C C C G T A A G G T C C C C G C G G T G A G C T C C A C T G G C C T T C A G T C A C C T G A T T G A C C G T C T T A T T C A C T G A A A G A C C A A C C T G C A T T A C A T C C G A G C T A G T T G G A C G C G A C G T C A C T G G C T G C A C T T T C G C A A G C C G C A G T A A T G C A G A G G C C T A G T T T A G A G T C A T C T T T G G G T C A T G C C C C C G G C C A C G A A T C G T C A G C T A G C C G G G T A T G C T C G C A C A G G C T C A C A C T T G A A A C C T A A G G T T T T G C C G G G G C A G T G G A G A T G T G A G C A C A A T A G A G C T G T A C T T T T G T C G A A G G A C C T T T T C T C G T A C G T G C G A G G G G C G C T C C A G C C G G C T G G A G T C G T A G A T A G T C A G C G T G C G G A G A C A C C G C C T T G T G A C G T T A T G A G T G G G A G A C T A A T G C A A G A G A T T C G A G A C T G T A C T A G A T G G C A G T G C T A T T C G C T C C C G A G G A A G G C A A C G T G G G C G C G C T C A A G T T A A A G A T C G T A C C C A A T C C A T T G T T T A G G C G G G G C T G A G T T G G C C T C C C A T T T T C G G C A G T C C G A G A A C A C T C C G A T A G A C C T C C A A A C A C G G T T T T C C A A T T G C A C G G T G G T C A C C C G C C A G C T G G C C C A A C C G G A G G A T C C A A G G T T A C G A C A A A T G A C T T C G A T G C A G C G C C T C C T G T T G T A C G G A T C T T C C T G A C A A G A T G G T T T C A G A C A G C C T C C A G G G C A A G A T G A G C G C A C T A C G C G G A G C A A T G C C G A G A T T C G T T T C A A T C G A T C A A T G G T A G T A C A T C A T C T C G G G T C A G C C G T T A A T G T A C C G G A T G A G A G G G T C G C C C G T T G G C T G G A A G A C G C G G C C G C G C C C T T C A C G T C A G T G T C T C G A A C T C C C G C G T G C C G C A G C A G T T C T T A A C C A G G T A A T G T G A C C T C T C A C G T G T A A T A A G A T A A A G G A A A T G T A T G G C G G G G A G C G G G A T G G T G C G C G A G C C C G T C A C A G T C C A G G A A G T A A A C A C T C C G G C G G G C C C G G A C T C C C A A T G C T G G C C T C C G C C A C A C G G C G C A T A C C C G A A A G T G A A A G T T G C A A G G C A C G G A C C T T A G T A C C G C G T C G A G A C T C A A G T C C C A G A T G C G C G T C A C G T T T A C C T A C C A C A A T C G G G A G A A C T C C T C G C T G A C T A C T T G T T C C C A T T A T A T A C A T C T T T C T G G G G C A G A T T G C G A T G G A T T T T C C C C G C C A G G C C C C A C G C C T G A C G G G G C T T T G G C G A G T A A C C T T G T G G A G A G C T T T C C A T A G C A G G T G G A A A G G G A G G T T A A A G T G C C T G T T T T T A A C A C C T G C C T A A G C A T G T T G T A A T C C T A G A G G T T T A G T G G A A A C T C G T G C G G A C G C A G A C T G G A G A C T A A G A A A G A T A G T C A C G C G C C G A T G A T G A G A G G T C C C A C A G C A G T G T G A G T C C T A G A C C G A C A G A T C G A A C C T G G T A C T T T C C C A G A G T T T T G T T G C A G T G G T T G T A A T A T T T G G T G A C A G A G G A G G C T G T A T G G C T A G C G G A G A C C A C C C C T G G T C T C C T A G A C T G G C A G C C G G T G C C A T T C C G T T G G C G G C G T A G T G G T G G C G T G C A C A C G G T T G G C T T C C G A C C G C T T C T G C A G C G T G G A A G A C T C C C C G T T T G C G C T G G G G A G A G T G T G C G T G T C A A G G G A T G G A A C C A G A A T G T G G A G A A C T T G A A G A A G C T T T G T G A G C T T T T C G G C C G A A C A A C T G T C G C T G G G A A A C G A G C G T T T G A C G C A T T C G T T T A G C G C C G G A A G G C T T G A C G A T G C C G T C A A G C C C A G T T T G C C G C T C A C G A A T A C G G T C C A C A T A G C C T C C C A C C T C A T A C A G C C C C C G A C A T G G G G T G T T   A C C A C G C C T C T A G T G C A A A C T T G A C T A T G C G G G G T G C C C T G A T T A G G T T C A G A G A C T T C T A C T A A C G C A T G C A A C T A C A G G T A C G G G A T C T T T T T C T A T T C A T C A C T G T T G G A A A T A G A T A T G G C C C C A T C A T A C G C A C A C G C C C A G T A A C C C C C T T C C A   G G C A T A G T G G C A C T G G G C G C A A T G T A C A G T A T T C C T G C A T C G T A T C C T T C C T G T A A G T A A G G C T G C C C G G G C T A T T G G G A A G A A C T C C G T T
A T G A A A T T T T A T G A C C G G G T   G C A T T C C G A T A A A G T G C C T G G A T T A G T A C T A G T C G T A T A G C A C C T C T G C T C T T A A T G G G A C G A G G C G C C C C G T C T C C C T A A C A G G G T G C C A T T T A T T T T T A C A C C G T G A A G C A A C G A C C T C C G A T A C G G T G C T T T A G A C C A G A G C T A C A T A C A T C G A C A T T A G C C A C G T C A T T A A A G T A T G T T G T G C C T T A G A A G G C A A G T G A C A A T C T G T A T T C C A G A G C T T T G C A A A A T G T C G T T T T C T A G G C C A T G G T G T G C G A G C C C G A C A C T C C C C T G G C A C G C C T C A T T A G G T A G G G T C T A C A G G G T G C A A T G A G A G C T C A C G C A C C A G G G C T T A A A G C A A C G G C G C G T A G C G A C T A C A C A A C T G T A G C G C C A T A G T C C G A G T C G C C A G A C G G C A T T C C A A G C T G C G A G G C C C C A G C T C C C T A C G G G G C C G C C T T A T T T A A C A G A T C G C A A C T G G G T T T C G G T T G C T C A A G G G G C A G T T A C T C T A T T A A C C G T T G C A A A A C A A T T C G A T G C C C A T T G A C C A G A A A G A C C C G G C T A C A A T G C C T C T C C C T G A C T C G G G C A T G C C A T G G C T C G T A C G C A C G G T G C G C G G C T T T T T T A G C G C G T T A C T C A A G C G C G A A C A C C G T C T G T C T C A A G T C G T G C C T T T G G G C G A C T G G G T C T G G G G G G A G G T G A T G T C G G C A T A A T T T A G C C A G C T A C G C G T C A T C C C G G G C T A C C G G A C G C C T C C A C G A T T C C A T G A G A A G A G A C A A T C T A C G T T T A G G G A G C T G T G G C A T G T C A A G C A G C A C T C T A T A G A C T A A A T G C G G C G G T C T C A G C C G T G G G G C T C G A T C G T T G G C A C C G C G G T T G C A G A A G T C C C T T C G A G T C G T C C T C T G T C A G T T A G T A C T T C G A C A T C A C C G T A G G T A G A T C C T C T C C C G C C T G T G C A G T C C C G C C G G T G T G G A C G C C T C T A A A C A T C C C T C G G G A A C C A G A G G T A C T G A C A T C G C G G T T T C C T C G A A C G C A A T C G C C G C A G T T T G A T G G C C C A G G C C A G C A C T C G C T G C T C G G C C C C T G A C C C A T T C A T T G C A G G C C A C G T A G A G C G G G G C A T C T G G C G A G G A T A A C C G T G A G G A T T C A T G A C C A A T T G G T C T G G G T G C A C A G T C C G T T C G T A G T G A C G C T C T C T G G G G A T A T A T A A C G G G C G G A C G T G T G C G C T G T T T G G T G A G A A G T A G G T C T C C T C A C C A C G T G G C C T C A T T T G C G C G C C C A G G G A T A C T A T C A T C G C G G G T C G T G G C C C A G T G A A G G T C C G A G G A T G C C C C C C G A G G A G T C A A C C T G T G C G G G G A A G A C C G T C A G A T G C C C A C G A A A C G A C C C A G G C T A T C C G A A C A A T G T G A G G C G G A T C G A T A C C G C C G C A C G G A G G A A G T G T T C C A A C G C C T C T C G T A C C G G T G T G A T T A G C C G T T G G T G G A T C A A G C A G C C C G C G A C T T A G G A A A G G A C A G T A C T G A G C C G A G A G C T A G A G A C A C A A G G G C A T G A T C C T T T G T C A C T G G G A G T C T G A T G G A A T G C A C A C C C G C G G G A A G G A C A C G G C A A T G C C C G C C A T A C A A C T T C T G G A C C C A T C C C A G A T C C G G T G A G A A T G C C T C G G G G C A C C A A T C G C G C A C C T G A A A T A C C T C C A T C A A G C A A A A T G A T A G T G A A A G G A A C C C A A G T G G C A G C C T C G T A G A C C T A A T G C T G G A A C T G A A A G A G C C A C T A G C T A T A C T T G C A C G C A T G T G C A A T C G C G A G C A T C T G G G T C G A C G C C T T T G C A G A A A C T T T G C T C A C T C G G A G T C G A A T C G C G T A T G G G T C A C G G G G C G T A G C G G T G C A A A A C T C C C A A T T A C C G T G T C G G C C G T A T A G G C G G A A T C A C G G A T T G A G C T T G T G G G G T G T G G T C C A C G G T A T C A T T C T A T C C A A C A G G A A C C A G A C T T T T A A A T C A G G C T T C G A G T G G G G T C T C A A G T C A T A A G C G C T G G A C G T G C T T C G A T G A A T G T G C G T T T C A G C G G C C C A A T T C T T C C C G C A T C G G C A A T T T T A A C C G G T A G C T T G C C C G A A A C A C C A T T T A T G T T T C A G A T C T T C C T A T C C T T T A C T A C G T T G A T A G G G C C T C C A G A T G A C A A A T G G C T T C C A T A A T T G T A A G T T A C C T C C A C A A C A T A T A G T G C A G A C G G C A C A G C C A C A A G C C G G C G C A T A T C C C C T A C C T C T T T C C T A A T C T G G C C A C C G T A A C T A T T T C C A C C A A G G C C G G C C C A T A A A G C G A A A C G C G T T A G C T G A G T G C A G T G T A A T G G T T T C T G G C T C G A T C G T A T G T C T G C T G G A G T C A T G C T A A T T C G T T T T G A G G G A C C A A C T C T C C G T A A A G T C T G G T A A G T T C C A G T C G C C A A T C G C C C C C G G C C A T A A C A G G A G A C G C C T T T C G T A G C A G A C G A A G G G C G T A G C A G A G A T T T G G G C C G T C A C A T G A C T T C G A T G G G C G A A G G T A C T G T C T T C T C T A C T G T G T T A C C T G G C T G A G A A T T A A T T T A T C T C T T A G C G C C A G G G T A A G T T C C G T C G A G A T G G A A T A C A T C G C C G G A G G C G G A T T A G T G G G T T G T G C T G T A C C C A A G T G C A A A C T G G A G A T G C A A T G C T C T C T A C A T C C T C T C G T A A T C A A C A G C C G G A C T T G A C C G C C C T G C T A G A C T G G C C G G A G C T G T A T T A C C C G G A C T A C C T C C C G G C A A A G C C T C A G A G A G A T C C T A T G C T A T G A C C G C A G G G C A G C A T C C T T C G C C G G A C C G A C T G G A T C G C C T A G C A G T A G G T C T G A A A T A C G A A C C T A A T G A G A T C C A G A C G G C A C G T C A G A G A G C C G A C A G G G A C G T T G A T G C A G A T G T A A C C A T A G T G T C C C G T A C A G C C C C C A G A G A T T A T A C A G G G C C C C T A C G G A C A G C G A A A G T C G C C A A A A T C C T A T C A C C C G C G G T G G A T G C A A A T A T T C C C G G C G C A G G A T A A G C A A A T T C C A G T A C C G G A A T G T G C T C A C G T T A G A A T A G G T G A A C T C T A G A A T T T A C G T C G G C C T T A A T A G A C G T C T G G A C G T A A A A T G C C T G C T A G G C C A A G C T T A C A T C C A G T C G T T G C T C A G A C T C G T A C G C A T G G G T G G A G C G T T T G A T G C C T C T G A T A G T T G T G T C T A A T C T G A G G A A T T T G C C C T G C G G G C A C T A A G A C G G A T G G A C A T C G C G T T A T C A G T A A T A C A T T A G G C T G A T T T T A G G C A T G C G C A G C C G T A C T A A A A G T A A A C T C T G G T G T C G T A G A T A T C C C G T C A G T T T T G A C G T G C G A A A A T C C G T C T T C G A A A C G A G T T G C C C G A C G T C C C C T A T A A T A C A A A G C C A T A G C G G C A A A G C T C A T C C C C A G T G A C G G A T A G G G G T G C T C C A G A G C A C G A G T T T G A A G A C C C A A G T T C C T G C A G G G A A A C A T T G T G G G G T C A C C G G T A C C C G A C C C C T C G C G A G G C T T A T T C T T G A G T A T G T A T G T G C C G C T C T C G A C G T C G A T A A T A T C A A G T A G C T A T G C C A G T G T T T G T G G A C T A G A A T C G C T A A C C G G T A T G T A G C G A C G A G G C C A T G T G G C G T A G A T C G C A A T C C C C C G C T A G T G G T G A A T G G C G C T A A T C C C T T T A A G T C G T G T A T C G G A A C T T G G T T G C C G C A G G G G T T C A A G G G T C C C G A A C A T A A A C G C A G C A T T T A C T C A C C G G C G T A C G C T C C G A C A G T A A A G G C C A T C G C C G A G A G G C G C C C G G A G G A T C T C A A A C G A T T A C T A G T A G A T A G G C C C T G C G G G T T A T A G C G C T G T A A G C T T T T G T C T T C A C C C C G C C A C C T T C T G G T C A G C A T T C A T T T T A C T G C G T C G T A T C C T G A A C A T C G G C A A T T A A A C G G A A A T A T T C A A A C C A A T A G T T A C C T A G A T T C C A G G A T C G A G C G A G T G T T G A C C T G G G G A A C T A G C A A G G G T C C T T T T T G A A T T T C C A C C G T C T A G C C A C G T G G A G G G T G A A C C A G C T A C T T C A C G C T A T A T C G T C G T C A G A C C T A A C G T A A C A T C G G G C T T A G A T G C G G C T G C T A T T A G A G C G G T G C A A A T A T C G A A A T A G T C G C G C C C C C A A C A C T C A A G T C C C T T T G G A A G C G A C A A T T G G G T A G G G T A A C A C G G T T T T A G G G C T G C G A C A A T T G G T G C T A C C T A G C G G G G A T C G T G T C A C C A T A A C G T C G G T C T T C G T C T A C T C T G C A C A A A T A T G C G T A G A T T G G C A A G T T G A C A A T A T C G A G T T C C T A C G C G G A G C T G T G G T G C C G C A T A C T C G A C T C T A G T A T C A A G T T T G A A T G G C C C A A G G A G G G C G T G G C A C G C G C C G C G A G A C T T A A G A G C G G C A G C G A A G A G G C G C A C G G G T T A A A C A T T G C G A A A G T G C C A C T T C A A T C A A C T T A C G T A T C A T C G T C T A C C A C C G G T C C C C C C C G A C T G T G T C A C C C T T T A A A A A C C T T T T T T A T T T A C C C T C C T C G C G T C G G C G C G G G G A G G T T T T C C T G T G T C G T A C G A G C A A C C G A G T G T A G T G T C G G C C G C G A C C C G C T G G A A C T G C T C T G G G C G A C T G C C T C C C C G T T C A A G C C G G C A C T G T G G T T T T T A G C C C T A A T C G T C G T T G T G G C G C G T G G G G T T C A A C G T T A A G C T G T A C A C A T A C T C A G T T C A C A G C G A A T C G T G G T C C A G A G T G G C A C G A G C C A A A G A G A A C T C G C A C T C G C G C C A A C G C T A T T A A T C T C C G C T T C T C T T G T T G T T A G G A C C A A A C G A C T C C C A T G G T G C A T A A A T C C T A A C A C C T A T G G G G G C G T C T G A A C G A T T C A A T T A C T G C A G G A G T T C A C C C G T C A C A C G G G G G G C T A G A C C T T A G T T C A A G G A C T G A C C C T C G C G T A A T C G T G G T A A G T G T T T A T A A C C G A C G G A C T A C T G G G G G G T T A G T A G A C C T A T T C T C C A C A C C A A G C C A A G G G C G T C T C G A A T A T G T A G T C A C G G A G C G T T C A A C T G C G C G C C A T T T A C C C A C C G A C A T T A C T T A T A C C T C T A T A G T C T C C C G G T G T C T G G G A C A C A C C G A C T C G T T T A A T C G G G G G T C G G T C G T C C T G G G T G C A G A T G T A C A A A C T C C G C A A G C C G T A T G T C G A C G A C T G C A G G C T A T C C C T T G T A C C C G A G C   C T G T A C A G T G G G T T C C G G A A G C T A G T T C G C T T A A T G A T C C C G C G G T T A A A A C T C T T C G G C G C G A C C A G G T G G G C G G G C C C C G A T G G A T G T T C C G A C G G A T C C A G T C T A C T T T T G T C A T C T G C G C C A T C C T G A G T A T G A T C G G C C T A G A T G G C A C A C T G C G G T C C A G T A C T C A T A T T A C G C T T C A G C G C T C T G A G C G T T G C G C C C A T G A C T C G T C T G C C C A G C C T C T G T C C A T A T T G A C T A G A C G G G T A A C C C C G C A G C G C A A A C C G T A A T A C A T A T T A C G A G C G T C A T G C C T T G G C G C C G T C A A C C G T G A C A C G G C C T G T T A C A A A G G G C C G C T T A C C T G C T A G A A G T T G T A C G C G T T G G C G G A C C G C C G G G G G G T A C G C G G C A C T C T T G A G C C T G G T T G A T A C C C T G T A A G G T C C G T G G A C C A A G C G T T T A T G C G T A C T T A G T T A A T G T C G A T C G A C A T G T T A A C A A G C C C G T A C G C G G G A G C G A G C G A C T C G C T T C C G C G A T A G C C C C C T G G C G T G A C T A A C G G A C T G C C A T C C C C C A G T C T C G T C G C T C C C C A T C A C C G T G T T G C T C C C T G A C C A T A T A A T C C G G G G C A G T T A T A A C G C G T G C T T A C C A A C T G A G G G C T G C A C A G A G A T T G G T A T C G A T A C A A C G C T A C T G A C G G C G G T A C G C T C A G G A G G A T T T C A T A C G C G G A C G G G A A G A G T A A C G C G C T C T A C G C G G C T G C C C G C C G C C C T A C G C G G G C T T C C C C G T A C T G A T C C C T A T A C A C T G G A G C G C T G C T C T T G G A T T T C A T C A G G C A A A T G T G C A C G A C A C C T G A T T A A C T T T A G C C G T G G T G A A G G A C A T T G T C C G C C G A A T A A T C G A T A T C G A C A A C G G A G C C G T C C G A C T G T T G T A C T G A T A G T T G C C G C C T G A G T C T G A T A A G C G G G G G T C G A T T C A G G A C A C C G T A A C T C C A G C T C C C A G T G T C G A G A G G T G A C C C A A T T C A T G G A T G T G G C A A T G C G T T C T C T T T T T T G T A G G T G T C G T C C A C A T T T A G C G G C A C T T A C C A C A A C G G A G G T G C A C A C C C G A T G C T T C C G C G G T C T G C C G G T G G C T A T C A A T C T A G A C C A G G T C G G G G C C G A G T A T C A T G C A C A G G G A T G T G G C C T C T C T T C C A T A A G T C G G C A G G A A A T C A T A C G C T G G A T G A G T C A T A C G T A G T A T C T C G T C G T C A T C G G C T C G C C C C G G G C G G C C A C C T C A A C T C C G T A C C C T T G C A A G T C T T A T C A A A C C A C T T G T T T T A C G T G T G A T T C C G C T G G G G C C A T G A G G A C G T C T G A T C A C C T C G G A A T G A C G C C G G A A G G T T G A G G G T A G G G T T C G T C A A C G T C A T A T C C T G G G C T G T T T A G A G T A A G C T C T T G G T A A A G G C C T C T T T A C A C T C C C T T G A C T C A C T C G T T G A G C T C G T T A C C A A C C T A T T G G G A C G C A C G G G G T T C C T C A T A T A A A C T C G T T A T G A A C A G T A C A C C A A C A T G A A C A T A G A A G G A C T G G C T A C T T T T T G T A A G A A A A A G G C C T A G G A G C A T C G T A T A A C A A T G A T A C G A T T G T C T C T G G T T T T G A A C A T G T G G T T G G T C G G A T A T A C T G A T C C C T T T C C T G T G C T C C C G C G C G G A C C T G G C T G C A C T C C C C A A C A A G A G T C C C G G A T G G A T T T G T C T G T C A A C C A G C G C G T C C T A T T C C T G T T A A G G C C T G A C G G T A A G G G T C C G G G A G T A G A G C T T G A C C A T A T C C C T A G A A A C C G C T G G A T T A A G T G G T A A T A T C A T A G C G C C C G G A C G G T T T G C A A C A G G G T T G G C C C T A A C C T A C A A C G C G A C A G C C T G G A T C C G C T C C G T T G A C C G G T C T C C C T A G C A T G T G G G A C T T A A A A T G G A G G G A T A T C T T G G G T C A T C A G C A A T G C T A G T C C G G T A C A C G A A T G T T C G C T C A C G C T T C G T G C A T G A T C C C C C G G T C G A T A C T G A G A T C C A G T T G G A T A G T A A G A T A G C A T G C C G T G C C G A G G G T A A G G G A G C A T G T G C C A C T C C G A A A A T A G T G C T A C A G T T A C T T G A G C G T T C C A A T G T A C A G G A C G C C C G A G T C G G C A A T C T A G T C G T T C G A T A C C T T T C T C T G A C C A A A T A A C G C A T C G T G C C G T T T G G G C C C A G T A A A G G A A T T T C G C T C A G C A T T C C G C G C C C G T T A G A A T A A C C G G A A G C G G A A G A T C A G T T C A A A G T A C G A T C T A C T A G G G G T C T T C G G A G T T G G T A C G C G G C C C T A T A C C C C G C A T T A T T G T G C A A T G T C A G C C T G T G C G A A A T T T A A G C G T G A C T G T A T A T C G G G A C T C T C G C A A T T A T A G G T C A C T A A G A G G A T T G A T A G G C A A C G C G G C C C C C C G A C G T T T A C C T G A T G A A C T C C A C G G C T T G G C C G A A T G T A G C T C G A G T T C C C G A T G G A C A G C C C T G A G C G G A G C A C C A A G G G T G C A C A G C G C T G T T A A T A C A G A A T C A G G T G T A G T T G C G T A G T T C T G G C T G G T T C A G G C C C G G C A C C G C G G C A C C A T C C T T T T G G G T G A C G A C T C T T T C G C A G G C A G G T A T C T G T G A C G T G A G C A G C C A G C A C T A T A A A A C A G C A T C T A T C T C G G C C T C G C G G C T T A G C A G G C G C T A G T A G C C G C G G C A A C A G G T G G A A C T A A T C C C T G A T A C A A C C G A G T A T C G A A T T C A G T A C C T C C T G T C A C T C G T C G C A T C A G C C G A G T C C C C C C G C T T A T G G A G T C G T A T C G T G A G A C T T C G C G A T A C C T T A T A A A C G G T C T A G T A T T C T A T G C A A G A G G T C C G C G A C C C C T G A A A G T T A C G C A G G C A A A G G C T C C A C G G C C T C C G T G T A G T A A C T C A G T T C C G G A C T A C T G G T G C C G G C A A G A A A G C T A C G G G T A T T G T T T T A C G C C G A C A A G T C A C C C T A C C A G C A C G G A T T G C G A A G T G A C G G C C C C C G T A G C C G C T G G G A C A C T A T T T G T G A C G C G C C A G   G G A A C A T G T T T A T A A G A T A G T C A A G A A G A C A A A A T A C A A G C G T C G G A G A C A C G A A T G G T T G T C C G A G G G G A G A A G T T T G C G T G G C G T C C C G A A G A G A T T T A G C A A G C T T A T G A C C T C A C A T G G G T A C T A A C C A C A G C G T A C C A C T C A C C A C A G G C G G A G C G A C A A T C C A A T G G A G C C A C C T C G G A G T A C G G A A A C C C A C C C G C T G T C G G A G T C C C A G G T A C C A T G C C A G C G G C C T C C T A C A T T C A A G C G T C C C T T A T C C A C T C G C A C G T T A A C A A G T A C C T C G C T T A C C C G T G G A T T G T T T G A T A C A C A G C T C T G T T G A C T G A A G A C C T G G A C G G C G A C A A G C A G T C C A C T C G C T C C G A A C C C C G G C A C G T G T A C T C C T T T A T C C A G G A T T C C G A C T T A C T G G G G T G C G C A G C G G A A T G C A C C C C A C T G C C G G G A G C A G C T C A G G T G C T C A A T T C G A G C G A A T C C T T A T T C T G A C T G T G C A T A G T A G G C C C T G A C C G T G A C T C G C G G A C G A C G A A A A A G T G C G C G G C C G G T G C C A C G A A C C T G G A A G G G C T T T G G C G T T C A T C T C T A A C T A T T T T C T T T A G C T G G G G A T C T G A T A T A G T A C T G C A T G G G C G G G G C T T C G T A C C T C C T G A T A A T G A G T G A C T G C G C C A C T A T C T A A T T G T T C A G C G A G T A T C T G A C T A C C C A C A A T C A C A C A A A G A T C T C A G C G A C T A C T G C A C C A C T G C T C T C T G T G T G T C A G A A G A G C T T T G C G G G A T A G A T G C A A G C T C A C C A C T T G C C G C G T C T G C A A T C T G G C G C C T G T A A A T G A G G C A A C T T A C A C C G C C T T A T G C C G G A G C C T G A C A G T A G C G C A C C C C C A T A A T A A C G T A T A G C C G C C T C A G G G A A A G G T G G G C G G G A G G C G G G G T C G C T C G G C C C C C C T C A C T T A A C T G T T G C A C A C C C T A A G C T T T T A T C C G C C A G C T T A C G A C G T C C T C C T A T T G T T T A A A C C C G C T A G T C C T A A T T A G T C C G T A A A A G G C T A G A C A C G C A A G G C C G A T G C T G T A T T T G C G T A A C C A G C C G A C T A C T G G T A A A C T A C G G T T A T C A C C T A T A A C G A C A G C T T C G T C G A A T C A G T C A C T G T G C T C C C A T G A A T G C G G T C A A C C C C G G C G T G T C T C G T A C C G T A A G C C C T G A G A A G T A G C G G G T G T C T C A C A A C C C A C A G T C C A G A G A G T C T A A A C C C T T A T A T G A G C C T A C T G C C C T C A C A T G G G T G T C G C C C A G C C A T G G G C A A G C A T G C C T A A G C C T G C A A G A A C A T A T C G A A C C G G T G C C C G A G T T T G G A C A C A C A T T C C C G G C C C C T C C G A C T C A A T C T G C A C T G A T C A A A A G G T C C C A A G T T A C G A G A A A T G C T C G A G G C G C C C T A C C T T G G A T A T T C G T C C C C C A G T A C T T T G C G A C C A C G C T A G A C G A A A G A A T C A T A A C A C T C A A T A C G G T C A C G G T G A A T G A C C T A A C T A C C G G A T G G T G C A A T G A A C C C T A C C A T G C C A G T G T C G A G G T C A A G G A A T T A G T C G G T T T T G T C C T G C A T G C A T T C G T C C A C T A G T G C G G T C C G A G C C A T T G G T C G G C C T A T G T G C T C A T C T T T G T C C C G G A C T C C A C G G C T T A G G T G G T G G G C T A T T G A A G A A C G T T A T C A A C T T T G C T G C A T A A T C C T G T A T T T G G T C A A G A T T T G C C G C T T C G T C G G T C C C G C C G T T T G A C T T G T T T A C C T T A C T T T T T G T A G G A T T T G C T T T A T T A G A A G G A A C G C A A C T C G C A C G C G A A G C C G T T G G T T A T T G A T G A G A C T G G G A A T C T C T A A A T G T T G C T G C C G C A C T A G G G G C C G C C A C G C C C C T T C A T G G G G T A A A T A G T C A A T A T T A A G G G T A T C G C C G T A G C T T A A C C A G C G A C C A A A A C G G G A C A T C C A G G T C A A G T A A A T G T C A C A T G A A G A G G C G G T G C C A C T G G A G A T A T A T G C T A A T T A G T A A A G G C T C G T C C A A C T G T A T G G T A T G C T C C A T G C G T T T C T G G T T A C T C G A C C A A G T C G T A T C T T G A A G T G T C A T C T G T A A C A C C G C G C C C G A T C G C T C T T T G C A T G T G G T T A T G C T T A C C T A C T T G C T G T C T C T C T C C T T T A T A C G T C C C T T G A T G G C C A T T G G T T T A A G T C A C A G G T T A A G T G C T C A C G A C C G A G T C G A A G T C C G G G G A A G C G T G C A A A C C T C T G C G A T C C G G A G T C C T T G G A T T T G G A C T C G C T T G T A A C A G G G G A T A C C C A C A T G A C T G T A G A T T T G G A C T C C G C G C C T C A C C G T G T T C C C C G G A A T C A T G A A A T G G T G G C C A G C G G A G A C C C T G A G A A A A G A C G G T G A T A G C C G G T A T A C T C C A G C C C T A C G G A C G C A T C C T T T G C G C G T G T A C A C C G G G G A T A A C A G C G C C T C T C G G T C A A T A T T A A A T C C C T C C C C A G G T T T G A A T G G G G C T A G G C G T A A G A G A C A T C C A G T C T A A G C T C A G A A G G C C A G T T C C G G G C G G C G C C A G A A G G A T C T G A A A T G C G C T A C G G G T G C G G C A G A C T T C C T C G G G C A T A T T T G A T A C C A A G A G C C C A C T G C C C G G C T C T C A G C G G C G T C G C A C T C C T C A G T C C A T G G G C G T C A A T G A G T T C A A G T C T T G T G T T T A C C G G C G A A C T T C T A A C G C T T G T A C A A C C C A G A C T T T G T A C C G C A A C A C G G C G A A C T T C C A T G G C G C G C C A C A C T A G C C T T A G A C C G C A C G C G T G G C T A G C T T C C C A G T C G G G G A C T C A A A C T G C A T T C C A T C C G A G C T A G T T G G A C G C G G C G T C A C T T G T C G T A A T G G A G T G G A T T G C A G T A A C G C C A G G G C T C C A C C C G A A A G A G C T C G G T A T T C A G T T C C C A T A A T C T G G G G A A G A C G C C A A T A A A A G G G T T C A A A A C A G G C T C A C A C T T G A A A C C T G C T A G T T T G C C G G G G C A G C T A G T A T G T G A G C A C A A T A A G G C T G C C T C C C G A C T T C A G T A A C T T T T C T T T T A C G C G C G A G G T G T A T C C T C T A A G G C C A G A G T C G C G A G G G G T C A G C G T G C G G C T C C C A T G C T C C A G G G C G T C C C T C A T A T G G A C T T A A T G C A C A C A G G C T T A G A C T G T A T G A G G C G G C G G C G C T A T T C A A T T T C G A G G A A G A C A A C A G T T G C G C A T C T G G T C G A G A G G T C G T A C C T C G T C T A C G G C C C A T T C A G A A C T G A G T G G G T C C C T A G G G C G C G G C A G G C T T A T G G A G T G T C G A T A G A C C T C C A G G C A C G A T T C T T C G G C C A T C C G G G G T C C C C C T G C A C A C G T G C C C A A C A A A C T A A T C C G C A A C C C T G G A G G A T T G T C T C G G G T C A A C G T C G T C T G T T G T A C G A G G C T T A A C T A T G G A G C A A C G G C A A A C G G C A C A C G A T G C A A G A T G A G C G C A C T G T T C G G A A T G A T G C T G A G A T T C G T T T C A G T C G A T C A A T G G T A G T G T G T C A T A C C A A A T C A T C A A C G C G T T T G A T A T A C A A G A G A A T A A T C C G T C A T C T G T C A G A C G C G G C C G C G C C C C G A A C G T C A G T G T C T C G A A C T C C C G C G T T C C G C A G C A G T T C T T A A C C A G G T A A T G T G A C C T C T C A C G T G T A A T A A G A T C G A G T C G G T A C G G T G C G G T G A G C G A A A T G A T A C G A G G T C C C G T C A C A G T C C A G T G A T G G G G T A A G C C G G C G G G A C C G T G T G A A T G G C T A G A G C T T C T G C C G C A C G G A G C A T A C C T G A A A G C G G G A G T G G C A A G G C A C G G A C C T T A T C A C T G C G T C A C A C C T C A A A T C C T G G G G G C T T T C C G T A C G C C C A C C T C A C A A T C G G G A G A A C T C C G T T T C T G T C C A C C A C C T A A G C C C G G T A A G G C T T T A T G A A G C A G G T G G C A G C T G C C T T G A T T T T T A G T A A A T T G T G A T C G C C G T G G C G C C T G T T G T C C G T T T T G T A A G G A T C T G T C C G C C A A G G T T G G A A A A G T G A G G C A G C A C G C T C G G T T C C A G C A T T C G T C C G A G C A T G T T G C G C C A T T G A G A G C T T A G T G A G G G C T T T G T C G G A C G C A G A C T G G A G A C T A A G A A C T G C C T T A G A G T A T T A G G T A T G G A A G G T C C C A C A G C A G T G T G A G T C C T A G A C C G A C A G A T C G A A C C T G G T A C T T T C C C A G A G T T T T G T T G C G A C A T T C A G A A T A T T T A A C G C T G A G G G A G G C T G T A T G G C T A G C A T A G G T T C T T C C T G A T C T C C C G G A A T G G C A G C C G G T G C C A T T C C G T T G G C G G C G T A G T G G T G G C G T G C A C A C G G T T G G C T T C C G C A A G A G G A C G C A G C G T G G G G A A C C C C A A G C C C T C G C T G G G G A G A G T G T A C A T A C C A A G T G A C A T G A C C A G A A T G T G G A G G G T G G G A A G A G G T T T T A T G C G C C T T T C G T T T T G G T A A C T G T C G C T G G G A A A C G A G C G T T T G A C G C A T T T A C G G G G C G C C A T C C T T T C C A C T T C C A A T A T A C A G C C C A G T T T G C C G C T C A C G C A T A C A A G T C A C A T A G C C G C C C A C C T C A T A C A G C C C C T A G A A G A T G A C G T T   A C T A C G C C T C T A T G A T C C G C C T G A C G C C A C G G A G T G C C C T G A T T A A A G T C A G G G G T T G C T A A T A A C G C A T G C A A C T A C A G A C C C G G G A T C T T T C T C T A T T C G T C A C T G T C T G A A A C G G G G A T G G C C C C A T T A T G A A C A T G A A C A A A T T A A C T A A A C C C C C   T G T G G G G G A G A A T C T T A A A T G G T G T A C G G G C G T T T C T T A T C G T A T C C T G T T G A G G A G T A G G G T C A C A C A G G C T A T T A A G A A G G A A T C C G T T
...

*/

bool  SNPSelTools::readfastPHASE(const string& path,const string& filename0,const string& filename1,vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, int& pref, const bool& firsthaplo)
{
try{

    /// OPEN 1st FILE

    //int tries=0;

	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable length column in different pops
	// and as much as rows as numpops x sample size

    if(!openfile(path, filename0,datafile, false))
	{
		string msg = "\nERROR: can not find input file " +filename0+"\n";
		cout<<msg<<endl;
		return false;

	}

    //const int ploidy=2;
    string temp="";

// read until BEGIN GENOTYPES
    while((temp.find("BEGIN GENOTYPES")==std::string::npos) && !datafile.eof() ){
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    int countID1=0;
    //int numsamples=0;
    int totsamples=0;
    vector<string> sequences1; //
    vector<string> sequences2; //

    vector<double>positions;

// Read lines with the information: rsid position A A A ..A (composition of this rsid in the sample)
    do{
        getline(datafile, temp);
//        trim_left(temp);
        if(temp.find("END GENOTYPES")!=std::string::npos){ // end the reading
            break;
        }
        if(temp.find("#")!=std::string::npos){ // individual id
            ++countID1;
        }
        else
        if(!temp.empty()){ // the sequences

        // erase spaces between nucleotides
            temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end());
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
            // each individual has two haplotypes: this is the first
            sequences1.push_back(temp);

            //get the second haplotype
            getline(datafile, temp);

        // erase spaces between nucleotides
            temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end());
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
            // second haplotype
            sequences2.push_back(temp);

        }

//cout<<temp<<endl;

    }while(!datafile.eof() );

    if(sequences1[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

    datafile.close();
    int  numpopulations{2},countID2{0};
    samplesizes.resize(numpopulations);

    samplesizes[0]= countID1;
    totsamples=countID1;

/// OPEN 2nd FILE
    /// we still need to read another file for the second population


    if(!openfile(path, filename1,datafile, false))
    {

        string msg = "\nERROR: can not find input file " +filename1+"\n";
		cout<<msg<<endl;
		return false;

    }


// read until BEGIN GENOTYPES
    while((temp.find("BEGIN GENOTYPES")==std::string::npos) && !datafile.eof() ){
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

/// READ the second file

    do{
        getline(datafile, temp);
//        trim_left(temp);
        if(temp.find("END GENOTYPES")!=std::string::npos){ // end the reading
            break;
        }
        if(temp.find("#")!=std::string::npos){ // individual id
            ++countID2;
//cout<<temp<<"\t"<<countID2<<endl;
        }
        else
        if(!temp.empty()){ // the sequences

        // erase spaces between nucleotides
            temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end());
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);

            sequences1.push_back(temp);

            getline(datafile, temp);

        // erase spaces between nucleotides
            temp.erase(std::remove(temp.begin(), temp.end(), ' '), temp.end());
        // uppercase
            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);

            sequences2.push_back(temp);

        }
//cout<<temp<<endl;
    }while(!datafile.eof() );


    datafile.close();

    samplesizes[1]= countID2;
    totsamples+= countID2;

    if(sequences1[countID1].size()> (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename1+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

assert(sequences1.size()==sequences2.size());

    // pref will be the population with largest sample
    if(samplesizes[0]!=samplesizes[1]) // choose as ref that having the highest sample size
        pref = distance(samplesizes.begin(),max_element(samplesizes.begin(),samplesizes.end()));

//cout<<samplesizes[0]<<"\t"<<samplesizes[1]<<endl; exit(1);

// redimension the snpfreqs and snpositions vector and set position
    snpfreqs.resize(numpopulations);
    snpositions.resize(numpopulations);

    int indexsampl{0};
    int haplolengthPop[2]={0,0};
    for(auto p=0; p<numpopulations; ++p){

        haplolengthPop[p]=sequences1[indexsampl].size(); // haploype length at each population
        snpfreqs[p].resize(haplolengthPop[p],0);
        snpositions[p].resize(haplolengthPop[p],-1);

        indexsampl+=samplesizes[p];

    // identify positions at each population
        //auto indexpos = p>0? snpositions[p-1].size():0;

        for(auto pos=0; pos< haplolengthPop[p];++pos)
            snpositions[p][pos]= pos; // first position in the 1st population is 0 and first in the 2nd population is also 0

    }

    // check sequence length to avoid blanks as gaps
    int countsampl=0,pop=0;
    for(auto& s:sequences1){ // s.size() is each sequence size for the first haplotype

        if(s.size()!=(size_t)haplolengthPop[pop]){
            string msg = "ERROR: There are SNPs lacking in sequence "+ NtoS(countsampl+1) +" from population "+NtoS(pop+1) +"\n";
            cout<<msg<<endl;
            texterr(0,msg,true);
        }

        ++countsampl;

        if(countsampl>=samplesizes[pop]){
            ++pop;
            countsampl=0;
        }

    }

// Compute the largest number of snps in any population sample
    size_t maxnumpos{0};
    for_each(snpositions.begin(),snpositions.end(), [&](vector<double> element){maxnumpos= max(maxnumpos,element.size());});

  // transform the sequences in biallelic data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    string minor1="", minor2=""; //
    string major1="", major2="";
    vector<int> contnuc1(5,0), contnuc2(5,0); // 0 for A, 1 C, 2G, 3 T, 4 N
    vector<vector<int>> postodelete1(numpopulations), postodelete2(numpopulations);
  // the major reference sequence is defined with respect the population pref
  // Major allele will be any other than the minor

    indexsampl = pref>0? samplesizes[pref-1]:0;

 // for each position
    for(auto pos=0; pos< haplolengthPop[pref];++pos){

        for(auto s=0; s<samplesizes[pref]; ++s){
            /// for haplotype 1 of each individual in the reference population
            if(sequences1[s +indexsampl][pos]=='A')
                ++contnuc1[0];
            else
            if(sequences1[s +indexsampl][pos]=='C')
                ++contnuc1[1];
            else
            if(sequences1[s +indexsampl][pos]=='G')
                ++contnuc1[2];
            else
            if(sequences1[s +indexsampl][pos]=='T')
                ++contnuc1[3];
            else    // this position is unresolved (under this format is NULL)
                ++contnuc1[4];

            /// for haplotype 2 of each individual in the reference population
            if(sequences2[s +indexsampl][pos]=='A')
                ++contnuc2[0];
            else
            if(sequences2[s +indexsampl][pos]=='C')
                ++contnuc2[1];
            else
            if(sequences2[s +indexsampl][pos]=='G')
                ++contnuc2[2];
            else
            if(sequences2[s +indexsampl][pos]=='T')
                ++contnuc2[3];
            else    // this position is unresolved (under this format is NULL)
                ++contnuc2[4];

        } // close for sample

        /// First haplotype major reference sequence
        auto maxeliter = max_element(contnuc1.begin(), contnuc1.end());
        bool NisMajor=false;
        switch (distance(contnuc1.begin(),maxeliter)){ // the most frequent is
            case 0: major1+="A"; break;
            case 1: major1+="C"; break;
            case 2: major1+="G"; break;
            case 3: major1+="T"; break;
            case 4: major1+="N"; NisMajor=true; postodelete1[pref].push_back(pos); break; // pos correspond to the index of snpositions[pref][pos]
        }

        if( (!NisMajor) && (*maxeliter+contnuc1[4] ==samplesizes[pref]) )// the position has the major allele fixed
            minor1+="N";
        else{ // this position is not fixed so there are at least a minor at freq >0
            auto mineliter = min_element(contnuc1.begin(), contnuc1.begin()+4); // do not count N
            while(*mineliter == 0){
                contnuc1[mineliter-contnuc1.begin()]=samplesizes[pref]+1; // put the count to samplesize +1 instead of 0 and go for the next minor that be not 0
                mineliter = min_element(contnuc1.begin(), contnuc1.begin()+4);
            }

            switch (distance(contnuc1.begin(),mineliter)){ // the less frequent is
                case 0: minor1+="A"; break;
                case 1: minor1+="C"; break;
                case 2: minor1+="G"; break;
                case 3: minor1+="T"; break;
                case 4: throw;
            }
        }

    // reset nucleotide counts for each position
        contnuc1.assign(contnuc1.size(),0);

        /// Second haplotype major reference sequence
        maxeliter = max_element(contnuc2.begin(), contnuc2.end());
        NisMajor=false;
        switch (distance(contnuc2.begin(),maxeliter)){ // the most frequent is
            case 0: major2+="A"; break;
            case 1: major2+="C"; break;
            case 2: major2+="G"; break;
            case 3: major2+="T"; break;
            case 4: major2+="N"; NisMajor=true; postodelete2[pref].push_back(pos); break; // pos correspond to the index of snpositions[pref][pos]
        }

        //if(*maxeliter+postodelete2[pref].size() ==(size_t)samplesizes[pref]) // the is fixed at this position
        if( (!NisMajor) && (*maxeliter+contnuc2[4] ==samplesizes[pref]) )
            minor2+="N";
        else{ // this position is not fixed so there are at least a minor at freq >0
            auto mineliter = min_element(contnuc2.begin(), contnuc2.begin()+4); // do not count N
            while(*mineliter == 0){
                contnuc2[mineliter-contnuc2.begin()]=samplesizes[pref]+1;
                mineliter = min_element(contnuc2.begin(), contnuc2.begin()+4);
            }

            switch (distance(contnuc2.begin(),mineliter)){ // the less frequent is
                case 0: minor2+="A"; break;
                case 1: minor2+="C"; break;
                case 2: minor2+="G"; break;
                case 3: minor2+="T"; break;
                case 4: throw;
            }
        }

    // reset nucleotide counts for each position
        contnuc2.assign(contnuc2.size(),0);

    } // close for positions

    // Update positions to delete in other pops than pref: should be the same
    for(auto p=0; p<numpopulations; ++p){

        if(p!=pref){ // we assume that snpositions[] collections are sorted from minor to major position
            // haplotype1
            for(const auto& delpos:postodelete1[pref]){
                int newindx = get_indxtoindx<double>(snpositions[pref],delpos, snpositions[p]);
assert(delpos==newindx);
                if(newindx>=0)
                    postodelete1[p].push_back(newindx);
            }
            // haplotype2
            for(const auto& delpos:postodelete2[pref]){
                int newindx = get_indxtoindx<double>(snpositions[pref],delpos, snpositions[p]);
assert(delpos==newindx);
                if(newindx>=0)
                    postodelete2[p].push_back(newindx);
            }
        }
    }

    // check
//    for(auto s=0; s<samplesizes[pref]; ++s){
//        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
//        assert(sequences1[s +indexsampl].size() == major.size() );
//        assert(sequences2[s +indexsampl].size() == major.size() );
//    }

/// Gather the information for data etc:
  	data.clear();
    data.resize(totsamples);
    if(firsthaplo){
        for(auto p=0; p<numpopulations; ++p){
            indexsampl = p>0? samplesizes[p-1]:0;
            for(auto s=0; s<samplesizes[p]; ++s){

                data[s +indexsampl].resize(haplolengthPop[p],false);

                for(auto pos=0; pos < haplolengthPop[p]; ++pos){
    // for the pref pop the non-minor alleles are 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N count as major one. If the majority of samples in a position have N this position will be deleted
    // **Note** we count those equal to the reference minor instead those distinct to the reference major because
    // since we are looking for divergent selection we expect the selective to be minor in one pop and major in the other
    // if the minor in the reference pop is A and the major is T and we count in the other pop the non-major it is possible that we are counting other alleles as C or G so inflating the minor frequency and so giving an spurious divergent selection signal
                    if( (sequences1[s+indexsampl][pos] == minor1[pos]) && (sequences1[s+indexsampl][pos] !='N') ){
                        data[indexsampl + s][pos]=true;
                       // the frequency of the allele 1
                       snpfreqs[p][pos]++;
                    }

                } // close for pos

                del_elements(data[s+indexsampl],postodelete1[p]);

            } // close for sample

        // delete sites with major unknown allele
            del_elements(snpfreqs[p],postodelete1[p]); // if the positions is too higher for a given population then is ignored
            del_elements(snpositions[p],postodelete1[p]); /// positions are deleted but not updated i.e. if delete 4th the 5th is still stored as the 5th

           // frequencies are relative to sample size
            for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

        } // close for p

/// acr June 21. Update selective positions if candidates are provided

/* iterators in for from https://stackoverflow.com/questions/14373934/iterator-loop-vs-index-loop
for (auto it = v.begin(); it != v.end(); ++it) {
    // if the current index is needed:
    auto i = std::distance(v.begin(), it);

    // access element as *it

    // any code including continue, break, return
}

BUT here we need two steps to delete and update positions
ex: postodelete=[9,20,100] selective[1,7,9,23,24,100,200]

*/
//postodelete1[pref].clear();
//postodelete1[pref] = {9,20,100};
//selective.clear();
//selective = {1,7,9,23,24,100,200};
//printcol(selective);
/*
        vector<int> indexes;
        vector<int>nondelpos;
        bool deleted=false;
        size_t countdeletions=0;
/// first step: delete. We assume and have checked that the positions in both pops are the same so we only need to access to the reference population
        for(auto pos : postodelete1[pref]){

            for(auto it = selective.begin(); it!= selective.end();){ // do not increase it automatically but only when not erasing

                if(pos ==*it){ // a selective positions corresponds to one to be deleted
                    // store the original index of the selective value that will be deleted
                    indexes.push_back(distance(selective.begin(), it) + countdeletions);

                    it = selective.erase(it); // delete and restore the iterator
                    ++countdeletions;
                    deleted=true;
                    break; // the selective positions are not repeated if deleted in selective we can go for next pos in postodelete
                }
                else {

                    ++it; // advance to the next selective
                }

            } //close for it

            if(!deleted){ //store the position in non deleted
                nondelpos.push_back(pos);
            }
            else
                deleted=false;
        } // close for pos

//printcol(selective);
//printcol(indexes);
//printcol(nondelpos);
*/
      /// second step: update after the selective deleted ones positions
       /*
       previous: selective[1,7,9,23,24,100,200]
       after deletion:
       selective[1,7,23,24,200]
       indexes=[2, 5]
       nondelpos=[20]

        for...
        indexes[0] = 2
        ui= 2-0=2
        selective[ui]=selective[2] ... selective[4] => selective[ui]-1
        selective[1, 7,22,23,199]
        indexes[1] = 5
        ui=4
        selective[4] => selective[ui]-1
        selective[1, 7,22,23,198]

        */
/*
        for(size_t i= 0; i < indexes.size(); ++i){
            auto ui = indexes[i]-i;
            for_each(selective.begin()+ui, selective.end(), [](int& s){s-=1;} );
        }
//printcol(selective);
        /// Last: position 20 was also deleted altouhg non selective this affect to the selective sites that are after it
        for(auto pos: nondelpos){

            for_each(selective.begin(), selective.end(), [=](int& s){if(pos < s) s-=1;} );

        }
*/
//printcol(selective);
        /*
            nondelpos=[20]
            selective[1, 7,21,22,197]
        */
//exit(8);
    } // close if firsthaplo
    else{ // second haplotype
        for(auto p=0; p<numpopulations; ++p){
            indexsampl = p>0? samplesizes[p-1]:0;
            for(auto s=0; s<samplesizes[p]; ++s){

                data[s +indexsampl].resize(haplolengthPop[p],false);

                for(auto pos=0; pos < haplolengthPop[p]; ++pos){
    // for the pref pop the non-minor alleles are 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N count as major one. If the majority of samples in a position have N this position will be deleted
    // **Note** we count those equal to the reference minor instead those distinct to the reference major
    // since we are looking for divergent selection we expect the selective to be minor in one pop and major in the other
    // if the minor in the reference pop is A and the major is T and we count in the other pop the non-major it is possible that we are counting other alleles as C or G so inflating the minor frequency and so giving an spurious divergent selection signal
                    if( (sequences2[s+indexsampl][pos] == minor2[pos]) && (sequences2[s+indexsampl][pos] !='N') ){
                        data[indexsampl + s][pos]=true;
                       // the frequency of the allele 1
                       snpfreqs[p][pos]++;
                    }

                } // close for pos

                del_elements(data[s+indexsampl],postodelete2[p]);

            } // close for sample

        // delete sites with major unknown allele
            del_elements(snpfreqs[p],postodelete2[p]); // if the positions is too higher for a given population then is ignored
            del_elements(snpositions[p],postodelete2[p]);

           // frequencies are relative to sample size
            for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

        } // close for p
/// acr June 21. Update selective positions if candidates are provided

/* iterators in for from https://stackoverflow.com/questions/14373934/iterator-loop-vs-index-loop
for (auto it = v.begin(); it != v.end(); ++it) {
    // if the current index is needed:
    auto i = std::distance(v.begin(), it);

    // access element as *it

    // any code including continue, break, return
}

BUT here we need two steps to delete and update positions
ex: postodelete=[9,20,100] selective[1,7,9,23,24,100,200]

*/
//postodelete2[pref].clear();
//postodelete2[pref] = {9,20,100};
//selective.clear();
//selective = {1,7,9,23,24,100,200};
//printcol(selective);
/*
        vector<int> indexes;
        vector<int>nondelpos;
        bool deleted=false;
        size_t countdeletions=0;
/// first step: delete. We assume and have checked that the positions in both pops are the same so we only need to access to the reference population
        for(auto pos : postodelete2[pref]){

            for(auto it = selective.begin(); it!= selective.end();){ // do not increase it automatically but only when not erasing

                if(pos ==*it){ // a selective positions corresponds to one to be deleted
                    // store the original index of the selective value that will be deleted
                    indexes.push_back(distance(selective.begin(), it) + countdeletions);

                    it = selective.erase(it); // delete and restore the iterator
                    ++countdeletions;
                    deleted=true;
                    break; // the selective positions are not repeated if deleted in selective we can go for next pos in postodelete
                }
                else {

                    ++it; // advance to the next selective
                }

            } //close for it

            if(!deleted){ //store the position in non deleted
                nondelpos.push_back(pos);
            }
            else
                deleted=false;
        } // close for pos
*/
//printcol(selective);
//printcol(indexes);
//printcol(nondelpos);

      /// second step: update after the selective deleted ones positions
       /*
       previous: selective[1,7,9,23,24,100,200]
       after deletion:
       selective[1,7,23,24,200]
       indexes=[2, 5]
       nondelpos=[20]

        for...
        indexes[0] = 2
        ui= 2-0=2
        selective[ui]=selective[2] ... selective[4] => selective[ui]-1
        selective[1, 7,22,23,199]
        indexes[1] = 5
        ui=4
        selective[4] => selective[ui]-1
        selective[1, 7,22,23,198]

        */
/*
        for(size_t i= 0; i < indexes.size(); ++i){
            auto ui = indexes[i]-i;
            for_each(selective.begin()+ui, selective.end(), [](int& s){s-=1;} );
        }
//printcol(selective);
        /// Last: position 20 was also deleted altouhg non selective this affect to the selective sites that are after it
        for(auto pos: nondelpos){

            for_each(selective.begin(), selective.end(), [=](int& s){if(pos < s) s-=1;} );

        }
*/
//printcol(selective);
        /*
            nondelpos=[20]
            selective[1, 7,21,22,197]
        */
//exit(8);
    } // close else second haplo


} catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
} catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename0 <<endl;
    return false;
} catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename0 <<endl;
    return false;
}
    return true;
}

/*
    int numloci{0}, numseqsperpop{0},numalleles{0};
    double snpfreq{0};
    double numsnpsinsample{0};
*/


/*
Formato fasta

>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY

HERE THE POSITION OF THE SNP IS NOT THE PHISICAL POSITION IN THE CHROMOSOME BUT THE POSITION IN THE SEQUENCE SO IF
WE DELETE A COLUM (A SNP) THE POSITIONS MUST BE UPDATED IF FOR EXAMPLE WE WANT TO DETECT SELECTION AT A GIVEN SNP IN THE
SEQUENCE E.G POS 3 BEFORE DELETING BECOMES POS 2 IF WE DELETE THE SNP COLUMN 1.

*/
/** This procedure is update by May 2024
Previous version read just the sequences and assume there are two populations with 2*samplesize sequences so that
it computes numpops = totsequences/ samplesize so that it fails when totsequences> 2*samplesize.
It seem bettwer to already assume to populations and if there is no tag just count totsequences/2 for the first sample and
the remaining for the second.

For making this change the argument const int& samplesize wasw changed to vector<int>& samplesizes


**/
bool  SNPSelTools::readfastadata(const bool& nogaps,const string& path,const string& filename0, vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions)
{

    /// Open file

    int tries=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size


	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}


//numcopies = 2N for diploids or N for haploids
// numalleles should be 2 for SNPs
    //int numloci(0), numpopulations(0), numsamples(0),numseqsperpop(0),numalleles(0);
    int numsamples(0);

    string temp="";
	vector<string> sequences; // first store the sequences then transform to data, positions and frequencies
	datafile >> boolalpha;
	//cout<<boolalpha;

    datafile.clear();

// skip blank lines and commentaries i.e. lines beginning with comment_tag
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    if(temp[0]=='>')
        numsamples=1;
    else{
        string msg = "\nEmpty file or wrong format when reading fasta "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

// Read lines skiping lines with '>' the identifier for sequence names
    string line="";
    do{
        getline(datafile, temp);

        if(!temp.empty()){
            if(temp[0]!='>'){

        // Feb 2024 remove spaces is the format is in triplets e.g. act acc tgt..
            clean_spaces(temp);
        // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                line+=temp;

            }
            else{
                if(!line.empty()){
                    sequences.push_back(line);
                    line="";
                }
                ++numsamples;
            }
        }

    }while(!datafile.eof() );
    // add the last line
    sequences.push_back(line);

    if(sequences[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: Sequence too large in file "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

/// May 2024
    int numpopulations=2;

    int samplesize1=numsamples/numpopulations;
    int samplesize2=numsamples-samplesize1;

    samplesizes={samplesize1,samplesize2};

    if(samplesize1<2 || samplesize1<2 )
	{
		string msg = "\nERROR: low sample size found " +NtoS(min(samplesize1,samplesize2))+"\n";
		cout<<msg<<endl;
		return false;

	}

assert(numsamples==(int)sequences.size());

    if(sequences[0].size()!= sequences[samplesizes[0]].size()){ // the sequences must be aligned and have the same sample size
        string msg = "ERROR: sequences must be aligned in "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

// redimension the snpfreqs and snpositions vector
    snpfreqs.resize(numpopulations);
    snpositions.resize(numpopulations);
    string major=""; //

    /// May 2024 def pref the population with highest sample size
    auto pref =samplesizes[0]>=samplesizes[1]? 0:1;


    for(auto p=0; p<numpopulations; ++p){
        snpfreqs[p].resize(sequences[samplesizes[0]*p].size(),0);
        snpositions[p].resize(sequences[samplesizes[0]*p].size(),-1);


    }

  // transform the sequences in data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    vector<int> contnuc(5); // 0 for A, 1 C, 2G, 3 T, 4 N

    vector<int> postodelete;
  // the major reference sequence is defined with respect the population pref
   // for each position
    for(size_t pos=0; pos< snpfreqs[pref].size();++pos){
        bool foundgap=false;
        for(auto s=0; s<samplesizes[pref]; ++s){

            const char element = sequences[s+samplesizes[0]*pref][pos];

            if(element=='A')
                ++contnuc[0];
            else
            if(element=='C')
                ++contnuc[1];
            else
            if(element=='G')
                ++contnuc[2];
            else
            if(element=='T')
                ++contnuc[3];
            else
            if(element=='-' && nogaps){
                postodelete.push_back(pos);
                foundgap=true;
                break;
            }
            else{
            //if(sequences[s +samplesize*pref][pos]=='N')
                sequences[s +samplesizes[0]*pref][pos]='N'; ///Feb 2024 homogenize non nucs to the symbol N
                ++contnuc[4];
            }

        } // close for sample
        if(!foundgap){
            auto maxeliter = max_element(contnuc.begin(), contnuc.end());
            switch (distance(contnuc.begin(),maxeliter)){ // the most frequent is
                case 0: major+="A"; break;
                case 1: major+="C"; break;
                case 2: major+="G"; break;
                case 3: major+="T"; break;
                case 4: major+="N"; postodelete.push_back(pos); break;
            }
        } // close if not foundgap
        else{
            major+="-";
        }
//get_indx(postodelete,'-');

    // reset nucleotide counts for each position
        contnuc.assign(contnuc.size(),0);
    } // close for positions

    // check
    for(auto s=0; s<samplesizes[pref]; ++s){
        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
        assert(sequences[s +samplesizes[0]*pref].size() == major.size() );
    }

/// Gather the information for data etc: if the sequences length are different in the populations then positions are considered to begin at 0 in every population so that the difference is at the ending positions
  	data.clear();
    data.resize(numsamples);

// positions are distributed uniformly in order to match positions between populations we should divide by the maximum number of sites
    size_t largernumsnps=0;
    for_each(snpositions.begin(),snpositions.end(), [&](vector<double> element){largernumsnps= max(largernumsnps,element.size());});

    for(auto p=0; p<numpopulations; ++p){
        for(auto s=0; s<samplesizes[p]; ++s){

            data[s +samplesizes[0]*p].resize(snpfreqs[p].size(),false);

            for(size_t pos=0; pos < snpfreqs[p].size(); ++pos){

                const char element = sequences[s+samplesizes[0]*p][pos];
                const bool is_in = nucleotides.find(string(1,element)) != nucleotides.end();
                if( (element != major[pos]) && (is_in) ){ // for the pref pop the major allele is 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N cout as major one. If the majority of samples in a position have N this position will be deleted
                    data[p*samplesizes[0] + s][pos]=true;
                   // the frequency of the allele 1
                   snpfreqs[p][pos]++;
                }

                //snpositions[p][pos] = ((double)pos) / largernumsnps;
                ///FEB 2024
                snpositions[p][pos] = ((double)pos);
            } // close for pos

            del_elements(data[s+samplesizes[0]*p],postodelete); // delete in data[row] the elements indicated by the indexes in postodelete

        } // close for sample

    // delete sites with major unknown allele
        del_elements(snpfreqs[p],postodelete); // if the positions is too higher for a given population then is ignored
        del_elements(snpositions[p],postodelete);


       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

    } // close for p


    return true;
}

/*
Formato fasta

>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY

HERE THE POSITION OF THE SNP IS NOT THE PHISICAL POSITION IN THE CHROMOSOME BUT THE POSITION IN THE SEQUENCE SO IF
WE DELETE A COLUM (A SNP) THE POSITIONS MUST BE UPDATED IF FOR EXAMPLE WE WANT TO DETECT SELECTION AT A GIVEN SNP IN THE
SEQUENCE E.G POS 3 BEFORE DELETING BECOMES POS 2 IF WE DELETE THE SNP COLUMN 1.

*/

/** Feb 2024. Esta version lee un fichero en formato fasta donde las dos poblaciones no están ordenadas sino que se separan según
un tag presente en el nombre de las secuencias. Por ejemplo tag='hpv' (mayúscula o minúscula) separa en poblaciones distintas
las secuencias hpv del resto.

Cambia las posiciones no se guardan en valores relativos sino absolutos (indexadas a 0)

Incluye la opción de guardar las poblaciones separadas en sendos ficheros
y la opción de eliminar columnas con gaps
**/
bool  SNPSelTools::readfastadatatag(const string& tag,const bool& store,const bool& nogaps, const string& path,const string& filename0,  vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, int& pref)
{

    /// Open file

    int tries=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size


	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}


    bool tagpop=false;
    int numpopulations(0), numsamples(0);
    string temp="";
	vector<string> sequences1, names1; // first store the sequences then transform to data, positions and frequencies
	vector<string> sequences2,names2;
	datafile >> boolalpha;
	//cout<<boolalpha;

    datafile.clear();

// skip blank lines and commentaries i.e. lines beginning with comment_tag
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    if(temp[0]=='>'){
        numsamples=1;
        if(ToLowerCase(temp).find(tag)!=std::string::npos){
            tagpop=true;
            names1.push_back(temp);
        }
        else{
            names2.push_back(temp);
        }

    }
    else{
        string msg = "\nEmpty file or wrong format when reading fasta "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

// Read lines skiping lines with '>' the identifier for sequence names
    string line="";
    do{
        getline(datafile, temp);

        if(!temp.empty()){
            if(temp[0]!='>'){

        // Feb 2024 remove spaces is the format is in triplets e.g. act acc tgt..
            clean_spaces(temp);
        // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                line+=temp;

            }
            else{
                if(!line.empty()){
                    if(tagpop)
                        sequences1.push_back(line);
                    else
                        sequences2.push_back(line);

                    line="";
                }
                ++numsamples;

                if(ToLowerCase(temp).find(tag)!=std::string::npos){
                    tagpop=true;
                    names1.push_back(temp);
                }
                else{
                    tagpop=false;
                    names2.push_back(temp);
                }
            }
        }


    }while(!datafile.eof() );
    // add the last line
    if(tagpop)
        sequences1.push_back(line);
    else
        sequences2.push_back(line);



    assert(sequences1.size()==names1.size());
    assert(sequences2.size()==names2.size());
    /// Calculate sample sizes
    samplesizes={(int)sequences1.size(),(int)sequences2.size()};
    /// Join the sequences (see https://stackoverflow.com/questions/3177241/what-is-the-best-way-to-concatenate-two-vectors)
    vector<string> sequences;
    sequences.reserve( samplesizes[0] + samplesizes[1] ); // preallocate memory
    sequences.insert( sequences.end(), sequences1.begin(), sequences1.end() );
    sequences.insert( sequences.end(), sequences2.begin(), sequences2.end() );

    if(sequences[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: Sequence too large in file "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

    if(sequences1.empty() || sequences2.empty() )
	{
		string msg = "\nERROR: The tag did not separate two populations\n";
		cout<<msg<<endl;

		cout<<tag<<"\t"<<sequences1.size()<<"\t"<<sequences2.size()<<"\t"<<sequences.size() <<endl;

		return false;

	}

	numpopulations = 2;

assert(numsamples==(int)sequences.size());

    if(sequences[0].size()!= sequences[samplesizes[0]].size()){ // the sequences must be aligned and have the same sample size
        string msg = "ERROR: sequences must be aligned in "+ filename0 + "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

// redimension the snpfreqs and snpositions vector
    snpfreqs.resize(numpopulations);
    snpositions.resize(numpopulations);
    string major="";

    for(auto p=0; p<numpopulations; ++p){
        snpfreqs[p].resize(sequences[samplesizes[0]*p].size(),0);
        snpositions[p].resize(sequences[samplesizes[0]*p].size(),-1);
    }
  // transform the sequences in data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    vector<int> contnuc(5); // 0 for A, 1 C, 2G, 3 T, 4 N

    vector<int> postodelete;

    /// we  use the population with the largest sample size to set the major reference sequence
    pref= samplesizes[0]>=samplesizes[1]?0:1;

  // the major reference sequence is defined with respect the population pref
   // for each position
    for(size_t pos=0; pos< snpfreqs[pref].size();++pos){
        bool foundgap=false;
        for(auto s=0; s<samplesizes[pref]; ++s){

            const char element = sequences[s+samplesizes[0]*pref][pos];

            if(element=='A')
                ++contnuc[0];
            else
            if(element=='C')
                ++contnuc[1];
            else
            if(element=='G')
                ++contnuc[2];
            else
            if(element=='T')
                ++contnuc[3];
            else
            if(element=='-' && nogaps){
                postodelete.push_back(pos);
                foundgap=true;
                break;
            }
            else{
            //if(sequences[s +samplesize*pref][pos]=='N')
                sequences[s +samplesizes[0]*pref][pos]='N'; ///Feb 2024 homogenize gaps or whatever to the symbol N
                ++contnuc[4];
            }

        } // close for sample

        if(!foundgap){
            auto maxeliter = max_element(contnuc.begin(), contnuc.end());
            switch (distance(contnuc.begin(),maxeliter)){ // the most frequent is
                case 0: major+="A"; break;
                case 1: major+="C"; break;
                case 2: major+="G"; break;
                case 3: major+="T"; break;
                case 4: major+="N"; postodelete.push_back(pos); break;
            }
        } // close if not foundgap
        else{
            major+="-";
        }
    // reset nucleotide counts for each position
        contnuc.assign(contnuc.size(),0);
    } // close for positions

    // check
    for(auto s=0; s<samplesizes[pref]; ++s){
        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
        assert(sequences[s +samplesizes[0]*pref].size() == major.size() );
    }

/// Gather the information for data etc: if the sequences length are different in the populations then positions are considered to begin at 0 in every population so that the difference is at the ending positions
  	data.clear();
    data.resize(samplesizes[0]+samplesizes[1]);

    for(auto p=0; p<numpopulations; ++p){

        for(auto s=0; s<samplesizes[p]; ++s){

            data[s +samplesizes[0]*p].resize(snpfreqs[p].size(),false);

            for(size_t pos=0; pos < snpfreqs[p].size(); ++pos){

                const char element = sequences[s+samplesizes[0]*p][pos];
                const bool is_in = nucleotides.find(string(1,element)) != nucleotides.end(); //sting(n,c) Fills the string with n consecutive copies of character c.
                if( (element != major[pos]) && (is_in) ){ // for the pref pop the major allele is 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N count as major one. If the majority of samples in a position have N this position will be deleted
                    data[p*samplesizes[0] + s][pos]=true;
                   // the frequency of the allele 1
                   snpfreqs[p][pos]++;
                }
                //FEB 2024
                //snpositions[p][pos] = ((double)pos) / largernumsnps;
                snpositions[p][pos] = ((double)pos);
            } // close for pos

//cout<<"Data size is "<<data[0].size()<<endl;
            del_elements(data[s+samplesizes[0]*p],postodelete); // delete in data[row] the elements indicated by the indexes in postodelete

//cout<<"Data size is "<<data[0].size()<<" and pos deleted size were "<<postodelete.size()<<endl;
//exit(1);
        } // close for sample

    // delete sites with major unknown allele
        del_elements(snpfreqs[p],postodelete); // if the positions is too higher for a given population then is ignored
        del_elements(snpositions[p],postodelete);

       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

    } // close for p


    if(store){ // store the separated data in two files

        string filename2=substring(filename0, ".", true, true); // sequence names without tag
        string filename1=filename2+"_"+tag+".fas"; //sequence names with tag

        filename2+="_NON_"+tag+".fas";

        ofstream out1((path+filename1).c_str(),ios::out);

        for(int seq=0; seq<(int)sequences1.size();++seq){
            out1<<names1[seq]<<"\n"<<sequences1[seq]<<endl;
        }

        ofstream out2((path+filename2).c_str(),ios::out);

        for(int seq=0; seq<(int)sequences2.size();++seq){
            out2<<names2[seq]<<"\n"<<sequences2[seq]<<endl;
        }
    }

    return true;
}

///
/** Feb 2024. Esta version lee y ALEATORIZA un fichero en formato fasta separándolo en dos poblaciones.

Cambia las posiciones no se guardan en valores relativos sino absolutos (indexadas a 0)

Incluye la opción de guardar las poblaciones separadas en sendos ficheros
y la opción de eliminar columnas con gaps
**/
bool  SNPSelTools::readfastadatarand(const bool& store,const bool& nogaps, const string& path,const string& filename0,  vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, int& pref)
{

    /// Open file

    int tries=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size


	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}


    bool tagpop=false;
    int numpopulations(0), numsamples(0);
    string temp="";
	vector<string> sequences1, names1; // first store the sequences then transform to data, positions and frequencies
	vector<string> sequences2,names2;
	datafile >> boolalpha;
	//cout<<boolalpha;

    datafile.clear();

// skip blank lines and commentaries i.e. lines beginning with comment_tag
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    if(temp[0]=='>'){ /// First sequence name
        numsamples=1;
        tagpop=true;
        names1.push_back(temp);

    }
    else{
        string msg = "\nEmpty file or wrong format when reading fasta "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

// Read lines skiping lines with '>' the identifier for sequence names
    string line="";
    do{
        getline(datafile, temp);

        if(!temp.empty()){
            if(temp[0]!='>'){

        // Feb 2024 remove spaces is the format is in triplets e.g. act acc tgt..
            clean_spaces(temp);
        // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                line+=temp;

            }
            else{
                if(!line.empty()){
                    if(tagpop){
                        sequences1.push_back(line); //sequence belongs to the first pop
                        tagpop=false; //alternate so the sequence following this name belongs to the second pop
                        names2.push_back(temp);
                    }
                    else{
                        sequences2.push_back(line);//sequence belongs to the second pop
                        tagpop=true; //alternate so the sequence following this name belongs to the first pop
                        names1.push_back(temp);
                    }

                    line="";
                }
                ++numsamples;

            }
        }


    }while(!datafile.eof() );
    // add the last line
    if(tagpop)
        sequences1.push_back(line);
    else
        sequences2.push_back(line);



    assert(sequences1.size()==names1.size());
    assert(sequences2.size()==names2.size());
    /// Calculate sample sizes
    samplesizes={(int)sequences1.size(),(int)sequences2.size()};
    /// Join the sequences (see https://stackoverflow.com/questions/3177241/what-is-the-best-way-to-concatenate-two-vectors)
    vector<string> sequences;
    sequences.reserve( samplesizes[0] + samplesizes[1] ); // preallocate memory
    sequences.insert( sequences.end(), sequences1.begin(), sequences1.end() );
    sequences.insert( sequences.end(), sequences2.begin(), sequences2.end() );

    if(sequences[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: Sequence too large in file "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

    if(sequences1.empty() || sequences2.empty() )
	{
		string msg = "\nERROR: Did not separate two populations\n";
		cout<<msg<<endl;

		cout<<sequences1.size()<<"\t"<<sequences2.size()<<"\t"<<sequences.size() <<endl;

		return false;

	}

	numpopulations = 2;

assert(numsamples==(int)sequences.size());

    if(sequences[0].size()!= sequences[samplesizes[0]].size()){ // the sequences must be aligned and have the same length
        string msg = "ERROR: sequences must be aligned in "+ filename0 + "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

// redimension the snpfreqs and snpositions vector
    snpfreqs.resize(numpopulations);
    snpositions.resize(numpopulations);
    string major="";

    for(auto p=0; p<numpopulations; ++p){
        snpfreqs[p].resize(sequences[samplesizes[0]*p].size(),0);
        snpositions[p].resize(sequences[samplesizes[0]*p].size(),-1);
    }
  // transform the sequences in data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    vector<int> contnuc(5); // 0 for A, 1 C, 2G, 3 T, 4 N

    vector<int> postodelete;

    /// we  use the population with the largest sample size to set the major reference sequence
    pref= samplesizes[0]>=samplesizes[1]?0:1;

  // the major reference sequence is defined with respect the population pref
   // for each position
    for(size_t pos=0; pos< snpfreqs[pref].size();++pos){
        bool foundgap=false;
        for(auto s=0; s<samplesizes[pref]; ++s){

            const char element = sequences[s+samplesizes[0]*pref][pos];

            if(element=='A')
                ++contnuc[0];
            else
            if(element=='C')
                ++contnuc[1];
            else
            if(element=='G')
                ++contnuc[2];
            else
            if(element=='T')
                ++contnuc[3];
            else
            if(element=='-' && nogaps){
                postodelete.push_back(pos);
                foundgap=true;
                break;
            }
            else{
            //if(sequences[s +samplesize*pref][pos]=='N')
                sequences[s +samplesizes[0]*pref][pos]='N'; ///Feb 2024 homogenize gaps or whatever to the symbol N
                ++contnuc[4];
            }

        } // close for sample

        if(!foundgap){
            auto maxeliter = max_element(contnuc.begin(), contnuc.end());
            switch (distance(contnuc.begin(),maxeliter)){ // the most frequent is
                case 0: major+="A"; break;
                case 1: major+="C"; break;
                case 2: major+="G"; break;
                case 3: major+="T"; break;
                case 4: major+="N"; postodelete.push_back(pos); break;
            }
        } // close if not foundgap
        else{
            major+="-";
        }
    // reset nucleotide counts for each position
        contnuc.assign(contnuc.size(),0);
    } // close for positions

    // check
    for(auto s=0; s<samplesizes[pref]; ++s){
        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
        assert(sequences[s +samplesizes[0]*pref].size() == major.size() );
    }

/// Gather the information for data etc: if the sequences length are different in the populations then positions are considered to begin at 0 in every population so that the difference is at the ending positions
  	data.clear();
    data.resize(samplesizes[0]+samplesizes[1]);

    for(auto p=0; p<numpopulations; ++p){

        for(auto s=0; s<samplesizes[p]; ++s){

            data[s +samplesizes[0]*p].resize(snpfreqs[p].size(),false);

            for(size_t pos=0; pos < snpfreqs[p].size(); ++pos){

                const char element = sequences[s+samplesizes[0]*p][pos];
                const bool is_in = nucleotides.find(string(1,element)) != nucleotides.end();
                if( (element != major[pos]) && (is_in) ){ // for the pref pop the major allele is 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N count as major one. If the majority of samples in a position have N this position will be deleted
                    data[p*samplesizes[0] + s][pos]=true;
                   // the frequency of the allele 1
                   snpfreqs[p][pos]++;
                }
                //FEB 2024
                //snpositions[p][pos] = ((double)pos) / largernumsnps;
                snpositions[p][pos] = ((double)pos);
            } // close for pos

//cout<<"Data size is "<<data[0].size()<<endl;
            del_elements(data[s+samplesizes[0]*p],postodelete); // delete in data[row] the elements indicated by the indexes in postodelete

//cout<<"Data size is "<<data[0].size()<<" and pos deleted size were "<<postodelete.size()<<endl;
//exit(1);
        } // close for sample

    // delete sites with major unknown allele
        del_elements(snpfreqs[p],postodelete); // if the positions is too higher for a given population then is ignored
        del_elements(snpositions[p],postodelete);

       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

    } // close for p


    if(store){ // store the separated data in two files

        string filename2=substring(filename0, ".", true, true); // sequence names without tag
        string filename1=filename2+"_rndPop1.fas"; //sequence names with tag

        filename2+="_rndPop2_.fas";

        ofstream out1((path+filename1).c_str(),ios::out);

        for(int seq=0; seq<(int)sequences1.size();++seq){
            out1<<names1[seq]<<"\n"<<sequences1[seq]<<endl;
        }

        ofstream out2((path+filename2).c_str(),ios::out);

        for(int seq=0; seq<(int)sequences2.size();++seq){
            out2<<names2[seq]<<"\n"<<sequences2[seq]<<endl;
        }
    }

    return true;
}

/// Esta version de read fasta lee los dos ficheros seprados y los acumula
/*
Formato fasta

>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY

HERE THE POSITION OF THE SNP IS NOT THE PHISICAL POSITION IN THE CHROMOSOME BUT THE POSITION IN THE SEQUENCE SO IF
WE DELETE A COLUM (A SNP) THE POSITIONS MUST BE UPDATED IF FOR EXAMPLE WE WANT TO DETECT SELECTION AT A GIVEN SNP IN THE
SEQUENCE E.G POS 3 BEFORE DELETING BECOMES POS 2 IF WE DELETE THE SNP COLUMN 1.


*/
bool  SNPSelTools::readfastadata(const bool& nogaps,const string& path,const string& filename1,const string& filename2, vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, int& pref)
{

    /// Open file

    int tries=0;

	string filename=path+filename1;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size


	// check input file name 1
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}


//numcopies = 2N for diploids or N for haploids
// numalleles should be 2 for SNPs
    //int numloci(0), numpopulations(0), numsamples(0),numseqsperpop(0),numalleles(0);
    //double snpfreq(0.0);
    //double numsnpsinsample(0.0);
    string temp="";
	vector<string> sequences; // first store the sequences then transform to data, positions and frequencies
	datafile >> boolalpha;
	//cout<<boolalpha;
	int numpopulations(0), numsamples(0);


    datafile.clear();

// skip blank lines and commentaries i.e. lines beginning with comment_tag
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    if(temp[0]=='>')
        numsamples=1;
    else{
        string msg = "\nEmpty file or wrong format when reading fasta "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

// Read lines skiping lines with '>' the identifier for sequence names
    string line="";
    do{
        getline(datafile, temp);

        if(!temp.empty()){
            if(temp[0]!='>'){

        // Feb 2024 remove spaces is the format is in triplets e.g. act acc tgt..
            clean_spaces(temp);
        // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                line+=temp;

            }
            else{
                if(!line.empty()){
                    sequences.push_back(line);
                    line="";
                }
                ++numsamples;
            }
        }

    }while(!datafile.eof() );
    // add the last line
    sequences.push_back(line);

    int samplesize1=numsamples;

    if(sequences[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: Sequence too large in file "+ filename1+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }




    datafile.close();

    filename=path+filename2;

    	/// check input file name 2
	do{
		//datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

    datafile.clear();
    temp="";
    numsamples=0;

// skip blank lines and commentaries i.e. lines beginning with comment_tag
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    if(temp[0]=='>')
        ++numsamples;
    else{
        string msg = "\nEmpty file or wrong format when reading fasta "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

// Read lines skiping lines with '>' the identifier for sequence names
    line="";
    do{
        getline(datafile, temp);

        if(!temp.empty()){
            if(temp[0]!='>'){

        // Feb 204 remove spaces is the format is in triplets e.g. act acc tgt..
            clean_spaces(temp);
        // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                line+=temp;

            }
            else{
                if(!line.empty()){
                    sequences.push_back(line);
                    line="";
                }
                ++numsamples;
            }
        }

    }while(!datafile.eof() );
    // add the last line
    sequences.push_back(line);
    int samplesize2=numsamples;

    if(sequences.back().size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: Sequence too large in file "+ filename2+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }


    if(sequences[0].size()!= sequences[samplesize1].size()){ // the sequences must be aligned and have the same sample size
        string msg = "ERROR: sequences must be of the same length in files "+ filename1+ " and "+filename2+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

    numpopulations=2;


//    if(numpopulations>2)
//	{
//		string msg = "\nERROR: only two populations allowed\n";
//		cout<<msg<<endl;
//		return false;
//
//	}

assert(samplesize1+samplesize2==(int)sequences.size());

// redimension the snpfreqs and snpositions vector
    snpfreqs.resize(numpopulations);
    snpositions.resize(numpopulations);
    string major=""; // we  use the population with the longest sequences to set the major reference sequence
    //size_t maxnumpos=0;
    samplesizes={samplesize1,samplesize2};
    int totsamplesize=samplesize1+samplesize2;
    for(auto p=0; p<numpopulations; ++p){
        snpfreqs[p].resize(sequences[samplesize1*p].size(),0);
        snpositions[p].resize(sequences[samplesize1*p].size(),-1);

    }

    ///ACR Feb 2024 we  use the population with the largest sample size to set the major reference sequence
    pref= samplesizes[0]>=samplesizes[1]?0:1;

// positions are distributed uniformly in order to match positions between populations we should divide by the maximum number of sites
    size_t largernumsnps=0;
    for_each(snpositions.begin(),snpositions.end(), [&](vector<double> element){largernumsnps= max(largernumsnps,element.size());});

  // transform the sequences in data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    vector<int> contnuc(5); // 0 for A, 1 C, 2G, 3 T, 4 N

    vector<int> postodelete;
  // the major reference sequence is defined with respect the population pref
   // for each position
    for(size_t pos=0; pos< snpfreqs[pref].size();++pos){
        bool foundgap=false;
        for(auto s=0; s<samplesizes[pref]; ++s){

            const char element = sequences[s+samplesize1*pref][pos];

            if(element=='A')
                ++contnuc[0];
            else
            if(element=='C')
                ++contnuc[1];
            else
            if(element=='G')
                ++contnuc[2];
            else
            if(element=='T')
                ++contnuc[3];
            else
            if(element=='-' && nogaps){
                postodelete.push_back(pos);
                foundgap=true;
                break;
            }
            else{
            //if(sequences[s +samplesize*pref][pos]=='N')
                sequences[s +samplesize1*pref][pos]='N'; ///Feb 2024 homogenize gaps or whatever to the symbol N
                ++contnuc[4];
            }

        } // close for sample

        if(!foundgap){
            auto maxeliter = max_element(contnuc.begin(), contnuc.end());
            switch (distance(contnuc.begin(),maxeliter)){ // the most frequent is
                case 0: major+="A"; break;
                case 1: major+="C"; break;
                case 2: major+="G"; break;
                case 3: major+="T"; break;
                case 4: major+="N"; postodelete.push_back(pos); break;
            }
        } // close if not foundgap
        else{
            major+="-";
        }
    // reset nucleotide counts for each position
        contnuc.assign(contnuc.size(),0);
    } // close for positions in pref


    // check
    for(auto s=0; s<samplesizes[pref]; ++s){
        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
        assert(sequences[s +samplesize1*pref].size() == major.size() );
    }

/// Gather the information for data etc: if the sequences length are different in the populations then positions are considered to begin at 0 in every population so that the difference is at the ending positions
  	data.clear();
    data.resize(totsamplesize);

    for(auto p=0; p<numpopulations; ++p){
        for(auto s=0; s<samplesizes[p]; ++s){

            data[s +samplesize1*p].resize(snpfreqs[p].size(),false);

            for(size_t pos=0; pos < snpfreqs[p].size(); ++pos){
                const char element = sequences[s+samplesize1*p][pos];
                const bool is_in = nucleotides.find(string(1,element)) != nucleotides.end();
// for the pref pop the major allele is 0 and the minor is 1.
//For the other populations 1 will the allele that matches with the minor in pref.
//If the allele is N cout as major one. If the majority of samples in a position have N this position will be deleted
                if( (element != major[pos]) && (is_in) ){

                    data[p*samplesize1 + s][pos]=true;
                   // the frequency of the allele 1
                   snpfreqs[p][pos]++;
                }

                //snpositions[p][pos] = ((double)pos) / largernumsnps;
                //FEB 2024
                snpositions[p][pos] = ((double)pos);
            } // close for pos

            del_elements(data[s+samplesize1*p],postodelete); // delete in data[row] the elements indicated by the indexes in postodelete

        } // close for sample

    // delete sites with major unknown allele
        del_elements(snpfreqs[p],postodelete); // if the positions is too higher for a given population then is ignored
        del_elements(snpositions[p],postodelete);

       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

    } // close for p

    /// Delete positions fixed with the same allele in both populations

    assert((int)data.size()==totsamplesize);
    assert(snpfreqs[0].size()==snpfreqs[1].size());
    assert(snpositions[0].size()==snpfreqs[0].size());


    return true;
}


///Filter Fasta
/** March 2024. Basado en la pipeline de nextclade para comprobar calidad de secuencias (versión de consola):

https://clades.nextstrain.org/
USAGE: https://docs.nextstrain.org/projects/nextclade/en/stable/user/nextclade-cli/usage.html

 Esta version lee un fichero en formato csv (separado por punto y coma o por coma) generado por nextclade que contiene las siguientes 26 columnas
 index; seqName; clade;Nextclade_pango;partiallyAliased;clade_nextstrain;clade_who;clade_display;qc.overallScore;qc.overallStatus; \
 totalSubstitutions;totalDeletions;totalInsertions;totalFrameShifts;totalMissing;totalNonACGTNs;totalAminoacidSubstitutions;totalAminoacidDeletions;totalAminoacidInsertions; \
totalUnknownAa;	alignmentScore;	alignmentStart;	alignmentEnd;	coverage;	isReverseComplement;substitutions


La función va a analizar la columna qc.overallStatus y si el valor contenido no es good (puede ser mediocre o bad) va a cargar un unordered_set con los nombres de esas secuencias
(contenido de la columna seqName). Así mismo da la opción de escribir estos nombres en un fichero.


**/


bool  SNPSelTools::filterfasta(const string& tag,const bool& store,const bool& nogaps, const string& path,const string& filename0,  vector<int>& samplesizes,deque < deque<bool> >& data, vector < vector<double> >& snpfreqs,vector < vector<double> >& snpositions, int& pref)
{

    /// Open file

    int tries=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size


	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}


    bool tagpop=false;
    int numpopulations(0), numsamples(0);
    string temp="";
	vector<string> sequences1, names1; // first store the sequences then transform to data, positions and frequencies
	vector<string> sequences2,names2;
	datafile >> boolalpha;
	//cout<<boolalpha;

    datafile.clear();

// skip blank lines and commentaries i.e. lines beginning with comment_tag
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank lines
        getline(datafile,temp);
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

    if(temp[0]=='>'){
        numsamples=1;
        if(ToLowerCase(temp).find(tag)!=std::string::npos){
            tagpop=true;
            names1.push_back(temp);
        }
        else{
            names2.push_back(temp);
        }

    }
    else{
        string msg = "\nEmpty file or wrong format when reading fasta "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

// Read lines skiping lines with '>' the identifier for sequence names
    string line="";
    do{
        getline(datafile, temp);

        if(!temp.empty()){
            if(temp[0]!='>'){

        // Feb 2024 remove spaces is the format is in triplets e.g. act acc tgt..
            clean_spaces(temp);
        // uppercase
                transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
                line+=temp;

            }
            else{
                if(!line.empty()){
                    if(tagpop)
                        sequences1.push_back(line);
                    else
                        sequences2.push_back(line);

                    line="";
                }
                ++numsamples;

                if(ToLowerCase(temp).find(tag)!=std::string::npos){
                    tagpop=true;
                    names1.push_back(temp);
                }
                else{
                    tagpop=false;
                    names2.push_back(temp);
                }
            }
        }


    }while(!datafile.eof() );
    // add the last line
    if(tagpop)
        sequences1.push_back(line);
    else
        sequences2.push_back(line);



    assert(sequences1.size()==names1.size());
    assert(sequences2.size()==names2.size());
    /// Calculate sample sizes
    samplesizes={(int)sequences1.size(),(int)sequences2.size()};
    /// Join the sequences (see https://stackoverflow.com/questions/3177241/what-is-the-best-way-to-concatenate-two-vectors)
    vector<string> sequences;
    sequences.reserve( samplesizes[0] + samplesizes[1] ); // preallocate memory
    sequences.insert( sequences.end(), sequences1.begin(), sequences1.end() );
    sequences.insert( sequences.end(), sequences2.begin(), sequences2.end() );

    if(sequences[0].size() > (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: Sequence too large in file "+ filename0+ "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

    if(sequences1.empty() || sequences2.empty() )
	{
		string msg = "\nERROR: The tag did not separate two populations\n";
		cout<<msg<<endl;

		cout<<tag<<"\t"<<sequences1.size()<<"\t"<<sequences2.size()<<"\t"<<sequences.size() <<endl;

		return false;

	}

	numpopulations = 2;

assert(numsamples==(int)sequences.size());

    if(sequences[0].size()!= sequences[samplesizes[0]].size()){ // the sequences must be aligned and have the same sample size
        string msg = "ERROR: sequences must be aligned in "+ filename0 + "\n";
        cout<<msg<<endl;
        texterr(0,msg,true);
    }

// redimension the snpfreqs and snpositions vector
    snpfreqs.resize(numpopulations);
    snpositions.resize(numpopulations);
    string major="";

    for(auto p=0; p<numpopulations; ++p){
        snpfreqs[p].resize(sequences[samplesizes[0]*p].size(),0);
        snpositions[p].resize(sequences[samplesizes[0]*p].size(),-1);
    }
  // transform the sequences in data. For each position the most frequent allele will be noted as '0' while any alternate as '1'
    vector<int> contnuc(5); // 0 for A, 1 C, 2G, 3 T, 4 N

    vector<int> postodelete;

    /// we  use the population with the largest sample size to set the major reference sequence
    pref= samplesizes[0]>=samplesizes[1]?0:1;

  // the major reference sequence is defined with respect the population pref
   // for each position
    for(size_t pos=0; pos< snpfreqs[pref].size();++pos){
        bool foundgap=false;
        for(auto s=0; s<samplesizes[pref]; ++s){

            const char element = sequences[s+samplesizes[0]*pref][pos];

            if(element=='A')
                ++contnuc[0];
            else
            if(element=='C')
                ++contnuc[1];
            else
            if(element=='G')
                ++contnuc[2];
            else
            if(element=='T')
                ++contnuc[3];
            else
            if(element=='-' && nogaps){
                postodelete.push_back(pos);
                foundgap=true;
                break;
            }
            else{
            //if(sequences[s +samplesize*pref][pos]=='N')
                sequences[s +samplesizes[0]*pref][pos]='N'; ///Feb 2024 homogenize gaps or whatever to the symbol N
                ++contnuc[4];
            }

        } // close for sample

        if(!foundgap){
            auto maxeliter = max_element(contnuc.begin(), contnuc.end());
            switch (distance(contnuc.begin(),maxeliter)){ // the most frequent is
                case 0: major+="A"; break;
                case 1: major+="C"; break;
                case 2: major+="G"; break;
                case 3: major+="T"; break;
                case 4: major+="N"; postodelete.push_back(pos); break;
            }
        } // close if not foundgap
        else{
            major+="-";
        }
    // reset nucleotide counts for each position
        contnuc.assign(contnuc.size(),0);
    } // close for positions

    // check
    for(auto s=0; s<samplesizes[pref]; ++s){
        //cout<<sequences[s +samplesize*pref].size()<<"\t"<<major.size()<<endl;
        assert(sequences[s +samplesizes[0]*pref].size() == major.size() );
    }

/// Gather the information for data etc: if the sequences length are different in the populations then positions are considered to begin at 0 in every population so that the difference is at the ending positions
  	data.clear();
    data.resize(samplesizes[0]+samplesizes[1]);

    for(auto p=0; p<numpopulations; ++p){

        for(auto s=0; s<samplesizes[p]; ++s){

            data[s +samplesizes[0]*p].resize(snpfreqs[p].size(),false);

            for(size_t pos=0; pos < snpfreqs[p].size(); ++pos){

                const char element = sequences[s+samplesizes[0]*p][pos];
                const bool is_in = nucleotides.find(string(1,element)) != nucleotides.end();
                if( (element != major[pos]) && (is_in) ){ // for the pref pop the major allele is 0 and the minor is 1. For the other populations 1 will the allele that matches with the minor in pref. if the allele is N count as major one. If the majority of samples in a position have N this position will be deleted
                    data[p*samplesizes[0] + s][pos]=true;
                   // the frequency of the allele 1
                   snpfreqs[p][pos]++;
                }
                //FEB 2024
                //snpositions[p][pos] = ((double)pos) / largernumsnps;
                snpositions[p][pos] = ((double)pos);
            } // close for pos

//cout<<"Data size is "<<data[0].size()<<endl;
            del_elements(data[s+samplesizes[0]*p],postodelete); // delete in data[row] the elements indicated by the indexes in postodelete

//cout<<"Data size is "<<data[0].size()<<" and pos deleted size were "<<postodelete.size()<<endl;
//exit(1);
        } // close for sample

    // delete sites with major unknown allele
        del_elements(snpfreqs[p],postodelete); // if the positions is too higher for a given population then is ignored
        del_elements(snpositions[p],postodelete);

       // frequencies are relative to sample size
        for_each(snpfreqs[p].begin(), snpfreqs[p].end(), [=](double& freq){freq/= (samplesizes[p]);});

    } // close for p


    if(store){ // store the separated data in two files

        string filename2=substring(filename0, ".", true, true); // sequence names without tag
        string filename1=filename2+"_"+tag+".fas"; //sequence names with tag

        filename2+="_NON_"+tag+".fas";

        ofstream out1((path+filename1).c_str(),ios::out);

        for(int seq=0; seq<(int)sequences1.size();++seq){
            out1<<names1[seq]<<"\n"<<sequences1[seq]<<endl;
        }

        ofstream out2((path+filename2).c_str(),ios::out);

        for(int seq=0; seq<(int)sequences2.size();++seq){
            out2<<names2[seq]<<"\n"<<sequences2[seq]<<endl;
        }
    }

    return true;
}



// read PLINK format when the genotypes are nucleotides
bool  SNPSelTools::readplinkdata(const string& path,const string& filename_map,const string& filename_ped, const int& numpops, vector<vector<double>>& positions, vector<int>& samplesizes,vector<vector<vector<float>>>& alfreqs,vector<vector<float>>&majoralfreqs,vector<vector<vector<uint_fast32_t>>>& alelids,const uint_fast8_t diploid, vector<string>& locnames)
{

    /// Open file

    int tries=0;

	string filename=path+filename_map;
	ifstream datafile; //ifstream will be opened for reading

/// ********************************* map file
	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open map file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find map input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

    if(!positions.empty())
        positions.clear();

    positions.resize(numpops);

    if(!locnames.empty())
        locnames.clear();

    // Read the map file: 4 columns: chromosome, marker id, genetic distance and physical position
    datafile.clear();
    string temp{""};
    vector<string> words;
    try{
    // skip blank lines
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank or comment lines
        getline(datafile,temp); // the first non-empty line can be skipped because contains information about data
        trim_left(temp);
    }

    if(datafile.eof()){
        string msg = "\nERROR: empty map file "+ filename+"\n";
        cout<<msg<<endl;
        return false; // empty map file
    }


    words=get_words(temp);

//    if(words[0][0]=='#'){
//
//        do{
//            getline(datafile,temp);
//            words=get_words(temp);
//        }while(words[0][0]=='#');
//
//    }

    if(words.size()>4 || words.size()<3){
        string msg = "\nERROR: problem reading map file "+ filename+" . Num of columns were "+(NtoS(words.size()))+"\n";
        cout<<msg<<endl;
        return false;

    }else{

        if(words.size()==4){ // there is genetic distance information
            //words[0]; // chromosome
            locnames.push_back(words[1]); // SNP id
            //words[2]; // genetic distance
            positions[0].push_back(atof(words[3].c_str())); // physical position
            do{
                getline(datafile, temp);
                trim_left(temp);
                if(!temp.empty()&& temp.find(comment_tag)!=0){
                    words=get_words(temp);
                    if(words.size()!=4){
                        string msg = "\nERROR: problem reading map file "+ filename+" . Num of columns were "+(NtoS(words.size()))+"\n";
                        cout<<msg<<endl;
                        return false;

                    }
                    locnames.push_back(words[1]); // SNP id
                    positions[0].push_back(atof(words[3].c_str())); // physical position
                } // close temp is not empty

            }while(!datafile.eof() );
            positions[1] = positions[0];
        } // close word size is 4
        else
        if(words.size()==3){ // there is not genetic distance information
            //words[0]; // chromosome
            locnames.push_back(words[1]); // SNP id
            positions[0].push_back(atof(words[2].c_str())); // physical position
            do{
                getline(datafile, temp);
                trim_left(temp);
                if(!temp.empty()&& temp.find(comment_tag)!=0){
                    words=get_words(temp);
                    if(words.size()!=3){
                        string msg = "\nERROR: problem reading map file "+ filename+" . Num of columns were "+(NtoS(words.size()))+"\n";
                        cout<<msg<<endl;
                        return false;

                    }
                    locnames.push_back(words[1]); // SNP id
                    positions[0].push_back(atof(words[2].c_str())); // physical position
                } // close temp is not empty

            }while(!datafile.eof() );
            positions[1] = positions[0];
        } // close word size is 3

    } // close else

    if(locnames.size()> (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename_map+ "\n";
        throw(overflow_error(msg));
//        cout<<msg<<endl;
  //      texterr(0,msg,true);
    }

    datafile.close();

    } // close try
    catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
    } catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename_map <<endl;
    return false;
    } catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename_map <<endl;
    return false;
    }


    tries=0;

/// ********************************** ped file

    filename=path+filename_ped;
	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find ped file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

//numcopies = 2N for diploids or N for haploids
// numalleles should be 2 for SNPs
    try{
    //double ploidy{static_cast<double>(diploid)+1};

    uint_fast32_t except{'N'}; // missing value if the genotype is in nucleotides
    //double snpfreq(0.0);
    //double numsnpsinsample(0.0);

	datafile >> boolalpha;
	//cout<<boolalpha;

	cout<<"------------------------------------------------\n"<<endl;
// ped file: populationID individualID paternalid maternalid sex phenotype genotypes: A T T T...
    datafile.clear();
    // skip blank lines or commentaries
    temp="";

    while( (temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank

        getline(datafile,temp); // the first non-empty line can be skipped because contains information about data

        trim_left(temp);

    }

    if(datafile.eof()){
        string msg = "\nERROR: empty ped file "+ filename+"\n";
        cout<<msg<<endl;
        return false; // empty map file
    }

    transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);

    words=get_words(temp);
    string popname=words[0];

    if(words.size()<8){ // six first columns are pop indiv dad mum sex phenotype, next 2 the first genotype
        string msg = "\nERROR: problem reading ped file "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

    int numloci = words.size()-6;

    if(numloci> (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename+ "\n";
        throw(overflow_error(msg));
//        cout<<msg<<endl;
  //      texterr(0,msg,true);
    }

    if(numloci%2 != 0){ // six first columns are pop indiv dad mum sex phenotype, next 2 the first genotype
        string msg = "\nERROR: wrong number of genotypes in ped file "+ filename+"\n";
        cout<<msg<<endl;
        return false;
    }

    numloci/=2;

    assert((int)locnames.size() == numloci);

    if(locnames.size()!=(size_t)numloci){ // six first columns are pop indiv dad mum sex phenotype, next 2 the first genotype
        string msg = "\nERROR: inconsistency between number of loci in map and ped files: "+ NtoS(locnames.size())+" vs "+NtoS(numloci)+"\n";
        cout<<msg<<endl;
        return false;
    }
    vector<vector<string>> datamatrix; // each string is a genotype i.e. pair of nucleotides. The inner dimension is the set of loci of the individual, the outer dimension are the individuals
    vector<string>loci(numloci);
    int l{0},samplesize{1}; // first individual use it to identify the kind of genotype of numeric or nucleotide

    if(isalpha(words[6][0])){ // check it is the nucleotide file
        for(size_t g=6; g < words.size(); g+=2){

            if( words[g]!="A" && words[g]!="C" && words[g]!="G" && words[g]!="T" )
                words[g]='N';
            if( words[g+1]!="A" && words[g+1]!="C" && words[g+1]!="G" && words[g+1]!="T" )
                words[g+1]='N';
            loci[l]=words[g]+words[g+1];
            ++l;
        }
    }
    else{

        string msg = "\nERROR: wrong plink nucleotide genotype format in ped file "+ filename+" have read "+NtoS(words[6][0])+"\n";
        cout<<msg<<endl;
        return false;

    }

    datamatrix.push_back(loci);


    if(!samplesizes.empty())
        samplesizes.clear();
    string line="";
    do{
        getline(datafile, temp);
        trim_left(temp);
        if(!temp.empty()&& temp.find(comment_tag)!=0){

            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
            words=get_words(temp);
            if(popname!=words[0]){
                samplesizes.push_back(samplesize);
                samplesize=1; // count the first individual in the new population
                popname=words[0];
            }
            else{
                ++samplesize;
            }
            l=0;
            for(size_t g=6; g < words.size(); g+=2){
                if( words[g]!="A" && words[g]!="C" && words[g]!="G" && words[g]!="T" )
                    words[g]='N';
                if( words[g+1]!="A" && words[g+1]!="C" && words[g+1]!="G" && words[g+1]!="T" )
                    words[g+1]='N';
                loci[l]=words[g]+words[g+1];
                ++l;
            }
            datamatrix.push_back(loci);

        } // close temp is not empty

    }while(!datafile.eof() );
    // the last population
    samplesizes.push_back(samplesize);

    assert(accumulate(samplesizes.begin(), samplesizes.end(),0) == ((int)datamatrix.size()) );
    assert(samplesizes.size()==(size_t)numpops);

	vector<vector<uint_fast32_t>>numallelesatloc; // num alleles at each loci at each population

    /// Identify num of alleles for each loci at each population
    numallelesatloc.resize(numloci,vector<uint_fast32_t>(numpops,0));

    //auto maxal = (2*samplesize);
    //uint_fast32_t refpop{0};

/// Compute allele frequencies for each locus in each population. The last dimension i.e. the number of alleles could be different at each loci for each population
    if(!alfreqs.empty()) alfreqs.clear();
    alfreqs.resize(numloci,vector<vector<float>>(numpops));

    if(!majoralfreqs.empty()) majoralfreqs.clear();
    majoralfreqs.resize(numloci,vector<float>(numpops));

    if(!alelids.empty()) alelids.clear();
    alelids.resize(numloci,vector<vector<uint_fast32_t>>(numpops)); // last dimension stores the allele ids and the dimension size corresponds to the number of alleles at each locus in each population

    float missingalfreq{0};

    vector<uint_fast32_t>alleles;
    int ini(0);
    for(auto p=0; p< numpops; ++p){ // for each pop
        alleles.resize(2*samplesizes[p]);

        for(auto l=0; l < numloci; ++l){ // for each locus
            auto ci=0;
            uint_fast32_t n=0; // to store sum of total alleles including the missing value
            for(auto i=0; i < (2*samplesizes[p]); i+=2){ // check the two alleles at each individual in the sample

                alleles[i] = datamatrix[ini + ci][l][0]; // could be 'A' 'G' 'C' 'T'
                alleles[i+1] = datamatrix[ini + ci][l][1];
                ++ci;
            }

            numallelesatloc[l][p] =count_distinct_els_andfreqs(alleles, except,alelids[l][p], alfreqs[l][p],n);

            missingalfreq = n-accumulate(alfreqs[l][p].begin(),alfreqs[l][p].end(),0);

//if(p==1)
//if(l==1){
//    for(auto a = 0; a < numallelesatloc[l][p]; ++a){
//        cout<< (int)alelids[l][p][a]<<"\t"<<alfreqs[l][p][a]<<endl;
//    }
//cout<<endl<<missingalfreq<<endl;
//}
            auto iterposmajor = max_element(begin(alfreqs[l][p]),end(alfreqs[l][p]));
            if(missingalfreq>= (samplesizes[p]-1)) // too many null alleles e.g in haploids all minus 1 in diploids half minus 1
                majoralfreqs[l][p] = MISSINGVAL;
            else{
                //for_each(alfreqs[l][p].begin(),alfreqs[l][p].end(),[=](float& element){element/=al;} ); // the missing alleles do not compute for the frequency
                majoralfreqs[l][p] = *iterposmajor;
            }

//if(p==1)
//if(l==1){
//    cout<<majoralfreqs[l][p]<<endl<<endl;
//    for(auto a = 0; a < numallelesatloc[l][p]; ++a){
//        cout<< (int)alelids[l][p][a]<<"\t"<<alfreqs[l][p][a]<<endl;
//    }
//exit(0);
//}

        } // close for loci


        alleles.clear();
        ini+=samplesizes[p];
    } // close for pop


//printcol(locnames);
//cout<<endl<<locnames[0]<<" "<<locnames[1]<<endl;
//exit(0);
    cout<<"Read "<<filename_map<<" and "<<filename_ped<<endl;
    } // close try
    catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
    } catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename_map <<endl;
    return false;
    } catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename_map <<endl;
    return false;
    }

    return true;
}



// read PLINK format when the genotypes are numbers
bool  SNPSelTools::readplinkdata2(const string& path,const string& filename_map,const string& filename_ped, const int& numpops, vector<vector<double>>& positions, vector<int>& samplesizes,vector<vector<vector<float>>>& alfreqs,vector<vector<float>>&majoralfreqs,vector<vector<vector<uint_fast32_t>>>& alelids,const uint_fast8_t diploid, vector<string>& locnames)
{

    /// Open file

    int tries=0;

	string filename=path+filename_map;
	ifstream datafile; //ifstream will be opened for reading

/// ********************************* map file
	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open map file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find map input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

    if(!positions.empty())
        positions.clear();

    positions.resize(numpops);

    if(!locnames.empty())
        locnames.clear();

    // Read the map file: 4 columns: chromosome, marker id, genetic distance and physical position
    datafile.clear();
    string temp{""};
    vector<string> words;
    try{
    // skip blank lines or commentaries
    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank or comment lines
        getline(datafile,temp); // the first non-empty line can be skipped because contains information about data
        trim_left(temp);
    }


    if(datafile.eof()){
        string msg = "\nERROR: empty map file "+ filename_map+"\n";
        cout<<msg<<endl;
        return false; // empty map file
    }


    words=get_words(temp);

//    if(words[0][0]=='#'){
//
//        do{
//            getline(datafile,temp);
//            words=get_words(temp);
//        }while(words[0][0]=='#');
//
//    }

    if(words.size()>4 || words.size()<3){
        string msg = "\nERROR: problem reading map file "+ filename_map+" . Num of columns were "+(NtoS(words.size()))+"\n";
        cout<<msg<<endl;
        return false;

    }else{

        if(words.size()==4){ // there is genetic distance information
            //words[0]; // chromosome
            locnames.push_back(words[1]); // SNP id
            //words[2]; // genetic distance
            positions[0].push_back(atof(words[3].c_str())); // physical position
            do{
                getline(datafile, temp);
                trim_left(temp);
                if(!temp.empty()&& temp.find(comment_tag)!=0){
                    words=get_words(temp);
                    if(words.size()!=4){
                        string msg = "\nERROR: problem reading map file "+ filename_map+" . Num of columns were "+(NtoS(words.size()))+"\n";
                        cout<<msg<<endl;
                        return false;

                    }
                    locnames.push_back(words[1]); // SNP id
                    positions[0].push_back(atof(words[3].c_str())); // physical position
                } // close temp is not empty

            }while(!datafile.eof() );
            positions[1] = positions[0];
        } // close word size is 4
        else
        if(words.size()==3){ // there is not genetic distance information
            words[0]; // chromosome
            locnames.push_back(words[1]); // SNP id
            positions[0].push_back(atof(words[2].c_str())); // physical position
            do{
                getline(datafile, temp);
                trim_left(temp);
                if(!temp.empty()&& temp.find(comment_tag)!=0){
                    words=get_words(temp);
                    if(words.size()!=3){
                        string msg = "\nERROR: problem reading map file "+ filename_map+" . Num of columns were "+(NtoS(words.size()))+"\n";
                        cout<<msg<<endl;
                        return false;

                    }
                    locnames.push_back(words[1]); // SNP id
                    positions[0].push_back(atof(words[2].c_str())); // physical position
                } // close temp is not empty

            }while(!datafile.eof() );
            positions[1] = positions[0];
        } // close word size is 3

    } // close else
    if(locnames.size()> (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename_map+ "\n";
        throw(overflow_error(msg));
//        cout<<msg<<endl;
  //      texterr(0,msg,true);
    }
    } // close try
    catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
    } catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename_map <<endl;
    return false;
    } catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename_map <<endl;
    return false;
    }
    datafile.close();
    tries=0;

/// ********************************** ped file

    filename=path+filename_ped;
	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find ped file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

//numcopies = 2N for diploids or N for haploids
// numalleles should be 2 for SNPs
    //double ploidy{static_cast<double>(diploid)+1.0};

    uint_fast32_t except{0}; // missing value if the genotype is a number
    //double snpfreq(0.0);
    //double numsnpsinsample(0.0);

	datafile >> boolalpha;
	//cout<<boolalpha;

	cout<<"------------------------------------------------\n"<<endl;
// ped file: populationID individualID paternalid maternalid sex phenotype genotypes: A T T T...
    datafile.clear();
    // skip blank lines or commentaries
    temp="";
    try{
    while( (temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){ // skip blank

        getline(datafile,temp); // the first non-empty line can be skipped because contains information about data

        trim_left(temp);

    }

    if(datafile.eof()){
        string msg = "\nERROR: empty ped file "+ filename_ped+"\n";
        cout<<msg<<endl;
        return false; // empty map file
    }

    transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);

    words=get_words(temp);
    string popname=words[0];

    if(words.size()<8){ // six first columns are pop indiv dad mum sex phenotype, next 2 the first genotype
        string msg = "\nERROR: problem reading ped file "+ filename_ped+"\n";
        cout<<msg<<endl;
        return false;
    }

    int numloci = words.size()-6;
    if(numloci%2 != 0){ // six first columns are pop indiv dad mum sex phenotype, next 2 the first genotype
        string msg = "\nERROR: wrong number of genotypes in ped file "+ filename_ped+"\n";
        cout<<msg<<endl;
        return false;
    }

    numloci/=2;

    assert((int)locnames.size() == numloci);

    if(numloci> (numeric_limits<int>::max()-1) ){
        string msg = "ERROR: There is an excessive number of SNPs in file "+ filename_ped+ "\n";
        throw(overflow_error(msg));
//        cout<<msg<<endl;
  //      texterr(0,msg,true);
    }
    if(locnames.size()!=(size_t)numloci){ // six first columns are pop indiv dad mum sex phenotype, next 2 the first genotype
        string msg = "\nERROR: inconsistency between number of loci in map and ped files: "+ NtoS(locnames.size())+" vs "+NtoS(numloci)+"\n";
        cout<<msg<<endl;
        return false;
    }
    vector<vector<genot>> datamatrix; // each string is a genotype i.e. pair of nucleotides. The inner dimension is the set of loci of the individual, the outer dimension are the individuals
    vector<genot>loci(numloci);
    int l{0},samplesize{1}; // first individual use it to identify the kind of genotype of numeric or nucleotide

    if(isdigit(words[6][0])){
       for(size_t g=6; g < words.size(); g+=2){
            loci[l].allel[0] = (atoi(words[g].c_str())); // transforms 001 in 1, 003 in 3 etc and then transform again the number into string
            loci[l].allel[1]= (atoi(words[g+1].c_str()));
            ++l;
       }
    }
    else{

        string msg = "\nERROR: wrong plink numeric genotype format in ped file "+ filename+" have read "+NtoS(words[6][0])+"\n";
        cout<<msg<<endl;
        return false;

    }

    datamatrix.push_back(loci);
    if(!samplesizes.empty())
        samplesizes.clear();
    string line="";
    do{
        getline(datafile, temp);
        trim_left(temp);
        if(!temp.empty()&& temp.find(comment_tag)!=0){

            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);
            words=get_words(temp);
            if(popname!=words[0]){
                samplesizes.push_back(samplesize);
                samplesize=1; // count the first individual in the new population
                popname=words[0];
            }
            else{
                ++samplesize;
            }
            l=0;
            for(size_t g=6; g < words.size(); g+=2){
                loci[l].allel[0] = (atoi(words[g].c_str())); // transforms 001 in 1, 003 in 3 etc and then transform again the number into string
                loci[l].allel[1]= (atoi(words[g+1].c_str()));
                ++l;
            }
            datamatrix.push_back(loci);

        } // close temp is not empty

    }while(!datafile.eof() );
    // the last population
    samplesizes.push_back(samplesize);

    assert(accumulate(samplesizes.begin(), samplesizes.end(),0) == (int)datamatrix.size() );
    assert((int)samplesizes.size()==numpops);

	vector<vector<uint_fast32_t>>numallelesatloc; // num alleles at each loci at each population

    /// Identify num of alleles for each loci at each population
    numallelesatloc.resize(numloci,vector<uint_fast32_t>(numpops,0));

    //auto maxal = (2*samplesize);
    //uint_fast32_t refpop{0};

/// Compute allele frequencies for each locus in each population. The last dimension i.e. the number of alleles could be different at each loci for each population
    if(!alfreqs.empty()) alfreqs.clear();
    alfreqs.resize(numloci,vector<vector<float>>(numpops));

    if(!majoralfreqs.empty()) majoralfreqs.clear();
    majoralfreqs.resize(numloci,vector<float>(numpops));

    if(!alelids.empty()) alelids.clear();
    alelids.resize(numloci,vector<vector<uint_fast32_t>>(numpops)); // last dimension stores the allele ids and the dimension size corresponds to the number of alleles at each locus in each population

    float missingalfreq{0};

    vector<uint_fast32_t>alleles;
    int ini(0);
    for(auto p=0; p< numpops; ++p){ // for each pop
        alleles.resize(2*samplesizes[p]);

        for(auto l=0; l < numloci; ++l){ // for each locus
            auto ci=0;
            uint_fast32_t n=0; // to store sum of total alleles including the missing value
            for(auto i=0; i < (2*samplesizes[p]); i+=2){ // check the two alleles at each individual in the sample

                alleles[i] = datamatrix[ini + ci][l].allel[0]; //
                alleles[i+1] = datamatrix[ini + ci][l].allel[1];
                ++ci;
            }

            numallelesatloc[l][p] =count_distinct_els_andfreqs(alleles, except,alelids[l][p], alfreqs[l][p],n);

            missingalfreq = n-accumulate(alfreqs[l][p].begin(),alfreqs[l][p].end(),0);

//if(p==1)
//if(l==1){
//    for(auto a = 0; a < numallelesatloc[l][p]; ++a){
//        cout<< (int)alelids[l][p][a]<<"\t"<<alfreqs[l][p][a]<<endl;
//    }
//cout<<endl<<missingalfreq<<endl;
//}
            auto iterposmajor = max_element(begin(alfreqs[l][p]),end(alfreqs[l][p]));
            if(missingalfreq>= (samplesizes[p]-1)) // too many null alleles e.g in haploids all minus 1 in diploids half minus 1
                majoralfreqs[l][p] = MISSINGVAL;
            else{
                //for_each(alfreqs[l][p].begin(),alfreqs[l][p].end(),[=](float& element){element/=al;} ); // the missing alleles do not compute for the frequency
                majoralfreqs[l][p] = *iterposmajor;
            }

//if(p==1)
//if(l==1){
//    cout<<majoralfreqs[l][p]<<endl<<endl;
//    for(auto a = 0; a < numallelesatloc[l][p]; ++a){
//        cout<< (int)alelids[l][p][a]<<"\t"<<alfreqs[l][p][a]<<endl;
//    }
//exit(0);
//}

        } // close for loci


        alleles.clear();
        ini+=samplesizes[p];
    } // close for pop


//printcol(locnames);
//cout<<endl<<locnames[0]<<" "<<locnames[1]<<endl;
//exit(0);
cout<<"Read "<<filename_map<<" and numeric "<<filename_ped<<endl;


    } // close try
    catch(const std::overflow_error& e) {
    cout<< e.what()<<endl;
    return false;
    } catch (const std::exception& ex) {
    // ...
    cout<<"An exception occurred when reading " + filename_ped <<endl;
    return false;
    } catch (...) {
    // ...
    cout<<"Unexpected problem occurred when reading " + filename_ped <<endl;
    return false;
    }

    return true;
}


/*
Formato BayeScan: no haplotype information

[loci]=3

[populations]=2

[pop]=1
// loc id, the pop number of alleles 2N, the number of alleles in the id loc, 0 and 4 are the observations for each allele in the locus
  1  4  2   0  4
  2  4  2   3  1
  3  4  2   2  2

[pop]=2
  1  4  2   0  4
  2  4  2   3  1
  3  4  2   2  2


*/
// No haplotype information
bool  SNPSelTools::readBSSNPdata(const string& path,const string& filename0,const int& numpops, vector<vector<vector<float>>>& alfreqs,vector<vector<float>>&majoralfreqs,const uint_fast8_t diploid, vector<string>& locnames)
{

    /// Open file

    int tries=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size


	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}


//numcopies = 2N for diploids or N for haploids
// numalleles should be 2 for SNPs
    int ploidy=diploid+1;
    int numloci(0), numpopulations(0), numcopies(0),numalleles(0);

    //double numsnpsinsample(0.0);
    string temp;
	vector<string> words;
	datafile >> boolalpha;
	//cout<<boolalpha;

	if(!datafile.eof())
	{
		datafile.clear();
		temp.clear();
		words.clear();

		// Read lines until '[' the first char of [loci]
		do{
            getline(datafile, temp);
            trim_left(temp);
		}while((temp[0]!='[') && !datafile.eof() );

        if(datafile.eof()) return false;

        words=get_words(temp,'=');
        numloci = atoi(words.back().c_str()); // this can be changed if some loci are fixed at a given population

        if(numloci> (numeric_limits<int>::max()-1) ){
            string msg = "ERROR: There is an excessive number of loci in file "+ filename0+ "\n";
            //throw(overflow_error(msg));
            cout<<msg<<endl;
            texterr(0,msg,true);
        }

        // Read lines until '[' the first char of [populations]
		do{
            getline(datafile, temp);
            trim_left(temp);
		}while((temp[0]!='[') && !datafile.eof() );

        if(datafile.eof()) return false;

        words.clear();
        words=get_words(temp,'=');
        numpopulations = atoi(words.back().c_str());

        if(numpops!=numpopulations){

            string msg = "ERROR reading BScan format: Number of populations is "+ NtoS(numpopulations)+" but should be "+NtoS(numpops) + "\n";
            cout<<msg<<endl;
            texterr(1,msg,true);

        }

/// Compute allele frequencies for each locus in each population. The last dimension i.e. the number of alleles could be different at each loci for each population
        if(!alfreqs.empty()) alfreqs.clear();
        alfreqs.resize(numloci,vector<vector<float>>(numpopulations));

        if(!majoralfreqs.empty()) majoralfreqs.clear();
        majoralfreqs.resize(numloci,vector<float>(numpopulations));

        if(!locnames.empty()) locnames.clear();
        locnames.resize(numloci);

        // should have read [pop]=1
        int checknpops{0};
        for(auto p=0; p<numpopulations; ++p){

        // skip blank lines
            temp.clear();
            while(temp.empty()){ // skip blank lines
                getline(datafile,temp);
                trim_left(temp);
            }

            words=get_words(temp,'=');
            if(words[0]=="[pop]"){
                ++checknpops;
                for(auto l=0; l< numloci; ++l){ // read numloci

                    getline(datafile,temp);
                    words = get_words(temp);
                    if(words.empty()){
                        string msg = "ERROR reading BScan format in loci "+ NtoS(l+1)+" of population "+NtoS(p+1) + "\n";
                        cout<<msg<<endl;
                        texterr(1,msg,true);
                    }
                    if(atoi(words[0].c_str())!= (l+1)) // check each locus number
                    {
                        string msg = "ERROR reading BScan format: Loci number was "+ words[0]+" should be "+NtoS(l+1) + "\n";
                        cout<<msg<<endl;
                        texterr(1,msg,true);
                    }
                    else{ // check allelic frequency
                        if(p==0) // loci names are the same for every pop
                            locnames[l]=words[0];

                        numcopies = atoi(words[1].c_str()); // == (diploid+1)*samplesize

                        numalleles= atoi(words[2].c_str()); //


                        if( (ploidy%2 && (!(numcopies%2))) )
                        {
                            string msg = "ERROR reading BScan format: Sample size is "+ NtoS((float)numcopies/ (ploidy)) + "\n";
                            cout<<msg<<endl;
                            texterr(2,msg,true);
                        }

                        for(auto al=0;al<numalleles;++al){

                            alfreqs[l][p].push_back(atof(words[3+al].c_str()));

                        }

                        double totsnpfreq{accumulate(begin(alfreqs[l][p]),end(alfreqs[l][p]),0.0)};

                        if( totsnpfreq  != numcopies)
                        {
                            string msg = "ERROR reading BScan format: Total alleles are "+ NtoS(numcopies) + " should be " + NtoS(totsnpfreq) + "\n";
                            cout<<msg<<endl;
                            texterr(3,msg,true);
                        }


                        auto iterposmajor = max_element(begin(alfreqs[l][p]),end(alfreqs[l][p]));

                        majoralfreqs[l][p] = *iterposmajor;

//cout<<p<<"\t"<<l<<"\t"<<majoralfreqs[l][p]<<endl;

                    }


                } // close for numloci
            } // close if words[0]== pop

        } // close for numpopulations

        if(numpops!=checknpops){

            string msg = "ERROR reading BScan format: Read "+ NtoS(checknpops)+" populations but should be "+NtoS(numpops) + "\n";
            cout<<msg<<endl;
            texterr(1,msg,true);

        }

      // Reach the end of the document
      	do{
            getline(datafile, temp);
		}while( !datafile.eof() );

	} // close if !datafile eof

cout<<"Read "<<filename<<endl;

    return true;
}



/*
genpop format: no haplotype information

para el genotipo pueden usarse 2 o 3 digitos i.e 0101 o 001001 son homozigotos para 01 y 001. El valor 0000 ó 000000 es missing value
Los loci pueden estar indicados arriba en una fila o una en cada fila tipo:
Loc1
Loc2
Loc3
.
.
POP
------------- The file starts here ----------------
Microsat on Chiracus radioactivus, a pest species
     Loc1, Loc2, Loc3, Y-linked, Loc4
POP
AA8, 004005 0711 0304 0000      0505
AA9, 0405 0609 0208 0000      0505
A10, 0205 0609 0101 0000      0305
Pop
AF, 0000 0000 0000 0000      0505
AF, 0205 0307 0102 0000      0505
pop
C45, 0505 0606 0202 0000      0505
C45, 0505 0909 0202 0000      0505

*/

// In this version each population can has its own sample size which is stored in vector sample sizes
// As with bayescan format we have no haplotypes and just consider the frequencies here just to run the EOT test
// in vector<string> locnames is the vector of loci names which are the same for every population
/// Nov 2019: check that not more than 2 pops are read
bool  SNPSelTools::readgenpopdata(const string& path,const string& filename0, vector<int>& samplesizes,vector<vector<vector<float>>>& alfreqs,vector<vector<float>>&majoralfreqs,vector<vector<vector<uint_fast32_t>>>& alelids, const uint_fast8_t diploid, vector<string>& locnames)
{

    /// Open file

    int tries=0;

	string filename=path+filename0;
	ifstream datafile; //ifstream will be opened for reading

	// data will be a matrix of bools with variable lenght column in different pops
	// and as much as rows as numpops x sample size

	// check input file name
	do{
		datafile.clear();
		datafile.open(filename.c_str());
		if(!datafile.fail())
		{
			tries=0;
			break; // the open file operation succeed
		}
		else{
            cout<<"\nCould not open file: "<<filename<<endl;
			switch(tries){
				case 0:	transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) tolower);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				case 1: transform(filename.begin(),filename.end(), filename.begin(), (int(*)(int)) toupper);
cout<<"\nTRYING FILE NAME "<<filename<<endl;
						tries++;
						break;
				default: tries++;
			}

		}

	}while(tries<openfiletries);

	if(tries>=openfiletries)
	{
		string msg = "\nERROR: can not find input file after "+ NtoS(tries+1)+" tries\n";
		cout<<msg<<endl;
		return false;

	}

//numcopies = 2N for diploids or N for haploids
// numalleles should be 2 for SNPs
    //double ploidy{static_cast<double>(diploid)+1};
    int numloci(0), numpopulations(0);
    int samplesize(0);
    uint_fast32_t except{0}; // genpop allele missing value
    //double snpfreq(0.0);
    //double numsnpsinsample(0.0);
    string temp{""};

	vector<string> words;
	vector<vector<genot>> datamatrix; // each genot is 2 (diploid=2) alleles each column is locus each row individual
	datafile >> boolalpha;
	//cout<<boolalpha;

    if(!locnames.empty())
        locnames.clear();

    datafile.clear();
    // skip blank lines and commentaries

    while((temp.empty()||temp.find(comment_tag)==0) && !datafile.eof() ){
        getline(datafile,temp); // the first non-empty and no commentary line can also be skipped because contains information about data
        trim_left(temp);
    }

    if(datafile.eof()) return false; // the file is empty

// Read lines identifying each pop
    samplesizes.clear();
    string line="";
    do{
        getline(datafile, temp);
        trim_left(temp);
        if(!temp.empty() && temp.find(comment_tag)!=0 ){

            if(numpopulations==0){ // loci names
                words=get_words(temp,',');
                string wordpop{""};
                if(words.size()==1){
                    wordpop = words[0];
                    transform(wordpop.begin(),wordpop.end(), wordpop.begin(), (int(*)(int)) toupper);
                }

                if(wordpop.find("POP")==string::npos) // the word is not POP
                    for(auto& word: words) // This work under both cases 1)if loci names are separated by commas they are all in a row, 2) if not, the size of each row will be one but would be many lines before the word POP
                        locnames.push_back(word);
            }

            transform(temp.begin(),temp.end(), temp.begin(), (int(*)(int)) toupper);

            if(temp.find("POP")!=string::npos){ // it found POP
                if(numpopulations>1){
                    string msg = "\nERROR reading genpop format: Only two populations are allowed and found "+ NtoS(numpopulations +1)+ "\n";
                    cout<<msg<<endl;
                    texterr(numpopulations+1,msg,true);
                }

                if(numpopulations) {samplesizes.push_back(samplesize);samplesize=0;} // if 1st population was read then store the sample size of this population, the last is stored in line 3135
                ++numpopulations;

            }
            else{
                if(numpopulations){ // this means that the lines previous first pop have been skipped now read individuals from the population until next POP

                    // get the words the first word separated by comma is the name, the second word if separated by spaces are the loci
                    words=get_words(temp,',');
                    if(words.size()!=2){
                        string msg = "ERROR reading genpop format: When separating loci names word number was "+ NtoS(words.size())+" should be 2"+ "\n";
                        cout<<msg<<endl;
                        texterr(1,msg,true);
                    }
                    temp=words[1]; // these are the loci
                    words=get_words(temp);
                    if(numpopulations==1 && samplesize==0) {
                        numloci = words.size();

                        if(numloci> (numeric_limits<int>::max()-1) ){
                            string msg = "ERROR: There is an excessive number of loci in file "+ filename0+ "\n";
                            //throw(overflow_error(msg));
                            cout<<msg<<endl;
                            texterr(0,msg,true);
                        }
                    }
                    else assert(numloci== (int)words.size());

                    // each word is a loci genotype. For each loci we need to know the number of alleles and the frequencies
                    vector<genot> g;

                    for(auto w: words){ // store the genotypes
                        // first half of the word is one allele: atoi(w.substr(0,w.size()/2).c_str());
                        // second half is the other allele: atoi(w.substr(w.size()/2).c_str());
//cout<<atoi(w.substr(0,w.size()/2).c_str())<<"\t"<<atoi(w.substr(w.size()/2).c_str())<<endl;
                        g.push_back(genot(atoi(w.substr(0,w.size()/2).c_str()), atoi(w.substr(w.size()/2).c_str()) ) );
                    }

                    // count new indiv
                    datamatrix.push_back(g );
                    ++samplesize;
                    g.clear();
                    vector<genot>().swap(g);
                }
            }
        } // close temp is not empty

    }while(!datafile.eof() );
    // the last population
    samplesizes.push_back(samplesize); //store the sample size of the last population

    //assert(samplesize == (datamatrix.size()/numpopulations) );
    assert((int)samplesizes.size()==numpopulations);

	vector<vector<uint_fast32_t>>numallelesatloc; // num alleles at each loci at each population
	//vector<vector<uint_fast8_t>>majorallelesatloc; // major frequency allele at each locus in each population

    /// Identify num of alleles for each loci at each population
    numallelesatloc.resize(numloci,vector<uint_fast32_t>(numpopulations,0));
    //majorallelesatloc.resize(numloci,vector<uint_fast8_t>(numpopulations,0));

    //auto maxal = (2*samplesize);
    //uint_fast32_t refpop{0};

/// Compute allele frequencies for each locus in each population. The last dimension i.e. the number of alleles may be different at each loci for each population
    if(!alfreqs.empty()) alfreqs.clear();
    alfreqs.resize(numloci,vector<vector<float>>(numpopulations));

    if(!majoralfreqs.empty()) majoralfreqs.clear();
    majoralfreqs.resize(numloci,vector<float>(numpopulations));

    if(!alelids.empty()) alelids.clear();
    alelids.resize(numloci,vector<vector<uint_fast32_t>>(numpopulations)); // last dimension stores the allele ids and the dimension size corresponds to the number of alleles at each locus in each population

    float missingalfreq{0};

    vector<uint_fast32_t>alleles;
    int ini(0);
    for(auto p=0; p< numpopulations; ++p){ // for each pop
        alleles.resize(2*samplesizes[p]);

        for(auto l=0; l < numloci; ++l){ // for each locus
            auto ci=0;
            uint_fast32_t n=0;
            for(auto i=0; i < (2*samplesizes[p]); i+=2){ // check the two alleles at each individual in the sample

                alleles[i] = datamatrix[ini + ci][l].allel[0];
                alleles[i+1] = datamatrix[ini + ci][l].allel[1];
                ++ci;
            }
            //numallelesatloc[p][l] = count_distinct_els(alleles,except);

            numallelesatloc[l][p] =count_distinct_els_andfreqs(alleles, except,alelids[l][p], alfreqs[l][p],n);

            missingalfreq = n-accumulate(alfreqs[l][p].begin(),alfreqs[l][p].end(),0);



//if(p==1)
//if(l==1){
//    for(auto a = 0; a < numallelesatloc[l][p]; ++a){
//        cout<< (int)alelids[l][p][a]<<"\t"<<alfreqs[l][p][a]<<endl;
//    }
//cout<<endl<<missingalfreq<<endl;
//}
            auto iterposmajor = max_element(begin(alfreqs[l][p]),end(alfreqs[l][p]));
            if(missingalfreq>= (samplesizes[p]-1)) // too many null alleles e.g in haploids all minus 1 in diploids half minus 1
                majoralfreqs[l][p] = MISSINGVAL;
            else{
                //for_each(alfreqs[l][p].begin(),alfreqs[l][p].end(),[=](float& element){element/=al;} ); // the missing alleles do not compute for the frequency

                majoralfreqs[l][p] = *iterposmajor;
            }

//if(p==1)
//if(l==1){
//    cout<<majoralfreqs[l][p]<<endl<<endl;
//    for(auto a = 0; a < numallelesatloc[l][p]; ++a){
//        cout<< (int)alelids[l][p][a]<<"\t"<<alfreqs[l][p][a]<<endl;
//    }
//exit(0);
//}

        } // close for loci


        alleles.clear();
        ini+=samplesizes[p];
    } // close for pop


//printcol(locnames);
//cout<<endl<<locnames[0]<<" "<<locnames[1]<<endl;
//exit(0);
cout<<"Read "<<filename<<endl;
    return true;
}



//void SNPSelTools::texterr(const int val,const string error_txt,bool finish)
//{
///*
//	Author: ACR
//	Writes in ERROR.txt the error message 'error_txt'
//*/
//	if(finish){
//        printval<int>(val,error_txt,"iHDSel_ERROR.log");
//        exit(val);
//
//	}
//	else{
//        string name("iHDSel.log");
//        printval<int>(val,error_txt,name);
//	}
//}

/// 28 abril 2026

void SNPSelTools::texterr(const int val, const string error_txt, bool finish)
{
/*
	Author: ACR
	Writes in ERROR.txt the error message 'error_txt'
*/
    const string name = finish ? "iHDSel_ERROR.log" : "iHDSel.log";

    printval<int>(val, error_txt, name);

    if (finish) {
        std::exit(val);
    }
}



