int main(void)
{
    Sequence L;
    L = (Sequence)malloc(sizeof(struct seqlist));
    CreatSequence(L);
    PrintSequence(L);
    reverse(L);
    PrintSequence(L);
}
Exemple #2
0
static void LIBCALLBACK GetSeqFeat (AsnExpOptStructPtr aeosp)

{
  BioseqPtr     bsp;
  ExpStructPtr  esp;
  SeqFeatPtr    sfp;

  if (aeosp->dvp->intvalue == START_STRUCT) {
    esp = (ExpStructPtr) aeosp->data;
    sfp = (SeqFeatPtr) aeosp->the_struct;
    if (esp != NULL && esp->fp != NULL && sfp != NULL &&
        sfp->data.choice == esp->feat) {
      bsp = BioseqFind (SeqLocId (sfp->location));
      if (bsp != NULL) {
        PrintSequence (bsp, sfp, esp->fp, esp->is_na);
      }
    }
  }
}
Exemple #3
0
void NormSequence(Input *xlst, int n, int dim){
	int i,j,d;
	fprintf(stderr, "Normalize sequences (0:%f) ... \n", MAXVAL);
	for(d=0;d<dim;d++){
		float min = INF, max=-INF;
		for(i=0;i<n;i++){
			Input *x = &xlst[i];
			/// find min & max values
			for(j=0;j<x->m;j++)
				if(x->O[j][d] > max)
					max = x->O[j][d];
				else if(x->O[j][d] < min)
					min = x->O[j][d];
		}//i
		for(i=0;i<n;i++){
			Input *x = &xlst[i];
			/// normalize -> [0:MAXVAL]
			for(j=0;j<x->m;j++)
				x->O[j][d] = MAXVAL*(x->O[j][d]-min) / (max-min);
		}//i
	}//d
	PrintSequence(stdout, xlst[0].m, dim, xlst[0].O);
}
Exemple #4
0
int main (int argc, char **argv)
{
  HMM  	hmm; 	/* the HMM */
  int  	T = 100; 	/* length of observation sequence */
  int	*O;	/* the observation sequence O[1..T]*/
  int	*q; 	/* the state sequence q[1..T] */
  FILE 	*fp;	/* HMM parameters in this file */
  int	sflg=0, tflg=0, errflg = 0;
  int	seed;	/* random number seed */
  int	c;	
  extern char *optarg;
  extern int optind, opterr, optopt;

  while ((c= getopt(argc, argv, "S:T:")) != EOF)
    switch (c) {
    case 'S':
      /* set random number generator seed */
      if (sflg)
	errflg++;
      else {	
	sflg++;
	sscanf(optarg, "%d", &seed);
      }
      break;
    case 'T':
      /* set sequence length */
      if (tflg)
	errflg++;
      else {	
	tflg++;
	sscanf(optarg, "%d", &T);
      }
      break;
    case '?':
      errflg++;
    }

  if ((argc - optind) != 1) errflg++; /* number or arguments not
					 okay */

  if (errflg || !tflg ) {
    Usage(argv[0]);
    exit(1);
  }


  /* read HMM file */
  fp = fopen(argv[optind],"r");		
  if (fp == NULL) {
    fprintf(stderr, "Error: File %s not found \n", argv[optind]);
    exit (1);
  }
  ReadHMM(fp, &hmm);
  fclose(fp);


  /* length of observation sequence, T */

  O = ivector(1,T); /* alloc space for observation sequence O */
  q = ivector(1,T); /* alloc space for state sequence q */

  if (!sflg) seed = hmmgetseed();

  fprintf(stderr, "RandomSeed: %d\n", seed);
  GenSequenceArray(&hmm, seed, T, O, q);

  PrintSequence(stdout, T, O);
  free_ivector(O, 1, T);
  free_ivector(q, 1, T);
  FreeHMM(&hmm);
}