 #include <nvbio/basic/dna.h>
 #include <thrust/host_vector.h>
 #include <thrust/device_vector.h>
+#include <zlib/zlib.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <vector>


            char_read[ read.length() ] = '\n';

            fwrite( &char_read[0], sizeof(char), read.length()+1, output_file );
        }

        n_reads += h_read_data.size();

        log_verbose(stderr,"\r    %u reads    ", n_reads);
    }
    log_verbose_cont(stderr,"\n");
    return true;
}

int main(int argc, char* argv[])
{
    if (argc < 2)
    {
        log_info(stderr, "nvExtractReads [options] input output\n");
        log_info(stderr, "  extract a set of reads to a plain ASCII file with one read per line (.txt)\n\n");
        log_info(stderr, "options:\n");
        log_info(stderr, "  --verbosity\n");
        log_info(stderr, "  -F | --skip-forward          skip forward strand\n");
        log_info(stderr, "  -R | --skip-reverse          skip forward strand\n");
        exit(0);
    }

    const char* reads_name  = argv[argc-2];
    const char* out_name    = argv[argc-1];
    bool  forward           = true;
    bool  reverse           = true;
    io::QualityEncoding qencoding = io::Phred33;

    for (int i = 0; i < argc - 2; ++i)

        {
            reverse = false;
        }
        else if (strcmp( argv[i], "-a" ) == 0 ||
                 strcmp( argv[i], "--ascii" ) == 0)  // ascii format
        {
            format = ASCII;
        }
        else if (strcmp( argv[i], "-p2" ) == 0 ||
                 strcmp( argv[i], "--packed-2" ) == 0)  // 2-bits packed
        {
            format = PACKED2;
        }
        else if (strcmp( argv[i], "-p4" ) == 0 ||
                 strcmp( argv[i], "--packed-4" ) == 0)  // 4-bits packed
        {
            format = PACKED4;
        }
        else if (strcmp( argv[i], "-i" ) == 0 ||
                 strcmp( argv[i], "--idx" ) == 0)       // index file
        {
            idx_name = argv[++i];
        }
    }

    std::string out_string = out_name;
    // parse out file extension; look for .fastq.gz, .fastq suffixes
    uint32 len = uint32( strlen(out_name) );
    bool is_gzipped = false;

    // do we have a .gz suffix?
    if (len >= strlen(".gz"))
    {
        if (strcmp(&out_name[len - strlen(".gz")], ".gz") == 0)
        {
            is_gzipped = true;
            len = uint32(len - strlen(".gz"));
        }
    }

    void* output_file  = NULL;
    void* output_index = NULL;

    if (format == ASCII)
    {
        // open a plain ASCII file
        output_file = gzopen( out_name, is_gzipped ? "w1R" : "w" );
    }
    else
    {
        // open a binary file
        output_file = gzopen( out_name, is_gzipped ? "wb1R" : "wbT" );
    }

    if (output_file == NULL)
    {
        log_error(stderr, "    failed opening file \"%s\"\n", out_name);
        return 1;
    }

    if (idx_name)
    {
        output_index = fopen( idx_name, "wb" );
        if (output_index == NULL)
        {
            log_error(stderr, "    failed opening file \"%s\"\n", idx_name);
            return 1;
        }
    }

    log_visible(stderr,"nvExtractReads... started\n");
