File: SAMPrinter.hpp

package info (click to toggle)
pbseqlib 5.3.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,020 kB
  • sloc: cpp: 77,246; python: 331; sh: 103; makefile: 42
file content (100 lines) | stat: -rw-r--r-- 4,005 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef _BLASR_FORMAT_SAMPRINTER_HPP_
#define _BLASR_FORMAT_SAMPRINTER_HPP_

#include <cstdint>
#include <sstream>

#include <alignment/datastructures/alignment/Alignment.hpp>
#include <alignment/datastructures/alignment/Alignment.hpp>
#include <alignment/datastructures/alignment/AlignmentCandidate.hpp>
#include <alignment/datastructures/alignment/AlignmentContext.hpp>
#include <alignment/datastructures/alignmentset/SAMSupplementalQVList.hpp>
#include <pbdata/SMRTSequence.hpp>

#define MULTI_SEGMENTS 0x1
#define ALL_SEGMENTS_ALIGNED 0x2
#define SEGMENT_UNMAPPED 0x4
#define NEXT_SEGMENT_UNMAPPED 0x8
#define SEQ_REVERSED 0x10
#define SEQ_NEXT_REVERSED 0x20
#define FIRST_SEGMENT 0x40
#define LAST_SEGMENT 0x80
#define SECONDARY_ALIGNMENT 0x100
#define NO_PASS_QUALITY 0x200
#define PCR_OR_OPTICAL_DUPLICATE 0x400

namespace SAMOutput {

enum Clipping
{
    hard,
    soft,
    subread,
    none
};

void BuildFlag(T_AlignmentCandidate &alignment, AlignmentContext &context, uint16_t &flag);

//
// Trimming is used for both hard non-clipping
// so it is called trim instead of clip.
//
void CreateDNAString(DNASequence &seq, DNASequence &clippedSeq, DNALength trimFront = 0,
                     DNALength trimEnd = 0);

void AddGaps(T_AlignmentCandidate &alignment, int gapIndex, std::vector<int> &opSize,
             std::vector<char> &opChar);

// Add sequence match/mismatch CIGAR string Ops for block b.
void AddMatchBlockCigarOps(DNASequence &qSeq, DNASequence &tSeq, blasr::Block &b,
                           DNALength &qSeqPos, DNALength &tSeqPos, std::vector<int> &opSize,
                           std::vector<char> &opChar);

// Merge adjacent indels and mismatches.
void MergeAdjacentIndels(std::vector<int> &opSize, std::vector<char> &opChar,
                         const char mismatchChar);

// If cigarUseSeqMatch is true, cigar string uses '=' and 'X'
// instead of 'M' to represent sequence match and mismatch;
void CreateNoClippingCigarOps(T_AlignmentCandidate &alignment, std::vector<int> &opSize,
                              std::vector<char> &opChar, bool cigarUseSeqMatch = false,
                              const bool allowAdjacentIndels = true);
//
//
// The aligned sequence is either the sequence from the first
// aligned base to the last (hard and no clipping), or first high
// quality base to the last high quality base (soft clipping).
//
template <typename T_Sequence>
void SetAlignedSequence(T_AlignmentCandidate &alignment, T_Sequence &read, T_Sequence &alignedSeq,
                        Clipping clipping = none);

template <typename T_Sequence>
void SetSoftClip(T_AlignmentCandidate &alignment, T_Sequence &read, DNALength hardClipPrefix,
                 DNALength hardClipSuffix, DNALength &softClipPrefix, DNALength &softClipSuffix);

template <typename T_Sequence>
void SetHardClip(T_AlignmentCandidate &alignment, T_Sequence &read, DNALength &prefixClip,
                 DNALength &suffixClip);

void CigarOpsToString(std::vector<int> &opSize, std::vector<char> &opChar,
                      std::string &cigarString);

//
// Straight forward: create the cigar string allowing some clipping
// The read is provided to give length and hq information.
//
template <typename T_Sequence>
void CreateCIGARString(T_AlignmentCandidate &alignment, T_Sequence &read, std::string &cigarString,
                       Clipping clipping, DNALength &prefixSoftClip, DNALength &suffixSoftClip,
                       DNALength &prefixHardClip, DNALength &suffixHardClip,
                       bool cigarUseSeqMatch = false, const bool allowAdjacentIndels = true);

template <typename T_Sequence>
void PrintAlignment(T_AlignmentCandidate &alignment, T_Sequence &read, std::ostream &samFile,
                    AlignmentContext &context, SupplementalQVList &qvList, Clipping clipping = none,
                    bool cigarUseSeqMatch = false, const bool allowAdjacentIndels = true);
}

#include "SAMPrinterImpl.hpp"
#endif  // _BLASR_FORMAT_SAMPRINTER_HPP_