Legofit
infers population history from nucleotide site patterns.
dafreader.h
1#ifndef DAFREADER_INCLUDED
2#define DAFREADER_INCLUDED
3
4#include "typedefs.h"
5#include <stdio.h>
6
7#define DAFSTRSIZE 20
8
9struct DAFReader {
10 char *fname;
11 FILE *fp;
12 Tokenizer *tkz;
13 int ispipe; // 1 if fp is a pipe; 0 otherwise
14
15 // properties of current snp
16 long snpid; // 0-based index of current snp
17 char aa[DAFSTRSIZE]; // ancestral alleles
18 char da[DAFSTRSIZE]; // derived alleles
19 char chr[DAFSTRSIZE]; // chromosome
20 unsigned long nucpos; // nucleotide position from daf file
21 double p; // frequency of ancestral allele
22};
23
24DAFReader *DAFReader_new(const char *fname);
25void DAFReader_clearChromosomes(int n, DAFReader *r[n]);
26void DAFReader_free(DAFReader * self);
27int DAFReader_next(DAFReader * self);
28double DAFReader_daf(DAFReader *r);
29int DAFReader_allelesMatch(int n, DAFReader *r[n]);
30void DAFReader_printHdr(FILE *fp);
31void DAFReader_print(DAFReader *r, FILE *fp);
33int DAFReader_multiNext(int n, DAFReader *r[n]);
34static inline const char *DAFReader_chr(DAFReader *self);
35static inline unsigned long DAFReader_nucpos(DAFReader *self);
36
37
39static inline const char *DAFReader_chr(DAFReader *self) {
40 return self->chr;
41}
42
44static inline unsigned long DAFReader_nucpos(DAFReader *self) {
45 return self->nucpos;
46}
47#endif
void DAFReader_printHdr(FILE *fp)
Print header for daf file.
Definition: dafreader.c:477
void DAFReader_clearChromosomes(int n, DAFReader *r[n])
Clear all chromosome names.
Definition: dafreader.c:83
double DAFReader_daf(DAFReader *r)
Return derived allele frequency of current line of daf file.
Definition: dafreader.c:490
void DAFReader_print(DAFReader *r, FILE *fp)
Print current line of daf file.
Definition: dafreader.c:483
int DAFReader_rewind(DAFReader *self)
Rewind daf file.
Definition: dafreader.c:227
int DAFReader_allelesMatch(int n, DAFReader *r[n])
Return 1 if ancestral and derived alleles of all readers match; 0 otherwise.
Definition: dafreader.c:445
DAFReader * DAFReader_new(const char *fname)
DAFReader constructor.
Definition: dafreader.c:26
void DAFReader_free(DAFReader *self)
DAFReader destructor.
Definition: dafreader.c:90
int DAFReader_next(DAFReader *self)
Read the next site.
Definition: dafreader.c:116
Definition: dafreader.h:9
Definition: tokenizer.h:28