11 #include "io_lib_header.h"
12 #include "util_lib_header.h"
13 #include "define_header.h"
14 #include "dp_lib_header.h"
18 //Free static allocated memory
19 free_proba_pair_wise();
22 /************************************************************************/
27 /************************************************************************/
28 int *** duplicate_residue_index (int ***r)
35 d1=read_array_size_new(r);
36 nr=vcalloc ( d1, sizeof (int**));
39 d2=read_array_size_new (r[a])-1;
40 nr[a]=vcalloc ( d2+1, sizeof (int*));
43 d3=read_array_size_new (r[a][b]);
44 for (c=0; c<d3; c++)nr[a][b][c]=r[a][b][c];
49 int *** declare_residue_index (Sequence *S)
55 r=vcalloc ( S->nseq, sizeof (int**));
56 for ( a=0; a<S->nseq; a++)
58 r[a]=vcalloc (S->len[a]+2, sizeof (int*));//The empty terminator makes a scan possible without knowing len
59 for ( b=0; b<=S->len[a]; b++)
61 r[a][b]=vcalloc ( 1, sizeof (int));
68 Constraint_list * declare_constraint_list_simple ( Sequence *S)
70 return declare_constraint_list (S, NULL, NULL, 0, NULL, NULL);
73 Constraint_list * declare_constraint_list ( Sequence *S, char *name, int *L, int ne,FILE *fp, int **M)
77 CL=vcalloc (1, sizeof ( Constraint_list));
85 sprintf ( CL->list_name, "%s", name);
92 HERE ("The USE of L is now Deprecated with Constraint Lists");
96 CL->entry_len=LIST_N_FIELDS;
97 CL->el_size=sizeof (CLIST_TYPE);
98 CL->matrices_list=declare_char(20,20);
102 if ( S)CL->seq_for_quadruplet=vcalloc ( S->nseq, sizeof (int));
103 CL->Prot_Blast=vcalloc ( 1, sizeof ( Blast_param));
104 CL->DNA_Blast=vcalloc ( 1, sizeof ( Blast_param));
105 CL->Pdb_Blast=vcalloc ( 1, sizeof ( Blast_param));
106 CL->TC=vcalloc (1, sizeof (TC_param));
109 CL->residue_index=declare_residue_index (S);
116 Constraint_list *free_constraint_list4lib_computation (Constraint_list *CL)
120 free_arrayN(CL->residue_index, 3);
121 free_int (CL->M, -1);
126 Constraint_list *duplicate_constraint_list4lib_computation (Constraint_list *CL)
128 Constraint_list *SCL;
129 SCL=vcalloc (1, sizeof ( Constraint_list));
132 SCL->RunName=CL->RunName;
140 Constraint_list *duplicate_constraint_list_soft (Constraint_list *CL)
142 /*Duplication that does not copy the long lists*/
143 return copy_constraint_list (CL,SOFT_COPY);
145 Constraint_list *duplicate_constraint_list (Constraint_list *CL)
147 /*Duplicate everything in the constraint_list*/
148 return copy_constraint_list (CL,HARD_COPY);
150 Constraint_list *copy_constraint_list (Constraint_list *CL, int mode)
152 Constraint_list *NCL;
161 S=(mode==HARD_COPY)?duplicate_sequence (CL->S):CL->S;
165 NCL=declare_constraint_list (S, NULL, NULL,0, NULL, NULL);
168 NCL=vcalloc ( 1, sizeof (Constraint_list));
174 if (mode==SOFT_COPY)NCL->pCL=CL;
177 if (mode==HARD_COPY && CL->master)
178 {NCL->master=vcalloc ( S->nseq, sizeof(int));
179 for ( a=0; a< S->nseq; a++)
180 NCL->master[a]=CL->master[a];
182 else if (mode==SOFT_COPY)
184 NCL->seq_for_quadruplet=CL->seq_for_quadruplet;
186 NCL->o2a_byte=CL->o2a_byte;
189 NCL->STRUC_LIST=(mode==HARD_COPY)?duplicate_sequence (CL->STRUC_LIST):CL->STRUC_LIST;
190 sprintf ( NCL->align_pdb_param_file, "%s", CL->align_pdb_param_file);
191 sprintf ( NCL->align_pdb_hasch_mode, "%s", CL->align_pdb_hasch_mode);
194 NCL->W=(mode==HARD_COPY)?duplicate_weights (CL->W):CL->W;
195 NCL->DM=(mode==HARD_COPY)?duplicate_distance_matrix (CL->DM):CL->DM;
196 NCL->ktupDM=(mode==HARD_COPY)?duplicate_distance_matrix (CL->ktupDM):CL->ktupDM;
197 NCL->RunName=CL->RunName;
199 if ( mode==HARD_COPY && CL->translation){NCL->translation=vcalloc ((CL->S)->nseq, sizeof (int)); for ( a=0; a< (CL->S)->nseq; a++)NCL->translation[a]=CL->translation[a];}
200 else{NCL->translation=CL->translation;}
202 NCL->out_aln_format=(mode==HARD_COPY)?duplicate_char (CL->out_aln_format, -1, -1):CL->out_aln_format;
203 NCL->n_out_aln_format=CL->n_out_aln_format;
205 /*Packing Sequence: To use with domain analysis*/
206 NCL->packed_seq_lu=(mode==HARD_COPY)?duplicate_int (CL->packed_seq_lu, -1, -1):CL->packed_seq_lu;
208 if (CL->fp)(mode==HARD_COPY)?NCL->fp=vtmpfile():CL->fp;
210 if ( mode==HARD_COPY)
212 NCL->residue_index=duplicate_residue_index (NCL->residue_index);
214 else NCL->residue_index=CL->residue_index;
217 if ( mode==HARD_COPY)
219 NCL->M=copy_int ( CL->M,NCL->M,-1, -1);
227 sprintf ( NCL->list_name, "%s", CL->list_name);
228 NCL->entry_len=CL->entry_len;
229 NCL->el_size=CL->el_size;
231 /*Normalisation information*/
232 NCL->filter_lib=CL->filter_lib;
233 NCL->normalise=CL->normalise;
234 NCL->overweight=CL->overweight;
235 NCL->max_ext_value=CL->max_ext_value;
236 NCL->max_value=CL->max_value;
238 /*Pair wise alignment method*/
239 NCL->pw_parameters_set=CL->pw_parameters_set;
241 NCL->f_gop=CL->f_gop;
243 NCL->f_gep=CL->f_gep;
245 NCL->nomatch=CL->nomatch;
247 NCL->TG_MODE=CL->TG_MODE;
248 NCL->F_TG_MODE=CL->F_TG_MODE;
250 sprintf ( NCL->dp_mode, "%s", CL->dp_mode);
251 NCL->maximise=CL->maximise;
252 sprintf ( NCL->matrix_for_aa_group, "%s", CL->matrix_for_aa_group);
253 sprintf ( NCL->method_matrix, "%s", CL->method_matrix);
255 NCL->diagonal_threshold=CL->diagonal_threshold;
258 NCL->use_fragments=CL->use_fragments;
259 NCL->fasta_step=CL->fasta_step;
260 NCL->lalign_n_top=CL->lalign_n_top;
261 NCL->sw_min_dist=CL->sw_min_dist;
262 NCL->matrices_list=(mode==HARD_COPY)?duplicate_char (CL->matrices_list, -1, -1):CL->matrices_list;
263 NCL->n_matrices=CL->n_matrices;
265 sprintf (NCL->distance_matrix_mode, "%s", CL->distance_matrix_mode);
266 sprintf (NCL->distance_matrix_sim_mode, "%s", CL->distance_matrix_sim_mode);
268 sprintf (NCL->tree_mode, "%s", CL->tree_mode);
269 NCL->tree_aln=(mode==HARD_COPY)?copy_aln (CL->tree_aln, NULL):CL->tree_aln;
270 /*Functions used for dynamic programming and Evaluation*/
271 NCL->no_overaln=CL->no_overaln;
272 NCL->profile_mode=CL->profile_mode;
273 sprintf ( NCL->profile_comparison, "%s",CL->profile_comparison);
274 NCL->get_dp_cost=CL->get_dp_cost;
275 NCL->evaluate_residue_pair=CL->evaluate_residue_pair;
276 NCL->pair_wise=CL->pair_wise;
278 NCL->weight_field=CL->weight_field;
279 NCL->max_n_pair=CL->max_n_pair;
281 /*threading parameters*/
282 NCL->Prot_Blast=(mode==HARD_COPY)?duplicate_blast_param ( CL->Prot_Blast):CL->Prot_Blast;
283 NCL->DNA_Blast =(mode==HARD_COPY)?duplicate_blast_param ( CL->DNA_Blast):CL->DNA_Blast;
284 NCL->Pdb_Blast =(mode==HARD_COPY)?duplicate_blast_param ( CL->Pdb_Blast):CL->Pdb_Blast;
285 NCL->TC =(mode==HARD_COPY)?duplicate_TC_param ( CL->TC):CL->TC;
288 NCL->split=CL->split;
289 NCL->split_nseq_thres= CL->split_nseq_thres;
290 NCL->split_score_thres= CL->split_score_thres;
291 /*Structural status*/
292 NCL->check_pdb_status=CL->check_pdb_status;
294 sprintf ( NCL->method_log, "%s",CL->method_log);
295 sprintf ( NCL->evaluate_mode, "%s",CL->evaluate_mode);
297 sprintf ( NCL->genepred_score, "%s",CL->genepred_score);
299 /*Parameters for domain extraction*/
300 NCL->moca=(mode==HARD_COPY)?duplicate_moca ( CL->moca):CL->moca;
304 /*Functions for hiding forbiden pairs of residues*/
305 /* Copy only for soft_copy*/
308 NCL->forbiden_pair_list=CL->forbiden_pair_list;
310 /*extention properties:*/
311 NCL->nseq_for_quadruplet=CL->nseq_for_quadruplet;
312 if (mode==HARD_COPY && CL->seq_for_quadruplet)
313 {NCL->seq_for_quadruplet=vcalloc ( S->nseq, sizeof(int));
314 for ( a=0; a< S->nseq; a++)
315 NCL->seq_for_quadruplet[a]=CL->seq_for_quadruplet[a];
317 else if (mode==SOFT_COPY)
319 NCL->seq_for_quadruplet=CL->seq_for_quadruplet;
322 /*extention properties: Do only a soft copy*/
323 /* Not To be copied yet */
324 if ( mode==SOFT_COPY)
326 NCL->extend_jit=CL->extend_jit;
327 NCL->extend_threshold=CL->extend_threshold;
328 sprintf ( NCL->extend_clean_mode, "%s", CL->extend_clean_mode);
329 sprintf ( NCL->extend_compact_mode, "%s", CL->extend_compact_mode);
332 /*Lookup table parameteres*/
333 NCL->chunk= CL->chunk;
334 /* Do NOT copy NCL->seq_indexed, NCL->start_index, NCL->max_L_len, NCL->chunk*/
336 if ( mode==SOFT_COPY)
338 NCL->seq_indexed=CL->seq_indexed;
339 NCL->start_index=CL->start_index;
340 NCL->end_index=CL->start_index;
341 NCL->max_L_len=CL->max_L_len;
344 /*PDB STRUCTURE ALIGNMENTS*/
345 /* Do only a soft copy */
346 if ( mode==SOFT_COPY)
352 NCL->local_stderr=CL->local_stderr;
353 sprintf (NCL->multi_thread, "%s", CL->multi_thread);
357 Constraint_list *free_constraint_list_full (Constraint_list *CL)
359 free_sequence (free_constraint_list (CL), -1);
362 Sequence *free_constraint_list (Constraint_list *CL)
366 Constraint_list *pCL;
369 /*Prepare the selective freeing of the CL data structure:
370 If the CL has been obtained from copy, every pointer that is identical to the parent CL (CL->pCL)
375 if ( !CL)return NULL;
378 if ( CL->copy_mode==SOFT_COPY && !CL->pCL)
379 {vfree(CL); return S;}
380 else if ( CL->copy_mode==SOFT_COPY)
384 CL->residue_index=NULL;
386 if ( CL->M ==pCL->M )CL->M=NULL;
388 if (CL->start_index ==pCL->start_index )CL->start_index=NULL;
389 if (CL->end_index ==pCL->end_index )CL->end_index=NULL;
391 if ( CL->fp ==pCL->fp )CL->fp=NULL;
392 if ( CL->matrices_list ==pCL->matrices_list )CL->matrices_list=NULL;
395 if ( CL->STRUC_LIST ==pCL->STRUC_LIST )CL->STRUC_LIST=NULL;
396 if ( CL->W ==pCL->W )CL->W=NULL;
397 if ( CL->DM ==pCL->DM )CL->DM=NULL;
398 if ( CL->ktupDM ==pCL->ktupDM )CL->ktupDM=NULL;
401 if ( CL->translation ==pCL->translation )CL->translation=NULL;
402 if ( CL->moca ==pCL->moca )CL->moca=NULL;
403 if ( CL->Prot_Blast ==pCL->Prot_Blast )CL->Prot_Blast=NULL;
404 if ( CL->DNA_Blast ==pCL->DNA_Blast )CL->DNA_Blast=NULL;
405 if ( CL->Pdb_Blast ==pCL->Pdb_Blast )CL->Pdb_Blast=NULL;
406 if ( CL->seq_for_quadruplet ==pCL->seq_for_quadruplet )CL->seq_for_quadruplet=NULL;
407 if ( CL->TC ==pCL->TC )CL->TC=NULL;
412 /*End of selective freeing of the CL data structure*/
416 if ( CL->residue_index)free_arrayN(CL->residue_index, 3);
418 if ( CL->M)free_int (CL->M, -1);
419 if ( CL->fp)vfclose (CL->fp);
420 if ( CL->matrices_list)free_char(CL->matrices_list,-1);
423 if ( CL->start_index)free_int ( CL->start_index,-1);
424 if ( CL->end_index)free_int ( CL->end_index,-1);
429 if ( CL->STRUC_LIST)free_sequence ( CL->STRUC_LIST, (CL->STRUC_LIST)->nseq);
430 if ( CL->W)free_weights (CL->W);
432 CL->DM=free_distance_matrix (CL->DM);
433 CL->ktupDM=free_distance_matrix (CL->ktupDM);
435 if ( CL->translation)vfree(CL->translation);
436 if ( CL->moca)free_moca (CL->moca);
437 if ( CL->Prot_Blast)free_blast_param ( CL->Prot_Blast);
438 if ( CL->DNA_Blast) free_blast_param ( CL->DNA_Blast);
439 if ( CL->Pdb_Blast) free_blast_param ( CL->Pdb_Blast);
440 if ( CL->TC) free_TC_param ( CL->TC);
442 if (CL->seq_for_quadruplet)vfree (CL->seq_for_quadruplet);
448 Distance_matrix * free_distance_matrix ( Distance_matrix *DM)
451 free_int ( DM->similarity_matrix,-1);
452 free_int ( DM->distance_matrix,-1);
453 free_int ( DM->score_similarity_matrix,-1);
457 Distance_matrix * duplicate_distance_matrix ( Distance_matrix *DMin)
460 if (!DMin) return NULL;
462 DM=vcalloc ( 1, sizeof (Distance_matrix));
463 DM->similarity_matrix=duplicate_int ( DMin->similarity_matrix, -1, -1);
464 DM->distance_matrix=duplicate_int ( DMin->distance_matrix, -1, -1);
465 DM->score_similarity_matrix=duplicate_int ( DMin->score_similarity_matrix, -1, -1);
469 /************************************************************************/
474 /************************************************************************/
475 Moca * duplicate_moca ( Moca *m)
479 if ( m==NULL)return m;
481 nm=vcalloc ( 1, sizeof (Moca));
483 nm->moca_scale=m->moca_scale;
484 nm->evaluate_domain=m->evaluate_domain;
485 nm->moca_threshold=m->moca_threshold;
486 nm->cache_cl_with_domain=m->cache_cl_with_domain;
487 if ( m->forbiden_residues)nm->forbiden_residues=copy_int (m->forbiden_residues,nm->forbiden_residues, -1, -1);
488 nm->make_nol_aln=m->make_nol_aln;
493 Moca * free_moca ( Moca *m)
495 if ( m->forbiden_residues)free_int ( m->forbiden_residues, -1);
499 /************************************************************************/
501 /* TC_param Functions */
504 /************************************************************************/
505 TC_param * duplicate_TC_param ( TC_param*B)
508 N=vcalloc (1, sizeof ( TC_param));
509 memcpy(B, N, sizeof(TC_param));
512 TC_param * free_TC_param ( TC_param*B)
517 /************************************************************************/
519 /* Blast_param Functions */
522 /************************************************************************/
523 Blast_param * duplicate_blast_param ( Blast_param*B)
526 N=vcalloc (1, sizeof ( Blast_param));
527 sprintf ( N->blast_server, "%s", B->blast_server);
528 sprintf ( N->db, "%s", B->db);
531 N->min_cov=B->min_cov;
534 Blast_param * free_blast_param ( Blast_param*B)
540 /************************************************************************/
545 /************************************************************************/
546 Structure* declare_structure ( int n, char **array)
551 S=vcalloc (1, sizeof (Structure));
555 S->struc=vcalloc ( n, sizeof (int**));
556 S->len=vcalloc ( n, sizeof (int));
557 for ( a=0; a< n; a++)
559 S->len[a]=strlen(array[a]);
560 S->struc[a]=declare_int ( strlen ( array[a])+2, 1);
565 Structure *extend_structure ( Structure *S)
570 for ( a=0; a< S->nseq; a++)
572 for ( b=0; b< S->len[a]; b++)
573 S->struc[a][b]=vrealloc ( S->struc[a][b],( S->n_fields+1)*sizeof (int));
578 Sequence * reset_sequence_len (Sequence *S)
582 if ( !S || !S->nseq)return 0;
583 max=min=strlen (S->seq[0]);
584 for (a=0; a<S->nseq; a++)
586 l=strlen (S->seq[a]);
595 Sequence * declare_sequence ( int min, int max, int nseq)
601 LS=vcalloc (1, sizeof ( Sequence));
603 LS->seq_comment=declare_char ( nseq,COMMENT_SIZE);
604 LS->aln_comment=declare_char ( nseq,COMMENT_SIZE);
606 LS->file=declare_char( nseq,STRING+1);
607 LS->seq=declare_char ( nseq, max+1);
608 LS->name=declare_char( nseq,MAXNAMES+1);
610 LS->len=vcalloc ( nseq, sizeof (int));
615 LS->type=vcalloc(30, sizeof (char));
616 LS->T=declare_arrayN(2, sizeof (Template), nseq, 1);
619 LS->dc=declare_int (nseq, 2);
622 Sequence * realloc_sequence (Sequence *OUT, int new_nseq, int max_len)
626 if ( new_nseq<OUT->max_nseq)return OUT;
628 OUT->min_len =MIN(OUT->min_len,max_len);
629 OUT->max_len =MAX(OUT->max_len,max_len);
630 OUT->seq_comment =new_realloc_char ( OUT->seq_comment, new_nseq,COMMENT_SIZE);
631 OUT->aln_comment =new_realloc_char ( OUT->aln_comment, new_nseq,COMMENT_SIZE);
633 OUT->seq =new_realloc_char ( OUT->seq, new_nseq,OUT->max_len+1);
634 OUT->name =new_realloc_char ( OUT->name, new_nseq,MAXNAMES+1);
637 OUT->file =new_realloc_char ( OUT->file, new_nseq,STRING+1);
638 OUT->len =vrealloc ( OUT->len, (new_nseq+1)*sizeof (int));
640 OUT->T=(Template**)realloc_arrayN (2, (void **)OUT->T,sizeof (Template), new_nseq, 1);
641 OUT->dc=(int **)realloc_arrayN (2, (void **)OUT->dc,sizeof (int), new_nseq, 2);
643 OUT->max_nseq=new_nseq;
647 Sequence * duplicate_sequence (Sequence *S )
653 if (S==NULL)return S;
654 LS=declare_sequence (S->min_len, S->max_len, S->nseq);
655 for (b=0, a=0; a<S->nseq; a++)
657 if (S->seq && S->seq[a])
660 sprintf ( LS->file[b], "%s", S->file[a]);
661 if ( S->seq_comment && S->seq_comment[a])sprintf ( LS->seq_comment[b], "%s", S->seq_comment[a]);
662 if ( S->aln_comment && S->aln_comment[a])sprintf ( LS->aln_comment[b], "%s", S->aln_comment[a]);
663 if ( S->seq && S->seq[a])sprintf ( LS->seq[b], "%s", S->seq[a]);
664 if ( S->name&& S->name[a])sprintf ( LS->name[b], "%s", S->name[a]);
665 LS->dc[b][0]=S->dc[a][0];
666 LS->dc[b][1]=S->dc[a][1];
667 LS->len[b]=S->len[a];
668 LS->T[b][0]=S->T[a][0];
675 LS->max_len=S->max_len;
676 LS->min_len=S->min_len;
679 if (S->W)LS->W=duplicate_weights (S->W);
680 sprintf ( LS->type, "%s", S->type);
681 sprintf ( LS->template_file, "%s", S->template_file);
682 LS->max_nseq=S->nseq;
687 void free_sequence ( Sequence *LS, int nseq)
694 free_char ( LS->file, -1);
695 free_char ( LS->seq_comment, -1);
696 free_char ( LS->aln_comment, -1);
697 free_char ( LS->seq, -1);
698 free_char ( LS->name,-1);
699 free_int (LS->dc, -1);
700 free_arrayN((void*)LS->T, 2);
703 free_weights (LS->W);
708 /************************************************************************/
710 /* Weights Functions */
713 /************************************************************************/
714 Weights* declare_weights ( int nseq)
718 W=vcalloc ( 1, sizeof ( Weights));
719 W->comments=vcalloc ( 1000, sizeof (char));
721 W->mode=vcalloc (FILENAMELEN, sizeof (char));
722 W->seq_name= declare_char ( W->nseq*2, 200);
723 W->PW_SD=declare_float ( W->nseq, W->nseq);
724 W->PW_ID=declare_float ( W->nseq, W->nseq);
725 W->SEQ_W=vcalloc ( W->nseq, sizeof ( float));
728 Weights* duplicate_weights (Weights *W)
733 NW=declare_weights (W->nseq);
734 sprintf ( NW->comments, "%s", W->comments);
735 sprintf ( NW->mode, "%s", W->mode);
736 for (a=0, c=0; a< W->nseq; a++)
740 sprintf ( NW->seq_name[c], "%s", W->seq_name[a]);
741 NW->SEQ_W[c]=W->SEQ_W[a];
742 for(b=0; b< W->nseq; b++)
744 NW->PW_SD[c][b]=W->PW_SD[a][b];
745 NW->PW_ID[c][b]=W->PW_ID[a][b];
752 Weights* free_weights ( Weights* W)
762 free_char(W->seq_name, -1);
763 free_float(W->PW_SD,-1);
764 free_float(W->PW_ID, -1);
771 Alignment* copy_aln ( Alignment *A, Alignment *B)
780 if ( A==NULL){free_aln(B); return NULL;}
782 nnseq=MAX(A->nseq, A->max_n_seq);
785 B=realloc_alignment2 (B, nnseq, nlen);
787 B=declare_aln2 (nnseq, nlen);
792 B->max_len=A->max_len;
793 B->min_len=A->min_len;
794 B->declared_len=nlen;
798 B->len_aln=A->len_aln;
801 /*sequence Information*/
802 if ( A->generic_comment)
804 vfree(B->generic_comment);
805 B->generic_comment=vcalloc (strlen(A->generic_comment)+1, sizeof (char));
806 sprintf ( B->generic_comment, "%s", A->generic_comment);
808 if ( (A->S)==NULL){vfree (B->len); B->len=vcalloc ( A->max_n_seq, sizeof (int));}
809 ga_memcpy_int ( A->len, B->len, B->nseq);
811 B->seq_comment=copy_char ( A->seq_comment, B->seq_comment, -1,-1);
812 B->aln_comment=copy_char ( A->aln_comment, B->aln_comment, -1,-1);
814 B->name=copy_char ( A->name, B->name, -1,-1);
816 B->file=copy_char ( A->file, B->file, -1,-1);
817 B->tree_order=copy_char ( A->tree_order, B->tree_order, -1,-1);
818 B->expanded_order=A->expanded_order;
819 free_char ( B->seq_al, -1);
820 B->seq_al=declare_char(B->max_n_seq, B->declared_len);
821 // HERE ("A: MAX_NSEQ=%d %d %d %d",B->nseq, B->max_n_seq, B->declared_len, B->len_aln);
822 // HERE ("B: MAX_NSEQ=%d %d %d %d",A->nseq, A->max_n_seq, A->declared_len, A->len_aln);
823 for ( a=0; a< nnseq; a++)
827 for ( b=0; b< A->len_aln; b++)
828 B->seq_al[a][b]=A->seq_al[a][b];
834 B->order=copy_int ( A->order, B->order, -1, -1);
838 B->seq_cache=copy_int ( A->seq_cache, B->seq_cache,-1,-1);
843 B->cdna_cache=copy_int ( A->cdna_cache, B->cdna_cache,-1,-1);
846 B->P=copy_profile (A->P);
848 B->Dp_result=A->Dp_result;
852 if ( (A->S)==NULL){vfree (B->score_seq); B->score_seq=vcalloc ( A->max_n_seq, sizeof (int));}
853 ga_memcpy_int( A->score_seq,B->score_seq,B->nseq);
854 B->score_res=A->score_res;
856 B->score_aln=A->score_aln;
860 B->finished=A->finished;
863 B->output_res_num=A->output_res_num;
864 B->residue_case=A->residue_case;
868 B->random_tag=A->random_tag;
870 /*Make the function Recursive */
873 B->A=copy_aln (A->A, NULL);
880 Alignment* shrink_aln ( Alignment *A, int nseq, int *list)
886 for ( a=0; a< nseq; a++)
889 sprintf ( A->seq_comment[a], "%s",B->seq_comment[seq]);
890 sprintf ( A->aln_comment[a], "%s",B->aln_comment[seq]);
892 sprintf ( A->seq_al [a], "%s",B->seq_al [seq]);
893 A->order[a][0]=B->order[seq][0];
894 A->order[a][1]=B->order[seq][1];
895 A->order[a][2]=B->order[seq][2];
896 A->order[a][3]=B->order[seq][3];
897 A->order[a][4]=B->order[seq][4];
899 A->score_seq[a]=B->score_seq[seq];
900 A->len[a]=B->len[seq];
903 A->len_aln=strlen (A->seq_al[0]);
907 Alignment* extract_sub_aln2 ( Alignment *B, int ns, char **ls)
912 list=name_array2index_array(ls, ns, B->name, B->nseq);
913 A=extract_sub_aln ( B,ns, list);
917 Alignment* extract_sub_aln ( Alignment *B, int nseq, int *list)
922 A=declare_aln2(nseq, B->len_aln+1);
923 for ( n=0,a=0; a< nseq; a++)
926 if ( seq==-1)continue;
928 sprintf ( A->seq_comment[a], "%s",B->seq_comment[seq]);
929 sprintf ( A->aln_comment[a], "%s",B->aln_comment[seq]);
930 sprintf ( A->name[a], "%s",B->name[seq]);
933 for (b=0; b<=B->len_aln; b++)A->seq_al [a][b]=B->seq_al [seq][b];
934 A->order[a][0]=B->order[seq][0];
935 A->order[a][1]=B->order[seq][1];
936 A->order[a][2]=B->order[seq][2];
937 A->order[a][3]=B->order[seq][3];
938 A->order[a][4]=B->order[seq][4];
940 A->score_seq[a]=B->score_seq[seq];
941 A->len[a]=B->len[seq];
944 A->len_aln=B->len_aln;
948 Alignment *declare_aln2 ( int nseq, int len)
953 S=vcalloc ( 1, sizeof ( Sequence));
965 Alignment *declare_aln ( Sequence *S){return declare_Alignment(S);}
967 Alignment *declare_Alignment ( Sequence *S)
973 [x][0]= which is the xth seq of aln
974 [x][1]= how many deleted residues before the first one
978 LA=vcalloc (1, sizeof ( Alignment));
979 aln_stack (LA, DECLARE_ALN);
982 LA->declared_len=MAX_LEN_ALN;
983 LA->max_n_seq=MAX_N_SEQ;
987 LA->declared_len=2*S->max_len+1;
988 LA->max_n_seq=S->nseq+1;
993 LA->seq_comment=declare_char (LA->max_n_seq, COMMENT_SIZE);
994 LA->aln_comment=declare_char (LA->max_n_seq, COMMENT_SIZE);
997 LA->seq_al=declare_char ( LA->max_n_seq,LA->declared_len );
998 LA->name=declare_char (LA->max_n_seq, MAXNAMES+1);
1001 LA->file=declare_char (LA->max_n_seq, STRING);
1002 LA->tree_order=declare_char (LA->max_n_seq, STRING);
1003 LA->order= declare_int (LA->max_n_seq , 5);
1004 //order[a][0]: sequence index in S
1005 //order[a][1]: offset of the sequence
1006 //order[a][2]: used by sw_gotoh_pair_wise
1007 //order[a][3]: used by sw_gotoh_pair_wise
1008 //order[a][4]: weight, -1
1009 LA->score_seq= vcalloc (LA->max_n_seq, sizeof (int));
1011 for ( a=0; a< LA->max_n_seq; a++)LA->order[a][0]=a;
1015 LA->len=vcalloc (LA->max_n_seq, sizeof (int));
1017 if (S && S->name)for ( a=0; a<S->nseq; a++)
1019 sprintf ( LA->name[a], "%s", S->name[a]);
1026 Alignment * realloc_aln ( Alignment *A, int new_len){return realloc_alignment(A, new_len);}
1027 Alignment * realloc_alignment ( Alignment *A, int new_len)
1029 if (A==NULL)A=declare_Alignment (NULL);
1031 return realloc_alignment2( A, A->max_n_seq,new_len);
1034 Alignment * realloc_aln2 ( Alignment *A, int n_nseq, int n_len){return realloc_alignment2(A, n_nseq, n_len);}
1038 Alignment * realloc_alignment2 ( Alignment *A, int n_nseq, int n_len)
1042 int delta_len, delta_nseq;
1044 if ( A==NULL) A=declare_Alignment(NULL);
1049 len=A->declared_len;
1052 n_len=MAX(len, n_len);
1053 n_nseq=MAX(nseq,n_nseq);
1054 delta_nseq=MAX(0,n_nseq-nseq);
1055 delta_len =MAX(0,n_len-len);
1057 if ( delta_nseq<=0 && delta_len<=0)return A;
1062 A->len =vrealloc( A->len , sizeof (int)*n_nseq);
1063 for (a=nseq; a< n_nseq; a++)A->len[a]=0;
1065 A->declared_len =n_len;
1066 A->max_n_seq =n_nseq;
1069 A->seq_comment=new_realloc_char ( A->seq_comment, n_nseq, -1);
1070 A->aln_comment=new_realloc_char ( A->aln_comment, n_nseq, -1);
1072 A->name =new_realloc_char ( A->name, n_nseq, -1);
1075 A->file =new_realloc_char ( A->file, n_nseq, -1);
1077 A->tree_order =new_realloc_char ( A->tree_order, n_nseq, -1);
1078 A->seq_al =new_realloc_char ( A->seq_al, n_nseq, n_len);
1079 A->order =new_realloc_int ( A->order, n_nseq, -1);
1081 if ( A->seq_cache) A->seq_cache=new_realloc_int ( A->seq_cache, n_nseq,n_len);
1082 if ( A->cdna_cache)A->cdna_cache=new_realloc_int ( A->cdna_cache, n_nseq,n_len);
1085 A->score_seq =vrealloc( A->score_seq, sizeof (int)*(n_nseq));
1086 for ( a=nseq; a< n_nseq; a++)A->score_seq[a]=0;
1095 long aln_stack (Alignment *A, int mode)
1099 static int max_size;
1102 if (A==NULL) return 0;
1103 else if ( mode==DECLARE_ALN)
1105 if ( size==max_size)
1108 list=vrealloc (list, max_size*sizeof (long));
1110 list[size++]=(long)A;
1113 else if (mode==FREE_ALN)
1116 for (a=0; a<size; a++)
1118 if (list[a]==(long)A)
1120 for (b=a+1; b<size;b++)
1131 else if ( mode==EXTRACT_ALN)
1133 return list[size--];
1137 printf_exit (EXIT_FAILURE, stderr, "ERROR: Unknown mode for aln_stack");
1142 Sequence* free_aln ( Alignment *LA){ return free_Alignment(LA);}
1143 Alignment *free_data_in_aln (Alignment *A)
1145 //Frees only the sequence data (keeps profile information)
1146 A->seq_al=free_char (A->seq_al, -1);
1147 A->seq_comment=free_char (A->seq_comment, -1);
1148 A->aln_comment=free_char (A->aln_comment, -1);
1149 A->name=free_char (A->name, -1);
1150 A->expanded_order=free_char (A->expanded_order, -1);
1152 A->order=free_int (A->order, -1);
1153 A->seq_cache=free_int (A->seq_cache, -1);
1154 A->cdna_cache=free_int (A->cdna_cache, -1);
1155 A->score_res=free_int (A->score_res, -1);
1156 free_sequence (A->S, -1);
1161 Sequence* free_Alignment ( Alignment *LA)
1163 /* Does not free the A->S field (sequences of A)*/
1166 //aln_stack checks the alignment has not already been freed
1167 if ( LA==NULL || !aln_stack(LA,FREE_ALN)){return NULL;}
1170 free_char ( LA->file, -1);
1171 free_char ( LA->seq_al, -1);
1172 free_int ( LA->seq_cache, -1);
1173 free_int ( LA->cdna_cache, -1);
1174 free_char ( LA->name,-1);
1176 free_char ( LA->tree_order,-1);
1177 vfree ( LA->generic_comment);
1178 free_char ( LA->seq_comment, -1);
1179 free_char ( LA->aln_comment, -1);
1181 free_int ( LA->order, -1);
1183 vfree ( LA->score_seq);
1186 free_profile (LA->P);
1187 if ( LA->A){free_Alignment (LA->A);LA->A=NULL;}
1194 Alignment * update_aln_random_tag ( Alignment *A)
1199 A->random_tag=++tag;
1203 Profile *copy_profile (Profile *P1)
1208 if ( !P1) return NULL;
1209 P=declare_profile ( P1->alphabet, P1->max_len);
1210 P->count=copy_int (P1->count, P->count, -1, -1);
1211 P->count2=copy_int (P1->count2, P->count2, -1, -1);
1212 P->count3=copy_int (P1->count3, P->count3, -1, -1);
1219 Profile *declare_profile(char *alphabet, int len)
1222 P=vcalloc ( 1, sizeof ( Profile));
1223 P->alp_size=strlen(alphabet);
1225 P->alphabet=vcalloc ( strlen (alphabet)+2, sizeof (char));
1226 sprintf ( P->alphabet, "%s", alphabet);
1228 P->count=declare_int( P->alp_size+2, len);
1229 P->count2=declare_int(100, len);
1230 P->count3=declare_int(100, len);
1234 Profile * free_profile ( Profile *P)
1236 if (!P) return NULL;
1239 vfree (P->alphabet);
1240 free_int ( P->count, -1);
1241 free_int ( P->count2, -1);
1248 /************************************************************************/
1253 /************************************************************************/
1259 Memcontrol *memlast;
1261 FILE* print_mem_usage (FILE *fp, char *comment)
1263 fprintf ( fp, "# %s Memory Usage: Current= %.3f Mb, Max= %.3f Mb\n", comment,(float)((float)alloc_mem/(1024*1024)),(float)((float)tot_mem/(1024*1024)) );
1266 void set_max_mem (int m)
1268 max_mem=m*1024*1024;
1271 int verify_memory (int s)
1275 tot_mem=(alloc_mem>tot_mem)?alloc_mem:tot_mem;
1277 if (max_mem && alloc_mem>max_mem)
1279 fprintf (stderr, "\n%s Requires Too Much Memory: %d Megabytes [FATAL:%s]\n", PROGRAM,(int)(alloc_mem/1024*1024),PROGRAM);
1280 fprintf (stderr, "Tip: Rerun your Job with a smaller dataset\n");
1282 myexit (EXIT_FAILURE);
1290 int my_assert ( void *p, int index)
1296 fprintf ( stderr, "\n****************************************************************\n");
1297 fprintf ( stderr, "\n DEBUG MODE [Rebuild For Better Performances] \n");
1298 fprintf ( stderr, "\n*****************************************************************\n");
1302 if ( !is_dynamic_memory(p)) return 1;
1303 else if ( read_array_size_new (p)<=index)
1305 fprintf ( stderr, "\nFaulty Allocation: Size=%d Access=%d\n", read_array_size (p,0),index);
1316 void * vmalloc ( size_t size)
1321 verify_memory (size+2*sizeof (Memcontrol));
1324 return NULL; /*crash ("\n0 bytes in vmalloc\n");*/
1328 x= malloc (size + 2*sizeof (Memcontrol));
1329 //x=dlmalloc (size + 2*sizeof (Memcontrol));
1332 printf_exit (EXIT_FAILURE,stderr, "\nFAILED TO ALLOCATE REQUIRED MEMORY (vmalloc)\n");
1339 M[0].size_element=0;
1340 sprintf ( M[0].check, "dy");
1350 void *vcalloc (size_t nobj, size_t size)
1352 return sub_vcalloc (nobj,size, MEMSET0);
1354 void *vcalloc_nomemset ( size_t nobj, size_t size)
1356 return sub_vcalloc (nobj, size, NO_MEMSET0);
1358 void *sub_vcalloc ( size_t nobj, size_t size, int MODE)
1363 if ( nobj<=0 || size<=0)return NULL;/*crash ("\n0 bytes in vmalloc\n");*/
1364 else x=vmalloc (nobj*size);
1367 M=x;M-=2;M[0].size_element=size;M+=2;x=M;
1371 crash ( "\nFAILED TO ALLOCATE REQUIRED MEMORY (vcalloc)\n");
1378 x=memset (x,0, nobj*size);
1382 if (nobj)x=memset (x, 0, size);
1388 void *vrealloc ( void *p, size_t size)
1399 memset (x, 0, size);
1411 if ( size<=0){return NULL;vfree (p);return NULL;}
1414 verify_memory (size - i_size);
1415 x=realloc ( p, size+2*sizeof(Memcontrol));
1417 if ( x==NULL){crash ( "\nFAILED TO ALLOCATE REQUIRED MEMORY (realloc)\n");return NULL;}
1422 for ( a=i_size; a< size; a++)((char*)x)[a]=0;
1428 void vfree ( void *p)
1443 verify_memory (-(size+2*sizeof(Memcontrol)));
1446 void vfree_all (void *p)
1456 /*********************************************************************/
1461 /*********************************************************************/
1462 #define WRITE_SIZE(type,function)\
1463 void function ( int x, type *array, int os)\
1465 fprintf(stderr, "\nwrite_size is a deprecated function [Warning:%s]\n", PROGRAM);return;\
1467 WRITE_SIZE(short,write_size_short)
1468 WRITE_SIZE(char,write_size_char)
1469 WRITE_SIZE(int,write_size_int)
1470 WRITE_SIZE(float,write_size_float)
1471 WRITE_SIZE(double,write_size_double)
1473 #define READ_ARRAY_SIZE(type, function)\
1474 int function (void *array, size_t size)\
1476 return read_array_size (array, size);\
1478 READ_ARRAY_SIZE(short,read_size_short)
1479 READ_ARRAY_SIZE(char,read_size_char)
1480 READ_ARRAY_SIZE(int,read_size_int)
1481 READ_ARRAY_SIZE(float,read_size_float)
1482 READ_ARRAY_SIZE(double,read_size_double)
1485 int read_array_size_new (void *array)
1487 return read_array_size ( array, 0);
1489 int read_array_size (void *array, size_t size)
1492 if (array==NULL)return 0;
1493 p=(Memcontrol *)array;
1495 if ( p[0].size_element ==0 && size==0)
1497 fprintf ( stderr, "\nERROR in read_array_size: trying to read the size of a malloced block");
1499 else if ( size ==0) return (int)p[0].size/p[0].size_element;
1501 return (int)p[0].size/size;
1504 int is_dynamic_memory ( void *array)
1507 if (array==NULL)return 0;
1508 p=(Memcontrol *)array;
1510 if ( strm (p[0].check, "dy"))return 1;
1514 /************************************************************************/
1516 /* DECLARE 2d ARRAYS */
1519 /************************************************************************/
1521 void * free_arrayN(void *p, int n)
1527 if ( p==NULL) return NULL;
1528 else if ( n==1)vfree ((void *)p);
1532 s=read_array_size ( (void *)p, sizeof ( void *));
1533 for ( a=0; a< s; a++)free_arrayN ((void *)i[a], n-1);
1539 void * declare_arrayNnomemset (int ndim, size_t size, ...)
1546 va_start (ap, size);
1548 array=vcalloc (ndim, sizeof (int));
1549 for ( a=0; a< ndim; a++)
1551 array[a]=va_arg (ap,int);
1552 if ( array[a]<0){va_end(ap);return NULL;}
1560 p=vcalloc_nomemset (array[0], sizeof ( void*));
1561 for (a=0; a< array[0]; a++)
1563 p[a]=vcalloc_nomemset (array[1], size);
1568 p=declare_arrayN2nomemset (ndim, array, size);
1574 void *declare_arrayN2nomemset ( int ndim, int *A, size_t size)
1581 p=vcalloc_nomemset (A[0], sizeof (void*));
1582 for ( a=0; a<A[0]; a++)
1583 p[a]=declare_arrayN2(ndim-1, A+1, size);
1587 p=vcalloc_nomemset (A[0], size);
1592 void * declare_arrayN (int ndim, size_t size, ...)
1600 va_start (ap, size);
1602 array=vcalloc (ndim, sizeof (int));
1603 for ( a=0; a< ndim; a++)
1605 array[a]=va_arg (ap,int);
1606 if ( array[a]<0){va_end(ap);return NULL;}
1614 p=vcalloc_nomemset (array[0], sizeof ( void*));
1615 for (a=0; a< array[0]; a++)
1616 p[a]=vcalloc (array[1], size);
1620 p=declare_arrayN2 (ndim, array, size);
1626 void *declare_arrayN2 ( int ndim, int *A, size_t size)
1633 p=vcalloc_nomemset (A[0], sizeof (void*));
1634 for ( a=0; a<A[0]; a++)
1635 p[a]=declare_arrayN2(ndim-1, A+1, size);
1639 p=vcalloc (A[0], size);
1644 void **declare_array (int first, int second, size_t size)
1646 return (void **)declare_arrayN (2,size,first, second);
1650 #define DECLARE_ARRAY(type,wf,rf,function)\
1651 type** function (int first, int second)\
1653 return (type **)declare_arrayN (2,sizeof(type), first, second);\
1656 int **declare_int2 (int f, int *s, int d)
1660 r=vcalloc ( f, sizeof (int*));
1662 r[a]=vcalloc (s[a]+d, sizeof (int));
1670 DECLARE_ARRAY(short,write_size_short,read_size_short,declare_short)
1671 DECLARE_ARRAY(char,write_size_char,read_size_char,declare_char)
1672 DECLARE_ARRAY(int,write_size_int,read_size_int,declare_int)
1673 DECLARE_ARRAY(float,write_size_float,read_size_float,declare_float)
1674 DECLARE_ARRAY(double,write_size_double,read_size_double,declare_double)
1676 void **declare_array_nomemset (int first, int second, size_t size)
1678 return (void **)declare_arrayNnomemset (2,size,first, second);
1680 #define DECLARE_ARRAY_NMS(type,wf,rf,function)\
1681 type** function (int first, int second)\
1683 return (type **)declare_arrayNnomemset (2,sizeof(type), first, second);\
1685 DECLARE_ARRAY_NMS(short,write_size_short,read_size_short,declare_short_nomemset)
1686 DECLARE_ARRAY_NMS(char,write_size_char,read_size_char,declare_char_nomemset)
1687 DECLARE_ARRAY_NMS(int,write_size_int,read_size_int,declare_int_nomemset)
1688 DECLARE_ARRAY_NMS(float,write_size_float,read_size_float,declare_float_nomemset)
1689 DECLARE_ARRAY_NMS(double,write_size_double,read_size_double,declare_double_nomemset)
1692 Alignment ** declare_aln_array ( int first)
1698 array=vcalloc (first, sizeof (Alignment*));
1699 for ( a=0; a< first; a++)
1700 array[a]=declare_Alignment (NULL);
1707 /************************************************************************/
1709 /* Realloc 2d ARRAYS */
1712 /************************************************************************/
1713 void ** realloc_arrayN(int ndim,void **main_array,size_t size, ...)
1720 /*dim size==-1: keep current size*/
1721 /*Dim sizes are the absolute size (not the extension*/
1722 /*If array getting shorter, memory is Not Claimed back*/
1724 array=vcalloc (ndim, sizeof (int));
1725 va_start (ap, size);
1726 for ( a=0; a< ndim; a++)
1728 array[a]=va_arg (ap,int);
1729 if ( array[a]<-1){va_end(ap);return NULL;}
1733 p=realloc_arrayN2 (ndim, main_array, array,size);
1738 void **realloc_arrayN2 ( int ndim, void ** p, int *A, size_t size)
1744 if (ndim==0)return NULL;
1748 o=read_array_size (p,sizeof (void*));
1749 if (A[0]>o)p=vrealloc (p, sizeof (void*)*A[0]);
1750 n=(A[0]==-1)?o:A[0];
1751 for ( a=0; a<n; a++)
1752 p[a]=realloc_arrayN2(ndim-1,p[a], A+1, size);
1756 o=read_array_size (p, size);
1757 if (A[0]>o)p=vrealloc (p, size*A[0]);
1764 void ** realloc_array (void **array,size_t size, int first, int second, int ext1, int ext2)
1768 if ( array==NULL)return declare_array (((first==-1)?0:first)+ext1, ((second==-1)?0:second)+ext2, size);
1769 else if ( first==-1)
1771 first=read_array_size (array, sizeof (void *));
1773 if (second==-1)second=read_array_size(array[0], size);
1778 for ( a=d1; a<first; a++)vfree (array[a]);
1779 array=vrealloc (array, sizeof (void*)*d1);
1783 for (a=0; a<d1 && a<first; a++)
1784 array[a]=vrealloc ( array[a], size*d2);
1786 for ( a=first; a< d1; a++)
1787 array[a]=vrealloc ( array[a], size*d2);
1795 #define REALLOC_ARRAY(type,wf,rf,function1,function2,function3)\
1796 type ** function1 ( type **array, int first, int second, int ext1, int ext2)\
1798 return (type **)realloc_array ((void **)array, sizeof (type),first, second, ext1, ext2);\
1801 REALLOC_ARRAY(short,write_size_short,read_size_short,realloc_short,declare_short,free_short)
1802 REALLOC_ARRAY(char,write_size_char,read_size_char,realloc_char,declare_char,free_char)
1803 REALLOC_ARRAY(int,write_size_int,read_size_int,realloc_int,declare_int,free_int)
1804 REALLOC_ARRAY(float,write_size_float,read_size_float,realloc_float,declare_float,free_float)
1805 REALLOC_ARRAY(double,write_size_double,read_size_double,realloc_double,declare_double,free_double)
1809 #define NEW_REALLOC_ARRAY(type,wf,rf,function1,function2,function3)\
1810 type ** function1 ( type **array, int ext1, int ext2)\
1816 first=rf(array,sizeof (type*));\
1817 second=rf(array[0],sizeof (type));\
1819 if ( ext1==-1)ext1=first;\
1820 if ( ext2==-1)ext2=second;\
1821 l1=MIN(ext1, first);\
1822 l2=MIN(ext2, second);\
1823 new_array=declare_arrayN(2,sizeof(type),ext1, ext2);\
1824 for ( a=0; a<l1; a++)\
1825 for ( b=0; b<l2; b++)new_array[a][b]=array[a][b];\
1826 function3(array, -1);\
1830 NEW_REALLOC_ARRAY(short,write_size_short,read_size_short,new_realloc_short,declare_short,free_short)
1831 NEW_REALLOC_ARRAY(char,write_size_char,read_size_char,new_realloc_char,declare_char,free_char)
1832 NEW_REALLOC_ARRAY(int,write_size_int,read_size_int,new_realloc_int,declare_int,free_int)
1833 NEW_REALLOC_ARRAY(float,write_size_float,read_size_float,new_realloc_float,declare_float,free_float)
1834 NEW_REALLOC_ARRAY(double,write_size_double,read_size_double,new_realloc_double,declare_double,free_double)
1835 Alignment ** realloc_aln_array ( Alignment **array, int ext1)
1843 array=declare_aln_array(ext1);
1846 first=read_array_size ( array, sizeof ( Alignment *));
1849 array=vrealloc ( array, (sizeof (Alignment*))*(first+ext1));
1850 for ( a=first; a<first+ext1; a++)array[a]=declare_Alignment (NULL);
1855 for ( a=first-1; a>=(first+ext1);a--)free_Alignment (array[a]);
1856 array=vrealloc ( array, (sizeof (Alignment*))*(first+ext1));
1861 /************************************************************************/
1863 /* free 2d ARRAYS */
1866 /************************************************************************/
1867 #define FREE_ARRAY(type,wf,rf,function) \
1868 type ** function (type **array, int first)\
1870 return free_arrayN((void*)array, 2);\
1872 FREE_ARRAY(short,write_size_short,read_size_short,free_short)
1873 FREE_ARRAY(char,write_size_char,read_size_char,free_char)
1874 FREE_ARRAY(int,write_size_int,read_size_int,free_int)
1875 FREE_ARRAY(float,write_size_float,read_size_float,free_float)
1876 FREE_ARRAY(double,write_size_double,read_size_double,free_double)
1880 Alignment ** free_aln_array (Alignment **array)
1886 if ( array==NULL)return NULL;
1887 len=read_array_size ( array, sizeof (Alignment *));
1888 for ( a=1; a< len; a++)free_Alignment(array[a]);
1893 Fname *declare_fname (int size)
1897 size+=strlen (get_home_4_tcoffee())+FILENAMELEN+1;
1899 F=vcalloc ( 1, sizeof (Fname));
1900 F->name =vcalloc ( size, sizeof (char));
1901 F->path =vcalloc ( size, sizeof (char));
1902 F->suffix=vcalloc ( size, sizeof (char));
1903 F->full=vcalloc ( size, sizeof (char));
1907 Fname *free_fname ( Fname *F)
1914 /******************************COPYRIGHT NOTICE*******************************/
1915 /*© Centro de Regulacio Genomica */
1917 /*Cedric Notredame */
1918 /*Fri Feb 18 08:27:45 CET 2011 - Revision 596. */
1919 /*All rights reserved.*/
1920 /*This file is part of T-COFFEE.*/
1922 /* T-COFFEE is free software; you can redistribute it and/or modify*/
1923 /* it under the terms of the GNU General Public License as published by*/
1924 /* the Free Software Foundation; either version 2 of the License, or*/
1925 /* (at your option) any later version.*/
1927 /* T-COFFEE is distributed in the hope that it will be useful,*/
1928 /* but WITHOUT ANY WARRANTY; without even the implied warranty of*/
1929 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the*/
1930 /* GNU General Public License for more details.*/
1932 /* You should have received a copy of the GNU General Public License*/
1933 /* along with Foobar; if not, write to the Free Software*/
1934 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
1935 /*............................................... |*/
1936 /* If you need some more information*/
1937 /* cedric.notredame@europe.com*/
1938 /*............................................... |*/
1942 /******************************COPYRIGHT NOTICE*******************************/