-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompressedDNASequence.h
89 lines (73 loc) · 2.01 KB
/
CompressedDNASequence.h
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
#ifndef COMPRESSED_DNA_SEQUENCE_H_
#define COMPRESSED_DNA_SEQUENCE_H_
#include "DNASequence.h"
#include "FASTASequence.h"
#include "algorithms/compare/Compare4BitCompressed.h"
#include "defs.h"
#include <string.h>
#include "qvs/QualityValue.h"
typedef unsigned char CompressedNucleotide;
class CompressedDNASequence: public DNASequence {
static const unsigned char MaskCount = 0xf;
static const unsigned char MaskNuc = 0xf0;
static const unsigned char ShiftCount = 4;
public:
char *title;
int titleLength;
//
// This is just a placeholder for now.
// No extra data here, just the ability to decompress. Right now
// the utilities for the compressed dna sequences
// are in CompressedSeqUtils.h, which could move here later.
//
QualityValue *qual;
CompressedDNASequence() {
const char t[] = "Compressed sequence\0";
titleLength = strlen(t);
title = new char[titleLength+1];
strcpy(title, t);
title[titleLength] = '\0';
}
void MakeRC(CompressedDNASequence &rc) {
rc.Allocate(length);
DNALength i;
for (i = 0; i < length; i++) {
rc.seq[length - i - 1] = ReverseComplementNuc[ThreeBit[seq[i] & MaskCount]];
rc.seq[length - i - 1] += (seq[i] & MaskNuc);
}
memcpy(rc.title, title, titleLength);
rc.titleLength = titleLength;
}
Nucleotide operator[](DNALength i) {
return GetNuc(i);
}
Nucleotide GetNuc(DNALength i) {
return (seq[i] & MaskCount);
}
unsigned char GetCount(DNALength i) {
return seq[i] >> ShiftCount;
}
char *GetName() {
return (char*) title;
}
void Copy(FASTASequence &rhs) {
seq = new CompressedNucleotide[rhs.length];
memcpy(seq, rhs.seq, rhs.length);
length = rhs.length;
if (title != NULL) {
delete[] title;
}
title = new char[rhs.titleLength+1];
memcpy(title, rhs.title, rhs.titleLength);
titleLength = rhs.titleLength;
title[titleLength] = '\0';
}
float GetAverageQuality() {
return 0.0;
}
void SortHomopolymerQualities() {
cout << "qualities are not implemented for compressed sequences." << endl;
assert(0);
}
};
#endif