File: IntervalPrinter.cpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (70 lines) | stat: -rw-r--r-- 2,661 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "IntervalPrinter.hpp"

void IntervalOutput::Print(T_AlignmentCandidate &alignment, 
    std::ostream &outFile) {

    int mapQV = alignment.mapQV;
    int lastBlock = alignment.blocks.size()-1;
    if (lastBlock < 0) return;

    outFile << alignment.qName << " " << alignment.tName << " " 
            << alignment.score << " " 
            << alignment.pctSimilarity << " " 
            << alignment.qStrand << " " 
            << alignment.QAlignStart() << " "
            << alignment.QAlignEnd() << " "
            << alignment.qLength << " "
            << alignment.tStrand << " "
            << alignment.TAlignStart() << " "
            << (alignment.tAlignedSeqPos + alignment.tPos
                + alignment.blocks[lastBlock].tPos 
                + alignment.blocks[lastBlock].length) << " "
            << alignment.tLength << " " 
            << mapQV << std::endl;
    //Remove the last four fields from m4 format.
    //<< " " << alignment.nCells << " " << alignment.clusterScore 
    //<< " " << alignment.probScore << " " 
    //<< alignment.numSignificantClusters 
} 

// Print an alignment from a sam file in Interval (m 4) format.
void IntervalOutput::PrintFromSAM(AlignmentCandidate<> &alignment, 
    std::ostream &outFile) {

    int mapQV = alignment.mapQV;
    int lastBlock = alignment.blocks.size()-1;
    if (lastBlock < 0) return;

    outFile << alignment.qName << " " 
            << alignment.tName << " " 
            << alignment.score << " " 
            << alignment.pctSimilarity << " " 
            << alignment.qStrand << " " 
            << alignment.QAlignStart() << " "
            << alignment.QAlignEnd() << " "
            << alignment.qLength << " "
            << alignment.tStrand << " ";

    DNALength tS = alignment.TAlignStart(); 
    DNALength tE = alignment.tAlignedSeqPos + alignment.tPos
                    + alignment.blocks[lastBlock].tPos 
                    + alignment.blocks[lastBlock].length;

    if (alignment.tStrand == 1) {
        // Since the alignment is from a SAM file and the reference 
        // is reverse, compute tS and tE in the coordinate of the reverse
        // complementary sequence
        DNALength tmp = tS;
        tS = alignment.tLength - tE;
        tE = alignment.tLength - tmp;
    }
    outFile << tS << " " << tE << " " << alignment.tLength << " " 
            << mapQV << std::endl;
}

void IntervalOutput::PrintHeader(std::ostream &out) {
    out << "qName tName score percentSimilarity qStrand " 
        << "qStart qEnd qLength tStrand tStart tEnd tLength mapQV" 
        << std::endl;
    //ncells clusterScore probscore numSigClusters" << endl;
}