Example #1
0
static rc_t ref_walker_add_iterator( struct ref_walker * self, const char * ref_name,
                        uint64_t start, uint64_t end, const char * src_name, Vector * cur_id_vector,
                        const VDatabase *db, const ReferenceObj * ref_obj, ReferenceIterator * ref_iter,
                        const char * table_name, align_id_src id_selector )
{
    walker_col_ids * cursor_ids;
    rc_t rc = make_cursor_ids( cur_id_vector, &cursor_ids );
    if ( rc == 0 )
    {
        const VTable *tbl;
        rc_t rc = VDatabaseOpenTableRead ( db, &tbl, table_name );
        if ( rc == 0 )
        {
            const VCursor *cursor;
            rc = add_required_columns( self, tbl, &cursor, cursor_ids );
            if ( rc == 0 )
            {
                rc = ReferenceIteratorAddPlacements ( ref_iter,             /* the outer ref-iter */
                                                      ref_obj,              /* the ref-obj for this chromosome */
                                                      start - 1,            /* start ( zero-based ) */
                                                      ( end - start ) + 1,  /* length */
                                                      NULL,                 /* ref-cursor */
                                                      cursor,               /* align-cursor */
                                                      id_selector,          /* which id's */
                                                      self->spot_group,     /* what read-group */
                                                      cursor_ids            /* placement-context */
                                                     );
                VCursorRelease( cursor );
            }
            VTableRelease ( tbl );
        }
    }
    return rc;
}
Example #2
0
static rc_t test_ref_iterator( trans_ctx *ctx,
                               const char * ref_name, 
                               INSDC_coord_zero ref_pos,
                               INSDC_coord_len ref_len,
                               bool skip_empty,
                               bool nodebug )
{
    rc_t rc;
    ReferenceIterator *ref_iter = NULL;
    struct VCursor const *ref_cursor = NULL;
    struct VCursor const *align_cursor = NULL;
    PlacementRecordExtendFuncs ef;

    /* (1) make the reference-iterator */
    ef.data = ( void * )ctx->almgr;
    ef.destroy = NULL; /* ext_rec_destroy; */
    ef.populate = ext_rec_populate;
    ef.alloc_size = ext_rec_size;
    ef.fixed_size = 0;

    rc = AlignMgrMakeReferenceIterator ( ctx->almgr, &ref_iter, &ef, 0 /* min_mapq*/ );
    if ( rc != 0 )
        LOGERR( klogInt, rc, "AlignMgrMakeReferenceIterator() failed" );

    /* (2) prepare the alignmnet-cursor (for the needs of the callback...)*/
    if ( rc == 0 )
        rc = get_prim_align_cursor( ctx->db, &align_cursor );

    /* (3) all placements to the ref-iter AND WALK THE REFERENCE-ITERATOR! */
    if ( rc == 0 )
    {
        rc = ReferenceIteratorAddPlacements( ref_iter, ctx->ref_obj, ref_pos, ref_len,
                                             ref_cursor, align_cursor, primary_align_ids, NULL );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "ReferenceIteratorAddPlacements() failed" );
        else
        {
            /* =============================================== */
            rc = walk_ref_iter( ref_iter, skip_empty, nodebug );
            /* =============================================== */
        }
    }

    if ( ref_cursor != NULL ) VCursorRelease ( ref_cursor );
    if ( align_cursor != NULL ) VCursorRelease ( align_cursor );
    if ( ref_iter != NULL ) ReferenceIteratorRelease( ref_iter );
    return rc;
}