Sequence* free_Alignment ( Alignment *LA)
	{
	  /* Does not free the A->S field (sequences of A)*/

	  Sequence *S;
	  //aln_stack checks the alignment has not already been freed
	  if ( LA==NULL || !aln_stack(LA,FREE_ALN)){return NULL;}

	  S=LA->S;
	  free_char ( LA->file, -1);
	  free_char ( LA->seq_al, -1);
	  free_int  ( LA->seq_cache, -1);
	  free_int  ( LA->cdna_cache, -1);
	  free_char ( LA->name,-1);

	  free_char ( LA->tree_order,-1);
	  vfree ( LA->generic_comment);
	  free_char ( LA->seq_comment, -1);
	  free_char ( LA->aln_comment, -1);

	  free_int  ( LA->order, -1);

	  vfree ( LA->score_seq);
	  vfree ( LA->len);

	  free_profile (LA->P);
	  if ( LA->A){free_Alignment (LA->A);LA->A=NULL;}


	  vfree ( LA);
	  return S;
	}
Example #2
0
static int unload_module(void) {
	unsigned int i = 0;

	LNOTICE("unloaded module %s", module_name);

	for (i = 0; i < profile_size; i++) {

		close_socket(i);
		free_profile(i);
	}
	
	                 
#if UV_VERSION_MAJOR == 0
	uv_async_send(&async_handle);
	uv_loop_delete(loop);
#else

	if (uv_loop_alive(loop)) {
        	uv_async_send(&async_handle);
	}
   
	uv_stop(loop);
	uv_loop_close(loop);
	free(loop);
#endif
	/* Close socket */
	return 0;
}
Example #3
0
static int unload_module(void) {
	unsigned int i = 0;

	LNOTICE("unloaded module %s", module_name);

	for (i = 0; i < profile_size; i++) {

		if(sniffer_proto[i]) {
  		    pcap_breakloop(sniffer_proto[i]);
  		    pthread_join(call_thread[i],NULL);
		}

		if (reasm[i] != NULL) {
                	reasm_ip_free(reasm[i]);  
                        reasm[i] = NULL;
                }

                if (tcpreasm[i] != NULL) {
                        tcpreasm_ip_free(tcpreasm[i]);
                        tcpreasm[i] = NULL;
                }


		free_profile(i);
	}
	/* Close socket */
	//pcap_close(sniffer_proto);
	return 0;
}
Example #4
0
File: 1.c Project: akydd/practicalc
int main(void)
{
	/* here are some profile records */
	profile_list[0] = create_profile("Mrs", "Kydd", "1428-330 Fake Street",
			"Unit 1428", "Edmonton", "Alberta", "A1B2C3");
	profile_list[1] = create_profile("Mr", "Kydd", "94 Fake Street",
			"Unit 505", "Edmonton", "Alberta", "A1B2C3");
	profile_list[2] = create_profile("Mr", "Kydd", "43 Fake Street",
			"Unit 227", "Sherwood Park", "Alberta", "D4E5F6");
	profile_list[3] = create_profile("Leeroy", "Jenkins",
			"1943 Fake Avenue", "Apt 123", "Sherwood Park",
			"Alberta", "D4E5F6");

	/* sort the profiles */
	(void)qsort(&profile_list, MAX_RECORDS, sizeof(struct profile *),
			profilecmp);
	
	/* print them out! */
	int i = 0;
	for(i = 0; i < MAX_RECORDS; i++) {
		(void)print_profile(profile_list[i]);
	}

	/* free memory */
	for(i = 0; i < MAX_RECORDS; i++) {
		(void)free_profile(profile_list[i]);
	}
	
	return 0;
}
static void profile_rwunlock(dir_profile_t *profile)
{
	switch_thread_rwlock_unlock(profile->rwlock);
	if (switch_test_flag(profile, PFLAG_DESTROY)) {
		if (switch_thread_rwlock_tryrdlock(profile->rwlock) == SWITCH_STATUS_SUCCESS) {
			free_profile(profile);
		}
	}
}
Example #6
0
static int unload_module(void)
{
  unsigned int i = 0;

  LNOTICE("unloaded module %s", module_name);

  for (i = 0; i < profile_size; i++)
    free_profile(i);

  return 0;
}
Example #7
0
static int unload_module(void)
{
	unsigned int i = 0;

	LNOTICE("unloaded module transport_json");

	for (i = 0; i < profile_size; i++) {

			free_profile(i);
	}

    return 0;
}
Example #8
0
static int unload_module(void)
{

	LNOTICE("Unloaded %s", module_name);

	unsigned int i = 0;

	for (i = 0; i < profile_size; i++) {

		free_profile(i);
	}

    return 0;
}
Example #9
0
static int unload_module(void)
{

	LNOTICE("unloaded module protocol_sip");

	unsigned int i = 0;

	for (i = 0; i < profile_size; i++) {

		free_profile(i);
	}

	 /* Close socket */
       //pcap_close(sniffer_proto);

    return 0;
}
Example #10
0
int main(int argc, char *argv[])

{
  float     *T[MAXSEQ];
  int        i,j, istty, n=0;
  int        type, length, taxa_list=0;
  float      dist;
  FILE      *somewhere=NULL;
  char      *structure;
  char      *line=NULL, fname[FILENAME_MAX_LENGTH], *list_title=NULL;
  plist     *pr_pl, *mfe_pl;

  pr_pl = mfe_pl = NULL;

  command_line(argc, argv);

  if((outfile[0]=='\0')&&(task=='m')&&(edit_backtrack))
    strcpy(outfile,"backtrack.file");
  if (outfile[0]!='\0') somewhere = fopen(outfile,"w");
  if (somewhere==NULL) somewhere = stdout;
  istty   = (isatty(fileno(stdout))&&isatty(fileno(stdin)));

  while (1) {
    if ((istty)&&(n==0)) {
      printf("\nInput sequence;  @ to quit\n");
      printf("%s\n", ruler);
    }

    type = 0;
    do {  /* get sequence to fold */
      if (line!=NULL) free(line);
      *fname='\0';
      if ((line=get_line(stdin))==NULL) {type = 999; break;}
      if (line[0]=='@') type = 999;
      if (line[0]=='*') {
        if (taxa_list==0) {
          if (task=='m') taxa_list=1;
          printf("%s\n", line);
          type = 0;
        } else {
          list_title = strdup(line);
          type = 888;
        }
      }
      if (line[0]=='>') {
        if (sscanf(line,">%" XSTR(FILENAME_ID_LENGTH) "s", fname)!=0)
          strcat(fname, "_dp.ps");
        if (taxa_list)
          printf("%d : %s\n", n+1, line+1);
        else printf("%s\n",line);
        type = 0;
      }
      if (isalpha(line[0]))  {
        char *cp;
        cp =strchr(line,' ');
        if (cp) *cp='\0';
        type = 1;
      }
    } while(type==0);

    if( (task == 'm')&&(type>800) ) {
      if (taxa_list)
        printf("* END of taxa list\n");
      printf("> p %d (pdist)\n",n);
      for (i=1; i<n; i++) {
        for (j=0; j<i; j++) {
          printf("%g ",profile_edit_distance(T[i], T[j]));
          if(edit_backtrack) fprintf(somewhere,"> %d %d\n",i+1,j+1);
          print_aligned_lines(somewhere);
        }
        printf("\n");
      }
      if (type==888) {  /* do another distance matrix */
        n = 0;
        printf("%s\n", list_title);
        free(list_title);
      }
    }

    if(type>800) {
      for (i=0; i<n; i++)
        free_profile(T[i]);
      if (type == 888) continue;
      if (outfile[0]!='\0') (void) fclose(somewhere);
      if (line!= NULL) free(line);
      return 0; /* finito */
    }

    length = (int) strlen(line);
    for (i=0; i<length; i++) {
      line[i]=toupper(line[i]);
      if (!noconv && line[i] == 'T') line[i] = 'U';
    }

    /* init_pf_fold(length); <- obsolete */
    structure = (char *) space((length+1)*sizeof(char));
    (void) pf_fold(line,structure);

    if (*fname=='\0')
      sprintf(fname, "%d_dp.ps", n+1);

    /* PS_dot_plot(line, fname); <- NOT THREADSAFE and obsolete function! */

    /* get pairlist of probability matrix */
    assign_plist_from_pr(&pr_pl, pr, length, 1e-5);
    /* no previous mfe call thus no mfe structure information known */
    mfe_pl = (plist *)space(sizeof(plist));
    mfe_pl[0].i = mfe_pl[0].j = 0;

    /* call threadsafe dot plot printing function */
    PS_dot_plot_list(line, fname, pr_pl, mfe_pl, "");

    T[n] = Make_bp_profile_bppm(pr, length);
    if((istty)&&(task=='m')) printf("%s\n",structure);
    free(structure);
    free(mfe_pl);
    free(pr_pl);
    free_pf_arrays();

    n++;
    switch (task) {
    case 'p' :
      if (n==2) {
        dist = profile_edit_distance(T[0],T[1]);
        printf("%g\n",dist);
        print_aligned_lines(somewhere);
        free_profile(T[0]);
        free_profile(T[1]);
        n=0;
      }
      break;
    case 'f' :
      if (n>1) {
        dist = profile_edit_distance(T[1], T[0]);
        printf("%g\n",dist);
        print_aligned_lines(somewhere);
        free_profile(T[1]);
        n=1;
      }
      break;
    case 'c' :
      if (n>1) {
        dist = profile_edit_distance(T[1], T[0]);
        printf("%g\n",dist);
        print_aligned_lines(somewhere);
        free_profile(T[0]);
        T[0] = T[1];
        n=1;
      }
      break;

    case 'm' :
      break;

    default :
      nrerror("This can't happen.");
    }    /* END switch task */
    (void) fflush(stdout);
  }    /* END while */
  if (line !=NULL) free(line);
  return 0;
}
Example #11
0
void main()
{
   char *seq1="CGCAGGGAUACCCGCG", *seq2="GCGCCCAUAGGGACGC",
        *struct1,* struct2,* xstruc;
   float e1, e2, tree_dist, string_dist, profile_dist, kT;
   Tree *T1, *T2;
   swString *S1, *S2;
   float *pf1, *pf2;
   FLT_OR_DBL *bppm;
   /* fold at 30C instead of the default 37C */
   temperature = 30.;      /* must be set *before* initializing  */

   /* allocate memory for structure and fold */
   struct1 = (char* ) space(sizeof(char)*(strlen(seq1)+1));
   e1 =  fold(seq1, struct1);

   struct2 = (char* ) space(sizeof(char)*(strlen(seq2)+1));
   e2 =  fold(seq2, struct2);

   free_arrays();     /* free arrays used in fold() */

   /* produce tree and string representations for comparison */
   xstruc = expand_Full(struct1);
   T1 = make_tree(xstruc);
   S1 = Make_swString(xstruc);
   free(xstruc);

   xstruc = expand_Full(struct2);
   T2 = make_tree(xstruc);
   S2 = Make_swString(xstruc);
   free(xstruc);

   /* calculate tree edit distance and aligned structures with gaps */
   edit_backtrack = 1;
   tree_dist = tree_edit_distance(T1, T2);
   free_tree(T1); free_tree(T2);
   unexpand_aligned_F(aligned_line);
   printf("%s\n%s  %3.2f\n", aligned_line[0], aligned_line[1], tree_dist);

   /* same thing using string edit (alignment) distance */
   string_dist = string_edit_distance(S1, S2);
   free(S1); free(S2);
   printf("%s  mfe=%5.2f\n%s  mfe=%5.2f  dist=%3.2f\n",
          aligned_line[0], e1, aligned_line[1], e2, string_dist);

   /* for longer sequences one should also set a scaling factor for
      partition function folding, e.g: */
   kT = (temperature+273.15)*1.98717/1000.;  /* kT in kcal/mol */
   pf_scale = exp(-e1/kT/strlen(seq1));

   /* calculate partition function and base pair probabilities */
   e1 = pf_fold(seq1, struct1);
   /* get the base pair probability matrix for the previous run of pf_fold() */
   bppm = export_bppm();
   pf1 = Make_bp_profile_bppm(bppm, strlen(seq1));

   e2 = pf_fold(seq2, struct2);
   /* get the base pair probability matrix for the previous run of pf_fold() */
   bppm = export_bppm();
   pf2 = Make_bp_profile_bppm(bppm, strlen(seq2));

   free_pf_arrays();  /* free space allocated for pf_fold() */

   profile_dist = profile_edit_distance(pf1, pf2);
   printf("%s  free energy=%5.2f\n%s  free energy=%5.2f  dist=%3.2f\n",
          aligned_line[0], e1, aligned_line[1], e2, profile_dist);

   free_profile(pf1); free_profile(pf2);
}