A71FE12C12EDF72400963CA7 /* mergegroupscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A71FE12B12EDF72400963CA7 /* mergegroupscommand.cpp */; };
A727864412E9E28C00F86ABA /* removerarecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A727864312E9E28C00F86ABA /* removerarecommand.cpp */; };
A75790591301749D00A30DAB /* homovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75790581301749D00A30DAB /* homovacommand.cpp */; };
+ A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */; };
A7A61F2D130062E000E05B6B /* amovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A61F2C130062E000E05B6B /* amovacommand.cpp */; };
A7E9B88112D37EC400DA6239 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B64F12D37EC300DA6239 /* ace.cpp */; };
A7E9B88212D37EC400DA6239 /* aligncommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B65112D37EC300DA6239 /* aligncommand.cpp */; };
A727864312E9E28C00F86ABA /* removerarecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removerarecommand.cpp; sourceTree = "<group>"; };
A75790571301749D00A30DAB /* homovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = homovacommand.h; sourceTree = "<group>"; };
A75790581301749D00A30DAB /* homovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = homovacommand.cpp; sourceTree = "<group>"; };
+ A799F5B71309A3E000AEEFA0 /* makefastqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makefastqcommand.h; sourceTree = "<group>"; };
+ A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makefastqcommand.cpp; sourceTree = "<group>"; };
A7A61F1A130035C800E05B6B /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
A7A61F2B130062E000E05B6B /* amovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amovacommand.h; sourceTree = "<group>"; };
A7A61F2C130062E000E05B6B /* amovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = amovacommand.cpp; sourceTree = "<group>"; };
A7E9B73E12D37EC400DA6239 /* listseqscommand.h */,
A7FA10001302E096003860FE /* mantelcommand.h */,
A7FA10011302E096003860FE /* mantelcommand.cpp */,
+ A799F5B71309A3E000AEEFA0 /* makefastqcommand.h */,
+ A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */,
A7E9B74312D37EC400DA6239 /* makegroupcommand.cpp */,
A7E9B74412D37EC400DA6239 /* makegroupcommand.h */,
A7E9B74912D37EC400DA6239 /* matrixoutputcommand.cpp */,
A7A61F2D130062E000E05B6B /* amovacommand.cpp in Sources */,
A75790591301749D00A30DAB /* homovacommand.cpp in Sources */,
A7FA10021302E097003860FE /* mantelcommand.cpp in Sources */,
+ A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
chimera->getChimeras(candidateSeq);
if (m->control_pressed) { delete candidateSeq; return 1; }
-
- //do you want to check both pieces for chimeras
- if (trimera) {
- //if you are not chimeric, then check each half
- data_results wholeResults = chimera->getResults();
+ //if you are not chimeric, then check each half
+ data_results wholeResults = chimera->getResults();
+
+ //determine if we need to split
+ bool isChimeric = false;
+
+ if (wholeResults.flag == "yes") {
+ string chimeraFlag = "no";
+ if( (wholeResults.results[0].bsa >= minBS && wholeResults.results[0].divr_qla_qrb >= divR)
+ ||
+ (wholeResults.results[0].bsb >= minBS && wholeResults.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
- //determine if we need to split
- bool isChimeric = false;
- if (wholeResults.flag == "yes") {
- string chimeraFlag = "no";
- if( (wholeResults.results[0].bsa >= minBS && wholeResults.results[0].divr_qla_qrb >= divR)
- ||
- (wholeResults.results[0].bsb >= minBS && wholeResults.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-
-
- if (chimeraFlag == "yes") {
- if ((wholeResults.results[0].bsa >= minBS) || (wholeResults.results[0].bsb >= minBS)) { isChimeric = true; }
- }
+ if (chimeraFlag == "yes") {
+ if ((wholeResults.results[0].bsa >= minBS) || (wholeResults.results[0].bsb >= minBS)) { isChimeric = true; }
}
+ }
+
+ if ((!isChimeric) && trimera) {
- if (!isChimeric) {
-
- //split sequence in half by bases
- string leftQuery, rightQuery;
- Sequence tempSeq(candidateSeq->getName(), candidateAligned);
- divideInHalf(tempSeq, leftQuery, rightQuery);
-
- //run chimeraSlayer on each piece
- Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
- Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
-
- //find chimeras
- chimera->getChimeras(left);
- data_results leftResults = chimera->getResults();
-
- chimera->getChimeras(right);
- data_results rightResults = chimera->getResults();
-
- //if either piece is chimeric then report
- Sequence* trimmed = chimera->print(out, out2, leftResults, rightResults);
- if (trim) { trimmed->printSequence(out3); delete trimmed; }
-
- delete left; delete right;
-
- }else { //already chimeric
- //print results
- Sequence* trimmed = chimera->print(out, out2);
- if (trim) { trimmed->printSequence(out3); delete trimmed; }
- }
- }else {
+ //split sequence in half by bases
+ string leftQuery, rightQuery;
+ Sequence tempSeq(candidateSeq->getName(), candidateAligned);
+ divideInHalf(tempSeq, leftQuery, rightQuery);
+
+ //run chimeraSlayer on each piece
+ Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
+ Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
+
+ //find chimeras
+ chimera->getChimeras(left);
+ data_results leftResults = chimera->getResults();
+
+ chimera->getChimeras(right);
+ data_results rightResults = chimera->getResults();
+
+ //if either piece is chimeric then report
+ Sequence* trimmed = chimera->print(out, out2, leftResults, rightResults);
+ if (trim) { trimmed->printSequence(out3); delete trimmed; }
+
+ delete left; delete right;
+
+ }else { //already chimeric
//print results
Sequence* trimmed = chimera->print(out, out2);
if (trim) { trimmed->printSequence(out3); delete trimmed; }
}
+
}
count++;
}
if (m->control_pressed) { delete candidateSeq; return 1; }
- //do you want to check both pieces for chimeras
- if (trimera) {
-
- //if you are not chimeric, then check each half
- data_results wholeResults = chimera->getResults();
+ //if you are not chimeric, then check each half
+ data_results wholeResults = chimera->getResults();
+
+ //determine if we need to split
+ bool isChimeric = false;
+
+ if (wholeResults.flag == "yes") {
+ string chimeraFlag = "no";
+ if( (wholeResults.results[0].bsa >= minBS && wholeResults.results[0].divr_qla_qrb >= divR)
+ ||
+ (wholeResults.results[0].bsb >= minBS && wholeResults.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
- //determine if we need to split
- bool isChimeric = false;
- if (wholeResults.flag == "yes") {
- string chimeraFlag = "no";
- if( (wholeResults.results[0].bsa >= minBS && wholeResults.results[0].divr_qla_qrb >= divR)
- ||
- (wholeResults.results[0].bsb >= minBS && wholeResults.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-
-
- if (chimeraFlag == "yes") {
- if ((wholeResults.results[0].bsa >= minBS) || (wholeResults.results[0].bsb >= minBS)) { isChimeric = true; }
- }
+ if (chimeraFlag == "yes") {
+ if ((wholeResults.results[0].bsa >= minBS) || (wholeResults.results[0].bsb >= minBS)) { isChimeric = true; }
}
+ }
+
+ if ((!isChimeric) && trimera) {
+ //split sequence in half by bases
+ string leftQuery, rightQuery;
+ Sequence tempSeq(candidateSeq->getName(), candidateAligned);
+ divideInHalf(tempSeq, leftQuery, rightQuery);
- if (!isChimeric) {
- //split sequence in half by bases
- string leftQuery, rightQuery;
- Sequence tempSeq(candidateSeq->getName(), candidateAligned);
- divideInHalf(tempSeq, leftQuery, rightQuery);
-
- //run chimeraSlayer on each piece
- Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
- Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
-
- //find chimeras
- chimera->getChimeras(left);
- data_results leftResults = chimera->getResults();
-
- chimera->getChimeras(right);
- data_results rightResults = chimera->getResults();
-
- //if either piece is chimeric then report
- Sequence* trimmed = chimera->print(outMPI, outAccMPI, leftResults, rightResults);
- if (trim) {
- string outputString = ">" + trimmed->getName() + "\n" + trimmed->getAligned() + "\n";
- delete trimmed;
-
- //write to accnos file
- int length = outputString.length();
- char* buf2 = new char[length];
- memcpy(buf2, outputString.c_str(), length);
-
- MPI_File_write_shared(outFastaMPI, buf2, length, MPI_CHAR, &status);
- delete buf2;
- }
-
- delete left; delete right;
+ //run chimeraSlayer on each piece
+ Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
+ Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
+
+ //find chimeras
+ chimera->getChimeras(left);
+ data_results leftResults = chimera->getResults();
+
+ chimera->getChimeras(right);
+ data_results rightResults = chimera->getResults();
+
+ //if either piece is chimeric then report
+ Sequence* trimmed = chimera->print(outMPI, outAccMPI, leftResults, rightResults);
+ if (trim) {
+ string outputString = ">" + trimmed->getName() + "\n" + trimmed->getAligned() + "\n";
+ delete trimmed;
- }else { //already chimeric
- //print results
- Sequence* trimmed = chimera->print(outMPI, outAccMPI);
+ //write to accnos file
+ int length = outputString.length();
+ char* buf2 = new char[length];
+ memcpy(buf2, outputString.c_str(), length);
- if (trim) {
- string outputString = ">" + trimmed->getName() + "\n" + trimmed->getAligned() + "\n";
- delete trimmed;
-
- //write to accnos file
- int length = outputString.length();
- char* buf2 = new char[length];
- memcpy(buf2, outputString.c_str(), length);
-
- MPI_File_write_shared(outFastaMPI, buf2, length, MPI_CHAR, &status);
- delete buf2;
- }
+ MPI_File_write_shared(outFastaMPI, buf2, length, MPI_CHAR, &status);
+ delete buf2;
}
- }else {
+
+ delete left; delete right;
+
+ }else {
//print results
Sequence* trimmed = chimera->print(outMPI, outAccMPI);
#include "amovacommand.h"
#include "homovacommand.h"
#include "mantelcommand.h"
+#include "makefastqcommand.h"
/*******************************************************/
commands["amova"] = "amova";
commands["homova"] = "homova";
commands["mantel"] = "mantel";
+ commands["make.fastq"] = "make.fastq";
commands["merge.groups"] = "merge.groups";
commands["pairwise.seqs"] = "MPIEnabled";
commands["pipeline.pds"] = "MPIEnabled";
else if(commandName == "amova") { command = new AmovaCommand(optionString); }
else if(commandName == "homova") { command = new HomovaCommand(optionString); }
else if(commandName == "mantel") { command = new MantelCommand(optionString); }
+ else if(commandName == "make.fastq") { command = new MakeFastQCommand(optionString); }
else { command = new NoCommand(optionString); }
return command;
else if(commandName == "amova") { pipecommand = new AmovaCommand(optionString); }
else if(commandName == "homova") { pipecommand = new HomovaCommand(optionString); }
else if(commandName == "mantel") { pipecommand = new MantelCommand(optionString); }
+ else if(commandName == "make.fastq") { pipecommand = new MakeFastQCommand(optionString); }
else { pipecommand = new NoCommand(optionString); }
return pipecommand;
else if(commandName == "amova") { shellcommand = new AmovaCommand(); }
else if(commandName == "homova") { shellcommand = new HomovaCommand(); }
else if(commandName == "mantel") { shellcommand = new MantelCommand(); }
+ else if(commandName == "make.fastq") { shellcommand = new MakeFastQCommand(); }
else { shellcommand = new NoCommand(); }
return shellcommand;
--- /dev/null
+/*
+ * makefastqcommand.cpp
+ * mothur
+ *
+ * Created by westcott on 2/14/11.
+ * Copyright 2011 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "makefastqcommand.h"
+#include "sequence.hpp"
+#include "qualityscores.h"
+
+//**********************************************************************************************************************
+vector<string> MakeFastQCommand::getValidParameters(){
+ try {
+ string Array[] = {"fasta","qfile","outputdir","inputdir" };
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "getValidParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+MakeFastQCommand::MakeFastQCommand(){
+ try {
+ abort = true; calledHelp = true;
+ vector<string> tempOutNames;
+ outputTypes["fastq"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "MakeFastQCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> MakeFastQCommand::getRequiredParameters(){
+ try {
+ string Array[] = {"fasta","qfile"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> MakeFastQCommand::getRequiredFiles(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+MakeFastQCommand::MakeFastQCommand(string option) {
+ try {
+ abort = false; calledHelp = false;
+
+ //allow user to run help
+ if(option == "help") { help(); abort = true; calledHelp = true; }
+
+ else {
+ //valid paramters for this command
+ string Array[] = {"fasta","qfile", "outputdir","inputdir" };
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+
+ OptionParser parser(option);
+ map<string,string> parameters = parser.getParameters();
+
+ ValidParameters validParameter;
+ map<string,string>::iterator it;
+
+ //check to make sure all parameters are valid for command
+ for (it = parameters.begin(); it != parameters.end(); it++) {
+ if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["fastq"] = tempOutNames;
+
+
+ //if the user changes the input directory command factory will send this info to us in the output parameter
+ string inputDir = validParameter.validFile(parameters, "inputdir", false);
+ if (inputDir == "not found"){ inputDir = ""; }
+ else {
+ string path;
+ it = parameters.find("fasta");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["fasta"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("qfile");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["qfile"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("list");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["list"] = inputDir + it->second; }
+ }
+ }
+
+
+ //check for required parameters
+ fastafile = validParameter.validFile(parameters, "fasta", true);
+ if (fastafile == "not open") { abort = true; fastafile = ""; }
+ else if (fastafile == "not found") { fastafile = ""; m->mothurOut("You must provide a fasta file."); m->mothurOutEndLine(); abort = true; }
+
+ qualfile = validParameter.validFile(parameters, "qfile", true);
+ if (qualfile == "not open") { abort = true; qualfile = ""; }
+ else if (qualfile == "not found") { qualfile = ""; m->mothurOut("You must provide a quality file."); m->mothurOutEndLine(); abort = true; }
+
+ //if the user changes the output directory command factory will send this info to us in the output parameter
+ outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(fastafile); }
+
+ }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "MakeFastQCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+void MakeFastQCommand::help(){
+ try {
+ /*m->mothurOut("The get.groups command selects sequences from a specfic group or set of groups from the following file types: fasta, name, group, list, taxonomy.\n");
+ m->mothurOut("It outputs a file containing the sequences in the those specified groups.\n");
+ m->mothurOut("The get.groups command parameters are accnos, fasta, name, group, list, taxonomy and groups. The group parameter is required.\n");
+ m->mothurOut("You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n");
+ m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like. You can separate group names with dashes.\n");
+ m->mothurOut("The get.groups command should be in the following format: get.groups(accnos=yourAccnos, fasta=yourFasta, group=yourGroupFile).\n");
+ m->mothurOut("Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n");
+ m->mothurOut("or get.seqs(groups=pasture, fasta=amazon.fasta, amazon.groups).\n");
+ m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");*/
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "help");
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+
+int MakeFastQCommand::execute(){
+ try {
+
+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
+
+
+ string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "fastq";
+ outputNames.push_back(outputFile); outputTypes["fastq"].push_back(outputFile);
+
+ ofstream out;
+ m->openOutputFile(outputFile, out);
+
+ ifstream qFile;
+ m->openInputFile(qualfile, qFile);
+
+ ifstream fFile;
+ m->openInputFile(fastafile, fFile);
+
+ while (!fFile.eof() && !qFile.eof()) {
+
+ if (m->control_pressed) { break; }
+
+ Sequence currSeq(fFile); m->gobble(fFile);
+ QualityScores currQual(qFile); m->gobble(qFile);
+
+ if (currSeq.getName() != currQual.getName()) { m->mothurOut("[ERROR]: mismatch between fasta and quality files. Found " + currSeq.getName() + " in fasta file and " + currQual.getName() + " in quality file."); m->mothurOutEndLine(); m->control_pressed = true; }
+ else {
+ //print sequence
+ out << '@' << currSeq.getName() << endl << currSeq.getAligned() << endl;
+
+ string qualityString = convertQual(currQual.getQualityScores());
+
+ //print quality info
+ out << '+' << currQual.getName() << endl << qualityString << endl;
+ }
+
+ }
+
+ fFile.close();
+ qFile.close();
+ out.close();
+
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "execute");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+string MakeFastQCommand::convertQual(vector<int> qual) {
+ try {
+ string qualScores;
+
+ int controlChar = int('!');
+
+ for (int i = 0; i < qual.size(); i++) {
+ int temp = qual[i] + controlChar;
+ char qualChar = (char) temp;
+
+ qualScores += qualChar;
+ }
+
+ return qualScores;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MakeFastQCommand", "convertQual");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+
+
+
+
--- /dev/null
+#ifndef MAKEFASTQCOMMAND_H
+#define MAKEFASTQCOMMAND_H
+
+/*
+ * makefastqcommand.h
+ * mothur
+ *
+ * Created by westcott on 2/14/11.
+ * Copyright 2011 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "command.hpp"
+
+class MakeFastQCommand : public Command {
+
+public:
+
+ MakeFastQCommand(string);
+ MakeFastQCommand();
+ ~MakeFastQCommand(){}
+ vector<string> getRequiredParameters();
+ vector<string> getValidParameters();
+ vector<string> getRequiredFiles();
+ map<string, vector<string> > getOutputFiles() { return outputTypes; }
+ int execute();
+ void help();
+
+private:
+
+ string fastafile, qualfile, outputDir;
+ bool abort;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
+
+ string convertQual(vector<int>);
+
+};
+
+#endif
+
+
QualityScores();
QualityScores(ifstream&);
string getName();
+ vector<int> getQualityScores() { return qScores; }
void printQScores(ofstream&);
void trimQScores(int, int);
void flipQScores();
m->mothurOutEndLine();
- m-mothurOut("Total time: " + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/CLOCKS_PER_SEC) + '\n');
+ m->mothurOut("Total time: " + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/CLOCKS_PER_SEC) + '\n');
return fDistFileName;