Пример #1
0
/* returns head of the list or NULL on failure. */
OS_Keylist Keylist_Create(
    void)
{
    struct Keylist *list;

    list = KeylistCreate();
    if (list)
        CheckArraySize(list);

    return list;
}
Пример #2
0
/* inserts a node into its sorted position */
int Keylist_Data_Add(
    OS_Keylist list,
    KEY key,
    void *data)
{
    struct Keylist_Node *node;  /* holds the new node */
    int index = -1;     /* return value */
    int i;      /* counts through the array */

    if (list && CheckArraySize(list)) {
        /* figure out where to put the new node */
        if (list->count) {
            (void) FindIndex(list, key, &index);
            /* Add to the beginning of the list */
            if (index < 0)
                index = 0;

            /* Add to the end of the list */
            else if (index > list->count)
                index = list->count;

            /* Move all the items up to make room for the new one */
            for (i = list->count; i > index; i--) {
                list->array[i] = list->array[i - 1];
            }
        }

        else {
            index = 0;
        }

        /* create and add the node */
        node = NodeCreate();
        if (node) {
            list->count++;
            node->key = key;
            node->data = data;
            list->array[index] = node;
        }
    }
    return index;
}
Пример #3
0
/* returns the data from the node */
void *Keylist_Data_Delete_By_Index(
    OS_Keylist list,
    int index)
{
    struct Keylist_Node *node;
    void *data = NULL;

    if (list && list->array && list->count && (index >= 0) &&
        (index < list->count)) {
        node = list->array[index];
        if (node)
            data = node->data;

        /* move the nodes to account for the deleted one */
        if (list->count == 1) {

            /* There is no node shifting to do */
        }
        /* We are the last one */
        else if (index == (list->count - 1)) {

            /* There is no node shifting to do */
        }
        /* Move all the nodes down one */
        else {
            int i;      /* counter */
            int count = list->count - 1;
            for (i = index; i < count; i++) {
                list->array[i] = list->array[i + 1];
            }
        }
        list->count--;
        if (node)
            free(node);

        /* potentially reduce the size of the array */
        (void) CheckArraySize(list);
    }
    return (data);
}
Пример #4
0
void RecalibrationModel::InitializeFromJSON(Json::Value &recal_params, string &my_block_key, bool spam_enabled, int over_flow_protect) {
  // this needs to signal when it fails in some way
	verbose_ = spam_enabled;
  
    int flowStart, flowEnd, flowSpan, xMin, xMax, xSpan, yMin, yMax, ySpan, max_hp_calibrated;
    flowStart = rGetParamsInt(recal_params[my_block_key],"flowStart",0);
    //cout << flowStart << endl;
    flowEnd = rGetParamsInt(recal_params[my_block_key],"flowEnd",0);
    if (over_flow_protect>flowEnd)
      flowEnd = over_flow_protect;  // allocate for combined bam files that need to access flows "past the end" without crashing
    //cout << flowEnd << endl;
    flowSpan = rGetParamsInt(recal_params[my_block_key],"flowSpan",0);
    //cout << flowSpan << endl;
    xMin = rGetParamsInt(recal_params[my_block_key],"xMin",0);
    //cout << xMin << endl;
    xMax =rGetParamsInt(recal_params[my_block_key],"xMax",0);
    //cout << xMax << endl;
    xSpan =rGetParamsInt(recal_params[my_block_key],"xSpan",0);
    //cout << xSpan << endl;
    yMin = rGetParamsInt(recal_params[my_block_key],"yMin",0);
    //cout << yMin << endl;
    yMax =rGetParamsInt(recal_params[my_block_key],"yMax",0);
    //cout << yMax << endl;
    ySpan = rGetParamsInt(recal_params[my_block_key],"ySpan",0);
    //cout << ySpan << endl;
    max_hp_calibrated = rGetParamsInt(recal_params[my_block_key],"max_hp_calibrated",0);
    stratification.SetupChipRegions(xMin, xMax, xSpan, yMin, yMax, ySpan);
    stratification.SetupFlowRegions(flowStart,flowEnd, flowSpan);
    //calculate number of partitions and initialize the stratifiedAs and stratifiedBs
    SetupStratification(flowStart,flowEnd, flowSpan,xMin,xMax,xSpan,yMin,yMax,ySpan,max_hp_calibrated);

    // stratification setup done
    // now iterate and obtain each line from the JSON
    int iter_size = recal_params[my_block_key]["modelParameters"].size();
    for (int i_item=0; i_item<iter_size; i_item++) {
        // extract my single line
        //model_file >> flowBase >> flowStart >> flowEnd >> xMin >> xMax >> yMin >> yMax >> refHP >> paramA >> paramB;
        //flowBase is a special extraction
        flowStart = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowStart",0);
        flowEnd = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowEnd",0);
        xMin = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"xMin",0);
        xMax =rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"xMax",0);
        yMin = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"yMin",0);
        yMax =rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"yMax",0);

        int refHP;
        refHP = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"refHP",0);
        float paramA, paramB;
        paramA = rGetParamsDbl(recal_params[my_block_key]["modelParameters"][i_item],"paramA",1.0);
        paramB = rGetParamsDbl(recal_params[my_block_key]["modelParameters"][i_item],"paramB",0.0);

        //string flowBase = recal_params[my_block_key]["modelParameters"][i_item]["flowBase"].asCString();
        char flowBase = (char) rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowBase",0);
        int nucInd = NuctoInt(flowBase);
        
        // all set with the values
        int offsetRegion = stratification.OffsetRegion(xMin,yMin);
        // note we only fill >in< flows fit by the recalibration model
        FillIndexes(offsetRegion,nucInd, refHP, flowStart, flowEnd, paramA, paramB);        
    }
    // if something bad happened above, how do we find out? - We do some basic sanity checks
    CheckArraySize();
    // now we're done!
    if (verbose_)
      cout << "Recalibration: enabled (using recalibration comment " << my_block_key << ") in a "
           << stratification.xCuts << 'x' << stratification.yCuts << 'x' << stratification.flowCuts << " grid." <<endl << endl;
    is_enabled_ = true;
}