X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=nastreport.cpp;h=132886bd55be4e9a57aa52816cfc49bcfb98eb42;hb=86b6cc7ce1ec7fce12cdfdd6225de4dee7cfbdbf;hp=67ec702fdd122b732b0f7e0598fe54f791a121c8;hpb=526a868606faa50caf86e7399f7554c0335b39e5;p=mothur.git diff --git a/nastreport.cpp b/nastreport.cpp index 67ec702..132886b 100644 --- a/nastreport.cpp +++ b/nastreport.cpp @@ -7,13 +7,30 @@ * */ -using namespace std; - #include "sequence.hpp" #include "nast.hpp" #include "alignment.hpp" #include "nastreport.hpp" + +/******************************************************************************************************************/ + +NastReport::NastReport() { + output = ""; +} +/******************************************************************************************************************/ +string NastReport::getHeaders() { + output = ""; + + output += "QueryName\tQueryLength\tTemplateName\tTemplateLength\t"; + output += "SearchMethod\tSearchScore\t"; + output += "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t"; + output += "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t"; + output += "LongestInsert\t"; + output += "SimBtwnQuery&Template\n"; + + return output; +} /******************************************************************************************************************/ NastReport::NastReport(string candidateReportFName) { @@ -29,6 +46,12 @@ NastReport::NastReport(string candidateReportFName) { /******************************************************************************************************************/ +NastReport::~NastReport() { + candidateReportFile.close(); +} + +/******************************************************************************************************************/ + void NastReport::print(){ candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t'; @@ -37,25 +60,57 @@ void NastReport::print(){ candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t'; candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t'; candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t'; - candidateReportFile << longestInsert << '\t';; + candidateReportFile << longestInsert << '\t'; candidateReportFile << setprecision(2) << similarityToTemplate; candidateReportFile << endl; candidateReportFile.flush(); } +/******************************************************************************************************************/ + +string NastReport::getReport(){ + + output = ""; + + output += queryName + '\t' + toString(queryLength) + '\t' + templateName + '\t' + toString(templateLength) + '\t'; + + string temp = toString(searchScore); + int pos = temp.find_last_of('.'); //find deicmal point if their is one + + //if there is a decimal + if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places + else{ temp += ".00"; } + + output += searchMethod + '\t' + temp + '\t'; + output += alignmentMethod + '\t' + toString(candidateStartPosition) + "\t" + toString(candidateEndPosition) + '\t'; + output += toString(templateStartPosition) + "\t" + toString(templateEndPosition) + '\t'; + output += toString(pairwiseAlignmentLength) + '\t' + toString(totalGapsInQuery) + '\t' + toString(totalGapsInTemplate) + '\t'; + output += toString(longestInsert) + '\t'; + + temp = toString(similarityToTemplate); + pos = temp.find_last_of('.'); //find deicmal point if their is one + + //if there is a decimal + if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places + else{ temp += ".00"; } + + output += temp + '\n'; + + return output; +} /******************************************************************************************************************/ void NastReport::setCandidate(Sequence* candSeq){ queryName = candSeq->getName(); - queryLength = candSeq->getUnalignLength(); + queryLength = candSeq->getNumBases(); } /******************************************************************************************************************/ void NastReport::setTemplate(Sequence* tempSeq){ templateName = tempSeq->getName(); - templateLength = tempSeq->getUnalignLength(); + templateLength = tempSeq->getNumBases(); } /******************************************************************************************************************/