Exemple #1
0
LIB_EXPORT rc_t CC AlignAccessAlignmentEnumeratorNext(const AlignAccessAlignmentEnumerator *cself) {
    rc_t rc;
    AlignAccessAlignmentEnumerator *self = (AlignAccessAlignmentEnumerator *)cself;
    int32_t refSeqID;

AGAIN:
    if (self->innerSelf != NULL) {
        BAMAlignmentRelease(self->innerSelf);
        self->innerSelf = NULL;
    }
    if (self->atend != 0)
        return AlignAccessAlignmentEnumeratorEOFCode;
    
    if (self->slice == NULL) {
        rc = BAMFileRead2(self->parent->innerSelf, &self->innerSelf);
        if (rc) {
            if (GetRCState(rc) == rcNotFound && GetRCObject(rc) == rcRow) {
                self->atend = 1;
                rc = AlignAccessAlignmentEnumeratorEOFCode;
            }
        }
        return rc;
    }
    rc = BAMFileReadSlice(self->parent->innerSelf, &self->innerSelf, self->slice);
    if (rc) {
        if (GetRCState(rc) == rcNotFound && GetRCObject(rc) == rcRow) {
            self->atend = 1;
            rc = AlignAccessAlignmentEnumeratorEOFCode;
        }
        return rc;
    }
    if (!BAMAlignmentIsMapped(self->innerSelf))
        goto AGAIN;

    BAMAlignmentGetRefSeqId(self->innerSelf, &refSeqID);
    if (self->refSeqID != refSeqID) {
        self->atend = 1;
        rc = AlignAccessAlignmentEnumeratorEOFCode;
    }
    else if (self->endpos != 0) {
        int64_t pos;
        uint32_t length;

        BAMAlignmentGetPosition2(self->innerSelf, &pos, &length);
        if (pos >= (int64_t)self->endpos) {
            self->atend = 1;
            rc = AlignAccessAlignmentEnumeratorEOFCode;
        }
        else {
            int64_t const endpos = pos + length;
            if (endpos <= self->startpos)
                goto AGAIN;
        }
    }
    return rc;
}
Exemple #2
0
LIB_EXPORT rc_t CC AlignAccessAlignmentEnumeratorGetRefSeqLen(
                                                              const AlignAccessAlignmentEnumerator *self,
                                                              uint32_t *reflen
                                                              )
{
    rc_t rc;
    uint32_t length;
    int64_t pos;
    
    rc = BAMAlignmentGetPosition2(self->innerSelf, &pos, &length);
    if (rc)
        return rc;
    if (pos < 0)
        return RC(rcAlign, rcTable, rcAccessing, rcData, rcNotFound);
    
    *reflen = length;
    return 0;
}