X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=classifyseqscommand.cpp;h=580dd9b6e056197bfc48cb39abcfb526237e1487;hb=7a7870ab773b993d8d1fd89703b1df3beb47f8d4;hp=0538bff07d99ca1266d488a5844fcde49afaf3bc;hpb=89d6711c2beed6ee75fb00e5e57f1a91564d3e89;p=mothur.git diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 0538bff..580dd9b 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -82,10 +82,7 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { } else if (templateFileName == "not open") { abort = true; } - groupfile = validParameter.validFile(parameters, "group", true); - if (groupfile == "not open") { abort = true; } - else if (groupfile == "not found") { groupfile = ""; } - + fastaFileName = validParameter.validFile(parameters, "fasta", false); if (fastaFileName == "not found") { m->mothurOut("fasta is a required parameter for the classify.seqs command."); m->mothurOutEndLine(); abort = true; } else { @@ -193,6 +190,53 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { if (namefileNames.size() != fastaFileNames.size()) { abort = true; m->mothurOut("If you provide a name file, you must have one for each fasta file."); m->mothurOutEndLine(); } } + groupfile = validParameter.validFile(parameters, "group", false); + if (groupfile == "not found") { groupfile = ""; } + else { + splitAtDash(groupfile, groupfileNames); + + //go through files and make sure they are good, if not, then disregard them + for (int i = 0; i < groupfileNames.size(); i++) { + if (inputDir != "") { + string path = hasPath(groupfileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { groupfileNames[i] = inputDir + groupfileNames[i]; } + } + int ableToOpen; + + #ifdef USE_MPI + int pid; + MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running + MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are + + if (pid == 0) { + #endif + + ifstream in; + ableToOpen = openInputFile(groupfileNames[i], in); + in.close(); + + #ifdef USE_MPI + for (int j = 1; j < processors; j++) { + MPI_Send(&ableToOpen, 1, MPI_INT, j, 2001, MPI_COMM_WORLD); + } + }else{ + MPI_Status status; + MPI_Recv(&ableToOpen, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status); + } + + #endif + if (ableToOpen == 1) { m->mothurOut("Unable to match group file with fasta file."); m->mothurOutEndLine(); abort = true; } + + } + } + + if (groupfile != "") { + if (groupfileNames.size() != fastaFileNames.size()) { abort = true; m->mothurOut("If you provide a group file, you must have one for each fasta file."); m->mothurOutEndLine(); } + }else { + for (int i = 0; i < fastaFileNames.size(); i++) { groupfileNames.push_back(""); } + } + //check for optional parameter and set defaults // ...at some point should added some additional type checking... string temp; @@ -507,7 +551,7 @@ int ClassifySeqsCommand::execute(){ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to classify " + toString(numFastaSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); start = time(NULL); - PhyloSummary taxaSum(taxonomyFileName, groupfile); + PhyloSummary taxaSum(taxonomyFileName, groupfileNames[s]); if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete classify; return 0; } @@ -527,7 +571,7 @@ int ClassifySeqsCommand::execute(){ m->mothurOut(name + " is not in your name file please correct."); m->mothurOutEndLine(); exit(1); }else{ for (int i = 0; i < itNames->second; i++) { - taxaSum.addSeqToTree(name+toString(i), taxon); //add it as many times as there are identical seqs + taxaSum.addSeqToTree(name, taxon); //add it as many times as there are identical seqs } } } @@ -582,7 +626,6 @@ int ClassifySeqsCommand::execute(){ m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); - } delete classify;