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