utils.h 1.12 KB
Newer Older
Romain Feron's avatar
Romain Feron committed
1
2
3
4
5
6
7
8
9
#pragma once

#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <time.h>
#include <cmath>
#include <algorithm>
Romain Feron's avatar
Romain Feron committed
10
#include <unordered_map>
11
#include <map>
Romain Feron's avatar
Romain Feron committed
12
13
14
15

#define DTTMFMT "%Y-%m-%d %H:%M:%S"
#define DTTMSZ 21

16
// Store information about a locus for the loci analysis
17
18
19
20
21
struct Locus {
    std::string id;
    std::string sequence;
    std::vector<std::string> coverage;
};
Romain Feron's avatar
Romain Feron committed
22

23
24
25
26
27
28
29
30
31
32
// Store information about a mapped sequence for the mapping analysis
struct MappedSequence {
    std::string id;
    std::string contig;
    int position;
    double sex_bias;
    double p;
};

// Store sex distribution resutls
33
typedef std::unordered_map<uint, std::unordered_map<uint, std::pair<uint64_t, double>>> sd_table;
34

Romain Feron's avatar
Romain Feron committed
35
36
37
// Output current date and time in format specified with DMTTMFMT and DTTMSZ
char* print_time (char *buff);

38
// Split a std::string into a std::vector of std::strings according to a specified delimiter (default: \t)
Romain Feron's avatar
Romain Feron committed
39
std::vector<std::string> split(std::string str, const std::string delimiter);
Romain Feron's avatar
Romain Feron committed
40

41
// Reverse complement of a sequence
Romain Feron's avatar
Romain Feron committed
42
void rev_comp(const std::string& sequence, std::string& revcomp_sequence, char nuc);