Esempio n. 1
0
/*
 * Creates a new named scaffold.
 *
 * Returns scaffold pointer on success.
 *         NULL on failure
 */
scaffold_t *scaffold_new(GapIO *io, char *name) {
    tg_rec rec;
    scaffold_t *f, init_f;

    if (!io->db->scaffold)
	return NULL;

    memset(&init_f, 0, sizeof(scaffold_t));
    init_f.name = name;

    /* Allocate our contig */
    rec = cache_item_create(io, GT_Scaffold, &init_f);

    /* Initialise it */
    f = (scaffold_t *)cache_search(io, GT_Scaffold, rec);
    f = cache_rw(io, f);

    if (name)
        scaffold_set_name(io, &f, name);
    else
        f->name = NULL;

    /* Add it to the scaffold order too */
    io->scaffold = cache_rw(io, io->scaffold);
    io->db = cache_rw(io, io->db);
    ARR(tg_rec, io->scaffold, io->db->Nscaffolds++) = rec;

    /* Add to the new contigs list */
    if (name)
	add_to_list("new_scaffolds", name);

    return f;
}
Esempio n. 2
0
/*
 * Allocates a new annotation element.
 * Returns rec for success
 *        -1 for failure.
 */
tg_rec anno_ele_new(GapIO *io, tg_rec bin,
		    int obj_type, tg_rec obj_rec, tg_rec anno_rec,
		    int type, char dir, char *comment) {
    tg_rec rec;
    anno_ele_t e;

    e.bin       = bin;
    e.obj_type  = obj_type;
    e.obj_rec   = obj_type == GT_Contig ? 0 : obj_rec;
    e.anno_rec  = anno_rec;
    e.tag_type  = type;
    e.direction = dir;
    e.comment   = comment;
    
    rec = cache_item_create(io, GT_AnnoEle, &e);

    return rec;
}