From: westcott <westcott>
Date: Fri, 18 Jun 2010 17:50:19 +0000 (+0000)
Subject: fixed problem with trim.seqs writing over files if barcodes belonged to the same... 
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=06cf8fa0ded0e427361e9ecd27917c7a8a52b89f;p=mothur.git

fixed problem with trim.seqs writing over files if barcodes belonged to the same group
---

diff --git a/splitabundcommand.cpp b/splitabundcommand.cpp
index fab1b64..287086a 100644
--- a/splitabundcommand.cpp
+++ b/splitabundcommand.cpp
@@ -146,7 +146,7 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
 void SplitAbundCommand::help(){
 	try {
 		m->mothurOut("The split.abund command reads a fasta file and a list or a names file splits the sequences into rare and abundant groups. \n");
-		m->mothurOut("The split.abund command parameters are list, name, cutoff, group, label, groups and accnos.\n");
+		m->mothurOut("The split.abund command parameters are fasta, list, name, cutoff, group, label, groups, cutoff and accnos.\n");
 		m->mothurOut("The fasta and a list or name parameter are required, and you must provide a cutoff value.\n");
 		m->mothurOut("The cutoff parameter is used to qualify what is abundant and rare.\n");
 		m->mothurOut("The group parameter allows you to parse a group file into rare and abundant groups.\n");
@@ -155,8 +155,8 @@ void SplitAbundCommand::help(){
 		m->mothurOut("The groups parameter allows you to parse the files into rare and abundant files by group.  \n");
 		m->mothurOut("For example if you set groups=A-B-C, you will get a .A.abund, .A.rare, .B.abund, .B.rare, .C.abund, .C.rare files.  \n");
 		m->mothurOut("If you want .abund and .rare files for all groups, set groups=all.  \n");
-		m->mothurOut("The split.abund command should be used in the following format: split.abund(list=yourListFile, group=yourGroupFile, label=yourLabels, cutoff=yourCutoff).\n");
-		m->mothurOut("Example: split.abundt(list=abrecovery.fn.list, group=abrecovery.groups, label=0.03, cutoff=2).\n");
+		m->mothurOut("The split.abund command should be used in the following format: split.abund(fasta=yourFasta, list=yourListFile, group=yourGroupFile, label=yourLabels, cutoff=yourCutoff).\n");
+		m->mothurOut("Example: split.abund(fasta=abrecovery.fasta, list=abrecovery.fn.list, group=abrecovery.groups, label=0.03, cutoff=2).\n");
 		m->mothurOut("Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n");
 
 	}
diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp
index 580fc22..4947b38 100644
--- a/trimseqscommand.cpp
+++ b/trimseqscommand.cpp
@@ -283,10 +283,13 @@ int TrimSeqsCommand::execute(){
 		for(int i=0;i<fastaFileNames.size();i++){
 			ifstream inFASTA;
 			string seqName;
-			openInputFile(getRootName(fastaFile) + groupVector[i] + ".fasta", inFASTA);
+			//openInputFile(getRootName(fastaFile) +  groupVector[i] + ".fasta", inFASTA);
+			openInputFile(fastaFileNames[i], inFASTA);
 			ofstream outGroups;
-			openOutputFile(outputDir + getRootName(getSimpleName(fastaFile)) + groupVector[i] + ".groups", outGroups);
-			outputNames.push_back(outputDir + getRootName(getSimpleName(fastaFile)) + groupVector[i] + ".groups");
+			string outGroupFilename = outputDir + getRootName(getSimpleName(fastaFileNames[i])) + "groups";
+			openOutputFile(outGroupFilename, outGroups);
+			//openOutputFile(outputDir + getRootName(getSimpleName(fastaFile)) + groupVector[i] + ".groups", outGroups);
+			outputNames.push_back(outGroupFilename);
 			
 			while(!inFASTA.eof()){
 				if(inFASTA.get() == '>'){
@@ -353,15 +356,8 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
 		for(int i=0;i<line->num;i++){
 				
 			if (m->control_pressed) { 
-				inFASTA.close(); 
-				outFASTA.close();
-				scrapFASTA.close();
-				if (oligoFile != "") {	 outGroups.close();   }
-				if(qFileName != "")	{	qFile.close();	}
-				for(int i=0;i<fastaFileNames.size();i++){
-					fastaFileNames[i]->close();
-					delete fastaFileNames[i];
-				}	
+				inFASTA.close(); outFASTA.close(); scrapFASTA.close(); if (oligoFile != "") {	 outGroups.close();   } if(qFileName != "")	{	qFile.close();	}
+				for(int i=0;i<fastaFileNames.size();i++){  fastaFileNames[i]->close(); delete fastaFileNames[i];  }	
 				for (int i = 0; i < outputNames.size(); i++) {	remove(outputNames[i].c_str()); }
 				return 0;
 			}
@@ -587,13 +583,13 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec){ //vector<ofstream*
 				}
 				else if(type == "barcode"){
 					inOligos >> group;
-					barcodes[oligo]=index++;
+					barcodes[oligo]=index; index++;
 					groupVector.push_back(group);
 					
 					if(allFiles){
 						//outFASTAVec.push_back(new ofstream((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta").c_str(), ios::ate));
-						outputNames.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
-						outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
+						outputNames.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + toString(index) + "." + group + ".fasta"));
+						outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + toString(index) + "." + group + ".fasta"));
 					}
 				}
 			}