int *code_seq (char *seq, char *type) { static int *code; static int *aa, ng; int a, b, l; if (!aa) { char **gl; if ( strm (type, "DNA") || strm (type, "RNA")) { gl=declare_char (4,5); sprintf ( gl[ng++], "Aa"); sprintf ( gl[ng++], "Gg"); sprintf ( gl[ng++], "TtUu"); sprintf ( gl[ng++], "Cc"); } else { gl=make_group_aa ( &ng, "mafft"); } aa=(int*)vcalloc ( 256, sizeof (int)); for ( a=0; a<ng; a++) { for ( b=0; b< strlen (gl[a]); b++) { aa[(int)gl[a][b]]=a; } } free_char (gl, -1); } l=strlen (seq); if ( code) code--; if ( !code || read_array_size (code, sizeof (int))<(l+2)) { vfree (code); code=(int*)vcalloc (l+2, sizeof (int)); } code[0]=ng; code++; for (a=0; a<l; a++) { code[a]=aa[(int)seq[a]]; } code[a]=END_ARRAY; return code; }
void * free_arrayN(void *p, int n) { int a, s; void **i; if ( p==NULL) return NULL; else if ( n==1)vfree ((void *)p); else { i=(void**)p; s=read_array_size ( (void *)p, sizeof ( void *)); for ( a=0; a< s; a++)free_arrayN ((void *)i[a], n-1); vfree (p); } return NULL; }
int my_assert ( void *p, int index) { static int warning; if (!warning) { fprintf ( stderr, "\n****************************************************************\n"); fprintf ( stderr, "\n DEBUG MODE [Rebuild For Better Performances] \n"); fprintf ( stderr, "\n*****************************************************************\n"); warning=1; } if ( !is_dynamic_memory(p)) return 1; else if ( read_array_size_new (p)<=index) { fprintf ( stderr, "\nFaulty Allocation: Size=%d Access=%d\n", read_array_size (p,0),index); return 0; } else { return 1; } }
int read_array_size_new(void *array) { return read_array_size( array, 0); }