Esempio n. 1
0
Widget_Assembly Dynamic_Server::spawn_anonymous_assembly(
    const std::string& alias_value
    , const std::string& anon_tmpl
    , const int& alias_type)
{
    mApp;
    Parsers::Node_Value_Parser& p = app->get_interpreter();
    std::string resolvable {get_resolvable_string(anon_tmpl)};
    std::string tmpl {get_template_name(anon_tmpl)};
    Widget_Assembly a {};
    Node_Value v {};
    a.node = create_unique_node_name();
    if (alias_type == Mogu_Syntax::user.integer)
    {
        p.set_user_id(atoi(alias_value.c_str()));
    }
    else if (alias_type == Mogu_Syntax::group.integer)
    {
        p.set_group_id(atoi(alias_value.c_str()));
    }
    p.give_input(resolvable, v);
    Attribute_Tuple t {merge_node_attributes("",tmpl)};
    a.children = std::get<0>(t);
    a.trigger_map = std::get<1>(t);
    a.attrdict = std::get<2>(t);
    a.attrdict[Mogu_Syntax::text.integer] = v;
    return a;

}
Esempio n. 2
0
Widget_Assembly Dynamic_Server::spawn_anonymous_assembly
    ( const std::string& data_point
    , const std::string& anon_tmpl
    , const Source_Declaration_Type& type)
{
    mApp;
    Parsers::Node_Value_Parser& p = app->get_interpreter();


    std::string resolvable {get_resolvable_string(anon_tmpl)};
    std::string tmpl {get_template_name(anon_tmpl)};

    Widget_Assembly a {};
    Node_Value v{};
    a.node = create_unique_node_name();

    if (type == Source_Declaration_Type::group_members) 
    {
        p.set_user_id(atoi(data_point.c_str()));
    }
    else if (type == Source_Declaration_Type::user_groups)
    {
        p.set_group_id(atoi(data_point.c_str()));
    }
    else
    {
        if (type==Source_Declaration_Type::user_list)
            p.set_user_id(atoi(data_point.c_str()));
        else if (type==Source_Declaration_Type::group_list)
            p.set_group_id(atoi(data_point.c_str()));
        resolvable = data_point;
    }

    p.give_input(resolvable,v);
    Attribute_Tuple t {merge_node_attributes("",tmpl)};
    a.children = std::get<0>(t);
    a.trigger_map = std::get<1>(t);
    a.attrdict = std::get<2>(t);
    a.attrdict[Mogu_Syntax::text.integer] = v;
    return a;
}
Esempio n. 3
0
/**
 * Builds a snp graph from the snps array
 */
graph *graph_from_snps(GapIO *io, snp_t *snp, int nsnps, double c_offset) {
    graph *g = NULL;
    int i, j;
    int ntemplates, *templates = NULL;
    node **tmpl_map = NULL;
    int lookup[256];

    if (verbosity)
	puts("Building graph");

    /* lookup table for fast base to index conversion */
    for (i = 0; i < 256; i++)
	lookup[i] = 0;
    lookup['A'] = lookup['a'] = 1;
    lookup['C'] = lookup['c'] = 2;
    lookup['G'] = lookup['g'] = 3;
    lookup['T'] = lookup['t'] = 4;
    lookup['*'] = 5;

    g = graph_create();
    g->correlation_offset = c_offset;

    /*
     * Obtain a list of unique template numbers, by collecting and sorting.
     * For each unique template we initialise the graph node.
     *
     * At the end of this we have ntemplates unique templates and
     * tmpl_map[] indexed by Gap4 template number maps us to the
     * node in the graph.
     */
    for (ntemplates = i = 0; i < nsnps; i++) {
	ntemplates += snp[i].nseqs;
    }
    templates = (int *)malloc(ntemplates * sizeof(int));
    for (ntemplates = i = 0; i < nsnps; i++) {
	for (j = 0; j < snp[i].nseqs; j++) {
	    templates[ntemplates++] = snp[i].seqs[j].tmplate;
	}
    }
    tmpl_map = (node **)xcalloc(Ntemplates(io)+1, sizeof(*tmpl_map));
    qsort(templates, ntemplates, sizeof(int), int_compare);
    for (i = j = 0; i < ntemplates; j++) {
	tmpl_map[templates[i]] = graph_add_node(g);
	tmpl_map[templates[i]]->number = j;
	tmpl_map[templates[i]]->tname  =
	    strdup(get_template_name(io, templates[i]));

	do {
	    i++;
	} while (i < ntemplates && templates[i] == templates[i-1]);
    }
    xfree(templates);
    ntemplates = j;

    g->nsnps = nsnps;
    g->ntemplates = ntemplates;


    /*
     * The matrix is of size nsnps by ntemplates. It initially will consist
     * of entirely empty vectors.
     */
    g->matrix = (int (*)[6])malloc(ntemplates * nsnps * sizeof(*g->matrix));
    memset(&g->matrix[0][0], 0, ntemplates * nsnps * 6 * sizeof(int));
    for (i = j = 0; j < ntemplates; i++) {
	if (!tmpl_map[i])
	    continue;

	tmpl_map[i]->matrix = &g->matrix[j * nsnps];
	j++;
    }


    /* Create the snp_score array */
    g->snp_scores = (double *)malloc(nsnps * sizeof(*g->snp_scores));
    for (i = 0; i < nsnps; i++) {
	g->snp_scores[i] = snp[i].score;
    }

    /* Now add basecalls to the matrix from snp info */
    for (i = 0; i < nsnps; i++) {
	for (j = 0; j < snp[i].nseqs; j++) {
	    node *n = tmpl_map[snp[i].seqs[j].tmplate];
	    n->matrix[i][lookup[snp[i].seqs[j].base]]++; 
	    n->tscore = snp[i].seqs[j].tscore; 
	    /* FIXME: confidence not yet used */
	}

	for (j = 0; j < ntemplates; j++) {
	    if (!g->nodes->node[j]->matrix[i][1] &&
		!g->nodes->node[j]->matrix[i][2] &&
		!g->nodes->node[j]->matrix[i][3] &&
		!g->nodes->node[j]->matrix[i][4] &&
		!g->nodes->node[j]->matrix[i][5])
 		g->nodes->node[j]->matrix[i][0]++;
	}
    }

    return g;
}
Esempio n. 4
0
	virtual std::string get_template_full_name() { return get_template_base() + get_template_name(); }