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; }
/* SetIdxColumnDefault * give a default value for column * * if no value gets written to a column within an open spot, * this value is substituted. * * "idx" [ IN ] - 1-based column index * * "base" [ IN ] and "offset" [ IN ] - pointer and bit offset * to start of row data * * "size" [ IN ] - size in bits of row data */ LIB_EXPORT rc_t CC SRATableSetIdxColumnDefault ( SRATable *self, uint32_t idx, const void *base, bitsz_t offset, bitsz_t size ) { const SRAColumn *col; rc_t rc; rc = lookup_and_validate(self, &col, idx, base, offset, size); if (rc == 0) rc = VCursorDefault(self->curs, col->idx, col->elem_bits, base, offset / col->elem_bits, size / col->elem_bits); return rc; }
rc_t prepare_consensus( VDatabase * database, con_ctx * sctx, ld_context *lctx ) { rc_t rc = prepare_table( database, &sctx->cursor, consensus_schema_template, consensus_table_to_create ); /* pl-tools.c ... this creates the cursor */ if ( rc == 0 ) { rc = add_columns( sctx->cursor, consensus_tab_count, -1, sctx->col_idx, consensus_tab_names ); if ( rc == 0 ) { rc = VCursorOpen( sctx->cursor ); if ( rc != 0 ) { LOGERR( klogErr, rc, "cannot open cursor on consensus-table" ); } else { const INSDC_SRA_platform_id platform = SRA_PLATFORM_PACBIO_SMRT; rc = VCursorDefault ( sctx->cursor, sctx->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 ( sctx->cursor, sctx->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" ); } else { sctx->lctx = lctx; } } } } } return rc; }
/* special case for SEQUENCE: in order to prepare the cursor correctly, we have to know the first HDF5-source-obj !*/ rc_t prepare_seq( VDatabase * database, seq_ctx * sctx, KDirectory * hdf5_src, ld_context *lctx ) { rc_t rc = prepare_table( database, &sctx->cursor, seq_schema_template, seq_table_to_create ); /* pl-tools.c ... this creates the cursor */ sctx->src_open = false; if ( rc == 0 ) { rc = open_BaseCalls( hdf5_src, &sctx->BaseCallsTab, "PulseData/BaseCalls", lctx->cache_content, &sctx->rgn_present ); if ( rc == 0 ) { int32_t to_exclude; /* depending on the bit-size of the PulseIndex-table in HDF5 exclude the opposite column from VDB */ if ( sctx->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( sctx->cursor, seq_tab_count, to_exclude, sctx->col_idx, seq_tab_names ); if ( rc == 0 ) { rc = VCursorOpen( sctx->cursor ); if ( rc != 0 ) { LOGERR( klogErr, rc, "cannot open cursor on seq-table" ); } else { const uint8_t platform = SRA_PLATFORM_PACBIO_SMRT; rc = VCursorDefault ( sctx->cursor, sctx->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 { sctx->src_open = true; sctx->lctx = lctx; } } } } } return rc; }
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", ®ion_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; }