예제 #1
0
/* RECONSTRUCT GENOME OF AN ISOLATE */
struct pathogen * reconstruct_genome(struct pathogen *in){
	int i;
	struct lineage *line = get_lineage(in);
	struct vec_int ** listSnpVec, *temp, *genome;
	struct pathogen *out = (struct pathogen *) malloc(sizeof(struct pathogen));
	if(out == NULL){
		fprintf(stderr, "\n[in: pathogen.c->reconstruct_genome]\nNo memory left to reconstruct pathogen genome. Exiting.\n");
		exit(1);
	}


	/* get all snps in the lineage */
	listSnpVec = (struct vec_int **) malloc(line->n * sizeof(struct vec_int *));

	for(i=0;i<line->n;i++){
		listSnpVec[i] = get_snps_vec(line->pathogens[i]);
	}

	/* merge snps */
	temp = merge_vec_int(listSnpVec, line->n);

	/* remove reverse mutations */
	genome = keep_odd_int(temp);

	/* create output and fill it in */
	out->age = in->age;
	out->ances = in->ances;
	out->snps = genome;

	/* free temporary allocation & return */
	free_lineage(line);
	free(listSnpVec);
	free_vec_int(temp);
	return out;
}
예제 #2
0
파일: srchaa.c 프로젝트: hsptools/hsp-wrap
static Boolean WhatOrg (Int4 taxid, CharPtr taxon)
{
    OrgRefPtr  orp;
    CharPtr    lineage;
    CharPtr    nodes[] = {"Archaea", "Viruses", "Eukaryotae", "Eubacteria"};
    Int4       i;
    Boolean    flagTaxHit;

    /*
     orp pointers only; mem doesn't have to be free'd
    */
    if ((orp = tax1_getOrgRef (taxid, NULL, NULL, NULL)) != NULL)
    {
        if (orp->taxname != NULL)
        {
            flagTaxHit = FALSE;
            if ((lineage = get_lineage (orp->taxname)) != NULL)
            {
                for (i = 0; i < 4; i++)
                {
                    if (StrStr (lineage, nodes[i]))
                    {
                        switch (i)
                        {
                        case 0:
                            taxon[0] = 'A';
                            flagTaxHit = TRUE;
                            break;
                        case 1:
                            taxon[1] = 'B';
                            taxon[4] = 'V';
                            flagTaxHit = TRUE;
                            break;
                        case 2:
                            taxon[2] = 'E';
                            flagTaxHit = TRUE;
                            break;
                        case 3:
                            taxon[3] = 'P';
                            flagTaxHit = TRUE;
                            break;
                        }
                    }
                }
                MemFree (lineage);
                return flagTaxHit;
            }
        }
    }
    return FALSE;
}