⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dnapars.c

📁 一个神经网络工具箱
💻 C
📖 第 1 页 / 共 4 页
字号:
#include "phylip.h"#include "seq.h"/* version 3.6 (c) Copyright 1993-2000 by the University of Washington.   Written by Joseph Felsenstein, Akiko Fuseki, Sean Lamont, and Andrew Keeffe.   Permission is granted to copy and use this program provided no fee is   charged for it and provided that this copyright notice is not removed. */#define MAXNUMTREES     1000000  /* bigger than number of user trees can be */extern sequence y;#ifndef OLDC/* function prototypes */void usage(void);void   getoptions(void);void   allocrest(void);void   reallocchars(void);void   doinit(void);void   makeweights(void);void   doinput(void);void   initdnaparsnode(node **, node **, node *, long, long, long *,        long *, initops, pointarray, pointarray, Char *, Char *, FILE *);void   evaluate(node *);void   tryadd(node *, node *, node *);void   addpreorder(node *, node *, node *);void   trydescendants(node *, node *, node *, node *, boolean);void   trylocal(node *, node *);void   trylocal2(node *, node *, node *);void   tryrearr(node *, boolean *);void   repreorder(node *, boolean *);void   rearrange(node **);void   describe(void);void   dnapars_coordinates(node *, double, long *, double *);void   dnapars_printree(void);void   globrearrange(void);void   grandrearr(void);void   maketree(void);void   freerest(void);void   load_tree(long treei);/* function prototypes */#endifChar infilename[100], outfilename[100], intreename[100], outtreename[100],     weightfilename[100];char basechar[32]="ACMGRSVTWYHKDBNO???????????????";node *root;long chars, col, msets, ith, njumble, jumb, maxtrees;/*   chars = number of sites in actual sequences */long inseed, inseed0;double threshold;boolean jumble, usertree, thresh, weights, thorough, rearrfirst,          trout, progress, stepbox, ancseq, mulsets, justwts, firstset, mulf,          multf;steptr oldweight;longer seed;pointarray treenode;            /* pointers to all nodes in tree */long *enterorder;long *zeros;/* local variables for Pascal maketree, propagated globally for C version: */long minwhich;double like, minsteps, bestyet, bestlike, bstlike2;boolean lastrearr, recompute;double nsteps[maxuser];long **fsteps;node *there, *oldnufork;long *place;bestelm *bestrees;long *threshwt;baseptr nothing;gbases *garbage;node *temp, *temp1, *temp2, *tempsum, *temprm, *tempadd, *tempf, *tmp, *tmp1,       *tmp2, *tmp3, *tmprm, *tmpadd;boolean *names;node *grbg;char *progname;void getoptions(){  /* interactively set options */  long loopcount, loopcount2;  Char ch, ch2;  fprintf(outfile, "\nDNA parsimony algorithm, version %s\n\n",VERSION);  jumble = false;  njumble = 1;  outgrno = 1;  outgropt = false;  thresh = false;  thorough = true;  transvp = false;  rearrfirst = false;  maxtrees = 100;  trout = true;  usertree = false;  weights = false;  mulsets = false;  printdata = false;  progress = true;  treeprint = true;  stepbox = false;  ancseq = false;  dotdiff = true;  interleaved = false;  loopcount = 0;/*  for (;;) {    cleerhome();    printf("\nDNA parsimony algorithm, version %s\n\n",VERSION);    printf("Setting for this run:\n");    printf("  U                 Search for best tree?  %s\n",           (usertree ? "No, use user trees in input file" : "Yes"));    if (!usertree) {      printf("  S                        Search option?  ");      if (thorough)        printf("More thorough search\n");      else if (rearrfirst)        printf("Rearrange on one best tree\n");      else        printf("Less thorough\n");      printf("  V              Number of trees to save?  %ld\n", maxtrees);      printf("  J   Randomize input order of sequences?");      if (jumble)        printf("  Yes (seed =%8ld,%3ld times)\n", inseed0, njumble);      else        printf("  No. Use input order\n");    }    printf("  O                        Outgroup root?");    if (outgropt)      printf("  Yes, at sequence number%3ld\n", outgrno);    else      printf("  No, use as outgroup species%3ld\n", outgrno);    printf("  T              Use Threshold parsimony?");    if (thresh)      printf("  Yes, count steps up to%4.1f per site\n", threshold);    else      printf("  No, use ordinary parsimony\n");    printf("  N           Use Transversion parsimony?");    if (transvp)      printf("  Yes, count only transversions\n");    else      printf("  No, count all steps\n");    printf("  W                       Sites weighted?  %s\n",           (weights ? "Yes" : "No"));    printf("  M           Analyze multiple data sets?");    if (mulsets)      printf("  Yes, %2ld %s\n", msets,               (justwts ? "sets of weights" : "data sets"));    else      printf("  No\n");    printf("  I          Input sequences interleaved?  %s\n",           (interleaved ? "Yes" : "No, sequential"));    printf("  0   Terminal type (IBM PC, ANSI, none)?  %s\n",           ibmpc ? "IBM PC" : ansi  ? "ANSI"  : "(none)");    printf("  1    Print out the data at start of run  %s\n",           (printdata ? "Yes" : "No"));    printf("  2  Print indications of progress of run  %s\n",           progress ? "Yes" : "No");    printf("  3                        Print out tree  %s\n",           treeprint ? "Yes" : "No");    printf("  4          Print out steps in each site  %s\n",           stepbox ? "Yes" : "No");    printf("  5  Print sequences at all nodes of tree  %s\n",           ancseq ? "Yes" : "No");    if (ancseq || printdata)      printf("  .  Use dot-differencing to display them  %s\n",           dotdiff ? "Yes" : "No");    printf("  6       Write out trees onto tree file?  %s\n",           trout ? "Yes" : "No");    printf("\n  Y to accept these or type the letter for one to change\n");#ifdef WIN32    phyFillScreenColor();#endif    scanf("%c%*[^\n]", &ch);    getchar();    if (ch == '\n')      ch = ' ';    uppercase(&ch);    if (ch == 'Y')      break;    if (strchr("WSVJOTNUMI12345.60",ch) != NULL){      switch (ch) {              case 'J':        jumble = !jumble;        if (jumble)          initjumble(&inseed, &inseed0, seed, &njumble);        else njumble = 1;        break;              case 'O':        outgropt = !outgropt;        if (outgropt)          initoutgroup(&outgrno, spp);        break;              case 'T':        thresh = !thresh;        if (thresh)          initthreshold(&threshold);        break;              case 'N':        transvp = !transvp;        break;              case 'W':        weights = !weights;        break;      case 'M':        mulsets = !mulsets;        if (mulsets) {          printf("Multiple data sets or multiple weights?");          loopcount2 = 0;          do {            printf(" (type D or W)\n");#ifdef WIN32            phyFillScreenColor();#endif            scanf("%c%*[^\n]", &ch2);            getchar();            if (ch2 == '\n')              ch2 = ' ';            uppercase(&ch2);            countup(&loopcount2, 10);          } while ((ch2 != 'W') && (ch2 != 'D'));          justwts = (ch2 == 'W');          if (justwts)            justweights(&msets);          else            initdatasets(&msets);          if (!jumble) {            jumble = true;            initjumble(&inseed, &inseed0, seed, &njumble);          }        }        break;              case 'U':        usertree = !usertree;        break;              case 'S':        thorough = !thorough;        if (!thorough)          printf("Rearrange on just one best tree?");          loopcount2 = 0;          do {            printf(" (type Y or N)\n");#ifdef WIN32            phyFillScreenColor();#endif            scanf("%c%*[^\n]", &ch2);            getchar();            if (ch2 == '\n')              ch2 = ' ';            uppercase(&ch2);            countup(&loopcount2, 10);          } while ((ch2 != 'Y') && (ch2 != 'N'));          rearrfirst = (ch2 == 'Y');        break;      case 'V':        loopcount2 = 0;        do {          printf("type the number of trees to save\n");#ifdef WIN32          phyFillScreenColor();#endif          scanf("%ld%*[^\n]", &maxtrees);          if (maxtrees > MAXNUMTREES)            maxtrees = MAXNUMTREES;                  getchar();          countup(&loopcount2, 10);        } while (maxtrees < 1);        break;      case 'I':        interleaved = !interleaved;        break;              case '0':        initterminal(&ibmpc, &ansi);        break;              case '1':        printdata = !printdata;        break;              case '2':        progress = !progress;        break;              case '3':        treeprint = !treeprint;        break;              case '4':        stepbox = !stepbox;        break;              case '5':        ancseq = !ancseq;        break;              case '.':        dotdiff = !dotdiff;        break;              case '6':        trout = !trout;        break;      }    } else      printf("Not a possible option!\n");    countup(&loopcount, 100);  }  */  if (transvp)    fprintf(outfile, "Transversion parsimony\n\n");}  /* getoptions */void allocrest(){  long i;  y = (Char **)Malloc(spp*sizeof(Char *));  for (i = 0; i < spp; i++)    y[i] = (Char *)Malloc(chars*sizeof(Char));  bestrees = (bestelm *)Malloc(maxtrees*sizeof(bestelm));  for (i = 1; i <= maxtrees; i++)    bestrees[i - 1].btree = (long *)Malloc(nonodes*sizeof(long));  nayme = (naym *)Malloc(spp*sizeof(naym));  enterorder = (long *)Malloc(spp*sizeof(long));  place = (long *)Malloc(nonodes*sizeof(long));  weight = (long *)Malloc(chars*sizeof(long));  oldweight = (long *)Malloc(chars*sizeof(long));  alias = (long *)Malloc(chars*sizeof(long));  ally = (long *)Malloc(chars*sizeof(long));  location = (long *)Malloc(chars*sizeof(long));}  /* allocrest */void doinit(){  /* initializes variables */  inputnumbers(&spp, &chars, &nonodes, 1);  getoptions();  if (printdata)    fprintf(outfile, "%2ld species, %3ld  sites\n\n", spp, chars);  alloctree(&treenode, nonodes, usertree);}  /* doinit */void makeweights(){  /* make up weights vector to avoid duplicate computations */  long i;  for (i = 1; i <= chars; i++) {    alias[i - 1] = i;    oldweight[i - 1] = weight[i - 1];    ally[i - 1] = i;  }  sitesort(chars, weight);  sitecombine(chars);  sitescrunch(chars);  endsite = 0;  for (i = 1; i <= chars; i++) {    if (ally[i - 1] == i)      endsite++;  }  for (i = 1; i <= endsite; i++)    location[alias[i - 1] - 1] = i;  if (!thresh)    threshold = spp;  threshwt = (long *)Malloc(endsite*sizeof(long));  for (i = 0; i < endsite; i++) {    weight[i] *= 10;    threshwt[i] = (long)(threshold * weight[i] + 0.5);  }  zeros = (long *)Malloc(endsite*sizeof(long));  for (i = 0; i < endsite; i++)    zeros[i] = 0;}  /* makeweights */void doinput(){  /* reads the input data */  long i;  if (justwts) {    if (firstset)      inputdata(chars);    for (i = 0; i < chars; i++)      weight[i] = 1;    inputweights(chars, weight, &weights);    if (justwts) {      fprintf(outfile, "\n\nWeights set # %ld:\n\n", ith);      if (progress)        printf("\nWeights set # %ld:\n\n", ith);    }    if (printdata)      printweights(outfile, 0, chars, weight, "Sites");  } else {    if (!firstset){      samenumsp(&chars, ith);      reallocchars();    }    inputdata(chars);    for (i = 0; i < chars; i++)      weight[i] = 1;    if (weights) {      inputweights(chars, weight, &weights);      if (printdata)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -