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, ...)
21 char bname[LONG_STRING];
22 char bval[LONG_STRING];
24 list=string2list2(string, " =");
28 name =vcalloc ( (n-1)/2, sizeof (char*));
29 value=vcalloc ( (n-1)/2, sizeof (char*));
32 va_start (ap, string);
33 for (a=1, np=0; a<n; a++)
37 if ( list[a][1]=='d')sprintf (bval, "%d", va_arg (ap,int));
38 else if ( list[a][1]=='s')sprintf (bval, "%s", va_arg (ap,char *));
40 else if ( list[a][1]=='f')sprintf (bval, "%lf",(float) va_arg (ap,double));
41 else if ( list[a][1]=='p')sprintf (bval, "%ld", (long)va_arg (ap,void *));
44 else if ( list[a][1]=='f')sprintf (bval, "%f",(float) va_arg (ap,double));
45 else if ( list[a][1]=='p')sprintf (bval, "%d", (long)va_arg (ap,void *));
47 value[np]=duplicate_string (bval);
52 sprintf (bname, "%s", list[a]);
53 name[np]=duplicate_string (bname);
56 free_arrayN((void**)list, 2);
60 return print_lib_job2 ( job,np,name,value);
64 Job_TC *print_lib_job2 ( Job_TC* job, int n, char **name, char **value)
70 job=vcalloc ( 1, sizeof (Job_TC));
71 job->pl=vcalloc (100, sizeof (char*));job->pl[job->np++]=(void*)job->pl;
78 if ( strstr(name[a], "control") && !job->control){job->control=vcalloc ( 1, sizeof (Job_control_TC));job->pl[job->np++]=(void*)job->control;}
79 else if ( strstr(name[a], "io") && !job->io){job->io=vcalloc ( 1, sizeof (Job_io_TC));job->pl[job->np++]=(void*)job->io;}
80 else if ( strstr(name[a], "param") && !job->param){job->param=vcalloc ( 1, sizeof (Job_param_TC));job->pl[job->np++]=(void*)job->param;}
82 if ( strm (name[a], "control")) {job->control=(struct Job_control_TC*)atoi(value[a]);string=0;}
83 else if ( strm (name[a], "control->submitF")) {(job->control) ->submitF=(struct Job_TC *(*)(struct Job_TC *))atol(value[a]);string=0;}
84 else if ( strm (name[a], "control->retrieveF")) {(job->control) ->retrieveF=(struct Job_TC *(*)(struct Job_TC *))atol(value[a]);string=0;}
85 else if ( strm (name[a], "control->mode")) {(job->control)->mode=value[a];string=1;}
87 else if ( strm (name[a], "param")) {job->param=(struct Job_param_TC*)atol(value[a]);string=0;}
88 else if ( strm (name[a], "param->method")) {job->pl[job->np++]=((job->param)->method)=value[a];string=1;}
89 else if ( strm (name[a], "param->TCM")) {(job->param)->TCM= (TC_method *) atol(value[a]) ;string=0;}
90 else if ( strm (name[a], "param->aln_c")) {job->pl[job->np++]=(job->param)->aln_c=value[a] ;string=1;}
91 else if ( strm (name[a], "param->seq_c")) {job->pl[job->np++]=(job->param)->seq_c=value[a] ;string=1;}
94 else if ( strm (name[a], "io")) {job->io=(struct Job_io_TC*)atol(value[a]);string=0;}
95 else if ( strm (name[a], "io->out")) {job->pl[job->np++]=(job->io)->out=value[a] ;string=1;}
96 else if ( strm (name[a], "io->in" )) {job->pl[job->np++]=(job->io)->in =value[a] ;string=1;}
97 else if ( strm (name[a], "io->CL")) {(job->io)->CL=(Constraint_list*)atol (value[a]); string=0;}
100 fprintf ( stderr, "ERROR: print_lib_job2: %s is unknown [FATAL:%s]", name[a], PROGRAM);
101 myexit (EXIT_FAILURE);
103 if ( string==0) vfree ( value[a]);
106 free_arrayN ((void **)name, 2);
112 /*Stack Manipulation*/
113 Job_TC *queue_cat (Job_TC *P, Job_TC *C)
115 if ( !P && !C) return NULL;
116 else if (!P || P->jobid==-1)
126 return queue2last(P);
130 Job_TC *free_queue (Job_TC *job)
133 if (!job) return job;
144 Job_TC *free_job (Job_TC *job)
149 if ( !job ) return job;
152 for ( a=job->np-1; a>=0; a--)
161 Job_TC * queue2heap (Job_TC*job)
164 while (job && job->p)
168 Job_TC * queue2last (Job_TC*job)
171 while (job && job->c)
178 int queue2n (Job_TC*job)
183 job=queue2last (job);
184 while (job && job->p)
193 Job_TC * descend_queue (Job_TC*job)
196 if (!job ||!job->c)return job;
205 Job_TC* delete_job (Job_TC *job)
213 return queue_cat (p, c);
216 Job_TC*** split_job_list (Job_TC *job, int ns)
221 //retun a pointer to ns splits for joblist
224 if (ns==0)return NULL;
226 jl=vcalloc(ns+1, sizeof (Job_TC**));
227 jl[0]=vcalloc (2, sizeof (Job_TC*));
231 if (nj==0)return NULL;
232 else split=(nj/ns)+1;
240 if (n==split && a<ns)
245 jl[a+1]=vcalloc (2, sizeof (Job_TC*));
262 Job_TC* submit_job ( Job_TC *job)
265 if (!(job->control)->mode ||!(job->control)->mode[0] || 1==1)
267 return (job->control)->submitF (job);
271 fprintf ( stderr, "\n%s is an unkown mode for posting jobs [FATAL:%s]",(job->control)->mode, PROGRAM);
272 myexit (EXIT_FAILURE);
278 Job_TC* retrieve_job ( Job_TC *job)
280 if (!(job->control)->mode ||!(job->control)->mode[0] || 1==1)
282 return (job->control)->retrieveF (job);
286 fprintf ( stderr, "\n%s is an unkown mode for posting jobs [FATAL:%s]",(job->control)->mode, PROGRAM);
287 myexit (EXIT_FAILURE);
291 /*********************************COPYRIGHT NOTICE**********************************/
292 /*© Centro de Regulacio Genomica */
294 /*Cedric Notredame */
295 /*Tue Oct 27 10:12:26 WEST 2009. */
296 /*All rights reserved.*/
297 /*This file is part of T-COFFEE.*/
299 /* T-COFFEE is free software; you can redistribute it and/or modify*/
300 /* it under the terms of the GNU General Public License as published by*/
301 /* the Free Software Foundation; either version 2 of the License, or*/
302 /* (at your option) any later version.*/
304 /* T-COFFEE is distributed in the hope that it will be useful,*/
305 /* but WITHOUT ANY WARRANTY; without even the implied warranty of*/
306 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the*/
307 /* GNU General Public License for more details.*/
309 /* You should have received a copy of the GNU General Public License*/
310 /* along with Foobar; if not, write to the Free Software*/
311 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
312 /*............................................... |*/
313 /* If you need some more information*/
314 /* cedric.notredame@europe.com*/
315 /*............................................... |*/
319 /*********************************COPYRIGHT NOTICE**********************************/