-
Notifications
You must be signed in to change notification settings - Fork 277
/
mutation_type.cpp
48 lines (39 loc) · 1.09 KB
/
mutation_type.cpp
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
#include "mutation.h" // IWYU pragma: associated
#include "json.h"
struct mutation_type {
std::string id;
};
std::map<std::string, mutation_type> mutation_types;
void load_mutation_type( const JsonObject &jsobj )
{
mutation_type new_type;
new_type.id = jsobj.get_string( "id" );
mutation_types[new_type.id] = new_type;
}
void reset_mutation_types()
{
mutation_types.clear();
}
bool mutation_type_exists( const std::string &id )
{
return mutation_types.find( id ) != mutation_types.end();
}
std::vector<trait_id> get_mutations_in_type( const std::string &id )
{
std::vector<trait_id> ret;
for( auto it : mutation_branch::get_all() ) {
if( it.types.find( id ) != it.types.end() ) {
ret.push_back( it.id );
}
}
return ret;
}
std::vector<trait_id> get_mutations_in_types( const std::set<std::string> &ids )
{
std::vector<trait_id> ret;
for( const std::string &it : ids ) {
std::vector<trait_id> this_id = get_mutations_in_type( it );
ret.insert( ret.end(), this_id.begin(), this_id.end() );
}
return ret;
}