Legofit
infers population history from nucleotide site patterns.
Macros | Functions
dafreader.c File Reference

Class DAFReader: read a daf file. More...

#include "dafreader.h"
#include "tokenizer.h"
#include "misc.h"
#include "error.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <unistd.h>

Macros

#define MAXFIELDS   5
 
#define MAX(X, Y)   ((X) > (Y) ? (X) : (Y))
 
#define MIN(X, Y)   ((X) > (Y) ? (Y) : (X))
 

Functions

int iscomment (const char *s)
 Return 1 if first non-white character in string is '#'; 0 otherwise.
 
int DAFReader_cmp (const DAFReader *lhs, const DAFReader *rhs)
 Compare two DAFReader objects. More...
 
DAFReaderDAFReader_new (const char *fname)
 DAFReader constructor.
 
void DAFReader_clearChromosomes (int n, DAFReader *r[n])
 Clear all chromosome names.
 
void DAFReader_free (DAFReader *self)
 DAFReader destructor.
 
int DAFReader_next (DAFReader *self)
 Read the next site. More...
 
int DAFReader_rewind (DAFReader *self)
 Rewind daf file. More...
 
int DAFReader_multiNext (int n, DAFReader *r[n])
 
int DAFReader_allelesMatch (int n, DAFReader *r[n])
 Return 1 if ancestral and derived alleles of all readers match; 0 otherwise.
 
void DAFReader_printHdr (FILE *fp)
 Print header for daf file.
 
void DAFReader_print (DAFReader *r, FILE *fp)
 Print current line of daf file.
 
double DAFReader_daf (DAFReader *r)
 Return derived allele frequency of current line of daf file.
 

Detailed Description

Class DAFReader: read a daf file.

Function Documentation

◆ DAFReader_cmp()

int DAFReader_cmp ( const DAFReader lhs,
const DAFReader rhs 
)

Compare two DAFReader objects.

If the "chr" fields differ, return positive if lhs->chr > rhs->chr; return negative if the reverse inequality holds. Otherwise return positive, 0, or negative to match the sign of lhs->nucpos - rhs->nucpos.

◆ DAFReader_next()

int DAFReader_next ( DAFReader self)

Read the next site.

Returns
0 on success; EOF on end of file; abort on other errors.

References iscomment(), strlowercase(), Tokenizer_print(), Tokenizer_printSummary(), Tokenizer_split(), Tokenizer_strip(), and Tokenizer_token().

◆ DAFReader_rewind()

int DAFReader_rewind ( DAFReader self)

Rewind daf file.

Returns
0 on success; -1 on failure