]> git.donarmstrong.com Git - mothur.git/blob - nastreport.cpp
a few minor things - pds
[mothur.git] / nastreport.cpp
1 /*
2  *  nastreport.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 12/19/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
10 #include "sequence.hpp"
11 #include "nast.hpp"
12 #include "alignment.hpp"
13 #include "nastreport.hpp"
14
15 /******************************************************************************************************************/
16
17 NastReport::NastReport(string candidateReportFName) {
18         openOutputFile(candidateReportFName, candidateReportFile);
19         
20         candidateReportFile << "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
21         candidateReportFile << "SearchMethod\tSearchScore\t";
22         candidateReportFile << "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
23         candidateReportFile << "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
24         candidateReportFile << "LongestInsert\t";
25         candidateReportFile << "SimBtwnQuery&Template" << endl;
26 }
27
28 /******************************************************************************************************************/
29
30 NastReport::~NastReport() {
31         candidateReportFile.close();
32 }
33
34 /******************************************************************************************************************/
35
36 void NastReport::print(){
37         
38         candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t';
39         candidateReportFile << searchMethod << '\t' << setprecision(2) << fixed << searchScore << '\t';
40
41         candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t';
42         candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t';
43         candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t';
44         candidateReportFile << longestInsert << '\t';;
45         candidateReportFile << setprecision(2) << similarityToTemplate;
46         
47         candidateReportFile << endl;
48         candidateReportFile.flush();
49 }
50
51 /******************************************************************************************************************/
52
53 void NastReport::setCandidate(Sequence* candSeq){ 
54         queryName = candSeq->getName();
55         queryLength = candSeq->getNumBases();
56 }
57
58 /******************************************************************************************************************/
59
60 void NastReport::setTemplate(Sequence* tempSeq){ 
61         templateName = tempSeq->getName();
62         templateLength = tempSeq->getNumBases();
63 }
64
65 /******************************************************************************************************************/
66
67 void NastReport::setSearchParameters(string method, float score){
68         searchMethod = method;
69         searchScore = score;
70 }
71
72 /******************************************************************************************************************/
73
74 void NastReport::setAlignmentParameters(string method, Alignment* align){
75         alignmentMethod = method;
76         
77         candidateStartPosition = align->getCandidateStartPos();
78         candidateEndPosition = align->getCandidateEndPos();
79         templateStartPosition = align->getTemplateStartPos();
80         templateEndPosition = align->getTemplateEndPos();
81         pairwiseAlignmentLength = align->getPairwiseLength();
82
83         totalGapsInQuery = pairwiseAlignmentLength - (candidateEndPosition - candidateStartPosition + 1);
84         totalGapsInTemplate = pairwiseAlignmentLength - (templateEndPosition - templateStartPosition + 1);
85 }
86
87 /******************************************************************************************************************/
88
89 void NastReport::setNastParameters(Nast nast){
90
91         longestInsert = nast.getMaxInsertLength();
92         similarityToTemplate = nast.getSimilarityScore();
93         
94 }
95
96 /******************************************************************************************************************/