示例#1
0
void addLink(cfuhash_table_t * linkHash,
             BM_linkInfo * LI,
             int cid1,
             int cid2
             ) {
    BM_linkInfo** nextLink_ptr = (BM_linkInfo**) &LI->nextLink;
    // see if the key is in the hash already
    char * key = calloc(30, sizeof(char)); // allocate room for the key
    makeContigKey(key, cid1, cid2);
    BM_linkPair * base_LP = cfuhash_get(linkHash, key);
    if (base_LP != NULL) {
        // exists in the hash -> daisy chain it on
        *nextLink_ptr = base_LP->LI;
        base_LP->LI = LI;
        base_LP->numLinks++;
    }
    else {
        // we'll need to build a bit of infrastructure
        // store the contig ids once only
        BM_linkPair * LP = (BM_linkPair*) calloc(1, sizeof(BM_linkPair));
        if(cid1 < cid2) {
            LP->cid1 = cid1;
            LP->cid2 = cid2;
        }
        else {
            LP->cid1 = cid2;
            LP->cid2 = cid1;
        }
        LP->LI = LI;
        LP->numLinks = 1;
        *nextLink_ptr = LI; // point to self means end of list

        // finally, add the lot to the hash
        cfuhash_put(linkHash, key, LP);
    }
    if (key != 0) {
        free(key);
        key = 0;
    }
}
示例#2
0
void addLink(cfuhash_table_t * linkHash,
             int cid_1,
             int cid_2,
             int pos_1,
             int pos_2,
             int orient_1,
             int orient_2,
             int bam_ID
            )
{
    // store the link info, swap order of cid_1 and cid_2 if needed
    PM_link_info* LI = (PM_link_info*) calloc(1, sizeof(PM_link_info));
    if(cid_1 < cid_2){
        LI->orient_1 = orient_1;
        LI->orient_2 = orient_2;
        LI->pos_1 = pos_1;
        LI->pos_2 = pos_2;
    }
    else
    {
        LI->orient_1 = orient_2;
        LI->orient_2 = orient_1;
        LI->pos_1 = pos_2;
        LI->pos_2 = pos_1;
    }
    LI->bam_ID = bam_ID;

    PM_link_info** next_link_ptr = (PM_link_info**) &LI->next_link;

    // see if the key is in the hash already
    char * key = calloc(30, sizeof(char)); // allocate room for the key
    makeContigKey(key, cid_1, cid_2);
    PM_link_pair * base_LP = cfuhash_get(linkHash, key);
    if (base_LP != NULL)
    {
        // exists in the hash -> daisy chain it on
        *next_link_ptr = base_LP->LI;
        base_LP->LI = LI;
        base_LP->numLinks++;
    }
    else
    {
        // we'll need to build a bit of infrastructure
        // store the contig ids once only
        PM_link_pair * LP = (PM_link_pair*) calloc(1, sizeof(PM_link_pair));
        if(cid_1 < cid_2)
        {
            LP->cid_1 = cid_1;
            LP->cid_2 = cid_2;
        }
        else
        {
            LP->cid_1 = cid_2;
            LP->cid_2 = cid_1;
        }
        LP->LI = LI;
        LP->numLinks = 1;
        *next_link_ptr = LI; // point to self means end of list

        // finally, add the lot to the hash
        cfuhash_put(linkHash, key, LP);
    }
    free(key);
}