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; }
bool rna_splice_dict_get( struct rna_splice_dict * dict, uint32_t pos, uint32_t len, splice_dict_entry * entry ) { bool res = false; if ( dict != NULL ) { rc_t rc; union dict_key_union ku; union dict_value_union vu; ku.key_struct.pos = pos; ku.key_struct.len = len; rc = KVectorGetU64 ( dict->v, ku.key, &(vu.value) ); res = ( rc == 0 ); if ( res && entry != NULL ) { entry->count = vu.entry.count; entry->intron_type = vu.entry.intron_type; } } return res; }
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; }
static void get_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, uint32_t *total, uint32_t *mismatch ) { counter_union u; uint64_t key = encode_key( pos, max_q, nread, dimer, gc, hp, qual ); if ( KVectorGetU64 ( v, key, &(u.value) ) == 0 ) { *total = u.counters.total; *mismatch = u.counters.mismatch; } else { *total = 0; *mismatch = 0; } }