static rc_t CC _AddSidNoLock ( const char * Name, struct __SidNode ** Ret ) { struct __SidNode * Node; rc_t RCt; Node = NULL; RCt = 0; if ( Name == NULL || Ret == NULL ) { return XFS_RC ( rcNull ); } * Ret = NULL; RCt = _SidNodeMake ( Name, & Node ); if ( RCt == 0 ) { RCt = BSTreeInsert ( & _sSidStorage, & ( Node -> node ), _SidStorageAddCallback ); if ( RCt == 0 ) { * Ret = Node; } } if ( RCt != 0 ) { _SidNodeDispose ( Node ); } return RCt; } /* _AddSidNoLock () */
static void count_indel_fragment( BSTree * fragments, const INSDC_4na_bin *bases, uint32_t len ) { find_fragment_ctx fctx; fctx.bases = malloc( len ); if ( fctx.bases != NULL ) { indel_fragment * fragment; uint32_t i; fctx.len = len; for ( i = 0; i < len; ++i ) ( ( char * )fctx.bases )[ i ] = _4na_to_ascii( bases[ i ], false ); fragment = ( indel_fragment * ) BSTreeFind ( fragments, &fctx, cmp_fragment_vs_find_ctx ); if ( fragment == NULL ) { fragment = make_indel_fragment( fctx.bases, len ); if ( fragment != NULL ) { rc_t rc = BSTreeInsert ( fragments, ( BSTNode * )fragment, cmp_fragment_vs_fragment ); if ( rc != 0 ) free_indel_fragment( ( BSTNode * )fragment, NULL ); } } else fragment->count++; free( ( void * ) fctx.bases ); } }
/* BSTreeResort * an optimized removal and re-insertion of * all contained elements using another function * * the treatment of order for items reported as identical * i.e. sort function returns zero when they are compared, * is undefined. * * the current implementation treats '<=' as '<' such * that all inserts are converted to a '<' or '>' comparison, * but this should not be relied upon. */ LIB_EXPORT void CC BSTreeResort ( BSTree *bt, int64_t ( CC * resort ) ( const BSTNode *item, const BSTNode *n ) ) { if ( bt != NULL ) { BSTNode *p = bt -> root; bt -> root = NULL; while ( p != NULL ) { BSTNode *q = p -> child [ 0 ]; if ( q == 0 ) { q = p -> child [ 1 ]; BSTreeInsert ( bt, p, resort ); } else { p -> child [ 0 ] = q -> child [ 1 ]; q -> child [ 1 ] = p; } p = q; } } }
static rc_t KNSProxiesAddHttpProxyPath ( KNSProxies * self, const char * proxy, size_t proxy_size, uint16_t proxy_port ) { const String * proxy_host = NULL; rc_t rc = 0; HttpProxy * new_proxy = NULL; BSTItem * node = NULL; HttpProxy add = { proxy_host, proxy_port, 0 }; assert ( self ); if ( proxy == NULL ) return 0; if ( rc == 0 ) { String tmp; StringInit ( & tmp, proxy, proxy_size, string_len ( proxy, proxy_size ) ); rc = StringCopy ( & proxy_host, & tmp ); if ( rc == 0 ) add . proxy_host = proxy_host; else return rc; } if ( BSTreeFind ( & self -> proxie_tree, & add, BSTItemCmp ) != NULL ) { DBGMSG ( DBG_KNS, DBG_FLAG ( DBG_KNS_PROXY ), ( "Ignored duplicate proxy '%S:%d'\n", proxy_host, proxy_port ) ); free ( ( void * ) proxy_host ); return 0; } new_proxy = calloc ( 1, sizeof * new_proxy ); if ( new_proxy == NULL ) return RC ( rcNS, rcMgr, rcAllocating, rcMemory, rcExhausted ); new_proxy -> proxy_host = proxy_host; new_proxy -> proxy_port = proxy_port; node = calloc ( 1, sizeof * node ); if ( node == NULL ) { free ( new_proxy ); return RC ( rcNS, rcMgr, rcAllocating, rcMemory, rcExhausted ); } node -> proxy = new_proxy; rc = BSTreeInsert ( & self -> proxie_tree, ( BSTNode * ) node, BSTreeSort ); DBGMSG ( DBG_KNS, DBG_FLAG ( DBG_KNS_PROXY ), ( "Added proxy '%S:%d'\n", proxy_host, proxy_port ) ); if ( ! self -> http_proxy_enabled ) self -> http_proxy_enabled = ( proxy_host != NULL ); return rc; }
rc_t KeyRingDataInsertObject(ObjectTable* data, uint32_t p_id, const String* name, const String* project, const String* display_name, uint64_t size, const String* checksum, const String* encryption_key) { rc_t rc = 0; Object* obj = (Object*) malloc(sizeof(Object)); if (obj != NULL) { rc = ObjectInit(obj, p_id, name, project, display_name, size, checksum, encryption_key); if (rc == 0) { rc = BSTreeInsert(data, &obj->dad, SortObjects); if (rc != 0) ProjectWhack(&obj->dad, NULL); } else free(obj); } else rc = RC ( rcApp, rcDatabase, rcUpdating, rcMemory, rcExhausted ); return rc; }
static rc_t VProdResolveColExpr ( const VProdResolve *self, VProduction **out, VFormatdecl *fd, const SSymExpr *x, bool casting ) { rc_t rc; const SNameOverload *sname; const KSymbol *sym = x -> _sym; BSTree ordered; uint32_t i, count; SColumnBestFit buff [ 16 ], * nodes = buff; /* fail if "fd" has a format */ if ( fd -> fmt != 0 ) { PLOGMSG ( klogWarn, ( klogWarn, "illegal cast of column '$(name)'" , "name=%.*s" , ( int ) sym -> name . size , sym -> name . addr )); return 0; } /* allocate nodes for indexing columns */ sname = sym -> u . obj; count = VectorLength ( & sname -> items ); if ( count > sizeof buff / sizeof buff [ 0 ] ) { nodes = malloc ( sizeof * nodes * count ); if ( nodes == NULL ) return RC ( rcVDB, rcProduction, rcResolving, rcMemory, rcExhausted ); } /* insert columns into ordered tree */ BSTreeInit ( & ordered ); for ( i = VectorStart ( & sname -> items ), count += i; i < count; ++ i ) { /* get SColumn */ nodes [ i ] . scol = ( const void* ) VectorGet ( & sname -> items, i ); /* perform type cast and measure distance */ if ( casting ? VTypedeclCommonAncestor ( & nodes [ i ] . scol -> td, self -> schema, & fd -> td, & nodes [ i ] . td, & nodes [ i ] . distance ) : VTypedeclToTypedecl ( & nodes [ i ] . scol -> td, self -> schema, & fd -> td, & nodes [ i ] . td, & nodes [ i ] . distance ) ) { BSTreeInsert ( & ordered, & nodes [ i ] . n, order_column ); } } /* try to resolve each in order */ rc = VProdResolveBestColumn ( self, out, & ordered, x -> alt ); if ( nodes != buff ) free ( nodes ); return rc; }
rc_t VCursorListSeededWritableColumns ( VCursor *self, BSTree *columns, const KNamelist *seed ) { rc_t rc; KDlset *libs; struct resolve_phys_data pb; pb . pr . schema = self -> schema; pb . pr . ld = self -> tbl -> linker; pb . pr . stbl = self -> stbl; pb . pr . curs = self; pb . pr . cache = & self -> prod; pb . pr . owned = & self -> owned; pb . pr . chain = chainEncoding; pb . pr . blobbing = false; pb . pr . ignore_column_errors = true; pb . pr . discover_writable_columns = true; pb . seed = seed; if ( seed != NULL ) { rc = KNamelistCount ( seed, & pb . count ); if ( rc != 0 ) return rc; } /* open the dynamic linker libraries */ rc = VLinkerOpen ( pb . pr . ld, & libs ); if ( rc == 0 ) { pb . pr . libs = libs; VProdResolveWritableColumns ( & pb , self->suspend_triggers ); KDlsetRelease ( libs ); if ( rc == 0 ) { /* add columns to list */ uint32_t idx = VectorStart ( & self -> row ); uint32_t end = VectorLength ( & self -> row ); for ( end += idx; idx < end; ++idx ) { const VColumn* vcol = ( const VColumn* ) VectorGet ( & self -> row, idx ); if ( vcol != NULL ) { VColumnRef *cref; rc = VColumnRefMake ( & cref, self -> schema, vcol -> scol ); if ( rc != 0 ) break; rc = BSTreeInsert ( columns, & cref -> n, VColumnRefSort ); assert ( rc == 0 ); } } } } return rc; }
rc_t extract_statistic_from_row( statistic * data, row_input * row_data, const int64_t row_id ) { rc_t rc = 0; spotgrp *sg; /* first try the SPOT_GROUP column (correct for newer db's) */ char * spotgrp_base = row_data->spotgroup; uint32_t spotgrp_len = row_data->spotgroup_len; /* first try the SPOT_GROUP column (correct for newer db's) */ if ( spotgrp_len < 1 || *spotgrp_base == 0 ) { /* if empty try with SEQ_SPOT_GROUP column (correct for older db's) */ spotgrp_base = row_data->seq_spotgroup; spotgrp_len = row_data->seq_spotgroup_len; } sg = find_spotgroup( data, spotgrp_base, spotgrp_len ); if ( sg == NULL ) { sg = make_spotgrp( spotgrp_base, spotgrp_len ); if ( sg == NULL ) { rc = RC( rcApp, rcSelf, rcConstructing, rcMemory, rcExhausted ); PLOGERR( klogInt, ( klogInt, rc, "make_spotgrp failed at row $(row_nr)", "row_nr=%lu", row_id ) ); } else { rc = BSTreeInsert ( &data->spotgroups, (BSTNode *)sg, spotgroup_sort ); if ( rc != 0 ) { PLOGERR( klogInt, ( klogInt, rc, "BSTreeInsert( new spotgroup ) at row $(row_nr)", "row_nr=%lu", row_id ) ); } } } if ( rc == 0 ) { uint32_t n_bases = row_data->read_len; if ( ( n_bases == row_data->quality_len ) && ( n_bases == row_data->has_mismatch_len ) ) { rc = extract_spotgroup_statistic( data, sg, n_bases, row_data, row_id ); } else { rc = RC( rcApp, rcNoTarg, rcConstructing, rcData, rcInvalid ); PLOGERR( klogInt, ( klogInt, rc, "number of bases, quality and has_mismatch is not the same at row $(row_nr)", "row_nr=%lu", row_id ) ); } } return rc; }
static rc_t add_seq_id_node( BSTree * tree, const char * seq_id, const char * name, INSDC_coord_len len ) { rc_t rc = 0; seq_id_node * node = make_seq_id_node( seq_id, name, len ); if ( node != NULL ) { rc = BSTreeInsert( tree, (BSTNode *)node, node_vs_node_wrapper ); if ( rc != 0 ) free_seq_id_node( node ); } else rc = RC( rcApp, rcNoTarg, rcConstructing, rcMemory, rcExhausted ); return rc; }
static rc_t insert_trans_nodes( BSTree *tree ) { rc_t rc = 0; uint32_t idx; for ( idx = 0; idx < N_TRANS_NODES && rc == 0; ++idx ) { trans_node * node = make_trans_node( chromosomes[ idx ], translations[ idx ] ); if ( node != NULL ) { rc = BSTreeInsert ( tree, (BSTNode *)node, trans_node_sort ); } } return rc; }
static rc_t XmlMetaInitMemser(BSTree* tr, const KXMLNode* node, const char* path, const char* member_name) { rc_t rc = 0; MetaMember* member = (MetaMember*)BSTreeFind(tr, member_name, MetaMemberCmp); if (member) { rc = RC(rcExe, rcMetadata, rcReading, rcAttr, rcDuplicate); PLOGERR(klogErr, ( klogErr, rc, "Member/@member_name='$(name)'", "name=%s", member_name)); } else { member = calloc(1, sizeof(*member)); if (member == NULL) { rc = RC(rcExe, rcStorage, rcAllocating, rcMemory, rcExhausted); } if (rc == 0) { member->member_name = strdup(member_name); if (member == NULL) { rc = RC(rcExe, rcStorage, rcAllocating, rcMemory, rcExhausted); } } if (rc == 0) { member->meta = calloc(1, sizeof(*member->meta)); if (member->meta == NULL) { rc = RC(rcExe, rcStorage, rcAllocating, rcMemory, rcExhausted); } } if (rc == 0) { rc = ParseSraMetaNode(node, path, member_name, member->meta); } if (rc) { if (member) { FREE(member->member_name); FREE(member->meta); FREE(member); } } else { BSTreeInsert(tr, (BSTNode*)member, MetaMemberSort); } } return rc; }
int main(int argc, char *argv[]) { BSTree T; int i, n, nvals, v[MAXVALS]; // Build tree from values in stdin T = newBSTree(); nvals = 0; while (nvals < MAXVALS && scanf("%d",&n) == 1) { v[nvals++] = n; T = BSTreeInsert(T,n); } // Display information about constructed tree printf("Tree:\n");showBSTree(T); printf("\n#nodes = %d, ",BSTreeNumNodes(T)); printf("#leaves = %d\n",BSTreeNumLeaves(T)); printf("Infix : "); BSTreeInfix(T); printf("\n"); printf("Prefix : "); BSTreePrefix(T); printf("\n"); printf("Postfix: "); BSTreePostfix(T); printf("\n"); printf("ByLevel: "); BSTreeLevelOrder(T); printf("\n"); if (argc >= 2) { FILE *out = fopen(argv[1], "w"); if (out) { BSTreeDot(T, out); fclose(out); } else { perror("fopen"); } } // Check correctness of tree // assume no duplicates => each value produces a node assert(nvals == BSTreeNumNodes(T)); // every inserted value can be found for (i = 0; i < nvals; i++) assert(BSTreeFind(T,v[i]) != 0); // (hopefully) non-existent value cannot be found assert(BSTreeFind(T,-7654321) == 0); dropBSTree(T); return 0; }
static rc_t CC _TeleportAdd ( const char * Name, XFSTeleportProvider_t Provider ) { rc_t RCt; struct _TNode * Tde; RCt = 0; if ( Name == NULL || Provider == NULL ) { return XFS_RC ( rcNull ); } if ( _TeleportHas ( Name ) == true ) { return XFS_RC ( rcInvalid ); } Tde = calloc ( 1, sizeof ( struct _TNode ) ); if ( Tde == NULL ) { return XFS_RC ( rcExhausted ); } if ( XFS_StrDup ( Name, & ( Tde -> Type ) ) != 0 ) { free ( Tde ); return XFS_RC ( rcExhausted ); } RCt = Provider ( & Tde -> Teleport ); if ( RCt != 0 || Tde -> Teleport == NULL ) { free ( ( char * ) Tde -> Type ); free ( Tde ); return XFS_RC ( rcInvalid ); } BSTreeInsert ( ( struct BSTree * ) & _sTeleport, ( struct BSTNode * ) Tde, _TeleportAddCallback ); return RCt; } /* _TeleportAdd () */
/* call back for each reference-region to generate eventually a skiplist_ref_node */ static void CC visit_region_node_for_skiplist( BSTNode *n, void *data ) { const struct reference_region * r = ( const struct reference_region * ) n; struct skiplist * skl = ( struct skiplist * ) data; if ( r != NULL && skl != NULL ) { /* walk the reference-region, detect if we even have something to skip in here */ if ( reference_region_has_skip_ranges( r ) ) { struct skiplist_ref_node * srn = make_skiplist_ref_node( r ); if ( srn != NULL ) { BSTreeInsert ( &(skl->nodes), ( BSTNode * )srn, srn_vs_srn_wrapper ); skl->node_count++; } } } }
/* ---------------------------------------------------------------------- */ static rc_t insert_path (const VPath * vpath, uint64_t offset) { extnode * node; rc_t rc; rc = extnode_make (&node, vpath, offset); if (rc == 0) { rc = BSTreeInsert (&options.pathtree, &node->node, extnode_sort); if (rc) LOGERR (klogInt, rc, "error inserting tree node"); else return 0; extnode_whack (&node->node, NULL); } return rc; }
static rc_t cg_dump_row( cg_dump_opts * opts, cg_dump_ctx * cg_ctx, uint64_t row_id ) { uint32_t elem_bits, boff, sg_len; const char * sg; rc_t rc = VCursorCellDataDirect( cg_ctx->seq_cur, row_id, cg_ctx->seq_sg_idx, &elem_bits, (const void**)&sg, &boff, &sg_len ); if ( rc != 0 ) { (void)PLOGERR( klogErr, ( klogErr, rc, "cannot read spot-group in row #$(row_id)", "row_id=%lu", row_id ) ); } else { String spot_group; lane * sg_lane; StringInit( &spot_group, sg, sg_len, sg_len ); sg_lane = ( lane * )BSTreeFind ( &cg_ctx->lanes, &spot_group, String_lane_cmp ); if ( sg_lane == NULL ) { /* KOutMsg( "row %lu (%S) not found, create it\n", row_id, &spot_group ); */ rc = make_lane( opts, cg_ctx->lookup, cg_ctx->out_dir, &spot_group, &sg_lane ); if ( rc == 0 ) { rc = BSTreeInsert ( &cg_ctx->lanes, ( BSTNode * )sg_lane, lane_lane_cmp ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "cannot insert new lane" ); whack_lane( sg_lane ); } } } else { /* KOutMsg( "row %lu (%S) found, use it\n", row_id, &spot_group ); */ } if ( rc == 0 ) { cg_dump_write_spot( opts, cg_ctx, row_id, sg_lane ); /* <================== */ } } return rc; }
static bool CC KU64Index_UnrollPersisted( PBSTNode *n, void *data ) { KU64Index_v3* self = data; const KU64Index_PNode* pn = n->data.addr; KU64Index_Node* node = calloc(1, sizeof(KU64Index_Node)); if( node == NULL ) { self->rc = RC(rcExe, rcNode, rcConstructing, rcMemory, rcInsufficient); } else { node->key = pn->key; node->key_size = pn->key_size; node->id = pn->id; node->id_qty = pn->id_qty; self->rc = BSTreeInsert(&self->tree, &node->node, KU64Index_NodeSort); } if( self->rc != 0 ) { free(node); } return self->rc == 0 ? false : true; }
static rc_t pnamesInsert (const char * path) { pnamesNode * node; rc_t rc; rc = pnamesNodeMake (&node, path); /* if (rc != 0) */ /* PLOGERR (klogDebug2, (klogDebug2, rc, "Unable to process filter parameter $(P)", */ /* PLOG_S(P), path)); */ if (rc == 0) { rc = BSTreeInsert ( &pnames, &node->dad, pnamesInsertCmp ); /* if (rc != 0) */ /* PLOGERR (klogDebug2, (klogDebug2, rc, "Unable to store filter parameter $(P)", */ /* PLOG_S(P), path)); */ /* else */ /* PLOGMSG (klogDebug2, "Processed filter parameter $(P)", */ /* PLOG_S(P), path); */ } return rc; }
static rc_t find_or_make_by_name( ref_exclude *exclude, const String * name, ref_node ** node ) { rc_t rc = 0; *node = find_ref_node( exclude, name ); if ( *node == NULL ) { /* if not found: make such a node... */ *node = make_ref_node( exclude, name ); if ( *node == NULL ) { rc = RC( rcApp, rcNoTarg, rcConstructing, rcSelf, rcNull ); } else { /* if node was successfully made, insert it into our tree */ rc = BSTreeInsert ( &exclude->ref_nodes, (BSTNode *)( *node ), ref_node_sort ); } } return rc; }
LIB_EXPORT rc_t CC XFSOwpSet ( const struct XFSOwp * self, const char * Key, const char * Property ) { rc_t RCt; struct XFSOwpEntry * Entry; RCt = 0; Entry = NULL; /* I suppose, that Property could be NULL value */ if ( self == NULL || Key == NULL ) { return XFS_RC ( rcNull ); } /* All property values are unique */ if ( XFSOwpHas ( self, Key ) == true ) { return XFS_RC ( rcInvalid ); } Entry = _OWPEntryMake ( Key, Property ); if ( Entry == NULL ) { RCt = XFS_RC ( rcExhausted ); } else { RCt = BSTreeInsert ( ( BSTree * ) self, ( BSTNode * ) Entry, _OWPNodeCmp ); } return RCt; } /* XFSOwpSet () */
rc_t KU64IndexInsert_v3(KU64Index_v3* self, bool unique, uint64_t key, uint64_t key_size, int64_t id, uint64_t id_qty) { KU64Index_Node* node = calloc(1, sizeof(KU64Index_Node)); self->rc = 0; if( node == NULL ) { self->rc = RC(rcExe, rcNode, rcConstructing, rcMemory, rcInsufficient); } else { node->key = key; node->key_size = key_size; node->id = id; node->id_qty = id_qty; if( unique ) { self->rc = BSTreeInsertUnique(&self->tree, &node->node, NULL, KU64Index_NodeSortUnique); } else { self->rc = BSTreeInsert(&self->tree, &node->node, KU64Index_NodeSort); } } if( self->rc != 0 ) { free(node); } return self->rc; }
rc_t add_region( BSTree * regions, const char * name, const uint64_t start, const uint64_t end ) { rc_t rc; struct reference_region * r = find_reference_region( regions, name ); if ( r == NULL ) { r = make_reference_region( name ); if ( r == NULL ) rc = RC( rcApp, rcNoTarg, rcConstructing, rcMemory, rcExhausted ); else rc = add_ref_region_range( r, start, end ); if ( rc == 0 ) rc = BSTreeInsert ( regions, (BSTNode *)r, ref_vs_ref_wrapper ); if ( rc != 0 ) free_reference_region( r ); } else { rc = add_ref_region_range( r, start, end ); } return rc; }
rc_t KeyRingDataInsertProject (ProjectTable* data, uint32_t p_id, const String* name, const String* download_ticket, const String* encryption_key) { rc_t rc = 0; Project* p = (Project*) malloc(sizeof(Project)); if (p != NULL) { rc = ProjectInit(p, p_id, name, download_ticket, encryption_key); if (rc == 0) { rc = BSTreeInsert(data, &p->dad, SortProjects); if (rc != 0) ProjectWhack(&p->dad, NULL); } if (rc != 0) free(p); } else rc = RC ( rcApp, rcDatabase, rcUpdating, rcMemory, rcExhausted ); return rc; }
/* function INSDC:coord:zero NCBI:align:ref_pos ( I64 ref_id, INSDC:coord:zero ref_start ); */ static rc_t CC align_ref_pos ( void *data, const VXformInfo *info, int64_t row_id, VRowResult *rslt, uint32_t argc, const VRowData argv[] ) { rc_t rc = 0; RefPos const *self = ( void const * )data; int64_t ref_row_id = 0; INSDC_coord_zero *ref_pos; unsigned const ploidy = ( unsigned const )argv[ REF_START ].u.data.elem_count; unsigned i; /* get start and length of reference segment */ int64_t const *ref_id = 0; INSDC_coord_zero const *ref_start; assert( argv[ REF_ID ].u.data.elem_bits == sizeof( *ref_id ) * 8 ); assert( argv[ REF_START ].u.data.elem_bits == sizeof( *ref_start ) * 8 ); ref_start = argv[ REF_START ].u.data.base; ref_start += argv[ REF_START ].u.data.first_elem; if ( self->curs != NULL ) { char const *name = NULL; uint32_t name_len; BSTRowRange *brr; ref_id = argv[ REF_ID ].u.data.base; ref_id += argv[ REF_ID ].u.data.first_elem; brr = ( BSTRowRange * )BSTreeFind( &self->tr_range, &ref_id[ 0 ], row_range_cmp ); if ( brr == NULL ) { RowRange *new_rr; SUB_DEBUG( ( "SUB.Rd in 'align-ref-pos.c' at #%lu\n", ref_id[ 0 ] ) ); rc = VCursorCellDataDirect( self->curs, ref_id[ 0 ], self->name_idx, NULL, (void const **)&name, NULL, &name_len ); if ( rc != 0 ) return rc; rc = VCursorParamsSet( ( struct VCursorParams const * )self->curs, "QUERY_SEQ_NAME", "%.*s", name_len, name ); if ( rc != 0 ) return rc; rc = VCursorCellDataDirect( self->curs, ref_id[ 0 ], self->name_range_idx, NULL, (void const **)&new_rr, NULL, NULL ); if ( rc != 0 ) return rc; brr = malloc( sizeof( *brr ) ); if ( brr == NULL ) { return RC( rcXF, rcFunction, rcConstructing, rcMemory, rcExhausted ); } else { memcpy( &brr->rr, new_rr, sizeof( *new_rr ) ); BSTreeInsert( ( BSTree* )&self->tr_range, ( BSTNode* )brr, row_range_sort ); } } ref_row_id = brr->rr.start_id; } rc = KDataBufferResize( rslt->data, ploidy ); if ( rc != 0 ) return rc; ref_pos = rslt->data->base; for ( i = 0; i != ploidy; ++i ) { ref_pos[ i ] = ref_start[ i ]; if ( self->curs != NULL ) { ref_pos[ i ] += ( INSDC_coord_zero )( ( ref_id[ 0 ] - ref_row_id ) * self->max_seq_len ); } } rslt->elem_count = ploidy; rslt->elem_bits = sizeof( ref_pos[ 0 ] ) * 8; return rc; }
rc_t extract_statistic_from_row(statistic *self, row_input const *data) { rc_t rc = 0; spotgrp *sg; char const *spotgrp_base; uint32_t spotgrp_len; unsigned i; uint8_t lb = 4; unsigned hpr = 0; unsigned gcc = 0; if (data == NULL) { return RC(rcXF, rcFunction, rcExecuting, rcParam, rcNull); } if (self == NULL) { return RC(rcXF, rcFunction, rcExecuting, rcSelf, rcNull); } rc = validate_row_data(self, data); if (rc) return rc; spotgrp_base = data->spotgroup; spotgrp_len = data->spotgroup_len; if (spotgrp_base == NULL || spotgrp_len == 0) { spotgrp_base = ""; spotgrp_len = 0; } sg = find_spotgroup( self, spotgrp_base, spotgrp_len ); if ( sg == NULL ) { sg = make_spotgrp( spotgrp_base, spotgrp_len ); if ( sg == NULL ) { return RC( rcXF, rcFunction, rcExecuting, rcMemory, rcExhausted ); } else { rc = BSTreeInsert ( &self->spotgroups, (BSTNode *)sg, spotgroup_sort ); if (rc) return rc; } } for (i = 0; i < data->read_len && rc == 0; ++i) { unsigned const base = data->read[i]; unsigned dimer; if (base > 3) { dimer = 16; hpr = 0; } else { dimer = (lb > 3) ? 16 : ((lb << 2) | base); if (lb == base) ++hpr; else hpr = 0; } if (i > 0) rc = spotgroup_enter_values(sg, data->quality[i], dimer, gcc, hpr, data->base_pos_offset + i, CASE_MATCH); if (base == 1 || base == 2) ++gcc; if (i >= self->gc_window) { unsigned const out = data->read[i - self->gc_window]; if (out == 1 || out == 2) --gcc; } lb = base; } return rc; }