| 1 | /*=========================================================================== |
| 2 | * |
| 3 | * PUBLIC DOMAIN NOTICE |
| 4 | * National Center for Biotechnology Information |
| 5 | * |
| 6 | * This software/database is a "United States Government Work" under the |
| 7 | * terms of the United States Copyright Act. It was written as part of |
| 8 | * the author's official duties as a United States Government employee and |
| 9 | * thus cannot be copyrighted. This software/database is freely available |
| 10 | * to the public for use. The National Library of Medicine and the U.S. |
| 11 | * Government have not placed any restriction on its use or reproduction. |
| 12 | * |
| 13 | * Although all reasonable efforts have been taken to ensure the accuracy |
| 14 | * and reliability of the software and data, the NLM and the U.S. |
| 15 | * Government do not and cannot warrant the performance or results that |
| 16 | * may be obtained by using this software or data. The NLM and the U.S. |
| 17 | * Government disclaim all warranties, express or implied, including |
| 18 | * warranties of performance, merchantability or fitness for any particular |
| 19 | * purpose. |
| 20 | * |
| 21 | * Please cite the author in any work or product based on this material. |
| 22 | * |
| 23 | * =========================================================================== |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include <align/extern.h>cxx . . $ `<file>/interfaces/align/extern.h`/ |
| 28 | |
| 29 | #include <klib/rc.h>cxx . . $ `<file>/interfaces/klib/rc.h`/ |
| 30 | #include <klib/text.h>cxx . . $ `<file>/interfaces/klib/text.h`/ |
| 31 | #include <klib/vector.h>cxx . . $ `<file>/interfaces/klib/vector.h`/ |
| 32 | |
| 33 | #include <vdb/manager.h>cxx . . $ `<file>/interfaces/vdb/manager.h`/ |
| 34 | #include <vdb/database.h>cxx . . $ `<file>/interfaces/vdb/database.h`/ |
| 35 | #include <vdb/table.h>cxx . . $ `<file>/interfaces/vdb/table.h`/ |
| 36 | #include <vdb/cursor.h>cxx . . $ `<file>/interfaces/vdb/cursor.h`/ |
| 37 | |
| 38 | #include <insdc/sra.h>cxx . . $ `<file>/interfaces/insdc/sra.h`/ |
| 39 | |
| 40 | #define DFLT_CACHE_SIZEcxx . . $ `libs/align/unsupported_pileup_estimator.c:40:9`! 1024 * 1024 * 32 |
| 41 | |
| 42 | typedef struct PileupEstimatorcxx . . $ PileupEstimator# |
| 43 | { |
| 44 | const VCursorcxx . . $ VCursor# * ref_cursorcxx . . $ PileupEstimator#ref_cursor.; |
| 45 | const VCursorcxx . . $ VCursor# * align_cursorcxx . . $ PileupEstimator#align_cursor.; |
| 46 | |
| 47 | uint32_tcxx . . $ uint32_t# * coveragecxx . . $ PileupEstimator#coverage.; |
| 48 | int64_tcxx . . $ int64_t# coverage_lencxx . . $ PileupEstimator#coverage_len.; |
| 49 | |
| 50 | Vectorcxx . . $ Vector# reftablecxx . . $ PileupEstimator#reftable.; |
| 51 | |
| 52 | uint64_tcxx . . $ uint64_t# cutoff_valuecxx . . $ PileupEstimator#cutoff_value.; |
| 53 | |
| 54 | uint32_tcxx . . $ uint32_t# ref_cursor_idx_SEQ_IDcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_ID.; |
| 55 | uint32_tcxx . . $ uint32_t# ref_cursor_idx_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_LEN.; |
| 56 | uint32_tcxx . . $ uint32_t# ref_cursor_idx_MAX_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_MAX_SEQ_LEN.; |
| 57 | uint32_tcxx . . $ uint32_t# ref_cursor_idx_PRIMARY_ALIGNMENT_IDScxx . . $ PileupEstimator#ref_cursor_idx_PRIMARY_ALIGNMENT_IDS.; |
| 58 | |
| 59 | uint32_tcxx . . $ uint32_t# align_cursor_idx_REF_POScxx . . $ PileupEstimator#align_cursor_idx_REF_POS.; |
| 60 | uint32_tcxx . . $ uint32_t# align_cursor_idx_REF_LENcxx . . $ PileupEstimator#align_cursor_idx_REF_LEN.; |
| 61 | uint32_tcxx . . $ uint32_t# align_cursor_idx_READ_FILTERcxx . . $ PileupEstimator#align_cursor_idx_READ_FILTER.; |
| 62 | |
| 63 | uint32_tcxx . . $ uint32_t# max_seq_lencxx . . $ PileupEstimator#max_seq_len.; |
| 64 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! use_read_filtercxx . . $ PileupEstimator#use_read_filter.; |
| 65 | } PileupEstimatorcxx . . $ PileupEstimator#; |
| 66 | |
| 67 | |
| 68 | typedef struct RefEntrycxx . . $ RefEntry# |
| 69 | { |
| 70 | const Stringcxx . . $ String# *rnamecxx . . $ RefEntry#rname.; /* the name of the reference */ |
| 71 | int64_tcxx . . $ int64_t# start_row_idcxx . . $ RefEntry#start_row_id.; /* the start-row-id of this reference in the REFERENCE-table */ |
| 72 | uint64_tcxx . . $ uint64_t# countcxx . . $ RefEntry#count.; /* how many rows for this reference in the REFERENCE-table */ |
| 73 | uint64_tcxx . . $ uint64_t# reflencxx . . $ RefEntry#reflen.; /* how many bases does this reference have */ |
| 74 | } RefEntrycxx . . $ RefEntry#; |
| 75 | |
| 76 | |
| 77 | static void RefEntry_releasecxx . . $ RefEntry_release(28f9fa1ede7edf1b).( RefEntrycxx . . $ RefEntry# * ref ) |
| 78 | { |
| 79 | if ( ref != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 80 | { |
| 81 | StringWhackcxx . . $ StringWhack(1d30580b912abaad).( ref->rnamecxx . . $ RefEntry#rname. ); |
| 82 | freecxx . . $ free(5d22bdacc48458e8).( ( void * )ref ); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | static rc_tcxx . . $ rc_t# make_ref_entrycxx . . $ make_ref_entry(a824eb64a18dedac).( RefEntrycxx . . $ RefEntry# **self, const Stringcxx . . $ String# * rname, int64_tcxx . . $ int64_t# start_row_id, uint32_tcxx . . $ uint32_t# len ) |
| 87 | { |
| 88 | rc_tcxx . . $ rc_t# rc = 0; |
| 89 | RefEntrycxx . . $ RefEntry# * o = calloccxx . . $ calloc(63a7bf2941bfcd7a).( 1, sizeof *o ); |
| 90 | if ( o == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 91 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcConstructing, rcMemory, rcExhausted ); |
| 92 | else |
| 93 | { |
| 94 | o->start_row_idcxx . . $ RefEntry#start_row_id. = start_row_id; |
| 95 | o->reflencxx . . $ RefEntry#reflen. = len; |
| 96 | rc = StringCopycxx . . $ StringCopy(39beb90cb30264d5).( &o->rnamecxx . . $ RefEntry#rname., rname ); |
| 97 | if ( rc == 0 ) |
| 98 | *self = o; |
| 99 | else |
| 100 | RefEntry_releasecxx . . $ RefEntry_release(28f9fa1ede7edf1b).( o ); |
| 101 | } |
| 102 | return rc; |
| 103 | } |
| 104 | |
| 105 | static void CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! RefEntry_releaes_callbackcxx . . $ RefEntry_releaes_callback(6c58c5e2437d25a2).( void * item, void * data ) |
| 106 | { |
| 107 | RefEntry_releasecxx . . $ RefEntry_release(28f9fa1ede7edf1b).( item ); |
| 108 | } |
| 109 | |
| 110 | LIB_EXPORTcxx . . $ `interfaces/kfc/extern.h:63:9`! rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! ReleasePileupEstimatorcxx . . $ ReleasePileupEstimator(a75ec6f50ca111c5).( struct PileupEstimatorcxx . . $ PileupEstimator# *self ) |
| 111 | { |
| 112 | rc_tcxx . . $ rc_t# rc = 0; |
| 113 | if ( self != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 114 | { |
| 115 | if ( self->coveragecxx . . $ PileupEstimator#coverage. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 116 | freecxx . . $ free(5d22bdacc48458e8).( ( void * ) self->coveragecxx . . $ PileupEstimator#coverage. ); |
| 117 | if ( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 118 | rc = VCursorReleasecxx . . $ VCursorRelease(b9a67829f47d6367).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor. ); |
| 119 | if ( rc == 0 && self->align_cursorcxx . . $ PileupEstimator#align_cursor. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 120 | rc = VCursorReleasecxx . . $ VCursorRelease(b9a67829f47d6367).( self->align_cursorcxx . . $ PileupEstimator#align_cursor. ); |
| 121 | VectorWhackcxx . . $ VectorWhack(2b92d0f42bcce61e).( &self->reftablecxx . . $ PileupEstimator#reftable., RefEntry_releaes_callbackcxx . . $ RefEntry_releaes_callback(6c58c5e2437d25a2)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 122 | if ( rc == 0 ) |
| 123 | freecxx . . $ free(5d22bdacc48458e8).( ( void * )self ); |
| 124 | } |
| 125 | return rc; |
| 126 | } |
| 127 | |
| 128 | |
| 129 | /* ===================================================================================================== */ |
| 130 | |
| 131 | |
| 132 | static rc_tcxx . . $ rc_t# AddRefCursorcxx . . $ AddRefCursor(509266da0cf3eb5c).( PileupEstimatorcxx . . $ PileupEstimator# *self, const VCursorcxx . . $ VCursor# * ref_cursor ) |
| 133 | { |
| 134 | rc_tcxx . . $ rc_t# rc = VCursorAddRefcxx . . $ VCursorAddRef(b9a67829f47d6367).( ref_cursor ); |
| 135 | if ( rc == 0 ) |
| 136 | self->ref_cursorcxx . . $ PileupEstimator#ref_cursor. = ref_cursor; |
| 137 | if ( rc == 0 ) |
| 138 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( ref_cursor, &self->ref_cursor_idx_SEQ_IDcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_ID., "SEQ_ID" ); |
| 139 | if ( rc == 0 ) |
| 140 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( ref_cursor, &self->ref_cursor_idx_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_LEN., "SEQ_LEN" ); |
| 141 | if ( rc == 0 ) |
| 142 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( ref_cursor, &self->ref_cursor_idx_MAX_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_MAX_SEQ_LEN., "MAX_SEQ_LEN" ); |
| 143 | if ( rc == 0 ) |
| 144 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( ref_cursor, &self->ref_cursor_idx_PRIMARY_ALIGNMENT_IDScxx . . $ PileupEstimator#ref_cursor_idx_PRIMARY_ALIGNMENT_IDS., "PRIMARY_ALIGNMENT_IDS" ); |
| 145 | return rc; |
| 146 | } |
| 147 | |
| 148 | static rc_tcxx . . $ rc_t# MakeRefCursorcxx . . $ MakeRefCursor(5f5ec10e5fa30c21).( PileupEstimatorcxx . . $ PileupEstimator# *self, const VDatabasecxx . . $ VDatabase# * db, size_t cursor_cache_size ) |
| 149 | { |
| 150 | const VTablecxx . . $ VTable# * tbl; |
| 151 | rc_tcxx . . $ rc_t# rc = VDatabaseOpenTableReadcxx . . $ VDatabaseOpenTableRead(c0afac0c6db25bdd).( db, &tbl, "%s", "REFERENCE" ); |
| 152 | if ( rc == 0 ) |
| 153 | { |
| 154 | rc = VTableCreateCachedCursorReadcxx . . $ VTableCreateCachedCursorRead(59f022b8c2fa0d34).( tbl, &self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., cursor_cache_size ); |
| 155 | if ( rc == 0 ) |
| 156 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., &self->ref_cursor_idx_SEQ_IDcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_ID., "SEQ_ID" ); |
| 157 | if ( rc == 0 ) |
| 158 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., &self->ref_cursor_idx_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_LEN., "SEQ_LEN" ); |
| 159 | if ( rc == 0 ) |
| 160 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., &self->ref_cursor_idx_MAX_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_MAX_SEQ_LEN., "MAX_SEQ_LEN" ); |
| 161 | if ( rc == 0 ) |
| 162 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., &self->ref_cursor_idx_PRIMARY_ALIGNMENT_IDScxx . . $ PileupEstimator#ref_cursor_idx_PRIMARY_ALIGNMENT_IDS., "PRIMARY_ALIGNMENT_IDS" ); |
| 163 | if ( rc == 0 ) |
| 164 | rc = VCursorOpencxx . . $ VCursorOpen(b9a67829f47d6367).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor. ); |
| 165 | VTableReleasecxx . . $ VTableRelease(9e343179418960f2).( tbl ); |
| 166 | } |
| 167 | return rc; |
| 168 | } |
| 169 | |
| 170 | static rc_tcxx . . $ rc_t# AddAlignCursorcxx . . $ AddAlignCursor(509266da0cf3eb5c).( PileupEstimatorcxx . . $ PileupEstimator# *self, const VCursorcxx . . $ VCursor# * align_cursor ) |
| 171 | { |
| 172 | rc_tcxx . . $ rc_t# rc = VCursorAddRefcxx . . $ VCursorAddRef(b9a67829f47d6367).( align_cursor ); |
| 173 | if ( rc == 0 ) |
| 174 | self->align_cursorcxx . . $ PileupEstimator#align_cursor. = align_cursor; |
| 175 | if ( rc == 0 ) |
| 176 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( align_cursor, &self->align_cursor_idx_REF_POScxx . . $ PileupEstimator#align_cursor_idx_REF_POS., "REF_POS" ); |
| 177 | if ( rc == 0 ) |
| 178 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( align_cursor, &self->align_cursor_idx_REF_LENcxx . . $ PileupEstimator#align_cursor_idx_REF_LEN., "REF_LEN" ); |
| 179 | if ( rc == 0 && self->use_read_filtercxx . . $ PileupEstimator#use_read_filter. ) |
| 180 | rc = VCursorGetColumnIdxcxx . . $ VCursorGetColumnIdx(240adf50b07e1022).( align_cursor, &self->align_cursor_idx_READ_FILTERcxx . . $ PileupEstimator#align_cursor_idx_READ_FILTER., "READ_FILTER" ); |
| 181 | return rc; |
| 182 | } |
| 183 | |
| 184 | static rc_tcxx . . $ rc_t# MakeAlignCursorcxx . . $ MakeAlignCursor(5f5ec10e5fa30c21).( PileupEstimatorcxx . . $ PileupEstimator# *self, const VDatabasecxx . . $ VDatabase# * db, size_t cursor_cache_size ) |
| 185 | { |
| 186 | const VTablecxx . . $ VTable# * tbl; |
| 187 | rc_tcxx . . $ rc_t# rc = VDatabaseOpenTableReadcxx . . $ VDatabaseOpenTableRead(c0afac0c6db25bdd).( db, &tbl, "%s", "PRIMARY_ALIGNMENT" ); |
| 188 | if ( rc == 0 ) |
| 189 | { |
| 190 | rc = VTableCreateCachedCursorReadcxx . . $ VTableCreateCachedCursorRead(59f022b8c2fa0d34).( tbl, &self->align_cursorcxx . . $ PileupEstimator#align_cursor., cursor_cache_size ); |
| 191 | if ( rc == 0 ) |
| 192 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., &self->align_cursor_idx_REF_POScxx . . $ PileupEstimator#align_cursor_idx_REF_POS., "REF_POS" ); |
| 193 | if ( rc == 0 ) |
| 194 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., &self->align_cursor_idx_REF_LENcxx . . $ PileupEstimator#align_cursor_idx_REF_LEN., "REF_LEN" ); |
| 195 | if ( rc == 0 && self->use_read_filtercxx . . $ PileupEstimator#use_read_filter. ) |
| 196 | rc = VCursorAddColumncxx . . $ VCursorAddColumn(240adf50b07e1022).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., &self->align_cursor_idx_READ_FILTERcxx . . $ PileupEstimator#align_cursor_idx_READ_FILTER., "READ_FILTER" ); |
| 197 | if ( rc == 0 ) |
| 198 | rc = VCursorOpencxx . . $ VCursorOpen(b9a67829f47d6367).( self->align_cursorcxx . . $ PileupEstimator#align_cursor. ); |
| 199 | VTableReleasecxx . . $ VTableRelease(9e343179418960f2).( tbl ); |
| 200 | } |
| 201 | return rc; |
| 202 | } |
| 203 | |
| 204 | static rc_tcxx . . $ rc_t# InitializePileupEstimatorcxx . . $ InitializePileupEstimator(d37e6392a3d55f83).( PileupEstimatorcxx . . $ PileupEstimator# *self, |
| 205 | const char * source, |
| 206 | size_t cursor_cache_size, |
| 207 | const VCursorcxx . . $ VCursor# * ref_cursor, |
| 208 | const VCursorcxx . . $ VCursor# * align_cursor, |
| 209 | uint64_tcxx . . $ uint64_t# cutoff_value, |
| 210 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! use_read_filter ) |
| 211 | { |
| 212 | rc_tcxx . . $ rc_t# rc = 0; |
| 213 | VectorInitcxx . . $ VectorInit(6b693a4f97babbbf).( &self->reftablecxx . . $ PileupEstimator#reftable., 0, 25 ); |
| 214 | self->cutoff_valuecxx . . $ PileupEstimator#cutoff_value. = cutoff_value; |
| 215 | self->use_read_filtercxx . . $ PileupEstimator#use_read_filter. = use_read_filter; |
| 216 | if ( ref_cursor == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || align_cursor == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 217 | { |
| 218 | if ( source == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 219 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcNull ); |
| 220 | else |
| 221 | { |
| 222 | const VDBManagercxx . . $ VDBManager# * mgr; |
| 223 | rc = VDBManagerMakeReadcxx . . $ VDBManagerMakeRead(771a2f2a09e2d448).( &mgr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 224 | if ( rc == 0 ) |
| 225 | { |
| 226 | const VDatabasecxx . . $ VDatabase# * db; |
| 227 | rc = VDBManagerOpenDBReadcxx . . $ VDBManagerOpenDBRead(3d052c4f59f1f00e).( mgr, &db, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "%s", source ); |
| 228 | if ( rc == 0 ) |
| 229 | { |
| 230 | if ( cursor_cache_size == 0 ) |
| 231 | cursor_cache_size = DFLT_CACHE_SIZEcxx . . $ `libs/align/unsupported_pileup_estimator.c:40:9`!; |
| 232 | |
| 233 | if ( ref_cursor != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 234 | rc = AddRefCursorcxx . . $ AddRefCursor(509266da0cf3eb5c).( self, ref_cursor ); |
| 235 | else |
| 236 | rc = MakeRefCursorcxx . . $ MakeRefCursor(5f5ec10e5fa30c21).( self, db, cursor_cache_size ); |
| 237 | |
| 238 | if ( rc == 0 ) |
| 239 | { |
| 240 | if ( align_cursor != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 241 | rc = AddAlignCursorcxx . . $ AddAlignCursor(509266da0cf3eb5c).( self, align_cursor ); |
| 242 | else |
| 243 | rc = MakeAlignCursorcxx . . $ MakeAlignCursor(5f5ec10e5fa30c21).( self, db, cursor_cache_size ); |
| 244 | } |
| 245 | VDatabaseReleasecxx . . $ VDatabaseRelease(a663aaccdcd0cced).( db ); |
| 246 | } |
| 247 | VDBManagerReleasecxx . . $ VDBManagerRelease(2367ef07756912da).( mgr ); |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | rc = AddRefCursorcxx . . $ AddRefCursor(509266da0cf3eb5c).( self, ref_cursor ); |
| 254 | if ( rc == 0 ) |
| 255 | rc = AddAlignCursorcxx . . $ AddAlignCursor(509266da0cf3eb5c).( self, align_cursor ); |
| 256 | } |
| 257 | return rc; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | LIB_EXPORTcxx . . $ `interfaces/kfc/extern.h:63:9`! rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! MakePileupEstimatorcxx . . $ MakePileupEstimator(dd68bd32bf53dda4).( struct PileupEstimatorcxx . . $ PileupEstimator# **self, |
| 262 | const char * source, |
| 263 | size_t cursor_cache_size, |
| 264 | const struct VCursorcxx . . $ VCursor# * ref_cursor, |
| 265 | const struct VCursorcxx . . $ VCursor# * align_cursor, |
| 266 | uint64_tcxx . . $ uint64_t# cutoff_value, |
| 267 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! use_read_filter ) |
| 268 | { |
| 269 | rc_tcxx . . $ rc_t# rc = 0; |
| 270 | if ( self == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 271 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcConstructing, rcSelf, rcNull ); |
| 272 | else |
| 273 | { |
| 274 | PileupEstimatorcxx . . $ PileupEstimator# * o = calloccxx . . $ calloc(63a7bf2941bfcd7a).( 1, sizeof *o ); |
| 275 | *self = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 276 | if ( o == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 277 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcConstructing, rcMemory, rcExhausted ); |
| 278 | else |
| 279 | { |
| 280 | rc = InitializePileupEstimatorcxx . . $ InitializePileupEstimator(d37e6392a3d55f83).( o, source, cursor_cache_size, |
| 281 | ref_cursor, align_cursor, |
| 282 | cutoff_value, use_read_filter ); |
| 283 | if ( rc == 0 ) |
| 284 | *self = o; |
| 285 | else |
| 286 | ReleasePileupEstimatorcxx . . $ ReleasePileupEstimator(a75ec6f50ca111c5).( o ); |
| 287 | } |
| 288 | } |
| 289 | return rc; |
| 290 | } |
| 291 | |
| 292 | /* ===================================================================================================== */ |
| 293 | |
| 294 | static rc_tcxx . . $ rc_t# ScanRefTablecxx . . $ ScanRefTable(a75ec6f50ca111c5).( PileupEstimatorcxx . . $ PileupEstimator# *self ) |
| 295 | { |
| 296 | int64_tcxx . . $ int64_t# row; |
| 297 | uint64_tcxx . . $ uint64_t# row_idx, count; |
| 298 | RefEntrycxx . . $ RefEntry# * ref_entry = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 299 | Stringcxx . . $ String# rname; |
| 300 | uint32_tcxx . . $ uint32_t# * ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 301 | uint32_tcxx . . $ uint32_t# elem_bits, boff, row_len; |
| 302 | |
| 303 | rc_tcxx . . $ rc_t# rc = VCursorIdRangecxx . . $ VCursorIdRange(18fc6b027aa4a503).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., self->ref_cursor_idx_SEQ_IDcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_ID., &row, &count ); |
| 304 | for( row_idx = 0; rc == 0 && row_idx < count; ++row, ++row_idx ) |
| 305 | { |
| 306 | /* get max_seq_len if we do not have it yet */ |
| 307 | if ( self->max_seq_lencxx . . $ PileupEstimator#max_seq_len. == 0 ) |
| 308 | { |
| 309 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., row, self->ref_cursor_idx_MAX_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_MAX_SEQ_LEN., &elem_bits, |
| 310 | ( const void ** )&ptr, &boff, &row_len ); |
| 311 | if ( rc == 0 && row_len < 1 ) |
| 312 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcInvalid ); |
| 313 | if ( rc == 0 && ptr[ 0 ] == 0 ) |
| 314 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcInvalid ); |
| 315 | if ( rc == 0 ) |
| 316 | self->max_seq_lencxx . . $ PileupEstimator#max_seq_len. = ptr[ 0 ]; |
| 317 | } |
| 318 | |
| 319 | /* get the REFERENCE-NAME */ |
| 320 | if ( rc == 0 ) |
| 321 | { |
| 322 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., row, self->ref_cursor_idx_SEQ_IDcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_ID., &elem_bits, |
| 323 | ( const void ** )&rname.addrcxx . . $ String#addr., &boff, &rname.lencxx . . $ String#len. ); |
| 324 | if ( rc == 0 && rname.lencxx . . $ String#len. < 1 ) |
| 325 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcInvalid ); |
| 326 | if ( rc == 0 ) |
| 327 | rname.sizecxx . . $ String#size. = rname.lencxx . . $ String#len.; |
| 328 | } |
| 329 | |
| 330 | /* get the SEQ_LEN */ |
| 331 | if ( rc == 0 ) |
| 332 | { |
| 333 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., row, self->ref_cursor_idx_SEQ_LENcxx . . $ PileupEstimator#ref_cursor_idx_SEQ_LEN., &elem_bits, |
| 334 | ( const void ** )&ptr, &boff, &row_len ); |
| 335 | if ( rc == 0 && row_len < 1 ) |
| 336 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcInvalid ); |
| 337 | } |
| 338 | |
| 339 | /* do the counting/inserting ... */ |
| 340 | if ( rc == 0 ) |
| 341 | { |
| 342 | if ( ref_entry == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 343 | rc = make_ref_entrycxx . . $ make_ref_entry(a824eb64a18dedac).( &ref_entry, &rname, row, ptr[ 0 ] ); |
| 344 | else |
| 345 | { |
| 346 | int cmp = StringComparecxx . . $ StringCompare(bd5fd046769c5966).( ref_entry->rnamecxx . . $ RefEntry#rname., &rname ); |
| 347 | if ( cmp == 0 ) |
| 348 | { |
| 349 | ref_entry->countcxx . . $ RefEntry#count. += 1; |
| 350 | ref_entry->reflencxx . . $ RefEntry#reflen. += ptr[ 0 ]; |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | rc = VectorAppendcxx . . $ VectorAppend(7bf5bdcf5af72e4f).( &self->reftablecxx . . $ PileupEstimator#reftable., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ref_entry ); |
| 355 | if ( rc == 0 ) |
| 356 | rc = make_ref_entrycxx . . $ make_ref_entry(a824eb64a18dedac).( &ref_entry, &rname, row, ptr[ 0 ] ); |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | /* insert the last entry */ |
| 362 | if ( rc == 0 && ref_entry != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 363 | { |
| 364 | rc = VectorAppendcxx . . $ VectorAppend(7bf5bdcf5af72e4f).( &self->reftablecxx . . $ PileupEstimator#reftable., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ref_entry ); |
| 365 | } |
| 366 | return rc; |
| 367 | } |
| 368 | |
| 369 | static rc_tcxx . . $ rc_t# FindRefEntrycxx . . $ FindRefEntry(858a706e6d5f570d).( PileupEstimatorcxx . . $ PileupEstimator# *self, RefEntrycxx . . $ RefEntry# ** entry, const Stringcxx . . $ String# * rname ) |
| 370 | { |
| 371 | rc_tcxx . . $ rc_t# rc = 0; |
| 372 | uint32_tcxx . . $ uint32_t# idx, count = VectorLengthcxx . . $ `interfaces/klib/vector.h:350:9`!( &self->reftable ); |
| 373 | *entry = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 374 | for( idx = 0; ( rc == 0 ) && ( idx < count ) && ( *entry == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); ++idx ) |
| 375 | { |
| 376 | RefEntrycxx . . $ RefEntry# * e = VectorGetcxx . . $ VectorGet(3b1701a338e5504b).( &self->reftablecxx . . $ PileupEstimator#reftable., idx ); |
| 377 | if ( e == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 378 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 379 | else if ( 0 == StringComparecxx . . $ StringCompare(bd5fd046769c5966).( e->rnamecxx . . $ RefEntry#rname., rname ) ) |
| 380 | *entry = e; |
| 381 | } |
| 382 | if ( *entry == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 383 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcNotFound ); |
| 384 | return rc; |
| 385 | } |
| 386 | |
| 387 | |
| 388 | static rc_tcxx . . $ rc_t# PerformEstimationcxx . . $ PerformEstimation(b8663da33edf5be9).( PileupEstimatorcxx . . $ PileupEstimator# *self, |
| 389 | RefEntrycxx . . $ RefEntry# * entry, |
| 390 | int64_tcxx . . $ int64_t# slice_start, |
| 391 | int32_tcxx . . $ int32_t# slice_len, |
| 392 | int64_tcxx . . $ int64_t# slice_end, |
| 393 | uint64_tcxx . . $ uint64_t# * result ) |
| 394 | { |
| 395 | rc_tcxx . . $ rc_t# rc = 0; |
| 396 | |
| 397 | if ( self->coveragecxx . . $ PileupEstimator#coverage. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 398 | { |
| 399 | self->coveragecxx . . $ PileupEstimator#coverage. = calloccxx . . $ calloc(63a7bf2941bfcd7a).( slice_len, sizeof *( self->coveragecxx . . $ PileupEstimator#coverage. ) ); |
| 400 | self->coverage_lencxx . . $ PileupEstimator#coverage_len. = slice_len; |
| 401 | } |
| 402 | else if ( self->coverage_lencxx . . $ PileupEstimator#coverage_len. < slice_len ) |
| 403 | { |
| 404 | freecxx . . $ free(5d22bdacc48458e8).( ( void * ) self->coveragecxx . . $ PileupEstimator#coverage. ); |
| 405 | self->coveragecxx . . $ PileupEstimator#coverage. = calloccxx . . $ calloc(63a7bf2941bfcd7a).( slice_len, sizeof *( self->coveragecxx . . $ PileupEstimator#coverage. ) ); |
| 406 | self->coverage_lencxx . . $ PileupEstimator#coverage_len. = slice_len; |
| 407 | } |
| 408 | else |
| 409 | { |
| 410 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( self->coveragecxx . . $ PileupEstimator#coverage., 0, self->coverage_lencxx . . $ PileupEstimator#coverage_len. ); |
| 411 | } |
| 412 | |
| 413 | if ( self->coveragecxx . . $ PileupEstimator#coverage. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 414 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcConstructing, rcMemory, rcExhausted ); |
| 415 | else |
| 416 | { |
| 417 | uint64_tcxx . . $ uint64_t# cutoff_sum = 0; |
| 418 | int64_tcxx . . $ int64_t# ref_row_id = entry->start_row_idcxx . . $ RefEntry#start_row_id.; |
| 419 | int64_tcxx . . $ int64_t# ref_row_count; |
| 420 | uint32_tcxx . . $ uint32_t# prim_id_count, prim_id_idx, ref_pos_count, ref_len_count, read_filter_len, elem_bits, boff; |
| 421 | int64_tcxx . . $ int64_t# * prim_ids; |
| 422 | int32_tcxx . . $ int32_t# * ref_pos_ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 423 | int32_tcxx . . $ int32_t# * ref_len_ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 424 | uint8_tcxx . . $ uint8_t# * read_filter_ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 425 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! done = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 426 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! filtered_out; |
| 427 | |
| 428 | /* adjust start_ref_row and ref_row_count to the given slice... */ |
| 429 | { |
| 430 | int64_tcxx . . $ int64_t# start_offset = (int64_tcxx . . $ int64_t#) (slice_start / self->max_seq_lencxx . . $ PileupEstimator#max_seq_len.); |
| 431 | int64_tcxx . . $ int64_t# end_offset = slice_end / self->max_seq_lencxx . . $ PileupEstimator#max_seq_len.; |
| 432 | if ( start_offset > 0 ) start_offset--; |
| 433 | ref_row_id += start_offset; |
| 434 | ref_row_count = ( end_offset - start_offset ) + 1; |
| 435 | } |
| 436 | |
| 437 | /* for each row in REFERENCE that matches the given slice... */ |
| 438 | for( ; rc == 0 && !done && ref_row_count > 0; ref_row_id++, ref_row_count-- ) |
| 439 | { |
| 440 | /* get the primary alignment-id's */ |
| 441 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., ref_row_id, self->ref_cursor_idx_PRIMARY_ALIGNMENT_IDScxx . . $ PileupEstimator#ref_cursor_idx_PRIMARY_ALIGNMENT_IDS., |
| 442 | &elem_bits, ( const void ** )&prim_ids, &boff, &prim_id_count ); |
| 443 | |
| 444 | /* doing the cutoff-check */ |
| 445 | if ( self->cutoff_valuecxx . . $ PileupEstimator#cutoff_value. > 0 ) |
| 446 | { |
| 447 | cutoff_sum += prim_id_count; |
| 448 | if ( cutoff_sum >= self->cutoff_valuecxx . . $ PileupEstimator#cutoff_value. ) |
| 449 | { |
| 450 | *result = UINTMAX_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:191:10`!; |
| 451 | done = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | /* for each alignment-id found */ |
| 456 | for ( prim_id_idx = 0; rc == 0 && !done && prim_id_idx < prim_id_count; prim_id_idx++ ) |
| 457 | { |
| 458 | /* get REF_POS */ |
| 459 | int64_tcxx . . $ int64_t# prim_id = prim_ids[ prim_id_idx ]; |
| 460 | filtered_out = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 461 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., prim_id, self->align_cursor_idx_REF_POScxx . . $ PileupEstimator#align_cursor_idx_REF_POS., |
| 462 | &elem_bits, ( const void ** )&ref_pos_ptr, &boff, &ref_pos_count ); |
| 463 | if ( ref_pos_count != 1 ) |
| 464 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 465 | |
| 466 | /* get REF_LEN */ |
| 467 | if ( rc == 0 ) |
| 468 | { |
| 469 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., prim_id, self->align_cursor_idx_REF_LENcxx . . $ PileupEstimator#align_cursor_idx_REF_LEN., |
| 470 | &elem_bits, ( const void ** )&ref_len_ptr, &boff, &ref_len_count ); |
| 471 | if ( ref_len_count != 1 ) |
| 472 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 473 | } |
| 474 | |
| 475 | /* get READ_FILTER */ |
| 476 | if ( rc == 0 && self->use_read_filtercxx . . $ PileupEstimator#use_read_filter. ) |
| 477 | { |
| 478 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., prim_id, self->align_cursor_idx_READ_FILTERcxx . . $ PileupEstimator#align_cursor_idx_READ_FILTER., |
| 479 | &elem_bits, ( const void ** )&read_filter_ptr, &boff, &read_filter_len ); |
| 480 | if ( read_filter_len > 0 ) |
| 481 | filtered_out = ( ( read_filter_ptr[ 0 ] == SRA_READ_FILTER_REJECTcxx . . $ SRA_READ_FILTER_REJECT. )|| |
| 482 | ( read_filter_ptr[ 0 ] == SRA_READ_FILTER_CRITERIAcxx . . $ SRA_READ_FILTER_CRITERIA. ) ); |
| 483 | } |
| 484 | |
| 485 | /* enter the coverage */ |
| 486 | if ( rc == 0 && !filtered_out ) |
| 487 | { |
| 488 | int32_tcxx . . $ int32_t# ref_pos = ref_pos_ptr[ 0 ]; |
| 489 | int32_tcxx . . $ int32_t# ref_len = ref_len_ptr[ 0 ]; |
| 490 | if ( ( ( ref_pos + ref_len - 1 ) >= slice_start ) && ( ref_pos <= slice_end ) ) |
| 491 | { |
| 492 | int32_tcxx . . $ int32_t# rel_start = ( ref_pos - ( uint32_tcxx . . $ uint32_t# )slice_start ); |
| 493 | int32_tcxx . . $ int32_t# i, j; |
| 494 | |
| 495 | if ( rel_start < 0 ) |
| 496 | { |
| 497 | ref_len += rel_start; |
| 498 | rel_start = 0; |
| 499 | } |
| 500 | for ( i = rel_start, j = 0; j < ref_len && i < slice_len; ++i, ++j ) |
| 501 | self->coveragecxx . . $ PileupEstimator#coverage.[ i ]++; /* <==== */ |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | /* sum up the bases in the slice */ |
| 508 | if ( rc == 0 && !done ) |
| 509 | { |
| 510 | int32_tcxx . . $ int32_t# idx; |
| 511 | uint64_tcxx . . $ uint64_t# sum = 0; |
| 512 | for ( idx = 0; idx < slice_len; ++idx ) sum += self->coveragecxx . . $ PileupEstimator#coverage.[ idx ]; |
| 513 | *result = sum; |
| 514 | } |
| 515 | } |
| 516 | return rc; |
| 517 | } |
| 518 | |
| 519 | LIB_EXPORTcxx . . $ `interfaces/kfc/extern.h:63:9`! rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! RunPileupEstimatorcxx . . $ RunPileupEstimator(433645cdd4c261ba).( struct PileupEstimatorcxx . . $ PileupEstimator# *self, |
| 520 | const Stringcxx . . $ String# * refname, |
| 521 | uint64_tcxx . . $ uint64_t# slice_start, |
| 522 | uint32_tcxx . . $ uint32_t# slice_len, |
| 523 | uint64_tcxx . . $ uint64_t# * result ) |
| 524 | { |
| 525 | rc_tcxx . . $ rc_t# rc = 0; |
| 526 | if ( self == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 527 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcSelf, rcNull ); |
| 528 | else if ( refname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || result == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 529 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcNull ); |
| 530 | else if ( slice_len == 0 ) |
| 531 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcInvalid ); |
| 532 | else |
| 533 | { |
| 534 | *result = 0; |
| 535 | /* we are using max_seq_len as a flag to determine if we have to scan the reference-table */ |
| 536 | if ( self->max_seq_lencxx . . $ PileupEstimator#max_seq_len. == 0 ) |
| 537 | rc = ScanRefTablecxx . . $ ScanRefTable(a75ec6f50ca111c5).( self ); |
| 538 | if ( rc == 0 ) |
| 539 | { |
| 540 | RefEntrycxx . . $ RefEntry# * ref_entry; |
| 541 | rc = FindRefEntrycxx . . $ FindRefEntry(858a706e6d5f570d).( self, &ref_entry, refname ); |
| 542 | if ( rc == 0 ) |
| 543 | { |
| 544 | uint64_tcxx . . $ uint64_t# slice_end = slice_start + slice_len - 1; |
| 545 | if ( slice_start >= ref_entry->reflencxx . . $ RefEntry#reflen. || slice_end >= ref_entry->reflencxx . . $ RefEntry#reflen. ) |
| 546 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 547 | else |
| 548 | { |
| 549 | assertcxx . . $ `/usr/include/assert.h:118:11`! ( (int64_t)slice_start > 0 ); |
| 550 | assertcxx . . $ `/usr/include/assert.h:118:11`! ( (int64_t)slice_len > 0 ); |
| 551 | assertcxx . . $ `/usr/include/assert.h:118:11`! ( (int64_t)slice_end > 0 ); |
| 552 | rc = PerformEstimationcxx . . $ PerformEstimation(b8663da33edf5be9).( self, ref_entry, slice_start, slice_len, slice_end, result ); |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | } |
| 557 | return rc; |
| 558 | } |
| 559 | |
| 560 | |
| 561 | static rc_tcxx . . $ rc_t# PerformCoveragecxx . . $ PerformCoverage(e4667cd380d86825).( PileupEstimatorcxx . . $ PileupEstimator# *self, |
| 562 | RefEntrycxx . . $ RefEntry# * entry, |
| 563 | int64_tcxx . . $ int64_t# slice_start, |
| 564 | int32_tcxx . . $ int32_t# slice_len, |
| 565 | int64_tcxx . . $ int64_t# slice_end, |
| 566 | uint32_tcxx . . $ uint32_t# * coverage ) |
| 567 | { |
| 568 | rc_tcxx . . $ rc_t# rc = 0; |
| 569 | |
| 570 | int64_tcxx . . $ int64_t# ref_row_id = entry->start_row_idcxx . . $ RefEntry#start_row_id., ref_row_count; |
| 571 | uint32_tcxx . . $ uint32_t# prim_id_count, prim_id_idx, ref_pos_count, ref_len_count, read_filter_len, elem_bits, boff; |
| 572 | int64_tcxx . . $ int64_t# * prim_ids = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 573 | int32_tcxx . . $ int32_t# * ref_pos_ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 574 | int32_tcxx . . $ int32_t# * ref_len_ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 575 | uint8_tcxx . . $ uint8_t# * read_filter_ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 576 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! filtered_out; |
| 577 | |
| 578 | /* adjust start_ref_row and ref_row_count to the given slice... */ |
| 579 | { |
| 580 | int64_tcxx . . $ int64_t# start_offset = slice_start / self->max_seq_lencxx . . $ PileupEstimator#max_seq_len.; |
| 581 | int64_tcxx . . $ int64_t# end_offset = slice_end / self->max_seq_lencxx . . $ PileupEstimator#max_seq_len.; |
| 582 | if ( start_offset > 0 ) start_offset--; |
| 583 | ref_row_id += start_offset; |
| 584 | ref_row_count = ( end_offset - start_offset ) + 1; |
| 585 | } |
| 586 | |
| 587 | /* for each row in REFERENCE that matches the given slice... */ |
| 588 | for( ; rc == 0 && ref_row_count > 0; ref_row_id++, ref_row_count-- ) |
| 589 | { |
| 590 | /* get the primary alignment-id's */ |
| 591 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->ref_cursorcxx . . $ PileupEstimator#ref_cursor., ref_row_id, self->ref_cursor_idx_PRIMARY_ALIGNMENT_IDScxx . . $ PileupEstimator#ref_cursor_idx_PRIMARY_ALIGNMENT_IDS., |
| 592 | &elem_bits, ( const void ** )&prim_ids, &boff, &prim_id_count ); |
| 593 | |
| 594 | /* for each alignment-id found */ |
| 595 | for ( prim_id_idx = 0; rc == 0 && prim_id_idx < prim_id_count; prim_id_idx++ ) |
| 596 | { |
| 597 | /* get REF_POS */ |
| 598 | int64_tcxx . . $ int64_t# prim_id = prim_ids[ prim_id_idx ]; |
| 599 | filtered_out = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 600 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., prim_id, self->align_cursor_idx_REF_POScxx . . $ PileupEstimator#align_cursor_idx_REF_POS., |
| 601 | &elem_bits, ( const void ** )&ref_pos_ptr, &boff, &ref_pos_count ); |
| 602 | if ( ref_pos_count != 1 ) |
| 603 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 604 | |
| 605 | /* get REF_LEN */ |
| 606 | if ( rc == 0 ) |
| 607 | { |
| 608 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., prim_id, self->align_cursor_idx_REF_LENcxx . . $ PileupEstimator#align_cursor_idx_REF_LEN., |
| 609 | &elem_bits, ( const void ** )&ref_len_ptr, &boff, &ref_len_count ); |
| 610 | if ( ref_len_count != 1 ) |
| 611 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 612 | } |
| 613 | |
| 614 | /* get READ_FILTER */ |
| 615 | if ( rc == 0 && self->use_read_filtercxx . . $ PileupEstimator#use_read_filter. ) |
| 616 | { |
| 617 | rc = VCursorCellDataDirectcxx . . $ VCursorCellDataDirect(a0934254cb578360).( self->align_cursorcxx . . $ PileupEstimator#align_cursor., prim_id, self->align_cursor_idx_READ_FILTERcxx . . $ PileupEstimator#align_cursor_idx_READ_FILTER., |
| 618 | &elem_bits, ( const void ** )&read_filter_ptr, &boff, &read_filter_len ); |
| 619 | if ( read_filter_len > 0 ) |
| 620 | filtered_out = ( ( read_filter_ptr[ 0 ] == SRA_READ_FILTER_REJECTcxx . . $ SRA_READ_FILTER_REJECT. )|| |
| 621 | ( read_filter_ptr[ 0 ] == SRA_READ_FILTER_CRITERIAcxx . . $ SRA_READ_FILTER_CRITERIA. ) ); |
| 622 | } |
| 623 | |
| 624 | /* enter the coverage */ |
| 625 | if ( rc == 0 && !filtered_out ) |
| 626 | { |
| 627 | int64_tcxx . . $ int64_t# ref_pos = ref_pos_ptr[ 0 ]; |
| 628 | int64_tcxx . . $ int64_t# ref_len = ref_len_ptr[ 0 ]; |
| 629 | if ( ( ( ref_pos + ref_len - 1 ) >= slice_start ) && ( ref_pos <= slice_end ) ) |
| 630 | { |
| 631 | int64_tcxx . . $ int64_t# j; |
| 632 | int64_tcxx . . $ int64_t# rel_pos = ref_pos; |
| 633 | rel_pos -= slice_start; |
| 634 | |
| 635 | if ( rel_pos < 0 ) |
| 636 | { |
| 637 | ref_len += rel_pos; |
| 638 | rel_pos = 0; |
| 639 | } |
| 640 | |
| 641 | for ( j = 0; j < ref_len && rel_pos < slice_len; ++rel_pos, ++j ) |
| 642 | coverage[ rel_pos ]++; /* <==== */ |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | return rc; |
| 648 | } |
| 649 | |
| 650 | |
| 651 | LIB_EXPORTcxx . . $ `interfaces/kfc/extern.h:63:9`! rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! RunCoveragecxx . . $ RunCoverage(d162cf062f2c9e9b).( struct PileupEstimatorcxx . . $ PileupEstimator# *self, |
| 652 | const Stringcxx . . $ String# * refname, |
| 653 | uint64_tcxx . . $ uint64_t# slice_start, |
| 654 | uint32_tcxx . . $ uint32_t# slice_len, |
| 655 | uint32_tcxx . . $ uint32_t# * coverage ) |
| 656 | { |
| 657 | rc_tcxx . . $ rc_t# rc = 0; |
| 658 | if ( self == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 659 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcSelf, rcNull ); |
| 660 | else if ( refname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || coverage == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 661 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcNull ); |
| 662 | else if ( slice_len == 0 ) |
| 663 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcInvalid ); |
| 664 | else |
| 665 | { |
| 666 | /* we are using max_seq_len as a flag to determine if we have to scan the reference-table */ |
| 667 | if ( self->max_seq_lencxx . . $ PileupEstimator#max_seq_len. == 0 ) |
| 668 | rc = ScanRefTablecxx . . $ ScanRefTable(a75ec6f50ca111c5).( self ); |
| 669 | if ( rc == 0 ) |
| 670 | { |
| 671 | RefEntrycxx . . $ RefEntry# * ref_entry; |
| 672 | rc = FindRefEntrycxx . . $ FindRefEntry(858a706e6d5f570d).( self, &ref_entry, refname ); |
| 673 | if ( rc == 0 ) |
| 674 | { |
| 675 | uint64_tcxx . . $ uint64_t# slice_end = slice_start + slice_len - 1; |
| 676 | if ( slice_start >= ref_entry->reflencxx . . $ RefEntry#reflen. || slice_end >= ref_entry->reflencxx . . $ RefEntry#reflen. ) |
| 677 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 678 | else |
| 679 | { |
| 680 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( coverage, 0, slice_len * ( sizeof *coverage ) ); |
| 681 | rc = PerformCoveragecxx . . $ PerformCoverage(e4667cd380d86825).( self, ref_entry, slice_start, slice_len, slice_end, coverage ); |
| 682 | } |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | } |
| 687 | return rc; |
| 688 | } |
| 689 | |
| 690 | |
| 691 | LIB_EXPORTcxx . . $ `interfaces/kfc/extern.h:63:9`! rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! EstimatorRefCountcxx . . $ EstimatorRefCount(83d24d90175af57b).( struct PileupEstimatorcxx . . $ PileupEstimator# *self, uint32_tcxx . . $ uint32_t# * count ) |
| 692 | { |
| 693 | rc_tcxx . . $ rc_t# rc = 0; |
| 694 | if ( self == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 695 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcSelf, rcNull ); |
| 696 | else if ( count == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 697 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcNull ); |
| 698 | else |
| 699 | { |
| 700 | /* we are using max_seq_len as a flag to determine if we have to scan the reference-table */ |
| 701 | if ( self->max_seq_lencxx . . $ PileupEstimator#max_seq_len. == 0 ) |
| 702 | rc = ScanRefTablecxx . . $ ScanRefTable(a75ec6f50ca111c5).( self ); |
| 703 | if ( rc == 0 ) |
| 704 | *count = VectorLengthcxx . . $ `interfaces/klib/vector.h:350:9`!( &self->reftable ); |
| 705 | } |
| 706 | return rc; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | LIB_EXPORTcxx . . $ `interfaces/kfc/extern.h:63:9`! rc_tcxx . . $ rc_t# CCcxx . . $ `interfaces/kfc/callconv.h:44:11`! EstimatorRefInfocxx . . $ EstimatorRefInfo(fa0b9decdd96b72c).( struct PileupEstimatorcxx . . $ PileupEstimator# *self, |
| 711 | uint32_tcxx . . $ uint32_t# idx, |
| 712 | Stringcxx . . $ String# * refname, |
| 713 | uint64_tcxx . . $ uint64_t# * reflen ) |
| 714 | { |
| 715 | rc_tcxx . . $ rc_t# rc = 0; |
| 716 | if ( self == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 717 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcSelf, rcNull ); |
| 718 | else if ( refname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || reflen == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 719 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcParam, rcNull ); |
| 720 | else |
| 721 | { |
| 722 | if ( self->max_seq_lencxx . . $ PileupEstimator#max_seq_len. == 0 ) |
| 723 | rc = ScanRefTablecxx . . $ ScanRefTable(a75ec6f50ca111c5).( self ); |
| 724 | if ( rc == 0 ) |
| 725 | { |
| 726 | RefEntrycxx . . $ RefEntry# * e = VectorGetcxx . . $ VectorGet(3b1701a338e5504b).( &self->reftablecxx . . $ PileupEstimator#reftable., idx ); |
| 727 | if ( e == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 728 | rc = RCcxx . . $ `interfaces/klib/rc.h:111:9`!( rcAlign, rcQuery, rcAccessing, rcItem, rcInvalid ); |
| 729 | else |
| 730 | { |
| 731 | StringInitcxx . . $ `interfaces/klib/text.h:114:9`!( refname, e->rname->addr, e->rname->size, e->rname->len ); |
| 732 | *reflen = e->reflencxx . . $ RefEntry#reflen.; |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | return rc; |
| 737 | } |