-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbioinfo_data_structures.h
85 lines (59 loc) · 1.57 KB
/
bioinfo_data_structures.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
#ifndef _bioinfo_data_structures_h
#define _bioinfo_data_structures_h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "data_structures.h"
#define R 1.9858775229213840e-3
/* BED files */
typedef struct {
char chrom[10];
unsigned long int start;
unsigned long int end;
char name[80];
int size;
} Region;
Region* read_next_region(FILE *bed);
/* VCF files */
typedef struct {
char chrom[10];
unsigned long int pos;
char id[150];
char ref[150];
char alt[150];
char format[2];
} Variant;
typedef struct {
char *prefseq; // pointer to the refseq
int n_variants;
int n_diffs;
CharsDynArray differences; // dynarray with one character for each alt allele
IntsDynArray positions; // dynarray with one position for each alt allele
BoolsDynArray haplotype; // dynarray with one haplotype for each snp
} Seq;
void InitSeq(Seq *seq, char *refseq);
void AddVariant(Seq *seq, bool allele, int pos, char alt);
char GetNthCharOfSeq(Seq *seq, int n);
int GetPosOfNthDiff(Seq *seq, int n);
char* GetFullSeq(Seq *seq, char *s);
void FreeSeq(Seq *seq);
/* PWM files */
#define PWMID_MAX_LENGTH 80
struct PWM {
char id[PWMID_MAX_LENGTH];
double *matrix;
int length;
double concentration;
struct PWM *next;
};
typedef struct {
struct PWM *head;
struct PWM *tail;
int size;
double T;
} PWMList;
void InitPWMList(PWMList *list, double T);
void AddPWMToList(PWMList *list, struct PWM *pwm);
struct PWM* ReadNextPWM(FILE *pwm, PWMList *list);
void FreePWMList(PWMList *list);
#endif