Code Monkey home page Code Monkey logo

crlf's Introduction

CRLF, or Concise Run-Length Format, is a lightweight format to store run-length encoded strings, typically for small alphabets such as DNA. This repository contains the spec, a library and a tool to convert encodings. The library is implemented in two files crlf.h and crlf.c without any dependencies to other libraries.

The minimal code create a CRLF to stdout from a BWT string:

uint32_t dectab[256], l_BWT, i;
uint8_t *BWT; // $ACGTN encoded as 012345
crlf_t *crlf;
crlf_dectab_RL53(dectab); // generate the decoding table
crlf = crlf_create(0, 6, dectab, crlf_write_RL53, 0, 0);
for (i = 0; i < l_BWT; ++i)
    crlf_write(crlf, BWT[i], 1);
crlf_close(crlf);

The minimal code to read a CRLF from stdin:

int c;
uint64_t i, l;
crlf_t *crlf;
crlf = crlf_open(0);
while ((c = crlf_read(crlf, &l)) >= 0)
    for (i = 0; i < l; ++i)
        putchar("$ACGTN"[c]);
crlf_close(crlf);

Basic APIs (see crlf.h for details):

  • crlf_create() creates a CRLF and writes the header, with a user-provided decoding table and a function pointer for encoding a run.

  • crlf_open() opens an existing CRLF for reading.

  • crlf_close() closes a CRLF.

  • crlf_write() writes a run to CRLF. If this function is called consecutively on runs of the same symbol, these runs will be merged.

  • crlf_read() reads a run from CRLF until it meets the next run of a different symbol from the current run.

crlf's People

Contributors

lh3 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.