Example #1
0
rc_t load_consensus_src( con_ctx * sctx, KDirectory * hdf5_src )
{
    BaseCalls_cmn ConsensusTab;

    rc_t rc = 0;
    if ( sctx->lctx->check_src_obj )
        rc = check_src_objects( hdf5_src, consensus_groups_to_check, 
                                consensus_tables_to_check, false );
    if ( rc == 0 )
        rc = open_BaseCalls_cmn( hdf5_src, &ConsensusTab, true,
                                 "PulseData/ConsensusBaseCalls", sctx->lctx->cache_content, true );
    if ( rc == 0 )
    {
        uint64_t total_bases = zmw_total( &ConsensusTab.zmw );
        uint64_t total_spots = ConsensusTab.zmw.NumEvent.extents[ 0 ];

        KLogLevel tmp_lvl = KLogLevelGet();
        KLogLevelSet( klogInfo );
        PLOGMSG( klogInfo, ( klogInfo,
                 "loading consensus-table ( $(bases) bases / $(spots) spots ):",
                 "bases=%lu,spots=%lu", total_bases, total_spots ));
        KLogLevelSet( tmp_lvl );

        if ( !check_Consensus_totalcount( &ConsensusTab, total_bases ) )
            rc = RC( rcExe, rcNoTarg, rcAllocating, rcParam, rcInvalid );
        else
            rc = zmw_for_each( &ConsensusTab.zmw, &sctx->lctx->xml_progress, sctx->cursor,
                               sctx->lctx->with_progress, sctx->col_idx, NULL,
                               true, consensus_load_spot, &ConsensusTab );
        close_BaseCalls_cmn( &ConsensusTab );
    }
    return rc;
}
Example #2
0
static rc_t consensus_loader( ld_context *lctx, const char * table_name,
                              bool cache_content )
{
    uint32_t col_idx[ consensus_tab_count ];
    rc_t rc = add_columns( lctx->cursor, consensus_tab_count, -1,
                           col_idx, consensus_tab_names );
    if ( rc == 0 )
    {
        rc = VCursorOpen( lctx->cursor );
        if ( rc != 0 )
            LOGERR( klogErr, rc, "cannot open cursor on consensus-table" );

        else
        {
            BaseCalls_cmn ConsensusTab;
            const INSDC_SRA_platform_id platform = SRA_PLATFORM_PACBIO_SMRT;

            rc = VCursorDefault ( lctx->cursor, col_idx[ consensus_tab_PLATFORM ],
                                  sizeof platform * 8, &platform, 0, 1 );
            if ( rc != 0 )
                LOGERR( klogErr, rc, "cannot set cursor-default on consensus-table for platform-column" );
            else
            {
                const INSDC_SRA_read_filter filter = SRA_READ_FILTER_PASS;
                rc = VCursorDefault ( lctx->cursor, col_idx[ consensus_tab_READ_FILTER ],
                                  sizeof filter * 8, &filter, 0, 1 );
                if ( rc != 0 )
                    LOGERR( klogErr, rc, "cannot set cursor-default on consensus-table for read-filter-column" );
            }

            if ( rc == 0 )
                rc = open_BaseCalls_cmn( lctx->hdf5_dir, &ConsensusTab, true,
                                     "PulseData/ConsensusBaseCalls", cache_content, true );

            if ( rc == 0 )
            {
                uint64_t total_bases = zmw_total( &ConsensusTab.zmw );
                uint64_t total_spots = ConsensusTab.zmw.NumEvent.extents[ 0 ];

                KLogLevel tmp_lvl = KLogLevelGet();
                KLogLevelSet( klogInfo );
                PLOGMSG( klogInfo, ( klogInfo,
                         "loading consensus-table ( $(bases) bases / $(spots) spots ):",
                         "bases=%lu,spots=%lu", total_bases, total_spots ));
                KLogLevelSet( tmp_lvl );

                if ( check_Consensus_totalcount( &ConsensusTab, total_bases ) )
                    rc = zmw_for_each( &ConsensusTab.zmw, lctx, col_idx, NULL,
                                       true, consensus_load_spot, &ConsensusTab );
                else
                    rc = RC( rcExe, rcNoTarg, rcAllocating, rcParam, rcInvalid );
                close_BaseCalls_cmn( &ConsensusTab );
            }
        }
    }
    return rc;
}
Example #3
0
rc_t load_seq_src( seq_ctx * sctx, KDirectory * hdf5_src )
{
    rc_t rc = 0;
    if ( sctx->lctx->check_src_obj )
        rc = check_src_objects( hdf5_src, seq_groups_to_check, seq_tables_to_check, true );

    if ( rc == 0 && !sctx->src_open )
        rc = open_BaseCalls( hdf5_src, &sctx->BaseCallsTab, "PulseData/BaseCalls", sctx->lctx->cache_content, &sctx->rgn_present );
    if ( rc == 0 )
    {
        /* calculates the total number of bases, according to the zmw-table */
        uint64_t total_bases = zmw_total( &sctx->BaseCallsTab.cmn.zmw );
        /* calculates the total number of spots, according to the zmw-table */
        uint64_t total_spots = sctx->BaseCallsTab.cmn.zmw.NumEvent.extents[ 0 ];

        KLogLevel tmp_lvl = KLogLevelGet();
        KLogLevelSet( klogInfo );
        PLOGMSG( klogInfo, ( klogInfo,
                 "loading sequence-table ( $(bases) bases / $(spots) spots ):",
                 "bases=%lu,spots=%lu", total_bases, total_spots ));
        KLogLevelSet( tmp_lvl );

        /* checks that all tables, which are loaded do have the correct
           number of values (the number that the zmw-table requests) */
        if ( !check_BaseCall_totalcount( &sctx->BaseCallsTab, total_bases ) )
            rc = RC( rcExe, rcNoTarg, rcAllocating, rcParam, rcInvalid );
        else
        {
            region_type_mapping mapping;

            if ( sctx->rgn_present )
            {
                const KNamelist *region_types;
                /* read the meta-data-entry "RegionTypes" of the hdf5-regions-table
                   into a KNamelist */
                rc = KArrayFileGetMeta ( sctx->BaseCallsTab.rgn.hdf5_regions.af, "RegionTypes", &region_types );
                if ( rc != 0 )
                {
                    LOGERR( klogErr, rc, "cannot read Regions.RegionTypes" );
                }
                else
                {
                    /* extract the region-type-mapping out of the read KNamelist */
                    rc = rgn_extract_type_mappings( region_types, &mapping, false );
                    KNamelistRelease ( region_types );
                    if ( rc != 0 )
                    {
                        LOGERR( klogErr, rc, "cannot map regions-types" );
                    }
                }
            }

            if ( rc == 0 )
            {
                region_type_mapping *mapping_ptr = NULL;

                if ( sctx->rgn_present )
                    mapping_ptr = &mapping;

                /* call for every spot the function >seq_load_spot< */
                rc = zmw_for_each( &sctx->BaseCallsTab.cmn.zmw, &sctx->lctx->xml_progress, sctx->cursor,
                                   sctx->lctx->with_progress, sctx->col_idx, mapping_ptr, false,
                                   seq_load_spot, &sctx->BaseCallsTab );
            }

            if ( sctx->rgn_present )
                seq_load_info( &sctx->BaseCallsTab.rgn.stat );

            sctx->lctx->total_seq_bases += total_bases;
            sctx->lctx->total_seq_spots += total_spots;
        }   
        close_BaseCalls( &sctx->BaseCallsTab );
        sctx->src_open = false;
    }
    return rc;
}
Example #4
0
static rc_t seq_loader( ld_context *lctx, KDirectory * hdf5_src, VCursor * cursor, const char * table_name )
{
    BaseCalls BaseCallsTab;
    bool rgn_present;

    /* opens all hdf5-tables, which are needed to load the sequence-table */
    rc_t rc = open_BaseCalls( hdf5_src, &BaseCallsTab,
                              "PulseData/BaseCalls", lctx->cache_content, &rgn_present );
    if ( rc == 0 )
    {
        /* calculates the total number of bases, according to the zmw-table */
        uint64_t total_bases = zmw_total( &BaseCallsTab.cmn.zmw );
        /* calculates the total number of spots, according to the zmw-table */
        uint64_t total_spots = BaseCallsTab.cmn.zmw.NumEvent.extents[ 0 ];

        KLogLevel tmp_lvl = KLogLevelGet();
        KLogLevelSet( klogInfo );
        PLOGMSG( klogInfo, ( klogInfo,
                 "loading sequence-table ( $(bases) bases / $(spots) spots ):",
                 "bases=%lu,spots=%lu", total_bases, total_spots ));
        KLogLevelSet( tmp_lvl );

        /* checks that all tables, which are loaded do have the correct
           number of values (the number that the zmw-table requests) */
        if ( check_BaseCall_totalcount( &BaseCallsTab, total_bases ) )
        {
            region_type_mapping mapping;

            if ( rgn_present )
            {
                const KNamelist *region_types;
                /* read the meta-data-entry "RegionTypes" of the hdf5-regions-table
                   into a KNamelist */
                rc = KArrayFileGetMeta ( BaseCallsTab.rgn.hdf5_regions.af, "RegionTypes", &region_types );
                if ( rc != 0 )
                {
                    LOGERR( klogErr, rc, "cannot read Regions.RegionTypes" );
                }
                else
                {
                    /* extract the region-type-mapping out of the read KNamelist */
                    rc = rgn_extract_type_mappings( region_types, &mapping, false );
                    KNamelistRelease ( region_types );
                    if ( rc != 0 )
                    {
                        LOGERR( klogErr, rc, "cannot map regions-types" );
                    }
                }
            }

            if ( rc == 0 )
            {
                /* holds the vdb-column-index for every column we write */
                uint32_t col_idx[ seq_tab_count ];
                int32_t to_exclude;

                /* depending on the bit-size of the PulseIndex-table in HDF5
                   exclude the opposite column from VDB */
                if ( BaseCallsTab.PulseIndex.element_bits == PULSE_INDEX_BITSIZE_16 )
                    to_exclude = seq_tab_PULSE_INDEX_32;
                else
                    to_exclude = seq_tab_PULSE_INDEX_16;

                /* add all columns to the vdb-cursor */
                rc = add_columns( cursor, seq_tab_count, to_exclude, col_idx, seq_tab_names );
                if ( rc == 0 )
                {
                    rc = VCursorOpen( cursor );
                    if ( rc != 0 )
                        LOGERR( klogErr, rc, "cannot open cursor on seq-table" );
                    else
                    {
                        const uint8_t platform = SRA_PLATFORM_PACBIO_SMRT;

                        rc = VCursorDefault ( cursor, col_idx[ seq_tab_PLATFORM ], 8, &platform, 0, 1 );
                        if ( rc != 0 )
                            LOGERR( klogErr, rc, "cannot set cursor-default on seq-table for platform-column" );
                        else
                        {
                            region_type_mapping *mapping_ptr = NULL;
        
                            if ( rgn_present )
                            {
                                mapping_ptr = &mapping;
                            }
                            /* call for every spot the function >seq_load_spot< */
                            rc = zmw_for_each( &BaseCallsTab.cmn.zmw, &lctx->xml_progress, cursor,
                                               lctx->with_progress, col_idx, mapping_ptr, false, seq_load_spot, &BaseCallsTab );
                        }
                    }
                }
            }

            if ( rgn_present )
            {
                seq_load_info( &BaseCallsTab.rgn.stat );

                if ( mapping.count_of_unknown_rgn_types > 0 )
                {
                    KLogLevel tmp_lvl = KLogLevelGet();
                    KLogLevelSet( klogInfo );

                    PLOGMSG( klogInfo, ( klogInfo,
                        "$(times) x unknown region types encountered",
                        "times=%i", mapping.count_of_unknown_rgn_types ) );
                    KLogLevelSet( tmp_lvl );

                }
            }

            lctx->total_seq_bases += total_bases;
            lctx->total_seq_spots += total_spots;
        }   
        else
            rc = RC( rcExe, rcNoTarg, rcAllocating, rcParam, rcInvalid );
        close_BaseCalls( &BaseCallsTab );
    }

    return rc;
}