2 * preclustercommand.cpp
5 * Created by westcott on 12/21/09.
6 * Copyright 2009 Schloss Lab. All rights reserved.
10 #include "preclustercommand.h"
11 #include "deconvolutecommand.h"
13 //**********************************************************************************************************************
14 vector<string> PreClusterCommand::setParameters(){
16 CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
17 CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
18 CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
19 CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pdiffs);
20 CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
21 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
22 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
24 vector<string> myArray;
25 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
29 m->errorOut(e, "PreClusterCommand", "setParameters");
33 //**********************************************************************************************************************
34 string PreClusterCommand::getHelpString(){
36 string helpString = "";
37 helpString += "The pre.cluster command groups sequences that are within a given number of base mismatches.\n";
38 helpString += "The pre.cluster command outputs a new fasta and name file.\n";
39 helpString += "The pre.cluster command parameters are fasta, names and diffs. The fasta parameter is required. \n";
40 helpString += "The names parameter allows you to give a list of seqs that are identical. This file is 2 columns, first column is name or representative sequence, second column is a list of its identical sequences separated by commas.\n";
41 helpString += "The group parameter allows you to provide a group file so you can cluster by group. \n";
42 helpString += "The diffs parameter allows you to specify maximum number of mismatched bases allowed between sequences in a grouping. The default is 1.\n";
43 helpString += "The pre.cluster command should be in the following format: \n";
44 helpString += "pre.cluster(fasta=yourFastaFile, names=yourNamesFile, diffs=yourMaxDiffs) \n";
45 helpString += "Example pre.cluster(fasta=amazon.fasta, diffs=2).\n";
46 helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
50 m->errorOut(e, "PreClusterCommand", "getHelpString");
55 //**********************************************************************************************************************
56 PreClusterCommand::PreClusterCommand(){
58 abort = true; calledHelp = true;
60 vector<string> tempOutNames;
61 outputTypes["fasta"] = tempOutNames;
62 outputTypes["name"] = tempOutNames;
63 outputTypes["map"] = tempOutNames;
66 m->errorOut(e, "PreClusterCommand", "PreClusterCommand");
70 //**********************************************************************************************************************
72 PreClusterCommand::PreClusterCommand(string option) {
74 abort = false; calledHelp = false;
76 //allow user to run help
77 if(option == "help") { help(); abort = true; calledHelp = true; }
78 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
81 vector<string> myArray = setParameters();
83 OptionParser parser(option);
84 map<string, string> parameters = parser.getParameters();
86 ValidParameters validParameter;
87 map<string, string>::iterator it;
89 //check to make sure all parameters are valid for command
90 for (map<string, string>::iterator it2 = parameters.begin(); it2 != parameters.end(); it2++) {
91 if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) { abort = true; }
94 //initialize outputTypes
95 vector<string> tempOutNames;
96 outputTypes["fasta"] = tempOutNames;
97 outputTypes["name"] = tempOutNames;
98 outputTypes["map"] = tempOutNames;
100 //if the user changes the input directory command factory will send this info to us in the output parameter
101 string inputDir = validParameter.validFile(parameters, "inputdir", false);
102 if (inputDir == "not found"){ inputDir = ""; }
105 it = parameters.find("fasta");
106 //user has given a template file
107 if(it != parameters.end()){
108 path = m->hasPath(it->second);
109 //if the user has not given a path then, add inputdir. else leave path alone.
110 if (path == "") { parameters["fasta"] = inputDir + it->second; }
113 it = parameters.find("name");
114 //user has given a template file
115 if(it != parameters.end()){
116 path = m->hasPath(it->second);
117 //if the user has not given a path then, add inputdir. else leave path alone.
118 if (path == "") { parameters["name"] = inputDir + it->second; }
121 it = parameters.find("group");
122 //user has given a template file
123 if(it != parameters.end()){
124 path = m->hasPath(it->second);
125 //if the user has not given a path then, add inputdir. else leave path alone.
126 if (path == "") { parameters["group"] = inputDir + it->second; }
130 //check for required parameters
131 fastafile = validParameter.validFile(parameters, "fasta", true);
132 if (fastafile == "not found") {
133 fastafile = m->getFastaFile();
134 if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
135 else { m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
137 else if (fastafile == "not open") { abort = true; }
138 else { m->setFastaFile(fastafile); }
140 //if the user changes the output directory command factory will send this info to us in the output parameter
141 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
143 outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
146 //check for optional parameter and set defaults
147 // ...at some point should added some additional type checking...
148 namefile = validParameter.validFile(parameters, "name", true);
149 if (namefile == "not found") { namefile = ""; }
150 else if (namefile == "not open") { namefile = ""; abort = true; }
151 else { m->setNameFile(namefile); }
153 groupfile = validParameter.validFile(parameters, "group", true);
154 if (groupfile == "not found") { groupfile = ""; bygroup = false; }
155 else if (groupfile == "not open") { abort = true; groupfile = ""; }
156 else { m->setGroupFile(groupfile); bygroup = true; }
158 string temp = validParameter.validFile(parameters, "diffs", false); if(temp == "not found"){ temp = "1"; }
159 m->mothurConvert(temp, diffs);
161 temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); }
162 m->setProcessors(temp);
163 m->mothurConvert(temp, processors);
165 if (namefile == "") {
166 vector<string> files; files.push_back(fastafile);
167 parser.getNameFile(files);
172 catch(exception& e) {
173 m->errorOut(e, "PreClusterCommand", "PreClusterCommand");
177 //**********************************************************************************************************************
179 int PreClusterCommand::execute(){
182 if (abort == true) { if (calledHelp) { return 0; } return 2; }
184 int start = time(NULL);
186 string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
187 string newFastaFile = fileroot + "precluster" + m->getExtension(fastafile);
188 string newNamesFile = fileroot + "precluster.names";
189 string newMapFile = fileroot + "precluster.map"; //add group name if by group
190 outputNames.push_back(newFastaFile); outputTypes["fasta"].push_back(newFastaFile);
191 outputNames.push_back(newNamesFile); outputTypes["name"].push_back(newNamesFile);
195 //clear out old files
196 ofstream outFasta; m->openOutputFile(newFastaFile, outFasta); outFasta.close();
197 ofstream outNames; m->openOutputFile(newNamesFile, outNames); outNames.close();
198 newMapFile = fileroot + "precluster.";
200 //parse fasta and name file by group
201 SequenceParser* parser;
202 if (namefile != "") { parser = new SequenceParser(groupfile, fastafile, namefile); }
203 else { parser = new SequenceParser(groupfile, fastafile); }
205 vector<string> groups = parser->getNamesOfGroups();
207 if(processors == 1) { driverGroups(parser, newFastaFile, newNamesFile, newMapFile, 0, groups.size(), groups); }
208 else { createProcessesGroups(parser, newFastaFile, newNamesFile, newMapFile, groups); }
212 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
214 //run unique.seqs for deconvolute results
215 string inputString = "fasta=" + newFastaFile;
216 if (namefile != "") { inputString += ", name=" + newNamesFile; }
217 m->mothurOutEndLine();
218 m->mothurOut("/******************************************/"); m->mothurOutEndLine();
219 m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine();
220 m->mothurCalling = true;
222 Command* uniqueCommand = new DeconvoluteCommand(inputString);
223 uniqueCommand->execute();
225 map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
227 delete uniqueCommand;
228 m->mothurCalling = false;
229 m->mothurOut("/******************************************/"); m->mothurOutEndLine();
231 m->renameFile(filenames["fasta"][0], newFastaFile);
232 m->renameFile(filenames["name"][0], newNamesFile);
234 m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run pre.cluster."); m->mothurOutEndLine();
237 if (namefile != "") { readNameFile(); }
239 //reads fasta file and return number of seqs
240 int numSeqs = readFASTA(); //fills alignSeqs and makes all seqs active
242 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
244 if (numSeqs == 0) { m->mothurOut("Error reading fasta file...please correct."); m->mothurOutEndLine(); return 0; }
245 if (diffs > length) { m->mothurOut("Error: diffs is greater than your sequence length."); m->mothurOutEndLine(); return 0; }
247 int count = process(newMapFile);
248 outputNames.push_back(newMapFile); outputTypes["map"].push_back(newMapFile);
250 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
252 m->mothurOut("Total number of sequences before precluster was " + toString(alignSeqs.size()) + "."); m->mothurOutEndLine();
253 m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
254 printData(newFastaFile, newNamesFile);
256 m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
259 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
261 m->mothurOutEndLine();
262 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
263 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
264 m->mothurOutEndLine();
266 //set fasta file as new current fastafile
268 itTypes = outputTypes.find("fasta");
269 if (itTypes != outputTypes.end()) {
270 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
273 itTypes = outputTypes.find("name");
274 if (itTypes != outputTypes.end()) {
275 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
281 catch(exception& e) {
282 m->errorOut(e, "PreClusterCommand", "execute");
286 /**************************************************************************************************/
287 int PreClusterCommand::createProcessesGroups(SequenceParser* parser, string newFName, string newNName, string newMFile, vector<string> groups) {
290 vector<int> processIDS;
295 if (groups.size() < processors) { processors = groups.size(); }
297 //divide the groups between the processors
298 vector<linePair> lines;
299 int numGroupsPerProcessor = groups.size() / processors;
300 for (int i = 0; i < processors; i++) {
301 int startIndex = i * numGroupsPerProcessor;
302 int endIndex = (i+1) * numGroupsPerProcessor;
303 if(i == (processors - 1)){ endIndex = groups.size(); }
304 lines.push_back(linePair(startIndex, endIndex));
307 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
309 //loop through and create all the processes you want
310 while (process != processors) {
314 processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later
318 num = driverGroups(parser, newFName + toString(getpid()) + ".temp", newNName + toString(getpid()) + ".temp", newMFile, lines[process].start, lines[process].end, groups);
320 string tempFile = toString(getpid()) + ".outputNames.temp";
322 m->openOutputFile(tempFile, outTemp);
324 outTemp << outputNames.size();
325 for (int i = 0; i < outputNames.size(); i++) { outTemp << outputNames[i] << endl; }
330 m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine();
331 for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
337 num = driverGroups(parser, newFName, newNName, newMFile, lines[0].start, lines[0].end, groups);
339 //force parent to wait until all the processes are done
340 for (int i=0;i<processIDS.size();i++) {
341 int temp = processIDS[i];
345 for (int i = 0; i < processIDS.size(); i++) {
346 string tempFile = toString(processIDS[i]) + ".outputNames.temp";
348 m->openInputFile(tempFile, intemp);
352 for (int k = 0; k < num; k++) {
354 intemp >> name; m->gobble(intemp);
356 outputNames.push_back(name); outputTypes["map"].push_back(name);
359 m->mothurRemove(tempFile);
363 //////////////////////////////////////////////////////////////////////////////////////////////////////
364 //Windows version shared memory, so be careful when passing variables through the preClusterData struct.
365 //Above fork() will clone, so memory is separate, but that's not the case with windows,
366 //////////////////////////////////////////////////////////////////////////////////////////////////////
368 vector<preClusterData*> pDataArray;
369 DWORD dwThreadIdArray[processors-1];
370 HANDLE hThreadArray[processors-1];
372 //Create processor worker threads.
373 for( int i=1; i<processors; i++ ){
374 // Allocate memory for thread data.
375 string extension = toString(i) + ".temp";
377 preClusterData* tempPreCluster = new preClusterData(fastafile, namefile, groupfile, (newFName+extension), (newNName+extension), newMFile, groups, m, lines[i].start, lines[i].end, diffs, i);
378 pDataArray.push_back(tempPreCluster);
379 processIDS.push_back(i);
381 //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
382 //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
383 hThreadArray[i-1] = CreateThread(NULL, 0, MyPreclusterThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);
387 //using the main process as a worker saves time and memory
388 num = driverGroups(parser, newFName, newNName, newMFile, lines[0].start, lines[0].end, groups);
390 //Wait until all threads have terminated.
391 WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
393 //Close all thread handles and free memory allocations.
394 for(int i=0; i < pDataArray.size(); i++){
395 for (int j = 0; j < pDataArray[i]->mapFileNames.size(); j++) {
396 outputNames.push_back(pDataArray[i]->mapFileNames[j]); outputTypes["map"].push_back(pDataArray[i]->mapFileNames[j]);
398 CloseHandle(hThreadArray[i]);
399 delete pDataArray[i];
404 //append output files
405 for(int i=0;i<processIDS.size();i++){
406 //newFName = m->getFullPathName(".\\" + newFName);
407 //newNName = m->getFullPathName(".\\" + newNName);
409 m->appendFiles((newFName + toString(processIDS[i]) + ".temp"), newFName);
410 m->mothurRemove((newFName + toString(processIDS[i]) + ".temp"));
412 m->appendFiles((newNName + toString(processIDS[i]) + ".temp"), newNName);
413 m->mothurRemove((newNName + toString(processIDS[i]) + ".temp"));
419 catch(exception& e) {
420 m->errorOut(e, "PreClusterCommand", "createProcessesGroups");
424 /**************************************************************************************************/
425 int PreClusterCommand::driverGroups(SequenceParser* parser, string newFFile, string newNFile, string newMFile, int start, int end, vector<string> groups){
430 //precluster each group
431 for (int i = start; i < end; i++) {
435 if (m->control_pressed) { return 0; }
437 m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[i] + ":"); m->mothurOutEndLine();
439 map<string, string> thisNameMap;
440 if (namefile != "") { thisNameMap = parser->getNameMap(groups[i]); }
441 vector<Sequence> thisSeqs = parser->getSeqs(groups[i]);
443 //fill alignSeqs with this groups info.
444 numSeqs = loadSeqs(thisNameMap, thisSeqs);
446 if (m->control_pressed) { return 0; }
448 if (diffs > length) { m->mothurOut("Error: diffs is greater than your sequence length."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
450 int count = process(newMFile+groups[i]+".map");
451 outputNames.push_back(newMFile+groups[i]+".map"); outputTypes["map"].push_back(newMFile+groups[i]+".map");
453 if (m->control_pressed) { return 0; }
455 m->mothurOut("Total number of sequences before pre.cluster was " + toString(alignSeqs.size()) + "."); m->mothurOutEndLine();
456 m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
457 printData(newFFile, newNFile);
459 m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
465 catch(exception& e) {
466 m->errorOut(e, "PreClusterCommand", "driverGroups");
470 /**************************************************************************************************/
471 int PreClusterCommand::process(string newMapFile){
474 m->openOutputFile(newMapFile, out);
476 //sort seqs by number of identical seqs
477 sort(alignSeqs.begin(), alignSeqs.end(), comparePriority);
480 int numSeqs = alignSeqs.size();
482 //think about running through twice...
483 for (int i = 0; i < numSeqs; i++) {
486 // itActive = active.find(alignSeqs[i].seq.getName());
488 if (alignSeqs[i].active) { //this sequence has not been merged yet
490 string chunk = alignSeqs[i].seq.getName() + "\t" + toString(alignSeqs[i].numIdentical) + "\t" + toString(0) + "\t" + alignSeqs[i].seq.getAligned() + "\n";
492 //try to merge it with all smaller seqs
493 for (int j = i+1; j < numSeqs; j++) {
495 if (m->control_pressed) { out.close(); return 0; }
497 if (alignSeqs[j].active) { //this sequence has not been merged yet
498 //are you within "diff" bases
499 int mismatch = calcMisMatches(alignSeqs[i].seq.getAligned(), alignSeqs[j].seq.getAligned());
501 if (mismatch <= diffs) {
503 alignSeqs[i].names += ',' + alignSeqs[j].names;
504 alignSeqs[i].numIdentical += alignSeqs[j].numIdentical;
506 chunk += alignSeqs[j].seq.getName() + "\t" + toString(alignSeqs[j].numIdentical) + "\t" + toString(mismatch) + "\t" + alignSeqs[j].seq.getAligned() + "\n";
508 alignSeqs[j].active = 0;
509 alignSeqs[j].numIdentical = 0;
515 //remove from active list
516 alignSeqs[i].active = 0;
518 out << "ideal_seq_" << (i+1) << '\t' << alignSeqs[i].numIdentical << endl << chunk << endl;;
521 if(i % 100 == 0) { m->mothurOut(toString(i) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); m->mothurOutEndLine(); }
525 if(numSeqs % 100 != 0) { m->mothurOut(toString(numSeqs) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); m->mothurOutEndLine(); }
530 catch(exception& e) {
531 m->errorOut(e, "PreClusterCommand", "process");
535 /**************************************************************************************************/
536 int PreClusterCommand::readFASTA(){
541 //m->openInputFile(namefile, inNames);
542 m->openInputFile(fastafile, inFasta);
544 //string firstCol, secondCol, nameString;
547 while (!inFasta.eof()) {
549 if (m->control_pressed) { inFasta.close(); return 0; }
551 //inNames >> firstCol >> secondCol;
552 //nameString = secondCol;
554 //m->gobble(inNames);
556 //while (secondCol.find_first_of(',') != -1) {
558 // secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
561 Sequence seq(inFasta); m->gobble(inFasta);
563 if (seq.getName() != "") { //can get "" if commented line is at end of fasta file
564 if (namefile != "") {
565 itSize = sizes.find(seq.getName());
567 if (itSize == sizes.end()) { m->mothurOut(seq.getName() + " is not in your names file, please correct."); m->mothurOutEndLine(); exit(1); }
569 seqPNode tempNode(itSize->second, seq, names[seq.getName()]);
570 alignSeqs.push_back(tempNode);
571 lengths.insert(seq.getAligned().length());
573 }else { //no names file, you are identical to yourself
574 seqPNode tempNode(1, seq, seq.getName());
575 alignSeqs.push_back(tempNode);
576 lengths.insert(seq.getAligned().length());
583 if (lengths.size() > 1) { m->control_pressed = true; m->mothurOut("[ERROR]: your sequences are not all the same length. pre.cluster requires sequences to be aligned."); m->mothurOutEndLine(); }
584 else if (lengths.size() == 1) { length = *(lengths.begin()); }
586 return alignSeqs.size();
589 catch(exception& e) {
590 m->errorOut(e, "PreClusterCommand", "readFASTA");
594 /**************************************************************************************************/
595 int PreClusterCommand::loadSeqs(map<string, string>& thisName, vector<Sequence>& thisSeqs){
599 map<string, string>::iterator it;
602 for (int i = 0; i < thisSeqs.size(); i++) {
604 if (m->control_pressed) { return 0; }
606 if (namefile != "") {
607 it = thisName.find(thisSeqs[i].getName());
609 //should never be true since parser checks for this
610 if (it == thisName.end()) { m->mothurOut(thisSeqs[i].getName() + " is not in your names file, please correct."); m->mothurOutEndLine(); error = true; }
614 for(int j=0;j<(it->second).length();j++){
615 if((it->second)[j] == ','){ numReps++; }
618 seqPNode tempNode(numReps, thisSeqs[i], it->second);
619 alignSeqs.push_back(tempNode);
620 lengths.insert(thisSeqs[i].getAligned().length());
622 }else { //no names file, you are identical to yourself
623 seqPNode tempNode(1, thisSeqs[i], thisSeqs[i].getName());
624 alignSeqs.push_back(tempNode);
625 lengths.insert(thisSeqs[i].getAligned().length());
629 if (lengths.size() > 1) { error = true; m->mothurOut("[ERROR]: your sequences are not all the same length. pre.cluster requires sequences to be aligned."); m->mothurOutEndLine(); }
630 else if (lengths.size() == 1) { length = *(lengths.begin()); }
633 if (error) { m->control_pressed = true; }
637 return alignSeqs.size();
640 catch(exception& e) {
641 m->errorOut(e, "PreClusterCommand", "loadSeqs");
646 /**************************************************************************************************/
648 int PreClusterCommand::calcMisMatches(string seq1, string seq2){
652 for (int i = 0; i < seq1.length(); i++) {
654 if (seq1[i] != seq2[i]) { numBad++; }
655 if (numBad > diffs) { return length; } //to far to cluster
660 catch(exception& e) {
661 m->errorOut(e, "PreClusterCommand", "calcMisMatches");
666 /**************************************************************************************************/
668 void PreClusterCommand::printData(string newfasta, string newname){
674 m->openOutputFileAppend(newfasta, outFasta);
675 m->openOutputFileAppend(newname, outNames);
677 m->openOutputFile(newfasta, outFasta);
678 m->openOutputFile(newname, outNames);
681 for (int i = 0; i < alignSeqs.size(); i++) {
682 if (alignSeqs[i].numIdentical != 0) {
683 alignSeqs[i].seq.printSequence(outFasta);
684 outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl;
692 catch(exception& e) {
693 m->errorOut(e, "PreClusterCommand", "printData");
697 /**************************************************************************************************/
699 void PreClusterCommand::readNameFile(){
702 m->openInputFile(namefile, in);
703 string firstCol, secondCol;
706 in >> firstCol >> secondCol; m->gobble(in);
707 names[firstCol] = secondCol;
710 for(int i=0;i<secondCol.size();i++){
711 if(secondCol[i] == ','){ size++; }
713 sizes[firstCol] = size;
717 catch(exception& e) {
718 m->errorOut(e, "PreClusterCommand", "readNameFile");
723 /**************************************************************************************************/