7 #include "io_lib_header.h"
8 #include "util_lib_header.h"
9 #include "define_header.h"
10 #include "dp_lib_header.h"
14 Job_TC* print_lib_job ( Job_TC *job,char *string, ...)
25 list=string2list2(string, " =");
29 name =vcalloc ( (n-1)/2, sizeof (char*));
30 value=vcalloc ( (n-1)/2, sizeof (char*));
33 va_start (ap, string);
34 for (a=1, np=0; a<n; a++)
36 if (list[a][0]=='%' && list[a][1]=='s')
38 value[np++]=duplicate_string (va_arg (ap,char *));
40 else if (list[a][0]=='%')
42 if ( list[a][1]=='d')sprintf (bval, "%d", va_arg (ap,int));
43 else if ( list[a][1]=='f')sprintf (bval, "%lf",(float) va_arg (ap,double));
44 else if ( list[a][1]=='p')sprintf (bval, "%ld", (long)va_arg (ap,void *));
45 value[np++]=duplicate_string (bval);
49 sprintf (bname, "%s", list[a]);
50 name[np]=duplicate_string (bname);
53 free_arrayN((void**)list, 2);
57 return print_lib_job2 ( job,np,name,value);
61 Job_TC *print_lib_job2 ( Job_TC* job, int n, char **name, char **value)
67 job=vcalloc ( 1, sizeof (Job_TC));
68 job->pl=vcalloc (100, sizeof (char*));job->pl[job->np++]=(void*)job->pl;
75 if ( strstr(name[a], "control") && !job->control){job->control=vcalloc ( 1, sizeof (Job_control_TC));job->pl[job->np++]=(void*)job->control;}
76 else if ( strstr(name[a], "io") && !job->io){job->io=vcalloc ( 1, sizeof (Job_io_TC));job->pl[job->np++]=(void*)job->io;}
77 else if ( strstr(name[a], "param") && !job->param){job->param=vcalloc ( 1, sizeof (Job_param_TC));job->pl[job->np++]=(void*)job->param;}
79 if ( strm (name[a], "control")) {job->control=(struct Job_control_TC*)atol(value[a]);string=0;}
80 else if ( strm (name[a], "control->submitF")) {(job->control) ->submitF=(struct Job_TC *(*)(struct Job_TC *))atol(value[a]);string=0;}
81 else if ( strm (name[a], "control->retrieveF")) {(job->control) ->retrieveF=(struct Job_TC *(*)(struct Job_TC *))atol(value[a]);string=0;}
82 else if ( strm (name[a], "control->mode")) {(job->control)->mode=value[a];string=1;}
84 else if ( strm (name[a], "param")) {job->param=(struct Job_param_TC*)atol(value[a]);string=0;}
85 else if ( strm (name[a], "param->method")) {job->pl[job->np++]=((job->param)->method)=value[a];string=1;}
86 else if ( strm (name[a], "param->TCM")) {(job->param)->TCM= (TC_method *) atol(value[a]) ;string=0;}
87 else if ( strm (name[a], "param->aln_c")) {job->pl[job->np++]=(job->param)->aln_c=value[a] ;string=1;}
88 else if ( strm (name[a], "param->seq_c")) {job->pl[job->np++]=(job->param)->seq_c=value[a] ;string=1;}
91 else if ( strm (name[a], "io")) {job->io=(struct Job_io_TC*)atol(value[a]);string=0;}
92 else if ( strm (name[a], "io->out")) {job->pl[job->np++]=(job->io)->out=value[a] ;string=1;}
93 else if ( strm (name[a], "io->in" )) {job->pl[job->np++]=(job->io)->in =value[a] ;string=1;}
94 else if ( strm (name[a], "io->CL")) {(job->io)->CL=(Constraint_list*)atol (value[a]); string=0;}
97 fprintf ( stderr, "ERROR: print_lib_job2: %s is unknown [FATAL:%s]", name[a], PROGRAM);
98 myexit (EXIT_FAILURE);
100 if ( string==0) vfree ( value[a]);
103 free_arrayN ((void **)name, 2);
109 /*Stack Manipulation*/
110 Job_TC *queue_cat (Job_TC *P, Job_TC *C)
112 if ( !P && !C) return NULL;
113 else if (!P || P->jobid==-1)
123 return queue2last(P);
127 Job_TC *free_queue (Job_TC *job)
130 if (!job) return job;
141 Job_TC *free_job (Job_TC *job)
146 if ( !job ) return job;
149 for ( a=job->np-1; a>=0; a--)
158 Job_TC * queue2heap (Job_TC*job)
161 while (job && job->p)
165 Job_TC * queue2last (Job_TC*job)
168 while (job && job->c)
175 int queue2n (Job_TC*job)
180 job=queue2last (job);
181 while (job && job->p)
190 Job_TC * descend_queue (Job_TC*job)
193 if (!job ||!job->c)return job;
202 Job_TC* delete_job (Job_TC *job)
210 return queue_cat (p, c);
213 Job_TC*** split_job_list (Job_TC *job, int ns)
218 //retun a pointer to ns splits for joblist
221 if (ns==0)return NULL;
223 jl=vcalloc(ns+1, sizeof (Job_TC**));
224 jl[0]=vcalloc (2, sizeof (Job_TC*));
228 if (nj==0)return NULL;
229 else split=(nj/ns)+1;
236 if (n==split && a<ns)
241 jl[a+1]=vcalloc (2, sizeof (Job_TC*));
252 /*Display job details when debugging
261 while (job!=end){todo++;job=job->c;}
265 HERE ("--- %d %d %s",a, job, job->param->aln_c);
272 while (jl[a]){HERE ("**** %d %d ", jl [a][0], jl[a][1]);a++;}
282 Job_TC* submit_job ( Job_TC *job)
285 if (!(job->control)->mode ||!(job->control)->mode[0] || 1==1)
287 return (job->control)->submitF (job);
291 fprintf ( stderr, "\n%s is an unkown mode for posting jobs [FATAL:%s]",(job->control)->mode, PROGRAM);
292 myexit (EXIT_FAILURE);
298 Job_TC* retrieve_job ( Job_TC *job)
300 if (!(job->control)->mode ||!(job->control)->mode[0] || 1==1)
302 return (job->control)->retrieveF (job);
306 fprintf ( stderr, "\n%s is an unkown mode for posting jobs [FATAL:%s]",(job->control)->mode, PROGRAM);
307 myexit (EXIT_FAILURE);
311 int **n2splits (int splits, int tot)
316 if (splits==0)return NULL;
317 else if ( tot==0)return NULL;
321 l=declare_int (splits,2);
324 for (a=0,b=0; a<splits && b<tot; a++,b+=delta)
327 l[a][1]=MIN((b+delta),tot);
329 l[splits-1][1]=MAX((l[splits-1][1]),tot);
334 /******************************COPYRIGHT NOTICE*******************************/
335 /*© Centro de Regulacio Genomica */
337 /*Cedric Notredame */
338 /*Fri Feb 18 08:27:45 CET 2011 - Revision 596. */
339 /*All rights reserved.*/
340 /*This file is part of T-COFFEE.*/
342 /* T-COFFEE is free software; you can redistribute it and/or modify*/
343 /* it under the terms of the GNU General Public License as published by*/
344 /* the Free Software Foundation; either version 2 of the License, or*/
345 /* (at your option) any later version.*/
347 /* T-COFFEE is distributed in the hope that it will be useful,*/
348 /* but WITHOUT ANY WARRANTY; without even the implied warranty of*/
349 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the*/
350 /* GNU General Public License for more details.*/
352 /* You should have received a copy of the GNU General Public License*/
353 /* along with Foobar; if not, write to the Free Software*/
354 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
355 /*............................................... |*/
356 /* If you need some more information*/
357 /* cedric.notredame@europe.com*/
358 /*............................................... |*/
362 /******************************COPYRIGHT NOTICE*******************************/