aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-04-25 11:38:29 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-04-25 11:38:29 -0700
commit788ddbd8e113cd4f9694aee779c5b5dcca26e30b (patch)
tree32e2db53cf5cd3fb907e6b17ab9ef6bdab8d9f4c /include
parent1f166f0a4ed9ed32ade1ed21a571c9b2d0171ebc (diff)
feat: updated fasta code to allow for iteration
Diffstat (limited to 'include')
-rw-r--r--include/libbio.h17
-rw-r--r--include/libn.h23
2 files changed, 32 insertions, 8 deletions
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*);
@@ -175,6 +184,18 @@ typedef struct io·ReadWriter
} 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!