Exemplo n.º 1
0
void getalleles()
{ /* set up number of alleles at loci */
  long i, j, m;

  if (!firstset)
    samenumsp(&loci, ith);
  if (contchars ) {
    totalleles = loci;
    for (i = 1; i <= loci; i++) {
      locus[i - 1] = i;
      alleles[i - 1] = 1;
    }
    df = loci;
  } else {
    totalleles = 0;
    scan_eoln(infile);
    if (printdata) {
      fprintf(outfile, "\nNumbers of alleles at the loci:\n");
      fprintf(outfile, "------- -- ------- -- --- -----\n\n");
    }
    for (i = 1; i <= loci; i++) {
      if (eoln(infile)) 
        scan_eoln(infile);
      if (fscanf(infile, "%ld", &alleles[i - 1]) != 1) {
        printf("ERROR: Unable to read number of alleles at locus %ld\n", i);
        exxit(-1);
      }
      if (alleles[i - 1] <= 0) {
    printf("ERROR: Bad number of alleles: %ld at locus %ld\n", alleles[i-1], i);
        exxit(-1);
      }
      totalleles += alleles[i - 1];
      if (printdata)
        fprintf(outfile, "%4ld", alleles[i - 1]);
    }
    locus = (long *)Malloc(totalleles*sizeof(long));
    m = 0;
    for (i = 1; i <= loci; i++) {
      for (j = 0; j < alleles[i - 1]; j++)
        locus[m+j] = i;
      m += alleles[i - 1];
    }
    df = totalleles - loci;
  }
  allocview(&curtree, nonodes2, totalleles);
  if (!usertree) {
    allocview(&bestree, nonodes2, totalleles);
    allocview(&priortree, nonodes2, totalleles);
    if (njumble > 1)
      allocview(&bestree2, nonodes2, totalleles);
  }
  for (i = 0; i < spp; i++)
    x[i] = (phenotype3)Malloc(totalleles*sizeof(double));
  pbar = (double *)Malloc(totalleles*sizeof(double));
  if (usertree)
    for (i = 0; i < MAXSHIMOTREES; i++)
      l0gf[i] = (double *)Malloc(totalleles*sizeof(double));
  if (printdata)
    putc('\n', outfile);
}  /* getalleles */
Exemplo n.º 2
0
void inputoptions()
{
  /* read options information */
  long i;

  if (!firstset && !justwts) {
    samenumsp(&sites, ith);
    reallocsites();
  }
  for (i = 0; i < sites; i++) {
    category[i] = 1;
    oldweight[i] = 1;
  }
  if (justwts || weights)
    inputweights(sites, oldweight, &weights);
  if (printdata)
    putc('\n', outfile);
  if (jukes && printdata)
    fprintf(outfile, "  Jukes-Cantor Distance\n");
  if (kimura && printdata)
    fprintf(outfile, "  Kimura 2-parameter Distance\n");
  if (f84 && printdata)
    fprintf(outfile, "  F84 Distance\n");
  if (similarity)
    fprintf(outfile, "  \n  Table of similarity between sequences\n");
  if (firstset && printdata && (kimura || f84))
    fprintf(outfile, "\nTransition/transversion ratio = %10.6f\n", ttratio);
  if (ctgry && categs > 1) {
    inputcategs(0, sites, category, categs, "DnaDist");
    if (printdata)
      printcategs(outfile, sites, category, "Site categories");
  } else if (printdata && (categs > 1)) {
    fprintf(outfile, "\nSite category   Rate of change\n\n");
    for (i = 1; i <= categs; i++)
      fprintf(outfile, "%12ld%13.3f\n", i, rate[i - 1]);
    putc('\n', outfile);
    printcategories();
  }
  if ((jukes || kimura || logdet) && freqsfrom) {
    printf(" WARNING: CANNOT USE EMPIRICAL BASE FREQUENCIES");
    printf(" WITH JUKES-CANTOR, KIMURA, JIN/NEI OR LOGDET DISTANCES\n");
    exxit(-1);
  }
  if (jukes)
    ttratio = 0.5000001;
  if (weights && printdata)
    printweights(outfile, 0, sites, oldweight, "Sites");
}  /* inputoptions */
Exemplo n.º 3
0
void inputoptions()
{
    /* input the information on the options */
    long i;
    if(justwts) {
        if(firstset) {
            scan_eoln(infile);
            if (ancvar) {
                inputancestors(anczero0, ancone0);
            }
            if (mixture) {
                inputmixture(wagner0);
            }
        }
        for (i = 0; i < (chars); i++)
            weight[i] = 1;
        inputweights(chars, weight, &weights);
        for (i = 0; i < (words); i++) {
            if (mixture)
                wagner[i] = wagner0[i];
            else if (allsokal)
                wagner[i] = 0;
            else
                wagner[i] = (1L << (bits + 1)) - (1L << 1);
        }
    }
    else {
        if (!firstset) {
            samenumsp(&chars, ith);
        }
        scan_eoln(infile);
        for (i = 0; i < (chars); i++)
            weight[i] = 1;
        if (ancvar) {
            inputancestors(anczero0, ancone0);
        }
        if (mixture) {
            inputmixture(wagner0);
        }
        if (weights)
            inputweights(chars, weight, &weights);
        for (i = 0; i < (words); i++) {
            if (mixture)
                wagner[i] = wagner0[i];
            else if (allsokal)
                wagner[i] = 0;
            else
                wagner[i] = (1L << (bits + 1)) - (1L << 1);
        }
    }
    for (i = 0; i < (chars); i++) {
        if (!ancvar) {
            anczero[i] = true;
            ancone[i] = (((1L << (i % bits + 1)) & wagner[i / bits]) != 0);
        } else {
            anczero[i] = anczero0[i];
            ancone[i] = ancone0[i];
        }
    }
    noroot = true;
    questions = false;
    for (i = 0; i < (chars); i++) {
        if (weight[i] > 0) {
            noroot = (noroot && ancone[i] && anczero[i] &&
                      ((((1L << (i % bits + 1)) & wagner[i / bits]) != 0)
                       || threshold <= 2.0));
        }
        questions = (questions || (ancone[i] && anczero[i]));
        threshwt[i] = threshold * weight[i];
    }
}  /* inputoptions */