forked from marbl/Mash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandScreen.h
171 lines (148 loc) · 3.54 KB
/
CommandScreen.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Copyright © 2015, Battelle National Biodefense Institute (BNBI);
// all rights reserved. Authored by: Brian Ondov, Todd Treangen,
// Sergey Koren, and Adam Phillippy
//
// See the LICENSE.txt file included with this software for license information.
#ifndef INCLUDED_CommandScreen
#define INCLUDED_CommandScreen
#include "Command.h"
#include "Sketch.h"
#include <list>
#include <string>
#include <vector>
#include <atomic>
#include "robin_hood.h"
#include "MinHashHeap.h"
namespace mash {
struct HashTableEntry
{
HashTableEntry() : count(0) {}
uint32_t count;
robin_hood::unordered_set<uint64_t> indices;
};
//typedef robin_hood::unordered_map< uint64_t, HashTableEntry > HashTable;
typedef robin_hood::unordered_map< uint64_t, robin_hood::unordered_set<uint64_t> > HashTable;
static const robin_hood::unordered_map< std::string, char > codons =
{
{"AAA", 'K'},
{"AAC", 'N'},
{"AAG", 'K'},
{"AAT", 'N'},
{"ACA", 'T'},
{"ACC", 'T'},
{"ACG", 'T'},
{"ACT", 'T'},
{"AGA", 'R'},
{"AGC", 'S'},
{"AGG", 'R'},
{"AGT", 'S'},
{"ATA", 'I'},
{"ATC", 'I'},
{"ATG", 'M'},
{"ATT", 'I'},
{"CAA", 'Q'},
{"CAC", 'H'},
{"CAG", 'Q'},
{"CAT", 'H'},
{"CCA", 'P'},
{"CCC", 'P'},
{"CCG", 'P'},
{"CCT", 'P'},
{"CGA", 'R'},
{"CGC", 'R'},
{"CGG", 'R'},
{"CGT", 'R'},
{"CTA", 'L'},
{"CTC", 'L'},
{"CTG", 'L'},
{"CTT", 'L'},
{"GAA", 'E'},
{"GAC", 'D'},
{"GAG", 'E'},
{"GAT", 'D'},
{"GCA", 'A'},
{"GCC", 'A'},
{"GCG", 'A'},
{"GCT", 'A'},
{"GGA", 'G'},
{"GGC", 'G'},
{"GGG", 'G'},
{"GGT", 'G'},
{"GTA", 'V'},
{"GTC", 'V'},
{"GTG", 'V'},
{"GTT", 'V'},
{"TAA", '*'},
{"TAC", 'Y'},
{"TAG", '*'},
{"TAT", 'Y'},
{"TCA", 'S'},
{"TCC", 'S'},
{"TCG", 'S'},
{"TCT", 'S'},
{"TGA", '*'},
{"TGC", 'C'},
{"TGG", 'W'},
{"TGT", 'C'},
{"TTA", 'L'},
{"TTC", 'F'},
{"TTG", 'L'},
{"TTT", 'F'}
};
class CommandScreen : public Command
{
public:
struct HashInput
{
HashInput(robin_hood::unordered_map<uint64_t, std::atomic<uint32_t> > & hashCountsNew, MinHashHeap * minHashHeapNew, char * seqNew, uint64_t lengthNew, const Sketch::Parameters & parametersNew, bool transNew)
:
hashCounts(hashCountsNew),
minHashHeap(minHashHeapNew),
seq(seqNew),
length(lengthNew),
parameters(parametersNew),
trans(transNew)
{}
~HashInput()
{
if ( seq != 0 )
{
delete [] seq;
}
}
std::string fileName;
char * seq;
uint64_t length;
bool trans;
Sketch::Parameters parameters;
robin_hood::unordered_map<uint64_t, std::atomic<uint32_t> > & hashCounts;
MinHashHeap * minHashHeap;
};
struct HashOutput
{
HashOutput(MinHashHeap * minHashHeapNew)
:
minHashHeap(minHashHeapNew)
{}
MinHashHeap * minHashHeap;
};
CommandScreen();
int run() const; // override
private:
struct Reference
{
Reference(uint64_t amerCountNew, std::string nameNew, std::string commentNew)
: amerCount(amerCountNew), name(nameNew), comment(commentNew) {}
uint64_t amerCount;
std::string name;
std::string comment;
};
};
char aaFromCodon(const char * codon);
double estimateIdentity(uint64_t common, uint64_t denom, int kmerSize, double kmerSpace);
CommandScreen::HashOutput * hashSequence(CommandScreen::HashInput * input);
double pValueWithin(uint64_t x, uint64_t setSize, double kmerSpace, uint64_t sketchSize);
void translate(const char * src, char * dst, uint64_t len);
void useThreadOutput(CommandScreen::HashOutput * output, robin_hood::unordered_set<MinHashHeap *> & minHashHeaps);
} // namespace mash
#endif