1 /******************************************************************************
2 
3   ####    #####    ##     #####  ######           ####
4  #          #     #  #      #    #               #    #
5   ####      #    #    #     #    #####           #
6       #     #    ######     #    #        ###    #
7  #    #     #    #    #     #    #        ###    #    #
8   ####      #    #    #     #    ######   ###     ####
9 
10 ******************************************************************************/
11 /* This file is part of MAPMAKER 3.0b, Copyright 1987-1992, Whitehead Institute
12    for Biomedical Research. All rights reserved. See READ.ME for license. */
13 
14 #define INC_LIB
15 #define INC_SHELL
16 #include "mapm.h"
17 
18 void state_init_values();
19 #define MAX_CONTEXTS 1
20 
21 /* NOTE: keep the declarations of vars in the same order here, below in
22    reset_state(), in read/write_state, and in mapm.h. */
23 
24 /* global state variables THESE SHOULD MOVE */
25 
26 /**** general ****/
27 bool print_names;
28 real tolerance;
29 int  units;
30 bool auto_save;
31 /* also more_mode */
32 
33 /**** two point ****/
34 real default_lod;
35 real default_theta;
36 bool use_haplotypes;
37 
38 /**** three point ****/
39 bool use_three_pt;
40 real triplet_lod;
41 real triplet_theta;
42 int  triplet_num_links;
43 real three_pt_threshold;
44 int  three_pt_window;
45 real triplet_error_rate;
46 
47 /**** order maker ****/
48 real npt_threshold;
49 real npt_first_threshold;
50 int  npt_window;
51 int  npt_min_indivs; /* infomativeness criteria */
52 bool npt_codominant;
53 real npt_min_theta;
54 bool print_all_maps;
55 
56 /* F2 only */
57 bool fake_maps;  /* just for debugging */
58 bool use_error_rate;
59 real error_lod_thresh;
60 real error_single_thresh;
61 real error_net_thresh;
62 
63 /* Contexts */
64 STATUS_CONTEXT **context;
65 int active_context;
66 int num_contexts;
67 
68 /* CEPH only or Obsolete */
69 int  sex_specific;
70 int  triplet_sex;
71 int  compress_DNA;
72 int  print_problem_size;
73 long max_problem_size;
74 bool segregation_distortion;
75 bool use_hmm;
76 int  print_maps;
77 bool print_all_errors;
78 int  time_stamping;
79 real inner_tolerance;
80 int  inner_loop;
81 int  convergence_rule;
82 int  original_markers;
83 real startrecombs;
84 int  print_dots;
85 
86 
state_init()87 void state_init()
88 {
89     parray(context,MAX_CONTEXTS,STATUS_CONTEXT);
90 }
91 
92 
reset_state()93 void reset_state()
94 {
95     allocate_context(context[0]);
96     state_init_values();
97     set_current_seq(NULL,FALSE);
98 }
99 
100 
undo_state()101 void undo_state()
102 { free_context(context[0]); state_init_values(); }
103 
104 
state_init_values()105 void state_init_values()
106 {
107 
108 /**** General ****/
109 
110     print_names=FALSE;
111     /* if TRUE, proper locus names will be displayed instead of locus numbers
112        in maps */
113 
114     tolerance=0.001;
115     /* convergence tolerance: a map is considered converged when two
116        successive maps have a log-likelihood difference less than the
117        tolerance */
118 
119     units=CENTIMORGANS; map_func(HALDANE);
120     /* if RECFRACS, recombination fractions will be displayed
121        rather than cM distances in short maps and other functions */
122 
123     auto_save=TRUE;
124     /* everything is saved upon quitting if TRUE */
125 
126 /**** two point ****/
127 
128     default_lod=3.0; default_theta=FIFTY_CM;
129     /* default linkage criteria used in two point */
130 
131     use_haplotypes=TRUE;
132     /* whether we should use the haplotype info or not - should be set only by
133        the haplotype command, which needs to do many other things when this
134        changes. NO LONGER REALLY A STATE VAR - IS FIXED AT TRUE. */
135 
136 /**** three point ****/
137 
138     use_three_pt=TRUE;
139     /* use fast 3pt extensions to place, etc by default */
140 
141     triplet_lod=3.0; triplet_theta=FIFTY_CM; triplet_num_links=2;
142     /* default linkage criteria used for three point triples */
143 
144     three_pt_threshold=4.0; three_pt_window=9;
145     /* likelihood diff for which a three point order is considered excluded.
146        NOTE THRESH IS >0, ALTHOUGH MOST OF THE TIME IT SHOULD BE NEGATED! */
147 
148     triplet_error_rate=0.0;
149     /* error rate to use in 3pt calculations, 0.0 means use_error_rate=FALSE,
150        LOCUS_ERROR_RATE means to use the per locus rates (as Npt does), or
151        a real# is a fixed error rate (must be 0.0 or fixed to use fast3pt) */
152 
153 /**** order maker ****/
154 
155     npt_threshold=2.0; npt_first_threshold=3.0; npt_window=7;
156     /* likelihood diffs for which a npt order is considered excluded.
157        NOTE THRESHS ARE >0, ALTHOUGH MOST OF THE TIME IT SHOULD BE NEGATED! */
158 
159     npt_min_indivs=1; npt_codominant=FALSE; npt_min_theta=ONE_CM;
160     /* default informativeness criteria */
161 
162     print_all_maps=FALSE;
163     /* for place, order, build, together, etc */
164 
165 /**** F2 Stuff, including error checker ****/
166 
167     fake_maps=FALSE;
168     /* bypass hmm ctm - for testing */
169 
170     use_error_rate=FALSE;
171     /* whether ctm should use the error kludge or not */
172 
173     error_lod_thresh=1.0;
174     /* error lod at which print_long_map barks, and which get summed into net*/
175 
176     error_single_thresh=2.0; error_net_thresh=3.0;
177     /* error lod at which order making barks */
178 
179 /**** Contexts, Partially Obsolete ****/
180 
181     num_contexts=1; active_context=0;
182     /* these never change as yet */
183 
184 /**** CEPH and Other Obsolete Stuff ****/
185 
186     sex_specific= context[active_context]->sex_specific= FALSE;
187     /* set to TRUE if sex specific maps to be made */
188 
189     triplet_sex=FALSE;
190     /* sex-specific flag for 3pt calculations - always FALSE for now */
191 
192     compress_DNA= context[active_context]->compress_DNA= TRUE;
193     /* always on - might be used in future */
194 
195     max_problem_size= context[active_context]->max_problem_size= 10000000;
196     /* (default = 10000000) above this threshold, maps will not
197        be computed, as they will take too long */
198 
199     inner_tolerance= 0.01;
200     /* inner convergence tolerance */
201 
202     inner_loop= TRUE;
203     /* inner looping switch */
204 
205     print_problem_size= FALSE;
206     /* problem sizes appear as each ceph map is computed */
207 
208     startrecombs= 0.05;
209     /* starting value for all recombination fractions */
210 
211     convergence_rule= 0;
212     /* unchangeable - perhaps useful in the future */
213 
214     time_stamping= FALSE;
215     /* if TRUE, each ctm map is timed and the time is printed */
216 
217     print_maps= FALSE; /* obsolete? */
218     /* if TRUE, full maps will be displayed as each map is computed in
219        some multi map functions (compare,try) */
220 
221     segregation_distortion=FALSE;  /* presently obsolete */
222     /* if TRUE, segregation distortion is accounted for in F2 map making */
223 
224     use_hmm=TRUE; /* also obsolete */
225     /* if TRUE use hmm ctm by default */
226 
227     print_all_errors= FALSE; /* unused? */
228     /* if TRUE, all candidate errors will be printed by commands like map,
229        otherwise only the worst N may be printed...  */
230 }
231 
232 
233 
234 /**** General ****/
235 
set_print_names()236 command set_print_names()
237 {
238     mapm_ready(ANY_DATA,0,0,NULL);
239     maybe_set_bool(&print_names);
240 }
241 
set_tolerance()242 command set_tolerance()
243 {
244     mapm_ready(ANY_DATA,0,0,NULL);
245     maybe_set_real(&tolerance,0.0000001,1.0,8.6);
246 }
247 
set_units()248 command set_units()
249 {
250     char type[TOKLEN+1];
251     mapm_ready(ANY_DATA,0,0,NULL);
252     get_one_arg(stoken,"",type);
253 
254     if (nullstr(type)) {
255 	if (units==RECFRACS)
256 	  print("the 'units' are currently recombination-fractions\n");
257 	else if (map_func_num()==HALDANE)
258 	  print("the 'units' are currently (Haldane) centimorgans\n");
259 	else if (map_func_num()==KOSAMBI)
260 	  print("the 'units' are currently (Kosambi) centimorgans\n");
261 	else send(CRASH);
262 
263     } else { /* have args */
264 	if (matches(type,"recombination fractions") ||
265 	    matches(type,"rec-fracs") ||
266 	    matches(type,"recombination-fractions") ||
267 	    matches(type,"rec fracs") ||
268 	    matches(type,"rf")) units=RECFRACS;
269 	else if (matches(type,"centimorgans") ||
270 		 matches(type,"cm")) units=CENTIMORGANS;
271 	else usage_error(1);
272 
273 	if (units==RECFRACS)
274 	  print("the 'units' are now recombination-fractions.\n");
275 	else if (map_func_num()==HALDANE)
276 	  print("the 'units' are now set to (Haldane) centimorgans.\n");
277 	else if (map_func_num()==KOSAMBI)
278 	  print("the 'units' are now set to (Kosambi) centimorgans.\n");
279 	else send(CRASH);
280     }
281 }
282 
set_cm_func()283 command set_cm_func()
284 {
285     int i, mapnum;
286 
287     char type[TOKLEN+1];
288     mapm_ready(ANY_DATA,0,FALSE,NULL);
289     get_one_arg(stoken,"",type);
290 
291     if (nullstr(type)) {
292 	sf(ps,"centimorgan function: %s\n",map_func_name()); pr();
293 	return;
294     }
295     /* assume here that the mapfunc names have different first letters */
296     for (i=0; i<num_map_functions; i++)
297       if (matches(type,maps[i].name)) {
298 	  map_func(i);
299 	  sf(ps,"centimorgan function: %s\n",map_func_name()); pr();
300 	  return;
301       }
302     error("unknown function name\nexpected either 'Haldane' or 'Kosambi'");
303 }
304 
305 
set_autosave()306 command set_autosave()
307 {
308     mapm_ready(ANY_DATA,0,0,NULL);
309     maybe_set_bool(&auto_save);
310 }
311 
set_more_mode()312 command set_more_mode()
313 {
314     mapm_ready(MAYBE_DATA,0,0,NULL);
315     maybe_set_bool(&more_mode);
316 }
317 
318 
319 /**** two-point ****/
320 
321 #define DEF_LINK_LOD    "default LOD score threshold is %.2lf\n"
322 #define DEF_LINK_THETA  "default %s threshold is %.2lf\n"
set_default_linkage()323 command set_default_linkage()
324 {
325     real lod, theta;
326     bool have_theta=FALSE;
327 
328     if (!nullstr(args)) {
329 	if (!rtoken(&args,rREQUIRED,&lod) || !rrange(&lod,0.0,100.0))
330 	  set_usage_error("a real number from 0 to 100");
331 	if (!nullstr(args)) {
332 	    if (!rtoken(&args,rREQUIRED,&theta) || !input_dist(&theta))
333 	      set_usage_error("a real number, greater than zero (cm or rf)");
334 	    else have_theta= TRUE;
335 	}
336 	default_lod= lod;
337 	if (have_theta) default_theta=theta;
338     }
339 
340     sf(ps,DEF_LINK_LOD,default_lod); pr();
341     if (units!=RECFRACS) sf(ps,DEF_LINK_THETA,"centimorgan distance",
342 		      ((*mapfunction->rec_to_dist)(default_theta))*100.0);
343     else sf(ps,DEF_LINK_THETA,"recombination-fraction",default_theta);
344     pr();
345 }
346 
347 
348 /**** three-point ****/
349 
set_use_3pt()350 command set_use_3pt()
351 {
352     mapm_ready(ANY_DATA,0,0,NULL);
353     maybe_set_bool(&use_three_pt);
354 }
355 
356 #define DEF_3PT_LOD   "triplet LOD score threshold is %.2lf\n"
357 #define DEF_3PT_THETA "triplet %s threshold is %.2lf\n"
358 #define DEF_3PT_NUM   "number of linkages required is %2d\n"
set_3pt_linkage()359 command set_3pt_linkage()
360 {
361     real lod, theta;
362     bool have_theta=FALSE, have_num=FALSE;
363     int num;
364 
365     mapm_ready(ANY_DATA,0,0,NULL);
366     if (!nullstr(args)) {
367 	if (!rtoken(&args,rREQUIRED,&lod) || !rrange(&lod,0.0,100.0))
368 	  set_usage_error("a real number from 0 to 100");
369 	if (!nullstr(args)) {
370 	    if (!rtoken(&args,rREQUIRED,&theta) || !input_dist(&theta))
371 	      set_usage_error("a real number, greater than zero (cm or rf)");
372 	    else have_theta= TRUE;
373 	}
374 	if (!nullstr(args)) { /* still */
375 	    if (!itoken(&args,0,&num) || !irange(&num,2,3))
376 	      set_usage_error("an integer number, either 2 or 3");
377 	    else have_num= TRUE;
378 	}
379 	triplet_lod= lod;
380 	if (have_theta) triplet_theta=theta;
381 	if (have_num)   triplet_num_links=num;
382     }
383     sf(ps,DEF_3PT_LOD,triplet_lod); pr();
384     if (units!=RECFRACS) sf(ps,DEF_3PT_THETA,"centimorgan distance",
385 		      ((*mapfunction->rec_to_dist)(triplet_theta))*100.0);
386     else sf(ps,DEF_3PT_THETA,"recombination-fraction",triplet_theta);
387     pr();
388     sf(ps,DEF_3PT_NUM,triplet_num_links); pr();
389 }
390 
391 #define TRIP_THRESH \
392   "triplet log-likelihood exclusion threshold is %.2lf.\nwindow size is %d.\n"
set_3pt_threshold()393 command set_3pt_threshold()
394 {
395     real like;
396     int wind, have_num=FALSE;
397 
398     mapm_ready(ANY_DATA,0,0,NULL);
399     if (!nullstr(args)) {
400 	if (!rtoken(&args,rREQUIRED,&like) || !rrange(&like,0.0,100.0))
401 	  set_usage_error("a real number from 0 to 100");
402 	if (!nullstr(args)) { /* still */
403 	    if (!itoken(&args,0,&wind) || !irange(&wind,3,99) || (wind%2)!=1)
404 	      set_usage_error("an odd integer number from 3 to 99");
405 	    else have_num=TRUE;
406 	}
407 	three_pt_threshold=like;
408 	if (have_num) three_pt_window=wind;
409     }
410     sf(ps,TRIP_THRESH,three_pt_threshold,three_pt_window); pr();
411 }
412 
413 #define SET_3ERR_USAGE \
414   "'on', 'off', or a real number from 0 to 10 (percent chance of error)"
set_3pt_errors()415 command set_3pt_errors()
416 {
417     real rate;
418 
419     mapm_ready(ANY_DATA,0,0,NULL);
420     if (!nullstr(args)) {
421 	if (rtoken(&args,rREQUIRED,&rate)) {
422 	    if (!rrange(&rate,0.0,10.0)) set_usage_error(SET_3ERR_USAGE);
423 	    triplet_error_rate=rate/100.0;
424 	} else if (nmatches(args,"on",2))  triplet_error_rate=LOCUS_ERROR_RATE;
425 	else if (nmatches(args,"off",2)) triplet_error_rate=0.0;
426 	else set_usage_error(SET_3ERR_USAGE);
427     }
428     if (triplet_error_rate==0.0) print("'triple error detection' is off.\n");
429     else if (triplet_error_rate==LOCUS_ERROR_RATE)
430       print("'triple error detection' is on.\n");
431     else {
432 	print("'triple error detection' in three-point analysis is on.\n");
433 	sf(ps,"'error probability' for all loci is fixed at %.2lf%%.\n",
434 	   triplet_error_rate*100.0);
435     }
436 }
437 
438 
439 /**** Order Maker ****/
440 
441 #define NPT_THRESH1 \
442 "multipoint exclusion threshold is %.2lf.\nwindow size is %d.\n"
443 #define NPT_THRESH2 \
444 "multipoint exclusion threshold is %.2lf.\nwindow size is %d.\n\
445 strict multipoint exclusion threshold is %.2lf.\n"
446 
set_npt_threshold()447 command set_npt_threshold()
448 {
449     real like, like2;
450     int wind, have_num=FALSE, have_2nd=FALSE;
451 
452     mapm_ready(ANY_DATA,0,0,NULL);
453     if (!nullstr(args)) {
454 	if (!rtoken(&args,rREQUIRED,&like) || !rrange(&like,0.0,100.0))
455 	  set_usage_error("a real number from 0 to 100");
456 	if (!nullstr(args)) { /* still */
457 	    if (!itoken(&args,0,&wind) || !irange(&wind,3,99) || (wind%2)!=1)
458 	      set_usage_error("an odd integer number from 3 to 99");
459 	    else have_num=TRUE;
460 	    if (!nullstr(args)) { /* still */
461 		if (!rtoken(&args,rREQUIRED,&like2)||!rrange(&like2,0.0,100.0))
462 		  set_usage_error("a real number from 0 to 100");
463 		else have_2nd=TRUE;
464 	    }
465 	}
466 	npt_threshold=like;
467 	if (have_num) npt_window=wind;
468 	if (have_2nd) npt_first_threshold=like2;
469 	  else npt_first_threshold=max(npt_first_threshold,npt_threshold);
470     }
471     if (npt_threshold==npt_first_threshold)
472       { sf(ps,NPT_THRESH1,npt_threshold,npt_window); pr(); }
473     else
474       { sf(ps,NPT_THRESH2,npt_threshold,npt_window,npt_first_threshold);pr(); }
475 }
476 
477 
478 #define INF_THRESHS \
479 "Informativeness Criteria: min Distance %s, min #Individuals %d%s\n"
480 #define CD_NOT \
481 "slecting codominant markers (or not) does not apply to the loaded data"
set_inf_threshold()482 command set_inf_threshold()
483 {
484     real theta;
485     int indivs, codom, have_indivs=FALSE, have_cd=FALSE;
486 
487     mapm_ready(F2_DATA,0,0,NULL);
488     if (!nullstr(args)) {
489 	if (!rtoken(&args,rREQUIRED,&theta) || !input_dist(&theta))
490 	  set_usage_error("a map distance, cM or RF");
491 	if (!nullstr(args)) { /* still */
492 	    if (!itoken(&args,0,&indivs) ||
493 		!irange(&indivs,3,raw.data.f2.num_indivs))
494 	      set_usage_error("an integer from 1 to #individuals in data set");
495 	    else have_indivs=TRUE;
496 	    if (!nullstr(args)) { /* still */
497 		if (matches(args,"codominant") || streq(args,"cd"))
498 		  { codom=TRUE; have_cd=TRUE; }
499 		else if (matches("any",args) || matches("all",args))
500 		  { codom=FALSE; have_cd=TRUE; }
501 		else set_usage_error("either 'codominant' or 'any'");
502 	    }
503 	}
504 	if (have_cd &&
505 	    raw.data.f2.cross_type!=F2_INTERCROSS &&
506 	    raw.data.f2.cross_type!=F3_SELF) error(CD_NOT);
507 	npt_min_theta=theta;
508 	if (have_indivs) npt_min_indivs=indivs;
509 	if (have_cd)     npt_codominant=codom;
510     }
511     sf(ps,INF_THRESHS,rag(rf2str(npt_min_theta)),npt_min_indivs,
512        (npt_codominant ? "\n(codominant markers only)":"")); pr();
513 }
514 
515 
set_print_all_maps()516 command set_print_all_maps()
517 {
518     mapm_ready(ANY_DATA,0,0,NULL);
519     maybe_set_bool(&print_all_maps);
520 }
521 
522 
523 
524 /**** F2 and error checker ****/
525 
set_fake_maps()526 command set_fake_maps()
527 {
528     mapm_ready(F2,0,0,NULL);
529     maybe_set_bool(&fake_maps);
530 }
531 
set_use_error_rate()532 command set_use_error_rate()
533 {
534     mapm_ready(F2,0,0,NULL);
535     maybe_set_bool(&use_error_rate);
536 }
537 
538 #define ERROR_THRESHES "error LOD threshold to print: %.2lf\n\
539 error LOD thresholds for mapping: single: %.2lf, net: %.2lf\n"
set_error_lod_thresh()540 command set_error_lod_thresh()
541 {
542     real t1, t2, t3;
543 
544     mapm_ready(F2,0,0,NULL);
545     if (!nullstr(args)) {
546 	if (!rtoken(&args,rREQUIRED,&t1) || !rrange(&t1,0.0,99.0))
547 	  set_usage_error("a real number from 0 to 99");
548 	if (!nullstr(args)) {
549 	    if (!rtoken(&args,rREQUIRED,&t2) || !rrange(&t2,0.0,99.0))
550 	      set_usage_error("a real number from 0 to 99");
551 	    if (!nullstr(args)) {
552 		if (!rtoken(&args,rREQUIRED,&t3) || !rrange(&t2,0.0,99.0))
553 		  set_usage_error("a real number from 0 to 99");
554 	    }
555 	}
556 	error_lod_thresh=t1; error_single_thresh=t2; error_net_thresh=t3;
557     }
558     sf(ps,ERROR_THRESHES,error_lod_thresh,error_single_thresh,
559        error_net_thresh); pr();
560 }
561 
562 
563 /**************** State Contexts ****************/
564 
allocate_context(con)565 void allocate_context(con)
566 STATUS_CONTEXT *con;
567 {
568     TABLE *seqhist=NULL, *names=NULL;
569 
570     run {
571 	con->sex_specific= FALSE;
572 	con->compress_DNA= TRUE;
573 	con->max_problem_size= 10000000;
574 #ifdef HAVE_CEPH
575 	con->use_number= USE_NO_DATA;
576 #endif
577 	con->named_sequences= allocate_table(MAX_NAMED_SEQS,MAX_SEQ_LEN,
578 					     EXPANDS_BY(MAX_NAMED_SEQS),
579 					     INDEX_BY_NAME);
580 	con->sequence_history= allocate_table(MAX_HISTORY_SEQS,MAX_SEQ_LEN,
581 					      CANT_EXPAND,INDEX_BY_NUMBER);
582 	con->seq_history_num= next_entry_number(con->sequence_history);
583 
584     } on_exit {
585 	free_context(con);
586 	relay_messages;
587     }
588 }
589 
free_context(con)590 void free_context(con)
591 STATUS_CONTEXT *con;
592 {
593     free_table(con->named_sequences);
594     free_table(con->sequence_history);
595 }
596 
597 
change_context(new_context)598 bool change_context(new_context)
599 int new_context;
600 {
601     if(context[new_context] != NULL) {
602 	active_context = new_context;
603 	/* set the globals */
604 	sex_specific = context[active_context]->sex_specific;
605 	compress_DNA = context[active_context]->compress_DNA;
606 	max_problem_size = context[active_context]->max_problem_size;
607 #ifdef HAVE_CEPH
608 	if(raw.data_type == CEPH)
609 	  raw.data.ceph.use_number = context[active_context]->use_number;
610 #endif
611 	return(TRUE);
612     } else {
613 	return(FALSE);
614     }
615 }
616 
617 
create_new_context(new_context)618 bool create_new_context(new_context)
619 int new_context;
620 {
621     if(context[new_context] != NULL || new_context > MAX_CONTEXTS)
622       return(FALSE);
623 
624     allocate_context(context[new_context]);
625 
626     /* take current values as defaults */
627     context[new_context]->sex_specific = context[active_context]->sex_specific;
628     context[new_context]->compress_DNA = context[active_context]->compress_DNA;
629     context[new_context]->use_number = context[active_context]->use_number;
630     context[new_context]->max_problem_size =
631       context[active_context]->max_problem_size;
632 
633     return(TRUE);
634 }
635 
636 
637 #ifdef OBSOLETE
kill_context(con,save_it)638 void kill_context(con,save_it)
639 STATUS_CONTEXT *con;
640 bool save_it;
641 {
642     char *name,*seqnce,*err;
643 
644     if(save_it) {
645 	for(Te=con->named_sequences->list; Te!=NULL; Te=Te->next) {
646 	    if(!name_sequence(Te->id.name,Te->string,&err))
647 	      error(err);
648 	}
649     }
650     free_context(con);
651 }
652 #endif
653 
654 
655 /**** CEPH/OBSOLETE? ****/
656 
657 #ifdef OBSOLETE
set_sex_specific()658 command set_sex_specific()
659 {
660     maybe_set_bool(&sex_specific);
661     context[active_context]->sex_specific = sex_specific;
662 }
663 
set_3pt_sex()664 command set_3pt_sex() /* unused */
665 {
666     mapm_ready(ANY_DATA,0,0,NULL);
667     maybe_set_bool(&triplet_sex);
668 }
669 
set_segregation_distortion()670 command set_segregation_distortion()
671 {
672     maybe_set_bool(&segregation_distortion);
673 }
674 
set_print_maps()675 command set_print_maps()
676 {
677     maybe_set_bool(&print_maps);
678 }
679 
set_inner_tolerance()680 command set_inner_tolerance()
681 {
682     maybe_set_real(&inner_tolerance,0.0000001,1.0,8.6);
683 }
684 
set_startrecombs()685 command set_startrecombs()
686 {
687     maybe_set_real(&startrecombs,0.0,0.5,4.2);
688 }
689 
set_inner_loop()690 command set_inner_loop()
691 {
692     maybe_set_bool(&inner_loop);
693 }
694 
set_print_problem_size()695 command set_print_problem_size()
696 {
697     maybe_set_bool(&print_problem_size);
698 }
699 
set_max_problem_size()700 command set_max_problem_size()
701 {
702     maybe_set_long(&max_problem_size,100,100000000);
703     context[active_context]->max_problem_size = max_problem_size;
704 }
705 
set_time_stamping()706 command set_time_stamping()
707 {
708     maybe_set_bool(&time_stamping);
709 }
710 
set_print_dots()711 command set_print_dots()
712 {
713     maybe_set_bool(&print_dots);
714 }
715 
set_use_hmm()716 command set_use_hmm()
717 {
718     maybe_set_bool(&use_hmm);
719 }
720 
set_use_haplotypes()721 command set_use_haplotypes()
722 {
723     maybe_set_bool(&use_haplotypes);
724 }
725 #endif /* OBSOLETE */
726 
727 
728 
729 /**************** Save and Load Status info ****************/
730 
731 
write_status(fp)732 void write_status(fp)
733 FILE *fp;
734 {
735     int i, usenum;
736 
737     fprint(fp,WRS("*MapmakerStatusInfo:\n"));
738 
739     sf(ps,"*PrintNames: %d\n",print_names); fpr(fp);
740     sf(ps,"*Tolerance: %lf\n",tolerance); fpr(fp);
741     sf(ps,"*Units: %d\n",units); fpr(fp);
742     sf(ps,"*MapFunc: %d\n",map_func_num()); fpr(fp);
743 
744     sf(ps,"*DefaultLOD: %lf\n",default_lod); fpr(fp);
745     sf(ps,"*DefaultTheta: %lf\n",default_theta); fpr(fp);
746 
747     sf(ps,"*UseThreePoint: %d\n",use_three_pt); fpr(fp);
748     sf(ps,"*TripletLOD: %lf\n",triplet_lod); fpr(fp);
749     sf(ps,"*TripletTheta: %lf\n",triplet_theta); fpr(fp);
750     sf(ps,"*TripletNumLinks: %d\n",triplet_num_links); fpr(fp);
751     sf(ps,"*ThreePointThreshold: %lf\n",three_pt_threshold); fpr(fp);
752     sf(ps,"*ThreePointWindow: %d\n",three_pt_window); fpr(fp);
753     sf(ps,"*TripletErrorRate: %lf\n",triplet_error_rate); fpr(fp);
754 
755     sf(ps,"*NptThreshold: %lf\n",npt_threshold); fpr(fp);
756     sf(ps,"*NptFirstThreshold: %lf\n",npt_first_threshold); fpr(fp);
757     sf(ps,"*NptWindow: %d\n",npt_window); fpr(fp);
758     sf(ps,"*NptMinIndivs: %d\n",npt_min_indivs); fpr(fp);
759     sf(ps,"*NptCodominant: %d\n",npt_codominant); fpr(fp);
760     sf(ps,"*NptMinTheta: %lf\n",npt_min_theta); fpr(fp);
761     sf(ps,"*PrintAllMaps: %d\n",print_all_maps); fpr(fp);
762 
763     sf(ps,"*UseErrorRate: %d\n",use_error_rate); fpr(fp);
764     sf(ps,"*ErrorLodThreshold: %lf\n",error_lod_thresh); fpr(fp);
765     sf(ps,"*ErrorSingleThreshold: %lf\n",error_single_thresh); fpr(fp);
766     sf(ps,"*ErrorNetThreshold: %lf\n",error_net_thresh); fpr(fp);
767 
768     sf(ps,"*Contexts: %d\n",num_contexts); fpr(fp);
769     sf(ps,"*ActiveContext: %d\n",active_context); fpr(fp);
770     fnl(fp);
771 
772     for (i=0; i<num_contexts; i++) {
773       sf(ps,"*Context %d\n",i+1); fpr(fp);
774       sf(ps,"*SexSpecific: %d\n",context[i]->sex_specific); fpr(fp);
775       sf(ps,"*CompressDNA: %d\n",context[i]->compress_DNA); fpr(fp);
776       if (raw.data_type==CEPH) usenum=context[i]->use_number; else usenum=0;
777       sf(ps,"*UseNum: %d\n",usenum); fpr(fp);
778       sf(ps,"*MaxProblemSize: %ld\n",context[i]->max_problem_size); fpr(fp);
779 
780       sf(ps,"*SavedNames: %d\n",
781 	 count_table_entries(context[i]->named_sequences)); fpr(fp);
782       save_table(context[i]->named_sequences,fp,INDEX_BY_NAME);
783 
784       sf(ps,"*SequenceHistory: %d\n",
785 	 count_table_entries(context[i]->sequence_history)); fpr(fp);
786       save_table(context[i]->sequence_history,fp,INDEX_BY_NUMBER);
787     }
788 }
789 
790 
read_status(fp)791 void read_status(fp)
792 FILE *fp;
793 {
794     int i, mapnum, usenum, num;
795     char word[TOKLEN+1];
796 
797     fscanf(fp,"%30s\n",word);
798     if (!streq(word,"*MapmakerStatusInfo:")) send(CRASH);
799 
800     fscanf(fp,"%*s %d\n", &print_names);
801     fscanf(fp,"%*s %lf\n",&tolerance);
802     fscanf(fp,"%*s %d\n", &units);
803     fscanf(fp,"%*s %d\n", &mapnum); map_func(mapnum);
804 
805     fscanf(fp,"%*s %lf\n",&default_lod);
806     fscanf(fp,"%*s %lf\n",&default_theta);
807 
808     fscanf(fp,"%*s %d\n", &use_three_pt);
809     fscanf(fp,"%*s %lf\n",&triplet_lod);
810     fscanf(fp,"%*s %lf\n",&triplet_theta);
811     fscanf(fp,"%*s %d\n", &triplet_num_links);
812     fscanf(fp,"%*s %lf\n",&three_pt_threshold);
813     fscanf(fp,"%*s %d\n", &three_pt_window);
814     fscanf(fp,"%*s %lf\n",&triplet_error_rate);
815 
816     fscanf(fp,"%*s %lf\n",&npt_threshold);
817     fscanf(fp,"%*s %lf\n",&npt_first_threshold);
818     fscanf(fp,"%*s %d\n", &npt_window);
819     fscanf(fp,"%*s %d\n", &npt_min_indivs);
820     fscanf(fp,"%*s %d\n", &npt_codominant);
821     fscanf(fp,"%*s %lf\n",&npt_min_theta);
822     fscanf(fp,"%*s %d\n", &print_all_maps);
823 
824     fscanf(fp,"%*s %d\n", &use_error_rate);
825     fscanf(fp,"%*s %lf\n",&error_lod_thresh);
826     fscanf(fp,"%*s %lf\n",&error_single_thresh);
827     fscanf(fp,"%*s %lf\n",&error_net_thresh);
828 
829     fscanf(fp,"%20s %d\n",word,&num_contexts);
830     if (!streq(word,"*Contexts:")) send(CRASH);
831     fscanf(fp,"%*s %d",&active_context);
832 
833     for (i=0; i<num_contexts; i++) { /* Fix this... */
834 	fscanf(fp,"%*s %*d\n");
835 	fscanf(fp,"%*s %d\n",&sex_specific);
836 	context[i]->sex_specific= sex_specific;
837 	fscanf(fp,"%*s %d\n",&compress_DNA);
838 	context[i]->compress_DNA = compress_DNA;
839 	fscanf(fp,"%*s %d\n",&usenum);
840 
841 #ifdef HAVE_CEPH
842 	if (raw.data_type==CEPH) {
843 	    raw.data.ceph.use_number=usenum;
844 	    context[i]->use_number=usenum;
845 	}
846 #endif
847 	fscanf(fp,"%*s %ld\n",&max_problem_size);
848 	context[i]->max_problem_size=max_problem_size;
849 	fscanf(fp,"%*s %d\n",&num);  /* "Saved names: %d" header */
850 	load_table(context[i]->named_sequences,fp,INDEX_BY_NAME,num);
851 	fscanf(fp,"%*s %d\n",&num); context[i]->seq_history_num=num;
852 	load_table(context[i]->sequence_history,fp,INDEX_BY_NUMBER,num);
853     }
854 
855     if (the_seq_history_num>0) set_current_seq(WRS("none"),FALSE);
856 }
857