5 * Created by Pat Schloss on 12/22/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "trimflowscommand.h"
11 #include "needlemanoverlap.hpp"
14 //**********************************************************************************************************************
15 vector<string> TrimFlowsCommand::setParameters(){
17 CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none","flow-file",false,true,true); parameters.push_back(pflow);
18 CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(poligos);
19 CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "","",false,false); parameters.push_back(pmaxhomop);
20 CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pmaxflows);
21 CommandParameter pminflows("minflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pminflows);
22 CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
23 CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
24 CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
25 CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
26 CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
27 CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
28 CommandParameter psignal("signal", "Number", "", "0.50", "", "", "","",false,false); parameters.push_back(psignal);
29 CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "","",false,false); parameters.push_back(pnoise);
30 CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "","",false,false); parameters.push_back(pallfiles);
31 CommandParameter porder("order", "Multiple", "A-B-I", "A", "", "", "","",false,false, true); parameters.push_back(porder);
32 CommandParameter pfasta("fasta", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pfasta);
33 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
34 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
36 vector<string> myArray;
37 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
41 m->errorOut(e, "TrimFlowsCommand", "setParameters");
45 //**********************************************************************************************************************
46 string TrimFlowsCommand::getHelpString(){
48 string helpString = "";
49 helpString += "The trim.flows command reads a flowgram file and creates .....\n";
50 helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
51 helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Trim.flows.\n";
55 m->errorOut(e, "TrimFlowsCommand", "getHelpString");
59 //**********************************************************************************************************************
60 string TrimFlowsCommand::getOutputPattern(string type) {
64 if (type == "flow") { pattern = "[filename],[tag],flow"; }
65 else if (type == "fasta") { pattern = "[filename],flow.fasta"; }
66 else if (type == "file") { pattern = "[filename],flow.files"; }
67 else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
72 m->errorOut(e, "TrimFlowsCommand", "getOutputPattern");
76 //**********************************************************************************************************************
78 TrimFlowsCommand::TrimFlowsCommand(){
80 abort = true; calledHelp = true;
82 vector<string> tempOutNames;
83 outputTypes["flow"] = tempOutNames;
84 outputTypes["fasta"] = tempOutNames;
85 outputTypes["file"] = tempOutNames;
88 m->errorOut(e, "TrimFlowsCommand", "TrimFlowsCommand");
92 //**********************************************************************************************************************
94 TrimFlowsCommand::TrimFlowsCommand(string option) {
97 abort = false; calledHelp = false;
100 //allow user to run help
101 if(option == "help") { help(); abort = true; calledHelp = true; }
102 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
106 vector<string> myArray = setParameters();
108 OptionParser parser(option);
109 map<string,string> parameters = parser.getParameters();
111 ValidParameters validParameter;
112 map<string,string>::iterator it;
114 //check to make sure all parameters are valid for command
115 for (it = parameters.begin(); it != parameters.end(); it++) {
116 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
119 //initialize outputTypes
120 vector<string> tempOutNames;
121 outputTypes["flow"] = tempOutNames;
122 outputTypes["fasta"] = tempOutNames;
123 outputTypes["file"] = tempOutNames;
125 //if the user changes the input directory command factory will send this info to us in the output parameter
126 string inputDir = validParameter.validFile(parameters, "inputdir", false);
127 if (inputDir == "not found"){ inputDir = ""; }
130 it = parameters.find("flow");
131 //user has given a template file
132 if(it != parameters.end()){
133 path = m->hasPath(it->second);
134 //if the user has not given a path then, add inputdir. else leave path alone.
135 if (path == "") { parameters["flow"] = inputDir + it->second; }
138 it = parameters.find("oligos");
139 //user has given a template file
140 if(it != parameters.end()){
141 path = m->hasPath(it->second);
142 //if the user has not given a path then, add inputdir. else leave path alone.
143 if (path == "") { parameters["oligos"] = inputDir + it->second; }
149 //check for required parameters
150 flowFileName = validParameter.validFile(parameters, "flow", true);
151 if (flowFileName == "not found") {
152 flowFileName = m->getFlowFile();
153 if (flowFileName != "") { m->mothurOut("Using " + flowFileName + " as input file for the flow parameter."); m->mothurOutEndLine(); }
155 m->mothurOut("No valid current flow file. You must provide a flow file."); m->mothurOutEndLine();
158 }else if (flowFileName == "not open") { flowFileName = ""; abort = true; }
160 //if the user changes the output directory command factory will send this info to us in the output parameter
161 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
163 outputDir += m->hasPath(flowFileName); //if user entered a file with a path then preserve it
167 //check for optional parameter and set defaults
168 // ...at some point should added some additional type checking...
171 temp = validParameter.validFile(parameters, "minflows", false); if (temp == "not found") { temp = "450"; }
172 m->mothurConvert(temp, minFlows);
174 temp = validParameter.validFile(parameters, "maxflows", false); if (temp == "not found") { temp = "450"; }
175 m->mothurConvert(temp, maxFlows);
178 temp = validParameter.validFile(parameters, "oligos", true);
179 if (temp == "not found") { oligoFileName = ""; }
180 else if(temp == "not open") { abort = true; }
181 else { oligoFileName = temp; m->setOligosFile(oligoFileName); }
183 temp = validParameter.validFile(parameters, "fasta", false); if (temp == "not found"){ fasta = 0; }
184 else if(m->isTrue(temp)) { fasta = 1; }
186 temp = validParameter.validFile(parameters, "maxhomop", false); if (temp == "not found"){ temp = "9"; }
187 m->mothurConvert(temp, maxHomoP);
189 temp = validParameter.validFile(parameters, "signal", false); if (temp == "not found"){ temp = "0.50"; }
190 m->mothurConvert(temp, signal);
192 temp = validParameter.validFile(parameters, "noise", false); if (temp == "not found"){ temp = "0.70"; }
193 m->mothurConvert(temp, noise);
195 temp = validParameter.validFile(parameters, "bdiffs", false); if (temp == "not found"){ temp = "0"; }
196 m->mothurConvert(temp, bdiffs);
198 temp = validParameter.validFile(parameters, "pdiffs", false); if (temp == "not found"){ temp = "0"; }
199 m->mothurConvert(temp, pdiffs);
201 temp = validParameter.validFile(parameters, "ldiffs", false); if (temp == "not found") { temp = "0"; }
202 m->mothurConvert(temp, ldiffs);
204 temp = validParameter.validFile(parameters, "sdiffs", false); if (temp == "not found") { temp = "0"; }
205 m->mothurConvert(temp, sdiffs);
207 temp = validParameter.validFile(parameters, "tdiffs", false); if (temp == "not found") { int tempTotal = pdiffs + bdiffs + ldiffs + sdiffs; temp = toString(tempTotal); }
208 m->mothurConvert(temp, tdiffs);
210 if(tdiffs == 0){ tdiffs = bdiffs + pdiffs + ldiffs + sdiffs; }
213 temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); }
214 m->setProcessors(temp);
215 m->mothurConvert(temp, processors);
217 temp = validParameter.validFile(parameters, "order", false); if (temp == "not found"){ temp = "A"; }
218 if (temp.length() > 1) { m->mothurOut("[ERROR]: " + temp + " is not a valid option for order. order options are A, B, or I. A = TACG, B = TACGTACGTACGATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGC, and I = TACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGC.\n"); abort=true;
221 if (toupper(temp[0]) == 'A') { flowOrder = "TACG"; }
222 else if(toupper(temp[0]) == 'B'){
223 flowOrder = "TACGTACGTACGATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGC"; }
224 else if(toupper(temp[0]) == 'I'){
225 flowOrder = "TACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGC"; }
227 m->mothurOut("[ERROR]: " + temp + " is not a valid option for order. order options are A, B, or I. A = TACG, B = TACGTACGTACGATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATAGATCGCATGACGATCGCATATCGTCAGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGTAGTCGAGCATCATCTGACGCAGTACGTGCATGATCTCAGTCAGCAGCTATGTCAGTGCATGCATAGATCGCATGACGATCGCATATCGTCAGTGCAGTGACTGATCGTCATCAGCTAGCATCGACTGCATGATCTCAGTCAGCAGC, and I = TACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGCTACGTACGTCTGAGCATCGATCGATGTACAGC.\n"); abort=true;
231 if(oligoFileName == "") { allFiles = 0; }
232 else { allFiles = 1; }
240 catch(exception& e) {
241 m->errorOut(e, "TrimFlowsCommand", "TrimFlowsCommand");
246 //***************************************************************************************************************
248 int TrimFlowsCommand::execute(){
251 if (abort == true) { if (calledHelp) { return 0; } return 2; }
253 map<string, string> variables;
254 variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(flowFileName));
255 string fastaFileName = getOutputFileName("fasta",variables);
256 if(fasta){ outputNames.push_back(fastaFileName); outputTypes["fasta"].push_back(fastaFileName); }
258 variables["[tag]"] = "trim";
259 string trimFlowFileName = getOutputFileName("flow",variables);
260 outputNames.push_back(trimFlowFileName); outputTypes["flow"].push_back(trimFlowFileName);
262 variables["[tag]"] = "scrap";
263 string scrapFlowFileName = getOutputFileName("flow",variables);
264 outputNames.push_back(scrapFlowFileName); outputTypes["flow"].push_back(scrapFlowFileName);
268 vector<unsigned long long> flowFilePos;
269 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
270 flowFilePos = getFlowFileBreaks();
271 for (int i = 0; i < (flowFilePos.size()-1); i++) {
272 lines.push_back(new linePair(flowFilePos[i], flowFilePos[(i+1)]));
275 ifstream in; m->openInputFile(flowFileName, in); in >> numFlows; in.close();
276 ///////////////////////////////////////// until I fix multiple processors for windows //////////////////
278 ///////////////////////////////////////// until I fix multiple processors for windows //////////////////
279 if (processors == 1) {
280 lines.push_back(new linePair(0, 1000));
283 flowFilePos = m->setFilePosEachLine(flowFileName, numFlowLines);
284 flowFilePos.erase(flowFilePos.begin() + 1); numFlowLines--;
286 //figure out how many sequences you have to process
287 int numSeqsPerProcessor = numFlowLines / processors;
288 cout << numSeqsPerProcessor << '\t' << numFlowLines << endl;
289 for (int i = 0; i < processors; i++) {
290 int startIndex = i * numSeqsPerProcessor;
291 if(i == (processors - 1)){ numSeqsPerProcessor = numFlowLines - i * numSeqsPerProcessor; }
292 lines.push_back(new linePair(flowFilePos[startIndex], numSeqsPerProcessor));
293 cout << flowFilePos[startIndex] << '\t' << numSeqsPerProcessor << endl;
298 vector<vector<string> > barcodePrimerComboFileNames;
299 if(oligoFileName != ""){
300 getOligos(barcodePrimerComboFileNames);
304 driverCreateTrim(flowFileName, trimFlowFileName, scrapFlowFileName, fastaFileName, barcodePrimerComboFileNames, lines[0]);
306 createProcessesCreateTrim(flowFileName, trimFlowFileName, scrapFlowFileName, fastaFileName, barcodePrimerComboFileNames);
309 if (m->control_pressed) { return 0; }
311 string flowFilesFileName;
315 set<string> namesAlreadyProcessed;
316 flowFilesFileName = getOutputFileName("file",variables);
317 m->openOutputFile(flowFilesFileName, output);
319 for(int i=0;i<barcodePrimerComboFileNames.size();i++){
320 for(int j=0;j<barcodePrimerComboFileNames[0].size();j++){
321 if (namesAlreadyProcessed.count(barcodePrimerComboFileNames[i][j]) == 0) {
322 if (barcodePrimerComboFileNames[i][j] != "") {
324 unsigned long long size;
326 //get num bytes in file
327 pFile = fopen (barcodePrimerComboFileNames[i][j].c_str(),"rb");
328 if (pFile==NULL) perror ("Error opening file");
330 fseek (pFile, 0, SEEK_END);
336 m->mothurRemove(barcodePrimerComboFileNames[i][j]);
339 output << m->getFullPathName(barcodePrimerComboFileNames[i][j]) << endl;
340 outputNames.push_back(barcodePrimerComboFileNames[i][j]);
341 outputTypes["flow"].push_back(barcodePrimerComboFileNames[i][j]);
343 namesAlreadyProcessed.insert(barcodePrimerComboFileNames[i][j]);
351 flowFilesFileName = getOutputFileName("file",variables);
352 m->openOutputFile(flowFilesFileName, output);
354 output << m->getFullPathName(trimFlowFileName) << endl;
358 outputTypes["file"].push_back(flowFilesFileName);
359 outputNames.push_back(flowFilesFileName);
361 m->mothurOutEndLine();
362 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
363 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
364 m->mothurOutEndLine();
368 catch(exception& e) {
369 m->errorOut(e, "TrimSeqsCommand", "execute");
374 //***************************************************************************************************************
376 int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileName, string scrapFlowFileName, string fastaFileName, vector<vector<string> > thisBarcodePrimerComboFileNames, linePair* line){
379 ofstream trimFlowFile;
380 m->openOutputFile(trimFlowFileName, trimFlowFile);
381 trimFlowFile.setf(ios::fixed, ios::floatfield); trimFlowFile.setf(ios::showpoint);
383 ofstream scrapFlowFile;
384 m->openOutputFile(scrapFlowFileName, scrapFlowFile);
385 scrapFlowFile.setf(ios::fixed, ios::floatfield); scrapFlowFile.setf(ios::showpoint);
388 if(fasta){ m->openOutputFile(fastaFileName, fastaFile); }
391 m->openInputFile(flowFileName, flowFile);
393 flowFile.seekg(line->start);
395 if(line->start == 0){
396 flowFile >> numFlows; m->gobble(flowFile);
397 scrapFlowFile << maxFlows << endl;
398 trimFlowFile << maxFlows << endl;
400 for(int i=0;i<thisBarcodePrimerComboFileNames.size();i++){
401 for(int j=0;j<thisBarcodePrimerComboFileNames[0].size();j++){
402 if (thisBarcodePrimerComboFileNames[i][j] != "") {
404 m->openOutputFile(thisBarcodePrimerComboFileNames[i][j], temp);
405 temp << maxFlows << endl;
413 FlowData flowData(numFlows, signal, noise, maxHomoP, flowOrder);
414 //cout << " driver flowdata address " << &flowData << &flowFile << endl;
418 TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, revPrimer, linker, spacer);
422 if (m->control_pressed) { break; }
425 int currentSeqDiffs = 0;
426 string trashCode = "";
428 flowData.getNext(flowFile);
429 flowData.capFlows(maxFlows);
431 Sequence currSeq = flowData.getSequence();
432 //cout << currSeq.getName() << '\t' << currSeq.getUnaligned() << endl;
433 if(!flowData.hasMinFlows(minFlows)){ //screen to see if sequence is of a minimum number of flows
439 int barcodeIndex = 0;
442 success = trimOligos.stripLinker(currSeq);
443 if(success > ldiffs) { trashCode += 'k'; }
444 else{ currentSeqDiffs += success; }
448 if (m->debug) { m->mothurOut("[DEBUG]: " + currSeq.getName() + " " + currSeq.getUnaligned() + "\n"); }
450 if(barcodes.size() != 0){
451 success = trimOligos.stripBarcode(currSeq, barcodeIndex);
452 if(success > bdiffs) { trashCode += 'b'; }
453 else{ currentSeqDiffs += success; }
457 success = trimOligos.stripSpacer(currSeq);
458 if(success > sdiffs) { trashCode += 's'; }
459 else{ currentSeqDiffs += success; }
463 if(numFPrimers != 0){
464 success = trimOligos.stripForward(currSeq, primerIndex);
465 if(success > pdiffs) { trashCode += 'f'; }
466 else{ currentSeqDiffs += success; }
469 if (currentSeqDiffs > tdiffs) { trashCode += 't'; }
471 if(numRPrimers != 0){
472 success = trimOligos.stripReverse(currSeq);
473 if(!success) { trashCode += 'r'; }
476 if(trashCode.length() == 0){
477 string thisGroup = "";
478 if(barcodes.size() != 0){
479 thisGroup = barcodeNameVector[barcodeIndex];
480 if (primers.size() != 0) {
481 if (primerNameVector[primerIndex] != "") {
482 if(thisGroup != "") {
483 thisGroup += "." + primerNameVector[primerIndex];
485 thisGroup = primerNameVector[primerIndex];
491 int pos = thisGroup.find("ignore");
492 if (pos == string::npos) {
493 flowData.printFlows(trimFlowFile);
495 if(fasta) { currSeq.printSequence(fastaFile); }
499 m->openOutputFileAppend(thisBarcodePrimerComboFileNames[barcodeIndex][primerIndex], output);
500 output.setf(ios::fixed, ios::floatfield); trimFlowFile.setf(ios::showpoint);
502 flowData.printFlows(output);
508 flowData.printFlows(scrapFlowFile, trashCode);
512 //cout << "driver" << '\t' << currSeq.getName() << endl;
514 if((count) % 10000 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }
516 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
517 unsigned long long pos = flowFile.tellg();
519 if ((pos == -1) || (pos >= line->end)) { break; }
521 if (flowFile.eof()) { break; }
526 if((count) % 10000 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }
528 trimFlowFile.close();
529 scrapFlowFile.close();
531 if(fasta){ fastaFile.close(); }
535 catch(exception& e) {
536 m->errorOut(e, "TrimSeqsCommand", "driverCreateTrim");
541 //***************************************************************************************************************
543 void TrimFlowsCommand::getOligos(vector<vector<string> >& outFlowFileNames){
546 m->openInputFile(oligoFileName, oligosFile);
548 string type, oligo, group;
551 int indexBarcode = 0;
553 while(!oligosFile.eof()){
555 oligosFile >> type; //get the first column value of the row - is it a comment or a feature we are interested in?
557 if (m->debug) { m->mothurOut("[DEBUG]: type = " + type + ".\n"); }
559 if(type[0] == '#'){ //igore the line because there's a comment
560 while (!oligosFile.eof()) { char c = oligosFile.get(); if (c == 10 || c == 13){ break; } }
561 m->gobble(oligosFile);// get rest of line if there's any crap there
563 else{ //there's a feature we're interested in
564 m->gobble(oligosFile);
565 for(int i=0;i<type.length();i++){ type[i] = toupper(type[i]); } //make type case insensitive
567 oligosFile >> oligo; //get the DNA sequence for the feature
569 for(int i=0;i<oligo.length();i++){ //make type case insensitive and change any U's to T's
570 oligo[i] = toupper(oligo[i]);
571 if(oligo[i] == 'U') { oligo[i] = 'T'; }
574 if (m->debug) { m->mothurOut("[DEBUG]: oligos = " + oligo + ".\n"); }
576 if(type == "FORWARD"){ //if the feature is a forward primer...
579 while (!oligosFile.eof()) { // get rest of line in case there is a primer name = will have the name of the primer
580 char c = oligosFile.get();
581 if (c == 10 || c == 13 || c == -1){ break; }
582 else if (c == 32 || c == 9){;} //space or tab
586 //have we seen this primer already?
587 map<string, int>::iterator itPrimer = primers.find(oligo);
588 if (itPrimer != primers.end()) { m->mothurOut("primer " + oligo + " is in your oligos file already."); m->mothurOutEndLine(); }
590 primers[oligo]=indexPrimer; indexPrimer++;
591 primerNameVector.push_back(group);
594 else if(type == "REVERSE"){
595 string oligoRC = reverseOligo(oligo);
596 revPrimer.push_back(oligoRC);
598 else if(type == "BARCODE"){
601 //check for repeat barcodes
602 map<string, int>::iterator itBar = barcodes.find(oligo);
603 if (itBar != barcodes.end()) { m->mothurOut("barcode " + oligo + " is in your oligos file already."); m->mothurOutEndLine(); }
605 if (m->debug) { m->mothurOut("[DEBUG]: group = " + group + ".\n"); }
607 barcodes[oligo]=indexBarcode; indexBarcode++;
608 barcodeNameVector.push_back(group);
609 }else if(type == "LINKER"){
610 linker.push_back(oligo);
611 }else if(type == "SPACER"){
612 spacer.push_back(oligo);
615 m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine();
619 m->gobble(oligosFile);
623 if(barcodeNameVector.size() == 0 && primerNameVector[0] == ""){ allFiles = 0; }
625 //add in potential combos
626 if(barcodeNameVector.size() == 0){
628 barcodeNameVector.push_back("");
631 if(primerNameVector.size() == 0){
633 primerNameVector.push_back("");
637 outFlowFileNames.resize(barcodeNameVector.size());
638 for(int i=0;i<outFlowFileNames.size();i++){
639 outFlowFileNames[i].assign(primerNameVector.size(), "");
644 for(map<string, int>::iterator itBar = barcodes.begin();itBar != barcodes.end();itBar++){
645 for(map<string, int>::iterator itPrimer = primers.begin();itPrimer != primers.end(); itPrimer++){
647 string primerName = primerNameVector[itPrimer->second];
648 string barcodeName = barcodeNameVector[itBar->second];
650 if ((primerName == "ignore") || (barcodeName == "ignore")) { } //do nothing
652 string comboGroupName = "";
653 string fileName = "";
655 map<string, string> variables;
656 variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(flowFileName));
658 if(primerName == ""){
659 comboGroupName = barcodeNameVector[itBar->second];
660 variables["[tag]"] = comboGroupName;
661 fileName = getOutputFileName("flow", variables);
664 if(barcodeName == ""){
665 comboGroupName = primerNameVector[itPrimer->second];
668 comboGroupName = barcodeNameVector[itBar->second] + "." + primerNameVector[itPrimer->second];
670 variables["[tag]"] = comboGroupName;
671 fileName = getOutputFileName("flow", variables);
674 outFlowFileNames[itBar->second][itPrimer->second] = fileName;
677 m->openOutputFile(fileName, temp);
684 numFPrimers = primers.size();
685 numRPrimers = revPrimer.size();
686 numLinkers = linker.size();
687 numSpacers = spacer.size();
690 catch(exception& e) {
691 m->errorOut(e, "TrimSeqsCommand", "getOligos");
695 //********************************************************************/
696 string TrimFlowsCommand::reverseOligo(string oligo){
700 for(int i=oligo.length()-1;i>=0;i--){
702 if(oligo[i] == 'A') { reverse += 'T'; }
703 else if(oligo[i] == 'T'){ reverse += 'A'; }
704 else if(oligo[i] == 'U'){ reverse += 'A'; }
706 else if(oligo[i] == 'G'){ reverse += 'C'; }
707 else if(oligo[i] == 'C'){ reverse += 'G'; }
709 else if(oligo[i] == 'R'){ reverse += 'Y'; }
710 else if(oligo[i] == 'Y'){ reverse += 'R'; }
712 else if(oligo[i] == 'M'){ reverse += 'K'; }
713 else if(oligo[i] == 'K'){ reverse += 'M'; }
715 else if(oligo[i] == 'W'){ reverse += 'W'; }
716 else if(oligo[i] == 'S'){ reverse += 'S'; }
718 else if(oligo[i] == 'B'){ reverse += 'V'; }
719 else if(oligo[i] == 'V'){ reverse += 'B'; }
721 else if(oligo[i] == 'D'){ reverse += 'H'; }
722 else if(oligo[i] == 'H'){ reverse += 'D'; }
724 else { reverse += 'N'; }
730 catch(exception& e) {
731 m->errorOut(e, "TrimFlowsCommand", "reverseOligo");
736 /**************************************************************************************************/
737 vector<unsigned long long> TrimFlowsCommand::getFlowFileBreaks() {
741 vector<unsigned long long> filePos;
742 filePos.push_back(0);
745 unsigned long long size;
747 //get num bytes in file
748 pFile = fopen (flowFileName.c_str(),"rb");
749 if (pFile==NULL) perror ("Error opening file");
751 fseek (pFile, 0, SEEK_END);
756 //estimate file breaks
757 unsigned long long chunkSize = 0;
758 chunkSize = size / processors;
760 //file too small to divide by processors
761 if (chunkSize == 0) { processors = 1; filePos.push_back(size); return filePos; }
763 //for each process seekg to closest file break and search for next '>' char. make that the filebreak
764 for (int i = 0; i < processors; i++) {
765 unsigned long long spot = (i+1) * chunkSize;
768 m->openInputFile(flowFileName, in);
771 string dummy = m->getline(in);
773 //there was not another sequence before the end of the file
774 unsigned long long sanityPos = in.tellg();
776 // if (sanityPos == -1) { break; }
777 // else { filePos.push_back(newSpot); }
778 if (sanityPos == -1) { break; }
779 else { filePos.push_back(sanityPos); }
785 filePos.push_back(size);
787 //sanity check filePos
788 for (int i = 0; i < (filePos.size()-1); i++) {
789 if (filePos[(i+1)] <= filePos[i]) { filePos.erase(filePos.begin()+(i+1)); i--; }
793 m->openInputFile(flowFileName, in);
796 //unsigned long long spot = in.tellg();
800 processors = (filePos.size() - 1);
804 catch(exception& e) {
805 m->errorOut(e, "TrimSeqsCommand", "getFlowFileBreaks");
810 /**************************************************************************************************/
812 int TrimFlowsCommand::createProcessesCreateTrim(string flowFileName, string trimFlowFileName, string scrapFlowFileName, string fastaFileName, vector<vector<string> > barcodePrimerComboFileNames){
818 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
821 //loop through and create all the processes you want
822 while (process != processors) {
826 processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later
830 vector<vector<string> > tempBarcodePrimerComboFileNames = barcodePrimerComboFileNames;
832 for(int i=0;i<tempBarcodePrimerComboFileNames.size();i++){
833 for(int j=0;j<tempBarcodePrimerComboFileNames[0].size();j++){
834 if (tempBarcodePrimerComboFileNames[i][j] != "") {
835 tempBarcodePrimerComboFileNames[i][j] += toString(getpid()) + ".temp";
837 m->openOutputFile(tempBarcodePrimerComboFileNames[i][j], temp);
843 driverCreateTrim(flowFileName,
844 (trimFlowFileName + toString(getpid()) + ".temp"),
845 (scrapFlowFileName + toString(getpid()) + ".temp"),
846 (fastaFileName + toString(getpid()) + ".temp"),
847 tempBarcodePrimerComboFileNames, lines[process]);
851 m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine();
852 for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
859 m->openOutputFile(trimFlowFileName, temp);
862 m->openOutputFile(scrapFlowFileName, temp);
866 m->openOutputFile(fastaFileName, temp);
870 driverCreateTrim(flowFileName, trimFlowFileName, scrapFlowFileName, fastaFileName, barcodePrimerComboFileNames, lines[0]);
872 //force parent to wait until all the processes are done
873 for (int i=0;i<processIDS.size();i++) {
874 int temp = processIDS[i];
878 //////////////////////////////////////////////////////////////////////////////////////////////////////
879 //Windows version shared memory, so be careful when passing variables through the trimFlowData struct.
880 //Above fork() will clone, so memory is separate, but that's not the case with windows,
881 //////////////////////////////////////////////////////////////////////////////////////////////////////
883 vector<trimFlowData*> pDataArray;
884 DWORD dwThreadIdArray[processors-1];
885 HANDLE hThreadArray[processors-1];
887 //Create processor worker threads.
888 for( int i=0; i<processors-1; i++ ){
889 // Allocate memory for thread data.
890 string extension = "";
891 if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); }
893 vector<vector<string> > tempBarcodePrimerComboFileNames = barcodePrimerComboFileNames;
895 for(int i=0;i<tempBarcodePrimerComboFileNames.size();i++){
896 for(int j=0;j<tempBarcodePrimerComboFileNames[0].size();j++){
897 if (tempBarcodePrimerComboFileNames[i][j] != "") {
898 tempBarcodePrimerComboFileNames[i][j] += extension;
900 m->openOutputFile(tempBarcodePrimerComboFileNames[i][j], temp);
907 trimFlowData* tempflow = new trimFlowData(flowFileName, (trimFlowFileName + extension), (scrapFlowFileName + extension), fastaFileName, flowOrder, tempBarcodePrimerComboFileNames, barcodes, primers, revPrimer, fasta, allFiles, lines[i]->start, lines[i]->end, m, signal, noise, numFlows, maxFlows, minFlows, maxHomoP, tdiffs, bdiffs, pdiffs, i);
908 pDataArray.push_back(tempflow);
910 //MyTrimFlowThreadFunction is in header. It must be global or static to work with the threads.
911 //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
912 hThreadArray[i] = CreateThread(NULL, 0, MyTrimFlowThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);
915 //using the main process as a worker saves time and memory
917 m->openOutputFile(trimFlowFileName, temp);
920 m->openOutputFile(scrapFlowFileName, temp);
924 m->openOutputFile(fastaFileName, temp);
928 vector<vector<string> > tempBarcodePrimerComboFileNames = barcodePrimerComboFileNames;
930 for(int i=0;i<tempBarcodePrimerComboFileNames.size();i++){
931 for(int j=0;j<tempBarcodePrimerComboFileNames[0].size();j++){
932 if (tempBarcodePrimerComboFileNames[i][j] != "") {
933 tempBarcodePrimerComboFileNames[i][j] += toString(processors-1) + ".temp";
935 m->openOutputFile(tempBarcodePrimerComboFileNames[i][j], temp);
943 //do my part - do last piece because windows is looking for eof
944 int num = driverCreateTrim(flowFileName, (trimFlowFileName + toString(processors-1) + ".temp"), (scrapFlowFileName + toString(processors-1) + ".temp"), (fastaFileName + toString(processors-1) + ".temp"), tempBarcodePrimerComboFileNames, lines[processors-1]);
945 processIDS.push_back((processors-1));
947 //Wait until all threads have terminated.
948 WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
950 //Close all thread handles and free memory allocations.
951 for(int i=0; i < pDataArray.size(); i++){
952 num += pDataArray[i]->count;
953 CloseHandle(hThreadArray[i]);
954 delete pDataArray[i];
960 m->mothurOutEndLine();
961 for(int i=0;i<processIDS.size();i++){
963 m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine();
965 m->appendFiles((trimFlowFileName + toString(processIDS[i]) + ".temp"), trimFlowFileName);
966 m->mothurRemove((trimFlowFileName + toString(processIDS[i]) + ".temp"));
967 // m->mothurOut("\tDone with trim.flow file"); m->mothurOutEndLine();
969 m->appendFiles((scrapFlowFileName + toString(processIDS[i]) + ".temp"), scrapFlowFileName);
970 m->mothurRemove((scrapFlowFileName + toString(processIDS[i]) + ".temp"));
971 // m->mothurOut("\tDone with scrap.flow file"); m->mothurOutEndLine();
974 m->appendFiles((fastaFileName + toString(processIDS[i]) + ".temp"), fastaFileName);
975 m->mothurRemove((fastaFileName + toString(processIDS[i]) + ".temp"));
976 // m->mothurOut("\tDone with flow.fasta file"); m->mothurOutEndLine();
979 for (int j = 0; j < barcodePrimerComboFileNames.size(); j++) {
980 for (int k = 0; k < barcodePrimerComboFileNames[0].size(); k++) {
981 if (barcodePrimerComboFileNames[j][k] != "") {
982 m->appendFiles((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp"), barcodePrimerComboFileNames[j][k]);
983 m->mothurRemove((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp"));
993 catch(exception& e) {
994 m->errorOut(e, "TrimFlowsCommand", "createProcessesCreateTrim");
999 //***************************************************************************************************************