//**********************************************************************************************************************
SeqErrorCommand::SeqErrorCommand(){
try {
- abort = true;
- //initialize outputTypes
+ abort = true; calledHelp = true;
vector<string> tempOutNames;
outputTypes["error.summary"] = tempOutNames;
outputTypes["error.seq"] = tempOutNames;
SeqErrorCommand::SeqErrorCommand(string option) {
try {
- abort = false;
+ abort = false; calledHelp = false;
//allow user to run help
- if(option == "help") { help(); abort = true; }
+ if(option == "help") { help(); abort = true; calledHelp = true; }
else {
string temp;
//***************************************************************************************************************
-SeqErrorCommand::~SeqErrorCommand(){
-
-}
+SeqErrorCommand::~SeqErrorCommand(){ /* void */ }
//***************************************************************************************************************
int SeqErrorCommand::execute(){
try{
- if (abort == true) { return 0; }
+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
string errorSummaryFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.summary";
m->openOutputFile(errorSummaryFileName, errorSummaryFile);
RefChimeraTest chimeraTest(referenceSeqs, errorChimeraFileName);
outputNames.push_back(errorChimeraFileName); outputTypes["error.chimera"].push_back(errorChimeraFileName);
+ vector<string> megaAlignVector(numRefs, "");
+
int index = 0;
bool ignoreSeq = 0;
else { minCompare.weight = 1; }
printErrorData(minCompare, numParentSeqs);
-
+
+
if(!ignoreSeq){
for(int i=0;i<minCompare.total;i++){
char letter = minCompare.sequence[i];
if(qualFileName != "" && reportFileName != ""){
report = ReportFile(reportFile);
- int origLength = report.getQueryLength();
+// int origLength = report.getQueryLength();
int startBase = report.getQueryStart();
int endBase = report.getQueryEnd();
- quality = QualityScores(qualFile, origLength);
+ quality = QualityScores(qualFile);
if(!ignoreSeq){
quality.updateQScoreErrorMap(qScoreErrorMap, minCompare.sequence, startBase, endBase, minCompare.weight);
}
misMatchCounts[minCompare.mismatches] += minCompare.weight;
numSeqs++;
+
+
+ megaAlignVector[closestRefIndex] += query.getInlineSeq() + '\n';
}
index++;
printSubMatrix();
+ string megAlignmentFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".ref-query";
+ ofstream megAlignmentFile;
+ m->openOutputFile(megAlignmentFileName, megAlignmentFile);
+
+ for(int i=0;i<numRefs;i++){
+ megAlignmentFile << referenceSeqs[i].getInlineSeq() << endl;
+ megAlignmentFile << megaAlignVector[i] << endl;
+ }
+
+
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
ifstream referenceFile;
m->openInputFile(referenceFileName, referenceFile);
+ int numAmbigSeqs = 0;
+
+ int maxStartPos = 0;
+ int minEndPos = 100000;
+
while(referenceFile){
Sequence currentSeq(referenceFile);
int numAmbigs = currentSeq.getAmbigBases();
+ if(numAmbigs > 0){ numAmbigSeqs++; }
- if(numAmbigs != 0){
- m->mothurOut("Warning: " + toString(currentSeq.getName()) + " has " + toString(numAmbigs) + " ambiguous bases, these bases will be removed\n");
- currentSeq.removeAmbigBases();
- }
+ int startPos = currentSeq.getStartPos();
+ if(startPos > maxStartPos) { maxStartPos = startPos; }
+
+ int endPos = currentSeq.getEndPos();
+ if(endPos < minEndPos) { minEndPos = endPos; }
referenceSeqs.push_back(currentSeq);
m->gobble(referenceFile);
}
+ referenceFile.close();
numRefs = referenceSeqs.size();
+
+ for(int i=0;i<numRefs;i++){
+ referenceSeqs[i].padToPos(maxStartPos);
+ referenceSeqs[i].padFromPos(minEndPos);
+ }
+
+ if(numAmbigSeqs != 0){
+ m->mothurOut("Warning: " + toString(numAmbigSeqs) + " reference sequences have ambiguous bases, these bases will be ignored\n");
+ }
- referenceFile.close();
}
catch(exception& e) {
m->errorOut(e, "SeqErrorCommand", "getReferences");
Compare errors;
for(int i=0;i<alignLength;i++){
- if(q[i] != '.' && r[i] != '.' && (q[i] != '-' || r[i] != '-')){ // no missing data and no double gaps
+ if(q[i] != 'N' && q[i] != '.' && r[i] != '.' && (q[i] != '-' || r[i] != '-')){ // no missing data and no double gaps
started = 1;
if(q[i] == 'A'){
if(started == 1){ break; }
}
else if(q[i] != '.' && r[i] == '.'){ // query extends beyond reference
- m->mothurOut("Warning: " + toString(query.getName()) + " extend beyond " + toString(reference.getName()) + ". Ignoring the extra bases in the query\n");
if(started == 1){ break; }
}
else if(q[i] == '.' && r[i] == '.'){ // both are missing data