File: SAMQVConversion.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 (31 lines) | stat: -rw-r--r-- 1,104 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
#include <alignment/datastructures/alignmentset/SAMQVConversion.hpp>
#include <pbdata/FASTQSequence.hpp>

#include <cassert>
#include <cstddef>

void QualityVectorToPrintable(unsigned char *data, int length)
{
    if (data == NULL) {
        return;
    }
    for (int i = 0; i < length; i++) {
        data[i] = (((unsigned char)data[i]) == MAX_STORED_QUALITY) ? MAX_PRINTED_QUALITY
                                                                   : (unsigned char)data[i];
        data[i] = (((unsigned char)data[i]) == SENTINAL) ? MAP_SENTINAL : (unsigned char)data[i];
        assert(data[i] != 255);
    }
}

void QualityStringToStored(unsigned char *data, int length)
{
    if (data == NULL) {
        return;
    }
    for (int i = 0; i < length; i++) {
        data[i] = data[i] - FASTQSequence::charToQuality;
        data[i] = ((unsigned char)data[i]) == MAX_PRINTED_QUALITY ? MAX_STORED_QUALITY
                                                                  : (unsigned char)data[i];
        data[i] = ((unsigned char)data[i]) == MAP_SENTINAL ? SENTINAL : (unsigned char)data[i];
    }
}