Example #1
0
DebugOutput::DebugOutput(const char *file_name, AlignmentType alignment_type, BNT bnt)
    : OutputFile(file_name, alignment_type, bnt)
{
    if (alignment_type == PAIRED_END)
    {
        char fname[256];
        char *mate_number;

        NVBIO_CUDA_ASSERT(strlen(file_name) < sizeof(fname));
        strncpy(fname, file_name, sizeof(fname));

        mate_number = strstr(fname, "#");
        if (mate_number)
        {
            *mate_number = '1';
        }

        fp = gzopen(fname, "wb");

        if (mate_number)
        {
            *mate_number = '2';
            fp_opposite_mate = gzopen(fname, "wb");
        } else {
            fp_opposite_mate = fp;
        }
    } else {
        fp = gzopen(file_name, "wb");
        fp_opposite_mate = NULL;
    }
}
Example #2
0
void OutputFile::readback(struct CPUOutputBatch& cpu_batch,
                          const struct GPUOutputBatch& gpu_batch,
                          const AlignmentMate mate,
                          const AlignmentScore score)
{
    Timer timer;
    timer.start();

    // read back the scores
    // readback_scores will do the "right thing" based on the pass and score that we're getting
    // (i.e., it'll update either the first or second score for either the anchor or opposite mate)
    gpu_batch.readback_scores(cpu_batch.best_alignments, mate, score);

    if (score == BEST_SCORE)
    {
        // if this is the best alignment, read back CIGARs and MD strings as well
        gpu_batch.readback_cigars(cpu_batch.cigar[mate]);
        gpu_batch.readback_mds(cpu_batch.mds[mate]);

        if (mate == MATE_1)
        {
            // mate 1 best score comes first; stash the count
            cpu_batch.count = gpu_batch.count;

            // set up the read data pointers
            // this is not strictly related to which mate or scoring pass we're processing,
            // but must be done once per batch, so we do it here
            cpu_batch.read_data[MATE_1] = read_data_1;
            cpu_batch.read_data[MATE_2] = read_data_2;
        }
    }

    // sanity check to make sure the number of reads matches what we got previously
    // (for mate 1 best score this will always pass due to the assignment above)
    NVBIO_CUDA_ASSERT(cpu_batch.count == gpu_batch.count);

    timer.stop();
    iostats.output_process_timings.add(gpu_batch.count, timer.seconds());

    iostats.alignments_DtoH_time += timer.seconds();
    iostats.alignments_DtoH_count += gpu_batch.count;
}
Example #3
0
void BamOutput::close()
{
    // protect this section
    ScopedLock lock( &mutex );

    // flush all non-emtpy blocks
    if (data_buffers[ buffer_id ].get_pos())
        write_block();

    flush_blocks();

    NVBIO_CUDA_ASSERT(fp);

    // write out the BAM EOF marker
    static const unsigned char magic[28] =  { 0037, 0213, 0010, 0004, 0000, 0000, 0000, 0000, 0000,
                                              0377, 0006, 0000, 0102, 0103, 0002, 0000, 0033, 0000,
                                              0003, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000 };

    fwrite(magic, sizeof(magic), 1, fp);

    fclose(fp);
    fp = NULL;
}