File: IntervalPrinter.cpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,020 kB
  • sloc: cpp: 77,250; python: 331; sh: 103; makefile: 41
file content (56 lines) | stat: -rw-r--r-- 2,467 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
#include <alignment/format/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" << std::endl;
}