Ejemplo n.º 1
0
Alignment* shrink_aln ( Alignment *A, int nseq, int *list)
        {
	Alignment *B=NULL;
	int a,seq;

	B=copy_aln (A, B);
	for ( a=0; a< nseq; a++)
	    {
	    seq=list[a];
	    sprintf ( A->seq_comment[a], "%s",B->seq_comment[seq]);
	    sprintf ( A->aln_comment[a], "%s",B->aln_comment[seq]);

	    sprintf ( A->seq_al [a], "%s",B->seq_al [seq]);
	    A->order[a][0]=B->order[seq][0];
	    A->order[a][1]=B->order[seq][1];
	    A->order[a][2]=B->order[seq][2];
	    A->order[a][3]=B->order[seq][3];
	    A->order[a][4]=B->order[seq][4];

	    A->score_seq[a]=B->score_seq[seq];
	    A->len[a]=B->len[seq];
	    }
	A->nseq=nseq;
	A->len_aln=strlen (A->seq_al[0]);
	free_aln (B);
	return A;
	}
int make_fasta_cdna_pair_wise (Alignment *B,Alignment *A,int*in_ns, int **l_s,Constraint_list *CL, int *diag)
    {
      int a,c,p,k;
      Dp_Result *DPR;
      static Dp_Model  *M;
      int l0, l1;
      int len_i, len_j;
      int f0=0, f1=0;
      int deltaf0, deltaf1, delta;
      int nr1, nr2;
      int ala, alb, aa0, aa1;
      int type;
      
      char **al;
      int **tl_s;
      int *tns;
      /*DEBUG*/
      int debug_cdna_fasta=0;
      Alignment *DA;
      int score;
      int state,prev_state;
      int t, e;
      int a1, a2;
      
      
      l0=strlen ( B->seq_al[l_s[0][0]]);
      l1=strlen ( B->seq_al[l_s[1][0]]);

      al=declare_char (2, l0+l1+1); 
      B=realloc_aln2 (B,B->nseq,l0+l1+1);


      free_int (B->cdna_cache, -1);
      B->cdna_cache=declare_int(1, l0+l1+1);
      
      if ( !M)M=initialize_dna_dp_model (CL);

     
      M->diag=diag;

      tl_s=declare_int (2, 2);tns=vcalloc(2, sizeof(int));tl_s[0][0]=0;tl_s[1][0]=3;tns[0]=tns[1]=1;
      DPR=make_fast_dp_pair_wise (A,tns, tl_s,CL,M);
      vfree(tns);free_int(tl_s, -1);


      
      /*new_trace_back*/
      a=p=0;
      aa0=aa1=ala=alb=0;
      while ( (k=DPR->traceback[a++])!=M->START);
      while ( (k=DPR->traceback[a++])!=M->END)
	{
	  
	  f0=M->model_properties[k][M->F0];
	  f1=M->model_properties[k][M->F1];

	  len_i=M->model_properties[k][M->LEN_I];
	  len_j=M->model_properties[k][M->LEN_J];
	  
	  type=M->model_properties[k][M->TYPE];
	  
	  

	  if (type==M->CODING0)
	    {
	      deltaf0=(aa0*3+f0)-ala;
	      deltaf1=(aa1*3+f1)-alb;

	      delta=MAX(deltaf0, deltaf1);
	      
	      for (nr1=0, nr2=0,c=0; c<delta; c++, nr1++, nr2++,p++)		  
		      {
			if (nr1<deltaf0 && ala<l0)al[0][p]=B->seq_al[l_s[0][0]][ala++];
			else al[0][p]='-';
			
			if (nr2<deltaf1 && alb<l1)al[1][p]=B->seq_al[l_s[1][0]][alb++];
			else al[1][p]='-'; 
			
			B->cdna_cache[0][p]=M->NON_CODING;	
			if ( is_gap(al[1][p]) && is_gap(al[0][p]))p--;
			else if ( debug_cdna_fasta)fprintf (stderr, "\nUM: %c %c",  al[0][p], al[1][p]);
		      } 
	      for ( c=0; c< 3; c++, p++)
		{
		  if ( c==0)B->cdna_cache[0][p]=M->CODING0;
		  else if ( c==1)B->cdna_cache[0][p]=M->CODING1;
		  else if ( c==2)B->cdna_cache[0][p]=M->CODING2;
		  if (ala<l0)al[0][p]=B->seq_al[l_s[0][0]][ala++];
		  else al[0][p]='-';

		  if (alb<l1)al[1][p]=B->seq_al[l_s[1][0]][alb++];
		  else al[1][p]='-';
			
		  if ( is_gap(al[1][p]) && is_gap(al[0][p]))p--;
		  else if ( debug_cdna_fasta)fprintf (stderr, "\n%d: %c %c",k,  al[0][p], al[1][p]);
		}
	    }

	  aa0+=len_i;
	  aa1+=len_j;
	}
      
      deltaf0=(aa0*3+f0)-ala;
      deltaf1=(aa1*3+f1)-alb;
      delta=MAX(deltaf0, deltaf1);
      for (nr1=0, nr2=0,c=0; c<delta; c++, nr1++, nr2++,p++)		  
	{
	  if (nr1<deltaf0 && ala<l0)al[0][p]=B->seq_al[l_s[0][0]][ala++];
	  else al[0][p]='-';
	  
	  if (nr2<deltaf1 && alb<l1)al[1][p]=B->seq_al[l_s[1][0]][alb++];
	  else al[1][p]='-'; 
	  
	  B->cdna_cache[0][p]=M->NON_CODING;	
	  if ( is_gap(al[1][p]) && is_gap(al[0][p]))p--;
	  else if ( debug_cdna_fasta)fprintf (stderr, "\nUM: %c %c",  al[0][p], al[1][p]);
	}
      

      /*End New traceback*/
      



      al[0][p]='\0';
      al[1][p]='\0';


      sprintf( B->seq_al[l_s[0][0]], "%s", al[0]);
      sprintf( B->seq_al[l_s[1][0]], "%s", al[1]);
      B->len_aln=strlen (al[0]);
      B->nseq=2;
     
      
     
      
      if ( debug_cdna_fasta)
	  {
	    fprintf ( stderr, "\nA-A=%d, %d", CL->M['a'-'A']['a'-'A'], CL->M['a'-'A']['a'-'A'] *SCORE_K);
	    for ( a=1; a<diag[0]; a++)
	      {
		fprintf ( stderr, "\nchosen diag: %d", diag[a]);
	      }
	    
	    fprintf ( stderr, "\n  GOP=%d   GEP=%d   TG_MODE=%d", M->gop, M->gep, M->TG_MODE);
	    fprintf ( stderr, "\nF_GOP=%d F_GEP=%d F_TG_MODE=%d", M->gop, M->gep, M->F_TG_MODE);
	    
	    DA=copy_aln (B, NULL);
	    DA=realloc_aln2 (DA,6,(DA->len_aln+1));
	

	    for ( a=0; a<B->len_aln; a++)
	      {

		fprintf ( stderr, "\n%d", DA->cdna_cache[0][a]);
		if (DA->cdna_cache[0][a]>=M->CODING0)DA->seq_al[DA->nseq][a]=DA->cdna_cache[0][a]-M->nstate+'0';
		else DA->seq_al[DA->nseq][a]=DA->cdna_cache[0][a]-M->nstate+'0';

		if (DA->cdna_cache[0][a]==M->CODING0)
		  {
		    DA->seq_al[DA->nseq+1][a]=translate_dna_codon (DA->seq_al[0]+a,'*');
		    DA->seq_al[DA->nseq+2][a]=translate_dna_codon (DA->seq_al[1]+a,'*');
		  }
		else
		  {
		    DA->seq_al[DA->nseq+1][a]='-'; 
		    DA->seq_al[DA->nseq+2][a]='-'; 
		  }
		
	      }
	    DA->nseq+=3;
	    print_aln (DA);
	    
	    free_aln(DA);		      
	    score=0;
	    
	    
	    for (prev_state=M->START,a=0; a< DA->len_aln;)
	      {
		state=DA->cdna_cache[0][a];
		t=M->model[prev_state][state];
		if ( DA->cdna_cache[0][a]==M->CODING0)
		  {
		    a1=translate_dna_codon (A->seq_al[0]+a,'x');
		    a2=translate_dna_codon (A->seq_al[1]+a,'x');
		    
		    if ( a1!='x' && a2!='x')
		      {
			e=CL->M[a1-'A'][a2-'A']*SCORE_K;
		      }
		  }
		else if ( DA->cdna_cache[0][a]>M->CODING0);
		else
		  {
		    e=M->model_properties[B->cdna_cache[0][a]][M->EMISSION];
		  }
		if ( e==UNDEFINED || t==UNDEFINED) fprintf ( stderr, "\nPROBLEM %d\n", a);
		
		fprintf ( stderr, "\n[%c..%c: %d(e)+%d(t)=%d]", A->seq_al[0][a], A->seq_al[1][a], e,t,e+t);
		score+=e+t;
		prev_state=state;
		
		if (B->cdna_cache[0][a]==M->NON_CODING)a++;
		else a+=3;
		
	      }
	    
	  }
      
      for ( a=0; a<B->len_aln; a++)
	{
	  
	  if ( B->cdna_cache[0][a]<M->CODING0)B->cdna_cache[0][a]=0;
	  else B->cdna_cache[0][a]=1;
	}
      
      free_char ( al, -1);
      return DPR->score;
      
    }
Ejemplo n.º 3
0
int measure_domain_length ( Constraint_list *CL,Alignment *IN, int start, int min_len, int max_len, int step)
{
    Alignment *C=NULL;
    int score, best_score,best_len,a, b, l;
    int *score_matrix, *len_matrix;
    int n_val, best_val;

    score_matrix=(int*)vcalloc ( max_len, sizeof (int));
    len_matrix=(int*)vcalloc ( max_len, sizeof (int));


    l=strlen ( (CL->S)->seq[0]);

    min_len=MAX(0, min_len);
    min_len=MIN(l-start, min_len);

    if ( !IN)C=extract_domain_with_coordinates (C,start,min_len, CL);
    else
    {
        C=copy_aln (IN, C);
        C->len_aln=min_len;
        for ( a=0; a< C->nseq; a++)C->seq_al[a][min_len]='\0';
        C=add_seq2aln (CL,C, CL->S);
    }

    best_score= score=((CL->moca)->evaluate_domain)(C, CL);


    min_len=MAX(0, min_len);
    for ( best_len=best_val=n_val=0,b=min_len; b<max_len && (start+b)<l; b+=step, n_val++)
    {
        if ( !IN)C=extract_domain_with_coordinates (C,start, b, CL);
        else
        {
            C=copy_aln (IN, C);
            C->len_aln=min_len;
            for ( a=0; a< C->nseq; a++)C->seq_al[a][b]='\0';
            C=add_seq2aln (CL,C, CL->S);
        }
        if ( C->len_aln>0 )score=((CL->moca)->evaluate_domain)(C, CL);
        else score=-1;

        if ( score< -3000)break;

        fprintf ( stderr, "\n\t%d %d=>%d (%d, %d)[%d]",start, b, score, C->nseq, C->len_aln, step);
        score_matrix[n_val]=score;
        len_matrix [n_val]=b;
        if ( score>best_score)
        {
            best_score=score;
            best_len=b;
            best_val=n_val;
        }
    }
    free_aln(C);

    for ( a=best_val; a<n_val; a++)
    {
        if (score_matrix[a]>best_score/2)best_len=len_matrix[a];
        else break;
    }
    vfree ( score_matrix);
    vfree ( len_matrix);

    return best_len;
}
Ejemplo n.º 4
0
Alignment * interactive_domain_extraction ( Constraint_list *CL)
{
    int LEN=0;
    int START=1;
    int SCALE=2;
    int GOPP=3;

    int iteration=0;
    char *choice;
    int a,b, c;
    int index;
    char *s;
    char last_start[100];
    char out_format[100];
    Alignment *RESULT=NULL;
    Alignment *PREVIOUS=NULL;
    Alignment *C=NULL;
    Alignment *EA=NULL;

    int **parameters;


    choice=(char*)vcalloc ( 100, sizeof (char));
    parameters=declare_int (10000, 4);

    parameters[0][START]=(CL->moca)->moca_start;
    parameters[0][LEN]=  (CL->moca)->moca_len;
    parameters[0][SCALE]=(CL->moca)->moca_scale;
    parameters[0][GOPP]=CL->gop;
    iteration=0;
    sprintf ( last_start, "%d", (CL->moca)->moca_start);
    sprintf ( out_format, "mocca_aln");

    print_moca_interactive_choices ();
    while ( !strm4 (choice, "Q","X", "q", "x" ))
    {
        c=choice[0];

        if (c=='b' || c=='B')
        {
            iteration-=atoi(choice+1)+1;

            if (iteration<0)iteration=1;
        }
        else
        {
            iteration++;
            parameters[iteration][START]=parameters[iteration-1][START];
            parameters[iteration][LEN]=parameters[iteration-1][LEN];
            parameters[iteration][SCALE]=parameters[iteration-1][SCALE];
            parameters[iteration][GOPP]=parameters[iteration-1][GOPP];

            if ( c=='>')parameters[iteration][LEN]=atoi(choice+1);
            else if ( c=='|')
            {
                sprintf ( last_start, "%s", choice);
                parameters[iteration][START]=0;
                s=strrchr(choice, ':');

                if (s==NULL)
                {
                    parameters[iteration][START]=atoi(choice+1);
                }
                else
                {

                    s[0]='\0';

                    if((index=name_is_in_list (choice+1,(CL->S)->name,(CL->S)->nseq,100))==-1)
                    {
                        fprintf ( stderr, "\n\tERROR: %s NOT in Sequence Set",choice+1);
                        continue;
                    }

                    for ( a=0; a< index; a++)
                    {
                        parameters[iteration][START]+=(CL->S)->len[a]+1;
                    }
                    parameters[iteration][START]+=atoi(s+1)-1;
                }

            }
            else if ( c=='C'||c=='c')parameters[iteration][SCALE]=atoi(choice+1);
            else if ( c=='G'||c=='g')
            {
                parameters[iteration][GOPP]=atoi(choice+1);
                CL->gop=parameters[iteration][GOPP];
            }
            else if (  c=='F'||c=='f')
            {
                sprintf ( out_format, "%s", choice+1);
            }
            else if ( c=='S'||c=='s')
            {
                if (choice[1]=='\0')sprintf ( choice, "default.domain_aln.%d", iteration);
                output_format_aln (out_format,RESULT,EA=fast_coffee_evaluate_output(RESULT, CL),choice+1);
                fprintf (stderr, "\tOutput  file [%15s] in [%10s] format\n",choice+1,out_format);
                free_aln (EA);
            }
            else if (c=='\0')
            {
                if ( parameters[iteration][SCALE]>0)
                {
                    fprintf ( stderr, "\nWARNING: THRESHOLD RESET to 0");
                    parameters[iteration][SCALE]=0;
                }

                (CL->moca)->moca_scale=parameters[iteration][SCALE];
                CL->gop=parameters[iteration][GOPP];

                C=extract_domain_with_coordinates (C,parameters[iteration][START],parameters[iteration][LEN],CL);

                if ( C==NULL)
                {
                    fprintf ( stderr, "\nERROR: ILLEGAL COORDINATES! SEQUENCE BOUNDARY CROSSED\n");
                    for ( b=1,a=0; a< (CL->S)->nseq-1; a++)
                    {

                        fprintf ( stderr, "\n\t%15s=> Abs:[%d %d] Rel:[0 %d]", (CL->S)->name[a],b, b+(CL->S)->len[a]-1,(CL->S)->len[a]);
                        b+=(CL->S)->len[a];
                    }
                    fprintf ( stderr, "\n");
                }
                else if (parameters[iteration][START]==0 && parameters[iteration][LEN]==0)
                {
                    fprintf ( stderr, "\n\tEnter the following parameters:\n\n\t\tSTART  value: |x [Return]\n\t\tLENgth value: >y [Return]\n\t\ttype             [Return]\n\n");
                    fprintf ( stderr, "\n\n\tSTART is measured on the total length of the concatenated sequences\n\tx and y are positive integers\n\n");
                }

                else if ( C->nseq==0)
                {
                    fprintf ( stderr, "\nNO MATCH FOUND: LOWER THE SCALE (C)\n");
                }
                else
                {
                    RESULT=copy_aln ( C, RESULT);
                    unpack_seq_aln (RESULT, CL);
                    RESULT->output_res_num=1;

                    output_format_aln (out_format,RESULT,EA=fast_coffee_evaluate_output(RESULT, CL),"stdout");
                    free_aln(EA);
                    PREVIOUS=copy_aln ( RESULT, PREVIOUS);
                    free_aln (C);
                    print_moca_interactive_choices ();

                }
            }

            fprintf ( stderr, "\t[ITERATION %3d][START=%s][LEN=%3d][GOPP=%3d][SCALE=%4d]\t",iteration,last_start,parameters[iteration][LEN],parameters[iteration][GOPP],parameters[iteration][SCALE]);
            a=0;
            fprintf ( stderr, "Your Choice: ");
            while ( (c=fgetc(stdin))!='\n')choice[a++]=c;
            choice[a]=0;
        }
    }

    if (!RESULT)myexit(EXIT_SUCCESS);
    if ( RESULT)RESULT->output_res_num=0;
    return RESULT;
}
Ejemplo n.º 5
0
Alignment * extract_domain ( Constraint_list *CL)
{
    /*
      function documentation: start
      Alignment * extract_domain ( Constraint_list *CL)

      given a CL, this function extracts the next best scoring local multiple alignment
      It returns a CL where the aligned residues have been indicated in (CL->moca)->forbiden_residues;

      the local alignment is extracted with the dp function indicated by
                          CL->dp_mode: (gotoh_sw_pair_wise)
      Evaluation:
                 CL->get_dp_cost=slow_get_dp_cost;
      CL->evaluate_residue_pair=sw_residue_pair_extended_list;
      Continuation:
                (CL->moca)->evaluate_domain=evaluate_moca_domain;
      Cache of CL:
                (CL->moca)->cache_cl_with_domain=cache_cl_with_moca_domain;
      Domain post processing:
                (CL->moca)->make_nol_aln=make_moca_nol_aln;
      function documentation: end
    */
    int min_start, max_start, start,min_len, max_len, len, score;
    int step;
    Alignment *C=NULL;
    Alignment *RESULT=NULL;
    Alignment *EA=NULL;




    /*CASE 1: Non Automatic Domain Extraction*/
    if ((CL->moca)->moca_interactive)
    {
        return interactive_domain_extraction (CL);
    }
    else if ((CL->moca)->moca_len)
    {
        while ((C=extract_domain_with_coordinates (C,(CL->moca)->moca_start,(CL->moca)->moca_len,CL))->nseq==0)(CL->moca)->moca_scale=(CL->moca)->moca_scale*0.9;
        RESULT=copy_aln ( C, RESULT);
        unpack_seq_aln (RESULT, CL);
        output_format_aln ("mocca_aln",RESULT,EA=fast_coffee_evaluate_output(RESULT, CL),"stdout");
        free_aln(EA);

        return RESULT;
    }
    else if ( !(CL->moca)->moca_len)
    {
        analyse_sequence (CL);
        myexit (EXIT_FAILURE);
    }

    /*CASE 2: Automatic Domain Extraction: Find Coordinates*/


    start=500;

    step=10;
    min_start=0;
    max_start=strlen ((CL->S)->seq[0]);
    min_len=20;
    max_len=strlen ((CL->S)->seq[0]);

    C=extract_domain_with_coordinates (C,13,30,CL);
    C->output_res_num=1;
    print_aln (C);

    (CL->moca)->moca_scale=-180;
    C=add_seq2aln (CL,C, CL->S);
    print_aln (C);

    (CL->moca)->moca_scale=-160;
    C=add_seq2aln (CL,C, CL->S);
    print_aln (C);

    myexit (EXIT_FAILURE);

    while ( step>0)
    {
        C=approximate_domain (min_start,max_start,step,min_len,max_len, step,&start, &len, &score, CL);
        min_start=start-step;
        max_start=start+step;
        min_len=len-step;
        max_len=len+step;
        step=step/2;
    }

    C=extract_domain_with_coordinates (C,start-10, len+20,CL);
    C->output_res_num=1;
    print_aln (C);

    myexit (EXIT_FAILURE);
    return C;


}
Ejemplo n.º 6
0
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, 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;


/*sequence Information*/
	    if ( A->generic_comment)
	      {
		vfree(B->generic_comment);
		B->generic_comment=vcalloc (strlen(A->generic_comment)+1, sizeof (char));
		sprintf ( B->generic_comment, "%s", A->generic_comment);
	      }
	    if ( (A->S)==NULL){vfree (B->len); B->len=vcalloc ( A->max_n_seq, sizeof (int));}
	    ga_memcpy_int ( A->len, B->len, B->nseq);

	    B->seq_comment=copy_char ( A->seq_comment,  B->seq_comment,  -1,-1);
	    B->aln_comment=copy_char ( A->aln_comment,  B->aln_comment,  -1,-1);

	    B->name=copy_char ( A->name,     B->name,     -1,-1);

	    B->file=copy_char ( A->file,     B->file,     -1,-1);
	    B->tree_order=copy_char ( A->tree_order,     B->tree_order,     -1,-1);
	    B->expanded_order=A->expanded_order;
	    free_char ( B->seq_al, -1);
	    B->seq_al=declare_char(B->max_n_seq, B->declared_len);
	    // 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++)
	      {
		if (A->seq_al[a])
		  {
		    for ( b=0; b< A->len_aln; b++)
		      B->seq_al[a][b]=A->seq_al[a][b];
		  }
	      }



	    B->order=copy_int  ( A->order,    B->order,    -1, -1);
	    B->S=A->S;
	    if (A->seq_cache)
	        {
		B->seq_cache=copy_int  ( A->seq_cache,    B->seq_cache,-1,-1);
		}

	    if (A->cdna_cache)
	        {
		B->cdna_cache=copy_int  ( A->cdna_cache,    B->cdna_cache,-1,-1);
		}

	    B->P=copy_profile (A->P);

	    B->Dp_result=A->Dp_result;

/*Score*/

	    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;

/*Output Options*/
	    B->output_res_num=A->output_res_num;
	    B->residue_case=A->residue_case;
	    B->expand=A->expand;

	    B->CL=A->CL;
	    B->random_tag=A->random_tag;

/*Make the function Recursive */
	    if ( A->A)
	      {
		B->A=copy_aln (A->A, NULL);
	      }
	    else B->A=NULL;

	    return B;
	}
Ejemplo n.º 7
0
Constraint_list *copy_constraint_list (Constraint_list *CL, int mode)
    {
    Constraint_list *NCL;
    Sequence *S;
    int a, b;



    /*Sequences*/


      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=vcalloc ( 1, sizeof (Constraint_list));
	  NCL[0]=CL[0];
	}


      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);


      NCL->W=(mode==HARD_COPY)?duplicate_weights (CL->W):CL->W;
      NCL->DM=(mode==HARD_COPY)?duplicate_distance_matrix (CL->DM):CL->DM;
      NCL->ktupDM=(mode==HARD_COPY)?duplicate_distance_matrix (CL->ktupDM):CL->ktupDM;
      NCL->RunName=CL->RunName;

      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];}
      else{NCL->translation=CL->translation;}

      NCL->out_aln_format=(mode==HARD_COPY)?duplicate_char (CL->out_aln_format, -1, -1):CL->out_aln_format;
      NCL->n_out_aln_format=CL->n_out_aln_format;

    /*Packing Sequence: To use with domain analysis*/
      NCL->packed_seq_lu=(mode==HARD_COPY)?duplicate_int (CL->packed_seq_lu, -1, -1):CL->packed_seq_lu;
    /*DATA*/
      if (CL->fp)(mode==HARD_COPY)?NCL->fp=vtmpfile():CL->fp;

      if ( mode==HARD_COPY)
	{
	  NCL->residue_index=duplicate_residue_index (NCL->residue_index);
	}
      else NCL->residue_index=CL->residue_index;


     if ( mode==HARD_COPY)
       {
	 NCL->M=copy_int ( CL->M,NCL->M,-1, -1);
       }
     else
       NCL->M=CL->M;


    /*List Information*/
      NCL->ne=CL->ne;
      sprintf ( NCL->list_name, "%s", CL->list_name);
      NCL->entry_len=CL->entry_len;
      NCL->el_size=CL->el_size;

    /*Normalisation information*/
      NCL->filter_lib=CL->filter_lib;
      NCL->normalise=CL->normalise;
      NCL->overweight=CL->overweight;
      NCL->max_ext_value=CL->max_ext_value;
      NCL->max_value=CL->max_value;

    /*Pair wise alignment method*/
      NCL->pw_parameters_set=CL->pw_parameters_set;
      NCL->gop=CL->gop;
      NCL->f_gop=CL->f_gop;
      NCL->gep=CL->gep;
      NCL->f_gep=CL->f_gep;

      NCL->nomatch=CL->nomatch;

      NCL->TG_MODE=CL->TG_MODE;
      NCL->F_TG_MODE=CL->F_TG_MODE;

      sprintf ( NCL->dp_mode, "%s", CL->dp_mode);
      NCL->maximise=CL->maximise;
      sprintf ( NCL->matrix_for_aa_group, "%s", CL->matrix_for_aa_group);
      sprintf ( NCL->method_matrix, "%s", CL->method_matrix);

      NCL->diagonal_threshold=CL->diagonal_threshold;
      NCL->ktup=CL->ktup;

      NCL->use_fragments=CL->use_fragments;
      NCL->fasta_step=CL->fasta_step;
      NCL->lalign_n_top=CL->lalign_n_top;
      NCL->sw_min_dist=CL->sw_min_dist;
      NCL->matrices_list=(mode==HARD_COPY)?duplicate_char (CL->matrices_list, -1, -1):CL->matrices_list;
      NCL->n_matrices=CL->n_matrices;

      sprintf (NCL->distance_matrix_mode, "%s", CL->distance_matrix_mode);
      sprintf (NCL->distance_matrix_sim_mode, "%s", CL->distance_matrix_sim_mode);

      sprintf (NCL->tree_mode, "%s", CL->tree_mode);
      NCL->tree_aln=(mode==HARD_COPY)?copy_aln (CL->tree_aln, NULL):CL->tree_aln;
    /*Functions used for dynamic programming and Evaluation*/
      NCL->no_overaln=CL->no_overaln;
      NCL->profile_mode=CL->profile_mode;
      sprintf ( NCL->profile_comparison, "%s",CL->profile_comparison);
      NCL->get_dp_cost=CL->get_dp_cost;
      NCL->evaluate_residue_pair=CL->evaluate_residue_pair;
      NCL->pair_wise=CL->pair_wise;

      NCL->weight_field=CL->weight_field;
      NCL->max_n_pair=CL->max_n_pair;

    /*threading parameters*/
      NCL->Prot_Blast=(mode==HARD_COPY)?duplicate_blast_param ( CL->Prot_Blast):CL->Prot_Blast;
      NCL->DNA_Blast =(mode==HARD_COPY)?duplicate_blast_param ( CL->DNA_Blast):CL->DNA_Blast;
      NCL->Pdb_Blast =(mode==HARD_COPY)?duplicate_blast_param ( CL->Pdb_Blast):CL->Pdb_Blast;
      NCL->TC =(mode==HARD_COPY)?duplicate_TC_param ( CL->TC):CL->TC;

    /*Split parameters*/
      NCL->split=CL->split;
      NCL->split_nseq_thres= CL->split_nseq_thres;
      NCL->split_score_thres= CL->split_score_thres;
    /*Structural status*/
      NCL->check_pdb_status=CL->check_pdb_status;
    /*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;



    /*Functions for hiding forbiden pairs of residues*/
      /* Copy only for soft_copy*/
      if (mode==SOFT_COPY)
	{
	  NCL->forbiden_pair_list=CL->forbiden_pair_list;
	}
   /*extention properties:*/
      NCL->nseq_for_quadruplet=CL->nseq_for_quadruplet;
      if (mode==HARD_COPY && CL->seq_for_quadruplet)
	{NCL->seq_for_quadruplet=vcalloc ( S->nseq, sizeof(int));
	for ( a=0; a< S->nseq; a++)
	  NCL->seq_for_quadruplet[a]=CL->seq_for_quadruplet[a];
	}
      else if (mode==SOFT_COPY)
	{
	  NCL->seq_for_quadruplet=CL->seq_for_quadruplet;
	}

   /*extention properties: Do only a soft copy*/
      /* Not To be copied yet */
      if ( mode==SOFT_COPY)
	{
	  NCL->extend_jit=CL->extend_jit;
	  NCL->extend_threshold=CL->extend_threshold;
	  sprintf ( NCL->extend_clean_mode, "%s", CL->extend_clean_mode);
	  sprintf ( NCL->extend_compact_mode, "%s", CL->extend_compact_mode);
	}

    /*Lookup table parameteres*/
      NCL->chunk= CL->chunk;
      /* Do NOT copy NCL->seq_indexed, NCL->start_index, NCL->max_L_len, NCL->chunk*/
      /*
	if ( mode==SOFT_COPY)
	{
	  NCL->seq_indexed=CL->seq_indexed;
	  NCL->start_index=CL->start_index;
	  NCL->end_index=CL->start_index;
	  NCL->max_L_len=CL->max_L_len;
	  }
      */
    /*PDB STRUCTURE ALIGNMENTS*/
      /* Do only a soft copy */
      if ( mode==SOFT_COPY)
	{
	  NCL->T=CL->T;
	}
    /*MISC*/
       NCL->cpu=CL->cpu;
       NCL->local_stderr=CL->local_stderr;
       sprintf (NCL->multi_thread, "%s", CL->multi_thread);

    return NCL;
    }