Example #1
0
static rc_t TableWriterSeq_CollectStatistics(TableWriterSeq *self, const TableWriterData* primary_alignment_id)
{
    rc_t rc;
    int64_t mate[2] = {0, 0};
    uint64_t distance = 0;
    uint64_t count = 0;
    
    memcpy(mate, primary_alignment_id->buffer, sizeof(mate[0]) * primary_alignment_id->elements);
    if (mate[0] && mate[1]) {
        distance = (mate[0] < mate[1]) ? (mate[1] - mate[0]) : (mate[0] - mate[1]);
    }
    else
        return 0;
    if (self->stats == NULL) {
        rc = KVectorMake(&self->stats); if (rc) return rc;
    }
    rc = KVectorGetU64(self->stats, distance, &count);
    if (GetRCObject(rc) == rcItem && GetRCState(rc) == rcNotFound) {
        rc = KVectorSetU64(self->stats, distance, 1);
        if (rc == 0) ++self->statsCount;
    }
    else if (rc == 0) {
        ++count;
        rc = KVectorSetU64(self->stats, distance, count);
    }
    return rc;
}
Example #2
0
void rna_splice_dict_set( struct rna_splice_dict * dict,
                          uint32_t pos, uint32_t len, const splice_dict_entry * entry )
{
    if ( dict != NULL && entry != NULL )
    {
        union dict_key_union ku;
        union dict_value_union vu;

        ku.key_struct.pos = pos;
        ku.key_struct.len = len;
        vu.entry.count = entry->count;
        vu.entry.intron_type = entry->intron_type;
        KVectorSetU64 ( dict->v, ku.key, vu.value );
    }
}
Example #3
0
static bool set_counter( KVector *v,
                         const uint32_t pos,
                         const uint8_t max_q,
                         const uint8_t nread,
                         const uint8_t dimer,
                         const uint8_t gc,
                         const uint8_t hp,
                         const uint8_t qual,
                         bool mismatch )
{
    bool res = false;
    counter_union u;
    uint64_t key = encode_key( pos, max_q, nread, dimer, gc, hp, qual );
    if ( KVectorGetU64 ( v, key, &(u.value) ) == 0 )
    {
        u.counters.total++;
        if ( mismatch )
        {
            u.counters.mismatch++;
        }
    }
    else
    {
        u.counters.total = 1;
        res = true;
        if ( mismatch )
        {
            u.counters.mismatch = 1;
        }
        else
        {
            u.counters.mismatch = 0;
        }
    }
    KVectorSetU64 ( v, key, u.value );
    return res;
}