#include <math.h>
#include <stdarg.h>
-
#include "io_lib_header.h"
#include "util_lib_header.h"
#include "define_header.h"
/* */
/* */
/************************************************************************/
+int *** duplicate_residue_index (int ***r)
+{
+ int a,b,c;
+ int d1,d2,d3;
+
+ int ***nr;
+
+ d1=read_array_size_new(r);
+ nr=vcalloc ( d1, sizeof (int**));
+ for (a=0; a<d1; a++)
+ {
+ d2=read_array_size_new (r[a])-1;
+ nr[a]=vcalloc ( d2+1, sizeof (int*));
+ for (b=0; b<d2; b++)
+ {
+ d3=read_array_size_new (r[a][b]);
+ for (c=0; c<d3; c++)nr[a][b][c]=r[a][b][c];
+ }
+ }
+ return nr;
+}
+int *** declare_residue_index (Sequence *S)
+{
+ int ***r;
+ int a,b,c;
+
+ if ( !S)return NULL;
+ r=vcalloc ( S->nseq, sizeof (int**));
+ for ( a=0; a<S->nseq; a++)
+ {
+ r[a]=vcalloc (S->len[a]+2, sizeof (int*));//The empty terminator makes a scan possible without knowing len
+ for ( b=0; b<=S->len[a]; b++)
+ {
+ r[a][b]=vcalloc ( 1, sizeof (int));
+ r[a][b][0]=1;
+ }
+ }
+ return r;
+}
+
Constraint_list * declare_constraint_list_simple ( Sequence *S)
{
return declare_constraint_list (S, NULL, NULL, 0, NULL, NULL);
}
CL->cpu=1;
CL->fp=fp;
- CL->L=L;
+ if (L)
+ {
+ HERE ("The USE of L is now Deprecated with Constraint Lists");
+ exit (0);
+ }
CL->ne=ne;
CL->entry_len=LIST_N_FIELDS;
CL->el_size=sizeof (CLIST_TYPE);
CL->matrices_list=declare_char(20,20);
- CL->chunk=500;
+
CL->weight_field=WE;
if ( S)CL->seq_for_quadruplet=vcalloc ( S->nseq, sizeof (int));
CL->Prot_Blast=vcalloc ( 1, sizeof ( Blast_param));
CL->DNA_Blast=vcalloc ( 1, sizeof ( Blast_param));
CL->Pdb_Blast=vcalloc ( 1, sizeof ( Blast_param));
CL->TC=vcalloc (1, sizeof (TC_param));
-
+
+ //New data structure
+ CL->residue_index=declare_residue_index (S);
+
+
+
return CL;
}
{
if (!CL)return NULL;
- vfree (CL->L);
+ free_arrayN(CL->residue_index, 3);
free_int (CL->M, -1);
vfree (CL);
SCL[0]=CL[0];
SCL->S=CL->S;
SCL->RunName=CL->RunName;
- SCL->L=NULL;
+
SCL->max_L_len=0;
SCL->M=NULL;
SCL->ne=0;
- SCL->residue_indexed=0;
- SCL->residue_index=NULL;
-
+
return SCL;
}
Constraint_list *duplicate_constraint_list_soft (Constraint_list *CL)
S=(mode==HARD_COPY)?duplicate_sequence (CL->S):CL->S;
-
+
+
if (mode==HARD_COPY)
NCL=declare_constraint_list (S, NULL, NULL,0, NULL, NULL);
else
NCL[0]=CL[0];
}
- NCL->S=S;
+
NCL->copy_mode=mode;
if (mode==SOFT_COPY)NCL->pCL=CL;
+ NCL->S=S;
+ /*master*/
+ if (mode==HARD_COPY && CL->master)
+ {NCL->master=vcalloc ( S->nseq, sizeof(int));
+ for ( a=0; a< S->nseq; a++)
+ NCL->master[a]=CL->master[a];
+ }
+ else if (mode==SOFT_COPY)
+ {
+ NCL->seq_for_quadruplet=CL->seq_for_quadruplet;
+ }
+ NCL->o2a_byte=CL->o2a_byte;
+ /*struc List*/
NCL->STRUC_LIST=(mode==HARD_COPY)?duplicate_sequence (CL->STRUC_LIST):CL->STRUC_LIST;
sprintf ( NCL->align_pdb_param_file, "%s", CL->align_pdb_param_file);
sprintf ( NCL->align_pdb_hasch_mode, "%s", CL->align_pdb_hasch_mode);
if ( mode==HARD_COPY)
{
- for ( a=0; a< CL->ne; a++)
- for ( b=0; b< CL->entry_len; b++) vwrite_clist(NCL, a, b, vread_clist(CL, a, b));
+ NCL->residue_index=duplicate_residue_index (NCL->residue_index);
}
- else NCL->L=CL->L;
+ else NCL->residue_index=CL->residue_index;
if ( mode==HARD_COPY)
/*log*/
sprintf ( NCL->method_log, "%s",CL->method_log);
sprintf ( NCL->evaluate_mode, "%s",CL->evaluate_mode);
-
+ /* Gene Prediction*/
+ sprintf ( NCL->genepred_score, "%s",CL->genepred_score);
+
/*Parameters for domain extraction*/
NCL->moca=(mode==HARD_COPY)?duplicate_moca ( CL->moca):CL->moca;
{
pCL=CL->pCL;
- CL->L=NULL;
+ CL->residue_index=NULL;
if ( CL->M ==pCL->M )CL->M=NULL;
if (CL->start_index ==pCL->start_index )CL->start_index=NULL;
if (CL->end_index ==pCL->end_index )CL->end_index=NULL;
- if (CL->residue_index ==pCL->residue_index )CL->residue_index=NULL;
-
+
if ( CL->fp ==pCL->fp )CL->fp=NULL;
if ( CL->matrices_list ==pCL->matrices_list )CL->matrices_list=NULL;
- if ( CL->L)vfree (CL->L);
+ if ( CL->residue_index)free_arrayN(CL->residue_index, 3);
+
if ( CL->M)free_int (CL->M, -1);
if ( CL->fp)vfclose (CL->fp);
if ( CL->matrices_list)free_char(CL->matrices_list,-1);
if ( CL->start_index)free_int ( CL->start_index,-1);
if ( CL->end_index)free_int ( CL->end_index,-1);
- if ( CL->residue_index)
- {
- for ( a=0; a< (CL->S)->nseq; a++)
- {
- for ( b=0; b<=(CL->S)->len[a]; b++)
- vfree(CL->residue_index[a][b]);
- vfree (CL->residue_index[a]);
- }
- vfree(CL->residue_index);
- }
+
if ( CL->STRUC_LIST)free_sequence ( CL->STRUC_LIST, (CL->STRUC_LIST)->nseq);
S->n_fields++;
return S;
}
-
+Sequence * reset_sequence_len (Sequence *S)
+{
+ int min,max,a,l;
+
+ if ( !S || !S->nseq)return 0;
+ max=min=strlen (S->seq[0]);
+ for (a=0; a<S->nseq; a++)
+ {
+ l=strlen (S->seq[a]);
+ min=MIN(l,min);
+ max=MAX(l,max);
+ S->len[a]=l;
+ }
+ S->max_len=max;
+ S->min_len=min;
+ return S;
+}
Sequence * declare_sequence ( int min, int max, int nseq)
{
Sequence *LS;
LS->max_nseq=nseq;
LS->type=vcalloc(30, sizeof (char));
LS->T=declare_arrayN(2, sizeof (Template), nseq, 1);
+
+
LS->dc=declare_int (nseq, 2);
return LS;
}
OUT->T=(Template**)realloc_arrayN (2, (void **)OUT->T,sizeof (Template), new_nseq, 1);
OUT->dc=(int **)realloc_arrayN (2, (void **)OUT->dc,sizeof (int), new_nseq, 2);
+
OUT->max_nseq=new_nseq;
return OUT;
}
sprintf ( LS->file[b], "%s", S->file[a]);
if ( S->seq_comment && S->seq_comment[a])sprintf ( LS->seq_comment[b], "%s", S->seq_comment[a]);
if ( S->aln_comment && S->aln_comment[a])sprintf ( LS->aln_comment[b], "%s", S->aln_comment[a]);
- if ( S->seq && S->seq[a])sprintf ( LS->seq[b], "%s", S->seq[a]);
+ if ( S->seq && S->seq[a])sprintf ( LS->seq[b], "%s", S->seq[a]);
if ( S->name&& S->name[a])sprintf ( LS->name[b], "%s", S->name[a]);
LS->dc[b][0]=S->dc[a][0];
LS->dc[b][1]=S->dc[a][1];
LS->len[b]=S->len[a];
LS->T[b][0]=S->T[a][0];
+
b++;
}
LS->min_len=S->min_len;
LS->nseq=b;
- if ( S->W)LS->W=duplicate_weights (S->W);
+ if (S->W)LS->W=duplicate_weights (S->W);
sprintf ( LS->type, "%s", S->type);
sprintf ( LS->template_file, "%s", S->template_file);
LS->max_nseq=S->nseq;
vfree (LS->type);
vfree (LS->len);
free_weights (LS->W);
+
vfree (LS);
}
Alignment* copy_aln ( Alignment *A, Alignment *B)
{
int a, b;
-
+ int nnseq;
+ int nlen;
/* c[100]=10;*/
if ( A==NULL){free_aln(B); return NULL;}
-
+ nnseq=MAX(A->nseq, A->max_n_seq);
+ nlen=A->len_aln+1;
if (B)
- B=realloc_alignment2 (B, A->nseq, A->len_aln);
- else if ( A->S && A->nseq>(A->S)->nseq)
- {
- B=declare_aln2(A->nseq, MAX((A->S)->max_len+1, A->len_aln+1));
- B->S=A->S;
- }
- else
- B=declare_aln ((A->S));
-
+ B=realloc_alignment2 (B, nnseq, nlen);
+ else
+ B=declare_aln2 (nnseq, nlen);
+ B->S=A->S;
+
+
+ /*SIZES*/
+ B->max_len=A->max_len;
+ B->min_len=A->min_len;
+ B->declared_len=nlen;
+ B->max_n_seq=nnseq;
+
+ B->nseq=A->nseq;
+ B->len_aln=A->len_aln;
-
-/*SIZES*/
- B->max_len=A->max_len;
- B->min_len=A->min_len;
- B->declared_len=A->declared_len;
- B->max_n_seq=A->max_n_seq;
-
- B->nseq=A->nseq;
- B->len_aln=A->len_aln;
-
/*sequence Information*/
if ( A->generic_comment)
B->expanded_order=A->expanded_order;
free_char ( B->seq_al, -1);
B->seq_al=declare_char(B->max_n_seq, B->declared_len);
- for ( a=0; a< A->max_n_seq; a++)
+ // HERE ("A: MAX_NSEQ=%d %d %d %d",B->nseq, B->max_n_seq, B->declared_len, B->len_aln);
+ // HERE ("B: MAX_NSEQ=%d %d %d %d",A->nseq, A->max_n_seq, A->declared_len, A->len_aln);
+ for ( a=0; a< nnseq; a++)
{
- for ( b=0; b< A->declared_len; b++)
- B->seq_al[a][b]=A->seq_al[a][b];
+ if (A->seq_al[a])
+ {
+ for ( b=0; b< A->len_aln; b++)
+ B->seq_al[a][b]=A->seq_al[a][b];
+ }
}
if ( (A->S)==NULL){vfree (B->score_seq); B->score_seq=vcalloc ( A->max_n_seq, sizeof (int));}
ga_memcpy_int( A->score_seq,B->score_seq,B->nseq);
-
+ B->score_res=A->score_res;
B->score_aln=A->score_aln;
B->score=A->score;
+ B->ibit=A->ibit;
B->cpu=A->cpu;
B->finished=A->finished;
aln_stack (LA, DECLARE_ALN);
if ( S==NULL)
{
- LA->declared_len=MAX_LEN_ALN;
- LA->max_n_seq=MAX_N_SEQ;
+ LA->declared_len=MAX_LEN_ALN;
+ LA->max_n_seq=MAX_N_SEQ;
}
else
- {
+ {
LA->declared_len=2*S->max_len+1;
LA->max_n_seq=S->nseq+1;
- }
+ }
LA->S=S;
}
Sequence* free_aln ( Alignment *LA){ return free_Alignment(LA);}
+Alignment *free_data_in_aln (Alignment *A)
+{
+ //Frees only the sequence data (keeps profile information)
+ A->seq_al=free_char (A->seq_al, -1);
+ A->seq_comment=free_char (A->seq_comment, -1);
+ A->aln_comment=free_char (A->aln_comment, -1);
+ A->name=free_char (A->name, -1);
+ A->expanded_order=free_char (A->expanded_order, -1);
+
+ A->order=free_int (A->order, -1);
+ A->seq_cache=free_int (A->seq_cache, -1);
+ A->cdna_cache=free_int (A->cdna_cache, -1);
+ A->score_res=free_int (A->score_res, -1);
+ free_sequence (A->S, -1);
+ A->S=NULL;
+ return A;
+
+}
Sequence* free_Alignment ( Alignment *LA)
{
/* Does not free the A->S field (sequences of A)*/
return NULL; /*crash ("\n0 bytes in vmalloc\n");*/
else
{
- x= malloc (size + 2*sizeof (Memcontrol));
-
+
+ x= malloc (size + 2*sizeof (Memcontrol));
+ //x=dlmalloc (size + 2*sizeof (Memcontrol));
if ( x==NULL)
{
printf_exit (EXIT_FAILURE,stderr, "\nFAILED TO ALLOCATE REQUIRED MEMORY (vmalloc)\n");
{\
return (type **)declare_arrayN (2,sizeof(type), first, second);\
}
+
+int **declare_int2 (int f, int *s, int d)
+{
+ int **r;
+ int a;
+ r=vcalloc ( f, sizeof (int*));
+ for (a=0; a<f; a++)
+ r[a]=vcalloc (s[a]+d, sizeof (int));
+ return r;
+}
+
+
+
+
+
DECLARE_ARRAY(short,write_size_short,read_size_short,declare_short)
DECLARE_ARRAY(char,write_size_char,read_size_char,declare_char)
DECLARE_ARRAY(int,write_size_int,read_size_int,declare_int)
vfree (F->suffix);
return NULL;
}
-/*********************************COPYRIGHT NOTICE**********************************/
+/******************************COPYRIGHT NOTICE*******************************/
/*© Centro de Regulacio Genomica */
/*and */
/*Cedric Notredame */
-/*Tue Oct 27 10:12:26 WEST 2009. */
+/*Fri Feb 18 08:27:45 CET 2011 - Revision 596. */
/*All rights reserved.*/
/*This file is part of T-COFFEE.*/
/**/
/**/
/**/
/* */
-/*********************************COPYRIGHT NOTICE**********************************/
+/******************************COPYRIGHT NOTICE*******************************/