X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=deconvolutecommand.cpp;h=fba2d27ebf470c968f50f64c71c54917f0e8f5df;hb=163b300cfd7d4ca4e70c454be20f07b1d8346650;hp=3ec5f734eebb393c6ff630a1adc8d7e94ab6729f;hpb=cd37904452dc95b183ff313ff05720c562902487;p=mothur.git diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index 3ec5f73..fba2d27 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -19,7 +19,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { else { //valid paramters for this command - string Array[] = {"fasta"}; + string Array[] = {"fasta", "name"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -33,10 +33,13 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { } //check for required parameters - filename = validParameter.validFile(parameters, "fasta", true); - if (filename == "not open") { abort = true; } - else if (filename == "not found") { filename = ""; cout << "fasta is a required parameter for the unique.seqs command." << endl; abort = true; } + inFastaName = validParameter.validFile(parameters, "fasta", true); + if (inFastaName == "not open") { abort = true; } + else if (inFastaName == "not found") { inFastaName = ""; cout << "fasta is a required parameter for the unique.seqs command." << endl; abort = true; } + oldNameMapFName = validParameter.validFile(parameters, "name", true); + if (oldNameMapFName == "not open") { abort = true; } + else if (oldNameMapFName == "not found"){ oldNameMapFName = ""; } } } @@ -75,30 +78,19 @@ int DeconvoluteCommand::execute() { try { if (abort == true) { return 0; } - + //prepare filenames and open files - outputFileName = (getRootName(filename) + "names"); - outFastafile = (getRootName(filename) + "unique.fasta"); + string outNameFile = (getRootName(inFastaName) + "names"); + string outFastaFile = (getRootName(inFastaName) + "unique" + getExtension(inFastaName)); - openInputFile(filename, in); - openOutputFile(outputFileName, out); - openOutputFile(outFastafile, outFasta); - - //constructor reads in file and store internally - fastamap = new FastaMap(); + FastaMap fastamap; - //two columns separated by tabs sequence name and then sequence - fastamap->readFastaFile(in); + if(oldNameMapFName == "") { fastamap.readFastaFile(inFastaName); } + else { fastamap.readFastaFile(inFastaName, oldNameMapFName); } - //print out new names file - //file contains 2 columns separated by tabs. the first column is the groupname(name of first sequence found. - //the second column is the list of names of identical sequences separated by ','. - fastamap->printNamesFile(out); - fastamap->printCondensedFasta(outFasta); + fastamap.printCondensedFasta(outFastaFile); + fastamap.printNamesFile(outNameFile); - out.close(); - outFasta.close(); - return 0; } catch(exception& e) {