From 788ddbd8e113cd4f9694aee779c5b5dcca26e30b Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 25 Apr 2020 11:38:29 -0700 Subject: feat: updated fasta code to allow for iteration --- include/libbio.h | 17 ++++++++++------- include/libn.h | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/libbio.h b/include/libbio.h index 2dc3d45..4c93656 100644 --- a/include/libbio.h +++ b/include/libbio.h @@ -31,11 +31,14 @@ error bio·writenewick(bio·Tree tree, io·Putter out, void*); // ----------------------------------------------------------------------- // Sequences -#if 0 typedef struct bio·FastaReader bio·FastaReader; - -/* fasta/q i/o */ -bio·Seq *bio·newfastareader(Stream *file, mem·Allocator heap); -bio·Seq *bio·readfasta(bio·FastaParser *p); -error bio·writefasta(bio·Seq *seq, Stream *out); -#endif +typedef struct bio·Seq +{ + int len; + byte *name; + byte *s; + byte *q; +} bio·Seq; + +bio·FastaReader *bio·newfastareader(io·Reader stream, void *s, mem·Allocator heap, void *h); +error bio·readfasta(bio·FastaReader *rdr, bio·Seq *seq); diff --git a/include/libn.h b/include/libn.h index 43600c0..99e4fdb 100644 --- a/include/libn.h +++ b/include/libn.h @@ -113,6 +113,8 @@ error coro·free(Coro *c); // I/O typedef FILE Stream; +typedef struct stat io·Stat; + enum SeekPos { seek·CUR = SEEK_CUR, @@ -121,11 +123,13 @@ enum SeekPos }; Stream *io·open(byte *name, byte *mode); +int io·fd(Stream *s); +error io·stat(Stream *s, io·Stat *buf); error io·close(Stream *s); byte io·getbyte(Stream *s); error io·ungetbyte(Stream *s, byte c); int io·read(Stream *s, int sz, int n, void *buf); -int io·readln(Stream *s, int n, byte* buf); +int io·readln(Stream *s, int n, byte *buf); error io·putbyte(Stream *s, byte c); int io·putstring(Stream *s, string str); int io·write(Stream *s, int sz, int n, void *buf); @@ -139,6 +143,11 @@ typedef struct io·Reader int (*read)(void*, int sz, int n, void *buf); } io·Reader; +typedef struct io·LineReader +{ + int (*readln)(void*, int n, void *buf); +} io·LineReader; + typedef struct io·Peeker { byte (*get)(void*); @@ -174,6 +183,18 @@ typedef struct io·ReadWriter io·Writer; } io·ReadWriter; +// ----------------------------------------------------------------------------- +// memory mapped files + +typedef struct mmap·Reader +{ + vlong len; + void* buf; +} mmap·Reader; + +mmap·Reader mmap·open(byte *name); +error mmap·close(mmap·Reader rdr); + // ----------------------------------------------------------------------------- // libflate // NOTE: Experimental! -- cgit v1.2.1