+/**************************************************************************************************/
+//custom data structure for threads to use.
+// This is passed by void pointer so it can be any data type
+// that can be passed using a single void pointer (LPVOID).
+struct preClusterData {
+ string fastafile;
+ string namefile;
+ string groupfile, countfile;
+ string newFName, newNName, newMName;
+ MothurOut* m;
+ int start;
+ int end;
+ int diffs, threadID;
+ vector<string> groups;
+ vector<string> mapFileNames;
+ bool topdown;
+
+ preClusterData(){}
+ preClusterData(string f, string n, string g, string c, string nff, string nnf, string nmf, vector<string> gr, MothurOut* mout, int st, int en, int d, bool td, int tid) {
+ fastafile = f;
+ namefile = n;
+ groupfile = g;
+ newFName = nff;
+ newNName = nnf;
+ newMName = nmf;
+ m = mout;
+ start = st;
+ end = en;
+ diffs = d;
+ threadID = tid;
+ groups = gr;
+ countfile = c;
+ topdown = td;
+ }
+};
+
+/**************************************************************************************************/
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+#else
+static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){
+ preClusterData* pDataArray;
+ pDataArray = (preClusterData*)lpParam;
+
+ try {
+
+ //parse fasta and name file by group
+ SequenceParser* parser;
+ SequenceCountParser* cparser;
+ if (pDataArray->countfile != "") {
+ cparser = new SequenceCountParser(pDataArray->countfile, pDataArray->fastafile);
+ }else {
+ if (pDataArray->namefile != "") { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile); }
+ else { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile); }
+ }
+
+ int numSeqs = 0;
+ vector<seqPNode> alignSeqs;
+ //clear out old files
+ ofstream outF; pDataArray->m->openOutputFile(pDataArray->newFName, outF); outF.close();
+ ofstream outN; pDataArray->m->openOutputFile(pDataArray->newNName, outN); outN.close();
+
+ //precluster each group
+ for (int k = pDataArray->start; k < pDataArray->end; k++) {
+
+ int start = time(NULL);
+
+ if (pDataArray->m->control_pressed) { delete parser; return 0; }
+
+ pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Processing group " + pDataArray->groups[k] + ":"); pDataArray->m->mothurOutEndLine();
+
+ map<string, string> thisNameMap;
+ vector<Sequence> thisSeqs;
+ if (pDataArray->groupfile != "") {
+ thisSeqs = parser->getSeqs(pDataArray->groups[k]);
+ }else if (pDataArray->countfile != "") {
+ thisSeqs = cparser->getSeqs(pDataArray->groups[k]);
+ }
+ if (pDataArray->namefile != "") { thisNameMap = parser->getNameMap(pDataArray->groups[k]); }
+
+ //fill alignSeqs with this groups info.
+ ////////////////////////////////////////////////////
+ //numSeqs = loadSeqs(thisNameMap, thisSeqs); same function below
+
+ int length = 0;
+ alignSeqs.clear();
+ map<string, string>::iterator it;
+ bool error = false;
+ map<string, int> thisCount;
+ if (pDataArray->countfile != "") { thisCount = cparser->getCountTable(pDataArray->groups[k]); }