コード例 #1
0
ファイル: ref_walker.c プロジェクト: gconcepcion/sratoolkit
static rc_t ref_walker_walk_alignment( struct ref_walker * self,
                                       ReferenceIterator * ref_iter,
                                       const PlacementRecord * rec,
                                       ref_walker_data * rwd )
{
    walker_rec * xrec = PlacementRecordCast ( rec, placementRecordExtension1 );
    rwd->state = ReferenceIteratorState ( ref_iter, &rwd->seq_pos );
    rwd->valid = ( ( rwd->state & align_iter_invalid ) == 0 );
    rwd->reverse = xrec->reverse;
    rwd->first = ( ( rwd->state & align_iter_first ) == align_iter_first );
    rwd->last  = ( ( rwd->state & align_iter_last ) == align_iter_last );
    rwd->skip = ( ( rwd->state & align_iter_skip ) == align_iter_skip );
    rwd->match = ( ( rwd->state & align_iter_match ) == align_iter_match );
    rwd->bin_alignment_base = ( rwd->state & 0x0F );
    rwd->ascii_alignment_base = _4na_to_ascii( rwd->state, rwd->reverse );
    if ( !self->omit_quality )
        rwd->quality = xrec->quality[ rwd->seq_pos ];
    rwd->mapq = rec->mapq;
    return self->on_alignment( rwd );
}
コード例 #2
0
ファイル: ref_walker_0.c プロジェクト: Bhumi28/sra-tools
static rc_t walk_placements( walk_data * data, walk_funcs * funcs )
{
    rc_t rc;
    do
    {
        rc = ReferenceIteratorNextPlacement ( data->ref_iter, &data->rec );
        if ( GetRCState( rc ) != rcDone )
        {
            if ( rc != 0 )
            {
                LOGERR( klogInt, rc, "ReferenceIteratorNextPlacement() failed" );
            }
            else
            {
                data->state = ReferenceIteratorState ( data->ref_iter, &data->seq_pos );
                data->xrec = ( tool_rec * ) PlacementRecordCast ( data->rec, placementRecordExtension1 );
                if ( funcs->on_placement != NULL )
                    rc = funcs->on_placement( data );
            }
        }
    } while ( rc == 0 );
    if ( GetRCState( rc ) == rcDone ) { rc = 0; }
    return rc;
}
コード例 #3
0
static void handle_base_pos( ReferenceIterator *ref_iter,
                             const PlacementRecord *rec,
                             uint8_t * qual,
                             bool nodebug )
{
    INSDC_coord_zero seq_pos;
    int32_t state = ReferenceIteratorState ( ref_iter, &seq_pos );
    ext_rec *xrec = ( ext_rec * ) PlacementRecordCast ( rec, placementRecordExtension1 );
    bool reverse = xrec->reverse;

    if ( !nodebug )
        OUTMSG(( "[%lu.%u ", rec->id, seq_pos ));

    *qual = xrec->quality[ seq_pos ];
    if ( ( state & align_iter_first ) == align_iter_first )
    {
        char mapq = ( rec->mapq + 33 );
        OUTMSG(( "^%c", mapq ));
    }

    if ( ( state & align_iter_last ) == align_iter_last )
        OUTMSG(( "$" ));

    if ( ( state & align_iter_insert ) == align_iter_insert )
    {
        const INSDC_4na_bin *bases;
        uint32_t n = ReferenceIteratorBasesInserted ( ref_iter, &bases );
        char * s = dup_2_ascii( bases, n, reverse );
        OUTMSG(( "+%u%s", n, s ));
        free( s );
    }

    if ( ( state & align_iter_delete ) == align_iter_delete )
    {
        const INSDC_4na_bin *bases;
        INSDC_coord_zero ref_pos;
        uint32_t n = ReferenceIteratorBasesDeleted ( ref_iter, &ref_pos, &bases );
        if ( bases != NULL )
        {
            char * s = dup_2_ascii( bases, n, reverse );
            OUTMSG(( "-%u%s", n, s ));
            free( s );
            free( (void *) bases );
        }
        else
        {
            OUTMSG(( "-%u?", n ));
        }
    }

    if ( ( state & align_iter_skip ) == align_iter_skip )
        OUTMSG(( "*" ));
    else
    {
        if ( ( state & align_iter_match ) == align_iter_match )
            OUTMSG(( "%c", reverse ? ',' : '.' ));
        else
            OUTMSG(( "%c", _4na_to_ascii( state & 0x0F, reverse ) ));
    }

    if ( !nodebug )
        OUTMSG(( "]" ));
}