]> git.donarmstrong.com Git - mothur.git/blob - nastreport.cpp
fixed some bugs
[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 void NastReport::print(){
31         
32         candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t';
33         candidateReportFile << searchMethod << '\t' << setprecision(2) << fixed << searchScore << '\t';
34
35         candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t';
36         candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t';
37         candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t';
38         candidateReportFile << longestInsert << '\t';;
39         candidateReportFile << setprecision(2) << similarityToTemplate;
40         
41         candidateReportFile << endl;
42         candidateReportFile.flush();
43 }
44
45 /******************************************************************************************************************/
46
47 void NastReport::setCandidate(Sequence* candSeq){ 
48         queryName = candSeq->getName();
49         queryLength = candSeq->getNumBases();
50 }
51
52 /******************************************************************************************************************/
53
54 void NastReport::setTemplate(Sequence* tempSeq){ 
55         templateName = tempSeq->getName();
56         templateLength = tempSeq->getNumBases();
57 }
58
59 /******************************************************************************************************************/
60
61 void NastReport::setSearchParameters(string method, float score){
62         searchMethod = method;
63         searchScore = score;
64 }
65
66 /******************************************************************************************************************/
67
68 void NastReport::setAlignmentParameters(string method, Alignment* align){
69         alignmentMethod = method;
70         
71         candidateStartPosition = align->getCandidateStartPos();
72         candidateEndPosition = align->getCandidateEndPos();
73         templateStartPosition = align->getTemplateStartPos();
74         templateEndPosition = align->getTemplateEndPos();
75         pairwiseAlignmentLength = align->getPairwiseLength();
76
77         totalGapsInQuery = pairwiseAlignmentLength - (candidateEndPosition - candidateStartPosition + 1);
78         totalGapsInTemplate = pairwiseAlignmentLength - (templateEndPosition - templateStartPosition + 1);
79 }
80
81 /******************************************************************************************************************/
82
83 void NastReport::setNastParameters(Nast nast){
84
85         longestInsert = nast.getMaxInsertLength();
86         similarityToTemplate = nast.getSimilarityScore();
87         
88 }
89
90 /******************************************************************************************************************/