5 * Created by Pat Schloss on 12/19/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
10 #include "sequence.hpp"
12 #include "alignment.hpp"
13 #include "nastreport.hpp"
16 /******************************************************************************************************************/
18 NastReport::NastReport() {
21 /******************************************************************************************************************/
22 string NastReport::getHeaders() {
25 output += "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
26 output += "SearchMethod\tSearchScore\t";
27 output += "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
28 output += "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
29 output += "LongestInsert\t";
30 output += "SimBtwnQuery&Template\n";
34 /******************************************************************************************************************/
36 NastReport::NastReport(string candidateReportFName) {
37 openOutputFile(candidateReportFName, candidateReportFile);
39 candidateReportFile << "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
40 candidateReportFile << "SearchMethod\tSearchScore\t";
41 candidateReportFile << "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
42 candidateReportFile << "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
43 candidateReportFile << "LongestInsert\t";
44 candidateReportFile << "SimBtwnQuery&Template" << endl;
47 /******************************************************************************************************************/
49 NastReport::~NastReport() {
50 candidateReportFile.close();
53 /******************************************************************************************************************/
55 void NastReport::print(){
57 candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t';
58 candidateReportFile << searchMethod << '\t' << setprecision(2) << fixed << searchScore << '\t';
60 candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t';
61 candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t';
62 candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t';
63 candidateReportFile << longestInsert << '\t';
64 candidateReportFile << setprecision(2) << similarityToTemplate;
66 candidateReportFile << endl;
67 candidateReportFile.flush();
69 /******************************************************************************************************************/
71 string NastReport::getReport(){
75 output += queryName + '\t' + toString(queryLength) + '\t' + templateName + '\t' + toString(templateLength) + '\t';
77 string temp = toString(searchScore);
78 int pos = temp.find_last_of('.'); //find deicmal point if their is one
80 //if there is a decimal
81 if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
82 else{ temp += ".00"; }
84 output += searchMethod + '\t' + temp + '\t';
85 output += alignmentMethod + '\t' + toString(candidateStartPosition) + "\t" + toString(candidateEndPosition) + '\t';
86 output += toString(templateStartPosition) + "\t" + toString(templateEndPosition) + '\t';
87 output += toString(pairwiseAlignmentLength) + '\t' + toString(totalGapsInQuery) + '\t' + toString(totalGapsInTemplate) + '\t';
88 output += toString(longestInsert) + '\t';
90 temp = toString(similarityToTemplate);
91 pos = temp.find_last_of('.'); //find deicmal point if their is one
93 //if there is a decimal
94 if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
95 else{ temp += ".00"; }
97 output += temp + '\n';
102 /******************************************************************************************************************/
104 void NastReport::setCandidate(Sequence* candSeq){
105 queryName = candSeq->getName();
106 queryLength = candSeq->getNumBases();
109 /******************************************************************************************************************/
111 void NastReport::setTemplate(Sequence* tempSeq){
112 templateName = tempSeq->getName();
113 templateLength = tempSeq->getNumBases();
116 /******************************************************************************************************************/
118 void NastReport::setSearchParameters(string method, float score){
119 searchMethod = method;
123 /******************************************************************************************************************/
125 void NastReport::setAlignmentParameters(string method, Alignment* align){
126 alignmentMethod = method;
128 candidateStartPosition = align->getCandidateStartPos();
129 candidateEndPosition = align->getCandidateEndPos();
130 templateStartPosition = align->getTemplateStartPos();
131 templateEndPosition = align->getTemplateEndPos();
132 pairwiseAlignmentLength = align->getPairwiseLength();
134 totalGapsInQuery = pairwiseAlignmentLength - (candidateEndPosition - candidateStartPosition + 1);
135 totalGapsInTemplate = pairwiseAlignmentLength - (templateEndPosition - templateStartPosition + 1);
138 /******************************************************************************************************************/
140 void NastReport::setNastParameters(Nast nast){
142 longestInsert = nast.getMaxInsertLength();
143 similarityToTemplate = nast.getSimilarityScore();
147 /******************************************************************************************************************/