[med-svn] [staden] 03/08: Imported Upstream version 2.0.0b11

Andreas Tille tille at debian.org
Thu Jul 14 18:29:34 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository staden.

commit 6604903cf711bee419046f72f7810a0bfc9d3eec
Author: Andreas Tille <tille at debian.org>
Date:   Thu Jul 14 20:06:46 2016 +0200

    Imported Upstream version 2.0.0b11
---
 ChangeLog                 | 2564 ++++++++++++++++++++++++++++++-
 Makefile.in               |    2 +-
 Misc/Makefile             |   66 +
 Misc/array.c              |   25 +
 Misc/array.h              |    4 +
 NEWS                      |  248 ++-
 README.build              |    4 +-
 abi/Makefile              |   10 +
 alf/Makefile              |    1 +
 configure                 |  245 +--
 configure.in              |    2 +-
 convert/Makefile          |   73 +
 copy_reads/Makefile       |   61 +
 copy_reads/copy_reads.c   |    4 +-
 eba/Makefile              |    5 +
 eba/conf.c                |    2 +-
 find_renz/Makefile        |    8 +
 g/Makefile                |   82 +
 gap4/Makefile             | 3694 +++++++++++++++++++++++++++++++++++++++++++++
 gap4/contig_editor.tcl    |   24 +-
 gap4/edMutations.c        |    2 +-
 gap4/gap-error.c          |    2 +-
 gap4/gaprc_menu_full      |    4 +-
 gap4/show_relationships.c |    6 +-
 gap5/Makefile             | 3406 ++++++++++++++++++++++++++++++++++++++++-
 gap5/ace.c                |    2 +-
 gap5/actf.c               |    4 +-
 gap5/assemble_single.tcl  |   48 +-
 gap5/auto_break.c         |   77 +-
 gap5/b+tree2.c            |    2 +
 gap5/baf.c                |    2 +-
 gap5/break_contig.c       |   17 +-
 gap5/check_assembly.c     |   10 +-
 gap5/configure.tcl        |  101 +-
 gap5/consen.c             |  147 +-
 gap5/consen.h             |    2 +-
 gap5/consen.tcl           |  117 +-
 gap5/consensus.c          |  381 ++++-
 gap5/consensus.h          |   14 +
 gap5/contig_editor.tcl    |  289 +++-
 gap5/contig_extend.c      |    4 +-
 gap5/contig_id.tcl        |    6 +-
 gap5/cs-object.h          |    2 +
 gap5/depth.tcl            |  267 +++-
 gap5/dis_readings.c       |    9 +-
 gap5/dis_readings.tcl     |   33 +-
 gap5/do_fij.c             |    9 +-
 gap5/editor_join.c        |    2 +-
 gap5/editor_search.c      |    8 +-
 gap5/editor_view.c        |  146 +-
 gap5/export_contigs.c     |  554 +++++--
 gap5/export_contigs.tcl   |   28 +-
 gap5/export_snps.c        |  350 +++++
 gap5/export_snps.h        |    9 +
 gap5/fasta.c              |    6 +-
 gap5/fij.c                |   27 +-
 gap5/fij.tcl              |   68 +-
 gap5/find_haplotypes.0.c  |  456 ++++++
 gap5/find_haplotypes.c    |  891 +++++++++++
 gap5/find_haplotypes.h    |   10 +
 gap5/find_oligo.c         |    4 +-
 gap5/find_repeats.c       |    2 +-
 gap5/g-alloc.c            |    6 +-
 gap5/g-request.c          |    1 +
 gap5/gap5.tcl             |   15 +-
 gap5/gap5_cmd.tcl         |  155 +-
 gap5/gap5_del_test.tcl    |  321 +++-
 gap5/gap5_thrash.tcl      |    5 +-
 gap5/gap5rc               |   10 +
 gap5/gap5rc_menu_full     |   18 +-
 gap5/gap_canvas_box.c     |    3 +-
 gap5/gap_globals.c        |    8 +-
 gap5/gap_globals.h        |    3 +
 gap5/gap_globals.tcl      |   43 +
 gap5/gap_range.c          |    2 +-
 gap5/hash_lib.c           |   13 +-
 gap5/import_contigs.tcl   |    2 +-
 gap5/import_gff.c         |    2 +-
 gap5/interval_tree.c      |  698 +++++++++
 gap5/interval_tree.h      |   89 ++
 gap5/libraries.tcl        |   81 +-
 gap5/list_proc.tcl        |   88 +-
 gap5/newgap5_cmds.c       |  238 ++-
 gap5/newgap_structs.h     |    5 +
 gap5/ng_fb_cmds.tcl       |    3 +
 gap5/qualIO.c             |   21 +-
 gap5/quality_plot.c       |   46 +-
 gap5/replay_log.tcl       |  401 +++++
 gap5/sam_index.c          |  158 +-
 gap5/sam_pileup.h         |    1 +
 gap5/shuffle_pads.c       | 1730 +++++++++++++++++++--
 gap5/shuffle_pads.h       |   14 +-
 gap5/shuffle_pads.tcl     |   31 +-
 gap5/str_finder.c         |  341 +++++
 gap5/str_finder.h         |   37 +
 gap5/tag_plot.c           |    3 -
 gap5/tclIndex             |    6 +
 gap5/template_display.c   |    4 +-
 gap5/template_draw.c      |    6 +
 gap5/tg_anno.c            |    7 +-
 gap5/tg_bin.c             |   39 +-
 gap5/tg_cache.c           |  200 ++-
 gap5/tg_check.c           |   44 +-
 gap5/tg_contig.c          | 1587 +++++++++++++------
 gap5/tg_contig.h          |   64 +-
 gap5/tg_gio.c             |   21 +-
 gap5/tg_gio.h             |    9 +-
 gap5/tg_iface_g.c         |   45 +-
 gap5/tg_index.c           |   11 +-
 gap5/tg_index.h           |    2 +
 gap5/tg_index_common.c    |  257 +++-
 gap5/tg_library.c         |   46 +-
 gap5/tg_library.h         |   18 +
 gap5/tg_sequence.c        |  205 ++-
 gap5/tg_sequence.h        |   25 +-
 gap5/tg_struct.h          |   57 +-
 gap5/tg_tcl.c             |  445 +++++-
 gap5/tg_utils.c           |   42 +-
 gap5/tk-io-reg.c          |    3 +-
 gap5/tkEditor.c           |   35 +
 gap5/tkEditor.h           |    6 +-
 gap5/tman_interface.c     |   12 +-
 gap5/utlist.h             |  761 ++++++++++
 gap5/zfio.c               |  128 --
 gap5/zfio.h               |   23 -
 get_scf_field/Makefile    |    3 +
 global.mk                 |    7 +-
 haplo/Makefile            |   89 ++
 hetins/hetins.c           |    1 +
 init_exp/Makefile         |    2 +
 make_weights/Makefile     |    4 +
 mutlib/Makefile           |  338 +++++
 polyA_clip/Makefile       |    9 +
 prefinish/Makefile        |  340 +++++
 primer3/src/ntdpal_main.c |    2 +-
 primer3/src/primer3_lib.c |    2 +-
 qclip/Makefile            |   13 +
 screen_seq/Makefile       |    5 +
 seq_utils/Makefile        |   85 +-
 seq_utils/align_lib.c     |  225 ++-
 seq_utils/align_lib.h     |   13 +-
 seq_utils/dna_utils.c     |   95 +-
 seq_utils/dna_utils.h     |    2 +-
 spin/Makefile             |  765 ++++++++++
 staden_config.h.in        |    5 +
 stops/Makefile            |    1 +
 system.mk.in              |    2 +-
 text_utils/Makefile       |    4 +
 tk_utils/Makefile         |  174 +++
 tk_utils/func_edit.tcl    |   25 +
 tk_utils/help.tcl         |    6 +-
 tk_utils/init.tcl         |    2 +
 tk_utils/tclIndex         |    2 +
 tk_utils/xcombobox.tcl    |   29 +-
 tracediff/Makefile        |    5 +
 tracediff/main.cpp        |   38 +-
 vector_clip/Makefile      |    5 +
 157 files changed, 23382 insertions(+), 2264 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3361a6c..b43ec43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,2565 @@
+========================================================================
+RELEASED 2.0.0b11-2016
+
+------------------------------------------------------------------------
+r4067 | jkbonfield | 2016-04-20 12:04:17 +0100 (Wed, 20 Apr 2016) | 2 lines
+Changed paths:
+   M /staden/trunk/src/eba/conf.c
+
+Due to io_lib changes, change from min() to MIN().
+
+------------------------------------------------------------------------
+r4065 | jkbonfield | 2016-04-19 14:56:02 +0100 (Tue, 19 Apr 2016) | 7 lines
+Changed paths:
+   M /staden/trunk/src/README.build
+
+Fixed io_lib version number needed.
+
+This may not be absolutely correct (no doubt a few versions before is
+also fine), but for certain it doesn't work with the stated version
+number and I don't have time to exhaustively check which version is
+new enough.
+
+------------------------------------------------------------------------
+r4058 | jkbonfield | 2016-03-24 10:26:12 +0000 (Thu, 24 Mar 2016) | 5 lines
+Changed paths:
+   M /staden/trunk/src/gap5/interval_tree.c
+
+Interval_tree and interval_node no longer have typedef twice.
+This tripped up early gcc versions (4.4 is fine, 4.1 is not).
+
+Bug reported by Martin Mokrejs.
+
+------------------------------------------------------------------------
+r4045 | jkbonfield | 2016-03-21 12:49:04 +0000 (Mon, 21 Mar 2016) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+
+Fixed broken commit r3930 in gap5_cmd.tcl.  This caused a syntax error.
+
+------------------------------------------------------------------------
+r4021 | jkbonfield | 2016-02-23 14:40:25 +0000 (Tue, 23 Feb 2016) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+   M /staden/trunk/src/gap5/tg_contig.h
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Fixed tcl_read_depth call to actually compute the depth rather than
+use the unfinished tracks.
+
+Added copy_refpos function to C and Tcl.  At present these are unused,
+but being present in Tcl means we can use these during debugging or
+experimentation within the Tcl console.
+
+------------------------------------------------------------------------
+r4020 | jkbonfield | 2016-02-23 12:37:49 +0000 (Tue, 23 Feb 2016) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/ace.c
+   M /staden/trunk/src/gap5/baf.c
+   M /staden/trunk/src/gap5/fasta.c
+   M /staden/trunk/src/gap5/import_gff.c
+   M /staden/trunk/src/gap5/tg_index.c
+   M /staden/trunk/src/gap5/tg_index_common.c
+   D /staden/trunk/src/gap5/zfio.c
+   D /staden/trunk/src/gap5/zfio.h
+
+Removed zfio.c in favour of io_lib's copy.
+
+------------------------------------------------------------------------
+r4016 | jkbonfield | 2016-02-22 11:43:26 +0000 (Mon, 22 Feb 2016) | 4 lines
+Changed paths:
+   M /staden/trunk/src/copy_reads/copy_reads.c
+   M /staden/trunk/src/gap5/do_fij.c
+   M /staden/trunk/src/gap5/tg_index.c
+   M /staden/trunk/src/primer3/src/ntdpal_main.c
+   M /staden/trunk/src/primer3/src/primer3_lib.c
+
+Applied Debian spelling patch:
+
+https://anonscm.debian.org/viewvc/debian-med/trunk/packages/staden/trunk/debian/patches/spelling.patch?revision=21433&view=markup
+
+------------------------------------------------------------------------
+r4015 | jkbonfield | 2016-02-22 11:33:20 +0000 (Mon, 22 Feb 2016) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap4/gap-error.c
+   M /staden/trunk/src/gap4/show_relationships.c
+   M /staden/trunk/src/system.mk.in
+
+Applied debian hardening patch:
+
+https://anonscm.debian.org/viewvc/debian-med/trunk/packages/staden/trunk/debian/patches/hardening.patch?revision=16751&view=markup
+https://anonscm.debian.org/viewvc/debian-med/trunk/packages/staden/trunk/debian/patches/hardening_format-security.patch?revision=15859&view=markup
+
+
+------------------------------------------------------------------------
+r4014 | jkbonfield | 2016-02-22 11:29:21 +0000 (Mon, 22 Feb 2016) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap4/contig_editor.tcl
+
+Fix to cope with newer window managers.
+
+The contig editor should no longer appear at zero height.
+
+------------------------------------------------------------------------
+r4002 | jkbonfield | 2016-02-03 18:08:33 +0000 (Wed, 03 Feb 2016) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consen.tcl
+   M /staden/trunk/src/gap5/contig_id.tcl
+
+Fixed a bug where using the contig selector or contig list to fill out a contig name in a dialogue box, without then doing anything else at all except hitting OK in that dialogue, could cause the contig name validity check to fail.
+
+------------------------------------------------------------------------
+r3999 | daviesrob | 2016-01-25 10:20:34 +0000 (Mon, 25 Jan 2016) | 12 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+   M /staden/trunk/src/gap5/auto_break.c
+   M /staden/trunk/src/gap5/break_contig.c
+   M /staden/trunk/src/gap5/consensus.c
+   M /staden/trunk/src/gap5/contig_extend.c
+   M /staden/trunk/src/gap5/dis_readings.c
+   M /staden/trunk/src/gap5/do_fij.c
+   M /staden/trunk/src/gap5/editor_join.c
+   M /staden/trunk/src/gap5/export_contigs.c
+   M /staden/trunk/src/gap5/export_snps.c
+   M /staden/trunk/src/gap5/fij.c
+   M /staden/trunk/src/gap5/find_haplotypes.c
+   M /staden/trunk/src/gap5/gap_canvas_box.c
+   M /staden/trunk/src/gap5/interval_tree.c
+   M /staden/trunk/src/gap5/interval_tree.h
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/str_finder.c
+   M /staden/trunk/src/gap5/tag_plot.c
+   M /staden/trunk/src/gap5/template_display.c
+   M /staden/trunk/src/gap5/tg_bin.c
+   M /staden/trunk/src/gap5/tg_contig.c
+   M /staden/trunk/src/gap5/tg_iface_g.c
+   M /staden/trunk/src/gap5/tg_tcl.c
+   M /staden/trunk/src/gap5/tman_interface.c
+
+Fix some compiler warnings.
+
+Mainly unused variables, plus a couple of missing prototypes.  Includes
+two bug fixes:
+
+  join_move_bins now returns non-zero on error.
+
+  sam_export_seq could calculate the wrong index bin number when exporting
+  bam if the contig started at position <= 0 dut to the offset being added
+  to the sequence end position twice.
+
+
+------------------------------------------------------------------------
+r3998 | daviesrob | 2016-01-20 12:08:13 +0000 (Wed, 20 Jan 2016) | 5 lines
+Changed paths:
+   A /staden/trunk/src/gap5/replay_log.tcl
+
+Add basic script to allow replaying of events in gap5 log files.
+
+Incomplete, but good enough for tracking down bugs with pair_rec updates
+and shuffle_pads.
+
+------------------------------------------------------------------------
+r3997 | daviesrob | 2016-01-19 16:41:51 +0000 (Tue, 19 Jan 2016) | 15 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/tg_sequence.c
+
+Prevent use of uninitialised values in shuffle_pads.
+
+validate_clip_regions goes through a list of annotation record numbers
+that is passed in to it.  It's possible that the annotations have been
+removed beforehand, so it needs to check the result of anno_get_position
+to ensure that it has set start, end and crec.
+
+Possibly related:  Ensure that sequence_set_left, sequence_set_right
+sequence_set_left_no_invalidate and sequence_set_right_no_invalidate
+do not set a clip point that is outside the extents of the sequence.
+It's unclear if this can be made to happen in normal use of the
+contig editor, but it did happen when tracking down the problem in
+validate_clip_regions.
+
+
+------------------------------------------------------------------------
+r3996 | daviesrob | 2016-01-19 14:14:48 +0000 (Tue, 19 Jan 2016) | 42 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/editor_view.c
+   M /staden/trunk/src/gap5/list_proc.tcl
+   M /staden/trunk/src/gap5/tg_bin.c
+   M /staden/trunk/src/gap5/tg_cache.c
+   M /staden/trunk/src/gap5/tg_gio.c
+   M /staden/trunk/src/gap5/tg_gio.h
+   M /staden/trunk/src/gap5/tg_sequence.c
+   M /staden/trunk/src/gap5/tg_sequence.h
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Fix bin corruption caused by updates to read pairs spanning two contigs.
+
+Updating information on read pairs could lead to bin records being updated
+differently in two or more child IOs.  This could cause database corruption
+when the child IOs were flushed and the bin data overwritten.
+
+The data being updated were the cached location of read pairs, and pair_rec
+which is a pointer to the other read in a pair.  The location information
+is fixed by simply not updating it on the paired read (it was only being
+invalidated, anyway).  This is safe as sequence_get_range_pair_position
+includes sufficient checks to ensure that the information is still valid.
+
+Updates to pair_rec on the paired read are no longer made while editing
+but instead deferred until cache_flush is called.  At this point the
+changes are applied by new function apply_pair_rec_updates in tg_cache.c.
+This function updates any bins affected both in the base IO and also in
+child IOs, so all copies of the data should be consistent.  gio_child
+and gio_close are updated to maintain a linked list of child IOs to allow
+apply_pair_rec_updates to iterate through all of the children.
+
+Between an edit being made and 'save' being pressed, there is a problem
+with pair_rec possibly pointing to an unmapped read.  Some other changes
+have been made to deal with this possibility:
+
+  * sequence_cmd gains a 'get_mapped' function to allow TCL to check
+    for unmapped reads.
+
+  * The contig_editor tcl function was using the base IO to get sequences
+    when the -reading or -reading2 options were used.  This was incorrect,
+    it now uses the child IO instead.  It also checks that the sequences
+    are mapped.
+
+  * sequence_get_pair checks that the paired read is mapped.
+
+  * edSetCursorPos to a sequence position checks that the sequence is mapped.
+
+  * ListEditMultiUpdate ignores unmapped sequences.
+
+It's likely that more edge cases remain, but the changes above fix the ones
+seen so far.
+
+
+------------------------------------------------------------------------
+r3959 | jkbonfield | 2015-09-24 17:34:52 +0100 (Thu, 24 Sep 2015) | 14 lines
+Changed paths:
+   M /staden/trunk/src/gap5/assemble_single.tcl
+   M /staden/trunk/src/gap5/fasta.c
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/tg_index.c
+   M /staden/trunk/src/gap5/tg_index.h
+
+Added a default quality to use for bases without quality. This defaults to 3
+and is used by fasta and SAM without qual. (Maybe there are other formats to
+do.)
+In the GUI this is now controllable via an additional entry box.
+
+In the C code, this is -ve to indicate a *default* value and positive to
+indicate an override value, used for fastq only at present.  This permits
+us to import a fasta/fastq set of consensus sequences and forcibly set
+confidence high (even to 100, forcing consensus) or low as desired
+irrespective of what the actual fastq qualities claim.  Useful for
+manipulating consenusii.
+
+(jkb)
+
+------------------------------------------------------------------------
+r3934 | jkbonfield | 2015-07-02 17:06:58 +0100 (Thu, 02 Jul 2015) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_utils.c
+
+Fixed u72intw with the same fix that appears to already be in
+s72intw.  When decoding a value > 31bits it wrapped around to become
+negative as the shift operator is applying on int and not int64_t.
+
+------------------------------------------------------------------------
+r3931 | jkbonfield | 2015-07-02 12:13:10 +0100 (Thu, 02 Jul 2015) | 2 lines
+Changed paths:
+   M /staden/trunk/src/Makefile.in
+
+Fixed a missing dependency, causing parallel makes to sometimes fail.
+
+------------------------------------------------------------------------
+r3930 | jkbonfield | 2015-07-02 12:09:18 +0100 (Thu, 02 Jul 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+
+Revert accidental commit of shuffle pads changes in the last commit.
+These introduced compilation errors due to a partial update.
+
+------------------------------------------------------------------------
+r3925 | jkbonfield | 2015-06-04 11:27:40 +0100 (Thu, 04 Jun 2015) | 5 lines
+Changed paths:
+   M /staden/trunk/src/gap5/find_haplotypes.c
+   M /staden/trunk/src/gap5/find_haplotypes.h
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+   M /staden/trunk/src/gap5/newgap_structs.h
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Fixed Find Haplotypes left/right settings when faced with inconsistent
+data.
+
+Also made it so that the various parameters are adjustable.
+
+------------------------------------------------------------------------
+r3921 | jkbonfield | 2015-05-29 12:07:41 +0100 (Fri, 29 May 2015) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/depth.tcl
+   M /staden/trunk/src/gap5/gap5rc
+
+Fixed the template display auto-scrolling. It wasn't taking into
+account the contig start location when computing the scrollbar
+position.
+
+Also made the margins for when to scroll and how much by adjustable in
+the gap5rc.
+
+------------------------------------------------------------------------
+r3831 | jkbonfield | 2015-02-23 16:52:09 +0000 (Mon, 23 Feb 2015) | 10 lines
+Changed paths:
+   M /staden/trunk/src/gap5/cs-object.h
+   M /staden/trunk/src/gap5/fij.c
+
+Auto-join now honours the -min_overlap and -max_overlap parameters.
+
+This is important for cases where we have two very long contigs (L1,
+L2) both overlapping a short contig S.
+We find the two short matches (L1/S and L2/S) and probably didn't even
+attempt to detect L1/L2 overlap due to -max_overlap.  After
+automatically joining L1+S however we then have L1+S / L2 due to
+inheriting the overlaps during merging.  We now recheck max_overlap
+before each and every alignment.
+
+------------------------------------------------------------------------
+r3830 | jkbonfield | 2015-02-23 11:44:09 +0000 (Mon, 23 Feb 2015) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+Removal of debugging output
+
+------------------------------------------------------------------------
+r3829 | jkbonfield | 2015-02-23 11:28:48 +0000 (Mon, 23 Feb 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/Misc/Makefile
+   M /staden/trunk/src/abi/Makefile
+   M /staden/trunk/src/alf/Makefile
+   M /staden/trunk/src/convert/Makefile
+   M /staden/trunk/src/copy_reads/Makefile
+   M /staden/trunk/src/eba/Makefile
+   M /staden/trunk/src/find_renz/Makefile
+   M /staden/trunk/src/g/Makefile
+   M /staden/trunk/src/gap4/Makefile
+   M /staden/trunk/src/get_scf_field/Makefile
+   M /staden/trunk/src/global.mk
+   M /staden/trunk/src/haplo/Makefile
+   M /staden/trunk/src/init_exp/Makefile
+   M /staden/trunk/src/make_weights/Makefile
+   M /staden/trunk/src/mutlib/Makefile
+   M /staden/trunk/src/polyA_clip/Makefile
+   M /staden/trunk/src/prefinish/Makefile
+   M /staden/trunk/src/qclip/Makefile
+   M /staden/trunk/src/screen_seq/Makefile
+   M /staden/trunk/src/seq_utils/Makefile
+   M /staden/trunk/src/spin/Makefile
+   M /staden/trunk/src/stops/Makefile
+   M /staden/trunk/src/text_utils/Makefile
+   M /staden/trunk/src/tk_utils/Makefile
+   M /staden/trunk/src/tracediff/Makefile
+   M /staden/trunk/src/vector_clip/Makefile
+
+Fixed an issue in "make depend" not working in all cases.
+Reran to update our local Makefiles.
+
+------------------------------------------------------------------------
+r3828 | jkbonfield | 2015-02-23 11:25:53 +0000 (Mon, 23 Feb 2015) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/find_haplotypes.c
+
+Fixed minor compiler warning.
+
+------------------------------------------------------------------------
+r3827 | jkbonfield | 2015-02-23 11:25:32 +0000 (Mon, 23 Feb 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+
+Added interval_tree to Makefile.
+(Also minor updates caused by make depend)
+
+------------------------------------------------------------------------
+r3826 | jkbonfield | 2015-02-20 17:52:19 +0000 (Fri, 20 Feb 2015) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+Allow for dotter -q NUM -s NUM
+
+------------------------------------------------------------------------
+r3825 | jkbonfield | 2015-02-20 16:28:00 +0000 (Fri, 20 Feb 2015) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/find_haplotypes.c
+   A /staden/trunk/src/gap5/interval_tree.c
+   A /staden/trunk/src/gap5/interval_tree.h
+
+Find Haplotypes revamp.
+- Read pairs are now considered.
+- Better merging of haplotype strings. Instead of aggressive merging
+at time of collation, we only early-merge exact dups and then merge by
+frequency after the full data has been gathered.
+
+Also added an interval tree implementation (used in the new haplotype code).
+
+------------------------------------------------------------------------
+r3824 | jkbonfield | 2015-02-20 16:25:25 +0000 (Fri, 20 Feb 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consensus.c
+
+Improved the consensus discrepancy score by taking into account a
+per-base difference rather than joining all together.
+
+------------------------------------------------------------------------
+r3823 | jkbonfield | 2015-02-18 17:42:58 +0000 (Wed, 18 Feb 2015) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/tk_utils/init.tcl
+
+Added a <<control-menu>> binding to the contig editor so that it is
+considered as a power-click, asking for more dialogue if appropriate.
+Ie it is considered the same as using the main menu bar.
+
+For now this only controls read selection and realignment.
+
+------------------------------------------------------------------------
+r3822 | jkbonfield | 2015-02-18 17:32:13 +0000 (Wed, 18 Feb 2015) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+Fixed end range in Realign Selection dialogue.
+
+------------------------------------------------------------------------
+r3821 | jkbonfield | 2015-02-18 17:29:48 +0000 (Wed, 18 Feb 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/gap5rc
+
+The Realign Selection option now brings up a user interface if invoked
+from the main menu, but not when right clicked via the popup menu.
+
+------------------------------------------------------------------------
+r3820 | jkbonfield | 2015-02-17 15:16:36 +0000 (Tue, 17 Feb 2015) | 10 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/shuffle_pads.h
+
+Fixed rewrite_soft_clips so it doesn't treat clips that fall partially
+outside the current start..end sub-range as scoring 0. This was
+causing it to falsely accept some clips.
+
+Fixed a bug in the main loop which chunks the contig into sections.
+It now tracks the number of pads added during update_io so it can
+validate the soft-clips over the now extended region.  Previously some
+reads at the end of the region were not validated if we introduced a
+lot of pads.
+
+------------------------------------------------------------------------
+r3819 | jkbonfield | 2015-02-17 12:38:31 +0000 (Tue, 17 Feb 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/check_assembly.c
+
+Improved the Show Information output to include the read name, making
+it easier to compare two databases.
+
+------------------------------------------------------------------------
+r3818 | jkbonfield | 2015-02-17 12:37:43 +0000 (Tue, 17 Feb 2015) | 2 lines
+Changed paths:
+   M /staden/trunk/src/Misc/array.c
+   M /staden/trunk/src/Misc/array.h
+
+Added ArrayConcat() function.
+
+------------------------------------------------------------------------
+r3812 | jkbonfield | 2015-02-05 12:42:36 +0000 (Thu, 05 Feb 2015) | 3 lines
+Changed paths:
+   M /staden/trunk/src/seq_utils/align_lib.c
+
+Minor tweak to get_malign_counts() to persuade any non-N base to be
+counted. This avoids issues with sequences full of N.
+
+------------------------------------------------------------------------
+r3811 | jkbonfield | 2015-02-05 12:39:26 +0000 (Thu, 05 Feb 2015) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5rc
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+   M /staden/trunk/src/gap5/newgap_structs.h
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/shuffle_pads.tcl
+
+Fixed a bug where we could realign data that we had previously
+realigned in an earlier chunk, but against less depth. This caused
+misalignments.
+
+We now skip data previously aligned, but it has to be included in the
+malign->contigl struct still for the fresh data to align against.
+
+Also added a maximum number of passes field to the GUI.
+
+------------------------------------------------------------------------
+r3788 | jkbonfield | 2015-01-14 16:31:34 +0000 (Wed, 14 Jan 2015) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/sam_index.c
+
+Fixed a bug in the tg_index -g mode where it erroneously added extra
+columns of pads to the contig if an incoming sequence has an insertion
+1 base after a pre-existing gap in the consensus.
+
+------------------------------------------------------------------------
+r3787 | jkbonfield | 2015-01-14 16:30:21 +0000 (Wed, 14 Jan 2015) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_sequence.c
+   M /staden/trunk/src/seq_utils/dna_utils.c
+   M /staden/trunk/src/seq_utils/dna_utils.h
+
+Removed the complementary_base[] and initialisation functions from
+tg_sequence.c and exported the version from seq_utils lib.  The
+seq_utils copy is now also statically initialised without needed to
+call the set_dna_lookup() function so we cannot accidentally forget to
+initialise it.
+
+------------------------------------------------------------------------
+r3786 | jkbonfield | 2015-01-13 14:39:15 +0000 (Tue, 13 Jan 2015) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_sequence.c
+
+Added a complementary_base_init function to build the
+complementary_base[] array and then use this in more places than the
+one function it came from.
+
+This fixes a bug with tg_index -a -g not working due to an
+complementary_base[] being unset during sequence_insert_bases() call.
+
+------------------------------------------------------------------------
+r3778 | daviesrob | 2015-01-06 11:29:22 +0000 (Tue, 06 Jan 2015) | 14 lines
+Changed paths:
+   M /staden/trunk/src/gap5/quality_plot.c
+
+Fix rounding error in qplot_redraw which triggered an assertion failure.
+
+Inverted the xzoom factor (xz) so that the x coordinate in the plot can
+be worked out by multiplying by xz instead of dividing.  This seems to
+fix a rounding error that could make the x position go out of bounds
+when zoomed out a long way.  Multiplying should also be slightly faster.
+
+In a belt-and-braces approach, also allocated the xs array one bigger
+than strictly necessary so any remaining rounding errors shouldn't cause
+a problem.  The assertions on x are adjusted to reflect this.
+
+Only one of the xp and xs arrays is used, depending on the value of xz.  So
+now only the one that is needed gets allocated.
+
+------------------------------------------------------------------------
+r3772 | jkbonfield | 2014-12-15 10:18:27 +0000 (Mon, 15 Dec 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/g-alloc.c
+
+Updated the list of known record types in the debug HeapChecker tool.
+
+------------------------------------------------------------------------
+r3767 | jkbonfield | 2014-11-14 11:20:17 +0000 (Fri, 14 Nov 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+The list size is now shown in the contig editor, giving an indication
+of how many fragments are in each haplotype.
+
+------------------------------------------------------------------------
+r3766 | jkbonfield | 2014-11-14 10:27:27 +0000 (Fri, 14 Nov 2014) | 13 lines
+Changed paths:
+   M /staden/trunk/src/gap5/find_haplotypes.c
+
+Reduced complexity in haplotype_str_add(). With long sections this can
+become over 100x less cpu, and growing more.  It is still a linear
+scan though so needs futher optimisation yet, using a tree instead to
+find snp overlaps.
+
+Also amended it to consider sites with too many discrepancies rather
+than pure consensus SNP call.
+
+Finally, added a minimum count of 2 seqs to filter most of the
+singleton haplotypes. The minimum count figure isn't yet user
+adjustable, but should be made so before this becomes production
+ready.
+
+------------------------------------------------------------------------
+r3765 | jkbonfield | 2014-11-14 10:25:31 +0000 (Fri, 14 Nov 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tk-io-reg.c
+
+Improve error messages.
+
+------------------------------------------------------------------------
+r3764 | jkbonfield | 2014-11-11 12:32:11 +0000 (Tue, 11 Nov 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/editor_view.c
+
+Changed highlight disagreements for cutoff data to always show in
+foreground instead of background (if selected), so it is more easily
+distinguishable.
+
+------------------------------------------------------------------------
+r3762 | jkbonfield | 2014-11-03 09:47:27 +0000 (Mon, 03 Nov 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+
+Fix typo in the trim command, causing it to fail.
+
+------------------------------------------------------------------------
+r3761 | jkbonfield | 2014-10-31 14:45:20 +0000 (Fri, 31 Oct 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+Delete old haplotype_* lists when creating new ones, so as not to
+confuse people as to how many haplotypes are present.
+
+------------------------------------------------------------------------
+r3760 | jkbonfield | 2014-10-31 14:21:21 +0000 (Fri, 31 Oct 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+Added the option to view the readings/haplotype lists on the ednames
+right click menu.
+
+------------------------------------------------------------------------
+r3759 | jkbonfield | 2014-10-31 12:36:37 +0000 (Fri, 31 Oct 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/tk_utils/xcombobox.tcl
+
+The popup listbox from the combobox now shares the width from the
+entry box.
+
+------------------------------------------------------------------------
+r3758 | jkbonfield | 2014-10-31 11:20:21 +0000 (Fri, 31 Oct 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Fixed contig_export_sam (used for SAM, BAM and CRAM formats) to be
+much faster in excessively deep regions where soft-clipping is being
+used.
+
+Gap5 has to convert from coordinates sorted by object start including
+soft-clipped bases, to coordinates sorted by first unclipped site
+(SAM).  This sorting could become O(N^2) in the worst case, but is now
+O(NlogN) - possibly better if soft-clip lengths co-locate.
+
+------------------------------------------------------------------------
+r3757 | daviesrob | 2014-10-29 15:32:53 +0000 (Wed, 29 Oct 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_cache.c
+
+haplo_hash bug fixes.
+
+In cache_dup, ensure that haplo_hash and haplo_timestamp are initialized
+when duplicating a contig.  This prevents a dangling pointer from being left
+in the parent if haplo_hash is freed in the child.
+
+In cache_flush, ensure that haplo_hash is freed from the parent where
+necessary when flushing a contig block.
+
+------------------------------------------------------------------------
+r3756 | jkbonfield | 2014-10-29 15:13:29 +0000 (Wed, 29 Oct 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_check.c
+
+Fixed a crash when being unable to load an annotation.
+
+------------------------------------------------------------------------
+r3755 | jkbonfield | 2014-10-29 15:12:42 +0000 (Wed, 29 Oct 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+
+Removed zfio.[ch] as these have been in io_lib for some time and
+causes compilation problems if attempting to link against a static
+build of io_lib.
+
+------------------------------------------------------------------------
+r3754 | jkbonfield | 2014-10-21 17:24:22 +0100 (Tue, 21 Oct 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Rewrote the fix for r->end - r->start + 1 == ABS(s->len).  Previously
+I modified s->len, but this breaks all sorts of other things, most
+notably it makes s->conf - s->seq not equal to s->len, then leading to
+broken confidence values and also to sequence insertion possibly
+calling memmove off the end of the buffer. (Oddly not detected by
+valgrind.)
+
+We now fix the far more likely error; r->end instead.
+
+------------------------------------------------------------------------
+r3753 | jkbonfield | 2014-10-17 17:01:49 +0100 (Fri, 17 Oct 2014) | 16 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consensus.c
+
+Work around for a bug where some bins are not covered by child
+bins. Ie:
+
+:-----------------------------------: Parent
+
+                      :-------------: Left
+           :------------------------: Right
+
+I don't know what causes this yet, but it makes
+calculate_consensus_simple sometiems find very large bins (the parent)
+on which to compute the cached consensus, taking a lot of time.  For
+now we simply reject an attempt to compute a very long cached
+consensus as it is probably not the write thing to do.
+
+(This really needs a total rewrite.)
+
+------------------------------------------------------------------------
+r3752 | jkbonfield | 2014-10-17 16:43:05 +0100 (Fri, 17 Oct 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Removal of debugging info.
+
+------------------------------------------------------------------------
+r3751 | jkbonfield | 2014-10-16 17:40:58 +0100 (Thu, 16 Oct 2014) | 13 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Made contig_insert_base2() more robust with respect to corrupted data
+or other sources of errors.
+
+Previously it just bailed out of the recursion, leaving a half
+inserted column. This is complicated to deal with and often turns a
+small problem into a bigger problem.
+
+Now it boldly carries on regardless, completing as much as it can,
+before then returning -1 to the calling function to indicate the
+failure.  Ideally the calling function would execute this in a child
+io so it can be backed out of to revert the change, but in the absence
+of this we have at least maintained consistency where able.
+
+------------------------------------------------------------------------
+r3750 | jkbonfield | 2014-10-16 16:48:56 +0100 (Thu, 16 Oct 2014) | 13 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/dis_readings.tcl
+   M /staden/trunk/src/gap5/editor_view.c
+   A /staden/trunk/src/gap5/find_haplotypes.c
+   A /staden/trunk/src/gap5/find_haplotypes.h
+   M /staden/trunk/src/gap5/gap5rc_menu_full
+   M /staden/trunk/src/gap5/list_proc.tcl
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+   M /staden/trunk/src/gap5/tclIndex
+   M /staden/trunk/src/gap5/tg_cache.c
+   M /staden/trunk/src/gap5/tg_contig.c
+   M /staden/trunk/src/gap5/tg_iface_g.c
+   M /staden/trunk/src/gap5/tg_struct.h
+   M /staden/trunk/src/gap5/tkEditor.c
+   M /staden/trunk/src/gap5/tkEditor.h
+
+First draft of a new haplotype finder.  It replaces the Sort By
+Sequence mode in the contig editor as well as generating lists of read
+IDs per haplotype and creating a master "haplotypes" list of lists.
+
+Disassemble readings now knows how to handle list of lists, so that it
+disassembles each sub-list into its own set of contigs.
+
+There is more to do on this to tidy it up: handling read-pairs,
+optimising it for larger contigs, improving the consensus algorithm to
+label more things as SNPs by avoiding the dominance of depth.  However
+it's a good starting point and users are already wanting to use it so
+we'll see how it goes in the current state.
+
+------------------------------------------------------------------------
+r3749 | jkbonfield | 2014-10-13 12:38:17 +0100 (Mon, 13 Oct 2014) | 9 lines
+Changed paths:
+   A /staden/trunk/src/tk_utils/func_edit.tcl
+   M /staden/trunk/src/tk_utils/tclIndex
+
+A new debugging tool: func_edit
+
+From the console (type "con" into the Gap5 Error window) you will be
+able to type "func_edit UpdateReadingDisplays", for example, to
+locally change the function definition without needing to quit and
+restart the program.
+
+All changes are temporary.
+
+------------------------------------------------------------------------
+r3748 | jkbonfield | 2014-10-07 17:45:30 +0100 (Tue, 07 Oct 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/import_contigs.tcl
+   M /staden/trunk/src/gap5/tclIndex
+
+Same fix as previous: Import Reads no longer clears "readings" list.
+
+------------------------------------------------------------------------
+r3747 | jkbonfield | 2014-10-07 13:58:37 +0100 (Tue, 07 Oct 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/assemble_single.tcl
+
+Replace the call to PostLoadSetup with a lighter-weight setup, so we
+don't clear "readings" list on loading new contigs.
+
+------------------------------------------------------------------------
+r3741 | jkbonfield | 2014-09-22 15:13:56 +0100 (Mon, 22 Sep 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/dis_readings.c
+   M /staden/trunk/src/gap5/hash_lib.c
+
+More compiler warning removal; this time clang.
+
+------------------------------------------------------------------------
+r3740 | jkbonfield | 2014-09-22 14:55:49 +0100 (Mon, 22 Sep 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/actf.c
+   M /staden/trunk/src/gap5/auto_break.c
+   M /staden/trunk/src/gap5/b+tree2.c
+   M /staden/trunk/src/gap5/editor_search.c
+   M /staden/trunk/src/gap5/export_contigs.c
+   M /staden/trunk/src/gap5/export_snps.c
+   M /staden/trunk/src/gap5/fij.c
+   M /staden/trunk/src/gap5/g-alloc.c
+   M /staden/trunk/src/gap5/qualIO.c
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/str_finder.c
+   M /staden/trunk/src/gap5/tg_iface_g.c
+   M /staden/trunk/src/gap5/tg_index_common.c
+   M /staden/trunk/src/gap5/tg_library.c
+   M /staden/trunk/src/gap5/zfio.c
+   M /staden/trunk/src/seq_utils/align_lib.h
+
+Various compiler warnings removed. Most are of the form "variable x
+may be used uninitialised" and most of the time it is untrue, however
+there are a few legitimate coding errors fixed too.
+
+------------------------------------------------------------------------
+r3739 | jkbonfield | 2014-09-22 14:02:43 +0100 (Mon, 22 Sep 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/sam_index.c
+
+Removed append_int as this is now exported from libstaden-read (bam.c).
+
+------------------------------------------------------------------------
+r3730 | jkbonfield | 2014-09-11 18:26:02 +0100 (Thu, 11 Sep 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Fixed memory leak and slow down caused by last patch to STR finder
+calling.
+
+Added seed_malign_region() to perform a rudimentary screen on the
+heterozygous consensus to only request realignment in regions that are
+heterozygous in nature.
+
+TODO: Make this an optional 3 way - all regions, all hets, het indel only.
+
+------------------------------------------------------------------------
+r3729 | jkbonfield | 2014-09-11 18:07:41 +0100 (Thu, 11 Sep 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/str_finder.c
+
+TEST_MAIN2 version of main() for testing on larger inputs, read from
+stdin rather than argv[1] as a string.
+
+------------------------------------------------------------------------
+r3727 | jkbonfield | 2014-09-10 17:35:40 +0100 (Wed, 10 Sep 2014) | 10 lines
+Changed paths:
+   M /staden/trunk/src/gap5/str_finder.c
+
+Fixed the STR finder to not step forward by 'extra' bytes as an
+optimisation.  It was causing overlapping repeats to sometimes be
+missed by 1 bp. Eg:
+
+$ ./a.out CTAAATAAATAAAC
+ 2 .. 12 AAATAAATAAA
+
+(Should be 1 .. 12)
+
+
+------------------------------------------------------------------------
+r3726 | jkbonfield | 2014-09-10 16:56:35 +0100 (Wed, 10 Sep 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Fixed a crash introduced in r3497, triggered when using control-left
+or right arrows in the editor to move a sequence location.
+
+------------------------------------------------------------------------
+r3725 | jkbonfield | 2014-09-10 11:25:50 +0100 (Wed, 10 Sep 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/str_finder.c
+
+Fixed buffer underrun.
+
+------------------------------------------------------------------------
+r3724 | jkbonfield | 2014-09-09 15:29:18 +0100 (Tue, 09 Sep 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Fixed rewrite_soft_clips() to correctly trim when handling overlapping
+STRs.  Previously it could reset s->left/right multiple times,
+overwriting the result each time, instead of taking the inner-most
+union of the values.
+
+Also tidied up the code to not needlessly compute consensus and STRs
+on the first pass.
+
+------------------------------------------------------------------------
+r3723 | jkbonfield | 2014-09-08 16:24:07 +0100 (Mon, 08 Sep 2014) | 39 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   A /staden/trunk/src/gap5/str_finder.c
+   A /staden/trunk/src/gap5/str_finder.h
+   A /staden/trunk/src/gap5/utlist.h
+
+Added a short tandem read detector. This looks for repeated strings
+between 1 and 8 bases long and returns a utlist of start..end ranges.
+These may be overlapping in some situations. Eg:
+
+$ ./a.out TGCAGAGCAGAGAGAGGGT
+ 1 .. 11 GCAGAGCAGAG
+ 8 .. 15 AGAGAGAG
+15 .. 17 GGG
+
+Compile str_finder.c with TEST_MAIN to get a command line tool.
+
+Within Shuffle Pads this is used to identify STRs that overlap a
+heterozygous indel region and then in turn to adjust the soft-clipping
+of any reads that do not span that region as they cannot be relied
+upon to indicate the copy number. Eg:
+
+S1 GATCGGACGAGAG
+S2 GATCGGACGAGAGAGAGAGAGT
+S3 GATCGGACGAGAGAGAGAG**TCGGAC
+S4     GGACGAGAGAGAGAGAGTCGGAC
+S5        CGAGAGAGAGAG**TCGGAC
+S6              AGAGAGAGTCGGAC
+
+We have subseq of GAGAGAGAGAG** vs GAGAGAGAGAGAG. The first and last
+(S1 and S6) sequences do not span and so we do not know which allele they
+match. Specifically as the pad is at the right hand end, the alignment of
+S6 gives incorrect weight to the consensus as it is stating AG when it
+may actually be ** at that point.
+
+By identifying the repeats we can soft clip as follows:
+
+S1 GATCGGACgagag
+S2 GATCGGACGAGAGAGAGAGAGT
+S3 GATCGGACGAGAGAGAGAG**TCGGAC
+S4     GGACGAGAGAGAGAGAGTCGGAC
+S5        CGAGAGAGAGAG**TCGGAC
+S6              agagagagTCGGAC
+
+
+------------------------------------------------------------------------
+r3722 | jkbonfield | 2014-09-05 15:31:51 +0100 (Fri, 05 Sep 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consensus.c
+
+Switched to using older method of handling ONT consensus (based on a
+one-liner perl/awk combo).  It just has a single parameter for how
+much more likely it is to have overcall vs undercall. This is simple
+to understand and more robust.
+
+It corrects issues with the old system, which was causing * in
+columns of illumina data to be downweighted too much.
+
+------------------------------------------------------------------------
+r3721 | jkbonfield | 2014-09-05 15:29:36 +0100 (Fri, 05 Sep 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/qualIO.c
+
+Bug fixes the insertion/deletion counting in List Base Confidence
+(they were reversed). Also updated it to report percentages.
+
+------------------------------------------------------------------------
+r3719 | jkbonfield | 2014-09-05 12:01:38 +0100 (Fri, 05 Sep 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consensus.c
+
+Changed the simple consensus qualities to be Phred scores instead of
+log-odds scores.  This fixes a bug where negative consensus qualities
+were appearing in CAF and ACE outputs.
+
+The change also impacts some other code, such as searching for
+consensus quality in the editor and fastq outputs, but only at the
+very low end as log-odds and phred scales rapidly converge. It is only
+very poor quality data that changes.
+
+------------------------------------------------------------------------
+r3718 | jkbonfield | 2014-09-01 09:37:22 +0100 (Mon, 01 Sep 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+
+Added Contig Extend/Trim options to gap5_cmd
+
+------------------------------------------------------------------------
+r3717 | jkbonfield | 2014-08-29 15:51:26 +0100 (Fri, 29 Aug 2014) | 5 lines
+Changed paths:
+   M /staden/trunk/src/gap5/configure.tcl
+   M /staden/trunk/src/gap5/gap_globals.tcl
+
+Fixed configuring consenus mode when in read only mode.
+
+Fixed using File->Open to swap databases, ensuring it now correctly
+sets the default_seq_tech back to Illumina.
+
+------------------------------------------------------------------------
+r3716 | jkbonfield | 2014-08-29 15:42:53 +0100 (Fri, 29 Aug 2014) | 30 lines
+Changed paths:
+   M /staden/trunk/src/gap5/configure.tcl
+   M /staden/trunk/src/gap5/gap5.tcl
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+   M /staden/trunk/src/gap5/gap5rc_menu_full
+   A /staden/trunk/src/gap5/gap_globals.tcl
+   M /staden/trunk/src/gap5/ng_fb_cmds.tcl
+   M /staden/trunk/src/gap5/tclIndex
+   M /staden/trunk/src/gap5/tg_anno.c
+   M /staden/trunk/src/gap5/tg_iface_g.c
+   M /staden/trunk/src/gap5/tg_struct.h
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Allowed the default_seq_tech parameter to be modified from Gap5 GUI.
+
+To do this required several things.
+
+1) The cached consensus may be incorrect after changing this, so it
+has to be purged. 
+
+2) The parameter needs to be remembered in the database itself so it
+can be set the next time we open a database.  I tidied up the setting
+of default parameters in multiple locations and put them into
+gap_globals.tcl.
+
+3) To store an arbitrary variable without modifying the database
+format required some lateral thinking. WARNING: ugliness ahead. Those
+of a nervous disposition should look away now.
+
+We create an anno_ele object with parent_type of GT_Database; ie an
+annotation on the database rather than a contig or sequence. 
+A scaffold of name __g5::CONFIG is created whose record number points
+to this annotation instead of a scaffold.  The annotation contains
+a series of 'set key val' tuples, which are carefully checked for
+validty so we don't blindly trust everything.
+
+We can extend this with other __g5::* fields for different types of
+data, replacing the old Gap4 "Notes" mechanism as tags attached to a
+database are essentially the same thing as notes.
+
+4) Added various C/Tcl interfaces to set and get the config_anno
+field.
+
+------------------------------------------------------------------------
+r3715 | jkbonfield | 2014-08-29 15:35:02 +0100 (Fri, 29 Aug 2014) | 12 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consensus.c
+   M /staden/trunk/src/gap5/gap_globals.c
+   M /staden/trunk/src/gap5/gap_globals.h
+
+Updated the consensus algorithm to cope with different overcall and
+undercall probabilities per machine platform, permitting mixing of
+different technologies to form a single consensus.
+
+At present these are complete guesses with only a minimal nod to
+reality and have no measurements backing them up (yet).  Expect them
+to be tuned in the future. However they act as a good proof of
+concept.
+
+The Tcl variable default_seq_tech may be modified to change what the
+Unknown sequencing tech is treated as.
+
+------------------------------------------------------------------------
+r3714 | jkbonfield | 2014-08-28 17:20:08 +0100 (Thu, 28 Aug 2014) | 5 lines
+Changed paths:
+   M /staden/trunk/src/gap5/fasta.c
+
+Fasta data now has a default quality of 3 instead of 0, as this was
+causing problems with my experimental consensus algorithm.  It makes
+more sense at 3 anyway. Confidence 0 implies it is 100% chance of
+being incorrect.
+
+------------------------------------------------------------------------
+r3713 | jkbonfield | 2014-08-28 17:19:17 +0100 (Thu, 28 Aug 2014) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/hash_lib.c
+
+Further tweakage of the align_blocks function. This was necessary in
+order to get alignments scoring positive when using very weakly
+aligning data.
+
+It doesn't seem to overly harm my other tests for Illumina.
+
+------------------------------------------------------------------------
+r3712 | jkbonfield | 2014-08-28 17:18:11 +0100 (Thu, 28 Aug 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/sam_index.c
+
+Prevent treatment of confidence 255 ("*" in qual field for BAM) as
+confidence -1 (or 255). Instead set it to a minimal confidence of 3.
+
+------------------------------------------------------------------------
+r3711 | jkbonfield | 2014-08-26 17:35:51 +0100 (Tue, 26 Aug 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/depth.tcl
+
+Fixed the mapping quality filter range from 0-80 to 0-255 as we are
+seeing data with >80 as mquals.
+
+Fixed the use of TEMPLATE_DISPLAY.SETTINGS_$i library records. These
+could be for another database, so it already attempted to blank out
+the libraries-list when they don't match up, but it failed to clear
+the undo versions causing the filter window to possibly blank the data
+when it's invoked.
+
+------------------------------------------------------------------------
+r3710 | jkbonfield | 2014-08-26 15:20:32 +0100 (Tue, 26 Aug 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap_range.c
+
+Fixed spacing
+
+------------------------------------------------------------------------
+r3709 | jkbonfield | 2014-08-26 11:58:00 +0100 (Tue, 26 Aug 2014) | 32 lines
+Changed paths:
+   M /staden/trunk/src/gap5/libraries.tcl
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/tg_iface_g.c
+   M /staden/trunk/src/gap5/tg_library.c
+   M /staden/trunk/src/gap5/tg_library.h
+   M /staden/trunk/src/gap5/tg_struct.h
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Further work on read-group machine types.
+
+1) Bug fix to the tg_index process so that it looks up "PL"atform RG
+tag correctly.  Previously it was doing something bizarre with
+attempting to find the library name as a 2 character key.
+
+2) Changed seq_tech to be an int instead of int:3 in the seq_t struct
+as it has 9 possible values now.
+
+3) Changed the on-disk format, which also packs 3 bits, to steal 2
+bits from the parent_type field and use these for seq_tech.  This is
+backwards compatible as these top bits have always been zero and we've
+also never needed more than 7 for seq_tech either.
+
+This limits the available number of GT_* types to 64, but we're only
+using 18 at the moment and I don't see us adding that many more table
+types to gap5. It gives us up to 32 instrument types.
+
+4) Added set_name and set_machine_type methods to the library tcl
+object.
+
+5) The List Libraries window now allows editing of the library name
+too, also also saves both this and edits to library machine type.
+
+
+Note that editing the machine type here does not actually modify all
+the sequence structures as the library type has been cached in both
+seq and range structures during tg_index. I do not know how to prevent
+that in an efficient manner, so for now editing the type is purely for
+informational purposes.
+
+
+------------------------------------------------------------------------
+r3708 | jkbonfield | 2014-08-22 17:17:51 +0100 (Fri, 22 Aug 2014) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/editor_view.c
+   M /staden/trunk/src/gap5/libraries.tcl
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/tg_struct.h
+   M /staden/trunk/src/tk_utils/xcombobox.tcl
+
+Updated Gap5 to support a richer list of machine platforms in the SAM
+ at RG tag.
+
+(Ongoing: the platform type can also now be edited, but not yet saved,
+in the ListLibraries window.)
+
+------------------------------------------------------------------------
+r3707 | jkbonfield | 2014-08-21 09:29:53 +0100 (Thu, 21 Aug 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Removed memory leak in sam_refbased_cigar().
+
+Also removed debugging output from the output GFF function.
+
+------------------------------------------------------------------------
+r3706 | jkbonfield | 2014-08-21 09:28:56 +0100 (Thu, 21 Aug 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Removed memory leak in padded_to_reference_array().
+
+------------------------------------------------------------------------
+r3705 | jkbonfield | 2014-08-01 14:45:41 +0100 (Fri, 01 Aug 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+
+Added code to provide an export_snps command. This is *PURELY TEST
+ONLY*.  It has hard coded names (like "chr20") and has a few bugs too,
+but it serves as a useful starting point for if/when we want to do
+proper VCF output at some stage.
+
+For now it is not supported by the GUI.
+
+------------------------------------------------------------------------
+r3704 | jkbonfield | 2014-08-01 14:45:22 +0100 (Fri, 01 Aug 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consen.tcl
+   A /staden/trunk/src/gap5/export_snps.c
+   A /staden/trunk/src/gap5/export_snps.h
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+
+Added code to provide an export_snps command. This is *PURELY TEST
+ONLY*.  It has hard coded names (like "chr20") and has a few bugs too,
+but it serves as a useful starting point for if/when we want to do
+proper VCF output at some stage.
+
+For now it is not supported by the GUI.
+
+------------------------------------------------------------------------
+r3703 | jkbonfield | 2014-07-31 11:28:25 +0100 (Thu, 31 Jul 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/check_assembly.c
+   M /staden/trunk/src/gap5/fij.c
+   M /staden/trunk/src/gap5/find_oligo.c
+   M /staden/trunk/src/gap5/find_repeats.c
+
+Fixed the buffer size for the OBJ_GET_BRIEF callback to be 160 instead
+of 80. This fixes buffer overruns when dealing with large databases
+and long record numbers.
+
+Worked it out on paper the maximum length is around 120 for FIJ, and
+a few bytes more for the others (but under 130). Set the new buffer
+size to 160.
+
+------------------------------------------------------------------------
+r3702 | jkbonfield | 2014-07-16 10:31:55 +0100 (Wed, 16 Jul 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Put back the line of code to output BAM_FPROPER_PAIR flag for reads in
+---> <--- paired orientation.
+
+While this isn't strictly correct for all library types, making this
+assumption is still usually correct and far better than simply never
+setting this flag at all.
+
+------------------------------------------------------------------------
+r3701 | jkbonfield | 2014-07-08 17:49:20 +0100 (Tue, 08 Jul 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_struct.h
+
+Added explanatory note to GRANGE_FLAG_REFPOS_HAVE_* fields so we don't
+accidentally recreate the same bug as before. (Fake warnings from
+Check Database.)
+
+------------------------------------------------------------------------
+r3700 | jkbonfield | 2014-07-08 17:44:14 +0100 (Tue, 08 Jul 2014) | 10 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Remove the code attempting to set GRANGE_FLAG_REFPOS_HAVE_* fields.
+
+These are used internally in tg_iface_g.c to determine whether we need
+to store the Position, Size or ID fields via a simplistic delta
+mechanism.  Outside of that file they should never be set or queried.
+
+This fix removes a warning about the in-memory and on-disc
+representations differing, which is bogus as these bit fields are
+zeroed after reading anyway.
+
+------------------------------------------------------------------------
+r3699 | jkbonfield | 2014-07-08 16:31:10 +0100 (Tue, 08 Jul 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consen.tcl
+   M /staden/trunk/src/gap5/consensus.c
+   M /staden/trunk/src/gap5/consensus.h
+   M /staden/trunk/src/gap5/gap5rc
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+
+Added an interface to save heterozygous bases in the consensus.
+
+Internally there are some new functions for this too (eg
+calculate_consensus_simple_het) as well as some experimental only
+functions for evaluation of SNP calling. (It is not expected that Gap5
+will perform well here.)
+
+------------------------------------------------------------------------
+r3698 | jkbonfield | 2014-07-08 15:29:41 +0100 (Tue, 08 Jul 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Fixed a bug in r3655 caused by failure to save bin ranges after
+modifying.  This causes thousands of errors after inserting columns of
+bases (eg via shuffle_pads).
+
+------------------------------------------------------------------------
+r3697 | jkbonfield | 2014-07-02 15:31:59 +0100 (Wed, 02 Jul 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/course/data/shotgun_data/DEMO.0.log
+   M /staden/trunk/course/data/shotgun_data/xb54f3.s1ta.exp
+   M /staden/trunk/course/data/shotgun_data/xb56a5.s1.exp
+   M /staden/trunk/demo/gap4/DEMO.0
+   M /staden/trunk/demo/gap4/DEMO.0.aux
+   M /staden/trunk/doc/Makefile
+   A /staden/trunk/doc/manual/test.texi
+   M /staden/trunk/src/gap5/gap5rc
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/seq_utils/align_lib.c
+
+Tweaks to the shuffle pads scoring system, in particular what tables
+it uses for the non-linear transforms (sinh vs log) as both have their
+particular strengths and weaknesses.
+
+The default is now to use soft-clips in the editor too for
+realignment.
+
+------------------------------------------------------------------------
+r3696 | jkbonfield | 2014-07-02 15:17:33 +0100 (Wed, 02 Jul 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/fij.tcl
+
+Added back Mask/Mark consensus filtering modes to Find Internal Joins.
+
+------------------------------------------------------------------------
+r3683 | jkbonfield | 2014-06-27 14:02:07 +0100 (Fri, 27 Jun 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/consen.c
+   M /staden/trunk/src/gap5/consen.h
+   M /staden/trunk/src/gap5/consen.tcl
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+   M /staden/trunk/src/gap5/gap_globals.c
+
+Fixed Mask/Mark consensus and also updated the gap5_cmd consensus
+function to allow specifying of arbitrary maps for masking purposes.
+
+------------------------------------------------------------------------
+r3674 | jkbonfield | 2014-06-11 16:28:22 +0100 (Wed, 11 Jun 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+
+Sanitise TGILIBS to use GAP5_LIBS and also removed the duplicate
+SEQUTILS_LIBS from GAP5_LIBS.
+
+This fix will also prevent the explicit -L/usr/lib64 -ltcl8.5 link
+line on Fedora from capturing a system libstaden-read.so in preference
+to the one we attempted to link against.
+
+------------------------------------------------------------------------
+r3661 | daviesrob | 2014-05-28 15:15:35 +0100 (Wed, 28 May 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+
+Stop undo list from being converted to a string, just to see if it's empty.
+
+------------------------------------------------------------------------
+r3658 | daviesrob | 2014-05-22 09:40:29 +0100 (Thu, 22 May 2014) | 5 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Rewrite of contig_insert_base2.
+
+The new version is much shorter and less byzantine than the previous one.
+
+
+------------------------------------------------------------------------
+r3657 | jkbonfield | 2014-05-21 12:35:46 +0100 (Wed, 21 May 2014) | 34 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/seq_utils/align_lib.c
+   M /staden/trunk/src/seq_utils/align_lib.h
+
+Many changes to shuffle pads implementation.
+
+The malign code in align_lib now copes with start/end range being
+something other than 1..length. This makes it far more efficient at
+dealing with sub-sections of a contig.
+
+Added a EDGE_GAPS_MAXY cost to block shifting the consensus to match
+the sequence (vice versa is OK). In essence this is moving the
+sequence beyond the end of the consensus, which can cause problems in
+BAM world if we get coordinates < 1.
+
+Adjusted the malign scores. It's now hard coded for DNA only, but it
+was never used on proteins anyway. The scaling of scores is still 0 to
+128, but now it is nonlinear and not in direct proportion to the
+fraction of base type in the consensus vector. This was arrived at by
+experimentation.
+
+There is also an optional second scoring method for pads, which works
+in some cases and not in others. This is selected by specifying
+gap_extend to be 0 (gap_extend has been ignored for years, since we
+switched from affine alignments). The shuffle pads code now executes
+both modes in an attempt to find the best alignments.
+
+When evaluating our realigned soft-clips we first undo the clipped
+before recomputing the new consensus vector. This avoids a circular
+argument and means we can only extend into heterozygous cutoffs when
+there was already the same heterozygosity in the originally clipped
+data.
+
+Finally, adjusted the soft clipped scoring method to promote more
+extension before realignment, but harsher when validating whether to
+keep the alignments.
+
+
+------------------------------------------------------------------------
+r3656 | jkbonfield | 2014-05-21 12:17:34 +0100 (Wed, 21 May 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_index.c
+
+Rename g_index to tg_index in usage output.
+
+------------------------------------------------------------------------
+r3655 | daviesrob | 2014-05-20 16:30:34 +0100 (Tue, 20 May 2014) | 85 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/gap5_del_test.tcl
+   M /staden/trunk/src/gap5/tg_check.c
+   M /staden/trunk/src/gap5/tg_contig.c
+   M /staden/trunk/src/gap5/tg_contig.h
+   M /staden/trunk/src/gap5/tg_sequence.c
+   M /staden/trunk/src/gap5/tg_sequence.h
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+More reworking of contig insertion / deletion code.
+
+The tcl code to undo consensus base deletion has been simplified by creating a
+contig insert_column interface, which takes the list of reads and base calls in
+the undo stack and applies it to the column being inserted.  This allows the C
+code to do a much more complete job than the old insert_base code, so the tcl
+part does not need to do as much cleaning up.  This also means there is less
+need to iterate around the bin tree.
+
+Consensus base deletion now also stores undo information for reference position
+markers.  As deleting a base may cause markers to be merged, the only way to
+get them back when undoing is to know what markers were present in the first
+place.
+
+Various edge cases and problems with complemented bins have been fixed.
+
+tg_tcl.c
+  Added contig insert_column, find_refpos_marker, set_refpos_marker and
+delete_refpos_marker interfaces.
+
+tg_contig.c
+tg_contig.h
+  Made it easier to turn debugging code on and off.
+
+  Added new contig_insert_column() function.  This is like contig_insert_base,
+but can be passed an array listing the base and confidence value to be inserted
+into each read in the column.  This is used to make a hash table which is
+passed to contig_insert_base_common and then contig_insert_base2 so the updates
+can be made reasonably efficiently without having to do too many traverses of
+the bin tree.
+
+  Update contig_insert_base2 to take the pileup hash, and to fix more edge
+case and complemented bin issues.
+
+  Ensure bin_incr_nseq() is only called for sequences in contig_delete_base2.
+
+  Improved calculation of moved_left, moved_right and fixed_right in
+contig_delete_base2.
+
+  Allow deletion of the first base of the contig in contig_delete_base_common.
+
+  Reworked refpos marker code to simplify it and to fix a bug where some
+deletion markers were not removed in contig_delete_base_common causing them
+to pile up.
+
+  Added set_refpos_marker() and delete_refpos_marker() functions.  These are
+called from the tcl interfaces in tg_tcl.c
+
+tg_sequence.c
+tg_sequence.h
+
+  Pass in comp to sequence_insert_bases, which should be 1 if the current bin
+is complemented.  This means it's possible to work out if the base call should
+be complemented or not when inserting in bin orientation.  The value passed in
+is ignored if in contig_orientation.
+
+tg_check.c
+
+  In bin_walk, when an incorrect nseqs or nanno count is found, print out what
+the stored and actual values were.
+
+contig_editor.tcl
+
+  C_INS undo code now uses $contig insert_column instead of insert_base.  This
+allowed a lot of code that was fixing eveything $contig insert_base had not
+done correctly to be removed.
+
+  Added RP_SET and RP_DEL undo commands.
+
+  Made editor_delete_cons_base store undo for any reference position markers
+that could be affected.  This is the only way to guarantee that the undo
+operation can get them back as they were before.
+
+gap5_del_test.tcl
+
+  Made the basic test run on a complemented bin as well as an uncomplemented
+one.
+
+  Make do_test compare sam files for the before and after complemented case.
+
+Makefile
+
+  Recalculated dependencies.
+
+
+------------------------------------------------------------------------
+r3651 | jkbonfield | 2014-05-08 15:25:15 +0100 (Thu, 08 May 2014) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Bug fix to bounds checking of cons[p]. Remember it's not start..end
+but 0..end-start.
+
+Inconsequential update to the scoring functions; the match and
+mismatch costs are now #defines (but the same as before).
+
+------------------------------------------------------------------------
+r3650 | jkbonfield | 2014-05-06 17:10:18 +0100 (Tue, 06 May 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Now more rigorous bounds checking in rewrite_soft_clips(), curing some
+crashes.
+
+concordant_soft_clips() is now more liberal with the scoring when
+extending into cutoff, to allow for misalignments of the cutoff data.
+The final assessment post re-alignment within rewrite_soft_clips() is
+still using the original scores so this shouldn't cause problems.
+
+------------------------------------------------------------------------
+r3649 | jkbonfield | 2014-05-06 17:07:14 +0100 (Tue, 06 May 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/seq_utils/align_lib.c
+
+Cull some of the old malign scoring methods in scale_malign_scores().
+
+Switched to a new version that scores based on log(count) instead of
+count. This allows for better multiple sequence alignments within
+heterozygous regions, so that we don't overly penalise the rare allele
+but still prefer to align correctly.
+
+------------------------------------------------------------------------
+r3648 | jkbonfield | 2014-05-02 14:20:48 +0100 (Fri, 02 May 2014) | 10 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Bug fix to the recent update to look at consensus heterozygous bases
+(typo leading to crash).
+
+Make the concordant clip detection more liberal to start with (it'll
+filter out those with turn out to be incorrect).
+
+Remove pad columns both both and after rewriting the clips, as
+series of pads left in the consensus was causing the seq-matches-cons
+check to fail early.
+
+------------------------------------------------------------------------
+r3647 | jkbonfield | 2014-05-02 12:26:52 +0100 (Fri, 02 May 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/shuffle_pads.h
+
+Renamed coherent to concordant for the soft-clipping strategy. This is
+the more appropriate English word.
+
+------------------------------------------------------------------------
+r3646 | jkbonfield | 2014-05-02 12:20:38 +0100 (Fri, 02 May 2014) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Fixed missing output of print_malign (unused unless uncommented out).
+
+Changed the cutoff evaluation and extension to align against
+heterozygous calls rather than single base consensus call. This allows
+it to extend reads into cutoffs in more situations.
+
+------------------------------------------------------------------------
+r3645 | jkbonfield | 2014-05-02 09:46:53 +0100 (Fri, 02 May 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Fixed @SQ line LN: field to use the clipped contig length instead of
+unclipped.
+
+------------------------------------------------------------------------
+r3644 | jkbonfield | 2014-05-01 16:52:07 +0100 (Thu, 01 May 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Further improvements to samtools output with fixmates.
+
+------------------------------------------------------------------------
+r3643 | jkbonfield | 2014-05-01 14:59:20 +0100 (Thu, 01 May 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+When realigning including cutoffs, the trim and re-extend process at
+the end extends the sequence for as far as it matches the consensus.
+
+We now have a small caveat on this such that it will backtrack to the
+first non-pad character after the extension, to avoid leaving trailing
+pads on the ends of reads.
+
+------------------------------------------------------------------------
+r3642 | jkbonfield | 2014-05-01 14:57:59 +0100 (Thu, 01 May 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Attempt to improve mate pos when using fix-mates output of SAM in
+conjunction with refpos depadding.
+
+------------------------------------------------------------------------
+r3641 | jkbonfield | 2014-05-01 11:50:26 +0100 (Thu, 01 May 2014) | 26 lines
+Changed paths:
+   M /staden/trunk/src/gap5/editor_view.c
+   M /staden/trunk/src/gap5/export_contigs.c
+   M /staden/trunk/src/gap5/export_contigs.tcl
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/sam_pileup.h
+   M /staden/trunk/src/gap5/tg_contig.c
+   M /staden/trunk/src/gap5/tg_contig.h
+
+1. Added an extra depadding option to Export Contigs; reference sequence
+positions (in addition to the old padded and unpadded consensus mode).
+The purpose of this is to allow tg_index to import a sam/bam/cram, run
+tools like Shuffle Pads on it, and then export back in the same
+coordinate system as the original BAM.
+
+It is not expected to work after joining and breaking has been
+applied, although it needs better error handling to cope with this
+more gracefully.
+
+Updated the padded_to_reference_array() function to aid this work.
+
+
+2. Fixed a bug in create_ref_seq(). It was producing incorrect .fai
+files for contigs that do not start at base 1.
+
+
+3. Fixed memory corruption in sam_add_seq() caused when using
+excessive padding in CIGAR ops during tg_index.
+
+
+4. Bug fix to contig_insert_base_common() when manipulating the
+REF_POS markers.  It wasn't coping correctly with this in some
+complemented scenarios and with nbases > 1.
+
+
+------------------------------------------------------------------------
+r3640 | daviesrob | 2014-04-29 10:16:55 +0100 (Tue, 29 Apr 2014) | 38 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5_del_test.tcl
+   M /staden/trunk/src/gap5/tg_bin.c
+   M /staden/trunk/src/gap5/tg_check.c
+   M /staden/trunk/src/gap5/tg_contig.c
+   M /staden/trunk/src/gap5/tg_sequence.c
+
+Various fixes to keep contig start/end correct.
+
+tg_check.c
+  In check_contig, print out start and end positions in the contig and those
+from the bin walk when they disagree.
+
+tg_bin.c
+  Fixed bug in bin_remove_item_from_bin where used start/end were not swapped
+for complemented bins when mapping to the position in the parent.  This could
+lead to the contig unclipped start/end not being recalculated when they should
+have been.
+
+tg_sequence.c
+  Add code to update contig used start/end and clipped_timestamp when
+necessary in sequence_move.
+
+tg_contig.c
+  Altered the way that contig_insert_base and contig_delete_base keep track of
+which ends of the contig may have changed.  This fixes several cases where the
+contig start/end were not updated as they should have been.
+  Modified read shifting code in contig_insert_base2 and contig_delete_base2. 
+The new version moves the same reads for both complemented and uncomplemented
+bins.
+  Renamed some variables to make the operation of the code less obscure,
+e.g. r_start, r_end to v_start,v_end in contig_insert_base2 and
+contig_delete_base2; ins,no_ins to del,no_del in contig_delete_base2.
+  Added some comments.
+
+gap5_del_test.tcl
+  Added test to ensure cutoff data at the start/end of the contig is handled
+correctly.
+  Made the test script stop but not exit on failure.  This allows the
+situation to be checked manually.
+  Made some tests run on complemented contigs as well.
+  Temporarily disabled the pattern tests to allow a faster iteration through
+the random ones.
+
+
+------------------------------------------------------------------------
+r3639 | jkbonfield | 2014-04-28 12:23:03 +0100 (Mon, 28 Apr 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/tracediff/main.cpp
+
+Replaced the potentially ambiguous copyright notice with the full root
+copyright notice (although we don't actually bother to have any in
+most of the files).
+
+When MRC open-sourced the software they sent me the original
+(LICENCE.txt) copyright notice for it to be applied to all the
+software.  Any internal MRC specific copyrights left in place are an
+accidental and  superceded.
+
+------------------------------------------------------------------------
+r3636 | jkbonfield | 2014-04-14 11:29:30 +0100 (Mon, 14 Apr 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_cache.c
+
+Minor comment tidyup
+
+------------------------------------------------------------------------
+r3622 | daviesrob | 2014-04-07 12:45:07 +0100 (Mon, 07 Apr 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_bin.c
+
+Made bin_add_to_range explicitly check for sequences beyond clipped_start/end
+
+bin_add_to_range would fail to set (*c)->clipped_timestamp = 0 if a sequence
+being added was within the existing contig used start/end but caused the
+clipped_start/end to change.  Added a check to see if the new range may
+go beyond clipped_start or clipped_end, and reset clipped_timestamp if
+this is the case.
+
+------------------------------------------------------------------------
+r3616 | daviesrob | 2014-04-04 13:43:20 +0100 (Fri, 04 Apr 2014) | 1 line
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/gap5_del_test.tcl
+
+Debugging aids for contig deletion/insertion
+------------------------------------------------------------------------
+r3615 | daviesrob | 2014-04-04 13:40:08 +0100 (Fri, 04 Apr 2014) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Fixed occasional incorrect update of contig used end position.
+
+Put in check that seq_end has actually been set in contig_insert_base2
+before using the value.
+
+Removed some dead code.
+
+------------------------------------------------------------------------
+r3612 | daviesrob | 2014-04-02 12:44:48 +0100 (Wed, 02 Apr 2014) | 12 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/tg_check.c
+   M /staden/trunk/src/gap5/tg_sequence.c
+   M /staden/trunk/src/gap5/tg_sequence.h
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Remove duplicate move_seq code and ensure annotations are in same bin as seq.
+
+The code for MOVE_SEQ in contig_cmd could move sequences to new bins without
+ensuring that the annotations were moved as well.  The version in
+sequence_move did fix the annotations, so made contig_cmd call this instead
+of using its own code.
+
+sequence_move now takes a contig_t ** so it can update the location of
+the contig record in the caller should it get checked out.  It also gets a
+prototype in tg_sequence.h
+
+
+------------------------------------------------------------------------
+r3611 | daviesrob | 2014-04-02 12:43:45 +0100 (Wed, 02 Apr 2014) | 1 line
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Stop tags from extending at the contig end when inserting consensus bases
+------------------------------------------------------------------------
+r3600 | daviesrob | 2014-03-19 16:33:20 +0000 (Wed, 19 Mar 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_check.c
+
+Disabled fix for annotations that do not overlap the annotated object.
+
+Trying to move the annotation to a new bin causes problems in bin_walk which
+expects the items in the bins to remain stable.  This leads it to try to
+fix problems that aren't really there resulting in a database that is in
+a much worse state that it was to start with.  Disabling the annotation
+fix prevents this.
+
+------------------------------------------------------------------------
+r3598 | daviesrob | 2014-03-14 17:02:32 +0000 (Fri, 14 Mar 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/auto_break.c
+   M /staden/trunk/src/gap5/contig_extend.c
+   M /staden/trunk/src/gap5/sam_index.c
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/template_display.c
+   M /staden/trunk/src/gap5/template_draw.c
+   M /staden/trunk/src/gap5/tg_index.h
+   M /staden/trunk/src/gap5/tg_index_common.c
+
+Fix compiler warnings.
+
+Mainly missing prototypes, a few char subscripts and some missing braces.
+
+------------------------------------------------------------------------
+r3597 | daviesrob | 2014-03-14 15:10:31 +0000 (Fri, 14 Mar 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_iface_g.c
+   M /staden/trunk/src/gap5/tg_struct.h
+
+Changed flags in contig_t struct from tg_rec to uint32_t
+
+Done to match what is stored in the database.
+
+------------------------------------------------------------------------
+r3596 | daviesrob | 2014-03-14 12:28:38 +0000 (Fri, 14 Mar 2014) | 8 lines
+Changed paths:
+   A /staden/trunk/src/gap5/test
+   A /staden/trunk/src/gap5/test/test_tg_utils.c
+   M /staden/trunk/src/gap5/tg_utils.c
+
+Fixed handling of INT32_MIN in s72int and INT64_MIN in s72intw
+
+int2s7 and intw2s7 both encode the lowest possible integer value with the
+output code 1, which was converted to 0 by s72int and s72intw.  Fixed the
+latter so they output the correct value instead.  Also added some test code
+to exercise these functions, including testing all the extreme values.
+
+
+------------------------------------------------------------------------
+r3595 | jkbonfield | 2014-03-11 14:46:58 +0000 (Tue, 11 Mar 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Fixed exporting CRAM in padded mode. It was outputting a depadded
+consensus, causing CRAM to work excessively hard in encoding reference
+differences.
+
+------------------------------------------------------------------------
+r3594 | jkbonfield | 2014-03-11 09:35:36 +0000 (Tue, 11 Mar 2014) | 13 lines
+Changed paths:
+   M /staden/trunk/src/gap5/g-request.c
+
+Added back fsync of main .g5d file when flushing.
+
+This will slow things down slightly, depending on how often flushes
+occur, but resolves some database corruptions we've been seeing.
+
+Specifically if a user has gap5 open on one machine, makes changes and
+saves the DB, then creates a backup of the database on the command
+line on a different machine[1] then there is a chance that NFS hasn't
+correctrly synced the changes yet. This call forces that to happen.
+
+[1] This happens a lot here due to using load-sharing to launch gap5
+on one of several nodes in a cluster.
+
+------------------------------------------------------------------------
+r3591 | jkbonfield | 2014-03-04 17:17:20 +0000 (Tue, 04 Mar 2014) | 8 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/shuffle_pads.h
+
+Added an automatic adapter detector. This works by hashing the
+soft-clip and hashing the used data (FIXME: need to strip pads) and
+then comparing the distributions.
+
+Also reduced memory and potentially sped up on very long contigs by
+doing shuffle pads in 32Kb windows. This avoids purging of memory
+cache.
+
+------------------------------------------------------------------------
+r3590 | jkbonfield | 2014-03-04 14:35:38 +0000 (Tue, 04 Mar 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/editor_view.c
+
+Fixed bug in ed_set_sequence_sort(). It wasn't correctly handling the
+variation of selection end < start.
+
+------------------------------------------------------------------------
+r3588 | jkbonfield | 2014-02-28 15:30:34 +0000 (Fri, 28 Feb 2014) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/shuffle_pads.c
+
+Improvements to Shuffle Pads's validate_clip() function. Using a
+similar method to rewrite_soft_clips (possibly the validation should
+be merged into that code), it now counts differences to the
+consensus.  This is often more reliable than counting SNP consensus
+bases when faced with highly varying read depth.
+
+------------------------------------------------------------------------
+r3587 | jkbonfield | 2014-02-28 12:44:58 +0000 (Fri, 28 Feb 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap4/edMutations.c
+
+Fixed a bug in showing the reading-frame translations. It's a 1 byte
+buffer overrun that has existed since ~2002.
+
+------------------------------------------------------------------------
+r3583 | jkbonfield | 2014-02-27 11:19:20 +0000 (Thu, 27 Feb 2014) | 19 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+   M /staden/trunk/src/gap5/gap5_thrash.tcl
+   M /staden/trunk/src/gap5/gap5rc
+   M /staden/trunk/src/gap5/newgap5_cmds.c
+   M /staden/trunk/src/gap5/newgap_structs.h
+   M /staden/trunk/src/gap5/shuffle_pads.c
+   M /staden/trunk/src/gap5/shuffle_pads.h
+   M /staden/trunk/src/gap5/shuffle_pads.tcl
+
+Added an option to Shuffle Pads to use the cutoff/soft-clip data.
+
+This is quite complex as it performs multiple passes. Firstly it looks
+for "coherent soft-clips"; regions with multiple sequences
+soft-clipped with the cutoffs in agreement with one another. Then it
+extends sequences into the cutoffs before running shuffle pads.
+
+Once realigned, it then inspects the data to check that the unclipped
+reads align. If so then they are kept, if not then they are tagged
+with CLIP and the clips are trimmed back to where they agree with the
+consensus.
+
+Finally special care is taken around consensus Ns. These are included
+in local conventions by faking scaffolds, placing contigs next to each
+other in the same "contig". Sometimes the realignment will resolve and
+join them together, but often it produces unaligned data. In that case
+we attempt to unclip and recreate the N as a internal scaffold marker,
+but it's not bullet proof.
+
+------------------------------------------------------------------------
+r3582 | jkbonfield | 2014-02-26 12:10:55 +0000 (Wed, 26 Feb 2014) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_contig.c
+
+Optimised contig_insert_base2 and contig_delete_base2.  The main
+change is avoiding recomputing contig ends all the while. Often we can
+work out what the change will be (eg we're in a bin in the middle of
+the contig) and it's only at the boundary bins where it gets more
+complex. So we avoid brute force calculations where possible.
+
+Also updated contig_shift_base to accept +N and -N to shift by more
+than 1 bp.
+
+------------------------------------------------------------------------
+r3581 | jkbonfield | 2014-02-26 12:08:33 +0000 (Wed, 26 Feb 2014) | 3 lines
+Changed paths:
+   M /staden/trunk/src/Misc/array.h
+
+Added an ArrayPush macro. Basically it's just a short-hand for
+appending to the end of an array.
+
+------------------------------------------------------------------------
+r3580 | jkbonfield | 2014-02-24 17:33:57 +0000 (Mon, 24 Feb 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_struct.h
+
+Fix to ANNO_DIR_REV, but apparently it is unused.
+
+------------------------------------------------------------------------
+r3565 | awhitwham | 2014-01-24 10:16:04 +0000 (Fri, 24 Jan 2014) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_index.c
+   M /staden/trunk/src/gap5/tg_index.h
+   M /staden/trunk/src/gap5/tg_index_common.c
+
+Changed the name index sorting mechanism of tg_index.  Should be faster.
+
+------------------------------------------------------------------------
+r3564 | jkbonfield | 2014-01-17 09:45:44 +0000 (Fri, 17 Jan 2014) | 16 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_cache.c
+   M /staden/trunk/src/gap5/tg_gio.h
+   M /staden/trunk/src/gap5/tg_index_common.c
+
+Reduced the volume of read-pair entries dumped to the /tmp file.
+
+Previously when we saw Read.1st we recorded it in a hash table and then
+when we found Read.2nd we linked it back to Read.1st and recorded in
+the temporary file a request to link Read.1st to Read.2nd in a second
+pass. (As doing this immediately causes a lot of disk thrashing due to
+chimeras, mismatches, genome shuffling etc.)
+
+Now we also make the forward link of Read.1st to Read.2nd if it is
+within a bin that is still held in the in-memory cache and is still
+locked for read-write (meaning it is yet to be saved/flushed).
+
+On a 3Gb bam file test this reduced the number of entries stored in
+the tmp file for 2nd pass from 15.9 million down to 0.6 million. The
+effect on speed was slight - only 3% quicker overall.
+
+------------------------------------------------------------------------
+r3563 | jkbonfield | 2014-01-16 16:19:54 +0000 (Thu, 16 Jan 2014) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/editor_view.c
+   M /staden/trunk/src/gap5/list_proc.tcl
+   M /staden/trunk/src/gap5/tg_tcl.c
+
+Added Template Status and Library Name to the multi-column list
+viewer.
+
+Also fixed a bug discovered in edview_items_between() which could
+return record numbers for cached consensus.
+
+------------------------------------------------------------------------
+r3562 | jkbonfield | 2014-01-16 14:10:04 +0000 (Thu, 16 Jan 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/depth.tcl
+
+Changed the click and drag bindings to check whether the initial press
+came from a double-1 binding to move the editor cursor. If so drag the
+cursor, otherwise do the old plot-drag code.
+
+------------------------------------------------------------------------
+r3561 | jkbonfield | 2014-01-16 11:53:37 +0000 (Thu, 16 Jan 2014) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/depth.tcl
+   M /staden/trunk/src/gap5/gap5rc_menu_full
+
+Added Shift-Function-key and Function-key bindings to the template
+display to store and restore the current configuration. Additionally
+this can be saved to ~/.gap5rc via the File->Save Settings option.
+
+
+
+========================================================================
+RELEASED 2.0.0b10
+
+------------------------------------------------------------------------
+r3554 | jkbonfield | 2013-12-18 16:36:35 +0000 (Wed, 18 Dec 2013) | 8 lines
+Changed paths:
+   M /staden/trunk/src/seq_utils/Makefile
+
+Use text_utils instead of tk_utils as vector_clip was inheriting a
+dependency on tk86.dll which bizarrely then crashes on program exit.
+
+The reason we switched to tk_utils instead of text_utils was, I think,
+originally due to inanities of the macosx linker disallowing linking
+against seq_utils and tk_utils within, say, gap4. But both that and
+windows now work.
+
+------------------------------------------------------------------------
+r3553 | jkbonfield | 2013-12-18 16:33:41 +0000 (Wed, 18 Dec 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/pregap4/modules/interactive_clip.p4m
+
+Fixed launching of Trev to avoid knowing the wish executable name.
+
+------------------------------------------------------------------------
+r3552 | jkbonfield | 2013-12-18 12:37:05 +0000 (Wed, 18 Dec 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/auto_build/remote.windows-i386
+   M /staden/trunk/auto_build/remote.windows-x86_64
+
+Bug fix to Gap4 - it's gap.exe and not gap4.exe that we need.
+
+------------------------------------------------------------------------
+r3551 | jkbonfield | 2013-12-18 12:28:28 +0000 (Wed, 18 Dec 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/windows/inno_setup/staden_config.iss
+
+Minor updates to windows setup: icon file locations; Start menu contents.
+
+------------------------------------------------------------------------
+r3550 | jkbonfield | 2013-12-18 12:27:28 +0000 (Wed, 18 Dec 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/g-files.c
+
+Bug fix for Windows - force opening in O_BINARY mode.
+
+------------------------------------------------------------------------
+r3545 | jkbonfield | 2013-12-16 14:31:51 +0000 (Mon, 16 Dec 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/auto_build/Makefile
+   M /staden/trunk/auto_build/local.lucid-i386
+   M /staden/trunk/auto_build/local.macosx
+   M /staden/trunk/auto_build/local.precise-x86_64
+   M /staden/trunk/auto_build/local.windows-i386
+   M /staden/trunk/auto_build/local.windows-x86_64
+   M /staden/trunk/auto_build/remote.lucid-i386
+   M /staden/trunk/auto_build/remote.macosx
+   M /staden/trunk/auto_build/remote.precise-x86_64
+   M /staden/trunk/auto_build/remote.windows-i386
+   M /staden/trunk/auto_build/remote.windows-x86_64
+
+Added documentation to the generated tarballs.
+Also produce lzma versions for linux.
+
+------------------------------------------------------------------------
+r3544 | jkbonfield | 2013-12-16 11:35:02 +0000 (Mon, 16 Dec 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/auto_build/Makefile
+   M /staden/trunk/auto_build/config
+   M /staden/trunk/auto_build/local.macosx
+   M /staden/trunk/auto_build/local.windows-i386
+   M /staden/trunk/auto_build/local.windows-x86_64
+
+Fixes to cope with moving the auto_build directory.
+
+------------------------------------------------------------------------
+r3543 | jkbonfield | 2013-12-16 11:28:11 +0000 (Mon, 16 Dec 2013) | 2 lines
+Changed paths:
+   A /staden/trunk/auto_build/README
+   A /staden/trunk/auto_build/README.linux
+   A /staden/trunk/auto_build/README.macosx
+   A /staden/trunk/auto_build/README.windows
+
+Docs for local machines.
+
+------------------------------------------------------------------------
+r3542 | jkbonfield | 2013-12-16 11:08:55 +0000 (Mon, 16 Dec 2013) | 6 lines
+Changed paths:
+   A /staden/trunk/auto_build
+   A /staden/trunk/auto_build/Makefile
+   A /staden/trunk/auto_build/config
+   A /staden/trunk/auto_build/local.lucid-i386
+   A /staden/trunk/auto_build/local.macosx
+   A /staden/trunk/auto_build/local.precise-x86_64
+   A /staden/trunk/auto_build/local.windows-i386
+   A /staden/trunk/auto_build/local.windows-x86_64
+   A /staden/trunk/auto_build/remote.lucid-i386
+   A /staden/trunk/auto_build/remote.macosx
+   A /staden/trunk/auto_build/remote.precise-x86_64
+   A /staden/trunk/auto_build/remote.windows-i386
+   A /staden/trunk/auto_build/remote.windows-x86_64
+
+Added auto_build directory. This contains Makefiles and shell scripts
+for local use in Sanger to build distributions on a variety of
+platforms.  It is designed to speed up the release cycle.
+
+(Still a work in progress.)
+
+------------------------------------------------------------------------
+r3541 | jkbonfield | 2013-12-13 17:56:44 +0000 (Fri, 13 Dec 2013) | 2 lines
+Changed paths:
+   A /staden/trunk/src/windows/inno_setup
+   A /staden/trunk/src/windows/inno_setup/splash.bmp
+   A /staden/trunk/src/windows/inno_setup/staden_config.iss
+
+Added InnoSetup configuration for building windows installations.
+
+------------------------------------------------------------------------
+r3539 | jkbonfield | 2013-12-13 16:55:30 +0000 (Fri, 13 Dec 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/ac_stubs/tcl.m4
+   M /staden/trunk/src/configure.in
+   M /staden/trunk/src/staden_config.h.in
+
+Updated to newer version of tcl.m4 to better support cross-compiling
+for windows.
+
+------------------------------------------------------------------------
+r3538 | jkbonfield | 2013-12-13 14:18:15 +0000 (Fri, 13 Dec 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/tk_utils/tkTraceDisp.c
+
+Renamed Winport to WinPort as case matters when cross-compiling from linux.
+
+------------------------------------------------------------------------
+r3537 | jkbonfield | 2013-12-13 14:17:42 +0000 (Fri, 13 Dec 2013) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/fasta.c
+
+Added staden_config.h for belt and braces. I don't think it's needed
+now that I fixed an issue elsewhere, but it ought to have it
+explicitly included anyway.
+
+------------------------------------------------------------------------
+r3536 | jkbonfield | 2013-12-13 14:16:56 +0000 (Fri, 13 Dec 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/Makefile
+
+Removed tg_view. It doesn't work on windows (unless we build our own
+curses) and is pretty pointless now anyway.
+
+------------------------------------------------------------------------
+r3535 | jkbonfield | 2013-12-13 14:16:28 +0000 (Fri, 13 Dec 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/windows/run/main.cpp
+
+Updated to work with tcl8.6 and also now adds lib directory to PATH so
+dlls don't need to be in the main bin directory.
+
+------------------------------------------------------------------------
+r3534 | jkbonfield | 2013-12-13 14:15:36 +0000 (Fri, 13 Dec 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/windows/run/Makefile
+
+Added $(COMPILER) to Makefile as a command prefix so we can override
+it for cross-compilers.
+
+------------------------------------------------------------------------
+r3527 | jkbonfield | 2013-11-29 10:13:20 +0000 (Fri, 29 Nov 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/pregap4/modules/interactive_clip.p4m
+   M /staden/trunk/src/tk_utils/stash
+
+Fixes to cope with spaces in filenames.
+
+------------------------------------------------------------------------
+r3526 | jkbonfield | 2013-11-21 15:36:07 +0000 (Thu, 21 Nov 2013) | 9 lines
+Changed paths:
+   M /staden/trunk/src/gap5/template_draw.c
+
+Fixed a bizarre red/blue colour swap on Windows. It seems to have been
+there several years. I'm not sure of the reason for it, but also see
+http://sourceforge.net/p/tktoolkit/bugs/1049/ for further discussion
+on the matter.
+
+That bug was rejected, but I do wonder if it's still there. Tested
+against Windows Server 2008 R2 and Win XP, both had the error and both
+now display correctly.
+
+------------------------------------------------------------------------
+r3525 | jkbonfield | 2013-11-21 15:34:16 +0000 (Thu, 21 Nov 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/b+tree2.h
+
+Fix when cross-compiling. (Missing int*_t)
+
+------------------------------------------------------------------------
+r3524 | jkbonfield | 2013-11-21 14:15:26 +0000 (Thu, 21 Nov 2013) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/template_draw.c
+
+A better fix to the template X Image handling. Blinding calling
+ckalloc and ckfree works for Windows, but then causes crashes on Unix
+for the same reasons we had crashes on Windows when using malloc/free.
+
+We now pick and choose which functions to use based on the OS.
+
+------------------------------------------------------------------------
+r3523 | jkbonfield | 2013-11-21 10:44:50 +0000 (Thu, 21 Nov 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/eba/conf.c
+   M /staden/trunk/src/gap5/tg_tcl.c
+   M /staden/trunk/src/hetins/hetins.c
+   M /staden/trunk/src/init_exp/init_exp.c
+
+Minor compilation warnings removed, particularly with respect to
+Windows building.
+
+------------------------------------------------------------------------
+r3522 | jkbonfield | 2013-11-20 17:29:17 +0000 (Wed, 20 Nov 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/gap5/contig_editor.tcl
+   M /staden/trunk/src/gap5/depth.tcl
+
+Fixed mouse wheel bindings for Windows in template display and contig
+editor.
+
+------------------------------------------------------------------------
+r3521 | jkbonfield | 2013-11-20 16:32:07 +0000 (Wed, 20 Nov 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap4/IO1.h
+
+Renamed #ifdef _IO_H_ guard. Forgot this in io to io1 rename.
+
+------------------------------------------------------------------------
+r3520 | jkbonfield | 2013-11-20 15:36:21 +0000 (Wed, 20 Nov 2013) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/template_draw.c
+
+Switched to using ckalloc and ckfree for image->buf as this is copied
+into the XImage and sometimes freed by Tcl. (On windows if tcl frees it
+we must allocate it using ckalloc.)
+
+------------------------------------------------------------------------
+r3519 | jkbonfield | 2013-11-20 15:33:35 +0000 (Wed, 20 Nov 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/tk_utils/tkWinX.c
+
+Renamed tkpWinRopModes to a static sp_tkpWinRopModes to avoid clashes
+with the same named variable in tk8.6 distribution.
+
+------------------------------------------------------------------------
+r3518 | jkbonfield | 2013-11-20 15:32:25 +0000 (Wed, 20 Nov 2013) | 9 lines
+Changed paths:
+   M /staden/trunk/src/Misc/Makefile
+   M /staden/trunk/src/Misc/os.h
+   M /staden/trunk/src/abi/Makefile
+   M /staden/trunk/src/alf/Makefile
+   M /staden/trunk/src/convert/Makefile
+   M /staden/trunk/src/convert/gapDB.c
+   M /staden/trunk/src/copy_reads/Makefile
+   M /staden/trunk/src/eba/Makefile
+   M /staden/trunk/src/find_renz/Makefile
+   M /staden/trunk/src/g/Makefile
+   D /staden/trunk/src/gap4/IO.c
+   D /staden/trunk/src/gap4/IO.h
+   A /staden/trunk/src/gap4/IO1.c (from /staden/trunk/src/gap4/IO.c:3509)
+   A /staden/trunk/src/gap4/IO1.h (from /staden/trunk/src/gap4/IO.h:3509)
+   M /staden/trunk/src/gap4/IO2.c
+   M /staden/trunk/src/gap4/IO3.c
+   M /staden/trunk/src/gap4/Makefile
+   M /staden/trunk/src/gap4/alter_rel.c
+   M /staden/trunk/src/gap4/alter_rel.h
+   M /staden/trunk/src/gap4/assemble_direct.c
+   M /staden/trunk/src/gap4/assemble_direct.h
+   M /staden/trunk/src/gap4/auto_assemble.c
+   M /staden/trunk/src/gap4/auto_break.c
+   M /staden/trunk/src/gap4/break_contig.c
+   M /staden/trunk/src/gap4/break_contig.h
+   M /staden/trunk/src/gap4/check_assembly.c
+   M /staden/trunk/src/gap4/clip.h
+   M /staden/trunk/src/gap4/clones.c
+   M /staden/trunk/src/gap4/clones.h
+   M /staden/trunk/src/gap4/complement.c
+   M /staden/trunk/src/gap4/confidence_graph.c
+   M /staden/trunk/src/gap4/consen.c
+   M /staden/trunk/src/gap4/consen.h
+   M /staden/trunk/src/gap4/contigEditor.c
+   M /staden/trunk/src/gap4/contig_order.c
+   M /staden/trunk/src/gap4/contig_order.h
+   M /staden/trunk/src/gap4/contig_selector.c
+   M /staden/trunk/src/gap4/copy_db.c
+   M /staden/trunk/src/gap4/copy_db.h
+   M /staden/trunk/src/gap4/cs-object.h
+   M /staden/trunk/src/gap4/dbcheck.c
+   M /staden/trunk/src/gap4/dis_readings.c
+   M /staden/trunk/src/gap4/edStructs.h
+   M /staden/trunk/src/gap4/edUtils.h
+   M /staden/trunk/src/gap4/edUtils2.c
+   M /staden/trunk/src/gap4/extract.c
+   M /staden/trunk/src/gap4/fij.c
+   M /staden/trunk/src/gap4/fij.h
+   M /staden/trunk/src/gap4/find_fragments.c
+   M /staden/trunk/src/gap4/find_oligo.c
+   M /staden/trunk/src/gap4/find_repeats.c
+   M /staden/trunk/src/gap4/find_repeats.h
+   M /staden/trunk/src/gap4/gap-tcl.c
+   M /staden/trunk/src/gap4/gap-thrash2.c
+   M /staden/trunk/src/gap4/gap-thrash2bug.c
+   M /staden/trunk/src/gap4/gap-thrash3.c
+   M /staden/trunk/src/gap4/gap-thrash_main.c
+   M /staden/trunk/src/gap4/gap_canvas_box.h
+   M /staden/trunk/src/gap4/io-reg.c
+   M /staden/trunk/src/gap4/io-reg.h
+   M /staden/trunk/src/gap4/io_handle.c
+   M /staden/trunk/src/gap4/io_utils.h
+   M /staden/trunk/src/gap4/join.c
+   M /staden/trunk/src/gap4/list_proc.h
+   M /staden/trunk/src/gap4/newgap_cmds.c
+   M /staden/trunk/src/gap4/newgap_cmds.h
+   M /staden/trunk/src/gap4/newgap_structs.h
+   M /staden/trunk/src/gap4/notes.c
+   M /staden/trunk/src/gap4/oligo.c
+   M /staden/trunk/src/gap4/oligo_sel.c
+   M /staden/trunk/src/gap4/plot_quality.c
+   M /staden/trunk/src/gap4/preass.c
+   M /staden/trunk/src/gap4/probe.h
+   M /staden/trunk/src/gap4/qualIO.c
+   M /staden/trunk/src/gap4/quality_plot.c
+   M /staden/trunk/src/gap4/reactions.c
+   M /staden/trunk/src/gap4/reading_coverage.c
+   M /staden/trunk/src/gap4/readpair.c
+   M /staden/trunk/src/gap4/readpair_coverage.c
+   M /staden/trunk/src/gap4/restriction_enzymes.h
+   M /staden/trunk/src/gap4/ruler_display.c
+   M /staden/trunk/src/gap4/ruler_display.h
+   M /staden/trunk/src/gap4/seqInfo.c
+   M /staden/trunk/src/gap4/shuffle_pads.c
+   M /staden/trunk/src/gap4/shuffle_pads.h
+   M /staden/trunk/src/gap4/strand_coverage.c
+   M /staden/trunk/src/gap4/tagU2.c
+   M /staden/trunk/src/gap4/tagUtils.h
+   M /staden/trunk/src/gap4/template.c
+   M /staden/trunk/src/gap4/template.h
+   M /staden/trunk/src/gap4/template_display.h
+   M /staden/trunk/src/gap4/text-io-reg.c
+   M /staden/trunk/src/gap4/tk-io-reg.c
+   M /staden/trunk/src/gap4/tman_display.h
+   M /staden/trunk/src/gap4/vseqs.c
+   M /staden/trunk/src/gap4/vseqs.h
+   M /staden/trunk/src/gap5/Makefile
+   M /staden/trunk/src/gap5/gap5_thrash.tcl
+   M /staden/trunk/src/get_scf_field/Makefile
+   M /staden/trunk/src/haplo/Makefile
+   M /staden/trunk/src/haplo/haplo.h
+   M /staden/trunk/src/haplo/haplo_cons.c
+   M /staden/trunk/src/haplo/haplo_snps.c
+   M /staden/trunk/src/haplo/haplo_split.c
+   M /staden/trunk/src/haplo/haplo_tcl.c
+   M /staden/trunk/src/init_exp/Makefile
+   M /staden/trunk/src/make_weights/Makefile
+   M /staden/trunk/src/mutlib/Makefile
+   M /staden/trunk/src/polyA_clip/Makefile
+   M /staden/trunk/src/prefinish/Makefile
+   M /staden/trunk/src/prefinish/finish.c
+   M /staden/trunk/src/prefinish/finish.h
+   M /staden/trunk/src/prefinish/finish_long.c
+   M /staden/trunk/src/prefinish/finish_main.c
+   M /staden/trunk/src/prefinish/finish_pcr.c
+   M /staden/trunk/src/prefinish/finish_pcr.h
+   M /staden/trunk/src/prefinish/finish_reverse.c
+   M /staden/trunk/src/prefinish/finish_utils.c
+   M /staden/trunk/src/prefinish/finish_utils.h
+   M /staden/trunk/src/prefinish/finish_walk.c
+   M /staden/trunk/src/prefinish/insert_size_dist.c
+   M /staden/trunk/src/prefinish/read_conf_dist.c
+   M /staden/trunk/src/prefinish/read_size_dist.c
+   M /staden/trunk/src/qclip/Makefile
+   M /staden/trunk/src/screen_seq/Makefile
+   M /staden/trunk/src/seq_utils/Makefile
+   M /staden/trunk/src/spin/Makefile
+   M /staden/trunk/src/stops/Makefile
+   M /staden/trunk/src/text_utils/Makefile
+   M /staden/trunk/src/tk_utils/Makefile
+   M /staden/trunk/src/tracediff/Makefile
+   M /staden/trunk/src/vector_clip/Makefile
+
+Added #include <io.h> to the MINGW part of os.h so the chdir() macro
+is applied after the system definition. This avoids errors if we
+include os.h before io.h and then get an illegal system head file.
+
+Unfortunately adding this breaks Gap4's IO.h (and .c) as on windows
+IO.h and io.h are the same file. So renamed these to IO1.c and IO1.h,
+given we have IO2.c and IO3.c already, updated the myriad of places
+they were included from and reran make depend too.
+
+------------------------------------------------------------------------
+r3517 | daviesrob | 2013-11-20 15:19:00 +0000 (Wed, 20 Nov 2013) | 6 lines
+Changed paths:
+   M /staden/trunk/src/gap5/export_contigs.c
+
+Stopped parse_acd_tag from returning pointers beyond the end of the string.
+
+If parse_acd_tag tag was handed a string that did not end in \n, it would
+return a pointer to 1 past the NUL byte on the end.  This would cause it
+to attempt to read uninitialized memory when called next time.
+
+------------------------------------------------------------------------
+r3516 | jkbonfield | 2013-11-20 15:15:10 +0000 (Wed, 20 Nov 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/readpair.c
+
+Cosmetic code tidyup. Lines longer than 80 characters offend me!
+
+------------------------------------------------------------------------
+r3515 | jkbonfield | 2013-11-20 15:14:21 +0000 (Wed, 20 Nov 2013) | 3 lines
+Changed paths:
+   M /staden/trunk/src/ChangeLog
+   M /staden/trunk/src/configure.in
+
+Nearing the next release so updated version and changelog. More to go
+still, specifically Windows and a few bugs uncovered.
+
+------------------------------------------------------------------------
+r3514 | jkbonfield | 2013-11-20 15:13:41 +0000 (Wed, 20 Nov 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/gap5/list_contigs.tcl
+
+Minor optimisation
+
+------------------------------------------------------------------------
+r3513 | jkbonfield | 2013-11-20 15:12:00 +0000 (Wed, 20 Nov 2013) | 5 lines
+Changed paths:
+   M /staden/trunk/src/staden.profile
+
+Added $STADENROOT/lib to LD_LIBRARY_PATH too so we can add any
+third-party libraries (ie not part of the staden package) in there to
+override any system versions or to ensure libraries exist. This is
+particularly relevant to the MacOS X build.
+
+------------------------------------------------------------------------
+r3512 | jkbonfield | 2013-11-20 15:10:29 +0000 (Wed, 20 Nov 2013) | 2 lines
+Changed paths:
+   M /staden/trunk/src/Makefile.in
+
+Make distsrc now also generates a tarball
+
+------------------------------------------------------------------------
+r3511 | jkbonfield | 2013-11-20 15:10:05 +0000 (Wed, 20 Nov 2013) | 7 lines
+Changed paths:
+   M /staden/trunk/src/gap5/gap5_cmd.tcl
+
+Make FIJ and Find Read Pairs sub-commands open in read-only mode as
+they have no strong need to be read-write.
+
+However possibly we should add a -rw command line option to force
+read-write still as some actions of these tools could generate data
+which is best cached (eg consensus, read-pair locations).
+
+------------------------------------------------------------------------
+r3510 | daviesrob | 2013-11-20 09:34:09 +0000 (Wed, 20 Nov 2013) | 13 lines
+Changed paths:
+   M /staden/trunk/src/gap5/readpair.c
+
+Fix bugs in spanning_pairs when run in end_all mode.
+
+When spanning_pairs had to use sequence_get_position to look up pair positions,
+it was not filling in all the needed parts of r2, leading to the use of
+uninitialized values later on.  It now fills in everything that is needed,
+which makes the results much more deterministic.  This only affected end_all
+mode, as none of the others needed to look up pairs by this method.
+
+Using sequence_get_position could also bring back links to contigs that were
+not in the original list passed to spanning_pairs.  These are now filtered
+out.  This also fixes a failed assertion in Find Internal Joins that was
+triggered by spanning_pairs returning such unexpected links.
+
+------------------------------------------------------------------------
+r3508 | jkbonfield | 2013-11-07 16:53:38 +0000 (Thu, 07 Nov 2013) | 7 lines
+Changed paths:
+   M /staden/trunk/src/MacOSX/Gap4.app/Contents/Info.plist
+   A /staden/trunk/src/MacOSX/Gap4.app/Contents/MacOS/gap4 (from /staden/trunk/src/MacOSX/Gap4.app/Contents/MacOS/run.sh:3506)
+   D /staden/trunk/src/MacOSX/Gap4.app/Contents/MacOS/run.sh
+   M /staden/trunk/src/MacOSX/Gap5.app/Contents/Info.plist
+   A /staden/trunk/src/MacOSX/Gap5.app/Contents/MacOS/gap5 (from /staden/trunk/src/MacOSX/Gap5.app/Contents/MacOS/run.sh:3506)
+   D /staden/trunk/src/MacOSX/Gap5.app/Contents/MacOS/run.sh
+   M /staden/trunk/src/MacOSX/Makefile
+   M /staden/trunk/src/MacOSX/Pregap4.app/Contents/Info.plist
+   A /staden/trunk/src/MacOSX/Pregap4.app/Contents/MacOS/pregap4 (from /staden/trunk/src/MacOSX/Pregap4.app/Contents/MacOS/run.sh:3506)
+   D /staden/trunk/src/MacOSX/Pregap4.app/Contents/MacOS/run.sh
+   M /staden/trunk/src/MacOSX/Spin.app/Contents/Info.plist
+   D /staden/trunk/src/MacOSX/Spin.app/Contents/MacOS/run.sh
+   A /staden/trunk/src/MacOSX/Spin.app/Contents/MacOS/spin (from /staden/trunk/src/MacOSX/Spin.app/Contents/MacOS/run.sh:3506)
+   M /staden/trunk/src/MacOSX/Trev.app/Contents/Info.plist
+   D /staden/trunk/src/MacOSX/Trev.app/Contents/MacOS/run.sh
+   A /staden/trunk/src/MacOSX/Trev.app/Contents/MacOS/trev (from /staden/trunk/src/MacOSX/Trev.app/Contents/MacOS/run.sh:3506)
+   M /staden/trunk/src/MacOSX/wrapper.c
+
+Replaced the wrapper script with a shell script now I figured out what
+was causing the failures in the past (Launch Service changes
+Contents/MacOS/gap5 to Contents/MacOS/Gap5 and then caused the sed
+part to fail).
+
+This avoids the whole 32-bit vs 64-bit Carbon woes.
+
+------------------------------------------------------------------------
+r3507 | jkbonfield | 2013-11-06 17:38:19 +0000 (Wed, 06 Nov 2013) | 4 lines
+Changed paths:
+   M /staden/trunk/src/gap5/tg_index_common.c
+
+Fixed the merge sorting of the sequence name index when only one file
+is needed. In this case it was closing the file descriptor early and
+then attempting to read it.
+
+------------------------------------------------------------------------
+r3506 | jkbonfield | 2013-11-06 17:03:39 +0000 (Wed, 06 Nov 2013) | 2 lines
+Changed paths:
+   A /staden/trunk/src/MacOSX/Gap4.app/Contents/MacOS/run.sh
+   A /staden/trunk/src/MacOSX/Gap5.app/Contents/MacOS/run.sh
+   A /staden/trunk/src/MacOSX/Makefile
+   A /staden/trunk/src/MacOSX/Pregap4.app/Contents/MacOS/run.sh
+   A /staden/trunk/src/MacOSX/Spin.app/Contents/MacOS/run.sh
+   A /staden/trunk/src/MacOSX/Trev.app/Contents/MacOS/run.sh
+   M /staden/trunk/src/MacOSX/wrapper.c
+
+Added code to help build and update the application bundles.
+
 ------------------------------------------------------------------------
 r3505 | jkbonfield | 2013-11-06 09:19:24 +0000 (Wed, 06 Nov 2013) | 2 lines
 Changed paths:
@@ -4977,7 +7539,7 @@ Changed paths:
 Improvements to use of svnversion: quoting the result and also a check
 for it looking legitimate (starting with a numeric value).
 
-------------------------------------------------------------------------
+========================================================================
 RELEASED 2.0.0b9	
 
 r2852 | jkbonfield | 2011-12-05 12:26:04 +0000 (Mon, 05 Dec 2011) | 4 lines
diff --git a/Makefile.in b/Makefile.in
index ef9f5f1..9cf3c2a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -209,7 +209,7 @@ convert: gap4
 copy_reads: gap4
 haplo: gap4
 prefinish: gap4
-gap5: primer3/src
+gap5: seq_utils primer3/src
 
 FORCE:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/Misc/Makefile b/Misc/Makefile
index cdf7a9b..c300266 100644
--- a/Misc/Makefile
+++ b/Misc/Makefile
@@ -73,20 +73,86 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 FtoC.o: $(PWD)/staden_config.h
+FtoC.o: $(SRCROOT)/Misc/os.h
+array.o: $(SRCROOT)/Misc/array.h
+array.o: $(SRCROOT)/Misc/xalloc.h
+array.o: $(SRCROOT)/Misc/xerror.h
 array_arith.o: $(PWD)/staden_config.h
+array_arith.o: $(SRCROOT)/Misc/misc.h
+array_arith.o: $(SRCROOT)/Misc/os.h
+array_arith.o: $(SRCROOT)/Misc/xalloc.h
 bitmap.o: $(PWD)/staden_config.h
+bitmap.o: $(SRCROOT)/Misc/bitmap.h
+bitmap.o: $(SRCROOT)/Misc/os.h
+bitmap.o: $(SRCROOT)/Misc/xalloc.h
+bitmap.o: $(SRCROOT)/Misc/xerror.h
 crash.o: $(PWD)/staden_config.h
+crash.o: $(SRCROOT)/Misc/misc.h
+crash.o: $(SRCROOT)/Misc/os.h
+crash.o: $(SRCROOT)/Misc/xalloc.h
 date.o: $(PWD)/staden_config.h
+date.o: $(SRCROOT)/Misc/misc.h
+date.o: $(SRCROOT)/Misc/os.h
+date.o: $(SRCROOT)/Misc/xalloc.h
 dstring.o: $(PWD)/staden_config.h
+dstring.o: $(SRCROOT)/Misc/dstring.h
+dstring.o: $(SRCROOT)/Misc/misc.h
+dstring.o: $(SRCROOT)/Misc/os.h
+dstring.o: $(SRCROOT)/Misc/vlen.h
+dstring.o: $(SRCROOT)/Misc/xalloc.h
 error.o: $(PWD)/staden_config.h
+error.o: $(SRCROOT)/Misc/error.h
+error.o: $(SRCROOT)/Misc/misc.h
+error.o: $(SRCROOT)/Misc/os.h
+error.o: $(SRCROOT)/Misc/xalloc.h
 filenames.o: $(PWD)/staden_config.h
+filenames.o: $(SRCROOT)/Misc/misc.h
+filenames.o: $(SRCROOT)/Misc/os.h
+filenames.o: $(SRCROOT)/Misc/xalloc.h
 files.o: $(PWD)/staden_config.h
+files.o: $(SRCROOT)/Misc/misc.h
+files.o: $(SRCROOT)/Misc/os.h
+files.o: $(SRCROOT)/Misc/xalloc.h
 find.o: $(PWD)/staden_config.h
+find.o: $(SRCROOT)/Misc/misc.h
+find.o: $(SRCROOT)/Misc/os.h
+find.o: $(SRCROOT)/Misc/xalloc.h
 getfile.o: $(PWD)/staden_config.h
+getfile.o: $(SRCROOT)/Misc/getfile.h
+getfile.o: $(SRCROOT)/Misc/misc.h
+getfile.o: $(SRCROOT)/Misc/os.h
+getfile.o: $(SRCROOT)/Misc/xalloc.h
+locks.o: $(SRCROOT)/Misc/locks.h
 parse_db.o: $(PWD)/staden_config.h
+parse_db.o: $(SRCROOT)/Misc/misc.h
+parse_db.o: $(SRCROOT)/Misc/os.h
+parse_db.o: $(SRCROOT)/Misc/parse_db.h
+parse_db.o: $(SRCROOT)/Misc/xalloc.h
 shell.o: $(PWD)/staden_config.h
+shell.o: $(SRCROOT)/Misc/misc.h
+shell.o: $(SRCROOT)/Misc/os.h
+shell.o: $(SRCROOT)/Misc/xalloc.h
+string_alloc.o: $(SRCROOT)/Misc/string_alloc.h
 strings.o: $(PWD)/staden_config.h
+strings.o: $(SRCROOT)/Misc/misc.h
+strings.o: $(SRCROOT)/Misc/os.h
+strings.o: $(SRCROOT)/Misc/xalloc.h
 strtol64.o: $(PWD)/staden_config.h
+strtol64.o: $(SRCROOT)/Misc/misc.h
+strtol64.o: $(SRCROOT)/Misc/os.h
+strtol64.o: $(SRCROOT)/Misc/xalloc.h
 vlen.o: $(PWD)/staden_config.h
+vlen.o: $(SRCROOT)/Misc/misc.h
+vlen.o: $(SRCROOT)/Misc/os.h
+vlen.o: $(SRCROOT)/Misc/vlen.h
+vlen.o: $(SRCROOT)/Misc/xalloc.h
 xalloc.o: $(PWD)/staden_config.h
+xalloc.o: $(SRCROOT)/Misc/error.h
+xalloc.o: $(SRCROOT)/Misc/misc.h
+xalloc.o: $(SRCROOT)/Misc/os.h
+xalloc.o: $(SRCROOT)/Misc/xalloc.h
 xerror.o: $(PWD)/staden_config.h
+xerror.o: $(SRCROOT)/Misc/misc.h
+xerror.o: $(SRCROOT)/Misc/os.h
+xerror.o: $(SRCROOT)/Misc/xalloc.h
+xerror.o: $(SRCROOT)/Misc/xerror.h
diff --git a/Misc/array.c b/Misc/array.c
index 572b02e..14d03c9 100644
--- a/Misc/array.c
+++ b/Misc/array.c
@@ -30,6 +30,7 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <sys/types.h>
 
 #include "array.h"
@@ -148,3 +149,27 @@ int ArrayDestroy(Array a)
 }
 
 
+/*
+ * Concatenates Array b onto the end of Array a.
+ * Array b is left unmodified.
+ *
+ * Returns 0 on success;
+ *        -1 on failure.
+ */
+int ArrayConcat(Array a, Array b) {
+    if (a->size != b->size) {
+	fprintf(stderr, "Attempt made to concatenate incompatible arrays\n");
+	return -1;
+    }
+
+    if (ArrayExtend(a, a->max + b->max))
+	return -1;
+
+    memcpy((char *)a->base + a->max*a->size,
+	   (char *)b->base,
+	   b->size * b->max);
+    a->max += b->max;
+
+    return 0;
+}
+
diff --git a/Misc/array.h b/Misc/array.h
index d50d895..af5e31c 100644
--- a/Misc/array.h
+++ b/Misc/array.h
@@ -61,6 +61,8 @@ extern void *ArrayRef(Array a, size_t i);
 
 extern int ArrayDestroy(Array a);
 
+extern int ArrayConcat(Array a, Array b);
+
 #define ArrayMax(a) ( (a)->max )
 
 #define ArrayBase(t,a) ( (t *)((a)->base) )
@@ -89,5 +91,7 @@ extern int ArrayDestroy(Array a);
 
 extern char *ArrayErrorString(int error);
 
+// Use as ArrayPush(Foo, int, 10);
+#define ArrayPush(a,t,v) (*((t*)ArrayRef((a),ArrayMax((a))))=(v))
 
 #endif /*_ARRAY_H_*/
diff --git a/NEWS b/NEWS
index 99d32d9..7ad607f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,186 @@
-August 2013 - 2.0.0b10
-===========
+April 2016 - 2.0.0b11
+==========
+
+Gap5 Updates
+------------
+
+* Find Haplotypes function for use within the contig editor.  This
+  replaces the old Sort By Sequence mode as well as generating lists
+  of read IDs per haplotype.  It also creates a master "haplotypes"
+  list of lists.
+
+* Disassemble Readings now handles list of lists (in addition to 
+  normal lists of readings), for use with the haplotype output.
+
+* Improvements to Shuffle Pads.  It can now use cutoff/soft-clip
+  data to detect concordant soft-clips (regions where all the
+  soft-clip data agrees with one another).  It auto-detects likely
+  adapter sequences to avoid extending these.
+
+  It also now detects short tandem repeats and handles these more
+  carefully.  An STR overlapping a heterozygous indel can be clipped
+  back if the read doesn't span the entire STR, in order to not cause
+  bias in the copy numbers.
+
+* The Realign Selection option now brings up a user interface if invoked
+  from the main menu, but not when right clicked via the popup menu
+  (unless Control key is held down while right-clicking).
+
+* Export Contigs has an additional depadded option to use original
+  reference sequence coordinates.  Note this isn't 100% robust as it
+  depends on which edits have happened, in particular joining and
+  breaking contigs.
+
+* Export SAM, BAM and CRAM should now be much faster in excessively
+  deep regions with soft-clips.
+
+* The quality values can now be overriden when importing FASTQ or the
+  default quality changed when importing FASTA.
+
+* Gap5_cmd has gained Contig Extend and Contig Trim commands.
+
+* Gap5_cmd auto_join now honours the -min_overlap and -max_overlap
+  parameters.
+
+* Improved the consensus discrepancy score by taking into account a
+  per-base difference rather than joining all together.
+
+* Check Assembly text results are now more verbose, for easier
+  comparison between databases.
+
+* The current selected reading list in the Contig Editor now shows the
+  number of items in that list.
+
+* Highlight Disagreements for cutoff data now defaults to displaying
+  foreground coloured differences.
+
+* The consensus algorithm has been tweaked to cope with different
+  overcall and undercall likelihoods.  This is tied to sequencing
+  technology, for which the default can be adjusted in the Options
+  menu.  This uses the @RG "PL"atform heading in BAM files.  The List
+  Libraries window permits editing of this field after import.
+
+* Small tweaks to Find Internal Joins block alignments.
+
+* Save Consensus can now optionally emit ambiguity codes for
+  heterozygous positions.
+
+* Added back Mask/Mark consensus filtering modes to Find Internal
+  Joins.
+
+* Read name indexing should uses less temporary disk space in
+  tg_index.
+
+* The multi-column reading list viewer now has Template Status and
+  Library Name columns for display/sorting.
+
+* The Template Display now has hot-keys for configurations.  Use
+  Shift-Function-Key to remember the current settings and Function-Key
+  to switch to that setting.  The File -> Save Settings option will
+  write these to your ~/.gap5rc.
+
+
+Gap5 Fixes
+----------
+
+* Fixed a bug where using the contig selector / contig list to fill
+  out a dialogue box without then doing anything else at all could
+  cause the name to be considered invalid.
+
+* Removed used of some unintialised data in Shuffle Pads.
+  - Validate_clip_regions could process annotation record numbers that
+    have been removed already.
+  - Functions setting sequence clip points could potentially set clips
+    beyond the sequence ends.
+
+* Fixed a bin corruption caused by updates to read pairs spanning two
+  contigs, eg with one editor open on each end. (See r3996 for the
+  long description.)
+
+* Auto-scrolling int he template display now takes into account the
+  contig start location.
+
+* Many bug fixes to Shuffle Pads, but there is also a lot of new code
+  in there too (hopefully without new bugs!).
+
+* Tg_index -g mode was erroneously adding columns of pads in some
+  cases.  Also fixed an issue with tg_index -a -g not working in some
+  situations.
+
+* Fixed rounding issues when zooming the template display quality
+  plot.
+
+* Some more (rather obscure) gap5 database corruptions have been
+  fixed.
+
+* Improved robustness in the presence of database corruptions.  While
+  not foolproof, the program shouldn't crash as often.
+
+* Import Reads no longer clears the "readings" list.
+
+* Corrected the (reversed) insertion / deletion percentages in List
+  Base Confidence.
+
+* Quality value "*" in BAM is no longer treated as quality -1.
+
+* Fixed a potential buffer overrun in querying individual items in the
+  contig selector.
+
+* Overhauled the base insertion and deletion code in the Contig
+  Editor, fixing several problems (in particular with Undo).
+
+* Various fixes to keep the contig start / end coordinates correct,
+  removing bin errors.
+
+* Fixed issues with annotation positions after using the editor
+  commands to move sequences.  Similarly consensus tags at the ends of
+  contigs should be more robust when inserting and removing consensus
+  columns.
+
+* SAM/BAM export should now correct the mate-pair flags and positions.
+
+* Fixed exporting CRAM in padded mode. It was outputting a depadded
+  consensus, causing CRAM to work excessively hard in encoding reference
+  differences.
+
+* Added back fsync to main .g5d file.  This should resolve some
+  database corruptions caused by running gap5 on a cluster, saving the
+  gap5 database (but not closing gap5) and then manually copying the
+  database from a different cluster node.
+
+Gap4
+----
+
+* The contig editor should now work better with newer X11 window managers.
+
+* Fixed a bug in showing the reading frame translations.  It
+  overflowed the buffer by 1 byte (a ~2002 bug).
+
+Misc
+----
+
+* Applied patches from Debian
+  https://anonscm.debian.org/viewvc/debian-med/trunk/packages/staden/trunk/debian/patches/spelling.patch?revision=21433&view=markup
+  https://anonscm.debian.org/viewvc/debian-med/trunk/packages/staden/trunk/debian/patches/hardening.patch?revision=16751&view=markup
+  https://anonscm.debian.org/viewvc/debian-med/trunk/packages/staden/trunk/debian/patches/hardening_format-security.patch?revision=15859&view=markup
+
+* The usual round of compiler warning fixes; mostly missing
+  prototypes, casts and unused variables.
+
+  This also includes two bug fixes:
+  - join_move_bins() now returns non-zero on error.
+  - sam_export_seq() could calculate the wrong index bin number when
+    exporting bam if the contig started at position <= 0 dut to the
+    offset being added to the sequence end position twice.
+
+* Added a debugging tool to replay events listed in gap5 log files
+  (staden/trunk/src/gap5/replay_log.tcl). 
+
+
+
+
+December 2013 - 2.0.0b10
+=============
 
 
 Gap5 Updates
@@ -96,6 +277,11 @@ to read databases created by the latest Gap5 and/or Tg_index.
 
 * Template Display
 
+  - We can now selectively filter by library.
+
+  - The average template insert size is now drawn superimposed on top
+    of the main display.
+
   - Tags/annotations can now be displayed as their own track (they are
     also visible in the Contig Selector).
 
@@ -116,6 +302,11 @@ to read databases created by the latest Gap5 and/or Tg_index.
     variable while it's recomputing this cached information.)
 
   - Zooming via the mouse wheel is now centred on the mouse cursor.
+    Mouse wheel is now also support on Windows (also in the Contig
+    Editor).
+
+  - The default mapping quality colouration is now minimum instead of
+    average.
 
 
 * Contig Selector / Lists Contigs
@@ -190,6 +381,10 @@ to read databases created by the latest Gap5 and/or Tg_index.
     programs. If this happens the programs should abort before
     corrupting the database.
 
+  - Tg_index should be more efficient when indexing the reading names.
+
+  - Gap5_cmd now opens the database in read-only mode when appropriate.
+
 
 * Other new functions / commands
 
@@ -210,6 +405,11 @@ to read databases created by the latest Gap5 and/or Tg_index.
   
   - New function "Delete Tags" option to remove all tags of a specific type.
 
+  - New "Contig Trim" function to clip back straggly low-depth contig
+    ends.
+
+  - Gap5_cmd auto_break: automatically break misassembled contigs based
+    on a whole slew of alignment / read-pair metrics.
 
 * Miscellaneous
 
@@ -219,6 +419,10 @@ to read databases created by the latest Gap5 and/or Tg_index.
   - Various speed increases to Delete Contig, Disassemble Readings, Find
     Read Pairs and the Contig Selector.
 
+  - Gap5_cmd now opens the database in read-only mode when appropriate.
+
+  - Tg_index should be more efficient when indexing the reading names.
+
 
 Gap5 bug fixes
 --------------
@@ -362,6 +566,27 @@ from this list as they have no single apparent end-user affect.
 
 * The code should now compile with zlib-1.2.6 and newer.
 
+* Fixed a bizarre Template Display red/blue colour swap on Windows.
+
+* More hardening against corrupted databases leading to crashes.
+
+* Bug fixes to Find Internal Joins in end-all mode and checking for
+  spanning read pairs.
+
+* Fixed various corner cases in using Undo after base deletion in the
+  contig editor (eg when entirely removing a read).
+
+* Fixed bug in Contig Extend where zero base extension matches could
+  lead to sequence trimming.
+
+* Export Contigs to SAM works better with read-names containing
+  slashes.
+
+* Delete Contigs now flushes per contig, reducing memory usage.
+
+* Break Contig now duplicates consensus tags when they overlap both
+  left and right contig; this is how Gap4 worked too.
+
 
 Io_lib Updates
 --------------
@@ -370,6 +595,25 @@ Io_lib Updates
   including SAM, BAM and CRAM.
 
 
+Misc
+----
+
+* Pregap4: Fixed vector_clip crash on exit caused by tk_utils vs
+  text_utils in linking.
+  
+* Pregap4: Interactive Clipping now copes with spaces in filenames.
+
+* We now support cross-compiling of windows binaries from linux.
+
+* Tcl/Tk 8.6 is now used.
+
+* Better support for Windows MinGW.
+
+* Improved application launcher on MacOS X.
+
+* Removed deprecated tg_view application.
+
+
 -----------------------------------------------------------------------------
 
 5th Dec 2011 - 2.0.0b9
diff --git a/README.build b/README.build
index 97a2104..a8730f9 100644
--- a/README.build
+++ b/README.build
@@ -17,7 +17,7 @@ downloaded and installed before hand.
 Packages required (newer versions should work; older versions may work
 but are untested - please tell me if they work too).
 
-* staden-io_lib	>=1.12.2
+* staden-io_lib	>=1.13.8
 * tcl		>=8.4
 * tk		>=8.4
 * zlib		>=1.2.x
@@ -384,7 +384,7 @@ Documentation / Course notes
 ============================
 
 These have now been moved to their own package named
-"staden_doc-2.0.0b8-src.tar.gz".
+"staden_doc-2.0.0b8-src.tar.gz" (and subsequent releases).
 
 Please download this from sourceforge and read the building and
 install documentation within there.
diff --git a/abi/Makefile b/abi/Makefile
index 15a57ad..ab5996f 100644
--- a/abi/Makefile
+++ b/abi/Makefile
@@ -42,7 +42,17 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 abiIO.o: $(PWD)/staden_config.h
+abiIO.o: $(SRCROOT)/Misc/os.h
+abiIO.o: $(SRCROOT)/abi/abiIO.h
 getABISampleName.o: $(PWD)/staden_config.h
+getABISampleName.o: $(SRCROOT)/Misc/os.h
+getABISampleName.o: $(SRCROOT)/abi/abiIO.h
 getABIcomment.o: $(PWD)/staden_config.h
+getABIcomment.o: $(SRCROOT)/Misc/os.h
+getABIcomment.o: $(SRCROOT)/abi/abiIO.h
 getABIdate.o: $(PWD)/staden_config.h
+getABIdate.o: $(SRCROOT)/Misc/os.h
+getABIdate.o: $(SRCROOT)/abi/abiIO.h
 getABIfield.o: $(PWD)/staden_config.h
+getABIfield.o: $(SRCROOT)/Misc/os.h
+getABIfield.o: $(SRCROOT)/abi/abiIO.h
diff --git a/alf/Makefile b/alf/Makefile
index 6a43d9e..70721d2 100644
--- a/alf/Makefile
+++ b/alf/Makefile
@@ -34,3 +34,4 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 alfsplit.o: $(PWD)/staden_config.h
+alfsplit.o: $(SRCROOT)/Misc/os.h
diff --git a/configure b/configure
index 286392b..11bdbf1 100755
--- a/configure
+++ b/configure
@@ -1,11 +1,9 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for staden 2.0.0b10.
+# Generated by GNU Autoconf 2.69 for staden 2.0.0b11-2016.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -134,6 +132,31 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -212,21 +236,25 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -328,6 +356,14 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -449,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -483,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -504,28 +544,8 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -557,8 +577,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='staden'
 PACKAGE_TARNAME='staden'
-PACKAGE_VERSION='2.0.0b10'
-PACKAGE_STRING='staden 2.0.0b10'
+PACKAGE_VERSION='2.0.0b11-2016'
+PACKAGE_STRING='staden 2.0.0b11-2016'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1249,8 +1269,6 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1336,7 +1354,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures staden 2.0.0b10 to adapt to many kinds of systems.
+\`configure' configures staden 2.0.0b11-2016 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1401,7 +1419,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of staden 2.0.0b10:";;
+     short | recursive ) echo "Configuration of staden 2.0.0b11-2016:";;
    esac
   cat <<\_ACEOF
 
@@ -1515,10 +1533,10 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-staden configure 2.0.0b10
-generated by GNU Autoconf 2.68
+staden configure 2.0.0b11-2016
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1632,7 +1650,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1918,8 +1936,8 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by staden $as_me 2.0.0b10, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by staden $as_me 2.0.0b11-2016, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2300,7 +2318,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2340,7 +2358,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2393,7 +2411,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2434,7 +2452,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -2492,7 +2510,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2536,7 +2554,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2982,8 +3000,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -3096,7 +3113,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3140,7 +3157,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3390,7 +3407,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AWK="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3440,7 +3457,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3481,7 +3498,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3926,7 +3943,7 @@ do
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -3992,7 +4009,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -4890,7 +4907,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path__io_lib_config="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4932,7 +4949,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path__io_lib_config="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5630,7 +5647,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5676,7 +5693,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5700,7 +5717,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5745,7 +5762,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5769,7 +5786,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5801,6 +5818,8 @@ _ACEOF
 esac
 rm -rf conftest*
   fi
+
+
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
@@ -6990,7 +7009,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CYGPATH="cygpath -w"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7591,7 +7610,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7631,7 +7650,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7856,7 +7875,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="${ac_tool_prefix}ar"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7896,7 +7915,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="ar"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -8187,7 +8206,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_RC="${ac_tool_prefix}windres"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -8227,7 +8246,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RC="windres"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -11088,16 +11107,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -11157,28 +11176,16 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -11199,8 +11206,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by staden $as_me 2.0.0b10, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by staden $as_me 2.0.0b11-2016, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -11261,11 +11268,11 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-staden config.status 2.0.0b10
-configured by $0, generated by GNU Autoconf 2.68,
+staden config.status 2.0.0b11-2016
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -11354,7 +11361,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
diff --git a/configure.in b/configure.in
index bab8d01..a3ee01b 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with aclocal and autoconf to produce a configure script.
-AC_INIT([staden],[2.0.0b10])
+AC_INIT([staden],[2.0.0b11-2016])
 
 # Check that we're running in a subdirectory. If not create one and rerun.
 # This ensures that the root directory does not get polluted with the
diff --git a/convert/Makefile b/convert/Makefile
index d4e506c..5f7d482 100644
--- a/convert/Makefile
+++ b/convert/Makefile
@@ -44,10 +44,83 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 bapDB.o: $(PWD)/staden_config.h
+bapDB.o: $(SRCROOT)/Misc/misc.h
+bapDB.o: $(SRCROOT)/Misc/os.h
+bapDB.o: $(SRCROOT)/Misc/xalloc.h
+bapDB.o: $(SRCROOT)/convert/bapIO.h
+bapDB.o: $(SRCROOT)/convert/list.h
+bapDB.o: $(SRCROOT)/convert/newtypes.h
+bapDB.o: $(SRCROOT)/convert/process.h
 bapIO.o: $(PWD)/staden_config.h
+bapIO.o: $(SRCROOT)/Misc/misc.h
+bapIO.o: $(SRCROOT)/Misc/os.h
+bapIO.o: $(SRCROOT)/Misc/xalloc.h
+bapIO.o: $(SRCROOT)/convert/bapIO.h
+bapIO.o: $(SRCROOT)/convert/newtypes.h
 dapDB.o: $(PWD)/staden_config.h
+dapDB.o: $(SRCROOT)/Misc/misc.h
+dapDB.o: $(SRCROOT)/Misc/os.h
+dapDB.o: $(SRCROOT)/Misc/xalloc.h
+dapDB.o: $(SRCROOT)/convert/dapDB.h
+dapDB.o: $(SRCROOT)/convert/dapIO.h
+dapDB.o: $(SRCROOT)/convert/list.h
+dapDB.o: $(SRCROOT)/convert/newtypes.h
+dapDB.o: $(SRCROOT)/convert/process.h
 dapIO.o: $(PWD)/staden_config.h
+dapIO.o: $(SRCROOT)/Misc/misc.h
+dapIO.o: $(SRCROOT)/Misc/os.h
+dapIO.o: $(SRCROOT)/Misc/xalloc.h
+dapIO.o: $(SRCROOT)/convert/dapIO.h
+dapIO.o: $(SRCROOT)/convert/newtypes.h
 flat_sd.o: $(PWD)/staden_config.h
+flat_sd.o: $(SRCROOT)/Misc/misc.h
+flat_sd.o: $(SRCROOT)/Misc/os.h
+flat_sd.o: $(SRCROOT)/Misc/xalloc.h
+flat_sd.o: $(SRCROOT)/convert/list.h
+flat_sd.o: $(SRCROOT)/convert/process.h
 gapDB.o: $(PWD)/staden_config.h
+gapDB.o: $(SRCROOT)/Misc/array.h
+gapDB.o: $(SRCROOT)/Misc/bitmap.h
+gapDB.o: $(SRCROOT)/Misc/misc.h
+gapDB.o: $(SRCROOT)/Misc/os.h
+gapDB.o: $(SRCROOT)/Misc/xalloc.h
+gapDB.o: $(SRCROOT)/Misc/xerror.h
+gapDB.o: $(SRCROOT)/convert/gapDB.h
+gapDB.o: $(SRCROOT)/convert/list.h
+gapDB.o: $(SRCROOT)/convert/process.h
+gapDB.o: $(SRCROOT)/g/freetree.h
+gapDB.o: $(SRCROOT)/g/g-defs.h
+gapDB.o: $(SRCROOT)/g/g-error.h
+gapDB.o: $(SRCROOT)/g/g-filedefs.h
+gapDB.o: $(SRCROOT)/g/g-os.h
+gapDB.o: $(SRCROOT)/g/g-struct.h
+gapDB.o: $(SRCROOT)/gap4/IO1.h
+gapDB.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gapDB.o: $(SRCROOT)/gap4/gap-if.h
+gapDB.o: $(SRCROOT)/gap4/io_handle.h
+gapDB.o: $(SRCROOT)/gap4/io_utils.h
+list.o: $(SRCROOT)/convert/list.h
 main.o: $(PWD)/staden_config.h
+main.o: $(SRCROOT)/Misc/array.h
+main.o: $(SRCROOT)/Misc/misc.h
+main.o: $(SRCROOT)/Misc/os.h
+main.o: $(SRCROOT)/Misc/xalloc.h
+main.o: $(SRCROOT)/Misc/xerror.h
+main.o: $(SRCROOT)/convert/list.h
+main.o: $(SRCROOT)/convert/process.h
+main.o: $(SRCROOT)/g/freetree.h
+main.o: $(SRCROOT)/g/g-error.h
+main.o: $(SRCROOT)/g/g-filedefs.h
+main.o: $(SRCROOT)/g/g-os.h
+main.o: $(SRCROOT)/g/g-struct.h
+main.o: $(SRCROOT)/gap4/gap-if.h
 process.o: $(PWD)/staden_config.h
+process.o: $(SRCROOT)/Misc/misc.h
+process.o: $(SRCROOT)/Misc/os.h
+process.o: $(SRCROOT)/Misc/xalloc.h
+process.o: $(SRCROOT)/convert/bapDB.h
+process.o: $(SRCROOT)/convert/dapDB.h
+process.o: $(SRCROOT)/convert/flat_sd.h
+process.o: $(SRCROOT)/convert/gapDB.h
+process.o: $(SRCROOT)/convert/list.h
+process.o: $(SRCROOT)/convert/process.h
diff --git a/copy_reads/Makefile b/copy_reads/Makefile
index 97b15e8..cf03628 100644
--- a/copy_reads/Makefile
+++ b/copy_reads/Makefile
@@ -51,3 +51,64 @@ DEPEND_OBJ = $(OBJS)
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 copy_reads.o: $(PWD)/staden_config.h
+copy_reads.o: $(SRCROOT)/Misc/array.h
+copy_reads.o: $(SRCROOT)/Misc/bitmap.h
+copy_reads.o: $(SRCROOT)/Misc/dstring.h
+copy_reads.o: $(SRCROOT)/Misc/misc.h
+copy_reads.o: $(SRCROOT)/Misc/os.h
+copy_reads.o: $(SRCROOT)/Misc/xalloc.h
+copy_reads.o: $(SRCROOT)/Misc/xerror.h
+copy_reads.o: $(SRCROOT)/copy_reads/copy_reads.h
+copy_reads.o: $(SRCROOT)/copy_reads/copy_reads_globals.h
+copy_reads.o: $(SRCROOT)/g/freetree.h
+copy_reads.o: $(SRCROOT)/g/g-defs.h
+copy_reads.o: $(SRCROOT)/g/g-error.h
+copy_reads.o: $(SRCROOT)/g/g-filedefs.h
+copy_reads.o: $(SRCROOT)/g/g-os.h
+copy_reads.o: $(SRCROOT)/g/g-struct.h
+copy_reads.o: $(SRCROOT)/gap4/IO1.h
+copy_reads.o: $(SRCROOT)/gap4/active_tags.h
+copy_reads.o: $(SRCROOT)/gap4/assemble_direct.h
+copy_reads.o: $(SRCROOT)/gap4/complement.h
+copy_reads.o: $(SRCROOT)/gap4/consen.h
+copy_reads.o: $(SRCROOT)/gap4/edStructs.h
+copy_reads.o: $(SRCROOT)/gap4/edUtils.h
+copy_reads.o: $(SRCROOT)/gap4/fij.h
+copy_reads.o: $(SRCROOT)/gap4/fort.h
+copy_reads.o: $(SRCROOT)/gap4/fortran.h
+copy_reads.o: $(SRCROOT)/gap4/gap-dbstruct.h
+copy_reads.o: $(SRCROOT)/gap4/gap-if.h
+copy_reads.o: $(SRCROOT)/gap4/gap_cli_arg.h
+copy_reads.o: $(SRCROOT)/gap4/gap_globals.h
+copy_reads.o: $(SRCROOT)/gap4/hash_lib.h
+copy_reads.o: $(SRCROOT)/gap4/io-reg.h
+copy_reads.o: $(SRCROOT)/gap4/io_handle.h
+copy_reads.o: $(SRCROOT)/gap4/io_utils.h
+copy_reads.o: $(SRCROOT)/gap4/list.h
+copy_reads.o: $(SRCROOT)/gap4/list_proc.h
+copy_reads.o: $(SRCROOT)/gap4/primlib.h
+copy_reads.o: $(SRCROOT)/gap4/qual.h
+copy_reads.o: $(SRCROOT)/gap4/seqInfo.h
+copy_reads.o: $(SRCROOT)/gap4/tagDefs.h
+copy_reads.o: $(SRCROOT)/gap4/tagUtils.h
+copy_reads.o: $(SRCROOT)/gap4/tagdb.h
+copy_reads.o: $(SRCROOT)/gap4/template.h
+copy_reads.o: $(SRCROOT)/gap4/tkEdNames.h
+copy_reads.o: $(SRCROOT)/gap4/tkEditor.h
+copy_reads.o: $(SRCROOT)/gap4/tman_display.h
+copy_reads.o: $(SRCROOT)/gap4/undo.h
+copy_reads.o: $(SRCROOT)/primer3/src/dpal.h
+copy_reads.o: $(SRCROOT)/primer3/src/primer3.h
+copy_reads.o: $(SRCROOT)/seq_utils/align.h
+copy_reads.o: $(SRCROOT)/seq_utils/align_lib.h
+copy_reads.o: $(SRCROOT)/seq_utils/align_lib_old.h
+copy_reads.o: $(SRCROOT)/seq_utils/dna_utils.h
+copy_reads.o: $(SRCROOT)/tk_utils/cli_arg.h
+copy_reads.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+copy_reads.o: $(SRCROOT)/tk_utils/postscript.h
+copy_reads.o: $(SRCROOT)/tk_utils/sheet.h
+copy_reads.o: $(SRCROOT)/tk_utils/tcl_utils.h
+copy_reads.o: $(SRCROOT)/tk_utils/tkSheet.h
+copy_reads.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+copy_reads.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+copy_reads.o: $(SRCROOT)/tk_utils/tkTrace.h
diff --git a/copy_reads/copy_reads.c b/copy_reads/copy_reads.c
index 76e9b01..1294532 100644
--- a/copy_reads/copy_reads.c
+++ b/copy_reads/copy_reads.c
@@ -478,7 +478,7 @@ int check_cons_match(char *seq1,
 
     if (mism > max_mismatch) {
 
-	vmessage("\nLocal mismatch of %f found at postion %d over a window length of %d\n",
+	vmessage("\nLocal mismatch of %f found at position %d over a window length of %d\n",
 		 (float)mism / win_len * 100, i-win_len+1, win_len);
 	vmessage("Aborting this match\n\n");
 	return -1;
@@ -490,7 +490,7 @@ int check_cons_match(char *seq1,
 	    mism += !same_char(seq1[i], seq2[j]);
 	}
 	if (mism > max_mismatch) {
-	    vmessage("\nLocal mismatch of %f found at postion %d over a window length of %d\n",
+	    vmessage("\nLocal mismatch of %f found at position %d over a window length of %d\n",
 		     (float)mism / win_len * 100, i-win_len, win_len);
 	    vmessage("Aborting this match\n\n");
 	    return -1;
diff --git a/eba/Makefile b/eba/Makefile
index 6226d7a..a06fd85 100644
--- a/eba/Makefile
+++ b/eba/Makefile
@@ -26,4 +26,9 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 conf.o: $(PWD)/staden_config.h
+conf.o: $(SRCROOT)/Misc/os.h
+conf.o: $(SRCROOT)/Misc/xalloc.h
+conf.o: $(SRCROOT)/eba/conf.h
 qual.o: $(PWD)/staden_config.h
+qual.o: $(SRCROOT)/Misc/os.h
+qual.o: $(SRCROOT)/eba/conf.h
diff --git a/eba/conf.c b/eba/conf.c
index 27a57f3..f1d2d5a 100644
--- a/eba/conf.c
+++ b/eba/conf.c
@@ -382,7 +382,7 @@ float max_cosa(TRACE *tx, TRACE *ty, TRACE *tz, int pos, int offset)
 
 char probFromQual(float qual)
 {
-    return (char)(100.0*(1.0 - min(qual,1.0)));
+    return (char)(100.0*(1.0 - MIN(qual,1.0)));
 }
 
 
diff --git a/find_renz/Makefile b/find_renz/Makefile
index 3b88034..a6e3a12 100644
--- a/find_renz/Makefile
+++ b/find_renz/Makefile
@@ -33,3 +33,11 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 find_renz.o: $(PWD)/staden_config.h
+find_renz.o: $(SRCROOT)/Misc/getfile.h
+find_renz.o: $(SRCROOT)/Misc/misc.h
+find_renz.o: $(SRCROOT)/Misc/os.h
+find_renz.o: $(SRCROOT)/Misc/xalloc.h
+find_renz.o: $(SRCROOT)/seq_utils/dna_utils.h
+find_renz.o: $(SRCROOT)/seq_utils/genetic_code.h
+find_renz.o: $(SRCROOT)/seq_utils/renz_utils.h
+find_renz.o: $(SRCROOT)/seq_utils/sequence_formats.h
diff --git a/g/Makefile b/g/Makefile
index 7d6c828..d4c4e5e 100644
--- a/g/Makefile
+++ b/g/Makefile
@@ -82,9 +82,91 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 freetree.o: $(PWD)/staden_config.h
+freetree.o: $(SRCROOT)/Misc/misc.h
+freetree.o: $(SRCROOT)/Misc/os.h
+freetree.o: $(SRCROOT)/Misc/xalloc.h
+freetree.o: $(SRCROOT)/Misc/xerror.h
+freetree.o: $(SRCROOT)/g/freetree.h
+freetree.o: $(SRCROOT)/g/g-error.h
+freetree.o: $(SRCROOT)/g/g-os.h
 g-connect.o: $(PWD)/staden_config.h
+g-connect.o: $(SRCROOT)/Misc/array.h
+g-connect.o: $(SRCROOT)/Misc/os.h
+g-connect.o: $(SRCROOT)/Misc/xerror.h
+g-connect.o: $(SRCROOT)/g/freetree.h
+g-connect.o: $(SRCROOT)/g/g-connect.h
+g-connect.o: $(SRCROOT)/g/g-db.h
+g-connect.o: $(SRCROOT)/g/g-defs.h
+g-connect.o: $(SRCROOT)/g/g-error.h
+g-connect.o: $(SRCROOT)/g/g-filedefs.h
+g-connect.o: $(SRCROOT)/g/g-os.h
+g-connect.o: $(SRCROOT)/g/g-struct.h
 g-db.o: $(PWD)/staden_config.h
+g-db.o: $(SRCROOT)/Misc/array.h
+g-db.o: $(SRCROOT)/Misc/os.h
+g-db.o: $(SRCROOT)/Misc/xerror.h
+g-db.o: $(SRCROOT)/g/freetree.h
+g-db.o: $(SRCROOT)/g/g-db.h
+g-db.o: $(SRCROOT)/g/g-defs.h
+g-db.o: $(SRCROOT)/g/g-error.h
+g-db.o: $(SRCROOT)/g/g-filedefs.h
+g-db.o: $(SRCROOT)/g/g-files.h
+g-db.o: $(SRCROOT)/g/g-io.h
+g-db.o: $(SRCROOT)/g/g-os.h
+g-db.o: $(SRCROOT)/g/g-request.h
+g-db.o: $(SRCROOT)/g/g-struct.h
+g-error.o: $(SRCROOT)/Misc/xerror.h
+g-error.o: $(SRCROOT)/g/g-error.h
+g-error.o: $(SRCROOT)/g/g-misc.h
 g-files.o: $(PWD)/staden_config.h
+g-files.o: $(SRCROOT)/Misc/array.h
+g-files.o: $(SRCROOT)/Misc/os.h
+g-files.o: $(SRCROOT)/Misc/xalloc.h
+g-files.o: $(SRCROOT)/Misc/xerror.h
+g-files.o: $(SRCROOT)/g/freetree.h
+g-files.o: $(SRCROOT)/g/g-db.h
+g-files.o: $(SRCROOT)/g/g-defs.h
+g-files.o: $(SRCROOT)/g/g-error.h
+g-files.o: $(SRCROOT)/g/g-filedefs.h
+g-files.o: $(SRCROOT)/g/g-files.h
+g-files.o: $(SRCROOT)/g/g-io.h
+g-files.o: $(SRCROOT)/g/g-os.h
+g-files.o: $(SRCROOT)/g/g-struct.h
 g-io.o: $(PWD)/staden_config.h
+g-io.o: $(SRCROOT)/Misc/array.h
+g-io.o: $(SRCROOT)/Misc/os.h
+g-io.o: $(SRCROOT)/Misc/xerror.h
+g-io.o: $(SRCROOT)/g/freetree.h
+g-io.o: $(SRCROOT)/g/g-error.h
+g-io.o: $(SRCROOT)/g/g-filedefs.h
+g-io.o: $(SRCROOT)/g/g-files.h
+g-io.o: $(SRCROOT)/g/g-io.h
+g-io.o: $(SRCROOT)/g/g-os.h
+g-io.o: $(SRCROOT)/g/g-struct.h
 g-request.o: $(PWD)/staden_config.h
+g-request.o: $(SRCROOT)/Misc/array.h
+g-request.o: $(SRCROOT)/Misc/os.h
+g-request.o: $(SRCROOT)/Misc/xalloc.h
+g-request.o: $(SRCROOT)/Misc/xerror.h
+g-request.o: $(SRCROOT)/g/freetree.h
+g-request.o: $(SRCROOT)/g/g-db.h
+g-request.o: $(SRCROOT)/g/g-defs.h
+g-request.o: $(SRCROOT)/g/g-error.h
+g-request.o: $(SRCROOT)/g/g-filedefs.h
+g-request.o: $(SRCROOT)/g/g-files.h
+g-request.o: $(SRCROOT)/g/g-misc.h
+g-request.o: $(SRCROOT)/g/g-os.h
+g-request.o: $(SRCROOT)/g/g-request.h
+g-request.o: $(SRCROOT)/g/g-struct.h
 g-struct.o: $(PWD)/staden_config.h
+g-struct.o: $(SRCROOT)/Misc/array.h
+g-struct.o: $(SRCROOT)/Misc/os.h
+g-struct.o: $(SRCROOT)/Misc/xalloc.h
+g-struct.o: $(SRCROOT)/Misc/xerror.h
+g-struct.o: $(SRCROOT)/g/freetree.h
+g-struct.o: $(SRCROOT)/g/g-error.h
+g-struct.o: $(SRCROOT)/g/g-filedefs.h
+g-struct.o: $(SRCROOT)/g/g-files.h
+g-struct.o: $(SRCROOT)/g/g-io.h
+g-struct.o: $(SRCROOT)/g/g-os.h
+g-struct.o: $(SRCROOT)/g/g-struct.h
diff --git a/gap4/Makefile b/gap4/Makefile
index 05bdbb2..b26a17a 100644
--- a/gap4/Makefile
+++ b/gap4/Makefile
@@ -277,105 +277,3799 @@ distsrc: distsrc_dirs
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
+IO1.o: $(PWD)/staden_config.h
+IO1.o: $(SRCROOT)/Misc/FtoC.h
+IO1.o: $(SRCROOT)/Misc/array.h
+IO1.o: $(SRCROOT)/Misc/bitmap.h
+IO1.o: $(SRCROOT)/Misc/dstring.h
+IO1.o: $(SRCROOT)/Misc/misc.h
+IO1.o: $(SRCROOT)/Misc/os.h
+IO1.o: $(SRCROOT)/Misc/xalloc.h
+IO1.o: $(SRCROOT)/Misc/xerror.h
+IO1.o: $(SRCROOT)/g/freetree.h
+IO1.o: $(SRCROOT)/g/g-defs.h
+IO1.o: $(SRCROOT)/g/g-error.h
+IO1.o: $(SRCROOT)/g/g-filedefs.h
+IO1.o: $(SRCROOT)/g/g-os.h
+IO1.o: $(SRCROOT)/g/g-struct.h
+IO1.o: $(SRCROOT)/gap4/IO1.h
+IO1.o: $(SRCROOT)/gap4/actf.h
+IO1.o: $(SRCROOT)/gap4/edStructs.h
+IO1.o: $(SRCROOT)/gap4/edUtils.h
+IO1.o: $(SRCROOT)/gap4/fort.h
+IO1.o: $(SRCROOT)/gap4/fortran.h
+IO1.o: $(SRCROOT)/gap4/gap-create.h
+IO1.o: $(SRCROOT)/gap4/gap-dbstruct.h
+IO1.o: $(SRCROOT)/gap4/gap-error.h
+IO1.o: $(SRCROOT)/gap4/gap-if.h
+IO1.o: $(SRCROOT)/gap4/gap-init.h
+IO1.o: $(SRCROOT)/gap4/gap-io.h
+IO1.o: $(SRCROOT)/gap4/io-reg.h
+IO1.o: $(SRCROOT)/gap4/io_handle.h
+IO1.o: $(SRCROOT)/gap4/io_utils.h
+IO1.o: $(SRCROOT)/gap4/list.h
+IO1.o: $(SRCROOT)/gap4/notes.h
+IO1.o: $(SRCROOT)/gap4/primlib.h
+IO1.o: $(SRCROOT)/gap4/qual.h
+IO1.o: $(SRCROOT)/gap4/tagDefs.h
+IO1.o: $(SRCROOT)/gap4/tagUtils.h
+IO1.o: $(SRCROOT)/gap4/template.h
+IO1.o: $(SRCROOT)/gap4/tkEdNames.h
+IO1.o: $(SRCROOT)/gap4/tkEditor.h
+IO1.o: $(SRCROOT)/gap4/tman_display.h
+IO1.o: $(SRCROOT)/gap4/undo.h
+IO1.o: $(SRCROOT)/primer3/src/dpal.h
+IO1.o: $(SRCROOT)/primer3/src/primer3.h
+IO1.o: $(SRCROOT)/tk_utils/cli_arg.h
+IO1.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+IO1.o: $(SRCROOT)/tk_utils/postscript.h
+IO1.o: $(SRCROOT)/tk_utils/sheet.h
+IO1.o: $(SRCROOT)/tk_utils/text_output.h
+IO1.o: $(SRCROOT)/tk_utils/tkSheet.h
+IO1.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+IO1.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+IO1.o: $(SRCROOT)/tk_utils/tkTrace.h
 IO2.o: $(PWD)/staden_config.h
+IO2.o: $(SRCROOT)/Misc/FtoC.h
+IO2.o: $(SRCROOT)/Misc/array.h
+IO2.o: $(SRCROOT)/Misc/bitmap.h
+IO2.o: $(SRCROOT)/Misc/dstring.h
+IO2.o: $(SRCROOT)/Misc/misc.h
+IO2.o: $(SRCROOT)/Misc/os.h
+IO2.o: $(SRCROOT)/Misc/xalloc.h
+IO2.o: $(SRCROOT)/Misc/xerror.h
+IO2.o: $(SRCROOT)/g/freetree.h
+IO2.o: $(SRCROOT)/g/g-defs.h
+IO2.o: $(SRCROOT)/g/g-error.h
+IO2.o: $(SRCROOT)/g/g-filedefs.h
+IO2.o: $(SRCROOT)/g/g-os.h
+IO2.o: $(SRCROOT)/g/g-struct.h
+IO2.o: $(SRCROOT)/gap4/IO1.h
+IO2.o: $(SRCROOT)/gap4/IO2.h
+IO2.o: $(SRCROOT)/gap4/clones.h
+IO2.o: $(SRCROOT)/gap4/contig_selector.h
+IO2.o: $(SRCROOT)/gap4/cs-object.h
+IO2.o: $(SRCROOT)/gap4/edStructs.h
+IO2.o: $(SRCROOT)/gap4/edUtils.h
+IO2.o: $(SRCROOT)/gap4/fort.h
+IO2.o: $(SRCROOT)/gap4/fortran.h
+IO2.o: $(SRCROOT)/gap4/gap-create.h
+IO2.o: $(SRCROOT)/gap4/gap-dbstruct.h
+IO2.o: $(SRCROOT)/gap4/gap-if.h
+IO2.o: $(SRCROOT)/gap4/io-reg.h
+IO2.o: $(SRCROOT)/gap4/io_handle.h
+IO2.o: $(SRCROOT)/gap4/io_utils.h
+IO2.o: $(SRCROOT)/gap4/list.h
+IO2.o: $(SRCROOT)/gap4/notes.h
+IO2.o: $(SRCROOT)/gap4/primlib.h
+IO2.o: $(SRCROOT)/gap4/qual.h
+IO2.o: $(SRCROOT)/gap4/seqInfo.h
+IO2.o: $(SRCROOT)/gap4/tagDefs.h
+IO2.o: $(SRCROOT)/gap4/tagUtils.h
+IO2.o: $(SRCROOT)/gap4/template.h
+IO2.o: $(SRCROOT)/gap4/tkEdNames.h
+IO2.o: $(SRCROOT)/gap4/tkEditor.h
+IO2.o: $(SRCROOT)/gap4/tman_display.h
+IO2.o: $(SRCROOT)/gap4/undo.h
+IO2.o: $(SRCROOT)/primer3/src/dpal.h
+IO2.o: $(SRCROOT)/primer3/src/primer3.h
+IO2.o: $(SRCROOT)/seq_utils/dna_utils.h
+IO2.o: $(SRCROOT)/tk_utils/canvas_box.h
+IO2.o: $(SRCROOT)/tk_utils/cli_arg.h
+IO2.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+IO2.o: $(SRCROOT)/tk_utils/postscript.h
+IO2.o: $(SRCROOT)/tk_utils/sheet.h
+IO2.o: $(SRCROOT)/tk_utils/text_output.h
+IO2.o: $(SRCROOT)/tk_utils/tkSheet.h
+IO2.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+IO2.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+IO2.o: $(SRCROOT)/tk_utils/tkTrace.h
 IO3.o: $(PWD)/staden_config.h
+IO3.o: $(SRCROOT)/Misc/FtoC.h
+IO3.o: $(SRCROOT)/Misc/array.h
+IO3.o: $(SRCROOT)/Misc/bitmap.h
+IO3.o: $(SRCROOT)/Misc/dstring.h
+IO3.o: $(SRCROOT)/Misc/misc.h
+IO3.o: $(SRCROOT)/Misc/os.h
+IO3.o: $(SRCROOT)/Misc/xalloc.h
+IO3.o: $(SRCROOT)/Misc/xerror.h
+IO3.o: $(SRCROOT)/g/freetree.h
+IO3.o: $(SRCROOT)/g/g-defs.h
+IO3.o: $(SRCROOT)/g/g-error.h
+IO3.o: $(SRCROOT)/g/g-filedefs.h
+IO3.o: $(SRCROOT)/g/g-os.h
+IO3.o: $(SRCROOT)/g/g-struct.h
+IO3.o: $(SRCROOT)/gap4/IO1.h
+IO3.o: $(SRCROOT)/gap4/edStructs.h
+IO3.o: $(SRCROOT)/gap4/edUtils.h
+IO3.o: $(SRCROOT)/gap4/fort.h
+IO3.o: $(SRCROOT)/gap4/fortran.h
+IO3.o: $(SRCROOT)/gap4/gap-dbstruct.h
+IO3.o: $(SRCROOT)/gap4/gap-error.h
+IO3.o: $(SRCROOT)/gap4/gap-if.h
+IO3.o: $(SRCROOT)/gap4/io-reg.h
+IO3.o: $(SRCROOT)/gap4/io_handle.h
+IO3.o: $(SRCROOT)/gap4/io_utils.h
+IO3.o: $(SRCROOT)/gap4/list.h
+IO3.o: $(SRCROOT)/gap4/primlib.h
+IO3.o: $(SRCROOT)/gap4/qual.h
+IO3.o: $(SRCROOT)/gap4/tagDefs.h
+IO3.o: $(SRCROOT)/gap4/tagUtils.h
+IO3.o: $(SRCROOT)/gap4/template.h
+IO3.o: $(SRCROOT)/gap4/tkEdNames.h
+IO3.o: $(SRCROOT)/gap4/tkEditor.h
+IO3.o: $(SRCROOT)/gap4/tman_display.h
+IO3.o: $(SRCROOT)/gap4/undo.h
+IO3.o: $(SRCROOT)/primer3/src/dpal.h
+IO3.o: $(SRCROOT)/primer3/src/primer3.h
+IO3.o: $(SRCROOT)/tk_utils/cli_arg.h
+IO3.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+IO3.o: $(SRCROOT)/tk_utils/postscript.h
+IO3.o: $(SRCROOT)/tk_utils/sheet.h
+IO3.o: $(SRCROOT)/tk_utils/tkSheet.h
+IO3.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+IO3.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+IO3.o: $(SRCROOT)/tk_utils/tkTrace.h
 actf.o: $(PWD)/staden_config.h
+actf.o: $(SRCROOT)/Misc/array.h
+actf.o: $(SRCROOT)/Misc/bitmap.h
+actf.o: $(SRCROOT)/Misc/misc.h
+actf.o: $(SRCROOT)/Misc/os.h
+actf.o: $(SRCROOT)/Misc/xalloc.h
+actf.o: $(SRCROOT)/Misc/xerror.h
+actf.o: $(SRCROOT)/g/freetree.h
+actf.o: $(SRCROOT)/g/g-defs.h
+actf.o: $(SRCROOT)/g/g-error.h
+actf.o: $(SRCROOT)/g/g-filedefs.h
+actf.o: $(SRCROOT)/g/g-os.h
+actf.o: $(SRCROOT)/g/g-struct.h
+actf.o: $(SRCROOT)/gap4/IO1.h
+actf.o: $(SRCROOT)/gap4/actf.h
+actf.o: $(SRCROOT)/gap4/fort.h
+actf.o: $(SRCROOT)/gap4/gap-dbstruct.h
+actf.o: $(SRCROOT)/gap4/gap-if.h
+actf.o: $(SRCROOT)/gap4/io_handle.h
+actf.o: $(SRCROOT)/gap4/io_utils.h
+actf.o: $(SRCROOT)/tk_utils/text_output.h
 active_tags.o: $(PWD)/staden_config.h
+active_tags.o: $(SRCROOT)/Misc/array.h
+active_tags.o: $(SRCROOT)/Misc/bitmap.h
+active_tags.o: $(SRCROOT)/Misc/dstring.h
+active_tags.o: $(SRCROOT)/Misc/misc.h
+active_tags.o: $(SRCROOT)/Misc/os.h
+active_tags.o: $(SRCROOT)/Misc/xalloc.h
+active_tags.o: $(SRCROOT)/Misc/xerror.h
+active_tags.o: $(SRCROOT)/g/freetree.h
+active_tags.o: $(SRCROOT)/g/g-defs.h
+active_tags.o: $(SRCROOT)/g/g-error.h
+active_tags.o: $(SRCROOT)/g/g-filedefs.h
+active_tags.o: $(SRCROOT)/g/g-os.h
+active_tags.o: $(SRCROOT)/g/g-struct.h
+active_tags.o: $(SRCROOT)/gap4/IO1.h
+active_tags.o: $(SRCROOT)/gap4/contigEditor.h
+active_tags.o: $(SRCROOT)/gap4/edStructs.h
+active_tags.o: $(SRCROOT)/gap4/edUtils.h
+active_tags.o: $(SRCROOT)/gap4/fort.h
+active_tags.o: $(SRCROOT)/gap4/fortran.h
+active_tags.o: $(SRCROOT)/gap4/gap-dbstruct.h
+active_tags.o: $(SRCROOT)/gap4/gap-if.h
+active_tags.o: $(SRCROOT)/gap4/io-reg.h
+active_tags.o: $(SRCROOT)/gap4/io_handle.h
+active_tags.o: $(SRCROOT)/gap4/io_utils.h
+active_tags.o: $(SRCROOT)/gap4/list.h
+active_tags.o: $(SRCROOT)/gap4/list_proc.h
+active_tags.o: $(SRCROOT)/gap4/primlib.h
+active_tags.o: $(SRCROOT)/gap4/qual.h
+active_tags.o: $(SRCROOT)/gap4/tagDefs.h
+active_tags.o: $(SRCROOT)/gap4/tagUtils.h
+active_tags.o: $(SRCROOT)/gap4/tagdb.h
+active_tags.o: $(SRCROOT)/gap4/template.h
+active_tags.o: $(SRCROOT)/gap4/tkEdNames.h
+active_tags.o: $(SRCROOT)/gap4/tkEditor.h
+active_tags.o: $(SRCROOT)/gap4/tman_display.h
+active_tags.o: $(SRCROOT)/gap4/undo.h
+active_tags.o: $(SRCROOT)/primer3/src/dpal.h
+active_tags.o: $(SRCROOT)/primer3/src/primer3.h
+active_tags.o: $(SRCROOT)/tk_utils/cli_arg.h
+active_tags.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+active_tags.o: $(SRCROOT)/tk_utils/postscript.h
+active_tags.o: $(SRCROOT)/tk_utils/sheet.h
+active_tags.o: $(SRCROOT)/tk_utils/tkSheet.h
+active_tags.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+active_tags.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+active_tags.o: $(SRCROOT)/tk_utils/tkTrace.h
 alter_rel.o: $(PWD)/staden_config.h
+alter_rel.o: $(SRCROOT)/Misc/array.h
+alter_rel.o: $(SRCROOT)/Misc/bitmap.h
+alter_rel.o: $(SRCROOT)/Misc/dstring.h
+alter_rel.o: $(SRCROOT)/Misc/misc.h
+alter_rel.o: $(SRCROOT)/Misc/os.h
+alter_rel.o: $(SRCROOT)/Misc/xalloc.h
+alter_rel.o: $(SRCROOT)/Misc/xerror.h
+alter_rel.o: $(SRCROOT)/g/freetree.h
+alter_rel.o: $(SRCROOT)/g/g-defs.h
+alter_rel.o: $(SRCROOT)/g/g-error.h
+alter_rel.o: $(SRCROOT)/g/g-filedefs.h
+alter_rel.o: $(SRCROOT)/g/g-os.h
+alter_rel.o: $(SRCROOT)/g/g-struct.h
+alter_rel.o: $(SRCROOT)/gap4/IO1.h
+alter_rel.o: $(SRCROOT)/gap4/alter_rel.h
+alter_rel.o: $(SRCROOT)/gap4/dis_readings.h
+alter_rel.o: $(SRCROOT)/gap4/edStructs.h
+alter_rel.o: $(SRCROOT)/gap4/edUtils.h
+alter_rel.o: $(SRCROOT)/gap4/fort.h
+alter_rel.o: $(SRCROOT)/gap4/fortran.h
+alter_rel.o: $(SRCROOT)/gap4/gap-dbstruct.h
+alter_rel.o: $(SRCROOT)/gap4/gap-error.h
+alter_rel.o: $(SRCROOT)/gap4/gap-if.h
+alter_rel.o: $(SRCROOT)/gap4/io-reg.h
+alter_rel.o: $(SRCROOT)/gap4/io_handle.h
+alter_rel.o: $(SRCROOT)/gap4/io_utils.h
+alter_rel.o: $(SRCROOT)/gap4/list.h
+alter_rel.o: $(SRCROOT)/gap4/primlib.h
+alter_rel.o: $(SRCROOT)/gap4/qual.h
+alter_rel.o: $(SRCROOT)/gap4/tagDefs.h
+alter_rel.o: $(SRCROOT)/gap4/tagUtils.h
+alter_rel.o: $(SRCROOT)/gap4/template.h
+alter_rel.o: $(SRCROOT)/gap4/tkEdNames.h
+alter_rel.o: $(SRCROOT)/gap4/tkEditor.h
+alter_rel.o: $(SRCROOT)/gap4/tman_display.h
+alter_rel.o: $(SRCROOT)/gap4/undo.h
+alter_rel.o: $(SRCROOT)/primer3/src/dpal.h
+alter_rel.o: $(SRCROOT)/primer3/src/primer3.h
+alter_rel.o: $(SRCROOT)/tk_utils/cli_arg.h
+alter_rel.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+alter_rel.o: $(SRCROOT)/tk_utils/postscript.h
+alter_rel.o: $(SRCROOT)/tk_utils/sheet.h
+alter_rel.o: $(SRCROOT)/tk_utils/tkSheet.h
+alter_rel.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+alter_rel.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+alter_rel.o: $(SRCROOT)/tk_utils/tkTrace.h
 assemble_direct.o: $(PWD)/staden_config.h
+assemble_direct.o: $(SRCROOT)/Misc/array.h
+assemble_direct.o: $(SRCROOT)/Misc/bitmap.h
+assemble_direct.o: $(SRCROOT)/Misc/dstring.h
+assemble_direct.o: $(SRCROOT)/Misc/misc.h
+assemble_direct.o: $(SRCROOT)/Misc/os.h
+assemble_direct.o: $(SRCROOT)/Misc/xalloc.h
+assemble_direct.o: $(SRCROOT)/Misc/xerror.h
+assemble_direct.o: $(SRCROOT)/g/freetree.h
+assemble_direct.o: $(SRCROOT)/g/g-defs.h
+assemble_direct.o: $(SRCROOT)/g/g-error.h
+assemble_direct.o: $(SRCROOT)/g/g-filedefs.h
+assemble_direct.o: $(SRCROOT)/g/g-os.h
+assemble_direct.o: $(SRCROOT)/g/g-struct.h
+assemble_direct.o: $(SRCROOT)/gap4/IO1.h
+assemble_direct.o: $(SRCROOT)/gap4/IO2.h
+assemble_direct.o: $(SRCROOT)/gap4/assemble_direct.h
+assemble_direct.o: $(SRCROOT)/gap4/clones.h
+assemble_direct.o: $(SRCROOT)/gap4/consen.h
+assemble_direct.o: $(SRCROOT)/gap4/dis_readings.h
+assemble_direct.o: $(SRCROOT)/gap4/edStructs.h
+assemble_direct.o: $(SRCROOT)/gap4/edUtils.h
+assemble_direct.o: $(SRCROOT)/gap4/fort.h
+assemble_direct.o: $(SRCROOT)/gap4/fortran.h
+assemble_direct.o: $(SRCROOT)/gap4/gap-dbstruct.h
+assemble_direct.o: $(SRCROOT)/gap4/gap-if.h
+assemble_direct.o: $(SRCROOT)/gap4/gap_globals.h
+assemble_direct.o: $(SRCROOT)/gap4/io-reg.h
+assemble_direct.o: $(SRCROOT)/gap4/io_handle.h
+assemble_direct.o: $(SRCROOT)/gap4/io_utils.h
+assemble_direct.o: $(SRCROOT)/gap4/list.h
+assemble_direct.o: $(SRCROOT)/gap4/list_proc.h
+assemble_direct.o: $(SRCROOT)/gap4/notes.h
+assemble_direct.o: $(SRCROOT)/gap4/primlib.h
+assemble_direct.o: $(SRCROOT)/gap4/qual.h
+assemble_direct.o: $(SRCROOT)/gap4/seqInfo.h
+assemble_direct.o: $(SRCROOT)/gap4/tagDefs.h
+assemble_direct.o: $(SRCROOT)/gap4/tagUtils.h
+assemble_direct.o: $(SRCROOT)/gap4/template.h
+assemble_direct.o: $(SRCROOT)/gap4/tkEdNames.h
+assemble_direct.o: $(SRCROOT)/gap4/tkEditor.h
+assemble_direct.o: $(SRCROOT)/gap4/tman_display.h
+assemble_direct.o: $(SRCROOT)/gap4/undo.h
+assemble_direct.o: $(SRCROOT)/primer3/src/dpal.h
+assemble_direct.o: $(SRCROOT)/primer3/src/primer3.h
+assemble_direct.o: $(SRCROOT)/seq_utils/align.h
+assemble_direct.o: $(SRCROOT)/seq_utils/align_lib_old.h
+assemble_direct.o: $(SRCROOT)/seq_utils/dna_utils.h
+assemble_direct.o: $(SRCROOT)/tk_utils/cli_arg.h
+assemble_direct.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+assemble_direct.o: $(SRCROOT)/tk_utils/postscript.h
+assemble_direct.o: $(SRCROOT)/tk_utils/sheet.h
+assemble_direct.o: $(SRCROOT)/tk_utils/tcl_utils.h
+assemble_direct.o: $(SRCROOT)/tk_utils/text_output.h
+assemble_direct.o: $(SRCROOT)/tk_utils/tkSheet.h
+assemble_direct.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+assemble_direct.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+assemble_direct.o: $(SRCROOT)/tk_utils/tkTrace.h
 auto_assemble.o: $(PWD)/staden_config.h
+auto_assemble.o: $(SRCROOT)/Misc/array.h
+auto_assemble.o: $(SRCROOT)/Misc/bitmap.h
+auto_assemble.o: $(SRCROOT)/Misc/misc.h
+auto_assemble.o: $(SRCROOT)/Misc/os.h
+auto_assemble.o: $(SRCROOT)/Misc/xalloc.h
+auto_assemble.o: $(SRCROOT)/Misc/xerror.h
+auto_assemble.o: $(SRCROOT)/g/freetree.h
+auto_assemble.o: $(SRCROOT)/g/g-defs.h
+auto_assemble.o: $(SRCROOT)/g/g-error.h
+auto_assemble.o: $(SRCROOT)/g/g-filedefs.h
+auto_assemble.o: $(SRCROOT)/g/g-os.h
+auto_assemble.o: $(SRCROOT)/g/g-struct.h
+auto_assemble.o: $(SRCROOT)/gap4/IO1.h
+auto_assemble.o: $(SRCROOT)/gap4/complement.h
+auto_assemble.o: $(SRCROOT)/gap4/fort.h
+auto_assemble.o: $(SRCROOT)/gap4/gap-dbstruct.h
+auto_assemble.o: $(SRCROOT)/gap4/gap-if.h
+auto_assemble.o: $(SRCROOT)/gap4/gap_globals.h
+auto_assemble.o: $(SRCROOT)/gap4/io_handle.h
+auto_assemble.o: $(SRCROOT)/gap4/io_utils.h
+auto_assemble.o: $(SRCROOT)/gap4/list_proc.h
+auto_assemble.o: $(SRCROOT)/tk_utils/tcl_utils.h
 auto_break.o: $(PWD)/staden_config.h
+auto_break.o: $(SRCROOT)/Misc/array.h
+auto_break.o: $(SRCROOT)/Misc/bitmap.h
+auto_break.o: $(SRCROOT)/Misc/dstring.h
+auto_break.o: $(SRCROOT)/Misc/misc.h
+auto_break.o: $(SRCROOT)/Misc/os.h
+auto_break.o: $(SRCROOT)/Misc/xalloc.h
+auto_break.o: $(SRCROOT)/Misc/xerror.h
+auto_break.o: $(SRCROOT)/g/freetree.h
+auto_break.o: $(SRCROOT)/g/g-defs.h
+auto_break.o: $(SRCROOT)/g/g-error.h
+auto_break.o: $(SRCROOT)/g/g-filedefs.h
+auto_break.o: $(SRCROOT)/g/g-os.h
+auto_break.o: $(SRCROOT)/g/g-struct.h
+auto_break.o: $(SRCROOT)/gap4/IO1.h
+auto_break.o: $(SRCROOT)/gap4/auto_break.h
+auto_break.o: $(SRCROOT)/gap4/gap-dbstruct.h
+auto_break.o: $(SRCROOT)/gap4/gap-if.h
+auto_break.o: $(SRCROOT)/gap4/gap_globals.h
+auto_break.o: $(SRCROOT)/gap4/io_handle.h
+auto_break.o: $(SRCROOT)/gap4/io_utils.h
+auto_break.o: $(SRCROOT)/gap4/list.h
+auto_break.o: $(SRCROOT)/gap4/qual.h
+auto_break.o: $(SRCROOT)/gap4/qualIO.h
+auto_break.o: $(SRCROOT)/gap4/template.h
+auto_break.o: $(SRCROOT)/seq_utils/filter_words.h
+auto_break.o: $(SRCROOT)/tk_utils/tcl_utils.h
+auto_break.o: $(SRCROOT)/tk_utils/text_output.h
 break_contig.o: $(PWD)/staden_config.h
+break_contig.o: $(SRCROOT)/Misc/array.h
+break_contig.o: $(SRCROOT)/Misc/bitmap.h
+break_contig.o: $(SRCROOT)/Misc/misc.h
+break_contig.o: $(SRCROOT)/Misc/os.h
+break_contig.o: $(SRCROOT)/Misc/xalloc.h
+break_contig.o: $(SRCROOT)/Misc/xerror.h
+break_contig.o: $(SRCROOT)/g/freetree.h
+break_contig.o: $(SRCROOT)/g/g-defs.h
+break_contig.o: $(SRCROOT)/g/g-error.h
+break_contig.o: $(SRCROOT)/g/g-filedefs.h
+break_contig.o: $(SRCROOT)/g/g-os.h
+break_contig.o: $(SRCROOT)/g/g-struct.h
+break_contig.o: $(SRCROOT)/gap4/IO1.h
+break_contig.o: $(SRCROOT)/gap4/dis_readings.h
+break_contig.o: $(SRCROOT)/gap4/fort.h
+break_contig.o: $(SRCROOT)/gap4/gap-dbstruct.h
+break_contig.o: $(SRCROOT)/gap4/gap-if.h
+break_contig.o: $(SRCROOT)/gap4/io-reg.h
+break_contig.o: $(SRCROOT)/gap4/io_handle.h
+break_contig.o: $(SRCROOT)/gap4/io_utils.h
 bubbl3.o: $(PWD)/staden_config.h
+bubbl3.o: $(SRCROOT)/Misc/os.h
 check_assembly.o: $(PWD)/staden_config.h
+check_assembly.o: $(SRCROOT)/Misc/array.h
+check_assembly.o: $(SRCROOT)/Misc/bitmap.h
+check_assembly.o: $(SRCROOT)/Misc/dstring.h
+check_assembly.o: $(SRCROOT)/Misc/misc.h
+check_assembly.o: $(SRCROOT)/Misc/os.h
+check_assembly.o: $(SRCROOT)/Misc/xalloc.h
+check_assembly.o: $(SRCROOT)/Misc/xerror.h
+check_assembly.o: $(SRCROOT)/g/freetree.h
+check_assembly.o: $(SRCROOT)/g/g-defs.h
+check_assembly.o: $(SRCROOT)/g/g-error.h
+check_assembly.o: $(SRCROOT)/g/g-filedefs.h
+check_assembly.o: $(SRCROOT)/g/g-os.h
+check_assembly.o: $(SRCROOT)/g/g-struct.h
+check_assembly.o: $(SRCROOT)/gap4/IO1.h
+check_assembly.o: $(SRCROOT)/gap4/consen.h
+check_assembly.o: $(SRCROOT)/gap4/contigEditor.h
+check_assembly.o: $(SRCROOT)/gap4/contig_selector.h
+check_assembly.o: $(SRCROOT)/gap4/cs-object.h
+check_assembly.o: $(SRCROOT)/gap4/edStructs.h
+check_assembly.o: $(SRCROOT)/gap4/edUtils.h
+check_assembly.o: $(SRCROOT)/gap4/fort.h
+check_assembly.o: $(SRCROOT)/gap4/fortran.h
+check_assembly.o: $(SRCROOT)/gap4/gap-dbstruct.h
+check_assembly.o: $(SRCROOT)/gap4/gap-if.h
+check_assembly.o: $(SRCROOT)/gap4/gap_globals.h
+check_assembly.o: $(SRCROOT)/gap4/io-reg.h
+check_assembly.o: $(SRCROOT)/gap4/io_handle.h
+check_assembly.o: $(SRCROOT)/gap4/io_utils.h
+check_assembly.o: $(SRCROOT)/gap4/list.h
+check_assembly.o: $(SRCROOT)/gap4/primlib.h
+check_assembly.o: $(SRCROOT)/gap4/qual.h
+check_assembly.o: $(SRCROOT)/gap4/tagDefs.h
+check_assembly.o: $(SRCROOT)/gap4/tagUtils.h
+check_assembly.o: $(SRCROOT)/gap4/template.h
+check_assembly.o: $(SRCROOT)/gap4/tkEdNames.h
+check_assembly.o: $(SRCROOT)/gap4/tkEditor.h
+check_assembly.o: $(SRCROOT)/gap4/tman_display.h
+check_assembly.o: $(SRCROOT)/gap4/undo.h
+check_assembly.o: $(SRCROOT)/primer3/src/dpal.h
+check_assembly.o: $(SRCROOT)/primer3/src/primer3.h
+check_assembly.o: $(SRCROOT)/seq_utils/align.h
+check_assembly.o: $(SRCROOT)/seq_utils/align_lib_old.h
+check_assembly.o: $(SRCROOT)/seq_utils/dna_utils.h
+check_assembly.o: $(SRCROOT)/tk_utils/canvas_box.h
+check_assembly.o: $(SRCROOT)/tk_utils/cli_arg.h
+check_assembly.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+check_assembly.o: $(SRCROOT)/tk_utils/postscript.h
+check_assembly.o: $(SRCROOT)/tk_utils/sheet.h
+check_assembly.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+check_assembly.o: $(SRCROOT)/tk_utils/tcl_utils.h
+check_assembly.o: $(SRCROOT)/tk_utils/text_output.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkSheet.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkTrace.h
 clip.o: $(PWD)/staden_config.h
+clip.o: $(SRCROOT)/Misc/array.h
+clip.o: $(SRCROOT)/Misc/bitmap.h
+clip.o: $(SRCROOT)/Misc/dstring.h
+clip.o: $(SRCROOT)/Misc/misc.h
+clip.o: $(SRCROOT)/Misc/os.h
+clip.o: $(SRCROOT)/Misc/xalloc.h
+clip.o: $(SRCROOT)/Misc/xerror.h
+clip.o: $(SRCROOT)/g/freetree.h
+clip.o: $(SRCROOT)/g/g-defs.h
+clip.o: $(SRCROOT)/g/g-error.h
+clip.o: $(SRCROOT)/g/g-filedefs.h
+clip.o: $(SRCROOT)/g/g-os.h
+clip.o: $(SRCROOT)/g/g-struct.h
+clip.o: $(SRCROOT)/gap4/IO1.h
+clip.o: $(SRCROOT)/gap4/clip.h
+clip.o: $(SRCROOT)/gap4/dis_readings.h
+clip.o: $(SRCROOT)/gap4/edStructs.h
+clip.o: $(SRCROOT)/gap4/edUtils.h
+clip.o: $(SRCROOT)/gap4/fort.h
+clip.o: $(SRCROOT)/gap4/fortran.h
+clip.o: $(SRCROOT)/gap4/gap-dbstruct.h
+clip.o: $(SRCROOT)/gap4/gap-if.h
+clip.o: $(SRCROOT)/gap4/gap_globals.h
+clip.o: $(SRCROOT)/gap4/io-reg.h
+clip.o: $(SRCROOT)/gap4/io_handle.h
+clip.o: $(SRCROOT)/gap4/io_utils.h
+clip.o: $(SRCROOT)/gap4/list.h
+clip.o: $(SRCROOT)/gap4/primlib.h
+clip.o: $(SRCROOT)/gap4/qual.h
+clip.o: $(SRCROOT)/gap4/tagDefs.h
+clip.o: $(SRCROOT)/gap4/tagUtils.h
+clip.o: $(SRCROOT)/gap4/template.h
+clip.o: $(SRCROOT)/gap4/tkEdNames.h
+clip.o: $(SRCROOT)/gap4/tkEditor.h
+clip.o: $(SRCROOT)/gap4/tman_display.h
+clip.o: $(SRCROOT)/gap4/undo.h
+clip.o: $(SRCROOT)/primer3/src/dpal.h
+clip.o: $(SRCROOT)/primer3/src/primer3.h
+clip.o: $(SRCROOT)/seq_utils/dna_utils.h
+clip.o: $(SRCROOT)/tk_utils/cli_arg.h
+clip.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+clip.o: $(SRCROOT)/tk_utils/postscript.h
+clip.o: $(SRCROOT)/tk_utils/sheet.h
+clip.o: $(SRCROOT)/tk_utils/tcl_utils.h
+clip.o: $(SRCROOT)/tk_utils/tkSheet.h
+clip.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+clip.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+clip.o: $(SRCROOT)/tk_utils/tkTrace.h
 clones.o: $(PWD)/staden_config.h
+clones.o: $(SRCROOT)/Misc/array.h
+clones.o: $(SRCROOT)/Misc/bitmap.h
+clones.o: $(SRCROOT)/Misc/dstring.h
+clones.o: $(SRCROOT)/Misc/misc.h
+clones.o: $(SRCROOT)/Misc/os.h
+clones.o: $(SRCROOT)/Misc/xalloc.h
+clones.o: $(SRCROOT)/Misc/xerror.h
+clones.o: $(SRCROOT)/g/freetree.h
+clones.o: $(SRCROOT)/g/g-defs.h
+clones.o: $(SRCROOT)/g/g-error.h
+clones.o: $(SRCROOT)/g/g-filedefs.h
+clones.o: $(SRCROOT)/g/g-os.h
+clones.o: $(SRCROOT)/g/g-struct.h
+clones.o: $(SRCROOT)/gap4/IO1.h
+clones.o: $(SRCROOT)/gap4/clones.h
+clones.o: $(SRCROOT)/gap4/edStructs.h
+clones.o: $(SRCROOT)/gap4/edUtils.h
+clones.o: $(SRCROOT)/gap4/fort.h
+clones.o: $(SRCROOT)/gap4/fortran.h
+clones.o: $(SRCROOT)/gap4/gap-dbstruct.h
+clones.o: $(SRCROOT)/gap4/gap-defaults.h
+clones.o: $(SRCROOT)/gap4/gap-if.h
+clones.o: $(SRCROOT)/gap4/io-reg.h
+clones.o: $(SRCROOT)/gap4/io_handle.h
+clones.o: $(SRCROOT)/gap4/io_utils.h
+clones.o: $(SRCROOT)/gap4/list.h
+clones.o: $(SRCROOT)/gap4/notes.h
+clones.o: $(SRCROOT)/gap4/primlib.h
+clones.o: $(SRCROOT)/gap4/qual.h
+clones.o: $(SRCROOT)/gap4/seqInfo.h
+clones.o: $(SRCROOT)/gap4/tagDefs.h
+clones.o: $(SRCROOT)/gap4/tagUtils.h
+clones.o: $(SRCROOT)/gap4/template.h
+clones.o: $(SRCROOT)/gap4/tkEdNames.h
+clones.o: $(SRCROOT)/gap4/tkEditor.h
+clones.o: $(SRCROOT)/gap4/tman_display.h
+clones.o: $(SRCROOT)/gap4/undo.h
+clones.o: $(SRCROOT)/primer3/src/dpal.h
+clones.o: $(SRCROOT)/primer3/src/primer3.h
+clones.o: $(SRCROOT)/tk_utils/cli_arg.h
+clones.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+clones.o: $(SRCROOT)/tk_utils/postscript.h
+clones.o: $(SRCROOT)/tk_utils/sheet.h
+clones.o: $(SRCROOT)/tk_utils/tkSheet.h
+clones.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+clones.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+clones.o: $(SRCROOT)/tk_utils/tkTrace.h
 complement.o: $(PWD)/staden_config.h
+complement.o: $(SRCROOT)/Misc/array.h
+complement.o: $(SRCROOT)/Misc/bitmap.h
+complement.o: $(SRCROOT)/Misc/dstring.h
+complement.o: $(SRCROOT)/Misc/misc.h
+complement.o: $(SRCROOT)/Misc/os.h
+complement.o: $(SRCROOT)/Misc/xalloc.h
+complement.o: $(SRCROOT)/Misc/xerror.h
+complement.o: $(SRCROOT)/g/freetree.h
+complement.o: $(SRCROOT)/g/g-defs.h
+complement.o: $(SRCROOT)/g/g-error.h
+complement.o: $(SRCROOT)/g/g-filedefs.h
+complement.o: $(SRCROOT)/g/g-os.h
+complement.o: $(SRCROOT)/g/g-struct.h
+complement.o: $(SRCROOT)/gap4/IO1.h
+complement.o: $(SRCROOT)/gap4/complement.h
+complement.o: $(SRCROOT)/gap4/edStructs.h
+complement.o: $(SRCROOT)/gap4/edUtils.h
+complement.o: $(SRCROOT)/gap4/fort.h
+complement.o: $(SRCROOT)/gap4/fortran.h
+complement.o: $(SRCROOT)/gap4/gap-dbstruct.h
+complement.o: $(SRCROOT)/gap4/gap-if.h
+complement.o: $(SRCROOT)/gap4/gap_cli_arg.h
+complement.o: $(SRCROOT)/gap4/io-reg.h
+complement.o: $(SRCROOT)/gap4/io_handle.h
+complement.o: $(SRCROOT)/gap4/io_utils.h
+complement.o: $(SRCROOT)/gap4/list.h
+complement.o: $(SRCROOT)/gap4/list_proc.h
+complement.o: $(SRCROOT)/gap4/primlib.h
+complement.o: $(SRCROOT)/gap4/qual.h
+complement.o: $(SRCROOT)/gap4/tagDefs.h
+complement.o: $(SRCROOT)/gap4/tagUtils.h
+complement.o: $(SRCROOT)/gap4/template.h
+complement.o: $(SRCROOT)/gap4/tkEdNames.h
+complement.o: $(SRCROOT)/gap4/tkEditor.h
+complement.o: $(SRCROOT)/gap4/tman_display.h
+complement.o: $(SRCROOT)/gap4/undo.h
+complement.o: $(SRCROOT)/primer3/src/dpal.h
+complement.o: $(SRCROOT)/primer3/src/primer3.h
+complement.o: $(SRCROOT)/seq_utils/dna_utils.h
+complement.o: $(SRCROOT)/tk_utils/cli_arg.h
+complement.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+complement.o: $(SRCROOT)/tk_utils/postscript.h
+complement.o: $(SRCROOT)/tk_utils/sheet.h
+complement.o: $(SRCROOT)/tk_utils/tcl_utils.h
+complement.o: $(SRCROOT)/tk_utils/tkSheet.h
+complement.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+complement.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+complement.o: $(SRCROOT)/tk_utils/tkTrace.h
 confidence_graph.o: $(PWD)/staden_config.h
+confidence_graph.o: $(SRCROOT)/Misc/array.h
+confidence_graph.o: $(SRCROOT)/Misc/bitmap.h
+confidence_graph.o: $(SRCROOT)/Misc/misc.h
+confidence_graph.o: $(SRCROOT)/Misc/os.h
+confidence_graph.o: $(SRCROOT)/Misc/xalloc.h
+confidence_graph.o: $(SRCROOT)/Misc/xerror.h
+confidence_graph.o: $(SRCROOT)/g/freetree.h
+confidence_graph.o: $(SRCROOT)/g/g-defs.h
+confidence_graph.o: $(SRCROOT)/g/g-error.h
+confidence_graph.o: $(SRCROOT)/g/g-filedefs.h
+confidence_graph.o: $(SRCROOT)/g/g-os.h
+confidence_graph.o: $(SRCROOT)/g/g-struct.h
+confidence_graph.o: $(SRCROOT)/gap4/IO1.h
+confidence_graph.o: $(SRCROOT)/gap4/confidence_graph.h
+confidence_graph.o: $(SRCROOT)/gap4/consen.h
+confidence_graph.o: $(SRCROOT)/gap4/consistency_display.h
+confidence_graph.o: $(SRCROOT)/gap4/gap-dbstruct.h
+confidence_graph.o: $(SRCROOT)/gap4/gap-if.h
+confidence_graph.o: $(SRCROOT)/gap4/gap_canvas_box.h
+confidence_graph.o: $(SRCROOT)/gap4/gap_globals.h
+confidence_graph.o: $(SRCROOT)/gap4/io-reg.h
+confidence_graph.o: $(SRCROOT)/gap4/io_handle.h
+confidence_graph.o: $(SRCROOT)/gap4/io_utils.h
+confidence_graph.o: $(SRCROOT)/gap4/list.h
+confidence_graph.o: $(SRCROOT)/gap4/newgap_cmds.h
+confidence_graph.o: $(SRCROOT)/gap4/qual.h
+confidence_graph.o: $(SRCROOT)/gap4/ruler_display.h
+confidence_graph.o: $(SRCROOT)/tk_utils/canvas_box.h
+confidence_graph.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+confidence_graph.o: $(SRCROOT)/tk_utils/tcl_utils.h
+confidence_graph.o: $(SRCROOT)/tk_utils/text_output.h
 consen.o: $(PWD)/staden_config.h
+consen.o: $(SRCROOT)/Misc/FtoC.h
+consen.o: $(SRCROOT)/Misc/array.h
+consen.o: $(SRCROOT)/Misc/bitmap.h
+consen.o: $(SRCROOT)/Misc/dstring.h
+consen.o: $(SRCROOT)/Misc/misc.h
+consen.o: $(SRCROOT)/Misc/os.h
+consen.o: $(SRCROOT)/Misc/xalloc.h
+consen.o: $(SRCROOT)/Misc/xerror.h
+consen.o: $(SRCROOT)/g/freetree.h
+consen.o: $(SRCROOT)/g/g-defs.h
+consen.o: $(SRCROOT)/g/g-error.h
+consen.o: $(SRCROOT)/g/g-filedefs.h
+consen.o: $(SRCROOT)/g/g-os.h
+consen.o: $(SRCROOT)/g/g-struct.h
+consen.o: $(SRCROOT)/gap4/IO1.h
+consen.o: $(SRCROOT)/gap4/consen.h
+consen.o: $(SRCROOT)/gap4/edStructs.h
+consen.o: $(SRCROOT)/gap4/edUtils.h
+consen.o: $(SRCROOT)/gap4/extract.h
+consen.o: $(SRCROOT)/gap4/fort.h
+consen.o: $(SRCROOT)/gap4/fortran.h
+consen.o: $(SRCROOT)/gap4/gap-dbstruct.h
+consen.o: $(SRCROOT)/gap4/gap-if.h
+consen.o: $(SRCROOT)/gap4/gap_globals.h
+consen.o: $(SRCROOT)/gap4/io-reg.h
+consen.o: $(SRCROOT)/gap4/io_handle.h
+consen.o: $(SRCROOT)/gap4/io_utils.h
+consen.o: $(SRCROOT)/gap4/list.h
+consen.o: $(SRCROOT)/gap4/list_proc.h
+consen.o: $(SRCROOT)/gap4/primlib.h
+consen.o: $(SRCROOT)/gap4/qual.h
+consen.o: $(SRCROOT)/gap4/tagDefs.h
+consen.o: $(SRCROOT)/gap4/tagUtils.h
+consen.o: $(SRCROOT)/gap4/template.h
+consen.o: $(SRCROOT)/gap4/tkEdNames.h
+consen.o: $(SRCROOT)/gap4/tkEditor.h
+consen.o: $(SRCROOT)/gap4/tman_display.h
+consen.o: $(SRCROOT)/gap4/undo.h
+consen.o: $(SRCROOT)/primer3/src/dpal.h
+consen.o: $(SRCROOT)/primer3/src/primer3.h
+consen.o: $(SRCROOT)/seq_utils/align_lib.h
+consen.o: $(SRCROOT)/seq_utils/dna_utils.h
+consen.o: $(SRCROOT)/tk_utils/cli_arg.h
+consen.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+consen.o: $(SRCROOT)/tk_utils/postscript.h
+consen.o: $(SRCROOT)/tk_utils/sheet.h
+consen.o: $(SRCROOT)/tk_utils/tcl_utils.h
+consen.o: $(SRCROOT)/tk_utils/tkSheet.h
+consen.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+consen.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+consen.o: $(SRCROOT)/tk_utils/tkTrace.h
 consistency_canvas_box.o: $(PWD)/staden_config.h
+consistency_canvas_box.o: $(SRCROOT)/Misc/array.h
+consistency_canvas_box.o: $(SRCROOT)/Misc/bitmap.h
+consistency_canvas_box.o: $(SRCROOT)/Misc/os.h
+consistency_canvas_box.o: $(SRCROOT)/Misc/xerror.h
+consistency_canvas_box.o: $(SRCROOT)/g/freetree.h
+consistency_canvas_box.o: $(SRCROOT)/g/g-defs.h
+consistency_canvas_box.o: $(SRCROOT)/g/g-error.h
+consistency_canvas_box.o: $(SRCROOT)/g/g-filedefs.h
+consistency_canvas_box.o: $(SRCROOT)/g/g-os.h
+consistency_canvas_box.o: $(SRCROOT)/g/g-struct.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/IO1.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/consistency_display.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/gap-dbstruct.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/gap-if.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/gap_canvas_box.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/io-reg.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/io_handle.h
+consistency_canvas_box.o: $(SRCROOT)/gap4/io_utils.h
+consistency_canvas_box.o: $(SRCROOT)/tk_utils/canvas_box.h
 consistency_display.o: $(PWD)/staden_config.h
+consistency_display.o: $(SRCROOT)/Misc/array.h
+consistency_display.o: $(SRCROOT)/Misc/bitmap.h
+consistency_display.o: $(SRCROOT)/Misc/misc.h
+consistency_display.o: $(SRCROOT)/Misc/os.h
+consistency_display.o: $(SRCROOT)/Misc/xalloc.h
+consistency_display.o: $(SRCROOT)/Misc/xerror.h
+consistency_display.o: $(SRCROOT)/g/freetree.h
+consistency_display.o: $(SRCROOT)/g/g-defs.h
+consistency_display.o: $(SRCROOT)/g/g-error.h
+consistency_display.o: $(SRCROOT)/g/g-filedefs.h
+consistency_display.o: $(SRCROOT)/g/g-os.h
+consistency_display.o: $(SRCROOT)/g/g-struct.h
+consistency_display.o: $(SRCROOT)/gap4/IO1.h
+consistency_display.o: $(SRCROOT)/gap4/consistency_canvas_box.h
+consistency_display.o: $(SRCROOT)/gap4/consistency_display.h
+consistency_display.o: $(SRCROOT)/gap4/gap-dbstruct.h
+consistency_display.o: $(SRCROOT)/gap4/gap-if.h
+consistency_display.o: $(SRCROOT)/gap4/gap_canvas_box.h
+consistency_display.o: $(SRCROOT)/gap4/gap_globals.h
+consistency_display.o: $(SRCROOT)/gap4/hash.h
+consistency_display.o: $(SRCROOT)/gap4/io-reg.h
+consistency_display.o: $(SRCROOT)/gap4/io_handle.h
+consistency_display.o: $(SRCROOT)/gap4/io_utils.h
+consistency_display.o: $(SRCROOT)/gap4/list.h
+consistency_display.o: $(SRCROOT)/gap4/ruler_display.h
+consistency_display.o: $(SRCROOT)/gap4/template.h
+consistency_display.o: $(SRCROOT)/gap4/template_display.h
+consistency_display.o: $(SRCROOT)/tk_utils/canvas_box.h
+consistency_display.o: $(SRCROOT)/tk_utils/ruler_tick.h
+consistency_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
 contigEditor.o: $(PWD)/staden_config.h
+contigEditor.o: $(SRCROOT)/Misc/array.h
+contigEditor.o: $(SRCROOT)/Misc/bitmap.h
+contigEditor.o: $(SRCROOT)/Misc/dstring.h
+contigEditor.o: $(SRCROOT)/Misc/locks.h
+contigEditor.o: $(SRCROOT)/Misc/misc.h
+contigEditor.o: $(SRCROOT)/Misc/os.h
+contigEditor.o: $(SRCROOT)/Misc/xalloc.h
+contigEditor.o: $(SRCROOT)/Misc/xerror.h
+contigEditor.o: $(SRCROOT)/g/freetree.h
+contigEditor.o: $(SRCROOT)/g/g-defs.h
+contigEditor.o: $(SRCROOT)/g/g-error.h
+contigEditor.o: $(SRCROOT)/g/g-filedefs.h
+contigEditor.o: $(SRCROOT)/g/g-os.h
+contigEditor.o: $(SRCROOT)/g/g-struct.h
+contigEditor.o: $(SRCROOT)/gap4/IO1.h
+contigEditor.o: $(SRCROOT)/gap4/contigEditor.h
+contigEditor.o: $(SRCROOT)/gap4/edStructs.h
+contigEditor.o: $(SRCROOT)/gap4/edUtils.h
+contigEditor.o: $(SRCROOT)/gap4/fort.h
+contigEditor.o: $(SRCROOT)/gap4/fortran.h
+contigEditor.o: $(SRCROOT)/gap4/gap-dbstruct.h
+contigEditor.o: $(SRCROOT)/gap4/gap-if.h
+contigEditor.o: $(SRCROOT)/gap4/gap_cli_arg.h
+contigEditor.o: $(SRCROOT)/gap4/gap_globals.h
+contigEditor.o: $(SRCROOT)/gap4/io-reg.h
+contigEditor.o: $(SRCROOT)/gap4/io_handle.h
+contigEditor.o: $(SRCROOT)/gap4/io_utils.h
+contigEditor.o: $(SRCROOT)/gap4/list.h
+contigEditor.o: $(SRCROOT)/gap4/list_proc.h
+contigEditor.o: $(SRCROOT)/gap4/primlib.h
+contigEditor.o: $(SRCROOT)/gap4/qual.h
+contigEditor.o: $(SRCROOT)/gap4/select.h
+contigEditor.o: $(SRCROOT)/gap4/tagDefs.h
+contigEditor.o: $(SRCROOT)/gap4/tagUtils.h
+contigEditor.o: $(SRCROOT)/gap4/template.h
+contigEditor.o: $(SRCROOT)/gap4/tkEdNames.h
+contigEditor.o: $(SRCROOT)/gap4/tkEditor.h
+contigEditor.o: $(SRCROOT)/gap4/tman_display.h
+contigEditor.o: $(SRCROOT)/gap4/tman_interface.h
+contigEditor.o: $(SRCROOT)/gap4/undo.h
+contigEditor.o: $(SRCROOT)/primer3/src/dpal.h
+contigEditor.o: $(SRCROOT)/primer3/src/primer3.h
+contigEditor.o: $(SRCROOT)/tk_utils/cli_arg.h
+contigEditor.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+contigEditor.o: $(SRCROOT)/tk_utils/postscript.h
+contigEditor.o: $(SRCROOT)/tk_utils/sheet.h
+contigEditor.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+contigEditor.o: $(SRCROOT)/tk_utils/tcl_utils.h
+contigEditor.o: $(SRCROOT)/tk_utils/tkSheet.h
+contigEditor.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+contigEditor.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+contigEditor.o: $(SRCROOT)/tk_utils/tkTrace.h
 contig_order.o: $(PWD)/staden_config.h
+contig_order.o: $(SRCROOT)/Misc/array.h
+contig_order.o: $(SRCROOT)/Misc/bitmap.h
+contig_order.o: $(SRCROOT)/Misc/misc.h
+contig_order.o: $(SRCROOT)/Misc/os.h
+contig_order.o: $(SRCROOT)/Misc/xalloc.h
+contig_order.o: $(SRCROOT)/Misc/xerror.h
+contig_order.o: $(SRCROOT)/g/freetree.h
+contig_order.o: $(SRCROOT)/g/g-defs.h
+contig_order.o: $(SRCROOT)/g/g-error.h
+contig_order.o: $(SRCROOT)/g/g-filedefs.h
+contig_order.o: $(SRCROOT)/g/g-os.h
+contig_order.o: $(SRCROOT)/g/g-struct.h
+contig_order.o: $(SRCROOT)/gap4/IO1.h
+contig_order.o: $(SRCROOT)/gap4/QueueInterface.h
+contig_order.o: $(SRCROOT)/gap4/SeqQueueTypes.h
+contig_order.o: $(SRCROOT)/gap4/gap-dbstruct.h
+contig_order.o: $(SRCROOT)/gap4/gap-if.h
+contig_order.o: $(SRCROOT)/gap4/io-reg.h
+contig_order.o: $(SRCROOT)/gap4/io_handle.h
+contig_order.o: $(SRCROOT)/gap4/io_utils.h
+contig_order.o: $(SRCROOT)/gap4/list.h
+contig_order.o: $(SRCROOT)/gap4/template.h
 contig_selector.o: $(PWD)/staden_config.h
+contig_selector.o: $(SRCROOT)/Misc/array.h
+contig_selector.o: $(SRCROOT)/Misc/bitmap.h
+contig_selector.o: $(SRCROOT)/Misc/dstring.h
+contig_selector.o: $(SRCROOT)/Misc/misc.h
+contig_selector.o: $(SRCROOT)/Misc/os.h
+contig_selector.o: $(SRCROOT)/Misc/xalloc.h
+contig_selector.o: $(SRCROOT)/Misc/xerror.h
+contig_selector.o: $(SRCROOT)/g/freetree.h
+contig_selector.o: $(SRCROOT)/g/g-defs.h
+contig_selector.o: $(SRCROOT)/g/g-error.h
+contig_selector.o: $(SRCROOT)/g/g-filedefs.h
+contig_selector.o: $(SRCROOT)/g/g-os.h
+contig_selector.o: $(SRCROOT)/g/g-struct.h
+contig_selector.o: $(SRCROOT)/gap4/IO1.h
+contig_selector.o: $(SRCROOT)/gap4/active_tags.h
+contig_selector.o: $(SRCROOT)/gap4/complement.h
+contig_selector.o: $(SRCROOT)/gap4/contigEditor.h
+contig_selector.o: $(SRCROOT)/gap4/contig_selector.h
+contig_selector.o: $(SRCROOT)/gap4/cs-object.h
+contig_selector.o: $(SRCROOT)/gap4/edStructs.h
+contig_selector.o: $(SRCROOT)/gap4/edUtils.h
+contig_selector.o: $(SRCROOT)/gap4/fort.h
+contig_selector.o: $(SRCROOT)/gap4/fortran.h
+contig_selector.o: $(SRCROOT)/gap4/gap-dbstruct.h
+contig_selector.o: $(SRCROOT)/gap4/gap-if.h
+contig_selector.o: $(SRCROOT)/gap4/gap_globals.h
+contig_selector.o: $(SRCROOT)/gap4/hash.h
+contig_selector.o: $(SRCROOT)/gap4/io-reg.h
+contig_selector.o: $(SRCROOT)/gap4/io_handle.h
+contig_selector.o: $(SRCROOT)/gap4/io_utils.h
+contig_selector.o: $(SRCROOT)/gap4/list.h
+contig_selector.o: $(SRCROOT)/gap4/newgap_cmds.h
+contig_selector.o: $(SRCROOT)/gap4/primlib.h
+contig_selector.o: $(SRCROOT)/gap4/qual.h
+contig_selector.o: $(SRCROOT)/gap4/ruler_display.h
+contig_selector.o: $(SRCROOT)/gap4/tagDefs.h
+contig_selector.o: $(SRCROOT)/gap4/tagUtils.h
+contig_selector.o: $(SRCROOT)/gap4/tagdb.h
+contig_selector.o: $(SRCROOT)/gap4/template.h
+contig_selector.o: $(SRCROOT)/gap4/template_display.h
+contig_selector.o: $(SRCROOT)/gap4/tkEdNames.h
+contig_selector.o: $(SRCROOT)/gap4/tkEditor.h
+contig_selector.o: $(SRCROOT)/gap4/tman_display.h
+contig_selector.o: $(SRCROOT)/gap4/undo.h
+contig_selector.o: $(SRCROOT)/primer3/src/dpal.h
+contig_selector.o: $(SRCROOT)/primer3/src/primer3.h
+contig_selector.o: $(SRCROOT)/tk_utils/canvas_box.h
+contig_selector.o: $(SRCROOT)/tk_utils/cli_arg.h
+contig_selector.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+contig_selector.o: $(SRCROOT)/tk_utils/postscript.h
+contig_selector.o: $(SRCROOT)/tk_utils/sheet.h
+contig_selector.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+contig_selector.o: $(SRCROOT)/tk_utils/tcl_utils.h
+contig_selector.o: $(SRCROOT)/tk_utils/text_output.h
+contig_selector.o: $(SRCROOT)/tk_utils/tkSheet.h
+contig_selector.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+contig_selector.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+contig_selector.o: $(SRCROOT)/tk_utils/tkTrace.h
 copy_db.o: $(PWD)/staden_config.h
+copy_db.o: $(SRCROOT)/Misc/array.h
+copy_db.o: $(SRCROOT)/Misc/bitmap.h
+copy_db.o: $(SRCROOT)/Misc/misc.h
+copy_db.o: $(SRCROOT)/Misc/os.h
+copy_db.o: $(SRCROOT)/Misc/xalloc.h
+copy_db.o: $(SRCROOT)/Misc/xerror.h
+copy_db.o: $(SRCROOT)/g/freetree.h
+copy_db.o: $(SRCROOT)/g/g-defs.h
+copy_db.o: $(SRCROOT)/g/g-error.h
+copy_db.o: $(SRCROOT)/g/g-filedefs.h
+copy_db.o: $(SRCROOT)/g/g-os.h
+copy_db.o: $(SRCROOT)/g/g-struct.h
+copy_db.o: $(SRCROOT)/gap4/IO1.h
+copy_db.o: $(SRCROOT)/gap4/copy_db.h
+copy_db.o: $(SRCROOT)/gap4/gap-dbstruct.h
+copy_db.o: $(SRCROOT)/gap4/gap-if.h
+copy_db.o: $(SRCROOT)/gap4/io_handle.h
+copy_db.o: $(SRCROOT)/gap4/io_utils.h
+copy_db.o: $(SRCROOT)/tk_utils/text_output.h
 copy_db_main.o: $(PWD)/staden_config.h
+copy_db_main.o: $(SRCROOT)/Misc/array.h
+copy_db_main.o: $(SRCROOT)/Misc/bitmap.h
+copy_db_main.o: $(SRCROOT)/Misc/misc.h
+copy_db_main.o: $(SRCROOT)/Misc/os.h
+copy_db_main.o: $(SRCROOT)/Misc/xalloc.h
+copy_db_main.o: $(SRCROOT)/Misc/xerror.h
+copy_db_main.o: $(SRCROOT)/g/freetree.h
+copy_db_main.o: $(SRCROOT)/g/g-defs.h
+copy_db_main.o: $(SRCROOT)/g/g-error.h
+copy_db_main.o: $(SRCROOT)/g/g-filedefs.h
+copy_db_main.o: $(SRCROOT)/g/g-os.h
+copy_db_main.o: $(SRCROOT)/g/g-struct.h
+copy_db_main.o: $(SRCROOT)/gap4/IO1.h
+copy_db_main.o: $(SRCROOT)/gap4/copy_db.h
+copy_db_main.o: $(SRCROOT)/gap4/gap-create.h
+copy_db_main.o: $(SRCROOT)/gap4/gap-dbstruct.h
+copy_db_main.o: $(SRCROOT)/gap4/gap-if.h
+copy_db_main.o: $(SRCROOT)/gap4/io_handle.h
+copy_db_main.o: $(SRCROOT)/gap4/io_utils.h
 cs-object.o: $(PWD)/staden_config.h
+cs-object.o: $(SRCROOT)/Misc/array.h
+cs-object.o: $(SRCROOT)/Misc/bitmap.h
+cs-object.o: $(SRCROOT)/Misc/misc.h
+cs-object.o: $(SRCROOT)/Misc/os.h
+cs-object.o: $(SRCROOT)/Misc/xalloc.h
+cs-object.o: $(SRCROOT)/Misc/xerror.h
+cs-object.o: $(SRCROOT)/g/freetree.h
+cs-object.o: $(SRCROOT)/g/g-defs.h
+cs-object.o: $(SRCROOT)/g/g-error.h
+cs-object.o: $(SRCROOT)/g/g-filedefs.h
+cs-object.o: $(SRCROOT)/g/g-os.h
+cs-object.o: $(SRCROOT)/g/g-struct.h
+cs-object.o: $(SRCROOT)/gap4/IO1.h
+cs-object.o: $(SRCROOT)/gap4/contig_selector.h
+cs-object.o: $(SRCROOT)/gap4/cs-object.h
+cs-object.o: $(SRCROOT)/gap4/gap-dbstruct.h
+cs-object.o: $(SRCROOT)/gap4/gap-if.h
+cs-object.o: $(SRCROOT)/gap4/gap_globals.h
+cs-object.o: $(SRCROOT)/gap4/io-reg.h
+cs-object.o: $(SRCROOT)/gap4/io_handle.h
+cs-object.o: $(SRCROOT)/gap4/io_utils.h
+cs-object.o: $(SRCROOT)/gap4/list.h
+cs-object.o: $(SRCROOT)/gap4/newgap_cmds.h
+cs-object.o: $(SRCROOT)/gap4/tk-io-reg.h
+cs-object.o: $(SRCROOT)/tk_utils/canvas_box.h
+cs-object.o: $(SRCROOT)/tk_utils/tcl_utils.h
+cs-object.o: $(SRCROOT)/tk_utils/text_output.h
 dbcheck.o: $(PWD)/staden_config.h
+dbcheck.o: $(SRCROOT)/Misc/array.h
+dbcheck.o: $(SRCROOT)/Misc/bitmap.h
+dbcheck.o: $(SRCROOT)/Misc/misc.h
+dbcheck.o: $(SRCROOT)/Misc/os.h
+dbcheck.o: $(SRCROOT)/Misc/xalloc.h
+dbcheck.o: $(SRCROOT)/Misc/xerror.h
+dbcheck.o: $(SRCROOT)/g/freetree.h
+dbcheck.o: $(SRCROOT)/g/g-defs.h
+dbcheck.o: $(SRCROOT)/g/g-error.h
+dbcheck.o: $(SRCROOT)/g/g-filedefs.h
+dbcheck.o: $(SRCROOT)/g/g-os.h
+dbcheck.o: $(SRCROOT)/g/g-struct.h
+dbcheck.o: $(SRCROOT)/gap4/IO1.h
+dbcheck.o: $(SRCROOT)/gap4/dbcheck.h
+dbcheck.o: $(SRCROOT)/gap4/fort.h
+dbcheck.o: $(SRCROOT)/gap4/fortran.h
+dbcheck.o: $(SRCROOT)/gap4/gap-dbstruct.h
+dbcheck.o: $(SRCROOT)/gap4/gap-error.h
+dbcheck.o: $(SRCROOT)/gap4/gap-if.h
+dbcheck.o: $(SRCROOT)/gap4/gap_globals.h
+dbcheck.o: $(SRCROOT)/gap4/io_handle.h
+dbcheck.o: $(SRCROOT)/gap4/io_utils.h
+dbcheck.o: $(SRCROOT)/tk_utils/tcl_utils.h
+dbcheck.o: $(SRCROOT)/tk_utils/text_output.h
 dis_readings.o: $(PWD)/staden_config.h
+dis_readings.o: $(SRCROOT)/Misc/array.h
+dis_readings.o: $(SRCROOT)/Misc/bitmap.h
+dis_readings.o: $(SRCROOT)/Misc/dstring.h
+dis_readings.o: $(SRCROOT)/Misc/misc.h
+dis_readings.o: $(SRCROOT)/Misc/os.h
+dis_readings.o: $(SRCROOT)/Misc/xalloc.h
+dis_readings.o: $(SRCROOT)/Misc/xerror.h
+dis_readings.o: $(SRCROOT)/g/freetree.h
+dis_readings.o: $(SRCROOT)/g/g-defs.h
+dis_readings.o: $(SRCROOT)/g/g-error.h
+dis_readings.o: $(SRCROOT)/g/g-filedefs.h
+dis_readings.o: $(SRCROOT)/g/g-os.h
+dis_readings.o: $(SRCROOT)/g/g-struct.h
+dis_readings.o: $(SRCROOT)/gap4/IO1.h
+dis_readings.o: $(SRCROOT)/gap4/IO2.h
+dis_readings.o: $(SRCROOT)/gap4/dbcheck.h
+dis_readings.o: $(SRCROOT)/gap4/dis_readings.h
+dis_readings.o: $(SRCROOT)/gap4/edStructs.h
+dis_readings.o: $(SRCROOT)/gap4/edUtils.h
+dis_readings.o: $(SRCROOT)/gap4/fort.h
+dis_readings.o: $(SRCROOT)/gap4/fortran.h
+dis_readings.o: $(SRCROOT)/gap4/gap-dbstruct.h
+dis_readings.o: $(SRCROOT)/gap4/gap-if.h
+dis_readings.o: $(SRCROOT)/gap4/io-reg.h
+dis_readings.o: $(SRCROOT)/gap4/io_handle.h
+dis_readings.o: $(SRCROOT)/gap4/io_utils.h
+dis_readings.o: $(SRCROOT)/gap4/list.h
+dis_readings.o: $(SRCROOT)/gap4/list_proc.h
+dis_readings.o: $(SRCROOT)/gap4/notes.h
+dis_readings.o: $(SRCROOT)/gap4/primlib.h
+dis_readings.o: $(SRCROOT)/gap4/qual.h
+dis_readings.o: $(SRCROOT)/gap4/tagDefs.h
+dis_readings.o: $(SRCROOT)/gap4/tagUtils.h
+dis_readings.o: $(SRCROOT)/gap4/template.h
+dis_readings.o: $(SRCROOT)/gap4/tkEdNames.h
+dis_readings.o: $(SRCROOT)/gap4/tkEditor.h
+dis_readings.o: $(SRCROOT)/gap4/tman_display.h
+dis_readings.o: $(SRCROOT)/gap4/undo.h
+dis_readings.o: $(SRCROOT)/primer3/src/dpal.h
+dis_readings.o: $(SRCROOT)/primer3/src/primer3.h
+dis_readings.o: $(SRCROOT)/tk_utils/cli_arg.h
+dis_readings.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+dis_readings.o: $(SRCROOT)/tk_utils/postscript.h
+dis_readings.o: $(SRCROOT)/tk_utils/sheet.h
+dis_readings.o: $(SRCROOT)/tk_utils/tkSheet.h
+dis_readings.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+dis_readings.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+dis_readings.o: $(SRCROOT)/tk_utils/tkTrace.h
 do_fij.o: $(PWD)/staden_config.h
+do_fij.o: $(SRCROOT)/Misc/array.h
+do_fij.o: $(SRCROOT)/Misc/bitmap.h
+do_fij.o: $(SRCROOT)/Misc/misc.h
+do_fij.o: $(SRCROOT)/Misc/os.h
+do_fij.o: $(SRCROOT)/Misc/xalloc.h
+do_fij.o: $(SRCROOT)/Misc/xerror.h
+do_fij.o: $(SRCROOT)/g/freetree.h
+do_fij.o: $(SRCROOT)/g/g-defs.h
+do_fij.o: $(SRCROOT)/g/g-error.h
+do_fij.o: $(SRCROOT)/g/g-filedefs.h
+do_fij.o: $(SRCROOT)/g/g-os.h
+do_fij.o: $(SRCROOT)/g/g-struct.h
+do_fij.o: $(SRCROOT)/gap4/IO1.h
+do_fij.o: $(SRCROOT)/gap4/consen.h
+do_fij.o: $(SRCROOT)/gap4/fij.h
+do_fij.o: $(SRCROOT)/gap4/gap-dbstruct.h
+do_fij.o: $(SRCROOT)/gap4/gap-if.h
+do_fij.o: $(SRCROOT)/gap4/hash_lib.h
+do_fij.o: $(SRCROOT)/gap4/io_handle.h
+do_fij.o: $(SRCROOT)/gap4/io_utils.h
+do_fij.o: $(SRCROOT)/seq_utils/align_lib.h
+do_fij.o: $(SRCROOT)/seq_utils/dna_utils.h
 dstrand.o: $(PWD)/staden_config.h
+dstrand.o: $(SRCROOT)/Misc/FtoC.h
+dstrand.o: $(SRCROOT)/Misc/array.h
+dstrand.o: $(SRCROOT)/Misc/bitmap.h
+dstrand.o: $(SRCROOT)/Misc/dstring.h
+dstrand.o: $(SRCROOT)/Misc/misc.h
+dstrand.o: $(SRCROOT)/Misc/os.h
+dstrand.o: $(SRCROOT)/Misc/xalloc.h
+dstrand.o: $(SRCROOT)/Misc/xerror.h
+dstrand.o: $(SRCROOT)/g/freetree.h
+dstrand.o: $(SRCROOT)/g/g-defs.h
+dstrand.o: $(SRCROOT)/g/g-error.h
+dstrand.o: $(SRCROOT)/g/g-filedefs.h
+dstrand.o: $(SRCROOT)/g/g-os.h
+dstrand.o: $(SRCROOT)/g/g-struct.h
+dstrand.o: $(SRCROOT)/gap4/IO1.h
+dstrand.o: $(SRCROOT)/gap4/IO2.h
+dstrand.o: $(SRCROOT)/gap4/complement.h
+dstrand.o: $(SRCROOT)/gap4/dstrand.h
+dstrand.o: $(SRCROOT)/gap4/edStructs.h
+dstrand.o: $(SRCROOT)/gap4/edUtils.h
+dstrand.o: $(SRCROOT)/gap4/fort.h
+dstrand.o: $(SRCROOT)/gap4/fortran.h
+dstrand.o: $(SRCROOT)/gap4/gap-dbstruct.h
+dstrand.o: $(SRCROOT)/gap4/gap-if.h
+dstrand.o: $(SRCROOT)/gap4/gap_globals.h
+dstrand.o: $(SRCROOT)/gap4/io-reg.h
+dstrand.o: $(SRCROOT)/gap4/io_handle.h
+dstrand.o: $(SRCROOT)/gap4/io_utils.h
+dstrand.o: $(SRCROOT)/gap4/list.h
+dstrand.o: $(SRCROOT)/gap4/primlib.h
+dstrand.o: $(SRCROOT)/gap4/qual.h
+dstrand.o: $(SRCROOT)/gap4/tagDefs.h
+dstrand.o: $(SRCROOT)/gap4/tagUtils.h
+dstrand.o: $(SRCROOT)/gap4/template.h
+dstrand.o: $(SRCROOT)/gap4/tkEdNames.h
+dstrand.o: $(SRCROOT)/gap4/tkEditor.h
+dstrand.o: $(SRCROOT)/gap4/tman_display.h
+dstrand.o: $(SRCROOT)/gap4/undo.h
+dstrand.o: $(SRCROOT)/primer3/src/dpal.h
+dstrand.o: $(SRCROOT)/primer3/src/primer3.h
+dstrand.o: $(SRCROOT)/seq_utils/align.h
+dstrand.o: $(SRCROOT)/seq_utils/align_lib_old.h
+dstrand.o: $(SRCROOT)/tk_utils/cli_arg.h
+dstrand.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+dstrand.o: $(SRCROOT)/tk_utils/postscript.h
+dstrand.o: $(SRCROOT)/tk_utils/sheet.h
+dstrand.o: $(SRCROOT)/tk_utils/tcl_utils.h
+dstrand.o: $(SRCROOT)/tk_utils/text_output.h
+dstrand.o: $(SRCROOT)/tk_utils/tkSheet.h
+dstrand.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+dstrand.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+dstrand.o: $(SRCROOT)/tk_utils/tkTrace.h
 edCommands.o: $(PWD)/staden_config.h
+edCommands.o: $(SRCROOT)/Misc/array.h
+edCommands.o: $(SRCROOT)/Misc/bitmap.h
+edCommands.o: $(SRCROOT)/Misc/dstring.h
+edCommands.o: $(SRCROOT)/Misc/misc.h
+edCommands.o: $(SRCROOT)/Misc/os.h
+edCommands.o: $(SRCROOT)/Misc/xalloc.h
+edCommands.o: $(SRCROOT)/Misc/xerror.h
+edCommands.o: $(SRCROOT)/g/freetree.h
+edCommands.o: $(SRCROOT)/g/g-defs.h
+edCommands.o: $(SRCROOT)/g/g-error.h
+edCommands.o: $(SRCROOT)/g/g-filedefs.h
+edCommands.o: $(SRCROOT)/g/g-os.h
+edCommands.o: $(SRCROOT)/g/g-struct.h
+edCommands.o: $(SRCROOT)/gap4/IO1.h
+edCommands.o: $(SRCROOT)/gap4/edStructs.h
+edCommands.o: $(SRCROOT)/gap4/edUtils.h
+edCommands.o: $(SRCROOT)/gap4/fort.h
+edCommands.o: $(SRCROOT)/gap4/fortran.h
+edCommands.o: $(SRCROOT)/gap4/gap-dbstruct.h
+edCommands.o: $(SRCROOT)/gap4/gap-if.h
+edCommands.o: $(SRCROOT)/gap4/gap_globals.h
+edCommands.o: $(SRCROOT)/gap4/io-reg.h
+edCommands.o: $(SRCROOT)/gap4/io_handle.h
+edCommands.o: $(SRCROOT)/gap4/io_utils.h
+edCommands.o: $(SRCROOT)/gap4/list.h
+edCommands.o: $(SRCROOT)/gap4/primlib.h
+edCommands.o: $(SRCROOT)/gap4/qual.h
+edCommands.o: $(SRCROOT)/gap4/select.h
+edCommands.o: $(SRCROOT)/gap4/tagDefs.h
+edCommands.o: $(SRCROOT)/gap4/tagUtils.h
+edCommands.o: $(SRCROOT)/gap4/template.h
+edCommands.o: $(SRCROOT)/gap4/tkEdNames.h
+edCommands.o: $(SRCROOT)/gap4/tkEditor.h
+edCommands.o: $(SRCROOT)/gap4/tman_display.h
+edCommands.o: $(SRCROOT)/gap4/tman_interface.h
+edCommands.o: $(SRCROOT)/gap4/undo.h
+edCommands.o: $(SRCROOT)/primer3/src/dpal.h
+edCommands.o: $(SRCROOT)/primer3/src/primer3.h
+edCommands.o: $(SRCROOT)/seq_utils/align.h
+edCommands.o: $(SRCROOT)/seq_utils/align_lib_old.h
+edCommands.o: $(SRCROOT)/tk_utils/cli_arg.h
+edCommands.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+edCommands.o: $(SRCROOT)/tk_utils/postscript.h
+edCommands.o: $(SRCROOT)/tk_utils/sheet.h
+edCommands.o: $(SRCROOT)/tk_utils/tcl_utils.h
+edCommands.o: $(SRCROOT)/tk_utils/tkSheet.h
+edCommands.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+edCommands.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+edCommands.o: $(SRCROOT)/tk_utils/tkTrace.h
 edExtend.o: $(PWD)/staden_config.h
+edExtend.o: $(SRCROOT)/Misc/array.h
+edExtend.o: $(SRCROOT)/Misc/bitmap.h
+edExtend.o: $(SRCROOT)/Misc/dstring.h
+edExtend.o: $(SRCROOT)/Misc/misc.h
+edExtend.o: $(SRCROOT)/Misc/os.h
+edExtend.o: $(SRCROOT)/Misc/xalloc.h
+edExtend.o: $(SRCROOT)/Misc/xerror.h
+edExtend.o: $(SRCROOT)/g/freetree.h
+edExtend.o: $(SRCROOT)/g/g-defs.h
+edExtend.o: $(SRCROOT)/g/g-error.h
+edExtend.o: $(SRCROOT)/g/g-filedefs.h
+edExtend.o: $(SRCROOT)/g/g-os.h
+edExtend.o: $(SRCROOT)/g/g-struct.h
+edExtend.o: $(SRCROOT)/gap4/IO1.h
+edExtend.o: $(SRCROOT)/gap4/contigEditor.h
+edExtend.o: $(SRCROOT)/gap4/edStructs.h
+edExtend.o: $(SRCROOT)/gap4/edUtils.h
+edExtend.o: $(SRCROOT)/gap4/extend.h
+edExtend.o: $(SRCROOT)/gap4/fort.h
+edExtend.o: $(SRCROOT)/gap4/fortran.h
+edExtend.o: $(SRCROOT)/gap4/gap-dbstruct.h
+edExtend.o: $(SRCROOT)/gap4/gap-if.h
+edExtend.o: $(SRCROOT)/gap4/io-reg.h
+edExtend.o: $(SRCROOT)/gap4/io_handle.h
+edExtend.o: $(SRCROOT)/gap4/io_utils.h
+edExtend.o: $(SRCROOT)/gap4/list.h
+edExtend.o: $(SRCROOT)/gap4/primlib.h
+edExtend.o: $(SRCROOT)/gap4/qual.h
+edExtend.o: $(SRCROOT)/gap4/select.h
+edExtend.o: $(SRCROOT)/gap4/tagDefs.h
+edExtend.o: $(SRCROOT)/gap4/tagUtils.h
+edExtend.o: $(SRCROOT)/gap4/template.h
+edExtend.o: $(SRCROOT)/gap4/tkEdNames.h
+edExtend.o: $(SRCROOT)/gap4/tkEditor.h
+edExtend.o: $(SRCROOT)/gap4/tman_display.h
+edExtend.o: $(SRCROOT)/gap4/undo.h
+edExtend.o: $(SRCROOT)/primer3/src/dpal.h
+edExtend.o: $(SRCROOT)/primer3/src/primer3.h
+edExtend.o: $(SRCROOT)/tk_utils/cli_arg.h
+edExtend.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+edExtend.o: $(SRCROOT)/tk_utils/postscript.h
+edExtend.o: $(SRCROOT)/tk_utils/sheet.h
+edExtend.o: $(SRCROOT)/tk_utils/tkSheet.h
+edExtend.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+edExtend.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+edExtend.o: $(SRCROOT)/tk_utils/tkTrace.h
 edInterface.o: $(PWD)/staden_config.h
+edInterface.o: $(SRCROOT)/Misc/array.h
+edInterface.o: $(SRCROOT)/Misc/bitmap.h
+edInterface.o: $(SRCROOT)/Misc/dstring.h
+edInterface.o: $(SRCROOT)/Misc/misc.h
+edInterface.o: $(SRCROOT)/Misc/os.h
+edInterface.o: $(SRCROOT)/Misc/xalloc.h
+edInterface.o: $(SRCROOT)/Misc/xerror.h
+edInterface.o: $(SRCROOT)/g/freetree.h
+edInterface.o: $(SRCROOT)/g/g-defs.h
+edInterface.o: $(SRCROOT)/g/g-error.h
+edInterface.o: $(SRCROOT)/g/g-filedefs.h
+edInterface.o: $(SRCROOT)/g/g-os.h
+edInterface.o: $(SRCROOT)/g/g-struct.h
+edInterface.o: $(SRCROOT)/gap4/IO1.h
+edInterface.o: $(SRCROOT)/gap4/active_tags.h
+edInterface.o: $(SRCROOT)/gap4/contigEditor.h
+edInterface.o: $(SRCROOT)/gap4/edStructs.h
+edInterface.o: $(SRCROOT)/gap4/edUtils.h
+edInterface.o: $(SRCROOT)/gap4/extend.h
+edInterface.o: $(SRCROOT)/gap4/fort.h
+edInterface.o: $(SRCROOT)/gap4/fortran.h
+edInterface.o: $(SRCROOT)/gap4/gap-dbstruct.h
+edInterface.o: $(SRCROOT)/gap4/gap-if.h
+edInterface.o: $(SRCROOT)/gap4/gap_globals.h
+edInterface.o: $(SRCROOT)/gap4/hash.h
+edInterface.o: $(SRCROOT)/gap4/io-reg.h
+edInterface.o: $(SRCROOT)/gap4/io_handle.h
+edInterface.o: $(SRCROOT)/gap4/io_utils.h
+edInterface.o: $(SRCROOT)/gap4/list.h
+edInterface.o: $(SRCROOT)/gap4/notes.h
+edInterface.o: $(SRCROOT)/gap4/primlib.h
+edInterface.o: $(SRCROOT)/gap4/qual.h
+edInterface.o: $(SRCROOT)/gap4/qualIO.h
+edInterface.o: $(SRCROOT)/gap4/ruler_display.h
+edInterface.o: $(SRCROOT)/gap4/tagDefs.h
+edInterface.o: $(SRCROOT)/gap4/tagUtils.h
+edInterface.o: $(SRCROOT)/gap4/tagdb.h
+edInterface.o: $(SRCROOT)/gap4/template.h
+edInterface.o: $(SRCROOT)/gap4/template_display.h
+edInterface.o: $(SRCROOT)/gap4/tkEdNames.h
+edInterface.o: $(SRCROOT)/gap4/tkEditor.h
+edInterface.o: $(SRCROOT)/gap4/tman_display.h
+edInterface.o: $(SRCROOT)/gap4/tman_interface.h
+edInterface.o: $(SRCROOT)/gap4/undo.h
+edInterface.o: $(SRCROOT)/primer3/src/dpal.h
+edInterface.o: $(SRCROOT)/primer3/src/primer3.h
+edInterface.o: $(SRCROOT)/tk_utils/canvas_box.h
+edInterface.o: $(SRCROOT)/tk_utils/cli_arg.h
+edInterface.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+edInterface.o: $(SRCROOT)/tk_utils/postscript.h
+edInterface.o: $(SRCROOT)/tk_utils/sheet.h
+edInterface.o: $(SRCROOT)/tk_utils/tcl_utils.h
+edInterface.o: $(SRCROOT)/tk_utils/tkSheet.h
+edInterface.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+edInterface.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+edInterface.o: $(SRCROOT)/tk_utils/tkTrace.h
 edMutations.o: $(PWD)/staden_config.h
+edMutations.o: $(SRCROOT)/Misc/array.h
+edMutations.o: $(SRCROOT)/Misc/bitmap.h
+edMutations.o: $(SRCROOT)/Misc/dstring.h
+edMutations.o: $(SRCROOT)/Misc/misc.h
+edMutations.o: $(SRCROOT)/Misc/os.h
+edMutations.o: $(SRCROOT)/Misc/xalloc.h
+edMutations.o: $(SRCROOT)/Misc/xerror.h
+edMutations.o: $(SRCROOT)/g/freetree.h
+edMutations.o: $(SRCROOT)/g/g-defs.h
+edMutations.o: $(SRCROOT)/g/g-error.h
+edMutations.o: $(SRCROOT)/g/g-filedefs.h
+edMutations.o: $(SRCROOT)/g/g-os.h
+edMutations.o: $(SRCROOT)/g/g-struct.h
+edMutations.o: $(SRCROOT)/gap4/IO1.h
+edMutations.o: $(SRCROOT)/gap4/edStructs.h
+edMutations.o: $(SRCROOT)/gap4/edUtils.h
+edMutations.o: $(SRCROOT)/gap4/fort.h
+edMutations.o: $(SRCROOT)/gap4/fortran.h
+edMutations.o: $(SRCROOT)/gap4/gap-dbstruct.h
+edMutations.o: $(SRCROOT)/gap4/gap-if.h
+edMutations.o: $(SRCROOT)/gap4/io-reg.h
+edMutations.o: $(SRCROOT)/gap4/io_handle.h
+edMutations.o: $(SRCROOT)/gap4/io_utils.h
+edMutations.o: $(SRCROOT)/gap4/list.h
+edMutations.o: $(SRCROOT)/gap4/parse_ft.h
+edMutations.o: $(SRCROOT)/gap4/primlib.h
+edMutations.o: $(SRCROOT)/gap4/qual.h
+edMutations.o: $(SRCROOT)/gap4/tagDefs.h
+edMutations.o: $(SRCROOT)/gap4/tagUtils.h
+edMutations.o: $(SRCROOT)/gap4/template.h
+edMutations.o: $(SRCROOT)/gap4/tkEdNames.h
+edMutations.o: $(SRCROOT)/gap4/tkEditor.h
+edMutations.o: $(SRCROOT)/gap4/tman_display.h
+edMutations.o: $(SRCROOT)/gap4/tman_interface.h
+edMutations.o: $(SRCROOT)/gap4/undo.h
+edMutations.o: $(SRCROOT)/primer3/src/dpal.h
+edMutations.o: $(SRCROOT)/primer3/src/primer3.h
+edMutations.o: $(SRCROOT)/seq_utils/dna_utils.h
+edMutations.o: $(SRCROOT)/seq_utils/genetic_code.h
+edMutations.o: $(SRCROOT)/tk_utils/cli_arg.h
+edMutations.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+edMutations.o: $(SRCROOT)/tk_utils/postscript.h
+edMutations.o: $(SRCROOT)/tk_utils/sheet.h
+edMutations.o: $(SRCROOT)/tk_utils/tkSheet.h
+edMutations.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+edMutations.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+edMutations.o: $(SRCROOT)/tk_utils/tkTrace.h
 edUtils2.o: $(PWD)/staden_config.h
+edUtils2.o: $(SRCROOT)/Misc/array.h
+edUtils2.o: $(SRCROOT)/Misc/bitmap.h
+edUtils2.o: $(SRCROOT)/Misc/dstring.h
+edUtils2.o: $(SRCROOT)/Misc/locks.h
+edUtils2.o: $(SRCROOT)/Misc/misc.h
+edUtils2.o: $(SRCROOT)/Misc/os.h
+edUtils2.o: $(SRCROOT)/Misc/xalloc.h
+edUtils2.o: $(SRCROOT)/Misc/xerror.h
+edUtils2.o: $(SRCROOT)/g/freetree.h
+edUtils2.o: $(SRCROOT)/g/g-defs.h
+edUtils2.o: $(SRCROOT)/g/g-error.h
+edUtils2.o: $(SRCROOT)/g/g-filedefs.h
+edUtils2.o: $(SRCROOT)/g/g-os.h
+edUtils2.o: $(SRCROOT)/g/g-struct.h
+edUtils2.o: $(SRCROOT)/gap4/IO1.h
+edUtils2.o: $(SRCROOT)/gap4/IO2.h
+edUtils2.o: $(SRCROOT)/gap4/active_tags.h
+edUtils2.o: $(SRCROOT)/gap4/contigEditor.h
+edUtils2.o: $(SRCROOT)/gap4/edStructs.h
+edUtils2.o: $(SRCROOT)/gap4/edUtils.h
+edUtils2.o: $(SRCROOT)/gap4/extend.h
+edUtils2.o: $(SRCROOT)/gap4/fort.h
+edUtils2.o: $(SRCROOT)/gap4/fortran.h
+edUtils2.o: $(SRCROOT)/gap4/gap-dbstruct.h
+edUtils2.o: $(SRCROOT)/gap4/gap-if.h
+edUtils2.o: $(SRCROOT)/gap4/gap_globals.h
+edUtils2.o: $(SRCROOT)/gap4/io-reg.h
+edUtils2.o: $(SRCROOT)/gap4/io_handle.h
+edUtils2.o: $(SRCROOT)/gap4/io_utils.h
+edUtils2.o: $(SRCROOT)/gap4/list.h
+edUtils2.o: $(SRCROOT)/gap4/notes.h
+edUtils2.o: $(SRCROOT)/gap4/primlib.h
+edUtils2.o: $(SRCROOT)/gap4/qual.h
+edUtils2.o: $(SRCROOT)/gap4/select.h
+edUtils2.o: $(SRCROOT)/gap4/tagDefs.h
+edUtils2.o: $(SRCROOT)/gap4/tagUtils.h
+edUtils2.o: $(SRCROOT)/gap4/tagdb.h
+edUtils2.o: $(SRCROOT)/gap4/template.h
+edUtils2.o: $(SRCROOT)/gap4/tkEdNames.h
+edUtils2.o: $(SRCROOT)/gap4/tkEditor.h
+edUtils2.o: $(SRCROOT)/gap4/tman_display.h
+edUtils2.o: $(SRCROOT)/gap4/tman_interface.h
+edUtils2.o: $(SRCROOT)/gap4/undo.h
+edUtils2.o: $(SRCROOT)/primer3/src/dpal.h
+edUtils2.o: $(SRCROOT)/primer3/src/primer3.h
+edUtils2.o: $(SRCROOT)/tk_utils/cli_arg.h
+edUtils2.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+edUtils2.o: $(SRCROOT)/tk_utils/postscript.h
+edUtils2.o: $(SRCROOT)/tk_utils/sheet.h
+edUtils2.o: $(SRCROOT)/tk_utils/tcl_utils.h
+edUtils2.o: $(SRCROOT)/tk_utils/tkSheet.h
+edUtils2.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+edUtils2.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+edUtils2.o: $(SRCROOT)/tk_utils/tkTrace.h
 extract.o: $(PWD)/staden_config.h
+extract.o: $(SRCROOT)/Misc/FtoC.h
+extract.o: $(SRCROOT)/Misc/array.h
+extract.o: $(SRCROOT)/Misc/bitmap.h
+extract.o: $(SRCROOT)/Misc/dstring.h
+extract.o: $(SRCROOT)/Misc/misc.h
+extract.o: $(SRCROOT)/Misc/os.h
+extract.o: $(SRCROOT)/Misc/xalloc.h
+extract.o: $(SRCROOT)/Misc/xerror.h
+extract.o: $(SRCROOT)/g/freetree.h
+extract.o: $(SRCROOT)/g/g-defs.h
+extract.o: $(SRCROOT)/g/g-error.h
+extract.o: $(SRCROOT)/g/g-filedefs.h
+extract.o: $(SRCROOT)/g/g-os.h
+extract.o: $(SRCROOT)/g/g-struct.h
+extract.o: $(SRCROOT)/gap4/IO1.h
+extract.o: $(SRCROOT)/gap4/edStructs.h
+extract.o: $(SRCROOT)/gap4/edUtils.h
+extract.o: $(SRCROOT)/gap4/extract.h
+extract.o: $(SRCROOT)/gap4/fort.h
+extract.o: $(SRCROOT)/gap4/fortran.h
+extract.o: $(SRCROOT)/gap4/gap-dbstruct.h
+extract.o: $(SRCROOT)/gap4/gap-if.h
+extract.o: $(SRCROOT)/gap4/io-reg.h
+extract.o: $(SRCROOT)/gap4/io_handle.h
+extract.o: $(SRCROOT)/gap4/io_utils.h
+extract.o: $(SRCROOT)/gap4/list.h
+extract.o: $(SRCROOT)/gap4/notes.h
+extract.o: $(SRCROOT)/gap4/primlib.h
+extract.o: $(SRCROOT)/gap4/qual.h
+extract.o: $(SRCROOT)/gap4/tagDefs.h
+extract.o: $(SRCROOT)/gap4/tagUtils.h
+extract.o: $(SRCROOT)/gap4/template.h
+extract.o: $(SRCROOT)/gap4/tkEdNames.h
+extract.o: $(SRCROOT)/gap4/tkEditor.h
+extract.o: $(SRCROOT)/gap4/tman_display.h
+extract.o: $(SRCROOT)/gap4/undo.h
+extract.o: $(SRCROOT)/primer3/src/dpal.h
+extract.o: $(SRCROOT)/primer3/src/primer3.h
+extract.o: $(SRCROOT)/tk_utils/cli_arg.h
+extract.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+extract.o: $(SRCROOT)/tk_utils/postscript.h
+extract.o: $(SRCROOT)/tk_utils/sheet.h
+extract.o: $(SRCROOT)/tk_utils/text_output.h
+extract.o: $(SRCROOT)/tk_utils/tkSheet.h
+extract.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+extract.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+extract.o: $(SRCROOT)/tk_utils/tkTrace.h
 f2c.o: $(PWD)/staden_config.h
+f2c.o: $(SRCROOT)/Misc/misc.h
+f2c.o: $(SRCROOT)/Misc/os.h
+f2c.o: $(SRCROOT)/Misc/xalloc.h
+f2c.o: $(SRCROOT)/gap4/f2c.h
 fij.o: $(PWD)/staden_config.h
+fij.o: $(SRCROOT)/Misc/array.h
+fij.o: $(SRCROOT)/Misc/bitmap.h
+fij.o: $(SRCROOT)/Misc/dstring.h
+fij.o: $(SRCROOT)/Misc/misc.h
+fij.o: $(SRCROOT)/Misc/os.h
+fij.o: $(SRCROOT)/Misc/xalloc.h
+fij.o: $(SRCROOT)/Misc/xerror.h
+fij.o: $(SRCROOT)/g/freetree.h
+fij.o: $(SRCROOT)/g/g-defs.h
+fij.o: $(SRCROOT)/g/g-error.h
+fij.o: $(SRCROOT)/g/g-filedefs.h
+fij.o: $(SRCROOT)/g/g-os.h
+fij.o: $(SRCROOT)/g/g-struct.h
+fij.o: $(SRCROOT)/gap4/IO1.h
+fij.o: $(SRCROOT)/gap4/complement.h
+fij.o: $(SRCROOT)/gap4/consen.h
+fij.o: $(SRCROOT)/gap4/contigEditor.h
+fij.o: $(SRCROOT)/gap4/contig_selector.h
+fij.o: $(SRCROOT)/gap4/cs-object.h
+fij.o: $(SRCROOT)/gap4/edStructs.h
+fij.o: $(SRCROOT)/gap4/edUtils.h
+fij.o: $(SRCROOT)/gap4/fij.h
+fij.o: $(SRCROOT)/gap4/fort.h
+fij.o: $(SRCROOT)/gap4/fortran.h
+fij.o: $(SRCROOT)/gap4/gap-dbstruct.h
+fij.o: $(SRCROOT)/gap4/gap-if.h
+fij.o: $(SRCROOT)/gap4/gap_globals.h
+fij.o: $(SRCROOT)/gap4/hash_lib.h
+fij.o: $(SRCROOT)/gap4/io-reg.h
+fij.o: $(SRCROOT)/gap4/io_handle.h
+fij.o: $(SRCROOT)/gap4/io_utils.h
+fij.o: $(SRCROOT)/gap4/list.h
+fij.o: $(SRCROOT)/gap4/newgap_cmds.h
+fij.o: $(SRCROOT)/gap4/primlib.h
+fij.o: $(SRCROOT)/gap4/qual.h
+fij.o: $(SRCROOT)/gap4/tagDefs.h
+fij.o: $(SRCROOT)/gap4/tagUtils.h
+fij.o: $(SRCROOT)/gap4/template.h
+fij.o: $(SRCROOT)/gap4/tkEdNames.h
+fij.o: $(SRCROOT)/gap4/tkEditor.h
+fij.o: $(SRCROOT)/gap4/tman_display.h
+fij.o: $(SRCROOT)/gap4/undo.h
+fij.o: $(SRCROOT)/primer3/src/dpal.h
+fij.o: $(SRCROOT)/primer3/src/primer3.h
+fij.o: $(SRCROOT)/seq_utils/align_lib.h
+fij.o: $(SRCROOT)/tk_utils/canvas_box.h
+fij.o: $(SRCROOT)/tk_utils/cli_arg.h
+fij.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+fij.o: $(SRCROOT)/tk_utils/postscript.h
+fij.o: $(SRCROOT)/tk_utils/sheet.h
+fij.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+fij.o: $(SRCROOT)/tk_utils/tcl_utils.h
+fij.o: $(SRCROOT)/tk_utils/text_output.h
+fij.o: $(SRCROOT)/tk_utils/tkSheet.h
+fij.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+fij.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+fij.o: $(SRCROOT)/tk_utils/tkTrace.h
 find_fragments.o: $(PWD)/staden_config.h
+find_fragments.o: $(SRCROOT)/Misc/array.h
+find_fragments.o: $(SRCROOT)/Misc/bitmap.h
+find_fragments.o: $(SRCROOT)/Misc/misc.h
+find_fragments.o: $(SRCROOT)/Misc/os.h
+find_fragments.o: $(SRCROOT)/Misc/xalloc.h
+find_fragments.o: $(SRCROOT)/Misc/xerror.h
+find_fragments.o: $(SRCROOT)/g/freetree.h
+find_fragments.o: $(SRCROOT)/g/g-defs.h
+find_fragments.o: $(SRCROOT)/g/g-error.h
+find_fragments.o: $(SRCROOT)/g/g-filedefs.h
+find_fragments.o: $(SRCROOT)/g/g-os.h
+find_fragments.o: $(SRCROOT)/g/g-struct.h
+find_fragments.o: $(SRCROOT)/gap4/IO1.h
+find_fragments.o: $(SRCROOT)/gap4/find_fragments.h
+find_fragments.o: $(SRCROOT)/gap4/gap-dbstruct.h
+find_fragments.o: $(SRCROOT)/gap4/gap-if.h
+find_fragments.o: $(SRCROOT)/gap4/io_handle.h
+find_fragments.o: $(SRCROOT)/gap4/io_utils.h
+find_fragments.o: $(SRCROOT)/gap4/qual.h
 find_oligo.o: $(PWD)/staden_config.h
+find_oligo.o: $(SRCROOT)/Misc/array.h
+find_oligo.o: $(SRCROOT)/Misc/bitmap.h
+find_oligo.o: $(SRCROOT)/Misc/dstring.h
+find_oligo.o: $(SRCROOT)/Misc/misc.h
+find_oligo.o: $(SRCROOT)/Misc/os.h
+find_oligo.o: $(SRCROOT)/Misc/xalloc.h
+find_oligo.o: $(SRCROOT)/Misc/xerror.h
+find_oligo.o: $(SRCROOT)/g/freetree.h
+find_oligo.o: $(SRCROOT)/g/g-defs.h
+find_oligo.o: $(SRCROOT)/g/g-error.h
+find_oligo.o: $(SRCROOT)/g/g-filedefs.h
+find_oligo.o: $(SRCROOT)/g/g-os.h
+find_oligo.o: $(SRCROOT)/g/g-struct.h
+find_oligo.o: $(SRCROOT)/gap4/IO1.h
+find_oligo.o: $(SRCROOT)/gap4/complement.h
+find_oligo.o: $(SRCROOT)/gap4/contigEditor.h
+find_oligo.o: $(SRCROOT)/gap4/contig_selector.h
+find_oligo.o: $(SRCROOT)/gap4/cs-object.h
+find_oligo.o: $(SRCROOT)/gap4/edStructs.h
+find_oligo.o: $(SRCROOT)/gap4/edUtils.h
+find_oligo.o: $(SRCROOT)/gap4/fort.h
+find_oligo.o: $(SRCROOT)/gap4/fortran.h
+find_oligo.o: $(SRCROOT)/gap4/gap-dbstruct.h
+find_oligo.o: $(SRCROOT)/gap4/gap-if.h
+find_oligo.o: $(SRCROOT)/gap4/gap_globals.h
+find_oligo.o: $(SRCROOT)/gap4/hash.h
+find_oligo.o: $(SRCROOT)/gap4/io-reg.h
+find_oligo.o: $(SRCROOT)/gap4/io_handle.h
+find_oligo.o: $(SRCROOT)/gap4/io_utils.h
+find_oligo.o: $(SRCROOT)/gap4/list.h
+find_oligo.o: $(SRCROOT)/gap4/primlib.h
+find_oligo.o: $(SRCROOT)/gap4/qual.h
+find_oligo.o: $(SRCROOT)/gap4/ruler_display.h
+find_oligo.o: $(SRCROOT)/gap4/tagDefs.h
+find_oligo.o: $(SRCROOT)/gap4/tagUtils.h
+find_oligo.o: $(SRCROOT)/gap4/tagdb.h
+find_oligo.o: $(SRCROOT)/gap4/template.h
+find_oligo.o: $(SRCROOT)/gap4/template_display.h
+find_oligo.o: $(SRCROOT)/gap4/tkEdNames.h
+find_oligo.o: $(SRCROOT)/gap4/tkEditor.h
+find_oligo.o: $(SRCROOT)/gap4/tman_display.h
+find_oligo.o: $(SRCROOT)/gap4/undo.h
+find_oligo.o: $(SRCROOT)/primer3/src/dpal.h
+find_oligo.o: $(SRCROOT)/primer3/src/primer3.h
+find_oligo.o: $(SRCROOT)/seq_utils/dna_utils.h
+find_oligo.o: $(SRCROOT)/seq_utils/search_utils.h
+find_oligo.o: $(SRCROOT)/seq_utils/sequence_formats.h
+find_oligo.o: $(SRCROOT)/tk_utils/canvas_box.h
+find_oligo.o: $(SRCROOT)/tk_utils/cli_arg.h
+find_oligo.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+find_oligo.o: $(SRCROOT)/tk_utils/postscript.h
+find_oligo.o: $(SRCROOT)/tk_utils/sheet.h
+find_oligo.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+find_oligo.o: $(SRCROOT)/tk_utils/tcl_utils.h
+find_oligo.o: $(SRCROOT)/tk_utils/text_output.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkSheet.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkTrace.h
 find_repeats.o: $(PWD)/staden_config.h
+find_repeats.o: $(SRCROOT)/Misc/array.h
+find_repeats.o: $(SRCROOT)/Misc/bitmap.h
+find_repeats.o: $(SRCROOT)/Misc/dstring.h
+find_repeats.o: $(SRCROOT)/Misc/misc.h
+find_repeats.o: $(SRCROOT)/Misc/os.h
+find_repeats.o: $(SRCROOT)/Misc/xalloc.h
+find_repeats.o: $(SRCROOT)/Misc/xerror.h
+find_repeats.o: $(SRCROOT)/g/freetree.h
+find_repeats.o: $(SRCROOT)/g/g-defs.h
+find_repeats.o: $(SRCROOT)/g/g-error.h
+find_repeats.o: $(SRCROOT)/g/g-filedefs.h
+find_repeats.o: $(SRCROOT)/g/g-os.h
+find_repeats.o: $(SRCROOT)/g/g-struct.h
+find_repeats.o: $(SRCROOT)/gap4/IO1.h
+find_repeats.o: $(SRCROOT)/gap4/complement.h
+find_repeats.o: $(SRCROOT)/gap4/consen.h
+find_repeats.o: $(SRCROOT)/gap4/contigEditor.h
+find_repeats.o: $(SRCROOT)/gap4/contig_selector.h
+find_repeats.o: $(SRCROOT)/gap4/cs-object.h
+find_repeats.o: $(SRCROOT)/gap4/edStructs.h
+find_repeats.o: $(SRCROOT)/gap4/edUtils.h
+find_repeats.o: $(SRCROOT)/gap4/find_repeats.h
+find_repeats.o: $(SRCROOT)/gap4/fort.h
+find_repeats.o: $(SRCROOT)/gap4/fortran.h
+find_repeats.o: $(SRCROOT)/gap4/gap-dbstruct.h
+find_repeats.o: $(SRCROOT)/gap4/gap-if.h
+find_repeats.o: $(SRCROOT)/gap4/gap_globals.h
+find_repeats.o: $(SRCROOT)/gap4/gap_hash.h
+find_repeats.o: $(SRCROOT)/gap4/io-reg.h
+find_repeats.o: $(SRCROOT)/gap4/io_handle.h
+find_repeats.o: $(SRCROOT)/gap4/io_utils.h
+find_repeats.o: $(SRCROOT)/gap4/list.h
+find_repeats.o: $(SRCROOT)/gap4/primlib.h
+find_repeats.o: $(SRCROOT)/gap4/qual.h
+find_repeats.o: $(SRCROOT)/gap4/tagDefs.h
+find_repeats.o: $(SRCROOT)/gap4/tagUtils.h
+find_repeats.o: $(SRCROOT)/gap4/template.h
+find_repeats.o: $(SRCROOT)/gap4/tkEdNames.h
+find_repeats.o: $(SRCROOT)/gap4/tkEditor.h
+find_repeats.o: $(SRCROOT)/gap4/tman_display.h
+find_repeats.o: $(SRCROOT)/gap4/undo.h
+find_repeats.o: $(SRCROOT)/primer3/src/dpal.h
+find_repeats.o: $(SRCROOT)/primer3/src/primer3.h
+find_repeats.o: $(SRCROOT)/tk_utils/canvas_box.h
+find_repeats.o: $(SRCROOT)/tk_utils/cli_arg.h
+find_repeats.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+find_repeats.o: $(SRCROOT)/tk_utils/postscript.h
+find_repeats.o: $(SRCROOT)/tk_utils/sheet.h
+find_repeats.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+find_repeats.o: $(SRCROOT)/tk_utils/tcl_utils.h
+find_repeats.o: $(SRCROOT)/tk_utils/text_output.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkSheet.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkTrace.h
 gap-create.o: $(PWD)/staden_config.h
+gap-create.o: $(SRCROOT)/Misc/FtoC.h
+gap-create.o: $(SRCROOT)/Misc/array.h
+gap-create.o: $(SRCROOT)/Misc/bitmap.h
+gap-create.o: $(SRCROOT)/Misc/misc.h
+gap-create.o: $(SRCROOT)/Misc/os.h
+gap-create.o: $(SRCROOT)/Misc/xalloc.h
+gap-create.o: $(SRCROOT)/Misc/xerror.h
+gap-create.o: $(SRCROOT)/g/freetree.h
+gap-create.o: $(SRCROOT)/g/g-defs.h
+gap-create.o: $(SRCROOT)/g/g-error.h
+gap-create.o: $(SRCROOT)/g/g-filedefs.h
+gap-create.o: $(SRCROOT)/g/g-io.h
+gap-create.o: $(SRCROOT)/g/g-misc.h
+gap-create.o: $(SRCROOT)/g/g-os.h
+gap-create.o: $(SRCROOT)/g/g-struct.h
+gap-create.o: $(SRCROOT)/gap4/gap-create.h
+gap-create.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap-create.o: $(SRCROOT)/gap4/gap-defaults.h
+gap-create.o: $(SRCROOT)/gap4/gap-error.h
+gap-create.o: $(SRCROOT)/gap4/gap-if.h
+gap-create.o: $(SRCROOT)/gap4/gap-init.h
+gap-create.o: $(SRCROOT)/gap4/gap-io.h
 gap-dbstruct.o: $(PWD)/staden_config.h
+gap-dbstruct.o: $(SRCROOT)/Misc/os.h
+gap-dbstruct.o: $(SRCROOT)/Misc/xerror.h
+gap-dbstruct.o: $(SRCROOT)/g/g-error.h
+gap-dbstruct.o: $(SRCROOT)/g/g-os.h
+gap-dbstruct.o: $(SRCROOT)/gap4/gap-dbstruct.h
 gap-error.o: $(PWD)/staden_config.h
+gap-error.o: $(SRCROOT)/Misc/array.h
+gap-error.o: $(SRCROOT)/Misc/bitmap.h
+gap-error.o: $(SRCROOT)/Misc/misc.h
+gap-error.o: $(SRCROOT)/Misc/os.h
+gap-error.o: $(SRCROOT)/Misc/xalloc.h
+gap-error.o: $(SRCROOT)/Misc/xerror.h
+gap-error.o: $(SRCROOT)/g/g-error.h
+gap-error.o: $(SRCROOT)/gap4/gap-error.h
+gap-error.o: $(SRCROOT)/gap4/stack_dump.h
 gap-if.o: $(PWD)/staden_config.h
+gap-if.o: $(SRCROOT)/Misc/array.h
+gap-if.o: $(SRCROOT)/Misc/os.h
+gap-if.o: $(SRCROOT)/Misc/xerror.h
+gap-if.o: $(SRCROOT)/g/freetree.h
+gap-if.o: $(SRCROOT)/g/g-error.h
+gap-if.o: $(SRCROOT)/g/g-filedefs.h
+gap-if.o: $(SRCROOT)/g/g-os.h
+gap-if.o: $(SRCROOT)/g/g-struct.h
+gap-if.o: $(SRCROOT)/gap4/gap-if.h
+gap-if.o: $(SRCROOT)/gap4/gap-init.h
+gap-if.o: $(SRCROOT)/gap4/gap-local.h
+gap-if.o: $(SRCROOT)/gap4/gap-remote.h
 gap-init.o: $(PWD)/staden_config.h
+gap-init.o: $(SRCROOT)/Misc/array.h
+gap-init.o: $(SRCROOT)/Misc/os.h
+gap-init.o: $(SRCROOT)/Misc/xerror.h
+gap-init.o: $(SRCROOT)/g/freetree.h
+gap-init.o: $(SRCROOT)/g/g-error.h
+gap-init.o: $(SRCROOT)/g/g-filedefs.h
+gap-init.o: $(SRCROOT)/g/g-os.h
+gap-init.o: $(SRCROOT)/g/g-struct.h
+gap-init.o: $(SRCROOT)/gap4/gap-if.h
+gap-init.o: $(SRCROOT)/gap4/gap-init.h
+gap-init.o: $(SRCROOT)/gap4/gap-io.h
 gap-io.o: $(PWD)/staden_config.h
+gap-io.o: $(SRCROOT)/Misc/array.h
+gap-io.o: $(SRCROOT)/Misc/misc.h
+gap-io.o: $(SRCROOT)/Misc/os.h
+gap-io.o: $(SRCROOT)/Misc/xalloc.h
+gap-io.o: $(SRCROOT)/Misc/xerror.h
+gap-io.o: $(SRCROOT)/g/freetree.h
+gap-io.o: $(SRCROOT)/g/g-error.h
+gap-io.o: $(SRCROOT)/g/g-filedefs.h
+gap-io.o: $(SRCROOT)/g/g-os.h
+gap-io.o: $(SRCROOT)/g/g-struct.h
+gap-io.o: $(SRCROOT)/gap4/gap-error.h
+gap-io.o: $(SRCROOT)/gap4/gap-if.h
 gap-local.o: $(PWD)/staden_config.h
+gap-local.o: $(SRCROOT)/Misc/array.h
+gap-local.o: $(SRCROOT)/Misc/os.h
+gap-local.o: $(SRCROOT)/Misc/xalloc.h
+gap-local.o: $(SRCROOT)/Misc/xerror.h
+gap-local.o: $(SRCROOT)/g/freetree.h
+gap-local.o: $(SRCROOT)/g/g-connect.h
+gap-local.o: $(SRCROOT)/g/g-db.h
+gap-local.o: $(SRCROOT)/g/g-error.h
+gap-local.o: $(SRCROOT)/g/g-filedefs.h
+gap-local.o: $(SRCROOT)/g/g-os.h
+gap-local.o: $(SRCROOT)/g/g-request.h
+gap-local.o: $(SRCROOT)/g/g-struct.h
+gap-local.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap-local.o: $(SRCROOT)/gap4/gap-if.h
+gap-local.o: $(SRCROOT)/gap4/gap-local.h
 gap-remote.o: $(PWD)/staden_config.h
+gap-remote.o: $(SRCROOT)/Misc/array.h
+gap-remote.o: $(SRCROOT)/Misc/os.h
+gap-remote.o: $(SRCROOT)/Misc/xerror.h
+gap-remote.o: $(SRCROOT)/g/freetree.h
+gap-remote.o: $(SRCROOT)/g/g-connect.h
+gap-remote.o: $(SRCROOT)/g/g-db.h
+gap-remote.o: $(SRCROOT)/g/g-error.h
+gap-remote.o: $(SRCROOT)/g/g-filedefs.h
+gap-remote.o: $(SRCROOT)/g/g-os.h
+gap-remote.o: $(SRCROOT)/g/g-request.h
+gap-remote.o: $(SRCROOT)/g/g-struct.h
+gap-remote.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap-remote.o: $(SRCROOT)/gap4/gap-if.h
+gap-remote.o: $(SRCROOT)/gap4/gap-remote.h
 gap-tcl.o: $(PWD)/staden_config.h
+gap-tcl.o: $(SRCROOT)/Misc/array.h
+gap-tcl.o: $(SRCROOT)/Misc/bitmap.h
+gap-tcl.o: $(SRCROOT)/Misc/dstring.h
+gap-tcl.o: $(SRCROOT)/Misc/misc.h
+gap-tcl.o: $(SRCROOT)/Misc/os.h
+gap-tcl.o: $(SRCROOT)/Misc/xalloc.h
+gap-tcl.o: $(SRCROOT)/Misc/xerror.h
+gap-tcl.o: $(SRCROOT)/g/freetree.h
+gap-tcl.o: $(SRCROOT)/g/g-defs.h
+gap-tcl.o: $(SRCROOT)/g/g-error.h
+gap-tcl.o: $(SRCROOT)/g/g-filedefs.h
+gap-tcl.o: $(SRCROOT)/g/g-os.h
+gap-tcl.o: $(SRCROOT)/g/g-struct.h
+gap-tcl.o: $(SRCROOT)/gap4/IO1.h
+gap-tcl.o: $(SRCROOT)/gap4/clones.h
+gap-tcl.o: $(SRCROOT)/gap4/edStructs.h
+gap-tcl.o: $(SRCROOT)/gap4/edUtils.h
+gap-tcl.o: $(SRCROOT)/gap4/fort.h
+gap-tcl.o: $(SRCROOT)/gap4/fortran.h
+gap-tcl.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap-tcl.o: $(SRCROOT)/gap4/gap-error.h
+gap-tcl.o: $(SRCROOT)/gap4/gap-if.h
+gap-tcl.o: $(SRCROOT)/gap4/gap-tcl.h
+gap-tcl.o: $(SRCROOT)/gap4/gap_globals.h
+gap-tcl.o: $(SRCROOT)/gap4/io-reg.h
+gap-tcl.o: $(SRCROOT)/gap4/io_handle.h
+gap-tcl.o: $(SRCROOT)/gap4/io_utils.h
+gap-tcl.o: $(SRCROOT)/gap4/list.h
+gap-tcl.o: $(SRCROOT)/gap4/primlib.h
+gap-tcl.o: $(SRCROOT)/gap4/qual.h
+gap-tcl.o: $(SRCROOT)/gap4/seqInfo.h
+gap-tcl.o: $(SRCROOT)/gap4/tagDefs.h
+gap-tcl.o: $(SRCROOT)/gap4/tagUtils.h
+gap-tcl.o: $(SRCROOT)/gap4/template.h
+gap-tcl.o: $(SRCROOT)/gap4/tkEdNames.h
+gap-tcl.o: $(SRCROOT)/gap4/tkEditor.h
+gap-tcl.o: $(SRCROOT)/gap4/tman_display.h
+gap-tcl.o: $(SRCROOT)/gap4/undo.h
+gap-tcl.o: $(SRCROOT)/primer3/src/dpal.h
+gap-tcl.o: $(SRCROOT)/primer3/src/primer3.h
+gap-tcl.o: $(SRCROOT)/tk_utils/cli_arg.h
+gap-tcl.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+gap-tcl.o: $(SRCROOT)/tk_utils/postscript.h
+gap-tcl.o: $(SRCROOT)/tk_utils/sheet.h
+gap-tcl.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+gap-tcl.o: $(SRCROOT)/tk_utils/tcl_utils.h
+gap-tcl.o: $(SRCROOT)/tk_utils/tkSheet.h
+gap-tcl.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+gap-tcl.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+gap-tcl.o: $(SRCROOT)/tk_utils/tkTrace.h
 gap_array.o: $(PWD)/staden_config.h
+gap_array.o: $(SRCROOT)/Misc/misc.h
+gap_array.o: $(SRCROOT)/Misc/os.h
+gap_array.o: $(SRCROOT)/Misc/xalloc.h
+gap_array.o: $(SRCROOT)/gap4/active_tags.h
+gap_array.o: $(SRCROOT)/gap4/gap_array.h
+gap_array.o: $(SRCROOT)/gap4/tagdb.h
+gap_array.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+gap_array.o: $(SRCROOT)/tk_utils/tcl_utils.h
 gap_canvas_box.o: $(PWD)/staden_config.h
+gap_canvas_box.o: $(SRCROOT)/Misc/array.h
+gap_canvas_box.o: $(SRCROOT)/Misc/bitmap.h
+gap_canvas_box.o: $(SRCROOT)/Misc/misc.h
+gap_canvas_box.o: $(SRCROOT)/Misc/os.h
+gap_canvas_box.o: $(SRCROOT)/Misc/xalloc.h
+gap_canvas_box.o: $(SRCROOT)/Misc/xerror.h
+gap_canvas_box.o: $(SRCROOT)/g/freetree.h
+gap_canvas_box.o: $(SRCROOT)/g/g-defs.h
+gap_canvas_box.o: $(SRCROOT)/g/g-error.h
+gap_canvas_box.o: $(SRCROOT)/g/g-filedefs.h
+gap_canvas_box.o: $(SRCROOT)/g/g-os.h
+gap_canvas_box.o: $(SRCROOT)/g/g-struct.h
+gap_canvas_box.o: $(SRCROOT)/gap4/IO1.h
+gap_canvas_box.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap_canvas_box.o: $(SRCROOT)/gap4/gap-if.h
+gap_canvas_box.o: $(SRCROOT)/gap4/gap_globals.h
+gap_canvas_box.o: $(SRCROOT)/gap4/io-reg.h
+gap_canvas_box.o: $(SRCROOT)/gap4/io_handle.h
+gap_canvas_box.o: $(SRCROOT)/gap4/io_utils.h
+gap_canvas_box.o: $(SRCROOT)/tk_utils/canvas_box.h
+gap_canvas_box.o: $(SRCROOT)/tk_utils/tcl_utils.h
 gap_cli_arg.o: $(PWD)/staden_config.h
+gap_cli_arg.o: $(SRCROOT)/Misc/array.h
+gap_cli_arg.o: $(SRCROOT)/Misc/bitmap.h
+gap_cli_arg.o: $(SRCROOT)/Misc/misc.h
+gap_cli_arg.o: $(SRCROOT)/Misc/os.h
+gap_cli_arg.o: $(SRCROOT)/Misc/xalloc.h
+gap_cli_arg.o: $(SRCROOT)/Misc/xerror.h
+gap_cli_arg.o: $(SRCROOT)/g/freetree.h
+gap_cli_arg.o: $(SRCROOT)/g/g-defs.h
+gap_cli_arg.o: $(SRCROOT)/g/g-error.h
+gap_cli_arg.o: $(SRCROOT)/g/g-filedefs.h
+gap_cli_arg.o: $(SRCROOT)/g/g-os.h
+gap_cli_arg.o: $(SRCROOT)/g/g-struct.h
+gap_cli_arg.o: $(SRCROOT)/gap4/IO1.h
+gap_cli_arg.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap_cli_arg.o: $(SRCROOT)/gap4/gap-if.h
+gap_cli_arg.o: $(SRCROOT)/gap4/gap_cli_arg.h
+gap_cli_arg.o: $(SRCROOT)/gap4/io_handle.h
+gap_cli_arg.o: $(SRCROOT)/gap4/io_utils.h
+gap_cli_arg.o: $(SRCROOT)/tk_utils/cli_arg.h
 gap_globals.o: $(PWD)/staden_config.h
+gap_globals.o: $(SRCROOT)/Misc/array.h
+gap_globals.o: $(SRCROOT)/Misc/bitmap.h
+gap_globals.o: $(SRCROOT)/Misc/misc.h
+gap_globals.o: $(SRCROOT)/Misc/os.h
+gap_globals.o: $(SRCROOT)/Misc/xalloc.h
+gap_globals.o: $(SRCROOT)/Misc/xerror.h
+gap_globals.o: $(SRCROOT)/g/freetree.h
+gap_globals.o: $(SRCROOT)/g/g-defs.h
+gap_globals.o: $(SRCROOT)/g/g-error.h
+gap_globals.o: $(SRCROOT)/g/g-filedefs.h
+gap_globals.o: $(SRCROOT)/g/g-os.h
+gap_globals.o: $(SRCROOT)/g/g-struct.h
+gap_globals.o: $(SRCROOT)/gap4/IO1.h
+gap_globals.o: $(SRCROOT)/gap4/consen.h
+gap_globals.o: $(SRCROOT)/gap4/fort.h
+gap_globals.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap_globals.o: $(SRCROOT)/gap4/gap-if.h
+gap_globals.o: $(SRCROOT)/gap4/gap_globals.h
+gap_globals.o: $(SRCROOT)/gap4/hash_lib.h
+gap_globals.o: $(SRCROOT)/gap4/io_handle.h
+gap_globals.o: $(SRCROOT)/gap4/io_utils.h
+gap_globals.o: $(SRCROOT)/gap4/notedb.h
+gap_globals.o: $(SRCROOT)/seq_utils/align.h
+gap_globals.o: $(SRCROOT)/seq_utils/align_lib.h
+gap_globals.o: $(SRCROOT)/seq_utils/align_lib_old.h
+gap_globals.o: $(SRCROOT)/seq_utils/dna_utils.h
+gap_globals.o: $(SRCROOT)/seq_utils/genetic_code.h
+gap_globals.o: $(SRCROOT)/seq_utils/read_matrix.h
+gap_globals.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+gap_globals.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+gap_globals.o: $(SRCROOT)/tk_utils/tcl_utils.h
 gap_hash.o: $(PWD)/staden_config.h
+gap_hash.o: $(SRCROOT)/Misc/array.h
+gap_hash.o: $(SRCROOT)/Misc/bitmap.h
+gap_hash.o: $(SRCROOT)/Misc/misc.h
+gap_hash.o: $(SRCROOT)/Misc/os.h
+gap_hash.o: $(SRCROOT)/Misc/xalloc.h
+gap_hash.o: $(SRCROOT)/Misc/xerror.h
+gap_hash.o: $(SRCROOT)/g/freetree.h
+gap_hash.o: $(SRCROOT)/g/g-defs.h
+gap_hash.o: $(SRCROOT)/g/g-error.h
+gap_hash.o: $(SRCROOT)/g/g-filedefs.h
+gap_hash.o: $(SRCROOT)/g/g-os.h
+gap_hash.o: $(SRCROOT)/g/g-struct.h
+gap_hash.o: $(SRCROOT)/gap4/IO1.h
+gap_hash.o: $(SRCROOT)/gap4/fort.h
+gap_hash.o: $(SRCROOT)/gap4/gap-dbstruct.h
+gap_hash.o: $(SRCROOT)/gap4/gap-if.h
+gap_hash.o: $(SRCROOT)/gap4/gap_hash.h
+gap_hash.o: $(SRCROOT)/gap4/hash_lib.h
+gap_hash.o: $(SRCROOT)/gap4/io_handle.h
+gap_hash.o: $(SRCROOT)/gap4/io_utils.h
+gap_hash.o: $(SRCROOT)/seq_utils/align_lib.h
+gap_hash.o: $(SRCROOT)/seq_utils/dna_utils.h
+hash.o: $(SRCROOT)/Misc/xalloc.h
+hash.o: $(SRCROOT)/gap4/hash.h
 hash_lib.o: $(PWD)/staden_config.h
+hash_lib.o: $(SRCROOT)/Misc/misc.h
+hash_lib.o: $(SRCROOT)/Misc/os.h
+hash_lib.o: $(SRCROOT)/Misc/xalloc.h
+hash_lib.o: $(SRCROOT)/gap4/hash_lib.h
+hash_lib.o: $(SRCROOT)/seq_utils/align_lib.h
+hash_lib.o: $(SRCROOT)/seq_utils/dna_utils.h
 init.o: $(PWD)/staden_config.h
+init.o: $(SRCROOT)/Misc/array.h
+init.o: $(SRCROOT)/Misc/bitmap.h
+init.o: $(SRCROOT)/Misc/dstring.h
+init.o: $(SRCROOT)/Misc/misc.h
+init.o: $(SRCROOT)/Misc/os.h
+init.o: $(SRCROOT)/Misc/xalloc.h
+init.o: $(SRCROOT)/Misc/xerror.h
+init.o: $(SRCROOT)/g/freetree.h
+init.o: $(SRCROOT)/g/g-defs.h
+init.o: $(SRCROOT)/g/g-error.h
+init.o: $(SRCROOT)/g/g-filedefs.h
+init.o: $(SRCROOT)/g/g-os.h
+init.o: $(SRCROOT)/g/g-struct.h
+init.o: $(SRCROOT)/gap4/IO1.h
+init.o: $(SRCROOT)/gap4/active_tags.h
+init.o: $(SRCROOT)/gap4/contigEditor.h
+init.o: $(SRCROOT)/gap4/edStructs.h
+init.o: $(SRCROOT)/gap4/edUtils.h
+init.o: $(SRCROOT)/gap4/fort.h
+init.o: $(SRCROOT)/gap4/fortran.h
+init.o: $(SRCROOT)/gap4/gap-dbstruct.h
+init.o: $(SRCROOT)/gap4/gap-if.h
+init.o: $(SRCROOT)/gap4/gap-tcl.h
+init.o: $(SRCROOT)/gap4/gap_globals.h
+init.o: $(SRCROOT)/gap4/io-reg.h
+init.o: $(SRCROOT)/gap4/io_handle.h
+init.o: $(SRCROOT)/gap4/io_utils.h
+init.o: $(SRCROOT)/gap4/list.h
+init.o: $(SRCROOT)/gap4/newgap_cmds.h
+init.o: $(SRCROOT)/gap4/primlib.h
+init.o: $(SRCROOT)/gap4/qual.h
+init.o: $(SRCROOT)/gap4/tagDefs.h
+init.o: $(SRCROOT)/gap4/tagUtils.h
+init.o: $(SRCROOT)/gap4/tagdb.h
+init.o: $(SRCROOT)/gap4/template.h
+init.o: $(SRCROOT)/gap4/tkEdNames.h
+init.o: $(SRCROOT)/gap4/tkEditor.h
+init.o: $(SRCROOT)/gap4/tman_display.h
+init.o: $(SRCROOT)/gap4/undo.h
+init.o: $(SRCROOT)/primer3/src/dpal.h
+init.o: $(SRCROOT)/primer3/src/primer3.h
+init.o: $(SRCROOT)/tk_utils/cli_arg.h
+init.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+init.o: $(SRCROOT)/tk_utils/postscript.h
+init.o: $(SRCROOT)/tk_utils/sheet.h
+init.o: $(SRCROOT)/tk_utils/tcl_utils.h
+init.o: $(SRCROOT)/tk_utils/tkSheet.h
+init.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+init.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+init.o: $(SRCROOT)/tk_utils/tkTrace.h
 io-reg.o: $(PWD)/staden_config.h
+io-reg.o: $(SRCROOT)/Misc/array.h
+io-reg.o: $(SRCROOT)/Misc/bitmap.h
+io-reg.o: $(SRCROOT)/Misc/misc.h
+io-reg.o: $(SRCROOT)/Misc/os.h
+io-reg.o: $(SRCROOT)/Misc/xalloc.h
+io-reg.o: $(SRCROOT)/Misc/xerror.h
+io-reg.o: $(SRCROOT)/g/freetree.h
+io-reg.o: $(SRCROOT)/g/g-defs.h
+io-reg.o: $(SRCROOT)/g/g-error.h
+io-reg.o: $(SRCROOT)/g/g-filedefs.h
+io-reg.o: $(SRCROOT)/g/g-os.h
+io-reg.o: $(SRCROOT)/g/g-struct.h
+io-reg.o: $(SRCROOT)/gap4/IO1.h
+io-reg.o: $(SRCROOT)/gap4/gap-dbstruct.h
+io-reg.o: $(SRCROOT)/gap4/gap-if.h
+io-reg.o: $(SRCROOT)/gap4/io-reg.h
+io-reg.o: $(SRCROOT)/gap4/io_handle.h
+io-reg.o: $(SRCROOT)/gap4/io_utils.h
+io-reg.o: $(SRCROOT)/gap4/tk-io-reg.h
+io-reg.o: $(SRCROOT)/tk_utils/text_output.h
 io_handle.o: $(PWD)/staden_config.h
+io_handle.o: $(SRCROOT)/Misc/array.h
+io_handle.o: $(SRCROOT)/Misc/bitmap.h
+io_handle.o: $(SRCROOT)/Misc/dstring.h
+io_handle.o: $(SRCROOT)/Misc/misc.h
+io_handle.o: $(SRCROOT)/Misc/os.h
+io_handle.o: $(SRCROOT)/Misc/xalloc.h
+io_handle.o: $(SRCROOT)/Misc/xerror.h
+io_handle.o: $(SRCROOT)/g/freetree.h
+io_handle.o: $(SRCROOT)/g/g-defs.h
+io_handle.o: $(SRCROOT)/g/g-error.h
+io_handle.o: $(SRCROOT)/g/g-filedefs.h
+io_handle.o: $(SRCROOT)/g/g-os.h
+io_handle.o: $(SRCROOT)/g/g-struct.h
+io_handle.o: $(SRCROOT)/gap4/IO1.h
+io_handle.o: $(SRCROOT)/gap4/edStructs.h
+io_handle.o: $(SRCROOT)/gap4/edUtils.h
+io_handle.o: $(SRCROOT)/gap4/fort.h
+io_handle.o: $(SRCROOT)/gap4/fortran.h
+io_handle.o: $(SRCROOT)/gap4/gap-dbstruct.h
+io_handle.o: $(SRCROOT)/gap4/gap-if.h
+io_handle.o: $(SRCROOT)/gap4/io-reg.h
+io_handle.o: $(SRCROOT)/gap4/io_handle.h
+io_handle.o: $(SRCROOT)/gap4/io_utils.h
+io_handle.o: $(SRCROOT)/gap4/list.h
+io_handle.o: $(SRCROOT)/gap4/primlib.h
+io_handle.o: $(SRCROOT)/gap4/qual.h
+io_handle.o: $(SRCROOT)/gap4/tagDefs.h
+io_handle.o: $(SRCROOT)/gap4/tagUtils.h
+io_handle.o: $(SRCROOT)/gap4/template.h
+io_handle.o: $(SRCROOT)/gap4/tkEdNames.h
+io_handle.o: $(SRCROOT)/gap4/tkEditor.h
+io_handle.o: $(SRCROOT)/gap4/tman_display.h
+io_handle.o: $(SRCROOT)/gap4/undo.h
+io_handle.o: $(SRCROOT)/primer3/src/dpal.h
+io_handle.o: $(SRCROOT)/primer3/src/primer3.h
+io_handle.o: $(SRCROOT)/tk_utils/cli_arg.h
+io_handle.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+io_handle.o: $(SRCROOT)/tk_utils/postscript.h
+io_handle.o: $(SRCROOT)/tk_utils/sheet.h
+io_handle.o: $(SRCROOT)/tk_utils/text_output.h
+io_handle.o: $(SRCROOT)/tk_utils/tkSheet.h
+io_handle.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+io_handle.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+io_handle.o: $(SRCROOT)/tk_utils/tkTrace.h
 io_utils.o: $(PWD)/staden_config.h
+io_utils.o: $(SRCROOT)/Misc/FtoC.h
+io_utils.o: $(SRCROOT)/Misc/array.h
+io_utils.o: $(SRCROOT)/Misc/bitmap.h
+io_utils.o: $(SRCROOT)/Misc/misc.h
+io_utils.o: $(SRCROOT)/Misc/os.h
+io_utils.o: $(SRCROOT)/Misc/xalloc.h
+io_utils.o: $(SRCROOT)/Misc/xerror.h
+io_utils.o: $(SRCROOT)/g/freetree.h
+io_utils.o: $(SRCROOT)/g/g-defs.h
+io_utils.o: $(SRCROOT)/g/g-error.h
+io_utils.o: $(SRCROOT)/g/g-filedefs.h
+io_utils.o: $(SRCROOT)/g/g-os.h
+io_utils.o: $(SRCROOT)/g/g-struct.h
+io_utils.o: $(SRCROOT)/gap4/IO1.h
+io_utils.o: $(SRCROOT)/gap4/gap-dbstruct.h
+io_utils.o: $(SRCROOT)/gap4/gap-if.h
+io_utils.o: $(SRCROOT)/gap4/io_handle.h
+io_utils.o: $(SRCROOT)/gap4/io_utils.h
 join.o: $(PWD)/staden_config.h
+join.o: $(SRCROOT)/Misc/array.h
+join.o: $(SRCROOT)/Misc/bitmap.h
+join.o: $(SRCROOT)/Misc/dstring.h
+join.o: $(SRCROOT)/Misc/misc.h
+join.o: $(SRCROOT)/Misc/os.h
+join.o: $(SRCROOT)/Misc/xalloc.h
+join.o: $(SRCROOT)/Misc/xerror.h
+join.o: $(SRCROOT)/g/freetree.h
+join.o: $(SRCROOT)/g/g-defs.h
+join.o: $(SRCROOT)/g/g-error.h
+join.o: $(SRCROOT)/g/g-filedefs.h
+join.o: $(SRCROOT)/g/g-os.h
+join.o: $(SRCROOT)/g/g-struct.h
+join.o: $(SRCROOT)/gap4/IO1.h
+join.o: $(SRCROOT)/gap4/IO2.h
+join.o: $(SRCROOT)/gap4/contigEditor.h
+join.o: $(SRCROOT)/gap4/edStructs.h
+join.o: $(SRCROOT)/gap4/edUtils.h
+join.o: $(SRCROOT)/gap4/fort.h
+join.o: $(SRCROOT)/gap4/fortran.h
+join.o: $(SRCROOT)/gap4/gap-dbstruct.h
+join.o: $(SRCROOT)/gap4/gap-if.h
+join.o: $(SRCROOT)/gap4/gap_globals.h
+join.o: $(SRCROOT)/gap4/hash_lib.h
+join.o: $(SRCROOT)/gap4/io-reg.h
+join.o: $(SRCROOT)/gap4/io_handle.h
+join.o: $(SRCROOT)/gap4/io_utils.h
+join.o: $(SRCROOT)/gap4/list.h
+join.o: $(SRCROOT)/gap4/notes.h
+join.o: $(SRCROOT)/gap4/primlib.h
+join.o: $(SRCROOT)/gap4/qual.h
+join.o: $(SRCROOT)/gap4/tagDefs.h
+join.o: $(SRCROOT)/gap4/tagUtils.h
+join.o: $(SRCROOT)/gap4/template.h
+join.o: $(SRCROOT)/gap4/tkEdNames.h
+join.o: $(SRCROOT)/gap4/tkEditor.h
+join.o: $(SRCROOT)/gap4/tman_display.h
+join.o: $(SRCROOT)/gap4/undo.h
+join.o: $(SRCROOT)/primer3/src/dpal.h
+join.o: $(SRCROOT)/primer3/src/primer3.h
+join.o: $(SRCROOT)/seq_utils/align.h
+join.o: $(SRCROOT)/seq_utils/align_lib.h
+join.o: $(SRCROOT)/seq_utils/align_lib_old.h
+join.o: $(SRCROOT)/seq_utils/dna_utils.h
+join.o: $(SRCROOT)/tk_utils/cli_arg.h
+join.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+join.o: $(SRCROOT)/tk_utils/postscript.h
+join.o: $(SRCROOT)/tk_utils/sheet.h
+join.o: $(SRCROOT)/tk_utils/tcl_utils.h
+join.o: $(SRCROOT)/tk_utils/tkSheet.h
+join.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+join.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+join.o: $(SRCROOT)/tk_utils/tkTrace.h
+legacy_f2c.o: $(SRCROOT)/gap4/f2c.h
+list.o: $(SRCROOT)/Misc/xalloc.h
+list.o: $(SRCROOT)/gap4/list.h
 list_proc.o: $(PWD)/staden_config.h
+list_proc.o: $(SRCROOT)/Misc/FtoC.h
+list_proc.o: $(SRCROOT)/Misc/array.h
+list_proc.o: $(SRCROOT)/Misc/bitmap.h
+list_proc.o: $(SRCROOT)/Misc/misc.h
+list_proc.o: $(SRCROOT)/Misc/os.h
+list_proc.o: $(SRCROOT)/Misc/xalloc.h
+list_proc.o: $(SRCROOT)/Misc/xerror.h
+list_proc.o: $(SRCROOT)/g/freetree.h
+list_proc.o: $(SRCROOT)/g/g-defs.h
+list_proc.o: $(SRCROOT)/g/g-error.h
+list_proc.o: $(SRCROOT)/g/g-filedefs.h
+list_proc.o: $(SRCROOT)/g/g-os.h
+list_proc.o: $(SRCROOT)/g/g-struct.h
+list_proc.o: $(SRCROOT)/gap4/IO1.h
+list_proc.o: $(SRCROOT)/gap4/gap-dbstruct.h
+list_proc.o: $(SRCROOT)/gap4/gap-if.h
+list_proc.o: $(SRCROOT)/gap4/gap_globals.h
+list_proc.o: $(SRCROOT)/gap4/io_handle.h
+list_proc.o: $(SRCROOT)/gap4/io_utils.h
+list_proc.o: $(SRCROOT)/gap4/list.h
+list_proc.o: $(SRCROOT)/gap4/newgap_cmds.h
+list_proc.o: $(SRCROOT)/tk_utils/tcl_utils.h
 mess.o: $(PWD)/staden_config.h
+mess.o: $(SRCROOT)/Misc/misc.h
+mess.o: $(SRCROOT)/Misc/os.h
+mess.o: $(SRCROOT)/Misc/xalloc.h
+mess.o: $(SRCROOT)/tk_utils/text_output.h
 newgap_cmds.o: $(PWD)/staden_config.h
+newgap_cmds.o: $(SRCROOT)/Misc/array.h
+newgap_cmds.o: $(SRCROOT)/Misc/bitmap.h
+newgap_cmds.o: $(SRCROOT)/Misc/dstring.h
+newgap_cmds.o: $(SRCROOT)/Misc/locks.h
+newgap_cmds.o: $(SRCROOT)/Misc/misc.h
+newgap_cmds.o: $(SRCROOT)/Misc/os.h
+newgap_cmds.o: $(SRCROOT)/Misc/xalloc.h
+newgap_cmds.o: $(SRCROOT)/Misc/xerror.h
+newgap_cmds.o: $(SRCROOT)/g/freetree.h
+newgap_cmds.o: $(SRCROOT)/g/g-defs.h
+newgap_cmds.o: $(SRCROOT)/g/g-error.h
+newgap_cmds.o: $(SRCROOT)/g/g-filedefs.h
+newgap_cmds.o: $(SRCROOT)/g/g-os.h
+newgap_cmds.o: $(SRCROOT)/g/g-struct.h
+newgap_cmds.o: $(SRCROOT)/gap4/IO1.h
+newgap_cmds.o: $(SRCROOT)/gap4/active_tags.h
+newgap_cmds.o: $(SRCROOT)/gap4/alter_rel.h
+newgap_cmds.o: $(SRCROOT)/gap4/assemble_direct.h
+newgap_cmds.o: $(SRCROOT)/gap4/auto_assemble.h
+newgap_cmds.o: $(SRCROOT)/gap4/auto_break.h
+newgap_cmds.o: $(SRCROOT)/gap4/break_contig.h
+newgap_cmds.o: $(SRCROOT)/gap4/check_assembly.h
+newgap_cmds.o: $(SRCROOT)/gap4/clip.h
+newgap_cmds.o: $(SRCROOT)/gap4/complement.h
+newgap_cmds.o: $(SRCROOT)/gap4/confidence_graph.h
+newgap_cmds.o: $(SRCROOT)/gap4/consen.h
+newgap_cmds.o: $(SRCROOT)/gap4/consistency_display.h
+newgap_cmds.o: $(SRCROOT)/gap4/contig_order.h
+newgap_cmds.o: $(SRCROOT)/gap4/contig_selector.h
+newgap_cmds.o: $(SRCROOT)/gap4/copy_db.h
+newgap_cmds.o: $(SRCROOT)/gap4/cs-object.h
+newgap_cmds.o: $(SRCROOT)/gap4/dbcheck.h
+newgap_cmds.o: $(SRCROOT)/gap4/dis_readings.h
+newgap_cmds.o: $(SRCROOT)/gap4/dstrand.h
+newgap_cmds.o: $(SRCROOT)/gap4/edStructs.h
+newgap_cmds.o: $(SRCROOT)/gap4/edUtils.h
+newgap_cmds.o: $(SRCROOT)/gap4/extract.h
+newgap_cmds.o: $(SRCROOT)/gap4/fij.h
+newgap_cmds.o: $(SRCROOT)/gap4/find_oligo.h
+newgap_cmds.o: $(SRCROOT)/gap4/find_repeats.h
+newgap_cmds.o: $(SRCROOT)/gap4/fort.h
+newgap_cmds.o: $(SRCROOT)/gap4/fortran.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap-create.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap-dbstruct.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap-if.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap_array.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap_canvas_box.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap_cli_arg.h
+newgap_cmds.o: $(SRCROOT)/gap4/gap_globals.h
+newgap_cmds.o: $(SRCROOT)/gap4/hash.h
+newgap_cmds.o: $(SRCROOT)/gap4/hash_lib.h
+newgap_cmds.o: $(SRCROOT)/gap4/io-reg.h
+newgap_cmds.o: $(SRCROOT)/gap4/io_handle.h
+newgap_cmds.o: $(SRCROOT)/gap4/io_utils.h
+newgap_cmds.o: $(SRCROOT)/gap4/list.h
+newgap_cmds.o: $(SRCROOT)/gap4/list_proc.h
+newgap_cmds.o: $(SRCROOT)/gap4/newgap_cmds.h
+newgap_cmds.o: $(SRCROOT)/gap4/newgap_structs.h
+newgap_cmds.o: $(SRCROOT)/gap4/notes.h
+newgap_cmds.o: $(SRCROOT)/gap4/oligo_sel.h
+newgap_cmds.o: $(SRCROOT)/gap4/plot_quality.h
+newgap_cmds.o: $(SRCROOT)/gap4/preass.h
+newgap_cmds.o: $(SRCROOT)/gap4/primlib.h
+newgap_cmds.o: $(SRCROOT)/gap4/probe.h
+newgap_cmds.o: $(SRCROOT)/gap4/qual.h
+newgap_cmds.o: $(SRCROOT)/gap4/qualIO.h
+newgap_cmds.o: $(SRCROOT)/gap4/quality_plot.h
+newgap_cmds.o: $(SRCROOT)/gap4/reactions.h
+newgap_cmds.o: $(SRCROOT)/gap4/reading_coverage.h
+newgap_cmds.o: $(SRCROOT)/gap4/readpair.h
+newgap_cmds.o: $(SRCROOT)/gap4/readpair_coverage.h
+newgap_cmds.o: $(SRCROOT)/gap4/restriction_enzymes.h
+newgap_cmds.o: $(SRCROOT)/gap4/ruler_display.h
+newgap_cmds.o: $(SRCROOT)/gap4/seqInfo.h
+newgap_cmds.o: $(SRCROOT)/gap4/show_relationships.h
+newgap_cmds.o: $(SRCROOT)/gap4/shuffle_pads.h
+newgap_cmds.o: $(SRCROOT)/gap4/stop_codon.h
+newgap_cmds.o: $(SRCROOT)/gap4/strand_coverage.h
+newgap_cmds.o: $(SRCROOT)/gap4/tagDefs.h
+newgap_cmds.o: $(SRCROOT)/gap4/tagUtils.h
+newgap_cmds.o: $(SRCROOT)/gap4/tagdb.h
+newgap_cmds.o: $(SRCROOT)/gap4/template.h
+newgap_cmds.o: $(SRCROOT)/gap4/template_display.h
+newgap_cmds.o: $(SRCROOT)/gap4/tk-io-reg.h
+newgap_cmds.o: $(SRCROOT)/gap4/tkEdNames.h
+newgap_cmds.o: $(SRCROOT)/gap4/tkEditor.h
+newgap_cmds.o: $(SRCROOT)/gap4/tman_display.h
+newgap_cmds.o: $(SRCROOT)/gap4/undo.h
+newgap_cmds.o: $(SRCROOT)/primer3/src/dpal.h
+newgap_cmds.o: $(SRCROOT)/primer3/src/primer3.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/align.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/align_lib.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/align_lib_old.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/genetic_code.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/read_matrix.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/renz_utils.h
+newgap_cmds.o: $(SRCROOT)/seq_utils/sequence_formats.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/canvas_box.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/cli_arg.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/postscript.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/sheet.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/tcl_utils.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/text_output.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/tkSheet.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+newgap_cmds.o: $(SRCROOT)/tk_utils/tkTrace.h
 notedb.o: $(PWD)/staden_config.h
+notedb.o: $(SRCROOT)/Misc/misc.h
+notedb.o: $(SRCROOT)/Misc/os.h
+notedb.o: $(SRCROOT)/Misc/parse_db.h
+notedb.o: $(SRCROOT)/Misc/xalloc.h
+notedb.o: $(SRCROOT)/gap4/notedb.h
+notedb.o: $(SRCROOT)/tk_utils/intrinsic_type.h
 notes.o: $(PWD)/staden_config.h
+notes.o: $(SRCROOT)/Misc/array.h
+notes.o: $(SRCROOT)/Misc/bitmap.h
+notes.o: $(SRCROOT)/Misc/dstring.h
+notes.o: $(SRCROOT)/Misc/misc.h
+notes.o: $(SRCROOT)/Misc/os.h
+notes.o: $(SRCROOT)/Misc/xalloc.h
+notes.o: $(SRCROOT)/Misc/xerror.h
+notes.o: $(SRCROOT)/g/freetree.h
+notes.o: $(SRCROOT)/g/g-defs.h
+notes.o: $(SRCROOT)/g/g-error.h
+notes.o: $(SRCROOT)/g/g-filedefs.h
+notes.o: $(SRCROOT)/g/g-os.h
+notes.o: $(SRCROOT)/g/g-struct.h
+notes.o: $(SRCROOT)/gap4/IO1.h
+notes.o: $(SRCROOT)/gap4/edStructs.h
+notes.o: $(SRCROOT)/gap4/edUtils.h
+notes.o: $(SRCROOT)/gap4/fort.h
+notes.o: $(SRCROOT)/gap4/fortran.h
+notes.o: $(SRCROOT)/gap4/gap-dbstruct.h
+notes.o: $(SRCROOT)/gap4/gap-if.h
+notes.o: $(SRCROOT)/gap4/gap_cli_arg.h
+notes.o: $(SRCROOT)/gap4/gap_globals.h
+notes.o: $(SRCROOT)/gap4/io-reg.h
+notes.o: $(SRCROOT)/gap4/io_handle.h
+notes.o: $(SRCROOT)/gap4/io_utils.h
+notes.o: $(SRCROOT)/gap4/list.h
+notes.o: $(SRCROOT)/gap4/notes.h
+notes.o: $(SRCROOT)/gap4/primlib.h
+notes.o: $(SRCROOT)/gap4/qual.h
+notes.o: $(SRCROOT)/gap4/tagDefs.h
+notes.o: $(SRCROOT)/gap4/tagUtils.h
+notes.o: $(SRCROOT)/gap4/template.h
+notes.o: $(SRCROOT)/gap4/tkEdNames.h
+notes.o: $(SRCROOT)/gap4/tkEditor.h
+notes.o: $(SRCROOT)/gap4/tman_display.h
+notes.o: $(SRCROOT)/gap4/undo.h
+notes.o: $(SRCROOT)/primer3/src/dpal.h
+notes.o: $(SRCROOT)/primer3/src/primer3.h
+notes.o: $(SRCROOT)/tk_utils/cli_arg.h
+notes.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+notes.o: $(SRCROOT)/tk_utils/postscript.h
+notes.o: $(SRCROOT)/tk_utils/sheet.h
+notes.o: $(SRCROOT)/tk_utils/tcl_utils.h
+notes.o: $(SRCROOT)/tk_utils/text_output.h
+notes.o: $(SRCROOT)/tk_utils/tkSheet.h
+notes.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+notes.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+notes.o: $(SRCROOT)/tk_utils/tkTrace.h
 oligo.o: $(PWD)/staden_config.h
+oligo.o: $(SRCROOT)/Misc/array.h
+oligo.o: $(SRCROOT)/Misc/bitmap.h
+oligo.o: $(SRCROOT)/Misc/dstring.h
+oligo.o: $(SRCROOT)/Misc/misc.h
+oligo.o: $(SRCROOT)/Misc/os.h
+oligo.o: $(SRCROOT)/Misc/reg_exp.h
+oligo.o: $(SRCROOT)/Misc/xalloc.h
+oligo.o: $(SRCROOT)/Misc/xerror.h
+oligo.o: $(SRCROOT)/g/freetree.h
+oligo.o: $(SRCROOT)/g/g-defs.h
+oligo.o: $(SRCROOT)/g/g-error.h
+oligo.o: $(SRCROOT)/g/g-filedefs.h
+oligo.o: $(SRCROOT)/g/g-os.h
+oligo.o: $(SRCROOT)/g/g-struct.h
+oligo.o: $(SRCROOT)/gap4/IO1.h
+oligo.o: $(SRCROOT)/gap4/edStructs.h
+oligo.o: $(SRCROOT)/gap4/edUtils.h
+oligo.o: $(SRCROOT)/gap4/fort.h
+oligo.o: $(SRCROOT)/gap4/fortran.h
+oligo.o: $(SRCROOT)/gap4/gap-dbstruct.h
+oligo.o: $(SRCROOT)/gap4/gap-if.h
+oligo.o: $(SRCROOT)/gap4/io-reg.h
+oligo.o: $(SRCROOT)/gap4/io_handle.h
+oligo.o: $(SRCROOT)/gap4/io_utils.h
+oligo.o: $(SRCROOT)/gap4/list.h
+oligo.o: $(SRCROOT)/gap4/oligo.h
+oligo.o: $(SRCROOT)/gap4/primlib.h
+oligo.o: $(SRCROOT)/gap4/qual.h
+oligo.o: $(SRCROOT)/gap4/tagDefs.h
+oligo.o: $(SRCROOT)/gap4/tagUtils.h
+oligo.o: $(SRCROOT)/gap4/template.h
+oligo.o: $(SRCROOT)/gap4/tkEdNames.h
+oligo.o: $(SRCROOT)/gap4/tkEditor.h
+oligo.o: $(SRCROOT)/gap4/tman_display.h
+oligo.o: $(SRCROOT)/gap4/undo.h
+oligo.o: $(SRCROOT)/primer3/src/dpal.h
+oligo.o: $(SRCROOT)/primer3/src/primer3.h
+oligo.o: $(SRCROOT)/seq_utils/dna_utils.h
+oligo.o: $(SRCROOT)/tk_utils/cli_arg.h
+oligo.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+oligo.o: $(SRCROOT)/tk_utils/postscript.h
+oligo.o: $(SRCROOT)/tk_utils/sheet.h
+oligo.o: $(SRCROOT)/tk_utils/tkSheet.h
+oligo.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+oligo.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+oligo.o: $(SRCROOT)/tk_utils/tkTrace.h
 oligo_sel.o: $(PWD)/staden_config.h
+oligo_sel.o: $(SRCROOT)/Misc/FtoC.h
+oligo_sel.o: $(SRCROOT)/Misc/array.h
+oligo_sel.o: $(SRCROOT)/Misc/bitmap.h
+oligo_sel.o: $(SRCROOT)/Misc/dstring.h
+oligo_sel.o: $(SRCROOT)/Misc/misc.h
+oligo_sel.o: $(SRCROOT)/Misc/os.h
+oligo_sel.o: $(SRCROOT)/Misc/xalloc.h
+oligo_sel.o: $(SRCROOT)/Misc/xerror.h
+oligo_sel.o: $(SRCROOT)/g/freetree.h
+oligo_sel.o: $(SRCROOT)/g/g-defs.h
+oligo_sel.o: $(SRCROOT)/g/g-error.h
+oligo_sel.o: $(SRCROOT)/g/g-filedefs.h
+oligo_sel.o: $(SRCROOT)/g/g-os.h
+oligo_sel.o: $(SRCROOT)/g/g-struct.h
+oligo_sel.o: $(SRCROOT)/gap4/IO1.h
+oligo_sel.o: $(SRCROOT)/gap4/dstrand.h
+oligo_sel.o: $(SRCROOT)/gap4/edStructs.h
+oligo_sel.o: $(SRCROOT)/gap4/edUtils.h
+oligo_sel.o: $(SRCROOT)/gap4/fort.h
+oligo_sel.o: $(SRCROOT)/gap4/fortran.h
+oligo_sel.o: $(SRCROOT)/gap4/gap-dbstruct.h
+oligo_sel.o: $(SRCROOT)/gap4/gap-if.h
+oligo_sel.o: $(SRCROOT)/gap4/gap_globals.h
+oligo_sel.o: $(SRCROOT)/gap4/io-reg.h
+oligo_sel.o: $(SRCROOT)/gap4/io_handle.h
+oligo_sel.o: $(SRCROOT)/gap4/io_utils.h
+oligo_sel.o: $(SRCROOT)/gap4/list.h
+oligo_sel.o: $(SRCROOT)/gap4/list_proc.h
+oligo_sel.o: $(SRCROOT)/gap4/oligo_sel.h
+oligo_sel.o: $(SRCROOT)/gap4/primlib.h
+oligo_sel.o: $(SRCROOT)/gap4/qual.h
+oligo_sel.o: $(SRCROOT)/gap4/tagDefs.h
+oligo_sel.o: $(SRCROOT)/gap4/tagUtils.h
+oligo_sel.o: $(SRCROOT)/gap4/template.h
+oligo_sel.o: $(SRCROOT)/gap4/tkEdNames.h
+oligo_sel.o: $(SRCROOT)/gap4/tkEditor.h
+oligo_sel.o: $(SRCROOT)/gap4/tman_display.h
+oligo_sel.o: $(SRCROOT)/gap4/undo.h
+oligo_sel.o: $(SRCROOT)/primer3/src/dpal.h
+oligo_sel.o: $(SRCROOT)/primer3/src/primer3.h
+oligo_sel.o: $(SRCROOT)/tk_utils/cli_arg.h
+oligo_sel.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+oligo_sel.o: $(SRCROOT)/tk_utils/postscript.h
+oligo_sel.o: $(SRCROOT)/tk_utils/sheet.h
+oligo_sel.o: $(SRCROOT)/tk_utils/tcl_utils.h
+oligo_sel.o: $(SRCROOT)/tk_utils/text_output.h
+oligo_sel.o: $(SRCROOT)/tk_utils/tkSheet.h
+oligo_sel.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+oligo_sel.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+oligo_sel.o: $(SRCROOT)/tk_utils/tkTrace.h
+parse_ft.o: $(SRCROOT)/Misc/xalloc.h
+parse_ft.o: $(SRCROOT)/gap4/parse_ft.h
 preass.o: $(PWD)/staden_config.h
+preass.o: $(SRCROOT)/Misc/array.h
+preass.o: $(SRCROOT)/Misc/bitmap.h
+preass.o: $(SRCROOT)/Misc/dstring.h
+preass.o: $(SRCROOT)/Misc/misc.h
+preass.o: $(SRCROOT)/Misc/os.h
+preass.o: $(SRCROOT)/Misc/xalloc.h
+preass.o: $(SRCROOT)/Misc/xerror.h
+preass.o: $(SRCROOT)/g/freetree.h
+preass.o: $(SRCROOT)/g/g-defs.h
+preass.o: $(SRCROOT)/g/g-error.h
+preass.o: $(SRCROOT)/g/g-filedefs.h
+preass.o: $(SRCROOT)/g/g-os.h
+preass.o: $(SRCROOT)/g/g-struct.h
+preass.o: $(SRCROOT)/gap4/IO1.h
+preass.o: $(SRCROOT)/gap4/clones.h
+preass.o: $(SRCROOT)/gap4/dbcheck.h
+preass.o: $(SRCROOT)/gap4/edStructs.h
+preass.o: $(SRCROOT)/gap4/edUtils.h
+preass.o: $(SRCROOT)/gap4/fort.h
+preass.o: $(SRCROOT)/gap4/fortran.h
+preass.o: $(SRCROOT)/gap4/gap-dbstruct.h
+preass.o: $(SRCROOT)/gap4/gap-if.h
+preass.o: $(SRCROOT)/gap4/io-reg.h
+preass.o: $(SRCROOT)/gap4/io_handle.h
+preass.o: $(SRCROOT)/gap4/io_utils.h
+preass.o: $(SRCROOT)/gap4/list.h
+preass.o: $(SRCROOT)/gap4/preass.h
+preass.o: $(SRCROOT)/gap4/primlib.h
+preass.o: $(SRCROOT)/gap4/qual.h
+preass.o: $(SRCROOT)/gap4/seqInfo.h
+preass.o: $(SRCROOT)/gap4/tagDefs.h
+preass.o: $(SRCROOT)/gap4/tagUtils.h
+preass.o: $(SRCROOT)/gap4/template.h
+preass.o: $(SRCROOT)/gap4/tkEdNames.h
+preass.o: $(SRCROOT)/gap4/tkEditor.h
+preass.o: $(SRCROOT)/gap4/tman_display.h
+preass.o: $(SRCROOT)/gap4/undo.h
+preass.o: $(SRCROOT)/primer3/src/dpal.h
+preass.o: $(SRCROOT)/primer3/src/primer3.h
+preass.o: $(SRCROOT)/tk_utils/cli_arg.h
+preass.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+preass.o: $(SRCROOT)/tk_utils/postscript.h
+preass.o: $(SRCROOT)/tk_utils/sheet.h
+preass.o: $(SRCROOT)/tk_utils/text_output.h
+preass.o: $(SRCROOT)/tk_utils/tkSheet.h
+preass.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+preass.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+preass.o: $(SRCROOT)/tk_utils/tkTrace.h
 primlib.o: $(PWD)/staden_config.h
+primlib.o: $(SRCROOT)/Misc/misc.h
+primlib.o: $(SRCROOT)/Misc/os.h
+primlib.o: $(SRCROOT)/Misc/xalloc.h
+primlib.o: $(SRCROOT)/gap4/gap_globals.h
+primlib.o: $(SRCROOT)/gap4/primlib.h
+primlib.o: $(SRCROOT)/primer3/src/dpal.h
+primlib.o: $(SRCROOT)/primer3/src/primer3.h
+primlib.o: $(SRCROOT)/tk_utils/tcl_utils.h
 probe.o: $(PWD)/staden_config.h
+probe.o: $(SRCROOT)/Misc/array.h
+probe.o: $(SRCROOT)/Misc/bitmap.h
+probe.o: $(SRCROOT)/Misc/misc.h
+probe.o: $(SRCROOT)/Misc/os.h
+probe.o: $(SRCROOT)/Misc/xalloc.h
+probe.o: $(SRCROOT)/Misc/xerror.h
+probe.o: $(SRCROOT)/g/freetree.h
+probe.o: $(SRCROOT)/g/g-defs.h
+probe.o: $(SRCROOT)/g/g-error.h
+probe.o: $(SRCROOT)/g/g-filedefs.h
+probe.o: $(SRCROOT)/g/g-os.h
+probe.o: $(SRCROOT)/g/g-struct.h
+probe.o: $(SRCROOT)/gap4/IO1.h
+probe.o: $(SRCROOT)/gap4/assemble_direct.h
+probe.o: $(SRCROOT)/gap4/fort.h
+probe.o: $(SRCROOT)/gap4/gap-dbstruct.h
+probe.o: $(SRCROOT)/gap4/gap-if.h
+probe.o: $(SRCROOT)/gap4/gap_globals.h
+probe.o: $(SRCROOT)/gap4/io_handle.h
+probe.o: $(SRCROOT)/gap4/io_utils.h
+probe.o: $(SRCROOT)/gap4/primlib.h
+probe.o: $(SRCROOT)/gap4/probe.h
+probe.o: $(SRCROOT)/gap4/seqInfo.h
+probe.o: $(SRCROOT)/primer3/src/dpal.h
+probe.o: $(SRCROOT)/primer3/src/primer3.h
+probe.o: $(SRCROOT)/seq_utils/align.h
+probe.o: $(SRCROOT)/seq_utils/align_lib_old.h
+probe.o: $(SRCROOT)/seq_utils/dna_utils.h
+probe.o: $(SRCROOT)/seq_utils/sequence_formats.h
+probe.o: $(SRCROOT)/tk_utils/tcl_utils.h
+probe.o: $(SRCROOT)/tk_utils/text_output.h
 qual.o: $(PWD)/staden_config.h
+qual.o: $(SRCROOT)/Misc/misc.h
+qual.o: $(SRCROOT)/Misc/os.h
+qual.o: $(SRCROOT)/Misc/xalloc.h
+qual.o: $(SRCROOT)/gap4/gap_globals.h
+qual.o: $(SRCROOT)/gap4/qual.h
+qual.o: $(SRCROOT)/gap4/qualP.h
+qual.o: $(SRCROOT)/tk_utils/tcl_utils.h
 qualIO.o: $(PWD)/staden_config.h
+qualIO.o: $(SRCROOT)/Misc/array.h
+qualIO.o: $(SRCROOT)/Misc/bitmap.h
+qualIO.o: $(SRCROOT)/Misc/misc.h
+qualIO.o: $(SRCROOT)/Misc/os.h
+qualIO.o: $(SRCROOT)/Misc/xalloc.h
+qualIO.o: $(SRCROOT)/Misc/xerror.h
+qualIO.o: $(SRCROOT)/g/freetree.h
+qualIO.o: $(SRCROOT)/g/g-defs.h
+qualIO.o: $(SRCROOT)/g/g-error.h
+qualIO.o: $(SRCROOT)/g/g-filedefs.h
+qualIO.o: $(SRCROOT)/g/g-os.h
+qualIO.o: $(SRCROOT)/g/g-struct.h
+qualIO.o: $(SRCROOT)/gap4/IO1.h
+qualIO.o: $(SRCROOT)/gap4/IO2.h
+qualIO.o: $(SRCROOT)/gap4/gap-dbstruct.h
+qualIO.o: $(SRCROOT)/gap4/gap-if.h
+qualIO.o: $(SRCROOT)/gap4/gap_globals.h
+qualIO.o: $(SRCROOT)/gap4/io_handle.h
+qualIO.o: $(SRCROOT)/gap4/io_utils.h
+qualIO.o: $(SRCROOT)/gap4/qual.h
+qualIO.o: $(SRCROOT)/gap4/qualP.h
+qualIO.o: $(SRCROOT)/tk_utils/tcl_utils.h
 quality_plot.o: $(PWD)/staden_config.h
+quality_plot.o: $(SRCROOT)/Misc/array.h
+quality_plot.o: $(SRCROOT)/Misc/bitmap.h
+quality_plot.o: $(SRCROOT)/Misc/dstring.h
+quality_plot.o: $(SRCROOT)/Misc/misc.h
+quality_plot.o: $(SRCROOT)/Misc/os.h
+quality_plot.o: $(SRCROOT)/Misc/xalloc.h
+quality_plot.o: $(SRCROOT)/Misc/xerror.h
+quality_plot.o: $(SRCROOT)/g/freetree.h
+quality_plot.o: $(SRCROOT)/g/g-defs.h
+quality_plot.o: $(SRCROOT)/g/g-error.h
+quality_plot.o: $(SRCROOT)/g/g-filedefs.h
+quality_plot.o: $(SRCROOT)/g/g-os.h
+quality_plot.o: $(SRCROOT)/g/g-struct.h
+quality_plot.o: $(SRCROOT)/gap4/IO1.h
+quality_plot.o: $(SRCROOT)/gap4/edStructs.h
+quality_plot.o: $(SRCROOT)/gap4/edUtils.h
+quality_plot.o: $(SRCROOT)/gap4/fort.h
+quality_plot.o: $(SRCROOT)/gap4/fortran.h
+quality_plot.o: $(SRCROOT)/gap4/gap-dbstruct.h
+quality_plot.o: $(SRCROOT)/gap4/gap-if.h
+quality_plot.o: $(SRCROOT)/gap4/gap_canvas_box.h
+quality_plot.o: $(SRCROOT)/gap4/gap_globals.h
+quality_plot.o: $(SRCROOT)/gap4/hash.h
+quality_plot.o: $(SRCROOT)/gap4/io-reg.h
+quality_plot.o: $(SRCROOT)/gap4/io_handle.h
+quality_plot.o: $(SRCROOT)/gap4/io_utils.h
+quality_plot.o: $(SRCROOT)/gap4/list.h
+quality_plot.o: $(SRCROOT)/gap4/newgap_cmds.h
+quality_plot.o: $(SRCROOT)/gap4/primlib.h
+quality_plot.o: $(SRCROOT)/gap4/qual.h
+quality_plot.o: $(SRCROOT)/gap4/quality_plot.h
+quality_plot.o: $(SRCROOT)/gap4/ruler_display.h
+quality_plot.o: $(SRCROOT)/gap4/tagDefs.h
+quality_plot.o: $(SRCROOT)/gap4/tagUtils.h
+quality_plot.o: $(SRCROOT)/gap4/template.h
+quality_plot.o: $(SRCROOT)/gap4/template_display.h
+quality_plot.o: $(SRCROOT)/gap4/tkEdNames.h
+quality_plot.o: $(SRCROOT)/gap4/tkEditor.h
+quality_plot.o: $(SRCROOT)/gap4/tman_display.h
+quality_plot.o: $(SRCROOT)/gap4/undo.h
+quality_plot.o: $(SRCROOT)/primer3/src/dpal.h
+quality_plot.o: $(SRCROOT)/primer3/src/primer3.h
+quality_plot.o: $(SRCROOT)/tk_utils/canvas_box.h
+quality_plot.o: $(SRCROOT)/tk_utils/cli_arg.h
+quality_plot.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+quality_plot.o: $(SRCROOT)/tk_utils/postscript.h
+quality_plot.o: $(SRCROOT)/tk_utils/sheet.h
+quality_plot.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+quality_plot.o: $(SRCROOT)/tk_utils/tcl_utils.h
+quality_plot.o: $(SRCROOT)/tk_utils/text_output.h
+quality_plot.o: $(SRCROOT)/tk_utils/tkSheet.h
+quality_plot.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+quality_plot.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+quality_plot.o: $(SRCROOT)/tk_utils/tkTrace.h
 reactions.o: $(PWD)/staden_config.h
+reactions.o: $(SRCROOT)/Misc/array.h
+reactions.o: $(SRCROOT)/Misc/bitmap.h
+reactions.o: $(SRCROOT)/Misc/dstring.h
+reactions.o: $(SRCROOT)/Misc/misc.h
+reactions.o: $(SRCROOT)/Misc/os.h
+reactions.o: $(SRCROOT)/Misc/xalloc.h
+reactions.o: $(SRCROOT)/Misc/xerror.h
+reactions.o: $(SRCROOT)/g/freetree.h
+reactions.o: $(SRCROOT)/g/g-defs.h
+reactions.o: $(SRCROOT)/g/g-error.h
+reactions.o: $(SRCROOT)/g/g-filedefs.h
+reactions.o: $(SRCROOT)/g/g-os.h
+reactions.o: $(SRCROOT)/g/g-struct.h
+reactions.o: $(SRCROOT)/gap4/IO1.h
+reactions.o: $(SRCROOT)/gap4/edStructs.h
+reactions.o: $(SRCROOT)/gap4/edUtils.h
+reactions.o: $(SRCROOT)/gap4/fort.h
+reactions.o: $(SRCROOT)/gap4/fortran.h
+reactions.o: $(SRCROOT)/gap4/gap-dbstruct.h
+reactions.o: $(SRCROOT)/gap4/gap-if.h
+reactions.o: $(SRCROOT)/gap4/gap_globals.h
+reactions.o: $(SRCROOT)/gap4/io-reg.h
+reactions.o: $(SRCROOT)/gap4/io_handle.h
+reactions.o: $(SRCROOT)/gap4/io_utils.h
+reactions.o: $(SRCROOT)/gap4/list.h
+reactions.o: $(SRCROOT)/gap4/primlib.h
+reactions.o: $(SRCROOT)/gap4/qual.h
+reactions.o: $(SRCROOT)/gap4/qualP.h
+reactions.o: $(SRCROOT)/gap4/tagDefs.h
+reactions.o: $(SRCROOT)/gap4/tagUtils.h
+reactions.o: $(SRCROOT)/gap4/template.h
+reactions.o: $(SRCROOT)/gap4/tkEdNames.h
+reactions.o: $(SRCROOT)/gap4/tkEditor.h
+reactions.o: $(SRCROOT)/gap4/tman_display.h
+reactions.o: $(SRCROOT)/gap4/undo.h
+reactions.o: $(SRCROOT)/primer3/src/dpal.h
+reactions.o: $(SRCROOT)/primer3/src/primer3.h
+reactions.o: $(SRCROOT)/tk_utils/cli_arg.h
+reactions.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+reactions.o: $(SRCROOT)/tk_utils/postscript.h
+reactions.o: $(SRCROOT)/tk_utils/sheet.h
+reactions.o: $(SRCROOT)/tk_utils/tcl_utils.h
+reactions.o: $(SRCROOT)/tk_utils/tkSheet.h
+reactions.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+reactions.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+reactions.o: $(SRCROOT)/tk_utils/tkTrace.h
 reading_coverage.o: $(PWD)/staden_config.h
+reading_coverage.o: $(SRCROOT)/Misc/array.h
+reading_coverage.o: $(SRCROOT)/Misc/bitmap.h
+reading_coverage.o: $(SRCROOT)/Misc/misc.h
+reading_coverage.o: $(SRCROOT)/Misc/os.h
+reading_coverage.o: $(SRCROOT)/Misc/xalloc.h
+reading_coverage.o: $(SRCROOT)/Misc/xerror.h
+reading_coverage.o: $(SRCROOT)/g/freetree.h
+reading_coverage.o: $(SRCROOT)/g/g-defs.h
+reading_coverage.o: $(SRCROOT)/g/g-error.h
+reading_coverage.o: $(SRCROOT)/g/g-filedefs.h
+reading_coverage.o: $(SRCROOT)/g/g-os.h
+reading_coverage.o: $(SRCROOT)/g/g-struct.h
+reading_coverage.o: $(SRCROOT)/gap4/IO1.h
+reading_coverage.o: $(SRCROOT)/gap4/consen.h
+reading_coverage.o: $(SRCROOT)/gap4/consistency_display.h
+reading_coverage.o: $(SRCROOT)/gap4/gap-dbstruct.h
+reading_coverage.o: $(SRCROOT)/gap4/gap-if.h
+reading_coverage.o: $(SRCROOT)/gap4/gap_canvas_box.h
+reading_coverage.o: $(SRCROOT)/gap4/gap_globals.h
+reading_coverage.o: $(SRCROOT)/gap4/hash.h
+reading_coverage.o: $(SRCROOT)/gap4/io-reg.h
+reading_coverage.o: $(SRCROOT)/gap4/io_handle.h
+reading_coverage.o: $(SRCROOT)/gap4/io_utils.h
+reading_coverage.o: $(SRCROOT)/gap4/list.h
+reading_coverage.o: $(SRCROOT)/gap4/newgap_cmds.h
+reading_coverage.o: $(SRCROOT)/gap4/qual.h
+reading_coverage.o: $(SRCROOT)/gap4/reading_coverage.h
+reading_coverage.o: $(SRCROOT)/gap4/ruler_display.h
+reading_coverage.o: $(SRCROOT)/gap4/template.h
+reading_coverage.o: $(SRCROOT)/gap4/template_display.h
+reading_coverage.o: $(SRCROOT)/tk_utils/canvas_box.h
+reading_coverage.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+reading_coverage.o: $(SRCROOT)/tk_utils/tcl_utils.h
+reading_coverage.o: $(SRCROOT)/tk_utils/text_output.h
 readpair.o: $(PWD)/staden_config.h
+readpair.o: $(SRCROOT)/Misc/array.h
+readpair.o: $(SRCROOT)/Misc/bitmap.h
+readpair.o: $(SRCROOT)/Misc/dstring.h
+readpair.o: $(SRCROOT)/Misc/misc.h
+readpair.o: $(SRCROOT)/Misc/os.h
+readpair.o: $(SRCROOT)/Misc/xalloc.h
+readpair.o: $(SRCROOT)/Misc/xerror.h
+readpair.o: $(SRCROOT)/g/freetree.h
+readpair.o: $(SRCROOT)/g/g-defs.h
+readpair.o: $(SRCROOT)/g/g-error.h
+readpair.o: $(SRCROOT)/g/g-filedefs.h
+readpair.o: $(SRCROOT)/g/g-os.h
+readpair.o: $(SRCROOT)/g/g-struct.h
+readpair.o: $(SRCROOT)/gap4/IO1.h
+readpair.o: $(SRCROOT)/gap4/complement.h
+readpair.o: $(SRCROOT)/gap4/contigEditor.h
+readpair.o: $(SRCROOT)/gap4/contig_selector.h
+readpair.o: $(SRCROOT)/gap4/cs-object.h
+readpair.o: $(SRCROOT)/gap4/edStructs.h
+readpair.o: $(SRCROOT)/gap4/edUtils.h
+readpair.o: $(SRCROOT)/gap4/fort.h
+readpair.o: $(SRCROOT)/gap4/fortran.h
+readpair.o: $(SRCROOT)/gap4/gap-dbstruct.h
+readpair.o: $(SRCROOT)/gap4/gap-if.h
+readpair.o: $(SRCROOT)/gap4/gap_globals.h
+readpair.o: $(SRCROOT)/gap4/io-reg.h
+readpair.o: $(SRCROOT)/gap4/io_handle.h
+readpair.o: $(SRCROOT)/gap4/io_utils.h
+readpair.o: $(SRCROOT)/gap4/list.h
+readpair.o: $(SRCROOT)/gap4/newgap_cmds.h
+readpair.o: $(SRCROOT)/gap4/primlib.h
+readpair.o: $(SRCROOT)/gap4/qual.h
+readpair.o: $(SRCROOT)/gap4/readpair.h
+readpair.o: $(SRCROOT)/gap4/tagDefs.h
+readpair.o: $(SRCROOT)/gap4/tagUtils.h
+readpair.o: $(SRCROOT)/gap4/template.h
+readpair.o: $(SRCROOT)/gap4/tkEdNames.h
+readpair.o: $(SRCROOT)/gap4/tkEditor.h
+readpair.o: $(SRCROOT)/gap4/tman_display.h
+readpair.o: $(SRCROOT)/gap4/undo.h
+readpair.o: $(SRCROOT)/primer3/src/dpal.h
+readpair.o: $(SRCROOT)/primer3/src/primer3.h
+readpair.o: $(SRCROOT)/tk_utils/canvas_box.h
+readpair.o: $(SRCROOT)/tk_utils/cli_arg.h
+readpair.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+readpair.o: $(SRCROOT)/tk_utils/postscript.h
+readpair.o: $(SRCROOT)/tk_utils/sheet.h
+readpair.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+readpair.o: $(SRCROOT)/tk_utils/tcl_utils.h
+readpair.o: $(SRCROOT)/tk_utils/text_output.h
+readpair.o: $(SRCROOT)/tk_utils/tkSheet.h
+readpair.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+readpair.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+readpair.o: $(SRCROOT)/tk_utils/tkTrace.h
 readpair_coverage.o: $(PWD)/staden_config.h
+readpair_coverage.o: $(SRCROOT)/Misc/array.h
+readpair_coverage.o: $(SRCROOT)/Misc/bitmap.h
+readpair_coverage.o: $(SRCROOT)/Misc/misc.h
+readpair_coverage.o: $(SRCROOT)/Misc/os.h
+readpair_coverage.o: $(SRCROOT)/Misc/xalloc.h
+readpair_coverage.o: $(SRCROOT)/Misc/xerror.h
+readpair_coverage.o: $(SRCROOT)/g/freetree.h
+readpair_coverage.o: $(SRCROOT)/g/g-defs.h
+readpair_coverage.o: $(SRCROOT)/g/g-error.h
+readpair_coverage.o: $(SRCROOT)/g/g-filedefs.h
+readpair_coverage.o: $(SRCROOT)/g/g-os.h
+readpair_coverage.o: $(SRCROOT)/g/g-struct.h
+readpair_coverage.o: $(SRCROOT)/gap4/IO1.h
+readpair_coverage.o: $(SRCROOT)/gap4/consen.h
+readpair_coverage.o: $(SRCROOT)/gap4/consistency_display.h
+readpair_coverage.o: $(SRCROOT)/gap4/gap-dbstruct.h
+readpair_coverage.o: $(SRCROOT)/gap4/gap-if.h
+readpair_coverage.o: $(SRCROOT)/gap4/gap_canvas_box.h
+readpair_coverage.o: $(SRCROOT)/gap4/gap_globals.h
+readpair_coverage.o: $(SRCROOT)/gap4/hash.h
+readpair_coverage.o: $(SRCROOT)/gap4/io-reg.h
+readpair_coverage.o: $(SRCROOT)/gap4/io_handle.h
+readpair_coverage.o: $(SRCROOT)/gap4/io_utils.h
+readpair_coverage.o: $(SRCROOT)/gap4/list.h
+readpair_coverage.o: $(SRCROOT)/gap4/newgap_cmds.h
+readpair_coverage.o: $(SRCROOT)/gap4/qual.h
+readpair_coverage.o: $(SRCROOT)/gap4/reading_coverage.h
+readpair_coverage.o: $(SRCROOT)/gap4/readpair_coverage.h
+readpair_coverage.o: $(SRCROOT)/gap4/ruler_display.h
+readpair_coverage.o: $(SRCROOT)/gap4/template.h
+readpair_coverage.o: $(SRCROOT)/gap4/template_display.h
+readpair_coverage.o: $(SRCROOT)/tk_utils/canvas_box.h
+readpair_coverage.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+readpair_coverage.o: $(SRCROOT)/tk_utils/tcl_utils.h
+readpair_coverage.o: $(SRCROOT)/tk_utils/text_output.h
 restriction_enzymes.o: $(PWD)/staden_config.h
+restriction_enzymes.o: $(SRCROOT)/Misc/array.h
+restriction_enzymes.o: $(SRCROOT)/Misc/bitmap.h
+restriction_enzymes.o: $(SRCROOT)/Misc/dstring.h
+restriction_enzymes.o: $(SRCROOT)/Misc/getfile.h
+restriction_enzymes.o: $(SRCROOT)/Misc/misc.h
+restriction_enzymes.o: $(SRCROOT)/Misc/os.h
+restriction_enzymes.o: $(SRCROOT)/Misc/xalloc.h
+restriction_enzymes.o: $(SRCROOT)/Misc/xerror.h
+restriction_enzymes.o: $(SRCROOT)/g/freetree.h
+restriction_enzymes.o: $(SRCROOT)/g/g-defs.h
+restriction_enzymes.o: $(SRCROOT)/g/g-error.h
+restriction_enzymes.o: $(SRCROOT)/g/g-filedefs.h
+restriction_enzymes.o: $(SRCROOT)/g/g-os.h
+restriction_enzymes.o: $(SRCROOT)/g/g-struct.h
+restriction_enzymes.o: $(SRCROOT)/gap4/IO1.h
+restriction_enzymes.o: $(SRCROOT)/gap4/edStructs.h
+restriction_enzymes.o: $(SRCROOT)/gap4/edUtils.h
+restriction_enzymes.o: $(SRCROOT)/gap4/fort.h
+restriction_enzymes.o: $(SRCROOT)/gap4/fortran.h
+restriction_enzymes.o: $(SRCROOT)/gap4/gap-dbstruct.h
+restriction_enzymes.o: $(SRCROOT)/gap4/gap-if.h
+restriction_enzymes.o: $(SRCROOT)/gap4/gap_canvas_box.h
+restriction_enzymes.o: $(SRCROOT)/gap4/gap_globals.h
+restriction_enzymes.o: $(SRCROOT)/gap4/hash.h
+restriction_enzymes.o: $(SRCROOT)/gap4/io-reg.h
+restriction_enzymes.o: $(SRCROOT)/gap4/io_handle.h
+restriction_enzymes.o: $(SRCROOT)/gap4/io_utils.h
+restriction_enzymes.o: $(SRCROOT)/gap4/list.h
+restriction_enzymes.o: $(SRCROOT)/gap4/list_proc.h
+restriction_enzymes.o: $(SRCROOT)/gap4/newgap_cmds.h
+restriction_enzymes.o: $(SRCROOT)/gap4/primlib.h
+restriction_enzymes.o: $(SRCROOT)/gap4/qual.h
+restriction_enzymes.o: $(SRCROOT)/gap4/restriction_enzymes.h
+restriction_enzymes.o: $(SRCROOT)/gap4/ruler_display.h
+restriction_enzymes.o: $(SRCROOT)/gap4/tagDefs.h
+restriction_enzymes.o: $(SRCROOT)/gap4/tagUtils.h
+restriction_enzymes.o: $(SRCROOT)/gap4/template.h
+restriction_enzymes.o: $(SRCROOT)/gap4/template_display.h
+restriction_enzymes.o: $(SRCROOT)/gap4/tkEdNames.h
+restriction_enzymes.o: $(SRCROOT)/gap4/tkEditor.h
+restriction_enzymes.o: $(SRCROOT)/gap4/tman_display.h
+restriction_enzymes.o: $(SRCROOT)/gap4/undo.h
+restriction_enzymes.o: $(SRCROOT)/primer3/src/dpal.h
+restriction_enzymes.o: $(SRCROOT)/primer3/src/primer3.h
+restriction_enzymes.o: $(SRCROOT)/seq_utils/dna_utils.h
+restriction_enzymes.o: $(SRCROOT)/seq_utils/renz_utils.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/canvas_box.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/cli_arg.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/postscript.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/restriction_enzyme_map.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/sheet.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tcl_utils.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/text_output.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tkSheet.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tkTrace.h
 ruler_display.o: $(PWD)/staden_config.h
+ruler_display.o: $(SRCROOT)/Misc/array.h
+ruler_display.o: $(SRCROOT)/Misc/bitmap.h
+ruler_display.o: $(SRCROOT)/Misc/misc.h
+ruler_display.o: $(SRCROOT)/Misc/os.h
+ruler_display.o: $(SRCROOT)/Misc/xalloc.h
+ruler_display.o: $(SRCROOT)/Misc/xerror.h
+ruler_display.o: $(SRCROOT)/g/freetree.h
+ruler_display.o: $(SRCROOT)/g/g-defs.h
+ruler_display.o: $(SRCROOT)/g/g-error.h
+ruler_display.o: $(SRCROOT)/g/g-filedefs.h
+ruler_display.o: $(SRCROOT)/g/g-os.h
+ruler_display.o: $(SRCROOT)/g/g-struct.h
+ruler_display.o: $(SRCROOT)/gap4/IO1.h
+ruler_display.o: $(SRCROOT)/gap4/gap-dbstruct.h
+ruler_display.o: $(SRCROOT)/gap4/gap-if.h
+ruler_display.o: $(SRCROOT)/gap4/gap_globals.h
+ruler_display.o: $(SRCROOT)/gap4/hash.h
+ruler_display.o: $(SRCROOT)/gap4/io-reg.h
+ruler_display.o: $(SRCROOT)/gap4/io_handle.h
+ruler_display.o: $(SRCROOT)/gap4/io_utils.h
+ruler_display.o: $(SRCROOT)/gap4/list.h
+ruler_display.o: $(SRCROOT)/gap4/ruler_display.h
+ruler_display.o: $(SRCROOT)/gap4/template.h
+ruler_display.o: $(SRCROOT)/gap4/template_display.h
+ruler_display.o: $(SRCROOT)/tk_utils/canvas_box.h
+ruler_display.o: $(SRCROOT)/tk_utils/ruler_tick.h
+ruler_display.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+ruler_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
 searchUtils.o: $(PWD)/staden_config.h
+searchUtils.o: $(SRCROOT)/Misc/array.h
+searchUtils.o: $(SRCROOT)/Misc/bitmap.h
+searchUtils.o: $(SRCROOT)/Misc/dstring.h
+searchUtils.o: $(SRCROOT)/Misc/misc.h
+searchUtils.o: $(SRCROOT)/Misc/os.h
+searchUtils.o: $(SRCROOT)/Misc/reg_exp.h
+searchUtils.o: $(SRCROOT)/Misc/xalloc.h
+searchUtils.o: $(SRCROOT)/Misc/xerror.h
+searchUtils.o: $(SRCROOT)/g/freetree.h
+searchUtils.o: $(SRCROOT)/g/g-defs.h
+searchUtils.o: $(SRCROOT)/g/g-error.h
+searchUtils.o: $(SRCROOT)/g/g-filedefs.h
+searchUtils.o: $(SRCROOT)/g/g-os.h
+searchUtils.o: $(SRCROOT)/g/g-struct.h
+searchUtils.o: $(SRCROOT)/gap4/IO1.h
+searchUtils.o: $(SRCROOT)/gap4/active_tags.h
+searchUtils.o: $(SRCROOT)/gap4/contigEditor.h
+searchUtils.o: $(SRCROOT)/gap4/edStructs.h
+searchUtils.o: $(SRCROOT)/gap4/edUtils.h
+searchUtils.o: $(SRCROOT)/gap4/fort.h
+searchUtils.o: $(SRCROOT)/gap4/fortran.h
+searchUtils.o: $(SRCROOT)/gap4/gap-dbstruct.h
+searchUtils.o: $(SRCROOT)/gap4/gap-if.h
+searchUtils.o: $(SRCROOT)/gap4/io-reg.h
+searchUtils.o: $(SRCROOT)/gap4/io_handle.h
+searchUtils.o: $(SRCROOT)/gap4/io_utils.h
+searchUtils.o: $(SRCROOT)/gap4/list.h
+searchUtils.o: $(SRCROOT)/gap4/primlib.h
+searchUtils.o: $(SRCROOT)/gap4/qual.h
+searchUtils.o: $(SRCROOT)/gap4/select.h
+searchUtils.o: $(SRCROOT)/gap4/tagDefs.h
+searchUtils.o: $(SRCROOT)/gap4/tagUtils.h
+searchUtils.o: $(SRCROOT)/gap4/tagdb.h
+searchUtils.o: $(SRCROOT)/gap4/template.h
+searchUtils.o: $(SRCROOT)/gap4/tkEdNames.h
+searchUtils.o: $(SRCROOT)/gap4/tkEditor.h
+searchUtils.o: $(SRCROOT)/gap4/tman_display.h
+searchUtils.o: $(SRCROOT)/gap4/tman_interface.h
+searchUtils.o: $(SRCROOT)/gap4/undo.h
+searchUtils.o: $(SRCROOT)/primer3/src/dpal.h
+searchUtils.o: $(SRCROOT)/primer3/src/primer3.h
+searchUtils.o: $(SRCROOT)/seq_utils/dna_utils.h
+searchUtils.o: $(SRCROOT)/seq_utils/search_utils.h
+searchUtils.o: $(SRCROOT)/tk_utils/cli_arg.h
+searchUtils.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+searchUtils.o: $(SRCROOT)/tk_utils/postscript.h
+searchUtils.o: $(SRCROOT)/tk_utils/sheet.h
+searchUtils.o: $(SRCROOT)/tk_utils/text_output.h
+searchUtils.o: $(SRCROOT)/tk_utils/tkSheet.h
+searchUtils.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+searchUtils.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+searchUtils.o: $(SRCROOT)/tk_utils/tkTrace.h
 seqInfo.o: $(PWD)/staden_config.h
+seqInfo.o: $(SRCROOT)/Misc/FtoC.h
+seqInfo.o: $(SRCROOT)/Misc/array.h
+seqInfo.o: $(SRCROOT)/Misc/bitmap.h
+seqInfo.o: $(SRCROOT)/Misc/dstring.h
+seqInfo.o: $(SRCROOT)/Misc/misc.h
+seqInfo.o: $(SRCROOT)/Misc/os.h
+seqInfo.o: $(SRCROOT)/Misc/xalloc.h
+seqInfo.o: $(SRCROOT)/Misc/xerror.h
+seqInfo.o: $(SRCROOT)/g/freetree.h
+seqInfo.o: $(SRCROOT)/g/g-defs.h
+seqInfo.o: $(SRCROOT)/g/g-error.h
+seqInfo.o: $(SRCROOT)/g/g-filedefs.h
+seqInfo.o: $(SRCROOT)/g/g-os.h
+seqInfo.o: $(SRCROOT)/g/g-struct.h
+seqInfo.o: $(SRCROOT)/gap4/IO1.h
+seqInfo.o: $(SRCROOT)/gap4/edStructs.h
+seqInfo.o: $(SRCROOT)/gap4/edUtils.h
+seqInfo.o: $(SRCROOT)/gap4/fort.h
+seqInfo.o: $(SRCROOT)/gap4/fortran.h
+seqInfo.o: $(SRCROOT)/gap4/gap-dbstruct.h
+seqInfo.o: $(SRCROOT)/gap4/gap-if.h
+seqInfo.o: $(SRCROOT)/gap4/io-reg.h
+seqInfo.o: $(SRCROOT)/gap4/io_handle.h
+seqInfo.o: $(SRCROOT)/gap4/io_utils.h
+seqInfo.o: $(SRCROOT)/gap4/list.h
+seqInfo.o: $(SRCROOT)/gap4/parse_ft.h
+seqInfo.o: $(SRCROOT)/gap4/primlib.h
+seqInfo.o: $(SRCROOT)/gap4/qual.h
+seqInfo.o: $(SRCROOT)/gap4/seqInfo.h
+seqInfo.o: $(SRCROOT)/gap4/tagDefs.h
+seqInfo.o: $(SRCROOT)/gap4/tagUtils.h
+seqInfo.o: $(SRCROOT)/gap4/tagdb.h
+seqInfo.o: $(SRCROOT)/gap4/template.h
+seqInfo.o: $(SRCROOT)/gap4/tkEdNames.h
+seqInfo.o: $(SRCROOT)/gap4/tkEditor.h
+seqInfo.o: $(SRCROOT)/gap4/tman_display.h
+seqInfo.o: $(SRCROOT)/gap4/undo.h
+seqInfo.o: $(SRCROOT)/primer3/src/dpal.h
+seqInfo.o: $(SRCROOT)/primer3/src/primer3.h
+seqInfo.o: $(SRCROOT)/tk_utils/cli_arg.h
+seqInfo.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqInfo.o: $(SRCROOT)/tk_utils/postscript.h
+seqInfo.o: $(SRCROOT)/tk_utils/sheet.h
+seqInfo.o: $(SRCROOT)/tk_utils/tkSheet.h
+seqInfo.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+seqInfo.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+seqInfo.o: $(SRCROOT)/tk_utils/tkTrace.h
 show_relationships.o: $(PWD)/staden_config.h
+show_relationships.o: $(SRCROOT)/Misc/array.h
+show_relationships.o: $(SRCROOT)/Misc/bitmap.h
+show_relationships.o: $(SRCROOT)/Misc/misc.h
+show_relationships.o: $(SRCROOT)/Misc/os.h
+show_relationships.o: $(SRCROOT)/Misc/xalloc.h
+show_relationships.o: $(SRCROOT)/Misc/xerror.h
+show_relationships.o: $(SRCROOT)/g/freetree.h
+show_relationships.o: $(SRCROOT)/g/g-defs.h
+show_relationships.o: $(SRCROOT)/g/g-error.h
+show_relationships.o: $(SRCROOT)/g/g-filedefs.h
+show_relationships.o: $(SRCROOT)/g/g-os.h
+show_relationships.o: $(SRCROOT)/g/g-struct.h
+show_relationships.o: $(SRCROOT)/gap4/IO1.h
+show_relationships.o: $(SRCROOT)/gap4/gap-dbstruct.h
+show_relationships.o: $(SRCROOT)/gap4/gap-if.h
+show_relationships.o: $(SRCROOT)/gap4/io_handle.h
+show_relationships.o: $(SRCROOT)/gap4/io_utils.h
+show_relationships.o: $(SRCROOT)/gap4/newgap_structs.h
+show_relationships.o: $(SRCROOT)/tk_utils/cli_arg.h
+show_relationships.o: $(SRCROOT)/tk_utils/text_output.h
 shuffle_pads.o: $(PWD)/staden_config.h
+shuffle_pads.o: $(SRCROOT)/Misc/array.h
+shuffle_pads.o: $(SRCROOT)/Misc/bitmap.h
+shuffle_pads.o: $(SRCROOT)/Misc/dstring.h
+shuffle_pads.o: $(SRCROOT)/Misc/misc.h
+shuffle_pads.o: $(SRCROOT)/Misc/os.h
+shuffle_pads.o: $(SRCROOT)/Misc/xalloc.h
+shuffle_pads.o: $(SRCROOT)/Misc/xerror.h
+shuffle_pads.o: $(SRCROOT)/g/freetree.h
+shuffle_pads.o: $(SRCROOT)/g/g-defs.h
+shuffle_pads.o: $(SRCROOT)/g/g-error.h
+shuffle_pads.o: $(SRCROOT)/g/g-filedefs.h
+shuffle_pads.o: $(SRCROOT)/g/g-os.h
+shuffle_pads.o: $(SRCROOT)/g/g-struct.h
+shuffle_pads.o: $(SRCROOT)/gap4/IO1.h
+shuffle_pads.o: $(SRCROOT)/gap4/dis_readings.h
+shuffle_pads.o: $(SRCROOT)/gap4/edStructs.h
+shuffle_pads.o: $(SRCROOT)/gap4/edUtils.h
+shuffle_pads.o: $(SRCROOT)/gap4/fort.h
+shuffle_pads.o: $(SRCROOT)/gap4/fortran.h
+shuffle_pads.o: $(SRCROOT)/gap4/gap-dbstruct.h
+shuffle_pads.o: $(SRCROOT)/gap4/gap-if.h
+shuffle_pads.o: $(SRCROOT)/gap4/io-reg.h
+shuffle_pads.o: $(SRCROOT)/gap4/io_handle.h
+shuffle_pads.o: $(SRCROOT)/gap4/io_utils.h
+shuffle_pads.o: $(SRCROOT)/gap4/list.h
+shuffle_pads.o: $(SRCROOT)/gap4/primlib.h
+shuffle_pads.o: $(SRCROOT)/gap4/qual.h
+shuffle_pads.o: $(SRCROOT)/gap4/shuffle_pads.h
+shuffle_pads.o: $(SRCROOT)/gap4/tagDefs.h
+shuffle_pads.o: $(SRCROOT)/gap4/tagUtils.h
+shuffle_pads.o: $(SRCROOT)/gap4/template.h
+shuffle_pads.o: $(SRCROOT)/gap4/tkEdNames.h
+shuffle_pads.o: $(SRCROOT)/gap4/tkEditor.h
+shuffle_pads.o: $(SRCROOT)/gap4/tman_display.h
+shuffle_pads.o: $(SRCROOT)/gap4/undo.h
+shuffle_pads.o: $(SRCROOT)/primer3/src/dpal.h
+shuffle_pads.o: $(SRCROOT)/primer3/src/primer3.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/align.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/align_lib.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/align_lib_old.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/dna_utils.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/cli_arg.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/postscript.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/sheet.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/text_output.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/tkSheet.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/tkTrace.h
 stack_dump.o: $(PWD)/staden_config.h
+stack_dump.o: $(SRCROOT)/Misc/array.h
+stack_dump.o: $(SRCROOT)/Misc/bitmap.h
+stack_dump.o: $(SRCROOT)/Misc/misc.h
+stack_dump.o: $(SRCROOT)/Misc/os.h
+stack_dump.o: $(SRCROOT)/Misc/xalloc.h
+stack_dump.o: $(SRCROOT)/Misc/xerror.h
+stack_dump.o: $(SRCROOT)/g/g-error.h
+stack_dump.o: $(SRCROOT)/gap4/gap-error.h
+stack_dump.o: $(SRCROOT)/gap4/stack_dump.h
 stop_codon.o: $(PWD)/staden_config.h
+stop_codon.o: $(SRCROOT)/Misc/array.h
+stop_codon.o: $(SRCROOT)/Misc/bitmap.h
+stop_codon.o: $(SRCROOT)/Misc/dstring.h
+stop_codon.o: $(SRCROOT)/Misc/misc.h
+stop_codon.o: $(SRCROOT)/Misc/os.h
+stop_codon.o: $(SRCROOT)/Misc/xalloc.h
+stop_codon.o: $(SRCROOT)/Misc/xerror.h
+stop_codon.o: $(SRCROOT)/g/freetree.h
+stop_codon.o: $(SRCROOT)/g/g-defs.h
+stop_codon.o: $(SRCROOT)/g/g-error.h
+stop_codon.o: $(SRCROOT)/g/g-filedefs.h
+stop_codon.o: $(SRCROOT)/g/g-os.h
+stop_codon.o: $(SRCROOT)/g/g-struct.h
+stop_codon.o: $(SRCROOT)/gap4/IO1.h
+stop_codon.o: $(SRCROOT)/gap4/edStructs.h
+stop_codon.o: $(SRCROOT)/gap4/edUtils.h
+stop_codon.o: $(SRCROOT)/gap4/fort.h
+stop_codon.o: $(SRCROOT)/gap4/fortran.h
+stop_codon.o: $(SRCROOT)/gap4/gap-dbstruct.h
+stop_codon.o: $(SRCROOT)/gap4/gap-if.h
+stop_codon.o: $(SRCROOT)/gap4/gap_canvas_box.h
+stop_codon.o: $(SRCROOT)/gap4/gap_globals.h
+stop_codon.o: $(SRCROOT)/gap4/hash.h
+stop_codon.o: $(SRCROOT)/gap4/io-reg.h
+stop_codon.o: $(SRCROOT)/gap4/io_handle.h
+stop_codon.o: $(SRCROOT)/gap4/io_utils.h
+stop_codon.o: $(SRCROOT)/gap4/list.h
+stop_codon.o: $(SRCROOT)/gap4/primlib.h
+stop_codon.o: $(SRCROOT)/gap4/qual.h
+stop_codon.o: $(SRCROOT)/gap4/restriction_enzymes.h
+stop_codon.o: $(SRCROOT)/gap4/ruler_display.h
+stop_codon.o: $(SRCROOT)/gap4/stop_codon.h
+stop_codon.o: $(SRCROOT)/gap4/tagDefs.h
+stop_codon.o: $(SRCROOT)/gap4/tagUtils.h
+stop_codon.o: $(SRCROOT)/gap4/template.h
+stop_codon.o: $(SRCROOT)/gap4/template_display.h
+stop_codon.o: $(SRCROOT)/gap4/tkEdNames.h
+stop_codon.o: $(SRCROOT)/gap4/tkEditor.h
+stop_codon.o: $(SRCROOT)/gap4/tman_display.h
+stop_codon.o: $(SRCROOT)/gap4/undo.h
+stop_codon.o: $(SRCROOT)/primer3/src/dpal.h
+stop_codon.o: $(SRCROOT)/primer3/src/primer3.h
+stop_codon.o: $(SRCROOT)/seq_utils/dna_utils.h
+stop_codon.o: $(SRCROOT)/seq_utils/renz_utils.h
+stop_codon.o: $(SRCROOT)/tk_utils/canvas_box.h
+stop_codon.o: $(SRCROOT)/tk_utils/cli_arg.h
+stop_codon.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+stop_codon.o: $(SRCROOT)/tk_utils/postscript.h
+stop_codon.o: $(SRCROOT)/tk_utils/restriction_enzyme_map.h
+stop_codon.o: $(SRCROOT)/tk_utils/sheet.h
+stop_codon.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+stop_codon.o: $(SRCROOT)/tk_utils/tcl_utils.h
+stop_codon.o: $(SRCROOT)/tk_utils/tkSheet.h
+stop_codon.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+stop_codon.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+stop_codon.o: $(SRCROOT)/tk_utils/tkTrace.h
 strand_coverage.o: $(PWD)/staden_config.h
+strand_coverage.o: $(SRCROOT)/Misc/array.h
+strand_coverage.o: $(SRCROOT)/Misc/bitmap.h
+strand_coverage.o: $(SRCROOT)/Misc/misc.h
+strand_coverage.o: $(SRCROOT)/Misc/os.h
+strand_coverage.o: $(SRCROOT)/Misc/xalloc.h
+strand_coverage.o: $(SRCROOT)/Misc/xerror.h
+strand_coverage.o: $(SRCROOT)/g/freetree.h
+strand_coverage.o: $(SRCROOT)/g/g-defs.h
+strand_coverage.o: $(SRCROOT)/g/g-error.h
+strand_coverage.o: $(SRCROOT)/g/g-filedefs.h
+strand_coverage.o: $(SRCROOT)/g/g-os.h
+strand_coverage.o: $(SRCROOT)/g/g-struct.h
+strand_coverage.o: $(SRCROOT)/gap4/IO1.h
+strand_coverage.o: $(SRCROOT)/gap4/consen.h
+strand_coverage.o: $(SRCROOT)/gap4/consistency_display.h
+strand_coverage.o: $(SRCROOT)/gap4/gap-dbstruct.h
+strand_coverage.o: $(SRCROOT)/gap4/gap-if.h
+strand_coverage.o: $(SRCROOT)/gap4/gap_canvas_box.h
+strand_coverage.o: $(SRCROOT)/gap4/gap_globals.h
+strand_coverage.o: $(SRCROOT)/gap4/hash.h
+strand_coverage.o: $(SRCROOT)/gap4/io-reg.h
+strand_coverage.o: $(SRCROOT)/gap4/io_handle.h
+strand_coverage.o: $(SRCROOT)/gap4/io_utils.h
+strand_coverage.o: $(SRCROOT)/gap4/list.h
+strand_coverage.o: $(SRCROOT)/gap4/newgap_cmds.h
+strand_coverage.o: $(SRCROOT)/gap4/qual.h
+strand_coverage.o: $(SRCROOT)/gap4/ruler_display.h
+strand_coverage.o: $(SRCROOT)/gap4/strand_coverage.h
+strand_coverage.o: $(SRCROOT)/gap4/template.h
+strand_coverage.o: $(SRCROOT)/gap4/template_display.h
+strand_coverage.o: $(SRCROOT)/tk_utils/canvas_box.h
+strand_coverage.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+strand_coverage.o: $(SRCROOT)/tk_utils/tcl_utils.h
+strand_coverage.o: $(SRCROOT)/tk_utils/text_output.h
 tagEditor.o: $(PWD)/staden_config.h
+tagEditor.o: $(SRCROOT)/Misc/array.h
+tagEditor.o: $(SRCROOT)/Misc/bitmap.h
+tagEditor.o: $(SRCROOT)/Misc/dstring.h
+tagEditor.o: $(SRCROOT)/Misc/misc.h
+tagEditor.o: $(SRCROOT)/Misc/os.h
+tagEditor.o: $(SRCROOT)/Misc/xalloc.h
+tagEditor.o: $(SRCROOT)/Misc/xerror.h
+tagEditor.o: $(SRCROOT)/g/freetree.h
+tagEditor.o: $(SRCROOT)/g/g-defs.h
+tagEditor.o: $(SRCROOT)/g/g-error.h
+tagEditor.o: $(SRCROOT)/g/g-filedefs.h
+tagEditor.o: $(SRCROOT)/g/g-os.h
+tagEditor.o: $(SRCROOT)/g/g-struct.h
+tagEditor.o: $(SRCROOT)/gap4/IO1.h
+tagEditor.o: $(SRCROOT)/gap4/edStructs.h
+tagEditor.o: $(SRCROOT)/gap4/edUtils.h
+tagEditor.o: $(SRCROOT)/gap4/fort.h
+tagEditor.o: $(SRCROOT)/gap4/fortran.h
+tagEditor.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tagEditor.o: $(SRCROOT)/gap4/gap-if.h
+tagEditor.o: $(SRCROOT)/gap4/gap_globals.h
+tagEditor.o: $(SRCROOT)/gap4/io-reg.h
+tagEditor.o: $(SRCROOT)/gap4/io_handle.h
+tagEditor.o: $(SRCROOT)/gap4/io_utils.h
+tagEditor.o: $(SRCROOT)/gap4/list.h
+tagEditor.o: $(SRCROOT)/gap4/primlib.h
+tagEditor.o: $(SRCROOT)/gap4/qual.h
+tagEditor.o: $(SRCROOT)/gap4/select.h
+tagEditor.o: $(SRCROOT)/gap4/tagDefs.h
+tagEditor.o: $(SRCROOT)/gap4/tagUtils.h
+tagEditor.o: $(SRCROOT)/gap4/template.h
+tagEditor.o: $(SRCROOT)/gap4/tkEdNames.h
+tagEditor.o: $(SRCROOT)/gap4/tkEditor.h
+tagEditor.o: $(SRCROOT)/gap4/tman_display.h
+tagEditor.o: $(SRCROOT)/gap4/undo.h
+tagEditor.o: $(SRCROOT)/primer3/src/dpal.h
+tagEditor.o: $(SRCROOT)/primer3/src/primer3.h
+tagEditor.o: $(SRCROOT)/tk_utils/cli_arg.h
+tagEditor.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tagEditor.o: $(SRCROOT)/tk_utils/postscript.h
+tagEditor.o: $(SRCROOT)/tk_utils/sheet.h
+tagEditor.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tagEditor.o: $(SRCROOT)/tk_utils/tkSheet.h
+tagEditor.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tagEditor.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tagEditor.o: $(SRCROOT)/tk_utils/tkTrace.h
 tagU1.o: $(PWD)/staden_config.h
+tagU1.o: $(SRCROOT)/Misc/array.h
+tagU1.o: $(SRCROOT)/Misc/bitmap.h
+tagU1.o: $(SRCROOT)/Misc/dstring.h
+tagU1.o: $(SRCROOT)/Misc/misc.h
+tagU1.o: $(SRCROOT)/Misc/os.h
+tagU1.o: $(SRCROOT)/Misc/xalloc.h
+tagU1.o: $(SRCROOT)/Misc/xerror.h
+tagU1.o: $(SRCROOT)/g/freetree.h
+tagU1.o: $(SRCROOT)/g/g-defs.h
+tagU1.o: $(SRCROOT)/g/g-error.h
+tagU1.o: $(SRCROOT)/g/g-filedefs.h
+tagU1.o: $(SRCROOT)/g/g-os.h
+tagU1.o: $(SRCROOT)/g/g-struct.h
+tagU1.o: $(SRCROOT)/gap4/IO1.h
+tagU1.o: $(SRCROOT)/gap4/active_tags.h
+tagU1.o: $(SRCROOT)/gap4/contigEditor.h
+tagU1.o: $(SRCROOT)/gap4/edStructs.h
+tagU1.o: $(SRCROOT)/gap4/edUtils.h
+tagU1.o: $(SRCROOT)/gap4/fort.h
+tagU1.o: $(SRCROOT)/gap4/fortran.h
+tagU1.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tagU1.o: $(SRCROOT)/gap4/gap-if.h
+tagU1.o: $(SRCROOT)/gap4/io-reg.h
+tagU1.o: $(SRCROOT)/gap4/io_handle.h
+tagU1.o: $(SRCROOT)/gap4/io_utils.h
+tagU1.o: $(SRCROOT)/gap4/list.h
+tagU1.o: $(SRCROOT)/gap4/notedb.h
+tagU1.o: $(SRCROOT)/gap4/primlib.h
+tagU1.o: $(SRCROOT)/gap4/qual.h
+tagU1.o: $(SRCROOT)/gap4/select.h
+tagU1.o: $(SRCROOT)/gap4/tagDefs.h
+tagU1.o: $(SRCROOT)/gap4/tagUtils.h
+tagU1.o: $(SRCROOT)/gap4/tagdb.h
+tagU1.o: $(SRCROOT)/gap4/template.h
+tagU1.o: $(SRCROOT)/gap4/tkEdNames.h
+tagU1.o: $(SRCROOT)/gap4/tkEditor.h
+tagU1.o: $(SRCROOT)/gap4/tman_display.h
+tagU1.o: $(SRCROOT)/gap4/undo.h
+tagU1.o: $(SRCROOT)/primer3/src/dpal.h
+tagU1.o: $(SRCROOT)/primer3/src/primer3.h
+tagU1.o: $(SRCROOT)/seq_utils/dna_utils.h
+tagU1.o: $(SRCROOT)/tk_utils/cli_arg.h
+tagU1.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tagU1.o: $(SRCROOT)/tk_utils/postscript.h
+tagU1.o: $(SRCROOT)/tk_utils/sheet.h
+tagU1.o: $(SRCROOT)/tk_utils/tkSheet.h
+tagU1.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tagU1.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tagU1.o: $(SRCROOT)/tk_utils/tkTrace.h
 tagU2.o: $(PWD)/staden_config.h
+tagU2.o: $(SRCROOT)/Misc/FtoC.h
+tagU2.o: $(SRCROOT)/Misc/array.h
+tagU2.o: $(SRCROOT)/Misc/bitmap.h
+tagU2.o: $(SRCROOT)/Misc/dstring.h
+tagU2.o: $(SRCROOT)/Misc/misc.h
+tagU2.o: $(SRCROOT)/Misc/os.h
+tagU2.o: $(SRCROOT)/Misc/xalloc.h
+tagU2.o: $(SRCROOT)/Misc/xerror.h
+tagU2.o: $(SRCROOT)/g/freetree.h
+tagU2.o: $(SRCROOT)/g/g-defs.h
+tagU2.o: $(SRCROOT)/g/g-error.h
+tagU2.o: $(SRCROOT)/g/g-filedefs.h
+tagU2.o: $(SRCROOT)/g/g-os.h
+tagU2.o: $(SRCROOT)/g/g-struct.h
+tagU2.o: $(SRCROOT)/gap4/IO1.h
+tagU2.o: $(SRCROOT)/gap4/active_tags.h
+tagU2.o: $(SRCROOT)/gap4/contigEditor.h
+tagU2.o: $(SRCROOT)/gap4/dbcheck.h
+tagU2.o: $(SRCROOT)/gap4/edStructs.h
+tagU2.o: $(SRCROOT)/gap4/edUtils.h
+tagU2.o: $(SRCROOT)/gap4/fort.h
+tagU2.o: $(SRCROOT)/gap4/fortran.h
+tagU2.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tagU2.o: $(SRCROOT)/gap4/gap-if.h
+tagU2.o: $(SRCROOT)/gap4/gap_globals.h
+tagU2.o: $(SRCROOT)/gap4/io-reg.h
+tagU2.o: $(SRCROOT)/gap4/io_handle.h
+tagU2.o: $(SRCROOT)/gap4/io_utils.h
+tagU2.o: $(SRCROOT)/gap4/list.h
+tagU2.o: $(SRCROOT)/gap4/primlib.h
+tagU2.o: $(SRCROOT)/gap4/qual.h
+tagU2.o: $(SRCROOT)/gap4/qualIO.h
+tagU2.o: $(SRCROOT)/gap4/tagDefs.h
+tagU2.o: $(SRCROOT)/gap4/tagUtils.h
+tagU2.o: $(SRCROOT)/gap4/tagdb.h
+tagU2.o: $(SRCROOT)/gap4/template.h
+tagU2.o: $(SRCROOT)/gap4/tkEdNames.h
+tagU2.o: $(SRCROOT)/gap4/tkEditor.h
+tagU2.o: $(SRCROOT)/gap4/tman_display.h
+tagU2.o: $(SRCROOT)/gap4/undo.h
+tagU2.o: $(SRCROOT)/primer3/src/dpal.h
+tagU2.o: $(SRCROOT)/primer3/src/primer3.h
+tagU2.o: $(SRCROOT)/tk_utils/cli_arg.h
+tagU2.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tagU2.o: $(SRCROOT)/tk_utils/postscript.h
+tagU2.o: $(SRCROOT)/tk_utils/sheet.h
+tagU2.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tagU2.o: $(SRCROOT)/tk_utils/text_output.h
+tagU2.o: $(SRCROOT)/tk_utils/tkSheet.h
+tagU2.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tagU2.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tagU2.o: $(SRCROOT)/tk_utils/tkTrace.h
 tagdb.o: $(PWD)/staden_config.h
+tagdb.o: $(SRCROOT)/Misc/misc.h
+tagdb.o: $(SRCROOT)/Misc/os.h
+tagdb.o: $(SRCROOT)/Misc/parse_db.h
+tagdb.o: $(SRCROOT)/Misc/xalloc.h
+tagdb.o: $(SRCROOT)/gap4/tagdb.h
+tagdb.o: $(SRCROOT)/tk_utils/intrinsic_type.h
 template.o: $(PWD)/staden_config.h
+template.o: $(SRCROOT)/Misc/array.h
+template.o: $(SRCROOT)/Misc/bitmap.h
+template.o: $(SRCROOT)/Misc/dstring.h
+template.o: $(SRCROOT)/Misc/misc.h
+template.o: $(SRCROOT)/Misc/os.h
+template.o: $(SRCROOT)/Misc/xalloc.h
+template.o: $(SRCROOT)/Misc/xerror.h
+template.o: $(SRCROOT)/g/freetree.h
+template.o: $(SRCROOT)/g/g-defs.h
+template.o: $(SRCROOT)/g/g-error.h
+template.o: $(SRCROOT)/g/g-filedefs.h
+template.o: $(SRCROOT)/g/g-os.h
+template.o: $(SRCROOT)/g/g-struct.h
+template.o: $(SRCROOT)/gap4/IO1.h
+template.o: $(SRCROOT)/gap4/edStructs.h
+template.o: $(SRCROOT)/gap4/edUtils.h
+template.o: $(SRCROOT)/gap4/fort.h
+template.o: $(SRCROOT)/gap4/fortran.h
+template.o: $(SRCROOT)/gap4/gap-dbstruct.h
+template.o: $(SRCROOT)/gap4/gap-if.h
+template.o: $(SRCROOT)/gap4/gap_globals.h
+template.o: $(SRCROOT)/gap4/io-reg.h
+template.o: $(SRCROOT)/gap4/io_handle.h
+template.o: $(SRCROOT)/gap4/io_utils.h
+template.o: $(SRCROOT)/gap4/list.h
+template.o: $(SRCROOT)/gap4/primlib.h
+template.o: $(SRCROOT)/gap4/qual.h
+template.o: $(SRCROOT)/gap4/tagDefs.h
+template.o: $(SRCROOT)/gap4/tagUtils.h
+template.o: $(SRCROOT)/gap4/template.h
+template.o: $(SRCROOT)/gap4/tkEdNames.h
+template.o: $(SRCROOT)/gap4/tkEditor.h
+template.o: $(SRCROOT)/gap4/tman_display.h
+template.o: $(SRCROOT)/gap4/undo.h
+template.o: $(SRCROOT)/primer3/src/dpal.h
+template.o: $(SRCROOT)/primer3/src/primer3.h
+template.o: $(SRCROOT)/tk_utils/cli_arg.h
+template.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+template.o: $(SRCROOT)/tk_utils/postscript.h
+template.o: $(SRCROOT)/tk_utils/sheet.h
+template.o: $(SRCROOT)/tk_utils/tcl_utils.h
+template.o: $(SRCROOT)/tk_utils/tkSheet.h
+template.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+template.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+template.o: $(SRCROOT)/tk_utils/tkTrace.h
 template_display.o: $(PWD)/staden_config.h
+template_display.o: $(SRCROOT)/Misc/FtoC.h
+template_display.o: $(SRCROOT)/Misc/array.h
+template_display.o: $(SRCROOT)/Misc/bitmap.h
+template_display.o: $(SRCROOT)/Misc/dstring.h
+template_display.o: $(SRCROOT)/Misc/misc.h
+template_display.o: $(SRCROOT)/Misc/os.h
+template_display.o: $(SRCROOT)/Misc/vlen.h
+template_display.o: $(SRCROOT)/Misc/xalloc.h
+template_display.o: $(SRCROOT)/Misc/xerror.h
+template_display.o: $(SRCROOT)/g/freetree.h
+template_display.o: $(SRCROOT)/g/g-defs.h
+template_display.o: $(SRCROOT)/g/g-error.h
+template_display.o: $(SRCROOT)/g/g-filedefs.h
+template_display.o: $(SRCROOT)/g/g-os.h
+template_display.o: $(SRCROOT)/g/g-struct.h
+template_display.o: $(SRCROOT)/gap4/IO1.h
+template_display.o: $(SRCROOT)/gap4/active_tags.h
+template_display.o: $(SRCROOT)/gap4/contig_selector.h
+template_display.o: $(SRCROOT)/gap4/cs-object.h
+template_display.o: $(SRCROOT)/gap4/edStructs.h
+template_display.o: $(SRCROOT)/gap4/edUtils.h
+template_display.o: $(SRCROOT)/gap4/fort.h
+template_display.o: $(SRCROOT)/gap4/fortran.h
+template_display.o: $(SRCROOT)/gap4/gap-dbstruct.h
+template_display.o: $(SRCROOT)/gap4/gap-if.h
+template_display.o: $(SRCROOT)/gap4/gap_canvas_box.h
+template_display.o: $(SRCROOT)/gap4/gap_globals.h
+template_display.o: $(SRCROOT)/gap4/hash.h
+template_display.o: $(SRCROOT)/gap4/io-reg.h
+template_display.o: $(SRCROOT)/gap4/io_handle.h
+template_display.o: $(SRCROOT)/gap4/io_utils.h
+template_display.o: $(SRCROOT)/gap4/list.h
+template_display.o: $(SRCROOT)/gap4/primlib.h
+template_display.o: $(SRCROOT)/gap4/qual.h
+template_display.o: $(SRCROOT)/gap4/ruler_display.h
+template_display.o: $(SRCROOT)/gap4/tagDefs.h
+template_display.o: $(SRCROOT)/gap4/tagUtils.h
+template_display.o: $(SRCROOT)/gap4/tagdb.h
+template_display.o: $(SRCROOT)/gap4/template.h
+template_display.o: $(SRCROOT)/gap4/template_display.h
+template_display.o: $(SRCROOT)/gap4/tkEdNames.h
+template_display.o: $(SRCROOT)/gap4/tkEditor.h
+template_display.o: $(SRCROOT)/gap4/tman_display.h
+template_display.o: $(SRCROOT)/gap4/undo.h
+template_display.o: $(SRCROOT)/primer3/src/dpal.h
+template_display.o: $(SRCROOT)/primer3/src/primer3.h
+template_display.o: $(SRCROOT)/tk_utils/canvas_box.h
+template_display.o: $(SRCROOT)/tk_utils/cli_arg.h
+template_display.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+template_display.o: $(SRCROOT)/tk_utils/postscript.h
+template_display.o: $(SRCROOT)/tk_utils/ruler_tick.h
+template_display.o: $(SRCROOT)/tk_utils/sheet.h
+template_display.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+template_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
+template_display.o: $(SRCROOT)/tk_utils/text_output.h
+template_display.o: $(SRCROOT)/tk_utils/tkSheet.h
+template_display.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+template_display.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+template_display.o: $(SRCROOT)/tk_utils/tkTrace.h
 text-io-reg.o: $(PWD)/staden_config.h
+text-io-reg.o: $(SRCROOT)/Misc/array.h
+text-io-reg.o: $(SRCROOT)/Misc/bitmap.h
+text-io-reg.o: $(SRCROOT)/Misc/os.h
+text-io-reg.o: $(SRCROOT)/Misc/xerror.h
+text-io-reg.o: $(SRCROOT)/g/freetree.h
+text-io-reg.o: $(SRCROOT)/g/g-defs.h
+text-io-reg.o: $(SRCROOT)/g/g-error.h
+text-io-reg.o: $(SRCROOT)/g/g-filedefs.h
+text-io-reg.o: $(SRCROOT)/g/g-os.h
+text-io-reg.o: $(SRCROOT)/g/g-struct.h
+text-io-reg.o: $(SRCROOT)/gap4/IO1.h
+text-io-reg.o: $(SRCROOT)/gap4/gap-dbstruct.h
+text-io-reg.o: $(SRCROOT)/gap4/gap-if.h
+text-io-reg.o: $(SRCROOT)/gap4/io_handle.h
+text-io-reg.o: $(SRCROOT)/gap4/io_utils.h
 tk-io-reg.o: $(PWD)/staden_config.h
+tk-io-reg.o: $(SRCROOT)/Misc/array.h
+tk-io-reg.o: $(SRCROOT)/Misc/bitmap.h
+tk-io-reg.o: $(SRCROOT)/Misc/misc.h
+tk-io-reg.o: $(SRCROOT)/Misc/os.h
+tk-io-reg.o: $(SRCROOT)/Misc/xalloc.h
+tk-io-reg.o: $(SRCROOT)/Misc/xerror.h
+tk-io-reg.o: $(SRCROOT)/g/freetree.h
+tk-io-reg.o: $(SRCROOT)/g/g-defs.h
+tk-io-reg.o: $(SRCROOT)/g/g-error.h
+tk-io-reg.o: $(SRCROOT)/g/g-filedefs.h
+tk-io-reg.o: $(SRCROOT)/g/g-os.h
+tk-io-reg.o: $(SRCROOT)/g/g-struct.h
+tk-io-reg.o: $(SRCROOT)/gap4/IO1.h
+tk-io-reg.o: $(SRCROOT)/gap4/consistency_display.h
+tk-io-reg.o: $(SRCROOT)/gap4/contig_selector.h
+tk-io-reg.o: $(SRCROOT)/gap4/cs-object.h
+tk-io-reg.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tk-io-reg.o: $(SRCROOT)/gap4/gap-if.h
+tk-io-reg.o: $(SRCROOT)/gap4/gap_cli_arg.h
+tk-io-reg.o: $(SRCROOT)/gap4/gap_globals.h
+tk-io-reg.o: $(SRCROOT)/gap4/hash.h
+tk-io-reg.o: $(SRCROOT)/gap4/io-reg.h
+tk-io-reg.o: $(SRCROOT)/gap4/io_handle.h
+tk-io-reg.o: $(SRCROOT)/gap4/io_utils.h
+tk-io-reg.o: $(SRCROOT)/gap4/list.h
+tk-io-reg.o: $(SRCROOT)/gap4/newgap_cmds.h
+tk-io-reg.o: $(SRCROOT)/gap4/newgap_structs.h
+tk-io-reg.o: $(SRCROOT)/gap4/ruler_display.h
+tk-io-reg.o: $(SRCROOT)/gap4/template.h
+tk-io-reg.o: $(SRCROOT)/gap4/template_display.h
+tk-io-reg.o: $(SRCROOT)/gap4/tk-io-reg.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/canvas_box.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/cli_arg.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/tcl_utils.h
 tkEdNames.o: $(PWD)/staden_config.h
+tkEdNames.o: $(SRCROOT)/Misc/array.h
+tkEdNames.o: $(SRCROOT)/Misc/bitmap.h
+tkEdNames.o: $(SRCROOT)/Misc/dstring.h
+tkEdNames.o: $(SRCROOT)/Misc/misc.h
+tkEdNames.o: $(SRCROOT)/Misc/os.h
+tkEdNames.o: $(SRCROOT)/Misc/xalloc.h
+tkEdNames.o: $(SRCROOT)/Misc/xerror.h
+tkEdNames.o: $(SRCROOT)/g/freetree.h
+tkEdNames.o: $(SRCROOT)/g/g-defs.h
+tkEdNames.o: $(SRCROOT)/g/g-error.h
+tkEdNames.o: $(SRCROOT)/g/g-filedefs.h
+tkEdNames.o: $(SRCROOT)/g/g-os.h
+tkEdNames.o: $(SRCROOT)/g/g-struct.h
+tkEdNames.o: $(SRCROOT)/gap4/IO1.h
+tkEdNames.o: $(SRCROOT)/gap4/edStructs.h
+tkEdNames.o: $(SRCROOT)/gap4/edUtils.h
+tkEdNames.o: $(SRCROOT)/gap4/fort.h
+tkEdNames.o: $(SRCROOT)/gap4/fortran.h
+tkEdNames.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tkEdNames.o: $(SRCROOT)/gap4/gap-if.h
+tkEdNames.o: $(SRCROOT)/gap4/io-reg.h
+tkEdNames.o: $(SRCROOT)/gap4/io_handle.h
+tkEdNames.o: $(SRCROOT)/gap4/io_utils.h
+tkEdNames.o: $(SRCROOT)/gap4/list.h
+tkEdNames.o: $(SRCROOT)/gap4/notes.h
+tkEdNames.o: $(SRCROOT)/gap4/primlib.h
+tkEdNames.o: $(SRCROOT)/gap4/qual.h
+tkEdNames.o: $(SRCROOT)/gap4/tagDefs.h
+tkEdNames.o: $(SRCROOT)/gap4/tagUtils.h
+tkEdNames.o: $(SRCROOT)/gap4/template.h
+tkEdNames.o: $(SRCROOT)/gap4/tkEdNames.h
+tkEdNames.o: $(SRCROOT)/gap4/tkEditor.h
+tkEdNames.o: $(SRCROOT)/gap4/tman_display.h
+tkEdNames.o: $(SRCROOT)/gap4/undo.h
+tkEdNames.o: $(SRCROOT)/primer3/src/dpal.h
+tkEdNames.o: $(SRCROOT)/primer3/src/primer3.h
+tkEdNames.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkEdNames.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkEdNames.o: $(SRCROOT)/tk_utils/postscript.h
+tkEdNames.o: $(SRCROOT)/tk_utils/sheet.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tk_defs.h
 tkEdUtils.o: $(PWD)/staden_config.h
+tkEdUtils.o: $(SRCROOT)/Misc/array.h
+tkEdUtils.o: $(SRCROOT)/Misc/bitmap.h
+tkEdUtils.o: $(SRCROOT)/Misc/dstring.h
+tkEdUtils.o: $(SRCROOT)/Misc/misc.h
+tkEdUtils.o: $(SRCROOT)/Misc/os.h
+tkEdUtils.o: $(SRCROOT)/Misc/xalloc.h
+tkEdUtils.o: $(SRCROOT)/Misc/xerror.h
+tkEdUtils.o: $(SRCROOT)/g/freetree.h
+tkEdUtils.o: $(SRCROOT)/g/g-defs.h
+tkEdUtils.o: $(SRCROOT)/g/g-error.h
+tkEdUtils.o: $(SRCROOT)/g/g-filedefs.h
+tkEdUtils.o: $(SRCROOT)/g/g-os.h
+tkEdUtils.o: $(SRCROOT)/g/g-struct.h
+tkEdUtils.o: $(SRCROOT)/gap4/IO1.h
+tkEdUtils.o: $(SRCROOT)/gap4/edStructs.h
+tkEdUtils.o: $(SRCROOT)/gap4/edUtils.h
+tkEdUtils.o: $(SRCROOT)/gap4/fort.h
+tkEdUtils.o: $(SRCROOT)/gap4/fortran.h
+tkEdUtils.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tkEdUtils.o: $(SRCROOT)/gap4/gap-if.h
+tkEdUtils.o: $(SRCROOT)/gap4/gap_globals.h
+tkEdUtils.o: $(SRCROOT)/gap4/io-reg.h
+tkEdUtils.o: $(SRCROOT)/gap4/io_handle.h
+tkEdUtils.o: $(SRCROOT)/gap4/io_utils.h
+tkEdUtils.o: $(SRCROOT)/gap4/list.h
+tkEdUtils.o: $(SRCROOT)/gap4/notedb.h
+tkEdUtils.o: $(SRCROOT)/gap4/primlib.h
+tkEdUtils.o: $(SRCROOT)/gap4/qual.h
+tkEdUtils.o: $(SRCROOT)/gap4/tagDefs.h
+tkEdUtils.o: $(SRCROOT)/gap4/tagUtils.h
+tkEdUtils.o: $(SRCROOT)/gap4/template.h
+tkEdUtils.o: $(SRCROOT)/gap4/tkEdNames.h
+tkEdUtils.o: $(SRCROOT)/gap4/tkEditor.h
+tkEdUtils.o: $(SRCROOT)/gap4/tman_display.h
+tkEdUtils.o: $(SRCROOT)/gap4/tman_interface.h
+tkEdUtils.o: $(SRCROOT)/gap4/undo.h
+tkEdUtils.o: $(SRCROOT)/primer3/src/dpal.h
+tkEdUtils.o: $(SRCROOT)/primer3/src/primer3.h
+tkEdUtils.o: $(SRCROOT)/seq_utils/dna_utils.h
+tkEdUtils.o: $(SRCROOT)/seq_utils/genetic_code.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/postscript.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/sheet.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkEdUtils.o: $(SRCROOT)/tk_utils/tkTrace.h
 tkEditor.o: $(PWD)/staden_config.h
+tkEditor.o: $(SRCROOT)/Misc/array.h
+tkEditor.o: $(SRCROOT)/Misc/bitmap.h
+tkEditor.o: $(SRCROOT)/Misc/dstring.h
+tkEditor.o: $(SRCROOT)/Misc/misc.h
+tkEditor.o: $(SRCROOT)/Misc/os.h
+tkEditor.o: $(SRCROOT)/Misc/xalloc.h
+tkEditor.o: $(SRCROOT)/Misc/xerror.h
+tkEditor.o: $(SRCROOT)/g/freetree.h
+tkEditor.o: $(SRCROOT)/g/g-defs.h
+tkEditor.o: $(SRCROOT)/g/g-error.h
+tkEditor.o: $(SRCROOT)/g/g-filedefs.h
+tkEditor.o: $(SRCROOT)/g/g-os.h
+tkEditor.o: $(SRCROOT)/g/g-struct.h
+tkEditor.o: $(SRCROOT)/gap4/IO1.h
+tkEditor.o: $(SRCROOT)/gap4/contigEditor.h
+tkEditor.o: $(SRCROOT)/gap4/edCommands.h
+tkEditor.o: $(SRCROOT)/gap4/edStructs.h
+tkEditor.o: $(SRCROOT)/gap4/edUtils.h
+tkEditor.o: $(SRCROOT)/gap4/fort.h
+tkEditor.o: $(SRCROOT)/gap4/fortran.h
+tkEditor.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tkEditor.o: $(SRCROOT)/gap4/gap-if.h
+tkEditor.o: $(SRCROOT)/gap4/gap_globals.h
+tkEditor.o: $(SRCROOT)/gap4/io-reg.h
+tkEditor.o: $(SRCROOT)/gap4/io_handle.h
+tkEditor.o: $(SRCROOT)/gap4/io_utils.h
+tkEditor.o: $(SRCROOT)/gap4/list.h
+tkEditor.o: $(SRCROOT)/gap4/oligo.h
+tkEditor.o: $(SRCROOT)/gap4/primlib.h
+tkEditor.o: $(SRCROOT)/gap4/qual.h
+tkEditor.o: $(SRCROOT)/gap4/tagDefs.h
+tkEditor.o: $(SRCROOT)/gap4/tagUtils.h
+tkEditor.o: $(SRCROOT)/gap4/template.h
+tkEditor.o: $(SRCROOT)/gap4/tkEdNames.h
+tkEditor.o: $(SRCROOT)/gap4/tkEditor.h
+tkEditor.o: $(SRCROOT)/gap4/tman_display.h
+tkEditor.o: $(SRCROOT)/gap4/tman_interface.h
+tkEditor.o: $(SRCROOT)/gap4/undo.h
+tkEditor.o: $(SRCROOT)/primer3/src/dpal.h
+tkEditor.o: $(SRCROOT)/primer3/src/primer3.h
+tkEditor.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkEditor.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkEditor.o: $(SRCROOT)/tk_utils/postscript.h
+tkEditor.o: $(SRCROOT)/tk_utils/sheet.h
+tkEditor.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkEditor.o: $(SRCROOT)/tk_utils/tk_defs.h
 tman_cons.o: $(PWD)/staden_config.h
+tman_cons.o: $(SRCROOT)/Misc/array.h
+tman_cons.o: $(SRCROOT)/Misc/bitmap.h
+tman_cons.o: $(SRCROOT)/Misc/dstring.h
+tman_cons.o: $(SRCROOT)/Misc/misc.h
+tman_cons.o: $(SRCROOT)/Misc/os.h
+tman_cons.o: $(SRCROOT)/Misc/xalloc.h
+tman_cons.o: $(SRCROOT)/Misc/xerror.h
+tman_cons.o: $(SRCROOT)/g/freetree.h
+tman_cons.o: $(SRCROOT)/g/g-defs.h
+tman_cons.o: $(SRCROOT)/g/g-error.h
+tman_cons.o: $(SRCROOT)/g/g-filedefs.h
+tman_cons.o: $(SRCROOT)/g/g-os.h
+tman_cons.o: $(SRCROOT)/g/g-struct.h
+tman_cons.o: $(SRCROOT)/gap4/IO1.h
+tman_cons.o: $(SRCROOT)/gap4/edStructs.h
+tman_cons.o: $(SRCROOT)/gap4/edUtils.h
+tman_cons.o: $(SRCROOT)/gap4/fort.h
+tman_cons.o: $(SRCROOT)/gap4/fortran.h
+tman_cons.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tman_cons.o: $(SRCROOT)/gap4/gap-if.h
+tman_cons.o: $(SRCROOT)/gap4/gap_globals.h
+tman_cons.o: $(SRCROOT)/gap4/io-reg.h
+tman_cons.o: $(SRCROOT)/gap4/io_handle.h
+tman_cons.o: $(SRCROOT)/gap4/io_utils.h
+tman_cons.o: $(SRCROOT)/gap4/list.h
+tman_cons.o: $(SRCROOT)/gap4/primlib.h
+tman_cons.o: $(SRCROOT)/gap4/qual.h
+tman_cons.o: $(SRCROOT)/gap4/tagDefs.h
+tman_cons.o: $(SRCROOT)/gap4/tagUtils.h
+tman_cons.o: $(SRCROOT)/gap4/template.h
+tman_cons.o: $(SRCROOT)/gap4/tkEdNames.h
+tman_cons.o: $(SRCROOT)/gap4/tkEditor.h
+tman_cons.o: $(SRCROOT)/gap4/tman_display.h
+tman_cons.o: $(SRCROOT)/gap4/tman_interface.h
+tman_cons.o: $(SRCROOT)/gap4/undo.h
+tman_cons.o: $(SRCROOT)/primer3/src/dpal.h
+tman_cons.o: $(SRCROOT)/primer3/src/primer3.h
+tman_cons.o: $(SRCROOT)/tk_utils/cli_arg.h
+tman_cons.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tman_cons.o: $(SRCROOT)/tk_utils/postscript.h
+tman_cons.o: $(SRCROOT)/tk_utils/sheet.h
+tman_cons.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tman_cons.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tman_cons.o: $(SRCROOT)/tk_utils/tkSheet.h
+tman_cons.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tman_cons.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tman_cons.o: $(SRCROOT)/tk_utils/tkTrace.h
+tman_cons.o: $(SRCROOT)/tk_utils/tkTraceIO.h
 tman_diff.o: $(PWD)/staden_config.h
+tman_diff.o: $(SRCROOT)/Misc/array.h
+tman_diff.o: $(SRCROOT)/Misc/bitmap.h
+tman_diff.o: $(SRCROOT)/Misc/dstring.h
+tman_diff.o: $(SRCROOT)/Misc/misc.h
+tman_diff.o: $(SRCROOT)/Misc/os.h
+tman_diff.o: $(SRCROOT)/Misc/xalloc.h
+tman_diff.o: $(SRCROOT)/Misc/xerror.h
+tman_diff.o: $(SRCROOT)/g/freetree.h
+tman_diff.o: $(SRCROOT)/g/g-defs.h
+tman_diff.o: $(SRCROOT)/g/g-error.h
+tman_diff.o: $(SRCROOT)/g/g-filedefs.h
+tman_diff.o: $(SRCROOT)/g/g-os.h
+tman_diff.o: $(SRCROOT)/g/g-struct.h
+tman_diff.o: $(SRCROOT)/gap4/IO1.h
+tman_diff.o: $(SRCROOT)/gap4/edStructs.h
+tman_diff.o: $(SRCROOT)/gap4/edUtils.h
+tman_diff.o: $(SRCROOT)/gap4/fort.h
+tman_diff.o: $(SRCROOT)/gap4/fortran.h
+tman_diff.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tman_diff.o: $(SRCROOT)/gap4/gap-if.h
+tman_diff.o: $(SRCROOT)/gap4/gap_globals.h
+tman_diff.o: $(SRCROOT)/gap4/io-reg.h
+tman_diff.o: $(SRCROOT)/gap4/io_handle.h
+tman_diff.o: $(SRCROOT)/gap4/io_utils.h
+tman_diff.o: $(SRCROOT)/gap4/list.h
+tman_diff.o: $(SRCROOT)/gap4/primlib.h
+tman_diff.o: $(SRCROOT)/gap4/qual.h
+tman_diff.o: $(SRCROOT)/gap4/tagDefs.h
+tman_diff.o: $(SRCROOT)/gap4/tagUtils.h
+tman_diff.o: $(SRCROOT)/gap4/template.h
+tman_diff.o: $(SRCROOT)/gap4/tkEdNames.h
+tman_diff.o: $(SRCROOT)/gap4/tkEditor.h
+tman_diff.o: $(SRCROOT)/gap4/tman_display.h
+tman_diff.o: $(SRCROOT)/gap4/tman_interface.h
+tman_diff.o: $(SRCROOT)/gap4/undo.h
+tman_diff.o: $(SRCROOT)/mutlib/mutlib.h
+tman_diff.o: $(SRCROOT)/mutlib/staden.h
+tman_diff.o: $(SRCROOT)/primer3/src/dpal.h
+tman_diff.o: $(SRCROOT)/primer3/src/primer3.h
+tman_diff.o: $(SRCROOT)/seq_utils/dna_utils.h
+tman_diff.o: $(SRCROOT)/tk_utils/cli_arg.h
+tman_diff.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tman_diff.o: $(SRCROOT)/tk_utils/postscript.h
+tman_diff.o: $(SRCROOT)/tk_utils/sheet.h
+tman_diff.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tman_diff.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tman_diff.o: $(SRCROOT)/tk_utils/tkSheet.h
+tman_diff.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tman_diff.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tman_diff.o: $(SRCROOT)/tk_utils/tkTrace.h
+tman_diff.o: $(SRCROOT)/tk_utils/tkTraceIO.h
 tman_display.o: $(PWD)/staden_config.h
+tman_display.o: $(SRCROOT)/Misc/array.h
+tman_display.o: $(SRCROOT)/Misc/bitmap.h
+tman_display.o: $(SRCROOT)/Misc/dstring.h
+tman_display.o: $(SRCROOT)/Misc/misc.h
+tman_display.o: $(SRCROOT)/Misc/os.h
+tman_display.o: $(SRCROOT)/Misc/xalloc.h
+tman_display.o: $(SRCROOT)/Misc/xerror.h
+tman_display.o: $(SRCROOT)/g/freetree.h
+tman_display.o: $(SRCROOT)/g/g-defs.h
+tman_display.o: $(SRCROOT)/g/g-error.h
+tman_display.o: $(SRCROOT)/g/g-filedefs.h
+tman_display.o: $(SRCROOT)/g/g-os.h
+tman_display.o: $(SRCROOT)/g/g-struct.h
+tman_display.o: $(SRCROOT)/gap4/IO1.h
+tman_display.o: $(SRCROOT)/gap4/edStructs.h
+tman_display.o: $(SRCROOT)/gap4/edUtils.h
+tman_display.o: $(SRCROOT)/gap4/fort.h
+tman_display.o: $(SRCROOT)/gap4/fortran.h
+tman_display.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tman_display.o: $(SRCROOT)/gap4/gap-if.h
+tman_display.o: $(SRCROOT)/gap4/gap_globals.h
+tman_display.o: $(SRCROOT)/gap4/io-reg.h
+tman_display.o: $(SRCROOT)/gap4/io_handle.h
+tman_display.o: $(SRCROOT)/gap4/io_utils.h
+tman_display.o: $(SRCROOT)/gap4/list.h
+tman_display.o: $(SRCROOT)/gap4/primlib.h
+tman_display.o: $(SRCROOT)/gap4/qual.h
+tman_display.o: $(SRCROOT)/gap4/tagDefs.h
+tman_display.o: $(SRCROOT)/gap4/tagUtils.h
+tman_display.o: $(SRCROOT)/gap4/template.h
+tman_display.o: $(SRCROOT)/gap4/tkEdNames.h
+tman_display.o: $(SRCROOT)/gap4/tkEditor.h
+tman_display.o: $(SRCROOT)/gap4/tman_display.h
+tman_display.o: $(SRCROOT)/gap4/tman_interface.h
+tman_display.o: $(SRCROOT)/gap4/undo.h
+tman_display.o: $(SRCROOT)/primer3/src/dpal.h
+tman_display.o: $(SRCROOT)/primer3/src/primer3.h
+tman_display.o: $(SRCROOT)/tk_utils/cli_arg.h
+tman_display.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tman_display.o: $(SRCROOT)/tk_utils/postscript.h
+tman_display.o: $(SRCROOT)/tk_utils/sheet.h
+tman_display.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tman_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tman_display.o: $(SRCROOT)/tk_utils/tkSheet.h
+tman_display.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tman_display.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tman_display.o: $(SRCROOT)/tk_utils/tkTrace.h
 tman_interface.o: $(PWD)/staden_config.h
+tman_interface.o: $(SRCROOT)/Misc/array.h
+tman_interface.o: $(SRCROOT)/Misc/bitmap.h
+tman_interface.o: $(SRCROOT)/Misc/dstring.h
+tman_interface.o: $(SRCROOT)/Misc/misc.h
+tman_interface.o: $(SRCROOT)/Misc/os.h
+tman_interface.o: $(SRCROOT)/Misc/xalloc.h
+tman_interface.o: $(SRCROOT)/Misc/xerror.h
+tman_interface.o: $(SRCROOT)/g/freetree.h
+tman_interface.o: $(SRCROOT)/g/g-defs.h
+tman_interface.o: $(SRCROOT)/g/g-error.h
+tman_interface.o: $(SRCROOT)/g/g-filedefs.h
+tman_interface.o: $(SRCROOT)/g/g-os.h
+tman_interface.o: $(SRCROOT)/g/g-struct.h
+tman_interface.o: $(SRCROOT)/gap4/IO1.h
+tman_interface.o: $(SRCROOT)/gap4/contigEditor.h
+tman_interface.o: $(SRCROOT)/gap4/edStructs.h
+tman_interface.o: $(SRCROOT)/gap4/edUtils.h
+tman_interface.o: $(SRCROOT)/gap4/fort.h
+tman_interface.o: $(SRCROOT)/gap4/fortran.h
+tman_interface.o: $(SRCROOT)/gap4/gap-dbstruct.h
+tman_interface.o: $(SRCROOT)/gap4/gap-if.h
+tman_interface.o: $(SRCROOT)/gap4/io-reg.h
+tman_interface.o: $(SRCROOT)/gap4/io_handle.h
+tman_interface.o: $(SRCROOT)/gap4/io_utils.h
+tman_interface.o: $(SRCROOT)/gap4/list.h
+tman_interface.o: $(SRCROOT)/gap4/primlib.h
+tman_interface.o: $(SRCROOT)/gap4/qual.h
+tman_interface.o: $(SRCROOT)/gap4/tagDefs.h
+tman_interface.o: $(SRCROOT)/gap4/tagUtils.h
+tman_interface.o: $(SRCROOT)/gap4/template.h
+tman_interface.o: $(SRCROOT)/gap4/tkEdNames.h
+tman_interface.o: $(SRCROOT)/gap4/tkEditor.h
+tman_interface.o: $(SRCROOT)/gap4/tman_display.h
+tman_interface.o: $(SRCROOT)/gap4/tman_interface.h
+tman_interface.o: $(SRCROOT)/gap4/undo.h
+tman_interface.o: $(SRCROOT)/primer3/src/dpal.h
+tman_interface.o: $(SRCROOT)/primer3/src/primer3.h
+tman_interface.o: $(SRCROOT)/tk_utils/cli_arg.h
+tman_interface.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tman_interface.o: $(SRCROOT)/tk_utils/postscript.h
+tman_interface.o: $(SRCROOT)/tk_utils/sheet.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkSheet.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkTrace.h
 undo.o: $(PWD)/staden_config.h
+undo.o: $(SRCROOT)/Misc/array.h
+undo.o: $(SRCROOT)/Misc/bitmap.h
+undo.o: $(SRCROOT)/Misc/dstring.h
+undo.o: $(SRCROOT)/Misc/misc.h
+undo.o: $(SRCROOT)/Misc/os.h
+undo.o: $(SRCROOT)/Misc/xalloc.h
+undo.o: $(SRCROOT)/Misc/xerror.h
+undo.o: $(SRCROOT)/g/freetree.h
+undo.o: $(SRCROOT)/g/g-defs.h
+undo.o: $(SRCROOT)/g/g-error.h
+undo.o: $(SRCROOT)/g/g-filedefs.h
+undo.o: $(SRCROOT)/g/g-os.h
+undo.o: $(SRCROOT)/g/g-struct.h
+undo.o: $(SRCROOT)/gap4/IO1.h
+undo.o: $(SRCROOT)/gap4/contigEditor.h
+undo.o: $(SRCROOT)/gap4/edStructs.h
+undo.o: $(SRCROOT)/gap4/edUtils.h
+undo.o: $(SRCROOT)/gap4/extend.h
+undo.o: $(SRCROOT)/gap4/fort.h
+undo.o: $(SRCROOT)/gap4/fortran.h
+undo.o: $(SRCROOT)/gap4/gap-dbstruct.h
+undo.o: $(SRCROOT)/gap4/gap-if.h
+undo.o: $(SRCROOT)/gap4/io-reg.h
+undo.o: $(SRCROOT)/gap4/io_handle.h
+undo.o: $(SRCROOT)/gap4/io_utils.h
+undo.o: $(SRCROOT)/gap4/list.h
+undo.o: $(SRCROOT)/gap4/primlib.h
+undo.o: $(SRCROOT)/gap4/qual.h
+undo.o: $(SRCROOT)/gap4/tagDefs.h
+undo.o: $(SRCROOT)/gap4/tagUtils.h
+undo.o: $(SRCROOT)/gap4/template.h
+undo.o: $(SRCROOT)/gap4/tkEdNames.h
+undo.o: $(SRCROOT)/gap4/tkEditor.h
+undo.o: $(SRCROOT)/gap4/tman_display.h
+undo.o: $(SRCROOT)/gap4/undo.h
+undo.o: $(SRCROOT)/primer3/src/dpal.h
+undo.o: $(SRCROOT)/primer3/src/primer3.h
+undo.o: $(SRCROOT)/tk_utils/cli_arg.h
+undo.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+undo.o: $(SRCROOT)/tk_utils/postscript.h
+undo.o: $(SRCROOT)/tk_utils/sheet.h
+undo.o: $(SRCROOT)/tk_utils/text_output.h
+undo.o: $(SRCROOT)/tk_utils/tkSheet.h
+undo.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+undo.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+undo.o: $(SRCROOT)/tk_utils/tkTrace.h
 vseqs.o: $(PWD)/staden_config.h
+vseqs.o: $(SRCROOT)/Misc/array.h
+vseqs.o: $(SRCROOT)/Misc/bitmap.h
+vseqs.o: $(SRCROOT)/Misc/misc.h
+vseqs.o: $(SRCROOT)/Misc/os.h
+vseqs.o: $(SRCROOT)/Misc/xalloc.h
+vseqs.o: $(SRCROOT)/Misc/xerror.h
+vseqs.o: $(SRCROOT)/g/freetree.h
+vseqs.o: $(SRCROOT)/g/g-defs.h
+vseqs.o: $(SRCROOT)/g/g-error.h
+vseqs.o: $(SRCROOT)/g/g-filedefs.h
+vseqs.o: $(SRCROOT)/g/g-os.h
+vseqs.o: $(SRCROOT)/g/g-struct.h
+vseqs.o: $(SRCROOT)/gap4/IO1.h
+vseqs.o: $(SRCROOT)/gap4/gap-dbstruct.h
+vseqs.o: $(SRCROOT)/gap4/gap-if.h
+vseqs.o: $(SRCROOT)/gap4/io_handle.h
+vseqs.o: $(SRCROOT)/gap4/io_utils.h
+vseqs.o: $(SRCROOT)/gap4/qual.h
+vseqs.o: $(SRCROOT)/gap4/vseqs.h
+vseqs.o: $(SRCROOT)/tk_utils/text_output.h
diff --git a/gap4/contig_editor.tcl b/gap4/contig_editor.tcl
index 00e747b..01b9084 100644
--- a/gap4/contig_editor.tcl
+++ b/gap4/contig_editor.tcl
@@ -108,7 +108,6 @@ proc create_editor {w edname join reveal ccut qcut dbptr {sets {}}} {
 	xtoplevel $w
 	fix_maxsize $w
     }
-    wm resizable $w 1 0
 
     catch {set $w.Grab [grab current]}
     frame $w.grab
@@ -431,26 +430,15 @@ proc create_editor {w edname join reveal ccut qcut dbptr {sets {}}} {
     # Eeek. When the user resizes the window, we need to reset the geometry to
     # {} to allow the editor to specify its own dimensions (it uses the user X
     # size, and its own Y size), otherwise user requested ones are honoured
-    # forever more. If we set wm geometry now then loops ensue.
-    # Doing it when idle still causes loops; why?
-    # So we hack it by waiting a second. Hopefully this doesn't
-    # cause any problems, but it still means it can loop on slow
-    # systems.
-    #
-    # 11th March 2003:
-    # Since upgrading to Tk8.4.0 the editor resizing has broken (it always
-    # jumps back to its original size). However commenting out this "fix"
-    # now fixes the resize problem and it seems that we no longer need this
-    # change anyway.
-    #
-    # 4th May 2004:
-    # It's about time this is totally rewritten! However, I put the hack back
-    # again. Since the change to disable 'SetGrid' on the sheet widget to fix
-    # a bug in the MetaCity wm, this broke twm.
+    # forever more. 
     #
+    # This used to form loops, but I cannot reproduce this on a
+    # variety of window managers so I think it may have been fixed in
+    # newer Tk releases.  If you get looping after resize, add an
+    # after 1000 {...} phrase.
     bind $w <Any-Configure> {
    	if {[winfo toplevel %W] == "%W"} {
-   	    after 1000 {if {[winfo exists %W]} {wm geometry %W {}}}
+   	    wm geometry %W {}
    	}
     }
     SetDefaultTags CONTIG_EDITOR.TAGS $editor
diff --git a/gap4/edMutations.c b/gap4/edMutations.c
index 53ef371..35200c9 100644
--- a/gap4/edMutations.c
+++ b/gap4/edMutations.c
@@ -1244,7 +1244,7 @@ static void store_translation(EdStruct *xx, int pos, int width,
     /* Set the line name */
     sprintf(xx->status_lines[l].name, " %*c %-*s",
 	    DB_GELNOLEN, dir == 0 ? '+' : '-',
-	    DB_NAMELEN, name);
+	    DB_NAMELEN-1, name);
 }
 
 /*
diff --git a/gap4/gap-error.c b/gap4/gap-error.c
index e7f5e2d..caee61f 100644
--- a/gap4/gap-error.c
+++ b/gap4/gap-error.c
@@ -89,7 +89,7 @@ void error_sig(int sig) {
 }
 
 static void xperror_out_func(char *name, char *str) {
-    verror(ERR_FATAL, name, str);
+    verror(ERR_FATAL, name, "%s", str);
 }
 
 /* NOT FATAL */
diff --git a/gap4/gaprc_menu_full b/gap4/gaprc_menu_full
index 1776889..113e7e2 100644
--- a/gap4/gaprc_menu_full
+++ b/gap4/gaprc_menu_full
@@ -199,8 +199,8 @@ add_command	{Help.Introduction}	1 0 {show_help gap4 Gap4-Introduction}
 add_command	{Help.Output Window}	1 0 {show_help interface {UI-Output}}
 add_separator	{Help.S1}
 add_command	{Help.Index}		1 0 {show_help gap4 Index}
-add_separator	{Help.S2}
-add_command	{Help.Show Licence}	1 0 {ShowLicence}
+#add_separator	{Help.S2}
+#add_command	{Help.Show Licence}	1 0 {ShowLicence}
 
 #For testing busy mode
 #add_command	{File.Busy On}	1 2 {SetBusy}
diff --git a/gap4/show_relationships.c b/gap4/show_relationships.c
index a5ce5bb..6b47dcc 100644
--- a/gap4/show_relationships.c
+++ b/gap4/show_relationships.c
@@ -34,7 +34,7 @@ int show_relationships(GapIO *io,
 		cright = io_crnbr(io, contigs[i].contig);
 		
 		/* print contig information */
-		vmessage(contig_line);
+		vmessage("%s", contig_line);
 		vmessage("%25d %8d %15d %8d\n", contigs[i].contig,
 			 clen, cleft, cright);
 	    
@@ -66,7 +66,7 @@ int show_relationships(GapIO *io,
 	} else if (ordered == 0) {
 	
 	    /* print contig information */
-	    vmessage(contig_line);
+	    vmessage("%s", contig_line);
 	
 	    for (i = 0; i < num_contigs; i++){ 
 		clen   = io_clength(io, contigs[i].contig);
@@ -106,7 +106,7 @@ int show_relationships(GapIO *io,
 	    cright = io_crnbr(io, contigs[i].contig);
 	    
 	    /* print contig information */
-	    vmessage(contig_line);
+	    vmessage("%s", contig_line);
 	    vmessage("%25d %8d %15d %8d\n",contigs[i].contig,
 		     clen, cleft, cright);
 	    
diff --git a/gap5/Makefile b/gap5/Makefile
index 6c806de..94a01fb 100644
--- a/gap5/Makefile
+++ b/gap5/Makefile
@@ -59,7 +59,6 @@ TG_IO = \
 	tg_scaffold.o \
 	tg_check.o \
         actf.o \
-	zfio.o \
 	gap_cli_arg.o \
 	tg_tcl.o
 
@@ -143,13 +142,17 @@ GAP5=\
 	break_contig.o \
 	dis_readings.o \
 	export_contigs.o \
+	export_snps.o \
 	find_oligo.o \
 	import_gff.o \
 	shuffle_pads.o \
+	str_finder.o \
 	restriction_enzymes.o \
 	gap_canvas_box.o \
 	contig_extend.o \
 	auto_break.o \
+	find_haplotypes.o \
+	interval_tree.o \
 	$(GOBJS) \
 	$(TG_IO) \
 	$(CEDITOR) \
@@ -157,7 +160,6 @@ GAP5=\
 
 GAP5_LIBS=\
 	$(IOLIB_LIB) \
-	$(SEQUTILS_LIB) \
 	$(TKUTILS_LIB) \
 	$(ZLIB_LIB) \
 	$(LZMA_LIB) \
@@ -184,14 +186,7 @@ TG_IND_OBJ = \
 
 TGILIBS = \
 	$(GAP5_LIB) \
-	$(P3_LIB) \
-	$(ZLIB_LIB) \
-	$(LZMA_LIB) \
-	$(TKUTILS_LIB) \
-	$(SEQUTILS_LIB) \
-	$(TK_LIB) \
-	$(MISC_LIB) \
-	$(IOLIB_LIB)
+	$(GAP5_LIBS)
 
 tg_index.bin: $(TG_IND_OBJ) $(L)/$(SHLIB_PREFIX)$(LIBS)$(SHLIB_SUFFIX)
 	$(CLD) $(LDEXEFLAG)$@$(EXE_SUFFIX) $(TG_IND_OBJ) $(TGILIBS) $(LIBSC)
@@ -229,91 +224,3480 @@ distsrc: distsrc_dirs
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 ace.o: $(PWD)/staden_config.h
+ace.o: $(SRCROOT)/Misc/array.h
+ace.o: $(SRCROOT)/Misc/misc.h
+ace.o: $(SRCROOT)/Misc/os.h
+ace.o: $(SRCROOT)/Misc/string_alloc.h
+ace.o: $(SRCROOT)/Misc/tree.h
+ace.o: $(SRCROOT)/Misc/xalloc.h
+ace.o: $(SRCROOT)/Misc/xerror.h
+ace.o: $(SRCROOT)/gap5/ace.h
+ace.o: $(SRCROOT)/gap5/b+tree2.h
+ace.o: $(SRCROOT)/gap5/g-alloc.h
+ace.o: $(SRCROOT)/gap5/g-connect.h
+ace.o: $(SRCROOT)/gap5/g-db.h
+ace.o: $(SRCROOT)/gap5/g-defs.h
+ace.o: $(SRCROOT)/gap5/g-error.h
+ace.o: $(SRCROOT)/gap5/g-filedefs.h
+ace.o: $(SRCROOT)/gap5/g-io.h
+ace.o: $(SRCROOT)/gap5/g-misc.h
+ace.o: $(SRCROOT)/gap5/g-os.h
+ace.o: $(SRCROOT)/gap5/g-request.h
+ace.o: $(SRCROOT)/gap5/g-struct.h
+ace.o: $(SRCROOT)/gap5/g.h
+ace.o: $(SRCROOT)/gap5/hache_table.h
+ace.o: $(SRCROOT)/gap5/io_utils.h
+ace.o: $(SRCROOT)/gap5/tg_anno.h
+ace.o: $(SRCROOT)/gap5/tg_bin.h
+ace.o: $(SRCROOT)/gap5/tg_cache_item.h
+ace.o: $(SRCROOT)/gap5/tg_contig.h
+ace.o: $(SRCROOT)/gap5/tg_gio.h
+ace.o: $(SRCROOT)/gap5/tg_iface.h
+ace.o: $(SRCROOT)/gap5/tg_index.h
+ace.o: $(SRCROOT)/gap5/tg_index_common.h
+ace.o: $(SRCROOT)/gap5/tg_library.h
+ace.o: $(SRCROOT)/gap5/tg_register.h
+ace.o: $(SRCROOT)/gap5/tg_scaffold.h
+ace.o: $(SRCROOT)/gap5/tg_sequence.h
+ace.o: $(SRCROOT)/gap5/tg_struct.h
+ace.o: $(SRCROOT)/gap5/tg_tcl.h
+ace.o: $(SRCROOT)/gap5/tg_track.h
+ace.o: $(SRCROOT)/gap5/tg_utils.h
+ace.o: $(SRCROOT)/seq_utils/dna_utils.h
 actf.o: $(PWD)/staden_config.h
+actf.o: $(SRCROOT)/Misc/array.h
+actf.o: $(SRCROOT)/Misc/misc.h
+actf.o: $(SRCROOT)/Misc/os.h
+actf.o: $(SRCROOT)/Misc/xalloc.h
+actf.o: $(SRCROOT)/Misc/xerror.h
+actf.o: $(SRCROOT)/gap5/actf.h
+actf.o: $(SRCROOT)/gap5/g-alloc.h
+actf.o: $(SRCROOT)/gap5/g-filedefs.h
+actf.o: $(SRCROOT)/gap5/g-files.h
+actf.o: $(SRCROOT)/gap5/g-os.h
+actf.o: $(SRCROOT)/gap5/g-struct.h
+actf.o: $(SRCROOT)/gap5/hache_table.h
+actf.o: $(SRCROOT)/tk_utils/text_output.h
 active_tags.o: $(PWD)/staden_config.h
+active_tags.o: $(SRCROOT)/Misc/array.h
+active_tags.o: $(SRCROOT)/Misc/misc.h
+active_tags.o: $(SRCROOT)/Misc/os.h
+active_tags.o: $(SRCROOT)/Misc/tree.h
+active_tags.o: $(SRCROOT)/Misc/xalloc.h
+active_tags.o: $(SRCROOT)/Misc/xerror.h
+active_tags.o: $(SRCROOT)/gap5/b+tree2.h
+active_tags.o: $(SRCROOT)/gap5/g-alloc.h
+active_tags.o: $(SRCROOT)/gap5/g-connect.h
+active_tags.o: $(SRCROOT)/gap5/g-db.h
+active_tags.o: $(SRCROOT)/gap5/g-defs.h
+active_tags.o: $(SRCROOT)/gap5/g-error.h
+active_tags.o: $(SRCROOT)/gap5/g-filedefs.h
+active_tags.o: $(SRCROOT)/gap5/g-io.h
+active_tags.o: $(SRCROOT)/gap5/g-misc.h
+active_tags.o: $(SRCROOT)/gap5/g-os.h
+active_tags.o: $(SRCROOT)/gap5/g-request.h
+active_tags.o: $(SRCROOT)/gap5/g-struct.h
+active_tags.o: $(SRCROOT)/gap5/g.h
+active_tags.o: $(SRCROOT)/gap5/hache_table.h
+active_tags.o: $(SRCROOT)/gap5/io_utils.h
+active_tags.o: $(SRCROOT)/gap5/list_proc.h
+active_tags.o: $(SRCROOT)/gap5/tagdb.h
+active_tags.o: $(SRCROOT)/gap5/tg_anno.h
+active_tags.o: $(SRCROOT)/gap5/tg_bin.h
+active_tags.o: $(SRCROOT)/gap5/tg_cache_item.h
+active_tags.o: $(SRCROOT)/gap5/tg_contig.h
+active_tags.o: $(SRCROOT)/gap5/tg_gio.h
+active_tags.o: $(SRCROOT)/gap5/tg_iface.h
+active_tags.o: $(SRCROOT)/gap5/tg_library.h
+active_tags.o: $(SRCROOT)/gap5/tg_register.h
+active_tags.o: $(SRCROOT)/gap5/tg_scaffold.h
+active_tags.o: $(SRCROOT)/gap5/tg_sequence.h
+active_tags.o: $(SRCROOT)/gap5/tg_struct.h
+active_tags.o: $(SRCROOT)/gap5/tg_tcl.h
+active_tags.o: $(SRCROOT)/gap5/tg_track.h
+active_tags.o: $(SRCROOT)/gap5/tg_utils.h
+active_tags.o: $(SRCROOT)/tk_utils/intrinsic_type.h
 afg.o: $(PWD)/staden_config.h
+afg.o: $(SRCROOT)/Misc/array.h
+afg.o: $(SRCROOT)/Misc/misc.h
+afg.o: $(SRCROOT)/Misc/os.h
+afg.o: $(SRCROOT)/Misc/string_alloc.h
+afg.o: $(SRCROOT)/Misc/tree.h
+afg.o: $(SRCROOT)/Misc/xalloc.h
+afg.o: $(SRCROOT)/Misc/xerror.h
+afg.o: $(SRCROOT)/gap5/afg.h
+afg.o: $(SRCROOT)/gap5/b+tree2.h
+afg.o: $(SRCROOT)/gap5/g-alloc.h
+afg.o: $(SRCROOT)/gap5/g-connect.h
+afg.o: $(SRCROOT)/gap5/g-db.h
+afg.o: $(SRCROOT)/gap5/g-defs.h
+afg.o: $(SRCROOT)/gap5/g-error.h
+afg.o: $(SRCROOT)/gap5/g-filedefs.h
+afg.o: $(SRCROOT)/gap5/g-io.h
+afg.o: $(SRCROOT)/gap5/g-misc.h
+afg.o: $(SRCROOT)/gap5/g-os.h
+afg.o: $(SRCROOT)/gap5/g-request.h
+afg.o: $(SRCROOT)/gap5/g-struct.h
+afg.o: $(SRCROOT)/gap5/g.h
+afg.o: $(SRCROOT)/gap5/hache_table.h
+afg.o: $(SRCROOT)/gap5/io_utils.h
+afg.o: $(SRCROOT)/gap5/tg_anno.h
+afg.o: $(SRCROOT)/gap5/tg_bin.h
+afg.o: $(SRCROOT)/gap5/tg_cache_item.h
+afg.o: $(SRCROOT)/gap5/tg_contig.h
+afg.o: $(SRCROOT)/gap5/tg_gio.h
+afg.o: $(SRCROOT)/gap5/tg_iface.h
+afg.o: $(SRCROOT)/gap5/tg_index.h
+afg.o: $(SRCROOT)/gap5/tg_index_common.h
+afg.o: $(SRCROOT)/gap5/tg_library.h
+afg.o: $(SRCROOT)/gap5/tg_register.h
+afg.o: $(SRCROOT)/gap5/tg_scaffold.h
+afg.o: $(SRCROOT)/gap5/tg_sequence.h
+afg.o: $(SRCROOT)/gap5/tg_struct.h
+afg.o: $(SRCROOT)/gap5/tg_tcl.h
+afg.o: $(SRCROOT)/gap5/tg_track.h
+afg.o: $(SRCROOT)/gap5/tg_utils.h
 auto_break.o: $(PWD)/staden_config.h
+auto_break.o: $(SRCROOT)/Misc/array.h
+auto_break.o: $(SRCROOT)/Misc/dstring.h
+auto_break.o: $(SRCROOT)/Misc/misc.h
+auto_break.o: $(SRCROOT)/Misc/os.h
+auto_break.o: $(SRCROOT)/Misc/tree.h
+auto_break.o: $(SRCROOT)/Misc/xalloc.h
+auto_break.o: $(SRCROOT)/Misc/xerror.h
+auto_break.o: $(SRCROOT)/gap5/auto_break.h
+auto_break.o: $(SRCROOT)/gap5/b+tree2.h
+auto_break.o: $(SRCROOT)/gap5/consensus.h
+auto_break.o: $(SRCROOT)/gap5/g-alloc.h
+auto_break.o: $(SRCROOT)/gap5/g-connect.h
+auto_break.o: $(SRCROOT)/gap5/g-db.h
+auto_break.o: $(SRCROOT)/gap5/g-defs.h
+auto_break.o: $(SRCROOT)/gap5/g-error.h
+auto_break.o: $(SRCROOT)/gap5/g-filedefs.h
+auto_break.o: $(SRCROOT)/gap5/g-io.h
+auto_break.o: $(SRCROOT)/gap5/g-misc.h
+auto_break.o: $(SRCROOT)/gap5/g-os.h
+auto_break.o: $(SRCROOT)/gap5/g-request.h
+auto_break.o: $(SRCROOT)/gap5/g-struct.h
+auto_break.o: $(SRCROOT)/gap5/g.h
+auto_break.o: $(SRCROOT)/gap5/gap_globals.h
+auto_break.o: $(SRCROOT)/gap5/hache_table.h
+auto_break.o: $(SRCROOT)/gap5/io_utils.h
+auto_break.o: $(SRCROOT)/gap5/qual.h
+auto_break.o: $(SRCROOT)/gap5/qualIO.h
+auto_break.o: $(SRCROOT)/gap5/tg_anno.h
+auto_break.o: $(SRCROOT)/gap5/tg_bin.h
+auto_break.o: $(SRCROOT)/gap5/tg_cache_item.h
+auto_break.o: $(SRCROOT)/gap5/tg_contig.h
+auto_break.o: $(SRCROOT)/gap5/tg_gio.h
+auto_break.o: $(SRCROOT)/gap5/tg_iface.h
+auto_break.o: $(SRCROOT)/gap5/tg_library.h
+auto_break.o: $(SRCROOT)/gap5/tg_register.h
+auto_break.o: $(SRCROOT)/gap5/tg_scaffold.h
+auto_break.o: $(SRCROOT)/gap5/tg_sequence.h
+auto_break.o: $(SRCROOT)/gap5/tg_struct.h
+auto_break.o: $(SRCROOT)/gap5/tg_tcl.h
+auto_break.o: $(SRCROOT)/gap5/tg_track.h
+auto_break.o: $(SRCROOT)/gap5/tg_utils.h
+auto_break.o: $(SRCROOT)/seq_utils/filter_words.h
+auto_break.o: $(SRCROOT)/tk_utils/tcl_utils.h
+auto_break.o: $(SRCROOT)/tk_utils/text_output.h
 b+tree2.o: $(PWD)/staden_config.h
+b+tree2.o: $(SRCROOT)/Misc/array.h
+b+tree2.o: $(SRCROOT)/Misc/os.h
+b+tree2.o: $(SRCROOT)/Misc/xerror.h
+b+tree2.o: $(SRCROOT)/gap5/b+tree2.h
+b+tree2.o: $(SRCROOT)/gap5/g-alloc.h
+b+tree2.o: $(SRCROOT)/gap5/g-connect.h
+b+tree2.o: $(SRCROOT)/gap5/g-db.h
+b+tree2.o: $(SRCROOT)/gap5/g-defs.h
+b+tree2.o: $(SRCROOT)/gap5/g-error.h
+b+tree2.o: $(SRCROOT)/gap5/g-filedefs.h
+b+tree2.o: $(SRCROOT)/gap5/g-io.h
+b+tree2.o: $(SRCROOT)/gap5/g-misc.h
+b+tree2.o: $(SRCROOT)/gap5/g-os.h
+b+tree2.o: $(SRCROOT)/gap5/g-request.h
+b+tree2.o: $(SRCROOT)/gap5/g-struct.h
+b+tree2.o: $(SRCROOT)/gap5/g.h
+b+tree2.o: $(SRCROOT)/gap5/hache_table.h
+b+tree2.o: $(SRCROOT)/gap5/tg_struct.h
+b+tree2.o: $(SRCROOT)/gap5/tg_utils.h
 baf.o: $(PWD)/staden_config.h
+baf.o: $(SRCROOT)/Misc/array.h
+baf.o: $(SRCROOT)/Misc/misc.h
+baf.o: $(SRCROOT)/Misc/os.h
+baf.o: $(SRCROOT)/Misc/string_alloc.h
+baf.o: $(SRCROOT)/Misc/tree.h
+baf.o: $(SRCROOT)/Misc/xalloc.h
+baf.o: $(SRCROOT)/Misc/xerror.h
+baf.o: $(SRCROOT)/gap5/b+tree2.h
+baf.o: $(SRCROOT)/gap5/baf.h
+baf.o: $(SRCROOT)/gap5/g-alloc.h
+baf.o: $(SRCROOT)/gap5/g-connect.h
+baf.o: $(SRCROOT)/gap5/g-db.h
+baf.o: $(SRCROOT)/gap5/g-defs.h
+baf.o: $(SRCROOT)/gap5/g-error.h
+baf.o: $(SRCROOT)/gap5/g-filedefs.h
+baf.o: $(SRCROOT)/gap5/g-io.h
+baf.o: $(SRCROOT)/gap5/g-misc.h
+baf.o: $(SRCROOT)/gap5/g-os.h
+baf.o: $(SRCROOT)/gap5/g-request.h
+baf.o: $(SRCROOT)/gap5/g-struct.h
+baf.o: $(SRCROOT)/gap5/g.h
+baf.o: $(SRCROOT)/gap5/hache_table.h
+baf.o: $(SRCROOT)/gap5/io_utils.h
+baf.o: $(SRCROOT)/gap5/tg_anno.h
+baf.o: $(SRCROOT)/gap5/tg_bin.h
+baf.o: $(SRCROOT)/gap5/tg_cache_item.h
+baf.o: $(SRCROOT)/gap5/tg_contig.h
+baf.o: $(SRCROOT)/gap5/tg_gio.h
+baf.o: $(SRCROOT)/gap5/tg_iface.h
+baf.o: $(SRCROOT)/gap5/tg_index.h
+baf.o: $(SRCROOT)/gap5/tg_index_common.h
+baf.o: $(SRCROOT)/gap5/tg_library.h
+baf.o: $(SRCROOT)/gap5/tg_register.h
+baf.o: $(SRCROOT)/gap5/tg_scaffold.h
+baf.o: $(SRCROOT)/gap5/tg_sequence.h
+baf.o: $(SRCROOT)/gap5/tg_struct.h
+baf.o: $(SRCROOT)/gap5/tg_tcl.h
+baf.o: $(SRCROOT)/gap5/tg_track.h
+baf.o: $(SRCROOT)/gap5/tg_utils.h
 break_contig.o: $(PWD)/staden_config.h
+break_contig.o: $(SRCROOT)/Misc/array.h
+break_contig.o: $(SRCROOT)/Misc/misc.h
+break_contig.o: $(SRCROOT)/Misc/os.h
+break_contig.o: $(SRCROOT)/Misc/tree.h
+break_contig.o: $(SRCROOT)/Misc/xalloc.h
+break_contig.o: $(SRCROOT)/Misc/xerror.h
+break_contig.o: $(SRCROOT)/gap5/b+tree2.h
+break_contig.o: $(SRCROOT)/gap5/break_contig.h
+break_contig.o: $(SRCROOT)/gap5/consensus.h
+break_contig.o: $(SRCROOT)/gap5/dis_readings.h
+break_contig.o: $(SRCROOT)/gap5/g-alloc.h
+break_contig.o: $(SRCROOT)/gap5/g-connect.h
+break_contig.o: $(SRCROOT)/gap5/g-db.h
+break_contig.o: $(SRCROOT)/gap5/g-defs.h
+break_contig.o: $(SRCROOT)/gap5/g-error.h
+break_contig.o: $(SRCROOT)/gap5/g-filedefs.h
+break_contig.o: $(SRCROOT)/gap5/g-io.h
+break_contig.o: $(SRCROOT)/gap5/g-misc.h
+break_contig.o: $(SRCROOT)/gap5/g-os.h
+break_contig.o: $(SRCROOT)/gap5/g-request.h
+break_contig.o: $(SRCROOT)/gap5/g-struct.h
+break_contig.o: $(SRCROOT)/gap5/g.h
+break_contig.o: $(SRCROOT)/gap5/hache_table.h
+break_contig.o: $(SRCROOT)/gap5/io_utils.h
+break_contig.o: $(SRCROOT)/gap5/tg_anno.h
+break_contig.o: $(SRCROOT)/gap5/tg_bin.h
+break_contig.o: $(SRCROOT)/gap5/tg_cache_item.h
+break_contig.o: $(SRCROOT)/gap5/tg_contig.h
+break_contig.o: $(SRCROOT)/gap5/tg_gio.h
+break_contig.o: $(SRCROOT)/gap5/tg_iface.h
+break_contig.o: $(SRCROOT)/gap5/tg_library.h
+break_contig.o: $(SRCROOT)/gap5/tg_register.h
+break_contig.o: $(SRCROOT)/gap5/tg_scaffold.h
+break_contig.o: $(SRCROOT)/gap5/tg_sequence.h
+break_contig.o: $(SRCROOT)/gap5/tg_struct.h
+break_contig.o: $(SRCROOT)/gap5/tg_tcl.h
+break_contig.o: $(SRCROOT)/gap5/tg_track.h
+break_contig.o: $(SRCROOT)/gap5/tg_utils.h
 caf.o: $(PWD)/staden_config.h
+caf.o: $(SRCROOT)/Misc/array.h
+caf.o: $(SRCROOT)/Misc/misc.h
+caf.o: $(SRCROOT)/Misc/os.h
+caf.o: $(SRCROOT)/Misc/string_alloc.h
+caf.o: $(SRCROOT)/Misc/tree.h
+caf.o: $(SRCROOT)/Misc/xalloc.h
+caf.o: $(SRCROOT)/Misc/xerror.h
+caf.o: $(SRCROOT)/gap5/b+tree2.h
+caf.o: $(SRCROOT)/gap5/caf.h
+caf.o: $(SRCROOT)/gap5/g-alloc.h
+caf.o: $(SRCROOT)/gap5/g-connect.h
+caf.o: $(SRCROOT)/gap5/g-db.h
+caf.o: $(SRCROOT)/gap5/g-defs.h
+caf.o: $(SRCROOT)/gap5/g-error.h
+caf.o: $(SRCROOT)/gap5/g-filedefs.h
+caf.o: $(SRCROOT)/gap5/g-io.h
+caf.o: $(SRCROOT)/gap5/g-misc.h
+caf.o: $(SRCROOT)/gap5/g-os.h
+caf.o: $(SRCROOT)/gap5/g-request.h
+caf.o: $(SRCROOT)/gap5/g-struct.h
+caf.o: $(SRCROOT)/gap5/g.h
+caf.o: $(SRCROOT)/gap5/hache_table.h
+caf.o: $(SRCROOT)/gap5/io_utils.h
+caf.o: $(SRCROOT)/gap5/tg_anno.h
+caf.o: $(SRCROOT)/gap5/tg_bin.h
+caf.o: $(SRCROOT)/gap5/tg_cache_item.h
+caf.o: $(SRCROOT)/gap5/tg_contig.h
+caf.o: $(SRCROOT)/gap5/tg_gio.h
+caf.o: $(SRCROOT)/gap5/tg_iface.h
+caf.o: $(SRCROOT)/gap5/tg_index.h
+caf.o: $(SRCROOT)/gap5/tg_index_common.h
+caf.o: $(SRCROOT)/gap5/tg_library.h
+caf.o: $(SRCROOT)/gap5/tg_register.h
+caf.o: $(SRCROOT)/gap5/tg_scaffold.h
+caf.o: $(SRCROOT)/gap5/tg_sequence.h
+caf.o: $(SRCROOT)/gap5/tg_struct.h
+caf.o: $(SRCROOT)/gap5/tg_tcl.h
+caf.o: $(SRCROOT)/gap5/tg_track.h
+caf.o: $(SRCROOT)/gap5/tg_utils.h
 check_assembly.o: $(PWD)/staden_config.h
+check_assembly.o: $(SRCROOT)/Misc/array.h
+check_assembly.o: $(SRCROOT)/Misc/misc.h
+check_assembly.o: $(SRCROOT)/Misc/os.h
+check_assembly.o: $(SRCROOT)/Misc/tree.h
+check_assembly.o: $(SRCROOT)/Misc/xalloc.h
+check_assembly.o: $(SRCROOT)/Misc/xerror.h
+check_assembly.o: $(SRCROOT)/gap5/b+tree2.h
+check_assembly.o: $(SRCROOT)/gap5/consen.h
+check_assembly.o: $(SRCROOT)/gap5/consensus.h
+check_assembly.o: $(SRCROOT)/gap5/contig_selector.h
+check_assembly.o: $(SRCROOT)/gap5/cs-object.h
+check_assembly.o: $(SRCROOT)/gap5/editor_view.h
+check_assembly.o: $(SRCROOT)/gap5/g-alloc.h
+check_assembly.o: $(SRCROOT)/gap5/g-connect.h
+check_assembly.o: $(SRCROOT)/gap5/g-db.h
+check_assembly.o: $(SRCROOT)/gap5/g-defs.h
+check_assembly.o: $(SRCROOT)/gap5/g-error.h
+check_assembly.o: $(SRCROOT)/gap5/g-filedefs.h
+check_assembly.o: $(SRCROOT)/gap5/g-io.h
+check_assembly.o: $(SRCROOT)/gap5/g-misc.h
+check_assembly.o: $(SRCROOT)/gap5/g-os.h
+check_assembly.o: $(SRCROOT)/gap5/g-request.h
+check_assembly.o: $(SRCROOT)/gap5/g-struct.h
+check_assembly.o: $(SRCROOT)/gap5/g.h
+check_assembly.o: $(SRCROOT)/gap5/gap4_compat.h
+check_assembly.o: $(SRCROOT)/gap5/gap_globals.h
+check_assembly.o: $(SRCROOT)/gap5/hache_table.h
+check_assembly.o: $(SRCROOT)/gap5/io_utils.h
+check_assembly.o: $(SRCROOT)/gap5/qual.h
+check_assembly.o: $(SRCROOT)/gap5/tg_anno.h
+check_assembly.o: $(SRCROOT)/gap5/tg_bin.h
+check_assembly.o: $(SRCROOT)/gap5/tg_cache_item.h
+check_assembly.o: $(SRCROOT)/gap5/tg_contig.h
+check_assembly.o: $(SRCROOT)/gap5/tg_gio.h
+check_assembly.o: $(SRCROOT)/gap5/tg_iface.h
+check_assembly.o: $(SRCROOT)/gap5/tg_library.h
+check_assembly.o: $(SRCROOT)/gap5/tg_register.h
+check_assembly.o: $(SRCROOT)/gap5/tg_scaffold.h
+check_assembly.o: $(SRCROOT)/gap5/tg_sequence.h
+check_assembly.o: $(SRCROOT)/gap5/tg_struct.h
+check_assembly.o: $(SRCROOT)/gap5/tg_tcl.h
+check_assembly.o: $(SRCROOT)/gap5/tg_track.h
+check_assembly.o: $(SRCROOT)/gap5/tg_utils.h
+check_assembly.o: $(SRCROOT)/gap5/tk-io-reg.h
+check_assembly.o: $(SRCROOT)/gap5/tkEdNames.h
+check_assembly.o: $(SRCROOT)/gap5/tkEditor.h
+check_assembly.o: $(SRCROOT)/seq_utils/align.h
+check_assembly.o: $(SRCROOT)/seq_utils/align_lib_old.h
+check_assembly.o: $(SRCROOT)/seq_utils/dna_utils.h
+check_assembly.o: $(SRCROOT)/tk_utils/canvas_box.h
+check_assembly.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+check_assembly.o: $(SRCROOT)/tk_utils/sheet.h
+check_assembly.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+check_assembly.o: $(SRCROOT)/tk_utils/tcl_utils.h
+check_assembly.o: $(SRCROOT)/tk_utils/text_output.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkSheet.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+check_assembly.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 consen.o: $(PWD)/staden_config.h
+consen.o: $(SRCROOT)/Misc/array.h
+consen.o: $(SRCROOT)/Misc/misc.h
+consen.o: $(SRCROOT)/Misc/os.h
+consen.o: $(SRCROOT)/Misc/tree.h
+consen.o: $(SRCROOT)/Misc/xalloc.h
+consen.o: $(SRCROOT)/Misc/xerror.h
+consen.o: $(SRCROOT)/gap5/b+tree2.h
+consen.o: $(SRCROOT)/gap5/consen.h
+consen.o: $(SRCROOT)/gap5/consensus.h
+consen.o: $(SRCROOT)/gap5/extract.h
+consen.o: $(SRCROOT)/gap5/g-alloc.h
+consen.o: $(SRCROOT)/gap5/g-connect.h
+consen.o: $(SRCROOT)/gap5/g-db.h
+consen.o: $(SRCROOT)/gap5/g-defs.h
+consen.o: $(SRCROOT)/gap5/g-error.h
+consen.o: $(SRCROOT)/gap5/g-filedefs.h
+consen.o: $(SRCROOT)/gap5/g-io.h
+consen.o: $(SRCROOT)/gap5/g-misc.h
+consen.o: $(SRCROOT)/gap5/g-os.h
+consen.o: $(SRCROOT)/gap5/g-request.h
+consen.o: $(SRCROOT)/gap5/g-struct.h
+consen.o: $(SRCROOT)/gap5/g.h
+consen.o: $(SRCROOT)/gap5/gap4_compat.h
+consen.o: $(SRCROOT)/gap5/gap_globals.h
+consen.o: $(SRCROOT)/gap5/hache_table.h
+consen.o: $(SRCROOT)/gap5/io_utils.h
+consen.o: $(SRCROOT)/gap5/list_proc.h
+consen.o: $(SRCROOT)/gap5/qual.h
+consen.o: $(SRCROOT)/gap5/tg_anno.h
+consen.o: $(SRCROOT)/gap5/tg_bin.h
+consen.o: $(SRCROOT)/gap5/tg_cache_item.h
+consen.o: $(SRCROOT)/gap5/tg_contig.h
+consen.o: $(SRCROOT)/gap5/tg_gio.h
+consen.o: $(SRCROOT)/gap5/tg_iface.h
+consen.o: $(SRCROOT)/gap5/tg_library.h
+consen.o: $(SRCROOT)/gap5/tg_register.h
+consen.o: $(SRCROOT)/gap5/tg_scaffold.h
+consen.o: $(SRCROOT)/gap5/tg_sequence.h
+consen.o: $(SRCROOT)/gap5/tg_struct.h
+consen.o: $(SRCROOT)/gap5/tg_tcl.h
+consen.o: $(SRCROOT)/gap5/tg_track.h
+consen.o: $(SRCROOT)/gap5/tg_utils.h
+consen.o: $(SRCROOT)/seq_utils/align_lib.h
+consen.o: $(SRCROOT)/seq_utils/dna_utils.h
+consen.o: $(SRCROOT)/tk_utils/tcl_utils.h
 consensus.o: $(PWD)/staden_config.h
+consensus.o: $(SRCROOT)/Misc/array.h
+consensus.o: $(SRCROOT)/Misc/misc.h
+consensus.o: $(SRCROOT)/Misc/os.h
+consensus.o: $(SRCROOT)/Misc/tree.h
+consensus.o: $(SRCROOT)/Misc/xalloc.h
+consensus.o: $(SRCROOT)/Misc/xerror.h
+consensus.o: $(SRCROOT)/gap5/b+tree2.h
+consensus.o: $(SRCROOT)/gap5/consensus.h
+consensus.o: $(SRCROOT)/gap5/g-alloc.h
+consensus.o: $(SRCROOT)/gap5/g-connect.h
+consensus.o: $(SRCROOT)/gap5/g-db.h
+consensus.o: $(SRCROOT)/gap5/g-defs.h
+consensus.o: $(SRCROOT)/gap5/g-error.h
+consensus.o: $(SRCROOT)/gap5/g-filedefs.h
+consensus.o: $(SRCROOT)/gap5/g-io.h
+consensus.o: $(SRCROOT)/gap5/g-misc.h
+consensus.o: $(SRCROOT)/gap5/g-os.h
+consensus.o: $(SRCROOT)/gap5/g-request.h
+consensus.o: $(SRCROOT)/gap5/g-struct.h
+consensus.o: $(SRCROOT)/gap5/g.h
+consensus.o: $(SRCROOT)/gap5/gap_globals.h
+consensus.o: $(SRCROOT)/gap5/hache_table.h
+consensus.o: $(SRCROOT)/gap5/io_utils.h
+consensus.o: $(SRCROOT)/gap5/tg_anno.h
+consensus.o: $(SRCROOT)/gap5/tg_bin.h
+consensus.o: $(SRCROOT)/gap5/tg_cache_item.h
+consensus.o: $(SRCROOT)/gap5/tg_contig.h
+consensus.o: $(SRCROOT)/gap5/tg_gio.h
+consensus.o: $(SRCROOT)/gap5/tg_iface.h
+consensus.o: $(SRCROOT)/gap5/tg_library.h
+consensus.o: $(SRCROOT)/gap5/tg_register.h
+consensus.o: $(SRCROOT)/gap5/tg_scaffold.h
+consensus.o: $(SRCROOT)/gap5/tg_sequence.h
+consensus.o: $(SRCROOT)/gap5/tg_struct.h
+consensus.o: $(SRCROOT)/gap5/tg_tcl.h
+consensus.o: $(SRCROOT)/gap5/tg_track.h
+consensus.o: $(SRCROOT)/gap5/tg_utils.h
+consensus.o: $(SRCROOT)/tk_utils/tcl_utils.h
 contig_extend.o: $(PWD)/staden_config.h
+contig_extend.o: $(SRCROOT)/Misc/array.h
+contig_extend.o: $(SRCROOT)/Misc/misc.h
+contig_extend.o: $(SRCROOT)/Misc/os.h
+contig_extend.o: $(SRCROOT)/Misc/tree.h
+contig_extend.o: $(SRCROOT)/Misc/xalloc.h
+contig_extend.o: $(SRCROOT)/Misc/xerror.h
+contig_extend.o: $(SRCROOT)/gap5/b+tree2.h
+contig_extend.o: $(SRCROOT)/gap5/break_contig.h
+contig_extend.o: $(SRCROOT)/gap5/consensus.h
+contig_extend.o: $(SRCROOT)/gap5/contig_extend.h
+contig_extend.o: $(SRCROOT)/gap5/g-alloc.h
+contig_extend.o: $(SRCROOT)/gap5/g-connect.h
+contig_extend.o: $(SRCROOT)/gap5/g-db.h
+contig_extend.o: $(SRCROOT)/gap5/g-defs.h
+contig_extend.o: $(SRCROOT)/gap5/g-error.h
+contig_extend.o: $(SRCROOT)/gap5/g-filedefs.h
+contig_extend.o: $(SRCROOT)/gap5/g-io.h
+contig_extend.o: $(SRCROOT)/gap5/g-misc.h
+contig_extend.o: $(SRCROOT)/gap5/g-os.h
+contig_extend.o: $(SRCROOT)/gap5/g-request.h
+contig_extend.o: $(SRCROOT)/gap5/g-struct.h
+contig_extend.o: $(SRCROOT)/gap5/g.h
+contig_extend.o: $(SRCROOT)/gap5/gap4_compat.h
+contig_extend.o: $(SRCROOT)/gap5/hache_table.h
+contig_extend.o: $(SRCROOT)/gap5/io_utils.h
+contig_extend.o: $(SRCROOT)/gap5/tg_anno.h
+contig_extend.o: $(SRCROOT)/gap5/tg_bin.h
+contig_extend.o: $(SRCROOT)/gap5/tg_cache_item.h
+contig_extend.o: $(SRCROOT)/gap5/tg_contig.h
+contig_extend.o: $(SRCROOT)/gap5/tg_gio.h
+contig_extend.o: $(SRCROOT)/gap5/tg_iface.h
+contig_extend.o: $(SRCROOT)/gap5/tg_library.h
+contig_extend.o: $(SRCROOT)/gap5/tg_register.h
+contig_extend.o: $(SRCROOT)/gap5/tg_scaffold.h
+contig_extend.o: $(SRCROOT)/gap5/tg_sequence.h
+contig_extend.o: $(SRCROOT)/gap5/tg_struct.h
+contig_extend.o: $(SRCROOT)/gap5/tg_tcl.h
+contig_extend.o: $(SRCROOT)/gap5/tg_track.h
+contig_extend.o: $(SRCROOT)/gap5/tg_utils.h
+contig_extend.o: $(SRCROOT)/seq_utils/dna_utils.h
+contig_extend.o: $(SRCROOT)/tk_utils/text_output.h
 contig_selector.o: $(PWD)/staden_config.h
+contig_selector.o: $(SRCROOT)/Misc/array.h
+contig_selector.o: $(SRCROOT)/Misc/misc.h
+contig_selector.o: $(SRCROOT)/Misc/os.h
+contig_selector.o: $(SRCROOT)/Misc/tree.h
+contig_selector.o: $(SRCROOT)/Misc/xalloc.h
+contig_selector.o: $(SRCROOT)/Misc/xerror.h
+contig_selector.o: $(SRCROOT)/gap5/active_tags.h
+contig_selector.o: $(SRCROOT)/gap5/b+tree2.h
+contig_selector.o: $(SRCROOT)/gap5/consensus.h
+contig_selector.o: $(SRCROOT)/gap5/contig_selector.h
+contig_selector.o: $(SRCROOT)/gap5/cs-object.h
+contig_selector.o: $(SRCROOT)/gap5/g-alloc.h
+contig_selector.o: $(SRCROOT)/gap5/g-connect.h
+contig_selector.o: $(SRCROOT)/gap5/g-db.h
+contig_selector.o: $(SRCROOT)/gap5/g-defs.h
+contig_selector.o: $(SRCROOT)/gap5/g-error.h
+contig_selector.o: $(SRCROOT)/gap5/g-filedefs.h
+contig_selector.o: $(SRCROOT)/gap5/g-io.h
+contig_selector.o: $(SRCROOT)/gap5/g-misc.h
+contig_selector.o: $(SRCROOT)/gap5/g-os.h
+contig_selector.o: $(SRCROOT)/gap5/g-request.h
+contig_selector.o: $(SRCROOT)/gap5/g-struct.h
+contig_selector.o: $(SRCROOT)/gap5/g.h
+contig_selector.o: $(SRCROOT)/gap5/gap4_compat.h
+contig_selector.o: $(SRCROOT)/gap5/gap_cli_arg.h
+contig_selector.o: $(SRCROOT)/gap5/gap_globals.h
+contig_selector.o: $(SRCROOT)/gap5/hache_table.h
+contig_selector.o: $(SRCROOT)/gap5/io_utils.h
+contig_selector.o: $(SRCROOT)/gap5/list.h
+contig_selector.o: $(SRCROOT)/gap5/newgap_cmds.h
+contig_selector.o: $(SRCROOT)/gap5/tagdb.h
+contig_selector.o: $(SRCROOT)/gap5/tg_anno.h
+contig_selector.o: $(SRCROOT)/gap5/tg_bin.h
+contig_selector.o: $(SRCROOT)/gap5/tg_cache_item.h
+contig_selector.o: $(SRCROOT)/gap5/tg_contig.h
+contig_selector.o: $(SRCROOT)/gap5/tg_gio.h
+contig_selector.o: $(SRCROOT)/gap5/tg_iface.h
+contig_selector.o: $(SRCROOT)/gap5/tg_library.h
+contig_selector.o: $(SRCROOT)/gap5/tg_register.h
+contig_selector.o: $(SRCROOT)/gap5/tg_scaffold.h
+contig_selector.o: $(SRCROOT)/gap5/tg_sequence.h
+contig_selector.o: $(SRCROOT)/gap5/tg_struct.h
+contig_selector.o: $(SRCROOT)/gap5/tg_tcl.h
+contig_selector.o: $(SRCROOT)/gap5/tg_track.h
+contig_selector.o: $(SRCROOT)/gap5/tg_utils.h
+contig_selector.o: $(SRCROOT)/tk_utils/canvas_box.h
+contig_selector.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+contig_selector.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+contig_selector.o: $(SRCROOT)/tk_utils/tcl_utils.h
+contig_selector.o: $(SRCROOT)/tk_utils/text_output.h
 cs-object.o: $(PWD)/staden_config.h
+cs-object.o: $(SRCROOT)/Misc/array.h
+cs-object.o: $(SRCROOT)/Misc/misc.h
+cs-object.o: $(SRCROOT)/Misc/os.h
+cs-object.o: $(SRCROOT)/Misc/tree.h
+cs-object.o: $(SRCROOT)/Misc/xalloc.h
+cs-object.o: $(SRCROOT)/Misc/xerror.h
+cs-object.o: $(SRCROOT)/gap5/b+tree2.h
+cs-object.o: $(SRCROOT)/gap5/consen.h
+cs-object.o: $(SRCROOT)/gap5/consensus.h
+cs-object.o: $(SRCROOT)/gap5/contig_selector.h
+cs-object.o: $(SRCROOT)/gap5/cs-object.h
+cs-object.o: $(SRCROOT)/gap5/fij.h
+cs-object.o: $(SRCROOT)/gap5/find_repeats.h
+cs-object.o: $(SRCROOT)/gap5/g-alloc.h
+cs-object.o: $(SRCROOT)/gap5/g-connect.h
+cs-object.o: $(SRCROOT)/gap5/g-db.h
+cs-object.o: $(SRCROOT)/gap5/g-defs.h
+cs-object.o: $(SRCROOT)/gap5/g-error.h
+cs-object.o: $(SRCROOT)/gap5/g-filedefs.h
+cs-object.o: $(SRCROOT)/gap5/g-io.h
+cs-object.o: $(SRCROOT)/gap5/g-misc.h
+cs-object.o: $(SRCROOT)/gap5/g-os.h
+cs-object.o: $(SRCROOT)/gap5/g-request.h
+cs-object.o: $(SRCROOT)/gap5/g-struct.h
+cs-object.o: $(SRCROOT)/gap5/g.h
+cs-object.o: $(SRCROOT)/gap5/gap4_compat.h
+cs-object.o: $(SRCROOT)/gap5/gap_globals.h
+cs-object.o: $(SRCROOT)/gap5/hache_table.h
+cs-object.o: $(SRCROOT)/gap5/hash_lib.h
+cs-object.o: $(SRCROOT)/gap5/io_utils.h
+cs-object.o: $(SRCROOT)/gap5/list.h
+cs-object.o: $(SRCROOT)/gap5/newgap_cmds.h
+cs-object.o: $(SRCROOT)/gap5/newgap_structs.h
+cs-object.o: $(SRCROOT)/gap5/readpair.h
+cs-object.o: $(SRCROOT)/gap5/tg_anno.h
+cs-object.o: $(SRCROOT)/gap5/tg_bin.h
+cs-object.o: $(SRCROOT)/gap5/tg_cache_item.h
+cs-object.o: $(SRCROOT)/gap5/tg_contig.h
+cs-object.o: $(SRCROOT)/gap5/tg_gio.h
+cs-object.o: $(SRCROOT)/gap5/tg_iface.h
+cs-object.o: $(SRCROOT)/gap5/tg_library.h
+cs-object.o: $(SRCROOT)/gap5/tg_register.h
+cs-object.o: $(SRCROOT)/gap5/tg_scaffold.h
+cs-object.o: $(SRCROOT)/gap5/tg_sequence.h
+cs-object.o: $(SRCROOT)/gap5/tg_struct.h
+cs-object.o: $(SRCROOT)/gap5/tg_tcl.h
+cs-object.o: $(SRCROOT)/gap5/tg_track.h
+cs-object.o: $(SRCROOT)/gap5/tg_utils.h
+cs-object.o: $(SRCROOT)/gap5/tk-io-reg.h
+cs-object.o: $(SRCROOT)/seq_utils/align_lib.h
+cs-object.o: $(SRCROOT)/tk_utils/canvas_box.h
+cs-object.o: $(SRCROOT)/tk_utils/tcl_utils.h
+cs-object.o: $(SRCROOT)/tk_utils/text_output.h
 depad_seq_tree.o: $(PWD)/staden_config.h
+depad_seq_tree.o: $(SRCROOT)/Misc/array.h
+depad_seq_tree.o: $(SRCROOT)/Misc/misc.h
+depad_seq_tree.o: $(SRCROOT)/Misc/os.h
+depad_seq_tree.o: $(SRCROOT)/Misc/tree.h
+depad_seq_tree.o: $(SRCROOT)/Misc/xalloc.h
+depad_seq_tree.o: $(SRCROOT)/Misc/xerror.h
+depad_seq_tree.o: $(SRCROOT)/gap5/b+tree2.h
+depad_seq_tree.o: $(SRCROOT)/gap5/consensus.h
+depad_seq_tree.o: $(SRCROOT)/gap5/depad_seq_tree.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-alloc.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-connect.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-db.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-defs.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-error.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-filedefs.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-io.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-misc.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-os.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-request.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g-struct.h
+depad_seq_tree.o: $(SRCROOT)/gap5/g.h
+depad_seq_tree.o: $(SRCROOT)/gap5/hache_table.h
+depad_seq_tree.o: $(SRCROOT)/gap5/io_utils.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_anno.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_bin.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_cache_item.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_contig.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_gio.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_iface.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_library.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_register.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_scaffold.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_sequence.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_struct.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_tcl.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_track.h
+depad_seq_tree.o: $(SRCROOT)/gap5/tg_utils.h
 depth_track.o: $(PWD)/staden_config.h
+depth_track.o: $(SRCROOT)/Misc/array.h
+depth_track.o: $(SRCROOT)/Misc/misc.h
+depth_track.o: $(SRCROOT)/Misc/os.h
+depth_track.o: $(SRCROOT)/Misc/tree.h
+depth_track.o: $(SRCROOT)/Misc/xalloc.h
+depth_track.o: $(SRCROOT)/Misc/xerror.h
+depth_track.o: $(SRCROOT)/gap5/b+tree2.h
+depth_track.o: $(SRCROOT)/gap5/depth_track.h
+depth_track.o: $(SRCROOT)/gap5/g-alloc.h
+depth_track.o: $(SRCROOT)/gap5/g-connect.h
+depth_track.o: $(SRCROOT)/gap5/g-db.h
+depth_track.o: $(SRCROOT)/gap5/g-defs.h
+depth_track.o: $(SRCROOT)/gap5/g-error.h
+depth_track.o: $(SRCROOT)/gap5/g-filedefs.h
+depth_track.o: $(SRCROOT)/gap5/g-io.h
+depth_track.o: $(SRCROOT)/gap5/g-misc.h
+depth_track.o: $(SRCROOT)/gap5/g-os.h
+depth_track.o: $(SRCROOT)/gap5/g-request.h
+depth_track.o: $(SRCROOT)/gap5/g-struct.h
+depth_track.o: $(SRCROOT)/gap5/g.h
+depth_track.o: $(SRCROOT)/gap5/gap_range.h
+depth_track.o: $(SRCROOT)/gap5/hache_table.h
+depth_track.o: $(SRCROOT)/gap5/io_utils.h
+depth_track.o: $(SRCROOT)/gap5/tg_anno.h
+depth_track.o: $(SRCROOT)/gap5/tg_bin.h
+depth_track.o: $(SRCROOT)/gap5/tg_cache_item.h
+depth_track.o: $(SRCROOT)/gap5/tg_contig.h
+depth_track.o: $(SRCROOT)/gap5/tg_gio.h
+depth_track.o: $(SRCROOT)/gap5/tg_iface.h
+depth_track.o: $(SRCROOT)/gap5/tg_library.h
+depth_track.o: $(SRCROOT)/gap5/tg_register.h
+depth_track.o: $(SRCROOT)/gap5/tg_scaffold.h
+depth_track.o: $(SRCROOT)/gap5/tg_sequence.h
+depth_track.o: $(SRCROOT)/gap5/tg_struct.h
+depth_track.o: $(SRCROOT)/gap5/tg_tcl.h
+depth_track.o: $(SRCROOT)/gap5/tg_track.h
+depth_track.o: $(SRCROOT)/gap5/tg_utils.h
 dis_readings.o: $(PWD)/staden_config.h
+dis_readings.o: $(SRCROOT)/Misc/array.h
+dis_readings.o: $(SRCROOT)/Misc/bitmap.h
+dis_readings.o: $(SRCROOT)/Misc/misc.h
+dis_readings.o: $(SRCROOT)/Misc/os.h
+dis_readings.o: $(SRCROOT)/Misc/tree.h
+dis_readings.o: $(SRCROOT)/Misc/xalloc.h
+dis_readings.o: $(SRCROOT)/Misc/xerror.h
+dis_readings.o: $(SRCROOT)/gap5/b+tree2.h
+dis_readings.o: $(SRCROOT)/gap5/break_contig.h
+dis_readings.o: $(SRCROOT)/gap5/consensus.h
+dis_readings.o: $(SRCROOT)/gap5/dis_readings.h
+dis_readings.o: $(SRCROOT)/gap5/g-alloc.h
+dis_readings.o: $(SRCROOT)/gap5/g-connect.h
+dis_readings.o: $(SRCROOT)/gap5/g-db.h
+dis_readings.o: $(SRCROOT)/gap5/g-defs.h
+dis_readings.o: $(SRCROOT)/gap5/g-error.h
+dis_readings.o: $(SRCROOT)/gap5/g-filedefs.h
+dis_readings.o: $(SRCROOT)/gap5/g-io.h
+dis_readings.o: $(SRCROOT)/gap5/g-misc.h
+dis_readings.o: $(SRCROOT)/gap5/g-os.h
+dis_readings.o: $(SRCROOT)/gap5/g-request.h
+dis_readings.o: $(SRCROOT)/gap5/g-struct.h
+dis_readings.o: $(SRCROOT)/gap5/g.h
+dis_readings.o: $(SRCROOT)/gap5/hache_table.h
+dis_readings.o: $(SRCROOT)/gap5/io_utils.h
+dis_readings.o: $(SRCROOT)/gap5/tg_anno.h
+dis_readings.o: $(SRCROOT)/gap5/tg_bin.h
+dis_readings.o: $(SRCROOT)/gap5/tg_cache_item.h
+dis_readings.o: $(SRCROOT)/gap5/tg_contig.h
+dis_readings.o: $(SRCROOT)/gap5/tg_gio.h
+dis_readings.o: $(SRCROOT)/gap5/tg_iface.h
+dis_readings.o: $(SRCROOT)/gap5/tg_library.h
+dis_readings.o: $(SRCROOT)/gap5/tg_register.h
+dis_readings.o: $(SRCROOT)/gap5/tg_scaffold.h
+dis_readings.o: $(SRCROOT)/gap5/tg_sequence.h
+dis_readings.o: $(SRCROOT)/gap5/tg_struct.h
+dis_readings.o: $(SRCROOT)/gap5/tg_tcl.h
+dis_readings.o: $(SRCROOT)/gap5/tg_track.h
+dis_readings.o: $(SRCROOT)/gap5/tg_utils.h
+dis_readings.o: $(SRCROOT)/tk_utils/text_output.h
 do_fij.o: $(PWD)/staden_config.h
+do_fij.o: $(SRCROOT)/Misc/array.h
+do_fij.o: $(SRCROOT)/Misc/misc.h
+do_fij.o: $(SRCROOT)/Misc/os.h
+do_fij.o: $(SRCROOT)/Misc/tree.h
+do_fij.o: $(SRCROOT)/Misc/xalloc.h
+do_fij.o: $(SRCROOT)/Misc/xerror.h
+do_fij.o: $(SRCROOT)/gap5/b+tree2.h
+do_fij.o: $(SRCROOT)/gap5/consen.h
+do_fij.o: $(SRCROOT)/gap5/consensus.h
+do_fij.o: $(SRCROOT)/gap5/fij.h
+do_fij.o: $(SRCROOT)/gap5/g-alloc.h
+do_fij.o: $(SRCROOT)/gap5/g-connect.h
+do_fij.o: $(SRCROOT)/gap5/g-db.h
+do_fij.o: $(SRCROOT)/gap5/g-defs.h
+do_fij.o: $(SRCROOT)/gap5/g-error.h
+do_fij.o: $(SRCROOT)/gap5/g-filedefs.h
+do_fij.o: $(SRCROOT)/gap5/g-io.h
+do_fij.o: $(SRCROOT)/gap5/g-misc.h
+do_fij.o: $(SRCROOT)/gap5/g-os.h
+do_fij.o: $(SRCROOT)/gap5/g-request.h
+do_fij.o: $(SRCROOT)/gap5/g-struct.h
+do_fij.o: $(SRCROOT)/gap5/g.h
+do_fij.o: $(SRCROOT)/gap5/hache_table.h
+do_fij.o: $(SRCROOT)/gap5/hash_lib.h
+do_fij.o: $(SRCROOT)/gap5/io_utils.h
+do_fij.o: $(SRCROOT)/gap5/newgap_structs.h
+do_fij.o: $(SRCROOT)/gap5/tg_anno.h
+do_fij.o: $(SRCROOT)/gap5/tg_bin.h
+do_fij.o: $(SRCROOT)/gap5/tg_cache_item.h
+do_fij.o: $(SRCROOT)/gap5/tg_contig.h
+do_fij.o: $(SRCROOT)/gap5/tg_gio.h
+do_fij.o: $(SRCROOT)/gap5/tg_iface.h
+do_fij.o: $(SRCROOT)/gap5/tg_library.h
+do_fij.o: $(SRCROOT)/gap5/tg_register.h
+do_fij.o: $(SRCROOT)/gap5/tg_scaffold.h
+do_fij.o: $(SRCROOT)/gap5/tg_sequence.h
+do_fij.o: $(SRCROOT)/gap5/tg_struct.h
+do_fij.o: $(SRCROOT)/gap5/tg_tcl.h
+do_fij.o: $(SRCROOT)/gap5/tg_track.h
+do_fij.o: $(SRCROOT)/gap5/tg_utils.h
+do_fij.o: $(SRCROOT)/seq_utils/align_lib.h
+do_fij.o: $(SRCROOT)/seq_utils/dna_utils.h
 editor_join.o: $(PWD)/staden_config.h
+editor_join.o: $(SRCROOT)/Misc/array.h
+editor_join.o: $(SRCROOT)/Misc/misc.h
+editor_join.o: $(SRCROOT)/Misc/os.h
+editor_join.o: $(SRCROOT)/Misc/tree.h
+editor_join.o: $(SRCROOT)/Misc/xalloc.h
+editor_join.o: $(SRCROOT)/Misc/xerror.h
+editor_join.o: $(SRCROOT)/gap5/b+tree2.h
+editor_join.o: $(SRCROOT)/gap5/consen.h
+editor_join.o: $(SRCROOT)/gap5/consensus.h
+editor_join.o: $(SRCROOT)/gap5/dis_readings.h
+editor_join.o: $(SRCROOT)/gap5/editor_join.h
+editor_join.o: $(SRCROOT)/gap5/editor_view.h
+editor_join.o: $(SRCROOT)/gap5/g-alloc.h
+editor_join.o: $(SRCROOT)/gap5/g-connect.h
+editor_join.o: $(SRCROOT)/gap5/g-db.h
+editor_join.o: $(SRCROOT)/gap5/g-defs.h
+editor_join.o: $(SRCROOT)/gap5/g-error.h
+editor_join.o: $(SRCROOT)/gap5/g-filedefs.h
+editor_join.o: $(SRCROOT)/gap5/g-io.h
+editor_join.o: $(SRCROOT)/gap5/g-misc.h
+editor_join.o: $(SRCROOT)/gap5/g-os.h
+editor_join.o: $(SRCROOT)/gap5/g-request.h
+editor_join.o: $(SRCROOT)/gap5/g-struct.h
+editor_join.o: $(SRCROOT)/gap5/g.h
+editor_join.o: $(SRCROOT)/gap5/hache_table.h
+editor_join.o: $(SRCROOT)/gap5/hash_lib.h
+editor_join.o: $(SRCROOT)/gap5/io_utils.h
+editor_join.o: $(SRCROOT)/gap5/tg_anno.h
+editor_join.o: $(SRCROOT)/gap5/tg_bin.h
+editor_join.o: $(SRCROOT)/gap5/tg_cache_item.h
+editor_join.o: $(SRCROOT)/gap5/tg_contig.h
+editor_join.o: $(SRCROOT)/gap5/tg_gio.h
+editor_join.o: $(SRCROOT)/gap5/tg_iface.h
+editor_join.o: $(SRCROOT)/gap5/tg_library.h
+editor_join.o: $(SRCROOT)/gap5/tg_register.h
+editor_join.o: $(SRCROOT)/gap5/tg_scaffold.h
+editor_join.o: $(SRCROOT)/gap5/tg_sequence.h
+editor_join.o: $(SRCROOT)/gap5/tg_struct.h
+editor_join.o: $(SRCROOT)/gap5/tg_tcl.h
+editor_join.o: $(SRCROOT)/gap5/tg_track.h
+editor_join.o: $(SRCROOT)/gap5/tg_utils.h
+editor_join.o: $(SRCROOT)/gap5/tkEdNames.h
+editor_join.o: $(SRCROOT)/gap5/tkEditor.h
+editor_join.o: $(SRCROOT)/seq_utils/align.h
+editor_join.o: $(SRCROOT)/seq_utils/align_lib.h
+editor_join.o: $(SRCROOT)/seq_utils/align_lib_old.h
+editor_join.o: $(SRCROOT)/seq_utils/dna_utils.h
+editor_join.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+editor_join.o: $(SRCROOT)/tk_utils/sheet.h
+editor_join.o: $(SRCROOT)/tk_utils/text_output.h
+editor_join.o: $(SRCROOT)/tk_utils/tkSheet.h
+editor_join.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+editor_join.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 editor_oligo.o: $(PWD)/staden_config.h
+editor_oligo.o: $(SRCROOT)/Misc/array.h
+editor_oligo.o: $(SRCROOT)/Misc/misc.h
+editor_oligo.o: $(SRCROOT)/Misc/os.h
+editor_oligo.o: $(SRCROOT)/Misc/tree.h
+editor_oligo.o: $(SRCROOT)/Misc/xalloc.h
+editor_oligo.o: $(SRCROOT)/Misc/xerror.h
+editor_oligo.o: $(SRCROOT)/gap5/b+tree2.h
+editor_oligo.o: $(SRCROOT)/gap5/consensus.h
+editor_oligo.o: $(SRCROOT)/gap5/editor_view.h
+editor_oligo.o: $(SRCROOT)/gap5/g-alloc.h
+editor_oligo.o: $(SRCROOT)/gap5/g-connect.h
+editor_oligo.o: $(SRCROOT)/gap5/g-db.h
+editor_oligo.o: $(SRCROOT)/gap5/g-defs.h
+editor_oligo.o: $(SRCROOT)/gap5/g-error.h
+editor_oligo.o: $(SRCROOT)/gap5/g-filedefs.h
+editor_oligo.o: $(SRCROOT)/gap5/g-io.h
+editor_oligo.o: $(SRCROOT)/gap5/g-misc.h
+editor_oligo.o: $(SRCROOT)/gap5/g-os.h
+editor_oligo.o: $(SRCROOT)/gap5/g-request.h
+editor_oligo.o: $(SRCROOT)/gap5/g-struct.h
+editor_oligo.o: $(SRCROOT)/gap5/g.h
+editor_oligo.o: $(SRCROOT)/gap5/gap4_compat.h
+editor_oligo.o: $(SRCROOT)/gap5/hache_table.h
+editor_oligo.o: $(SRCROOT)/gap5/io_utils.h
+editor_oligo.o: $(SRCROOT)/gap5/primlib.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_anno.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_bin.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_cache_item.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_contig.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_gio.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_iface.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_library.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_register.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_scaffold.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_sequence.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_struct.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_tcl.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_track.h
+editor_oligo.o: $(SRCROOT)/gap5/tg_utils.h
+editor_oligo.o: $(SRCROOT)/gap5/tkEdNames.h
+editor_oligo.o: $(SRCROOT)/gap5/tkEditor.h
+editor_oligo.o: $(SRCROOT)/primer3/src/dpal.h
+editor_oligo.o: $(SRCROOT)/primer3/src/primer3.h
+editor_oligo.o: $(SRCROOT)/seq_utils/dna_utils.h
+editor_oligo.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+editor_oligo.o: $(SRCROOT)/tk_utils/sheet.h
+editor_oligo.o: $(SRCROOT)/tk_utils/tkSheet.h
+editor_oligo.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+editor_oligo.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 editor_search.o: $(PWD)/staden_config.h
+editor_search.o: $(SRCROOT)/Misc/array.h
+editor_search.o: $(SRCROOT)/Misc/misc.h
+editor_search.o: $(SRCROOT)/Misc/os.h
+editor_search.o: $(SRCROOT)/Misc/reg_exp.h
+editor_search.o: $(SRCROOT)/Misc/tree.h
+editor_search.o: $(SRCROOT)/Misc/xalloc.h
+editor_search.o: $(SRCROOT)/Misc/xerror.h
+editor_search.o: $(SRCROOT)/gap5/b+tree2.h
+editor_search.o: $(SRCROOT)/gap5/consensus.h
+editor_search.o: $(SRCROOT)/gap5/editor_view.h
+editor_search.o: $(SRCROOT)/gap5/g-alloc.h
+editor_search.o: $(SRCROOT)/gap5/g-connect.h
+editor_search.o: $(SRCROOT)/gap5/g-db.h
+editor_search.o: $(SRCROOT)/gap5/g-defs.h
+editor_search.o: $(SRCROOT)/gap5/g-error.h
+editor_search.o: $(SRCROOT)/gap5/g-filedefs.h
+editor_search.o: $(SRCROOT)/gap5/g-io.h
+editor_search.o: $(SRCROOT)/gap5/g-misc.h
+editor_search.o: $(SRCROOT)/gap5/g-os.h
+editor_search.o: $(SRCROOT)/gap5/g-request.h
+editor_search.o: $(SRCROOT)/gap5/g-struct.h
+editor_search.o: $(SRCROOT)/gap5/g.h
+editor_search.o: $(SRCROOT)/gap5/gap4_compat.h
+editor_search.o: $(SRCROOT)/gap5/hache_table.h
+editor_search.o: $(SRCROOT)/gap5/io_utils.h
+editor_search.o: $(SRCROOT)/gap5/tg_anno.h
+editor_search.o: $(SRCROOT)/gap5/tg_bin.h
+editor_search.o: $(SRCROOT)/gap5/tg_cache_item.h
+editor_search.o: $(SRCROOT)/gap5/tg_contig.h
+editor_search.o: $(SRCROOT)/gap5/tg_gio.h
+editor_search.o: $(SRCROOT)/gap5/tg_iface.h
+editor_search.o: $(SRCROOT)/gap5/tg_library.h
+editor_search.o: $(SRCROOT)/gap5/tg_register.h
+editor_search.o: $(SRCROOT)/gap5/tg_scaffold.h
+editor_search.o: $(SRCROOT)/gap5/tg_sequence.h
+editor_search.o: $(SRCROOT)/gap5/tg_struct.h
+editor_search.o: $(SRCROOT)/gap5/tg_tcl.h
+editor_search.o: $(SRCROOT)/gap5/tg_track.h
+editor_search.o: $(SRCROOT)/gap5/tg_utils.h
+editor_search.o: $(SRCROOT)/gap5/tkEdNames.h
+editor_search.o: $(SRCROOT)/gap5/tkEditor.h
+editor_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+editor_search.o: $(SRCROOT)/seq_utils/search_utils.h
+editor_search.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+editor_search.o: $(SRCROOT)/tk_utils/sheet.h
+editor_search.o: $(SRCROOT)/tk_utils/tkSheet.h
+editor_search.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+editor_search.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 editor_view.o: $(PWD)/staden_config.h
+editor_view.o: $(SRCROOT)/Misc/array.h
+editor_view.o: $(SRCROOT)/Misc/dstring.h
+editor_view.o: $(SRCROOT)/Misc/misc.h
+editor_view.o: $(SRCROOT)/Misc/os.h
+editor_view.o: $(SRCROOT)/Misc/tree.h
+editor_view.o: $(SRCROOT)/Misc/xalloc.h
+editor_view.o: $(SRCROOT)/Misc/xerror.h
+editor_view.o: $(SRCROOT)/gap5/active_tags.h
+editor_view.o: $(SRCROOT)/gap5/b+tree2.h
+editor_view.o: $(SRCROOT)/gap5/consensus.h
+editor_view.o: $(SRCROOT)/gap5/depad_seq_tree.h
+editor_view.o: $(SRCROOT)/gap5/editor_view.h
+editor_view.o: $(SRCROOT)/gap5/g-alloc.h
+editor_view.o: $(SRCROOT)/gap5/g-connect.h
+editor_view.o: $(SRCROOT)/gap5/g-db.h
+editor_view.o: $(SRCROOT)/gap5/g-defs.h
+editor_view.o: $(SRCROOT)/gap5/g-error.h
+editor_view.o: $(SRCROOT)/gap5/g-filedefs.h
+editor_view.o: $(SRCROOT)/gap5/g-io.h
+editor_view.o: $(SRCROOT)/gap5/g-misc.h
+editor_view.o: $(SRCROOT)/gap5/g-os.h
+editor_view.o: $(SRCROOT)/gap5/g-request.h
+editor_view.o: $(SRCROOT)/gap5/g-struct.h
+editor_view.o: $(SRCROOT)/gap5/g.h
+editor_view.o: $(SRCROOT)/gap5/gap_globals.h
+editor_view.o: $(SRCROOT)/gap5/hache_table.h
+editor_view.o: $(SRCROOT)/gap5/io_utils.h
+editor_view.o: $(SRCROOT)/gap5/qual.h
+editor_view.o: $(SRCROOT)/gap5/qualIO.h
+editor_view.o: $(SRCROOT)/gap5/tagdb.h
+editor_view.o: $(SRCROOT)/gap5/tg_anno.h
+editor_view.o: $(SRCROOT)/gap5/tg_bin.h
+editor_view.o: $(SRCROOT)/gap5/tg_cache_item.h
+editor_view.o: $(SRCROOT)/gap5/tg_contig.h
+editor_view.o: $(SRCROOT)/gap5/tg_gio.h
+editor_view.o: $(SRCROOT)/gap5/tg_iface.h
+editor_view.o: $(SRCROOT)/gap5/tg_library.h
+editor_view.o: $(SRCROOT)/gap5/tg_register.h
+editor_view.o: $(SRCROOT)/gap5/tg_scaffold.h
+editor_view.o: $(SRCROOT)/gap5/tg_sequence.h
+editor_view.o: $(SRCROOT)/gap5/tg_struct.h
+editor_view.o: $(SRCROOT)/gap5/tg_tcl.h
+editor_view.o: $(SRCROOT)/gap5/tg_track.h
+editor_view.o: $(SRCROOT)/gap5/tg_utils.h
+editor_view.o: $(SRCROOT)/gap5/tkEdNames.h
+editor_view.o: $(SRCROOT)/gap5/tkEditor.h
+editor_view.o: $(SRCROOT)/gap5/tman_display.h
+editor_view.o: $(SRCROOT)/gap5/tman_interface.h
+editor_view.o: $(SRCROOT)/seq_utils/align.h
+editor_view.o: $(SRCROOT)/seq_utils/align_lib.h
+editor_view.o: $(SRCROOT)/seq_utils/align_lib_old.h
+editor_view.o: $(SRCROOT)/tk_utils/cli_arg.h
+editor_view.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+editor_view.o: $(SRCROOT)/tk_utils/postscript.h
+editor_view.o: $(SRCROOT)/tk_utils/sheet.h
+editor_view.o: $(SRCROOT)/tk_utils/tcl_utils.h
+editor_view.o: $(SRCROOT)/tk_utils/tkSheet.h
+editor_view.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+editor_view.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+editor_view.o: $(SRCROOT)/tk_utils/tkTrace.h
 export_contigs.o: $(PWD)/staden_config.h
+export_contigs.o: $(SRCROOT)/Misc/array.h
+export_contigs.o: $(SRCROOT)/Misc/dstring.h
+export_contigs.o: $(SRCROOT)/Misc/misc.h
+export_contigs.o: $(SRCROOT)/Misc/os.h
+export_contigs.o: $(SRCROOT)/Misc/string_alloc.h
+export_contigs.o: $(SRCROOT)/Misc/tree.h
+export_contigs.o: $(SRCROOT)/Misc/xalloc.h
+export_contigs.o: $(SRCROOT)/Misc/xerror.h
+export_contigs.o: $(SRCROOT)/gap5/active_tags.h
+export_contigs.o: $(SRCROOT)/gap5/b+tree2.h
+export_contigs.o: $(SRCROOT)/gap5/consensus.h
+export_contigs.o: $(SRCROOT)/gap5/export_contigs.h
+export_contigs.o: $(SRCROOT)/gap5/g-alloc.h
+export_contigs.o: $(SRCROOT)/gap5/g-connect.h
+export_contigs.o: $(SRCROOT)/gap5/g-db.h
+export_contigs.o: $(SRCROOT)/gap5/g-defs.h
+export_contigs.o: $(SRCROOT)/gap5/g-error.h
+export_contigs.o: $(SRCROOT)/gap5/g-filedefs.h
+export_contigs.o: $(SRCROOT)/gap5/g-io.h
+export_contigs.o: $(SRCROOT)/gap5/g-misc.h
+export_contigs.o: $(SRCROOT)/gap5/g-os.h
+export_contigs.o: $(SRCROOT)/gap5/g-request.h
+export_contigs.o: $(SRCROOT)/gap5/g-struct.h
+export_contigs.o: $(SRCROOT)/gap5/g.h
+export_contigs.o: $(SRCROOT)/gap5/gap_cli_arg.h
+export_contigs.o: $(SRCROOT)/gap5/hache_table.h
+export_contigs.o: $(SRCROOT)/gap5/io_utils.h
+export_contigs.o: $(SRCROOT)/gap5/list_proc.h
+export_contigs.o: $(SRCROOT)/gap5/newgap_structs.h
+export_contigs.o: $(SRCROOT)/gap5/sam_index.h
+export_contigs.o: $(SRCROOT)/gap5/tagdb.h
+export_contigs.o: $(SRCROOT)/gap5/tg_anno.h
+export_contigs.o: $(SRCROOT)/gap5/tg_bin.h
+export_contigs.o: $(SRCROOT)/gap5/tg_cache_item.h
+export_contigs.o: $(SRCROOT)/gap5/tg_contig.h
+export_contigs.o: $(SRCROOT)/gap5/tg_gio.h
+export_contigs.o: $(SRCROOT)/gap5/tg_iface.h
+export_contigs.o: $(SRCROOT)/gap5/tg_index.h
+export_contigs.o: $(SRCROOT)/gap5/tg_library.h
+export_contigs.o: $(SRCROOT)/gap5/tg_register.h
+export_contigs.o: $(SRCROOT)/gap5/tg_scaffold.h
+export_contigs.o: $(SRCROOT)/gap5/tg_sequence.h
+export_contigs.o: $(SRCROOT)/gap5/tg_struct.h
+export_contigs.o: $(SRCROOT)/gap5/tg_tcl.h
+export_contigs.o: $(SRCROOT)/gap5/tg_track.h
+export_contigs.o: $(SRCROOT)/gap5/tg_utils.h
+export_contigs.o: $(SRCROOT)/seq_utils/dna_utils.h
+export_contigs.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+export_snps.o: $(PWD)/staden_config.h
+export_snps.o: $(SRCROOT)/Misc/array.h
+export_snps.o: $(SRCROOT)/Misc/dstring.h
+export_snps.o: $(SRCROOT)/Misc/misc.h
+export_snps.o: $(SRCROOT)/Misc/os.h
+export_snps.o: $(SRCROOT)/Misc/tree.h
+export_snps.o: $(SRCROOT)/Misc/xalloc.h
+export_snps.o: $(SRCROOT)/Misc/xerror.h
+export_snps.o: $(SRCROOT)/gap5/b+tree2.h
+export_snps.o: $(SRCROOT)/gap5/consensus.h
+export_snps.o: $(SRCROOT)/gap5/export_snps.h
+export_snps.o: $(SRCROOT)/gap5/g-alloc.h
+export_snps.o: $(SRCROOT)/gap5/g-connect.h
+export_snps.o: $(SRCROOT)/gap5/g-db.h
+export_snps.o: $(SRCROOT)/gap5/g-defs.h
+export_snps.o: $(SRCROOT)/gap5/g-error.h
+export_snps.o: $(SRCROOT)/gap5/g-filedefs.h
+export_snps.o: $(SRCROOT)/gap5/g-io.h
+export_snps.o: $(SRCROOT)/gap5/g-misc.h
+export_snps.o: $(SRCROOT)/gap5/g-os.h
+export_snps.o: $(SRCROOT)/gap5/g-request.h
+export_snps.o: $(SRCROOT)/gap5/g-struct.h
+export_snps.o: $(SRCROOT)/gap5/g.h
+export_snps.o: $(SRCROOT)/gap5/gap_cli_arg.h
+export_snps.o: $(SRCROOT)/gap5/hache_table.h
+export_snps.o: $(SRCROOT)/gap5/io_utils.h
+export_snps.o: $(SRCROOT)/gap5/list_proc.h
+export_snps.o: $(SRCROOT)/gap5/tg_anno.h
+export_snps.o: $(SRCROOT)/gap5/tg_bin.h
+export_snps.o: $(SRCROOT)/gap5/tg_cache_item.h
+export_snps.o: $(SRCROOT)/gap5/tg_contig.h
+export_snps.o: $(SRCROOT)/gap5/tg_gio.h
+export_snps.o: $(SRCROOT)/gap5/tg_iface.h
+export_snps.o: $(SRCROOT)/gap5/tg_library.h
+export_snps.o: $(SRCROOT)/gap5/tg_register.h
+export_snps.o: $(SRCROOT)/gap5/tg_scaffold.h
+export_snps.o: $(SRCROOT)/gap5/tg_sequence.h
+export_snps.o: $(SRCROOT)/gap5/tg_struct.h
+export_snps.o: $(SRCROOT)/gap5/tg_tcl.h
+export_snps.o: $(SRCROOT)/gap5/tg_track.h
+export_snps.o: $(SRCROOT)/gap5/tg_utils.h
 fasta.o: $(PWD)/staden_config.h
+fasta.o: $(SRCROOT)/Misc/array.h
+fasta.o: $(SRCROOT)/Misc/misc.h
+fasta.o: $(SRCROOT)/Misc/os.h
+fasta.o: $(SRCROOT)/Misc/string_alloc.h
+fasta.o: $(SRCROOT)/Misc/tree.h
+fasta.o: $(SRCROOT)/Misc/xalloc.h
+fasta.o: $(SRCROOT)/Misc/xerror.h
+fasta.o: $(SRCROOT)/gap5/b+tree2.h
+fasta.o: $(SRCROOT)/gap5/fasta.h
+fasta.o: $(SRCROOT)/gap5/g-alloc.h
+fasta.o: $(SRCROOT)/gap5/g-connect.h
+fasta.o: $(SRCROOT)/gap5/g-db.h
+fasta.o: $(SRCROOT)/gap5/g-defs.h
+fasta.o: $(SRCROOT)/gap5/g-error.h
+fasta.o: $(SRCROOT)/gap5/g-filedefs.h
+fasta.o: $(SRCROOT)/gap5/g-io.h
+fasta.o: $(SRCROOT)/gap5/g-misc.h
+fasta.o: $(SRCROOT)/gap5/g-os.h
+fasta.o: $(SRCROOT)/gap5/g-request.h
+fasta.o: $(SRCROOT)/gap5/g-struct.h
+fasta.o: $(SRCROOT)/gap5/g.h
+fasta.o: $(SRCROOT)/gap5/hache_table.h
+fasta.o: $(SRCROOT)/gap5/io_utils.h
+fasta.o: $(SRCROOT)/gap5/tg_anno.h
+fasta.o: $(SRCROOT)/gap5/tg_bin.h
+fasta.o: $(SRCROOT)/gap5/tg_cache_item.h
+fasta.o: $(SRCROOT)/gap5/tg_contig.h
+fasta.o: $(SRCROOT)/gap5/tg_gio.h
+fasta.o: $(SRCROOT)/gap5/tg_iface.h
+fasta.o: $(SRCROOT)/gap5/tg_index.h
+fasta.o: $(SRCROOT)/gap5/tg_index_common.h
+fasta.o: $(SRCROOT)/gap5/tg_library.h
+fasta.o: $(SRCROOT)/gap5/tg_register.h
+fasta.o: $(SRCROOT)/gap5/tg_scaffold.h
+fasta.o: $(SRCROOT)/gap5/tg_sequence.h
+fasta.o: $(SRCROOT)/gap5/tg_struct.h
+fasta.o: $(SRCROOT)/gap5/tg_tcl.h
+fasta.o: $(SRCROOT)/gap5/tg_track.h
+fasta.o: $(SRCROOT)/gap5/tg_utils.h
+fasta.o: $(SRCROOT)/tk_utils/text_output.h
 fij.o: $(PWD)/staden_config.h
+fij.o: $(SRCROOT)/Misc/array.h
+fij.o: $(SRCROOT)/Misc/dstring.h
+fij.o: $(SRCROOT)/Misc/misc.h
+fij.o: $(SRCROOT)/Misc/os.h
+fij.o: $(SRCROOT)/Misc/tree.h
+fij.o: $(SRCROOT)/Misc/xalloc.h
+fij.o: $(SRCROOT)/Misc/xerror.h
+fij.o: $(SRCROOT)/gap5/b+tree2.h
+fij.o: $(SRCROOT)/gap5/consen.h
+fij.o: $(SRCROOT)/gap5/consensus.h
+fij.o: $(SRCROOT)/gap5/contig_selector.h
+fij.o: $(SRCROOT)/gap5/cs-object.h
+fij.o: $(SRCROOT)/gap5/editor_join.h
+fij.o: $(SRCROOT)/gap5/editor_view.h
+fij.o: $(SRCROOT)/gap5/fij.h
+fij.o: $(SRCROOT)/gap5/g-alloc.h
+fij.o: $(SRCROOT)/gap5/g-connect.h
+fij.o: $(SRCROOT)/gap5/g-db.h
+fij.o: $(SRCROOT)/gap5/g-defs.h
+fij.o: $(SRCROOT)/gap5/g-error.h
+fij.o: $(SRCROOT)/gap5/g-filedefs.h
+fij.o: $(SRCROOT)/gap5/g-io.h
+fij.o: $(SRCROOT)/gap5/g-misc.h
+fij.o: $(SRCROOT)/gap5/g-os.h
+fij.o: $(SRCROOT)/gap5/g-request.h
+fij.o: $(SRCROOT)/gap5/g-struct.h
+fij.o: $(SRCROOT)/gap5/g.h
+fij.o: $(SRCROOT)/gap5/gap4_compat.h
+fij.o: $(SRCROOT)/gap5/gap_globals.h
+fij.o: $(SRCROOT)/gap5/hache_table.h
+fij.o: $(SRCROOT)/gap5/hash_lib.h
+fij.o: $(SRCROOT)/gap5/io_utils.h
+fij.o: $(SRCROOT)/gap5/list.h
+fij.o: $(SRCROOT)/gap5/newgap_cmds.h
+fij.o: $(SRCROOT)/gap5/newgap_structs.h
+fij.o: $(SRCROOT)/gap5/readpair.h
+fij.o: $(SRCROOT)/gap5/tg_anno.h
+fij.o: $(SRCROOT)/gap5/tg_bin.h
+fij.o: $(SRCROOT)/gap5/tg_cache_item.h
+fij.o: $(SRCROOT)/gap5/tg_contig.h
+fij.o: $(SRCROOT)/gap5/tg_gio.h
+fij.o: $(SRCROOT)/gap5/tg_iface.h
+fij.o: $(SRCROOT)/gap5/tg_library.h
+fij.o: $(SRCROOT)/gap5/tg_register.h
+fij.o: $(SRCROOT)/gap5/tg_scaffold.h
+fij.o: $(SRCROOT)/gap5/tg_sequence.h
+fij.o: $(SRCROOT)/gap5/tg_struct.h
+fij.o: $(SRCROOT)/gap5/tg_tcl.h
+fij.o: $(SRCROOT)/gap5/tg_track.h
+fij.o: $(SRCROOT)/gap5/tg_utils.h
+fij.o: $(SRCROOT)/gap5/tk-io-reg.h
+fij.o: $(SRCROOT)/gap5/tkEdNames.h
+fij.o: $(SRCROOT)/gap5/tkEditor.h
+fij.o: $(SRCROOT)/seq_utils/align_lib.h
+fij.o: $(SRCROOT)/tk_utils/canvas_box.h
+fij.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+fij.o: $(SRCROOT)/tk_utils/sheet.h
+fij.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+fij.o: $(SRCROOT)/tk_utils/tcl_utils.h
+fij.o: $(SRCROOT)/tk_utils/text_output.h
+fij.o: $(SRCROOT)/tk_utils/tkSheet.h
+fij.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+fij.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+find_haplotypes.o: $(PWD)/staden_config.h
+find_haplotypes.o: $(SRCROOT)/Misc/array.h
+find_haplotypes.o: $(SRCROOT)/Misc/misc.h
+find_haplotypes.o: $(SRCROOT)/Misc/os.h
+find_haplotypes.o: $(SRCROOT)/Misc/tree.h
+find_haplotypes.o: $(SRCROOT)/Misc/xalloc.h
+find_haplotypes.o: $(SRCROOT)/Misc/xerror.h
+find_haplotypes.o: $(SRCROOT)/gap5/b+tree2.h
+find_haplotypes.o: $(SRCROOT)/gap5/consensus.h
+find_haplotypes.o: $(SRCROOT)/gap5/find_haplotypes.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-alloc.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-connect.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-db.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-defs.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-error.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-filedefs.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-io.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-misc.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-os.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-request.h
+find_haplotypes.o: $(SRCROOT)/gap5/g-struct.h
+find_haplotypes.o: $(SRCROOT)/gap5/g.h
+find_haplotypes.o: $(SRCROOT)/gap5/hache_table.h
+find_haplotypes.o: $(SRCROOT)/gap5/interval_tree.h
+find_haplotypes.o: $(SRCROOT)/gap5/io_utils.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_anno.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_bin.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_cache_item.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_contig.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_gio.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_iface.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_library.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_register.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_scaffold.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_sequence.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_struct.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_tcl.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_track.h
+find_haplotypes.o: $(SRCROOT)/gap5/tg_utils.h
+find_haplotypes.o: $(SRCROOT)/seq_utils/align.h
+find_haplotypes.o: $(SRCROOT)/seq_utils/align_lib_old.h
+find_haplotypes.o: $(SRCROOT)/seq_utils/dna_utils.h
 find_oligo.o: $(PWD)/staden_config.h
+find_oligo.o: $(SRCROOT)/Misc/array.h
+find_oligo.o: $(SRCROOT)/Misc/misc.h
+find_oligo.o: $(SRCROOT)/Misc/os.h
+find_oligo.o: $(SRCROOT)/Misc/tree.h
+find_oligo.o: $(SRCROOT)/Misc/xalloc.h
+find_oligo.o: $(SRCROOT)/Misc/xerror.h
+find_oligo.o: $(SRCROOT)/gap5/b+tree2.h
+find_oligo.o: $(SRCROOT)/gap5/consensus.h
+find_oligo.o: $(SRCROOT)/gap5/contig_selector.h
+find_oligo.o: $(SRCROOT)/gap5/cs-object.h
+find_oligo.o: $(SRCROOT)/gap5/editor_view.h
+find_oligo.o: $(SRCROOT)/gap5/g-alloc.h
+find_oligo.o: $(SRCROOT)/gap5/g-connect.h
+find_oligo.o: $(SRCROOT)/gap5/g-db.h
+find_oligo.o: $(SRCROOT)/gap5/g-defs.h
+find_oligo.o: $(SRCROOT)/gap5/g-error.h
+find_oligo.o: $(SRCROOT)/gap5/g-filedefs.h
+find_oligo.o: $(SRCROOT)/gap5/g-io.h
+find_oligo.o: $(SRCROOT)/gap5/g-misc.h
+find_oligo.o: $(SRCROOT)/gap5/g-os.h
+find_oligo.o: $(SRCROOT)/gap5/g-request.h
+find_oligo.o: $(SRCROOT)/gap5/g-struct.h
+find_oligo.o: $(SRCROOT)/gap5/g.h
+find_oligo.o: $(SRCROOT)/gap5/gap4_compat.h
+find_oligo.o: $(SRCROOT)/gap5/gap_globals.h
+find_oligo.o: $(SRCROOT)/gap5/hache_table.h
+find_oligo.o: $(SRCROOT)/gap5/io_utils.h
+find_oligo.o: $(SRCROOT)/gap5/list_proc.h
+find_oligo.o: $(SRCROOT)/gap5/tagdb.h
+find_oligo.o: $(SRCROOT)/gap5/template_display.h
+find_oligo.o: $(SRCROOT)/gap5/tg_anno.h
+find_oligo.o: $(SRCROOT)/gap5/tg_bin.h
+find_oligo.o: $(SRCROOT)/gap5/tg_cache_item.h
+find_oligo.o: $(SRCROOT)/gap5/tg_contig.h
+find_oligo.o: $(SRCROOT)/gap5/tg_gio.h
+find_oligo.o: $(SRCROOT)/gap5/tg_iface.h
+find_oligo.o: $(SRCROOT)/gap5/tg_library.h
+find_oligo.o: $(SRCROOT)/gap5/tg_register.h
+find_oligo.o: $(SRCROOT)/gap5/tg_scaffold.h
+find_oligo.o: $(SRCROOT)/gap5/tg_sequence.h
+find_oligo.o: $(SRCROOT)/gap5/tg_struct.h
+find_oligo.o: $(SRCROOT)/gap5/tg_tcl.h
+find_oligo.o: $(SRCROOT)/gap5/tg_track.h
+find_oligo.o: $(SRCROOT)/gap5/tg_utils.h
+find_oligo.o: $(SRCROOT)/gap5/tk-io-reg.h
+find_oligo.o: $(SRCROOT)/gap5/tkEdNames.h
+find_oligo.o: $(SRCROOT)/gap5/tkEditor.h
+find_oligo.o: $(SRCROOT)/seq_utils/dna_utils.h
+find_oligo.o: $(SRCROOT)/seq_utils/search_utils.h
+find_oligo.o: $(SRCROOT)/seq_utils/sequence_formats.h
+find_oligo.o: $(SRCROOT)/tk_utils/canvas_box.h
+find_oligo.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+find_oligo.o: $(SRCROOT)/tk_utils/sheet.h
+find_oligo.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+find_oligo.o: $(SRCROOT)/tk_utils/tcl_utils.h
+find_oligo.o: $(SRCROOT)/tk_utils/text_output.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkSheet.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+find_oligo.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 find_repeats.o: $(PWD)/staden_config.h
+find_repeats.o: $(SRCROOT)/Misc/array.h
+find_repeats.o: $(SRCROOT)/Misc/misc.h
+find_repeats.o: $(SRCROOT)/Misc/os.h
+find_repeats.o: $(SRCROOT)/Misc/tree.h
+find_repeats.o: $(SRCROOT)/Misc/xalloc.h
+find_repeats.o: $(SRCROOT)/Misc/xerror.h
+find_repeats.o: $(SRCROOT)/gap5/b+tree2.h
+find_repeats.o: $(SRCROOT)/gap5/check_assembly.h
+find_repeats.o: $(SRCROOT)/gap5/consen.h
+find_repeats.o: $(SRCROOT)/gap5/consensus.h
+find_repeats.o: $(SRCROOT)/gap5/contig_selector.h
+find_repeats.o: $(SRCROOT)/gap5/cs-object.h
+find_repeats.o: $(SRCROOT)/gap5/editor_view.h
+find_repeats.o: $(SRCROOT)/gap5/find_oligo.h
+find_repeats.o: $(SRCROOT)/gap5/find_repeats.h
+find_repeats.o: $(SRCROOT)/gap5/g-alloc.h
+find_repeats.o: $(SRCROOT)/gap5/g-connect.h
+find_repeats.o: $(SRCROOT)/gap5/g-db.h
+find_repeats.o: $(SRCROOT)/gap5/g-defs.h
+find_repeats.o: $(SRCROOT)/gap5/g-error.h
+find_repeats.o: $(SRCROOT)/gap5/g-filedefs.h
+find_repeats.o: $(SRCROOT)/gap5/g-io.h
+find_repeats.o: $(SRCROOT)/gap5/g-misc.h
+find_repeats.o: $(SRCROOT)/gap5/g-os.h
+find_repeats.o: $(SRCROOT)/gap5/g-request.h
+find_repeats.o: $(SRCROOT)/gap5/g-struct.h
+find_repeats.o: $(SRCROOT)/gap5/g.h
+find_repeats.o: $(SRCROOT)/gap5/gap4_compat.h
+find_repeats.o: $(SRCROOT)/gap5/gap_globals.h
+find_repeats.o: $(SRCROOT)/gap5/gap_hash.h
+find_repeats.o: $(SRCROOT)/gap5/hache_table.h
+find_repeats.o: $(SRCROOT)/gap5/io_utils.h
+find_repeats.o: $(SRCROOT)/gap5/tg_anno.h
+find_repeats.o: $(SRCROOT)/gap5/tg_bin.h
+find_repeats.o: $(SRCROOT)/gap5/tg_cache_item.h
+find_repeats.o: $(SRCROOT)/gap5/tg_contig.h
+find_repeats.o: $(SRCROOT)/gap5/tg_gio.h
+find_repeats.o: $(SRCROOT)/gap5/tg_iface.h
+find_repeats.o: $(SRCROOT)/gap5/tg_library.h
+find_repeats.o: $(SRCROOT)/gap5/tg_register.h
+find_repeats.o: $(SRCROOT)/gap5/tg_scaffold.h
+find_repeats.o: $(SRCROOT)/gap5/tg_sequence.h
+find_repeats.o: $(SRCROOT)/gap5/tg_struct.h
+find_repeats.o: $(SRCROOT)/gap5/tg_tcl.h
+find_repeats.o: $(SRCROOT)/gap5/tg_track.h
+find_repeats.o: $(SRCROOT)/gap5/tg_utils.h
+find_repeats.o: $(SRCROOT)/gap5/tk-io-reg.h
+find_repeats.o: $(SRCROOT)/gap5/tkEdNames.h
+find_repeats.o: $(SRCROOT)/gap5/tkEditor.h
+find_repeats.o: $(SRCROOT)/seq_utils/dna_utils.h
+find_repeats.o: $(SRCROOT)/tk_utils/canvas_box.h
+find_repeats.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+find_repeats.o: $(SRCROOT)/tk_utils/sheet.h
+find_repeats.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+find_repeats.o: $(SRCROOT)/tk_utils/tcl_utils.h
+find_repeats.o: $(SRCROOT)/tk_utils/text_output.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkSheet.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+find_repeats.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 g-alloc.o: $(PWD)/staden_config.h
+g-alloc.o: $(SRCROOT)/Misc/os.h
+g-alloc.o: $(SRCROOT)/gap5/g-alloc.h
 g-connect.o: $(PWD)/staden_config.h
+g-connect.o: $(SRCROOT)/Misc/array.h
+g-connect.o: $(SRCROOT)/Misc/os.h
+g-connect.o: $(SRCROOT)/Misc/xerror.h
+g-connect.o: $(SRCROOT)/gap5/g-alloc.h
+g-connect.o: $(SRCROOT)/gap5/g-connect.h
+g-connect.o: $(SRCROOT)/gap5/g-db.h
+g-connect.o: $(SRCROOT)/gap5/g-defs.h
+g-connect.o: $(SRCROOT)/gap5/g-error.h
+g-connect.o: $(SRCROOT)/gap5/g-filedefs.h
+g-connect.o: $(SRCROOT)/gap5/g-os.h
+g-connect.o: $(SRCROOT)/gap5/g-struct.h
+g-connect.o: $(SRCROOT)/gap5/hache_table.h
 g-db.o: $(PWD)/staden_config.h
+g-db.o: $(SRCROOT)/Misc/array.h
+g-db.o: $(SRCROOT)/Misc/os.h
+g-db.o: $(SRCROOT)/Misc/xerror.h
+g-db.o: $(SRCROOT)/gap5/g-alloc.h
+g-db.o: $(SRCROOT)/gap5/g-db.h
+g-db.o: $(SRCROOT)/gap5/g-defs.h
+g-db.o: $(SRCROOT)/gap5/g-error.h
+g-db.o: $(SRCROOT)/gap5/g-filedefs.h
+g-db.o: $(SRCROOT)/gap5/g-files.h
+g-db.o: $(SRCROOT)/gap5/g-io.h
+g-db.o: $(SRCROOT)/gap5/g-os.h
+g-db.o: $(SRCROOT)/gap5/g-request.h
+g-db.o: $(SRCROOT)/gap5/g-struct.h
+g-db.o: $(SRCROOT)/gap5/hache_table.h
+g-error.o: $(SRCROOT)/Misc/xerror.h
+g-error.o: $(SRCROOT)/gap5/g-error.h
+g-error.o: $(SRCROOT)/gap5/g-misc.h
 g-files.o: $(PWD)/staden_config.h
+g-files.o: $(SRCROOT)/Misc/array.h
+g-files.o: $(SRCROOT)/Misc/misc.h
+g-files.o: $(SRCROOT)/Misc/os.h
+g-files.o: $(SRCROOT)/Misc/xalloc.h
+g-files.o: $(SRCROOT)/Misc/xerror.h
+g-files.o: $(SRCROOT)/gap5/g-alloc.h
+g-files.o: $(SRCROOT)/gap5/g-db.h
+g-files.o: $(SRCROOT)/gap5/g-defs.h
+g-files.o: $(SRCROOT)/gap5/g-error.h
+g-files.o: $(SRCROOT)/gap5/g-filedefs.h
+g-files.o: $(SRCROOT)/gap5/g-files.h
+g-files.o: $(SRCROOT)/gap5/g-io.h
+g-files.o: $(SRCROOT)/gap5/g-os.h
+g-files.o: $(SRCROOT)/gap5/g-struct.h
+g-files.o: $(SRCROOT)/gap5/hache_table.h
 g-io.o: $(PWD)/staden_config.h
+g-io.o: $(SRCROOT)/Misc/array.h
+g-io.o: $(SRCROOT)/Misc/os.h
+g-io.o: $(SRCROOT)/Misc/xerror.h
+g-io.o: $(SRCROOT)/gap5/g-alloc.h
+g-io.o: $(SRCROOT)/gap5/g-filedefs.h
+g-io.o: $(SRCROOT)/gap5/g-files.h
+g-io.o: $(SRCROOT)/gap5/g-io.h
+g-io.o: $(SRCROOT)/gap5/g-os.h
+g-io.o: $(SRCROOT)/gap5/g-struct.h
+g-io.o: $(SRCROOT)/gap5/hache_table.h
 g-request.o: $(PWD)/staden_config.h
+g-request.o: $(SRCROOT)/Misc/array.h
+g-request.o: $(SRCROOT)/Misc/os.h
+g-request.o: $(SRCROOT)/Misc/xalloc.h
+g-request.o: $(SRCROOT)/Misc/xerror.h
+g-request.o: $(SRCROOT)/gap5/g-alloc.h
+g-request.o: $(SRCROOT)/gap5/g-db.h
+g-request.o: $(SRCROOT)/gap5/g-defs.h
+g-request.o: $(SRCROOT)/gap5/g-error.h
+g-request.o: $(SRCROOT)/gap5/g-filedefs.h
+g-request.o: $(SRCROOT)/gap5/g-files.h
+g-request.o: $(SRCROOT)/gap5/g-misc.h
+g-request.o: $(SRCROOT)/gap5/g-os.h
+g-request.o: $(SRCROOT)/gap5/g-request.h
+g-request.o: $(SRCROOT)/gap5/g-struct.h
+g-request.o: $(SRCROOT)/gap5/hache_table.h
 g-struct.o: $(PWD)/staden_config.h
+g-struct.o: $(SRCROOT)/Misc/array.h
+g-struct.o: $(SRCROOT)/Misc/os.h
+g-struct.o: $(SRCROOT)/Misc/xalloc.h
+g-struct.o: $(SRCROOT)/Misc/xerror.h
+g-struct.o: $(SRCROOT)/gap5/g-alloc.h
+g-struct.o: $(SRCROOT)/gap5/g-filedefs.h
+g-struct.o: $(SRCROOT)/gap5/g-files.h
+g-struct.o: $(SRCROOT)/gap5/g-io.h
+g-struct.o: $(SRCROOT)/gap5/g-os.h
+g-struct.o: $(SRCROOT)/gap5/g-struct.h
+g-struct.o: $(SRCROOT)/gap5/hache_table.h
 gap-error.o: $(PWD)/staden_config.h
+gap-error.o: $(SRCROOT)/Misc/array.h
+gap-error.o: $(SRCROOT)/Misc/bitmap.h
+gap-error.o: $(SRCROOT)/Misc/misc.h
+gap-error.o: $(SRCROOT)/Misc/os.h
+gap-error.o: $(SRCROOT)/Misc/xalloc.h
+gap-error.o: $(SRCROOT)/Misc/xerror.h
+gap-error.o: $(SRCROOT)/gap5/g-error.h
+gap-error.o: $(SRCROOT)/gap5/gap-error.h
+gap-error.o: $(SRCROOT)/gap5/stack_dump.h
 gap4_compat.o: $(PWD)/staden_config.h
+gap4_compat.o: $(SRCROOT)/Misc/array.h
+gap4_compat.o: $(SRCROOT)/Misc/misc.h
+gap4_compat.o: $(SRCROOT)/Misc/os.h
+gap4_compat.o: $(SRCROOT)/Misc/tree.h
+gap4_compat.o: $(SRCROOT)/Misc/xalloc.h
+gap4_compat.o: $(SRCROOT)/Misc/xerror.h
+gap4_compat.o: $(SRCROOT)/gap5/b+tree2.h
+gap4_compat.o: $(SRCROOT)/gap5/consensus.h
+gap4_compat.o: $(SRCROOT)/gap5/g-alloc.h
+gap4_compat.o: $(SRCROOT)/gap5/g-connect.h
+gap4_compat.o: $(SRCROOT)/gap5/g-db.h
+gap4_compat.o: $(SRCROOT)/gap5/g-defs.h
+gap4_compat.o: $(SRCROOT)/gap5/g-error.h
+gap4_compat.o: $(SRCROOT)/gap5/g-filedefs.h
+gap4_compat.o: $(SRCROOT)/gap5/g-io.h
+gap4_compat.o: $(SRCROOT)/gap5/g-misc.h
+gap4_compat.o: $(SRCROOT)/gap5/g-os.h
+gap4_compat.o: $(SRCROOT)/gap5/g-request.h
+gap4_compat.o: $(SRCROOT)/gap5/g-struct.h
+gap4_compat.o: $(SRCROOT)/gap5/g.h
+gap4_compat.o: $(SRCROOT)/gap5/gap4_compat.h
+gap4_compat.o: $(SRCROOT)/gap5/hache_table.h
+gap4_compat.o: $(SRCROOT)/gap5/io_utils.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_anno.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_bin.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_cache_item.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_contig.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_gio.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_iface.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_library.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_register.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_scaffold.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_sequence.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_struct.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_tcl.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_track.h
+gap4_compat.o: $(SRCROOT)/gap5/tg_utils.h
 gap_canvas_box.o: $(PWD)/staden_config.h
+gap_canvas_box.o: $(SRCROOT)/Misc/array.h
+gap_canvas_box.o: $(SRCROOT)/Misc/misc.h
+gap_canvas_box.o: $(SRCROOT)/Misc/os.h
+gap_canvas_box.o: $(SRCROOT)/Misc/tree.h
+gap_canvas_box.o: $(SRCROOT)/Misc/xalloc.h
+gap_canvas_box.o: $(SRCROOT)/Misc/xerror.h
+gap_canvas_box.o: $(SRCROOT)/gap5/b+tree2.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-alloc.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-connect.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-db.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-defs.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-error.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-filedefs.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-io.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-misc.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-os.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-request.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g-struct.h
+gap_canvas_box.o: $(SRCROOT)/gap5/g.h
+gap_canvas_box.o: $(SRCROOT)/gap5/gap4_compat.h
+gap_canvas_box.o: $(SRCROOT)/gap5/gap_globals.h
+gap_canvas_box.o: $(SRCROOT)/gap5/hache_table.h
+gap_canvas_box.o: $(SRCROOT)/gap5/io_utils.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_anno.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_bin.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_cache_item.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_contig.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_gio.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_iface.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_library.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_register.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_scaffold.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_sequence.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_struct.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_tcl.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_track.h
+gap_canvas_box.o: $(SRCROOT)/gap5/tg_utils.h
+gap_canvas_box.o: $(SRCROOT)/tk_utils/canvas_box.h
+gap_canvas_box.o: $(SRCROOT)/tk_utils/tcl_utils.h
 gap_cli_arg.o: $(PWD)/staden_config.h
+gap_cli_arg.o: $(SRCROOT)/Misc/array.h
+gap_cli_arg.o: $(SRCROOT)/Misc/misc.h
+gap_cli_arg.o: $(SRCROOT)/Misc/os.h
+gap_cli_arg.o: $(SRCROOT)/Misc/tree.h
+gap_cli_arg.o: $(SRCROOT)/Misc/xalloc.h
+gap_cli_arg.o: $(SRCROOT)/Misc/xerror.h
+gap_cli_arg.o: $(SRCROOT)/gap5/b+tree2.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-alloc.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-connect.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-db.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-defs.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-error.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-filedefs.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-io.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-misc.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-os.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-request.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g-struct.h
+gap_cli_arg.o: $(SRCROOT)/gap5/g.h
+gap_cli_arg.o: $(SRCROOT)/gap5/gap_cli_arg.h
+gap_cli_arg.o: $(SRCROOT)/gap5/hache_table.h
+gap_cli_arg.o: $(SRCROOT)/gap5/io_utils.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_anno.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_bin.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_cache_item.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_contig.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_gio.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_iface.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_library.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_register.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_scaffold.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_sequence.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_struct.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_tcl.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_track.h
+gap_cli_arg.o: $(SRCROOT)/gap5/tg_utils.h
 gap_globals.o: $(PWD)/staden_config.h
+gap_globals.o: $(SRCROOT)/Misc/array.h
+gap_globals.o: $(SRCROOT)/Misc/misc.h
+gap_globals.o: $(SRCROOT)/Misc/os.h
+gap_globals.o: $(SRCROOT)/Misc/tree.h
+gap_globals.o: $(SRCROOT)/Misc/xalloc.h
+gap_globals.o: $(SRCROOT)/Misc/xerror.h
+gap_globals.o: $(SRCROOT)/gap5/b+tree2.h
+gap_globals.o: $(SRCROOT)/gap5/consen.h
+gap_globals.o: $(SRCROOT)/gap5/g-alloc.h
+gap_globals.o: $(SRCROOT)/gap5/g-connect.h
+gap_globals.o: $(SRCROOT)/gap5/g-db.h
+gap_globals.o: $(SRCROOT)/gap5/g-defs.h
+gap_globals.o: $(SRCROOT)/gap5/g-error.h
+gap_globals.o: $(SRCROOT)/gap5/g-filedefs.h
+gap_globals.o: $(SRCROOT)/gap5/g-io.h
+gap_globals.o: $(SRCROOT)/gap5/g-misc.h
+gap_globals.o: $(SRCROOT)/gap5/g-os.h
+gap_globals.o: $(SRCROOT)/gap5/g-request.h
+gap_globals.o: $(SRCROOT)/gap5/g-struct.h
+gap_globals.o: $(SRCROOT)/gap5/g.h
+gap_globals.o: $(SRCROOT)/gap5/gap_globals.h
+gap_globals.o: $(SRCROOT)/gap5/hache_table.h
+gap_globals.o: $(SRCROOT)/gap5/hash_lib.h
+gap_globals.o: $(SRCROOT)/gap5/io_utils.h
+gap_globals.o: $(SRCROOT)/gap5/notedb.h
+gap_globals.o: $(SRCROOT)/gap5/tg_anno.h
+gap_globals.o: $(SRCROOT)/gap5/tg_bin.h
+gap_globals.o: $(SRCROOT)/gap5/tg_cache_item.h
+gap_globals.o: $(SRCROOT)/gap5/tg_contig.h
+gap_globals.o: $(SRCROOT)/gap5/tg_gio.h
+gap_globals.o: $(SRCROOT)/gap5/tg_iface.h
+gap_globals.o: $(SRCROOT)/gap5/tg_library.h
+gap_globals.o: $(SRCROOT)/gap5/tg_register.h
+gap_globals.o: $(SRCROOT)/gap5/tg_scaffold.h
+gap_globals.o: $(SRCROOT)/gap5/tg_sequence.h
+gap_globals.o: $(SRCROOT)/gap5/tg_struct.h
+gap_globals.o: $(SRCROOT)/gap5/tg_tcl.h
+gap_globals.o: $(SRCROOT)/gap5/tg_track.h
+gap_globals.o: $(SRCROOT)/gap5/tg_utils.h
+gap_globals.o: $(SRCROOT)/seq_utils/align.h
+gap_globals.o: $(SRCROOT)/seq_utils/align_lib.h
+gap_globals.o: $(SRCROOT)/seq_utils/align_lib_old.h
+gap_globals.o: $(SRCROOT)/seq_utils/dna_utils.h
+gap_globals.o: $(SRCROOT)/seq_utils/genetic_code.h
+gap_globals.o: $(SRCROOT)/seq_utils/read_matrix.h
+gap_globals.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+gap_globals.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+gap_globals.o: $(SRCROOT)/tk_utils/tcl_utils.h
 gap_hash.o: $(PWD)/staden_config.h
+gap_hash.o: $(SRCROOT)/Misc/array.h
+gap_hash.o: $(SRCROOT)/Misc/misc.h
+gap_hash.o: $(SRCROOT)/Misc/os.h
+gap_hash.o: $(SRCROOT)/Misc/tree.h
+gap_hash.o: $(SRCROOT)/Misc/xalloc.h
+gap_hash.o: $(SRCROOT)/Misc/xerror.h
+gap_hash.o: $(SRCROOT)/gap5/b+tree2.h
+gap_hash.o: $(SRCROOT)/gap5/consen.h
+gap_hash.o: $(SRCROOT)/gap5/g-alloc.h
+gap_hash.o: $(SRCROOT)/gap5/g-connect.h
+gap_hash.o: $(SRCROOT)/gap5/g-db.h
+gap_hash.o: $(SRCROOT)/gap5/g-defs.h
+gap_hash.o: $(SRCROOT)/gap5/g-error.h
+gap_hash.o: $(SRCROOT)/gap5/g-filedefs.h
+gap_hash.o: $(SRCROOT)/gap5/g-io.h
+gap_hash.o: $(SRCROOT)/gap5/g-misc.h
+gap_hash.o: $(SRCROOT)/gap5/g-os.h
+gap_hash.o: $(SRCROOT)/gap5/g-request.h
+gap_hash.o: $(SRCROOT)/gap5/g-struct.h
+gap_hash.o: $(SRCROOT)/gap5/g.h
+gap_hash.o: $(SRCROOT)/gap5/gap_hash.h
+gap_hash.o: $(SRCROOT)/gap5/hache_table.h
+gap_hash.o: $(SRCROOT)/gap5/hash_lib.h
+gap_hash.o: $(SRCROOT)/gap5/io_utils.h
+gap_hash.o: $(SRCROOT)/gap5/tg_anno.h
+gap_hash.o: $(SRCROOT)/gap5/tg_bin.h
+gap_hash.o: $(SRCROOT)/gap5/tg_cache_item.h
+gap_hash.o: $(SRCROOT)/gap5/tg_contig.h
+gap_hash.o: $(SRCROOT)/gap5/tg_gio.h
+gap_hash.o: $(SRCROOT)/gap5/tg_iface.h
+gap_hash.o: $(SRCROOT)/gap5/tg_library.h
+gap_hash.o: $(SRCROOT)/gap5/tg_register.h
+gap_hash.o: $(SRCROOT)/gap5/tg_scaffold.h
+gap_hash.o: $(SRCROOT)/gap5/tg_sequence.h
+gap_hash.o: $(SRCROOT)/gap5/tg_struct.h
+gap_hash.o: $(SRCROOT)/gap5/tg_tcl.h
+gap_hash.o: $(SRCROOT)/gap5/tg_track.h
+gap_hash.o: $(SRCROOT)/gap5/tg_utils.h
+gap_hash.o: $(SRCROOT)/seq_utils/align_lib.h
+gap_hash.o: $(SRCROOT)/seq_utils/dna_utils.h
 gap_range.o: $(PWD)/staden_config.h
+gap_range.o: $(SRCROOT)/Misc/array.h
+gap_range.o: $(SRCROOT)/Misc/misc.h
+gap_range.o: $(SRCROOT)/Misc/os.h
+gap_range.o: $(SRCROOT)/Misc/tree.h
+gap_range.o: $(SRCROOT)/Misc/xalloc.h
+gap_range.o: $(SRCROOT)/Misc/xerror.h
+gap_range.o: $(SRCROOT)/gap5/b+tree2.h
+gap_range.o: $(SRCROOT)/gap5/g-alloc.h
+gap_range.o: $(SRCROOT)/gap5/g-connect.h
+gap_range.o: $(SRCROOT)/gap5/g-db.h
+gap_range.o: $(SRCROOT)/gap5/g-defs.h
+gap_range.o: $(SRCROOT)/gap5/g-error.h
+gap_range.o: $(SRCROOT)/gap5/g-filedefs.h
+gap_range.o: $(SRCROOT)/gap5/g-io.h
+gap_range.o: $(SRCROOT)/gap5/g-misc.h
+gap_range.o: $(SRCROOT)/gap5/g-os.h
+gap_range.o: $(SRCROOT)/gap5/g-request.h
+gap_range.o: $(SRCROOT)/gap5/g-struct.h
+gap_range.o: $(SRCROOT)/gap5/g.h
+gap_range.o: $(SRCROOT)/gap5/gap_cli_arg.h
+gap_range.o: $(SRCROOT)/gap5/gap_range.h
+gap_range.o: $(SRCROOT)/gap5/hache_table.h
+gap_range.o: $(SRCROOT)/gap5/io_utils.h
+gap_range.o: $(SRCROOT)/gap5/tg_anno.h
+gap_range.o: $(SRCROOT)/gap5/tg_bin.h
+gap_range.o: $(SRCROOT)/gap5/tg_cache_item.h
+gap_range.o: $(SRCROOT)/gap5/tg_contig.h
+gap_range.o: $(SRCROOT)/gap5/tg_gio.h
+gap_range.o: $(SRCROOT)/gap5/tg_iface.h
+gap_range.o: $(SRCROOT)/gap5/tg_library.h
+gap_range.o: $(SRCROOT)/gap5/tg_register.h
+gap_range.o: $(SRCROOT)/gap5/tg_scaffold.h
+gap_range.o: $(SRCROOT)/gap5/tg_sequence.h
+gap_range.o: $(SRCROOT)/gap5/tg_struct.h
+gap_range.o: $(SRCROOT)/gap5/tg_tcl.h
+gap_range.o: $(SRCROOT)/gap5/tg_track.h
+gap_range.o: $(SRCROOT)/gap5/tg_utils.h
 hache_table.o: $(PWD)/staden_config.h
+hache_table.o: $(SRCROOT)/Misc/os.h
+hache_table.o: $(SRCROOT)/gap5/hache_table.h
 hash_lib.o: $(PWD)/staden_config.h
+hash_lib.o: $(SRCROOT)/Misc/array.h
+hash_lib.o: $(SRCROOT)/Misc/misc.h
+hash_lib.o: $(SRCROOT)/Misc/os.h
+hash_lib.o: $(SRCROOT)/Misc/tree.h
+hash_lib.o: $(SRCROOT)/Misc/xalloc.h
+hash_lib.o: $(SRCROOT)/Misc/xerror.h
+hash_lib.o: $(SRCROOT)/gap5/b+tree2.h
+hash_lib.o: $(SRCROOT)/gap5/consen.h
+hash_lib.o: $(SRCROOT)/gap5/fij.h
+hash_lib.o: $(SRCROOT)/gap5/g-alloc.h
+hash_lib.o: $(SRCROOT)/gap5/g-connect.h
+hash_lib.o: $(SRCROOT)/gap5/g-db.h
+hash_lib.o: $(SRCROOT)/gap5/g-defs.h
+hash_lib.o: $(SRCROOT)/gap5/g-error.h
+hash_lib.o: $(SRCROOT)/gap5/g-filedefs.h
+hash_lib.o: $(SRCROOT)/gap5/g-io.h
+hash_lib.o: $(SRCROOT)/gap5/g-misc.h
+hash_lib.o: $(SRCROOT)/gap5/g-os.h
+hash_lib.o: $(SRCROOT)/gap5/g-request.h
+hash_lib.o: $(SRCROOT)/gap5/g-struct.h
+hash_lib.o: $(SRCROOT)/gap5/g.h
+hash_lib.o: $(SRCROOT)/gap5/hache_table.h
+hash_lib.o: $(SRCROOT)/gap5/hash_lib.h
+hash_lib.o: $(SRCROOT)/gap5/io_utils.h
+hash_lib.o: $(SRCROOT)/gap5/newgap_structs.h
+hash_lib.o: $(SRCROOT)/gap5/tg_anno.h
+hash_lib.o: $(SRCROOT)/gap5/tg_bin.h
+hash_lib.o: $(SRCROOT)/gap5/tg_cache_item.h
+hash_lib.o: $(SRCROOT)/gap5/tg_contig.h
+hash_lib.o: $(SRCROOT)/gap5/tg_gio.h
+hash_lib.o: $(SRCROOT)/gap5/tg_iface.h
+hash_lib.o: $(SRCROOT)/gap5/tg_library.h
+hash_lib.o: $(SRCROOT)/gap5/tg_register.h
+hash_lib.o: $(SRCROOT)/gap5/tg_scaffold.h
+hash_lib.o: $(SRCROOT)/gap5/tg_sequence.h
+hash_lib.o: $(SRCROOT)/gap5/tg_struct.h
+hash_lib.o: $(SRCROOT)/gap5/tg_tcl.h
+hash_lib.o: $(SRCROOT)/gap5/tg_track.h
+hash_lib.o: $(SRCROOT)/gap5/tg_utils.h
+hash_lib.o: $(SRCROOT)/seq_utils/align_lib.h
+hash_lib.o: $(SRCROOT)/seq_utils/dna_utils.h
 import_gff.o: $(PWD)/staden_config.h
+import_gff.o: $(SRCROOT)/Misc/array.h
+import_gff.o: $(SRCROOT)/Misc/dstring.h
+import_gff.o: $(SRCROOT)/Misc/misc.h
+import_gff.o: $(SRCROOT)/Misc/os.h
+import_gff.o: $(SRCROOT)/Misc/tree.h
+import_gff.o: $(SRCROOT)/Misc/xalloc.h
+import_gff.o: $(SRCROOT)/Misc/xerror.h
+import_gff.o: $(SRCROOT)/gap5/b+tree2.h
+import_gff.o: $(SRCROOT)/gap5/consensus.h
+import_gff.o: $(SRCROOT)/gap5/export_contigs.h
+import_gff.o: $(SRCROOT)/gap5/g-alloc.h
+import_gff.o: $(SRCROOT)/gap5/g-connect.h
+import_gff.o: $(SRCROOT)/gap5/g-db.h
+import_gff.o: $(SRCROOT)/gap5/g-defs.h
+import_gff.o: $(SRCROOT)/gap5/g-error.h
+import_gff.o: $(SRCROOT)/gap5/g-filedefs.h
+import_gff.o: $(SRCROOT)/gap5/g-io.h
+import_gff.o: $(SRCROOT)/gap5/g-misc.h
+import_gff.o: $(SRCROOT)/gap5/g-os.h
+import_gff.o: $(SRCROOT)/gap5/g-request.h
+import_gff.o: $(SRCROOT)/gap5/g-struct.h
+import_gff.o: $(SRCROOT)/gap5/g.h
+import_gff.o: $(SRCROOT)/gap5/gap_cli_arg.h
+import_gff.o: $(SRCROOT)/gap5/hache_table.h
+import_gff.o: $(SRCROOT)/gap5/import_gff.h
+import_gff.o: $(SRCROOT)/gap5/io_utils.h
+import_gff.o: $(SRCROOT)/gap5/tg_anno.h
+import_gff.o: $(SRCROOT)/gap5/tg_bin.h
+import_gff.o: $(SRCROOT)/gap5/tg_cache_item.h
+import_gff.o: $(SRCROOT)/gap5/tg_contig.h
+import_gff.o: $(SRCROOT)/gap5/tg_gio.h
+import_gff.o: $(SRCROOT)/gap5/tg_iface.h
+import_gff.o: $(SRCROOT)/gap5/tg_library.h
+import_gff.o: $(SRCROOT)/gap5/tg_register.h
+import_gff.o: $(SRCROOT)/gap5/tg_scaffold.h
+import_gff.o: $(SRCROOT)/gap5/tg_sequence.h
+import_gff.o: $(SRCROOT)/gap5/tg_struct.h
+import_gff.o: $(SRCROOT)/gap5/tg_tcl.h
+import_gff.o: $(SRCROOT)/gap5/tg_track.h
+import_gff.o: $(SRCROOT)/gap5/tg_utils.h
 init.o: $(PWD)/staden_config.h
+init.o: $(SRCROOT)/Misc/array.h
+init.o: $(SRCROOT)/Misc/misc.h
+init.o: $(SRCROOT)/Misc/os.h
+init.o: $(SRCROOT)/Misc/tree.h
+init.o: $(SRCROOT)/Misc/xalloc.h
+init.o: $(SRCROOT)/Misc/xerror.h
+init.o: $(SRCROOT)/gap5/active_tags.h
+init.o: $(SRCROOT)/gap5/b+tree2.h
+init.o: $(SRCROOT)/gap5/g-alloc.h
+init.o: $(SRCROOT)/gap5/g-connect.h
+init.o: $(SRCROOT)/gap5/g-db.h
+init.o: $(SRCROOT)/gap5/g-defs.h
+init.o: $(SRCROOT)/gap5/g-error.h
+init.o: $(SRCROOT)/gap5/g-filedefs.h
+init.o: $(SRCROOT)/gap5/g-io.h
+init.o: $(SRCROOT)/gap5/g-misc.h
+init.o: $(SRCROOT)/gap5/g-os.h
+init.o: $(SRCROOT)/gap5/g-request.h
+init.o: $(SRCROOT)/gap5/g-struct.h
+init.o: $(SRCROOT)/gap5/g.h
+init.o: $(SRCROOT)/gap5/gap_globals.h
+init.o: $(SRCROOT)/gap5/hache_table.h
+init.o: $(SRCROOT)/gap5/io_utils.h
+init.o: $(SRCROOT)/gap5/list.h
+init.o: $(SRCROOT)/gap5/newgap_cmds.h
+init.o: $(SRCROOT)/gap5/tagdb.h
+init.o: $(SRCROOT)/gap5/tg_anno.h
+init.o: $(SRCROOT)/gap5/tg_bin.h
+init.o: $(SRCROOT)/gap5/tg_cache_item.h
+init.o: $(SRCROOT)/gap5/tg_contig.h
+init.o: $(SRCROOT)/gap5/tg_gio.h
+init.o: $(SRCROOT)/gap5/tg_iface.h
+init.o: $(SRCROOT)/gap5/tg_library.h
+init.o: $(SRCROOT)/gap5/tg_register.h
+init.o: $(SRCROOT)/gap5/tg_scaffold.h
+init.o: $(SRCROOT)/gap5/tg_sequence.h
+init.o: $(SRCROOT)/gap5/tg_struct.h
+init.o: $(SRCROOT)/gap5/tg_tcl.h
+init.o: $(SRCROOT)/gap5/tg_track.h
+init.o: $(SRCROOT)/gap5/tg_utils.h
+init.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+init.o: $(SRCROOT)/tk_utils/tcl_utils.h
+interval_tree.o: $(SRCROOT)/Misc/tree.h
+interval_tree.o: $(SRCROOT)/gap5/interval_tree.h
 list_proc.o: $(PWD)/staden_config.h
+list_proc.o: $(SRCROOT)/Misc/FtoC.h
+list_proc.o: $(SRCROOT)/Misc/array.h
+list_proc.o: $(SRCROOT)/Misc/misc.h
+list_proc.o: $(SRCROOT)/Misc/os.h
+list_proc.o: $(SRCROOT)/Misc/tree.h
+list_proc.o: $(SRCROOT)/Misc/xalloc.h
+list_proc.o: $(SRCROOT)/Misc/xerror.h
+list_proc.o: $(SRCROOT)/gap5/b+tree2.h
+list_proc.o: $(SRCROOT)/gap5/g-alloc.h
+list_proc.o: $(SRCROOT)/gap5/g-connect.h
+list_proc.o: $(SRCROOT)/gap5/g-db.h
+list_proc.o: $(SRCROOT)/gap5/g-defs.h
+list_proc.o: $(SRCROOT)/gap5/g-error.h
+list_proc.o: $(SRCROOT)/gap5/g-filedefs.h
+list_proc.o: $(SRCROOT)/gap5/g-io.h
+list_proc.o: $(SRCROOT)/gap5/g-misc.h
+list_proc.o: $(SRCROOT)/gap5/g-os.h
+list_proc.o: $(SRCROOT)/gap5/g-request.h
+list_proc.o: $(SRCROOT)/gap5/g-struct.h
+list_proc.o: $(SRCROOT)/gap5/g.h
+list_proc.o: $(SRCROOT)/gap5/gap4_compat.h
+list_proc.o: $(SRCROOT)/gap5/gap_globals.h
+list_proc.o: $(SRCROOT)/gap5/hache_table.h
+list_proc.o: $(SRCROOT)/gap5/io_utils.h
+list_proc.o: $(SRCROOT)/gap5/list.h
+list_proc.o: $(SRCROOT)/gap5/newgap_cmds.h
+list_proc.o: $(SRCROOT)/gap5/tg_anno.h
+list_proc.o: $(SRCROOT)/gap5/tg_bin.h
+list_proc.o: $(SRCROOT)/gap5/tg_cache_item.h
+list_proc.o: $(SRCROOT)/gap5/tg_contig.h
+list_proc.o: $(SRCROOT)/gap5/tg_gio.h
+list_proc.o: $(SRCROOT)/gap5/tg_iface.h
+list_proc.o: $(SRCROOT)/gap5/tg_library.h
+list_proc.o: $(SRCROOT)/gap5/tg_register.h
+list_proc.o: $(SRCROOT)/gap5/tg_scaffold.h
+list_proc.o: $(SRCROOT)/gap5/tg_sequence.h
+list_proc.o: $(SRCROOT)/gap5/tg_struct.h
+list_proc.o: $(SRCROOT)/gap5/tg_tcl.h
+list_proc.o: $(SRCROOT)/gap5/tg_track.h
+list_proc.o: $(SRCROOT)/gap5/tg_utils.h
+list_proc.o: $(SRCROOT)/tk_utils/tcl_utils.h
 maq.o: $(PWD)/staden_config.h
+maq.o: $(SRCROOT)/Misc/array.h
+maq.o: $(SRCROOT)/Misc/misc.h
+maq.o: $(SRCROOT)/Misc/os.h
+maq.o: $(SRCROOT)/Misc/string_alloc.h
+maq.o: $(SRCROOT)/Misc/tree.h
+maq.o: $(SRCROOT)/Misc/xalloc.h
+maq.o: $(SRCROOT)/Misc/xerror.h
+maq.o: $(SRCROOT)/gap5/b+tree2.h
+maq.o: $(SRCROOT)/gap5/g-alloc.h
+maq.o: $(SRCROOT)/gap5/g-connect.h
+maq.o: $(SRCROOT)/gap5/g-db.h
+maq.o: $(SRCROOT)/gap5/g-defs.h
+maq.o: $(SRCROOT)/gap5/g-error.h
+maq.o: $(SRCROOT)/gap5/g-filedefs.h
+maq.o: $(SRCROOT)/gap5/g-io.h
+maq.o: $(SRCROOT)/gap5/g-misc.h
+maq.o: $(SRCROOT)/gap5/g-os.h
+maq.o: $(SRCROOT)/gap5/g-request.h
+maq.o: $(SRCROOT)/gap5/g-struct.h
+maq.o: $(SRCROOT)/gap5/g.h
+maq.o: $(SRCROOT)/gap5/hache_table.h
+maq.o: $(SRCROOT)/gap5/io_utils.h
+maq.o: $(SRCROOT)/gap5/maq.h
+maq.o: $(SRCROOT)/gap5/maqmap.h
+maq.o: $(SRCROOT)/gap5/tg_anno.h
+maq.o: $(SRCROOT)/gap5/tg_bin.h
+maq.o: $(SRCROOT)/gap5/tg_cache_item.h
+maq.o: $(SRCROOT)/gap5/tg_contig.h
+maq.o: $(SRCROOT)/gap5/tg_gio.h
+maq.o: $(SRCROOT)/gap5/tg_iface.h
+maq.o: $(SRCROOT)/gap5/tg_index.h
+maq.o: $(SRCROOT)/gap5/tg_index_common.h
+maq.o: $(SRCROOT)/gap5/tg_library.h
+maq.o: $(SRCROOT)/gap5/tg_register.h
+maq.o: $(SRCROOT)/gap5/tg_scaffold.h
+maq.o: $(SRCROOT)/gap5/tg_sequence.h
+maq.o: $(SRCROOT)/gap5/tg_struct.h
+maq.o: $(SRCROOT)/gap5/tg_tcl.h
+maq.o: $(SRCROOT)/gap5/tg_track.h
+maq.o: $(SRCROOT)/gap5/tg_utils.h
+maqmap.o: $(SRCROOT)/gap5/maqmap.h
 newgap5_cmds.o: $(PWD)/staden_config.h
+newgap5_cmds.o: $(SRCROOT)/Misc/array.h
+newgap5_cmds.o: $(SRCROOT)/Misc/dstring.h
+newgap5_cmds.o: $(SRCROOT)/Misc/misc.h
+newgap5_cmds.o: $(SRCROOT)/Misc/os.h
+newgap5_cmds.o: $(SRCROOT)/Misc/string_alloc.h
+newgap5_cmds.o: $(SRCROOT)/Misc/tree.h
+newgap5_cmds.o: $(SRCROOT)/Misc/xalloc.h
+newgap5_cmds.o: $(SRCROOT)/Misc/xerror.h
+newgap5_cmds.o: $(SRCROOT)/gap5/ace.h
+newgap5_cmds.o: $(SRCROOT)/gap5/active_tags.h
+newgap5_cmds.o: $(SRCROOT)/gap5/afg.h
+newgap5_cmds.o: $(SRCROOT)/gap5/auto_break.h
+newgap5_cmds.o: $(SRCROOT)/gap5/b+tree2.h
+newgap5_cmds.o: $(SRCROOT)/gap5/baf.h
+newgap5_cmds.o: $(SRCROOT)/gap5/break_contig.h
+newgap5_cmds.o: $(SRCROOT)/gap5/caf.h
+newgap5_cmds.o: $(SRCROOT)/gap5/check_assembly.h
+newgap5_cmds.o: $(SRCROOT)/gap5/consen.h
+newgap5_cmds.o: $(SRCROOT)/gap5/consensus.h
+newgap5_cmds.o: $(SRCROOT)/gap5/contig_extend.h
+newgap5_cmds.o: $(SRCROOT)/gap5/contig_selector.h
+newgap5_cmds.o: $(SRCROOT)/gap5/cs-object.h
+newgap5_cmds.o: $(SRCROOT)/gap5/depth_track.h
+newgap5_cmds.o: $(SRCROOT)/gap5/dis_readings.h
+newgap5_cmds.o: $(SRCROOT)/gap5/editor_join.h
+newgap5_cmds.o: $(SRCROOT)/gap5/editor_view.h
+newgap5_cmds.o: $(SRCROOT)/gap5/export_contigs.h
+newgap5_cmds.o: $(SRCROOT)/gap5/export_snps.h
+newgap5_cmds.o: $(SRCROOT)/gap5/fasta.h
+newgap5_cmds.o: $(SRCROOT)/gap5/fij.h
+newgap5_cmds.o: $(SRCROOT)/gap5/find_haplotypes.h
+newgap5_cmds.o: $(SRCROOT)/gap5/find_oligo.h
+newgap5_cmds.o: $(SRCROOT)/gap5/find_repeats.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-alloc.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-connect.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-db.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-defs.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-error.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-filedefs.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-io.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-misc.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-os.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-request.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g-struct.h
+newgap5_cmds.o: $(SRCROOT)/gap5/g.h
+newgap5_cmds.o: $(SRCROOT)/gap5/gap4_compat.h
+newgap5_cmds.o: $(SRCROOT)/gap5/gap_cli_arg.h
+newgap5_cmds.o: $(SRCROOT)/gap5/gap_globals.h
+newgap5_cmds.o: $(SRCROOT)/gap5/gap_range.h
+newgap5_cmds.o: $(SRCROOT)/gap5/hache_table.h
+newgap5_cmds.o: $(SRCROOT)/gap5/hash_lib.h
+newgap5_cmds.o: $(SRCROOT)/gap5/import_gff.h
+newgap5_cmds.o: $(SRCROOT)/gap5/io_handle.h
+newgap5_cmds.o: $(SRCROOT)/gap5/io_utils.h
+newgap5_cmds.o: $(SRCROOT)/gap5/list.h
+newgap5_cmds.o: $(SRCROOT)/gap5/list_proc.h
+newgap5_cmds.o: $(SRCROOT)/gap5/maq.h
+newgap5_cmds.o: $(SRCROOT)/gap5/newgap_cmds.h
+newgap5_cmds.o: $(SRCROOT)/gap5/newgap_structs.h
+newgap5_cmds.o: $(SRCROOT)/gap5/qual.h
+newgap5_cmds.o: $(SRCROOT)/gap5/qualIO.h
+newgap5_cmds.o: $(SRCROOT)/gap5/quality_plot.h
+newgap5_cmds.o: $(SRCROOT)/gap5/read_depth.h
+newgap5_cmds.o: $(SRCROOT)/gap5/readpair.h
+newgap5_cmds.o: $(SRCROOT)/gap5/restriction_enzymes.h
+newgap5_cmds.o: $(SRCROOT)/gap5/sam_index.h
+newgap5_cmds.o: $(SRCROOT)/gap5/shuffle_pads.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tag_plot.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tagdb.h
+newgap5_cmds.o: $(SRCROOT)/gap5/template_display.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_anno.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_bin.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_cache_item.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_contig.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_gio.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_iface.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_index.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_index_common.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_library.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_register.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_scaffold.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_sequence.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_struct.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_tcl.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_track.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tg_utils.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tk-io-reg.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tkEdNames.h
+newgap5_cmds.o: $(SRCROOT)/gap5/tkEditor.h
+newgap5_cmds.o: $(SRCROOT)/seq_utils/align.h
+newgap5_cmds.o: $(SRCROOT)/seq_utils/align_lib.h
+newgap5_cmds.o: $(SRCROOT)/seq_utils/align_lib_old.h
+newgap5_cmds.o: $(SRCROOT)/seq_utils/genetic_code.h
+newgap5_cmds.o: $(SRCROOT)/seq_utils/read_matrix.h
+newgap5_cmds.o: $(SRCROOT)/seq_utils/renz_utils.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/canvas_box.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/sheet.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/tcl_utils.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/text_output.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/tkSheet.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+newgap5_cmds.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 notedb.o: $(PWD)/staden_config.h
+notedb.o: $(SRCROOT)/Misc/misc.h
+notedb.o: $(SRCROOT)/Misc/os.h
+notedb.o: $(SRCROOT)/Misc/parse_db.h
+notedb.o: $(SRCROOT)/Misc/xalloc.h
+notedb.o: $(SRCROOT)/gap5/notedb.h
+notedb.o: $(SRCROOT)/tk_utils/intrinsic_type.h
 primlib.o: $(PWD)/staden_config.h
+primlib.o: $(SRCROOT)/Misc/misc.h
+primlib.o: $(SRCROOT)/Misc/os.h
+primlib.o: $(SRCROOT)/Misc/xalloc.h
+primlib.o: $(SRCROOT)/gap5/gap_globals.h
+primlib.o: $(SRCROOT)/gap5/primlib.h
+primlib.o: $(SRCROOT)/primer3/src/dpal.h
+primlib.o: $(SRCROOT)/primer3/src/primer3.h
+primlib.o: $(SRCROOT)/tk_utils/tcl_utils.h
+primlib.o: $(SRCROOT)/tk_utils/text_output.h
 qual.o: $(PWD)/staden_config.h
+qual.o: $(SRCROOT)/Misc/array.h
+qual.o: $(SRCROOT)/Misc/misc.h
+qual.o: $(SRCROOT)/Misc/os.h
+qual.o: $(SRCROOT)/Misc/tree.h
+qual.o: $(SRCROOT)/Misc/xalloc.h
+qual.o: $(SRCROOT)/Misc/xerror.h
+qual.o: $(SRCROOT)/gap5/b+tree2.h
+qual.o: $(SRCROOT)/gap5/consensus.h
+qual.o: $(SRCROOT)/gap5/g-alloc.h
+qual.o: $(SRCROOT)/gap5/g-connect.h
+qual.o: $(SRCROOT)/gap5/g-db.h
+qual.o: $(SRCROOT)/gap5/g-defs.h
+qual.o: $(SRCROOT)/gap5/g-error.h
+qual.o: $(SRCROOT)/gap5/g-filedefs.h
+qual.o: $(SRCROOT)/gap5/g-io.h
+qual.o: $(SRCROOT)/gap5/g-misc.h
+qual.o: $(SRCROOT)/gap5/g-os.h
+qual.o: $(SRCROOT)/gap5/g-request.h
+qual.o: $(SRCROOT)/gap5/g-struct.h
+qual.o: $(SRCROOT)/gap5/g.h
+qual.o: $(SRCROOT)/gap5/gap_globals.h
+qual.o: $(SRCROOT)/gap5/hache_table.h
+qual.o: $(SRCROOT)/gap5/io_utils.h
+qual.o: $(SRCROOT)/gap5/qual.h
+qual.o: $(SRCROOT)/gap5/qualP.h
+qual.o: $(SRCROOT)/gap5/tg_anno.h
+qual.o: $(SRCROOT)/gap5/tg_bin.h
+qual.o: $(SRCROOT)/gap5/tg_cache_item.h
+qual.o: $(SRCROOT)/gap5/tg_contig.h
+qual.o: $(SRCROOT)/gap5/tg_gio.h
+qual.o: $(SRCROOT)/gap5/tg_iface.h
+qual.o: $(SRCROOT)/gap5/tg_library.h
+qual.o: $(SRCROOT)/gap5/tg_register.h
+qual.o: $(SRCROOT)/gap5/tg_scaffold.h
+qual.o: $(SRCROOT)/gap5/tg_sequence.h
+qual.o: $(SRCROOT)/gap5/tg_struct.h
+qual.o: $(SRCROOT)/gap5/tg_tcl.h
+qual.o: $(SRCROOT)/gap5/tg_track.h
+qual.o: $(SRCROOT)/gap5/tg_utils.h
+qual.o: $(SRCROOT)/tk_utils/tcl_utils.h
 qualIO.o: $(PWD)/staden_config.h
+qualIO.o: $(SRCROOT)/Misc/array.h
+qualIO.o: $(SRCROOT)/Misc/misc.h
+qualIO.o: $(SRCROOT)/Misc/os.h
+qualIO.o: $(SRCROOT)/Misc/tree.h
+qualIO.o: $(SRCROOT)/Misc/xalloc.h
+qualIO.o: $(SRCROOT)/Misc/xerror.h
+qualIO.o: $(SRCROOT)/gap5/b+tree2.h
+qualIO.o: $(SRCROOT)/gap5/g-alloc.h
+qualIO.o: $(SRCROOT)/gap5/g-connect.h
+qualIO.o: $(SRCROOT)/gap5/g-db.h
+qualIO.o: $(SRCROOT)/gap5/g-defs.h
+qualIO.o: $(SRCROOT)/gap5/g-error.h
+qualIO.o: $(SRCROOT)/gap5/g-filedefs.h
+qualIO.o: $(SRCROOT)/gap5/g-io.h
+qualIO.o: $(SRCROOT)/gap5/g-misc.h
+qualIO.o: $(SRCROOT)/gap5/g-os.h
+qualIO.o: $(SRCROOT)/gap5/g-request.h
+qualIO.o: $(SRCROOT)/gap5/g-struct.h
+qualIO.o: $(SRCROOT)/gap5/g.h
+qualIO.o: $(SRCROOT)/gap5/gap4_compat.h
+qualIO.o: $(SRCROOT)/gap5/gap_globals.h
+qualIO.o: $(SRCROOT)/gap5/hache_table.h
+qualIO.o: $(SRCROOT)/gap5/io_utils.h
+qualIO.o: $(SRCROOT)/gap5/qual.h
+qualIO.o: $(SRCROOT)/gap5/qualP.h
+qualIO.o: $(SRCROOT)/gap5/tg_anno.h
+qualIO.o: $(SRCROOT)/gap5/tg_bin.h
+qualIO.o: $(SRCROOT)/gap5/tg_cache_item.h
+qualIO.o: $(SRCROOT)/gap5/tg_contig.h
+qualIO.o: $(SRCROOT)/gap5/tg_gio.h
+qualIO.o: $(SRCROOT)/gap5/tg_iface.h
+qualIO.o: $(SRCROOT)/gap5/tg_library.h
+qualIO.o: $(SRCROOT)/gap5/tg_register.h
+qualIO.o: $(SRCROOT)/gap5/tg_scaffold.h
+qualIO.o: $(SRCROOT)/gap5/tg_sequence.h
+qualIO.o: $(SRCROOT)/gap5/tg_struct.h
+qualIO.o: $(SRCROOT)/gap5/tg_tcl.h
+qualIO.o: $(SRCROOT)/gap5/tg_track.h
+qualIO.o: $(SRCROOT)/gap5/tg_utils.h
+qualIO.o: $(SRCROOT)/tk_utils/tcl_utils.h
 quality_plot.o: $(PWD)/staden_config.h
+quality_plot.o: $(SRCROOT)/Misc/array.h
+quality_plot.o: $(SRCROOT)/Misc/misc.h
+quality_plot.o: $(SRCROOT)/Misc/os.h
+quality_plot.o: $(SRCROOT)/Misc/tree.h
+quality_plot.o: $(SRCROOT)/Misc/xalloc.h
+quality_plot.o: $(SRCROOT)/Misc/xerror.h
+quality_plot.o: $(SRCROOT)/gap5/b+tree2.h
+quality_plot.o: $(SRCROOT)/gap5/consensus.h
+quality_plot.o: $(SRCROOT)/gap5/g-alloc.h
+quality_plot.o: $(SRCROOT)/gap5/g-connect.h
+quality_plot.o: $(SRCROOT)/gap5/g-db.h
+quality_plot.o: $(SRCROOT)/gap5/g-defs.h
+quality_plot.o: $(SRCROOT)/gap5/g-error.h
+quality_plot.o: $(SRCROOT)/gap5/g-filedefs.h
+quality_plot.o: $(SRCROOT)/gap5/g-io.h
+quality_plot.o: $(SRCROOT)/gap5/g-misc.h
+quality_plot.o: $(SRCROOT)/gap5/g-os.h
+quality_plot.o: $(SRCROOT)/gap5/g-request.h
+quality_plot.o: $(SRCROOT)/gap5/g-struct.h
+quality_plot.o: $(SRCROOT)/gap5/g.h
+quality_plot.o: $(SRCROOT)/gap5/gap_range.h
+quality_plot.o: $(SRCROOT)/gap5/hache_table.h
+quality_plot.o: $(SRCROOT)/gap5/io_utils.h
+quality_plot.o: $(SRCROOT)/gap5/quality_plot.h
+quality_plot.o: $(SRCROOT)/gap5/tg_anno.h
+quality_plot.o: $(SRCROOT)/gap5/tg_bin.h
+quality_plot.o: $(SRCROOT)/gap5/tg_cache_item.h
+quality_plot.o: $(SRCROOT)/gap5/tg_contig.h
+quality_plot.o: $(SRCROOT)/gap5/tg_gio.h
+quality_plot.o: $(SRCROOT)/gap5/tg_iface.h
+quality_plot.o: $(SRCROOT)/gap5/tg_library.h
+quality_plot.o: $(SRCROOT)/gap5/tg_register.h
+quality_plot.o: $(SRCROOT)/gap5/tg_scaffold.h
+quality_plot.o: $(SRCROOT)/gap5/tg_sequence.h
+quality_plot.o: $(SRCROOT)/gap5/tg_struct.h
+quality_plot.o: $(SRCROOT)/gap5/tg_tcl.h
+quality_plot.o: $(SRCROOT)/gap5/tg_track.h
+quality_plot.o: $(SRCROOT)/gap5/tg_utils.h
 read_depth.o: $(PWD)/staden_config.h
+read_depth.o: $(SRCROOT)/Misc/array.h
+read_depth.o: $(SRCROOT)/Misc/misc.h
+read_depth.o: $(SRCROOT)/Misc/os.h
+read_depth.o: $(SRCROOT)/Misc/tree.h
+read_depth.o: $(SRCROOT)/Misc/xalloc.h
+read_depth.o: $(SRCROOT)/Misc/xerror.h
+read_depth.o: $(SRCROOT)/gap5/b+tree2.h
+read_depth.o: $(SRCROOT)/gap5/g-alloc.h
+read_depth.o: $(SRCROOT)/gap5/g-connect.h
+read_depth.o: $(SRCROOT)/gap5/g-db.h
+read_depth.o: $(SRCROOT)/gap5/g-defs.h
+read_depth.o: $(SRCROOT)/gap5/g-error.h
+read_depth.o: $(SRCROOT)/gap5/g-filedefs.h
+read_depth.o: $(SRCROOT)/gap5/g-io.h
+read_depth.o: $(SRCROOT)/gap5/g-misc.h
+read_depth.o: $(SRCROOT)/gap5/g-os.h
+read_depth.o: $(SRCROOT)/gap5/g-request.h
+read_depth.o: $(SRCROOT)/gap5/g-struct.h
+read_depth.o: $(SRCROOT)/gap5/g.h
+read_depth.o: $(SRCROOT)/gap5/hache_table.h
+read_depth.o: $(SRCROOT)/gap5/io_utils.h
+read_depth.o: $(SRCROOT)/gap5/read_depth.h
+read_depth.o: $(SRCROOT)/gap5/tg_anno.h
+read_depth.o: $(SRCROOT)/gap5/tg_bin.h
+read_depth.o: $(SRCROOT)/gap5/tg_cache_item.h
+read_depth.o: $(SRCROOT)/gap5/tg_contig.h
+read_depth.o: $(SRCROOT)/gap5/tg_gio.h
+read_depth.o: $(SRCROOT)/gap5/tg_iface.h
+read_depth.o: $(SRCROOT)/gap5/tg_library.h
+read_depth.o: $(SRCROOT)/gap5/tg_register.h
+read_depth.o: $(SRCROOT)/gap5/tg_scaffold.h
+read_depth.o: $(SRCROOT)/gap5/tg_sequence.h
+read_depth.o: $(SRCROOT)/gap5/tg_struct.h
+read_depth.o: $(SRCROOT)/gap5/tg_tcl.h
+read_depth.o: $(SRCROOT)/gap5/tg_track.h
+read_depth.o: $(SRCROOT)/gap5/tg_utils.h
 readpair.o: $(PWD)/staden_config.h
+readpair.o: $(SRCROOT)/Misc/array.h
+readpair.o: $(SRCROOT)/Misc/misc.h
+readpair.o: $(SRCROOT)/Misc/os.h
+readpair.o: $(SRCROOT)/Misc/tree.h
+readpair.o: $(SRCROOT)/Misc/xalloc.h
+readpair.o: $(SRCROOT)/Misc/xerror.h
+readpair.o: $(SRCROOT)/gap5/b+tree2.h
+readpair.o: $(SRCROOT)/gap5/consensus.h
+readpair.o: $(SRCROOT)/gap5/contig_selector.h
+readpair.o: $(SRCROOT)/gap5/cs-object.h
+readpair.o: $(SRCROOT)/gap5/editor_view.h
+readpair.o: $(SRCROOT)/gap5/g-alloc.h
+readpair.o: $(SRCROOT)/gap5/g-connect.h
+readpair.o: $(SRCROOT)/gap5/g-db.h
+readpair.o: $(SRCROOT)/gap5/g-defs.h
+readpair.o: $(SRCROOT)/gap5/g-error.h
+readpair.o: $(SRCROOT)/gap5/g-filedefs.h
+readpair.o: $(SRCROOT)/gap5/g-io.h
+readpair.o: $(SRCROOT)/gap5/g-misc.h
+readpair.o: $(SRCROOT)/gap5/g-os.h
+readpair.o: $(SRCROOT)/gap5/g-request.h
+readpair.o: $(SRCROOT)/gap5/g-struct.h
+readpair.o: $(SRCROOT)/gap5/g.h
+readpair.o: $(SRCROOT)/gap5/gap4_compat.h
+readpair.o: $(SRCROOT)/gap5/gap_globals.h
+readpair.o: $(SRCROOT)/gap5/hache_table.h
+readpair.o: $(SRCROOT)/gap5/io_utils.h
+readpair.o: $(SRCROOT)/gap5/list.h
+readpair.o: $(SRCROOT)/gap5/newgap_cmds.h
+readpair.o: $(SRCROOT)/gap5/readpair.h
+readpair.o: $(SRCROOT)/gap5/tg_anno.h
+readpair.o: $(SRCROOT)/gap5/tg_bin.h
+readpair.o: $(SRCROOT)/gap5/tg_cache_item.h
+readpair.o: $(SRCROOT)/gap5/tg_contig.h
+readpair.o: $(SRCROOT)/gap5/tg_gio.h
+readpair.o: $(SRCROOT)/gap5/tg_iface.h
+readpair.o: $(SRCROOT)/gap5/tg_library.h
+readpair.o: $(SRCROOT)/gap5/tg_register.h
+readpair.o: $(SRCROOT)/gap5/tg_scaffold.h
+readpair.o: $(SRCROOT)/gap5/tg_sequence.h
+readpair.o: $(SRCROOT)/gap5/tg_struct.h
+readpair.o: $(SRCROOT)/gap5/tg_tcl.h
+readpair.o: $(SRCROOT)/gap5/tg_track.h
+readpair.o: $(SRCROOT)/gap5/tg_utils.h
+readpair.o: $(SRCROOT)/gap5/tk-io-reg.h
+readpair.o: $(SRCROOT)/gap5/tkEdNames.h
+readpair.o: $(SRCROOT)/gap5/tkEditor.h
+readpair.o: $(SRCROOT)/tk_utils/canvas_box.h
+readpair.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+readpair.o: $(SRCROOT)/tk_utils/sheet.h
+readpair.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+readpair.o: $(SRCROOT)/tk_utils/tcl_utils.h
+readpair.o: $(SRCROOT)/tk_utils/text_output.h
+readpair.o: $(SRCROOT)/tk_utils/tkSheet.h
+readpair.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+readpair.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 restriction_enzymes.o: $(PWD)/staden_config.h
+restriction_enzymes.o: $(SRCROOT)/Misc/array.h
+restriction_enzymes.o: $(SRCROOT)/Misc/getfile.h
+restriction_enzymes.o: $(SRCROOT)/Misc/misc.h
+restriction_enzymes.o: $(SRCROOT)/Misc/os.h
+restriction_enzymes.o: $(SRCROOT)/Misc/tree.h
+restriction_enzymes.o: $(SRCROOT)/Misc/xalloc.h
+restriction_enzymes.o: $(SRCROOT)/Misc/xerror.h
+restriction_enzymes.o: $(SRCROOT)/gap5/b+tree2.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-alloc.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-connect.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-db.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-defs.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-error.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-filedefs.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-io.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-misc.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-os.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-request.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g-struct.h
+restriction_enzymes.o: $(SRCROOT)/gap5/g.h
+restriction_enzymes.o: $(SRCROOT)/gap5/gap4_compat.h
+restriction_enzymes.o: $(SRCROOT)/gap5/gap_canvas_box.h
+restriction_enzymes.o: $(SRCROOT)/gap5/gap_cli_arg.h
+restriction_enzymes.o: $(SRCROOT)/gap5/gap_globals.h
+restriction_enzymes.o: $(SRCROOT)/gap5/hache_table.h
+restriction_enzymes.o: $(SRCROOT)/gap5/io_utils.h
+restriction_enzymes.o: $(SRCROOT)/gap5/list.h
+restriction_enzymes.o: $(SRCROOT)/gap5/list_proc.h
+restriction_enzymes.o: $(SRCROOT)/gap5/newgap_cmds.h
+restriction_enzymes.o: $(SRCROOT)/gap5/qual.h
+restriction_enzymes.o: $(SRCROOT)/gap5/restriction_enzymes.h
+restriction_enzymes.o: $(SRCROOT)/gap5/template_display.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_anno.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_bin.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_cache_item.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_contig.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_gio.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_iface.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_library.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_register.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_scaffold.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_sequence.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_struct.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_tcl.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_track.h
+restriction_enzymes.o: $(SRCROOT)/gap5/tg_utils.h
+restriction_enzymes.o: $(SRCROOT)/seq_utils/dna_utils.h
+restriction_enzymes.o: $(SRCROOT)/seq_utils/renz_utils.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/canvas_box.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/restriction_enzyme_map.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/tcl_utils.h
+restriction_enzymes.o: $(SRCROOT)/tk_utils/text_output.h
 sam_index.o: $(PWD)/staden_config.h
+sam_index.o: $(SRCROOT)/Misc/array.h
+sam_index.o: $(SRCROOT)/Misc/misc.h
+sam_index.o: $(SRCROOT)/Misc/os.h
+sam_index.o: $(SRCROOT)/Misc/string_alloc.h
+sam_index.o: $(SRCROOT)/Misc/tree.h
+sam_index.o: $(SRCROOT)/Misc/xalloc.h
+sam_index.o: $(SRCROOT)/Misc/xerror.h
+sam_index.o: $(SRCROOT)/gap5/b+tree2.h
+sam_index.o: $(SRCROOT)/gap5/break_contig.h
+sam_index.o: $(SRCROOT)/gap5/consensus.h
+sam_index.o: $(SRCROOT)/gap5/depad_seq_tree.h
+sam_index.o: $(SRCROOT)/gap5/g-alloc.h
+sam_index.o: $(SRCROOT)/gap5/g-connect.h
+sam_index.o: $(SRCROOT)/gap5/g-db.h
+sam_index.o: $(SRCROOT)/gap5/g-defs.h
+sam_index.o: $(SRCROOT)/gap5/g-error.h
+sam_index.o: $(SRCROOT)/gap5/g-filedefs.h
+sam_index.o: $(SRCROOT)/gap5/g-io.h
+sam_index.o: $(SRCROOT)/gap5/g-misc.h
+sam_index.o: $(SRCROOT)/gap5/g-os.h
+sam_index.o: $(SRCROOT)/gap5/g-request.h
+sam_index.o: $(SRCROOT)/gap5/g-struct.h
+sam_index.o: $(SRCROOT)/gap5/g.h
+sam_index.o: $(SRCROOT)/gap5/hache_table.h
+sam_index.o: $(SRCROOT)/gap5/io_utils.h
+sam_index.o: $(SRCROOT)/gap5/sam_index.h
+sam_index.o: $(SRCROOT)/gap5/sam_pileup.h
+sam_index.o: $(SRCROOT)/gap5/tg_anno.h
+sam_index.o: $(SRCROOT)/gap5/tg_bin.h
+sam_index.o: $(SRCROOT)/gap5/tg_cache_item.h
+sam_index.o: $(SRCROOT)/gap5/tg_contig.h
+sam_index.o: $(SRCROOT)/gap5/tg_gio.h
+sam_index.o: $(SRCROOT)/gap5/tg_iface.h
+sam_index.o: $(SRCROOT)/gap5/tg_index.h
+sam_index.o: $(SRCROOT)/gap5/tg_index_common.h
+sam_index.o: $(SRCROOT)/gap5/tg_library.h
+sam_index.o: $(SRCROOT)/gap5/tg_register.h
+sam_index.o: $(SRCROOT)/gap5/tg_scaffold.h
+sam_index.o: $(SRCROOT)/gap5/tg_sequence.h
+sam_index.o: $(SRCROOT)/gap5/tg_struct.h
+sam_index.o: $(SRCROOT)/gap5/tg_tcl.h
+sam_index.o: $(SRCROOT)/gap5/tg_track.h
+sam_index.o: $(SRCROOT)/gap5/tg_utils.h
 sam_pileup.o: $(PWD)/staden_config.h
+sam_pileup.o: $(SRCROOT)/gap5/sam_pileup.h
 shuffle_pads.o: $(PWD)/staden_config.h
+shuffle_pads.o: $(SRCROOT)/Misc/array.h
+shuffle_pads.o: $(SRCROOT)/Misc/misc.h
+shuffle_pads.o: $(SRCROOT)/Misc/os.h
+shuffle_pads.o: $(SRCROOT)/Misc/tree.h
+shuffle_pads.o: $(SRCROOT)/Misc/xalloc.h
+shuffle_pads.o: $(SRCROOT)/Misc/xerror.h
+shuffle_pads.o: $(SRCROOT)/gap5/b+tree2.h
+shuffle_pads.o: $(SRCROOT)/gap5/break_contig.h
+shuffle_pads.o: $(SRCROOT)/gap5/consensus.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-alloc.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-connect.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-db.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-defs.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-error.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-filedefs.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-io.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-misc.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-os.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-request.h
+shuffle_pads.o: $(SRCROOT)/gap5/g-struct.h
+shuffle_pads.o: $(SRCROOT)/gap5/g.h
+shuffle_pads.o: $(SRCROOT)/gap5/hache_table.h
+shuffle_pads.o: $(SRCROOT)/gap5/io_utils.h
+shuffle_pads.o: $(SRCROOT)/gap5/shuffle_pads.h
+shuffle_pads.o: $(SRCROOT)/gap5/str_finder.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_anno.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_bin.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_cache_item.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_contig.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_gio.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_iface.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_library.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_register.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_scaffold.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_sequence.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_struct.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_tcl.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_track.h
+shuffle_pads.o: $(SRCROOT)/gap5/tg_utils.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/align.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/align_lib.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/align_lib_old.h
+shuffle_pads.o: $(SRCROOT)/seq_utils/dna_utils.h
+shuffle_pads.o: $(SRCROOT)/tk_utils/text_output.h
 stack_dump.o: $(PWD)/staden_config.h
+stack_dump.o: $(SRCROOT)/Misc/array.h
+stack_dump.o: $(SRCROOT)/Misc/bitmap.h
+stack_dump.o: $(SRCROOT)/Misc/misc.h
+stack_dump.o: $(SRCROOT)/Misc/os.h
+stack_dump.o: $(SRCROOT)/Misc/xalloc.h
+stack_dump.o: $(SRCROOT)/Misc/xerror.h
+stack_dump.o: $(SRCROOT)/gap5/g-error.h
+stack_dump.o: $(SRCROOT)/gap5/gap-error.h
+stack_dump.o: $(SRCROOT)/gap5/stack_dump.h
+str_finder.o: $(SRCROOT)/gap5/str_finder.h
+str_finder.o: $(SRCROOT)/gap5/utlist.h
 tag_plot.o: $(PWD)/staden_config.h
+tag_plot.o: $(SRCROOT)/Misc/array.h
+tag_plot.o: $(SRCROOT)/Misc/misc.h
+tag_plot.o: $(SRCROOT)/Misc/os.h
+tag_plot.o: $(SRCROOT)/Misc/tree.h
+tag_plot.o: $(SRCROOT)/Misc/xalloc.h
+tag_plot.o: $(SRCROOT)/Misc/xerror.h
+tag_plot.o: $(SRCROOT)/gap5/active_tags.h
+tag_plot.o: $(SRCROOT)/gap5/b+tree2.h
+tag_plot.o: $(SRCROOT)/gap5/g-alloc.h
+tag_plot.o: $(SRCROOT)/gap5/g-connect.h
+tag_plot.o: $(SRCROOT)/gap5/g-db.h
+tag_plot.o: $(SRCROOT)/gap5/g-defs.h
+tag_plot.o: $(SRCROOT)/gap5/g-error.h
+tag_plot.o: $(SRCROOT)/gap5/g-filedefs.h
+tag_plot.o: $(SRCROOT)/gap5/g-io.h
+tag_plot.o: $(SRCROOT)/gap5/g-misc.h
+tag_plot.o: $(SRCROOT)/gap5/g-os.h
+tag_plot.o: $(SRCROOT)/gap5/g-request.h
+tag_plot.o: $(SRCROOT)/gap5/g-struct.h
+tag_plot.o: $(SRCROOT)/gap5/g.h
+tag_plot.o: $(SRCROOT)/gap5/gap_range.h
+tag_plot.o: $(SRCROOT)/gap5/hache_table.h
+tag_plot.o: $(SRCROOT)/gap5/io_utils.h
+tag_plot.o: $(SRCROOT)/gap5/tag_plot.h
+tag_plot.o: $(SRCROOT)/gap5/tagdb.h
+tag_plot.o: $(SRCROOT)/gap5/template_draw.h
+tag_plot.o: $(SRCROOT)/gap5/tg_anno.h
+tag_plot.o: $(SRCROOT)/gap5/tg_bin.h
+tag_plot.o: $(SRCROOT)/gap5/tg_cache_item.h
+tag_plot.o: $(SRCROOT)/gap5/tg_contig.h
+tag_plot.o: $(SRCROOT)/gap5/tg_gio.h
+tag_plot.o: $(SRCROOT)/gap5/tg_iface.h
+tag_plot.o: $(SRCROOT)/gap5/tg_library.h
+tag_plot.o: $(SRCROOT)/gap5/tg_register.h
+tag_plot.o: $(SRCROOT)/gap5/tg_scaffold.h
+tag_plot.o: $(SRCROOT)/gap5/tg_sequence.h
+tag_plot.o: $(SRCROOT)/gap5/tg_struct.h
+tag_plot.o: $(SRCROOT)/gap5/tg_tcl.h
+tag_plot.o: $(SRCROOT)/gap5/tg_track.h
+tag_plot.o: $(SRCROOT)/gap5/tg_utils.h
+tag_plot.o: $(SRCROOT)/tk_utils/intrinsic_type.h
 tagdb.o: $(PWD)/staden_config.h
+tagdb.o: $(SRCROOT)/Misc/misc.h
+tagdb.o: $(SRCROOT)/Misc/os.h
+tagdb.o: $(SRCROOT)/Misc/parse_db.h
+tagdb.o: $(SRCROOT)/Misc/xalloc.h
+tagdb.o: $(SRCROOT)/gap5/tagdb.h
+tagdb.o: $(SRCROOT)/tk_utils/intrinsic_type.h
 template_display.o: $(PWD)/staden_config.h
+template_display.o: $(SRCROOT)/Misc/array.h
+template_display.o: $(SRCROOT)/Misc/misc.h
+template_display.o: $(SRCROOT)/Misc/os.h
+template_display.o: $(SRCROOT)/Misc/tree.h
+template_display.o: $(SRCROOT)/Misc/xalloc.h
+template_display.o: $(SRCROOT)/Misc/xerror.h
+template_display.o: $(SRCROOT)/gap5/b+tree2.h
+template_display.o: $(SRCROOT)/gap5/g-alloc.h
+template_display.o: $(SRCROOT)/gap5/g-connect.h
+template_display.o: $(SRCROOT)/gap5/g-db.h
+template_display.o: $(SRCROOT)/gap5/g-defs.h
+template_display.o: $(SRCROOT)/gap5/g-error.h
+template_display.o: $(SRCROOT)/gap5/g-filedefs.h
+template_display.o: $(SRCROOT)/gap5/g-io.h
+template_display.o: $(SRCROOT)/gap5/g-misc.h
+template_display.o: $(SRCROOT)/gap5/g-os.h
+template_display.o: $(SRCROOT)/gap5/g-request.h
+template_display.o: $(SRCROOT)/gap5/g-struct.h
+template_display.o: $(SRCROOT)/gap5/g.h
+template_display.o: $(SRCROOT)/gap5/gap_globals.h
+template_display.o: $(SRCROOT)/gap5/gap_range.h
+template_display.o: $(SRCROOT)/gap5/hache_table.h
+template_display.o: $(SRCROOT)/gap5/io_utils.h
+template_display.o: $(SRCROOT)/gap5/template_display.h
+template_display.o: $(SRCROOT)/gap5/template_draw.h
+template_display.o: $(SRCROOT)/gap5/tg_anno.h
+template_display.o: $(SRCROOT)/gap5/tg_bin.h
+template_display.o: $(SRCROOT)/gap5/tg_cache_item.h
+template_display.o: $(SRCROOT)/gap5/tg_contig.h
+template_display.o: $(SRCROOT)/gap5/tg_gio.h
+template_display.o: $(SRCROOT)/gap5/tg_iface.h
+template_display.o: $(SRCROOT)/gap5/tg_library.h
+template_display.o: $(SRCROOT)/gap5/tg_register.h
+template_display.o: $(SRCROOT)/gap5/tg_scaffold.h
+template_display.o: $(SRCROOT)/gap5/tg_sequence.h
+template_display.o: $(SRCROOT)/gap5/tg_struct.h
+template_display.o: $(SRCROOT)/gap5/tg_tcl.h
+template_display.o: $(SRCROOT)/gap5/tg_track.h
+template_display.o: $(SRCROOT)/gap5/tg_utils.h
+template_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
+template_draw.o: $(SRCROOT)/gap5/template_draw.h
 tg_anno.o: $(PWD)/staden_config.h
+tg_anno.o: $(SRCROOT)/Misc/array.h
+tg_anno.o: $(SRCROOT)/Misc/misc.h
+tg_anno.o: $(SRCROOT)/Misc/os.h
+tg_anno.o: $(SRCROOT)/Misc/tree.h
+tg_anno.o: $(SRCROOT)/Misc/xalloc.h
+tg_anno.o: $(SRCROOT)/Misc/xerror.h
+tg_anno.o: $(SRCROOT)/gap5/active_tags.h
+tg_anno.o: $(SRCROOT)/gap5/b+tree2.h
+tg_anno.o: $(SRCROOT)/gap5/g-alloc.h
+tg_anno.o: $(SRCROOT)/gap5/g-connect.h
+tg_anno.o: $(SRCROOT)/gap5/g-db.h
+tg_anno.o: $(SRCROOT)/gap5/g-defs.h
+tg_anno.o: $(SRCROOT)/gap5/g-error.h
+tg_anno.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_anno.o: $(SRCROOT)/gap5/g-io.h
+tg_anno.o: $(SRCROOT)/gap5/g-misc.h
+tg_anno.o: $(SRCROOT)/gap5/g-os.h
+tg_anno.o: $(SRCROOT)/gap5/g-request.h
+tg_anno.o: $(SRCROOT)/gap5/g-struct.h
+tg_anno.o: $(SRCROOT)/gap5/g.h
+tg_anno.o: $(SRCROOT)/gap5/gap4_compat.h
+tg_anno.o: $(SRCROOT)/gap5/hache_table.h
+tg_anno.o: $(SRCROOT)/gap5/io_utils.h
+tg_anno.o: $(SRCROOT)/gap5/tagdb.h
+tg_anno.o: $(SRCROOT)/gap5/tg_anno.h
+tg_anno.o: $(SRCROOT)/gap5/tg_bin.h
+tg_anno.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_anno.o: $(SRCROOT)/gap5/tg_contig.h
+tg_anno.o: $(SRCROOT)/gap5/tg_gio.h
+tg_anno.o: $(SRCROOT)/gap5/tg_iface.h
+tg_anno.o: $(SRCROOT)/gap5/tg_library.h
+tg_anno.o: $(SRCROOT)/gap5/tg_register.h
+tg_anno.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_anno.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_anno.o: $(SRCROOT)/gap5/tg_struct.h
+tg_anno.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_anno.o: $(SRCROOT)/gap5/tg_track.h
+tg_anno.o: $(SRCROOT)/gap5/tg_utils.h
+tg_anno.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tg_anno.o: $(SRCROOT)/tk_utils/text_output.h
 tg_bin.o: $(PWD)/staden_config.h
+tg_bin.o: $(SRCROOT)/Misc/array.h
+tg_bin.o: $(SRCROOT)/Misc/misc.h
+tg_bin.o: $(SRCROOT)/Misc/os.h
+tg_bin.o: $(SRCROOT)/Misc/tree.h
+tg_bin.o: $(SRCROOT)/Misc/xalloc.h
+tg_bin.o: $(SRCROOT)/Misc/xerror.h
+tg_bin.o: $(SRCROOT)/gap5/b+tree2.h
+tg_bin.o: $(SRCROOT)/gap5/consensus.h
+tg_bin.o: $(SRCROOT)/gap5/g-alloc.h
+tg_bin.o: $(SRCROOT)/gap5/g-connect.h
+tg_bin.o: $(SRCROOT)/gap5/g-db.h
+tg_bin.o: $(SRCROOT)/gap5/g-defs.h
+tg_bin.o: $(SRCROOT)/gap5/g-error.h
+tg_bin.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_bin.o: $(SRCROOT)/gap5/g-io.h
+tg_bin.o: $(SRCROOT)/gap5/g-misc.h
+tg_bin.o: $(SRCROOT)/gap5/g-os.h
+tg_bin.o: $(SRCROOT)/gap5/g-request.h
+tg_bin.o: $(SRCROOT)/gap5/g-struct.h
+tg_bin.o: $(SRCROOT)/gap5/g.h
+tg_bin.o: $(SRCROOT)/gap5/hache_table.h
+tg_bin.o: $(SRCROOT)/gap5/io_utils.h
+tg_bin.o: $(SRCROOT)/gap5/tg_anno.h
+tg_bin.o: $(SRCROOT)/gap5/tg_bin.h
+tg_bin.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_bin.o: $(SRCROOT)/gap5/tg_contig.h
+tg_bin.o: $(SRCROOT)/gap5/tg_gio.h
+tg_bin.o: $(SRCROOT)/gap5/tg_iface.h
+tg_bin.o: $(SRCROOT)/gap5/tg_library.h
+tg_bin.o: $(SRCROOT)/gap5/tg_register.h
+tg_bin.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_bin.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_bin.o: $(SRCROOT)/gap5/tg_struct.h
+tg_bin.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_bin.o: $(SRCROOT)/gap5/tg_track.h
+tg_bin.o: $(SRCROOT)/gap5/tg_tracks.h
+tg_bin.o: $(SRCROOT)/gap5/tg_utils.h
 tg_cache.o: $(PWD)/staden_config.h
+tg_cache.o: $(SRCROOT)/Misc/array.h
+tg_cache.o: $(SRCROOT)/Misc/misc.h
+tg_cache.o: $(SRCROOT)/Misc/os.h
+tg_cache.o: $(SRCROOT)/Misc/tree.h
+tg_cache.o: $(SRCROOT)/Misc/xalloc.h
+tg_cache.o: $(SRCROOT)/Misc/xerror.h
+tg_cache.o: $(SRCROOT)/gap5/b+tree2.h
+tg_cache.o: $(SRCROOT)/gap5/g-alloc.h
+tg_cache.o: $(SRCROOT)/gap5/g-connect.h
+tg_cache.o: $(SRCROOT)/gap5/g-db.h
+tg_cache.o: $(SRCROOT)/gap5/g-defs.h
+tg_cache.o: $(SRCROOT)/gap5/g-error.h
+tg_cache.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_cache.o: $(SRCROOT)/gap5/g-io.h
+tg_cache.o: $(SRCROOT)/gap5/g-misc.h
+tg_cache.o: $(SRCROOT)/gap5/g-os.h
+tg_cache.o: $(SRCROOT)/gap5/g-request.h
+tg_cache.o: $(SRCROOT)/gap5/g-struct.h
+tg_cache.o: $(SRCROOT)/gap5/g.h
+tg_cache.o: $(SRCROOT)/gap5/hache_table.h
+tg_cache.o: $(SRCROOT)/gap5/io_utils.h
+tg_cache.o: $(SRCROOT)/gap5/tg_anno.h
+tg_cache.o: $(SRCROOT)/gap5/tg_bin.h
+tg_cache.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_cache.o: $(SRCROOT)/gap5/tg_contig.h
+tg_cache.o: $(SRCROOT)/gap5/tg_gio.h
+tg_cache.o: $(SRCROOT)/gap5/tg_iface.h
+tg_cache.o: $(SRCROOT)/gap5/tg_library.h
+tg_cache.o: $(SRCROOT)/gap5/tg_register.h
+tg_cache.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_cache.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_cache.o: $(SRCROOT)/gap5/tg_struct.h
+tg_cache.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_cache.o: $(SRCROOT)/gap5/tg_track.h
+tg_cache.o: $(SRCROOT)/gap5/tg_utils.h
 tg_check.o: $(PWD)/staden_config.h
+tg_check.o: $(SRCROOT)/Misc/array.h
+tg_check.o: $(SRCROOT)/Misc/misc.h
+tg_check.o: $(SRCROOT)/Misc/os.h
+tg_check.o: $(SRCROOT)/Misc/tree.h
+tg_check.o: $(SRCROOT)/Misc/xalloc.h
+tg_check.o: $(SRCROOT)/Misc/xerror.h
+tg_check.o: $(SRCROOT)/gap5/b+tree2.h
+tg_check.o: $(SRCROOT)/gap5/consensus.h
+tg_check.o: $(SRCROOT)/gap5/g-alloc.h
+tg_check.o: $(SRCROOT)/gap5/g-connect.h
+tg_check.o: $(SRCROOT)/gap5/g-db.h
+tg_check.o: $(SRCROOT)/gap5/g-defs.h
+tg_check.o: $(SRCROOT)/gap5/g-error.h
+tg_check.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_check.o: $(SRCROOT)/gap5/g-io.h
+tg_check.o: $(SRCROOT)/gap5/g-misc.h
+tg_check.o: $(SRCROOT)/gap5/g-os.h
+tg_check.o: $(SRCROOT)/gap5/g-request.h
+tg_check.o: $(SRCROOT)/gap5/g-struct.h
+tg_check.o: $(SRCROOT)/gap5/g.h
+tg_check.o: $(SRCROOT)/gap5/hache_table.h
+tg_check.o: $(SRCROOT)/gap5/io_utils.h
+tg_check.o: $(SRCROOT)/gap5/tg_anno.h
+tg_check.o: $(SRCROOT)/gap5/tg_bin.h
+tg_check.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_check.o: $(SRCROOT)/gap5/tg_check.h
+tg_check.o: $(SRCROOT)/gap5/tg_contig.h
+tg_check.o: $(SRCROOT)/gap5/tg_gio.h
+tg_check.o: $(SRCROOT)/gap5/tg_iface.h
+tg_check.o: $(SRCROOT)/gap5/tg_library.h
+tg_check.o: $(SRCROOT)/gap5/tg_register.h
+tg_check.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_check.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_check.o: $(SRCROOT)/gap5/tg_struct.h
+tg_check.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_check.o: $(SRCROOT)/gap5/tg_track.h
+tg_check.o: $(SRCROOT)/gap5/tg_utils.h
+tg_check.o: $(SRCROOT)/tk_utils/text_output.h
 tg_contig.o: $(PWD)/staden_config.h
+tg_contig.o: $(SRCROOT)/Misc/array.h
+tg_contig.o: $(SRCROOT)/Misc/misc.h
+tg_contig.o: $(SRCROOT)/Misc/os.h
+tg_contig.o: $(SRCROOT)/Misc/tree.h
+tg_contig.o: $(SRCROOT)/Misc/xalloc.h
+tg_contig.o: $(SRCROOT)/Misc/xerror.h
+tg_contig.o: $(SRCROOT)/gap5/b+tree2.h
+tg_contig.o: $(SRCROOT)/gap5/break_contig.h
+tg_contig.o: $(SRCROOT)/gap5/consensus.h
+tg_contig.o: $(SRCROOT)/gap5/find_haplotypes.h
+tg_contig.o: $(SRCROOT)/gap5/g-alloc.h
+tg_contig.o: $(SRCROOT)/gap5/g-connect.h
+tg_contig.o: $(SRCROOT)/gap5/g-db.h
+tg_contig.o: $(SRCROOT)/gap5/g-defs.h
+tg_contig.o: $(SRCROOT)/gap5/g-error.h
+tg_contig.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_contig.o: $(SRCROOT)/gap5/g-io.h
+tg_contig.o: $(SRCROOT)/gap5/g-misc.h
+tg_contig.o: $(SRCROOT)/gap5/g-os.h
+tg_contig.o: $(SRCROOT)/gap5/g-request.h
+tg_contig.o: $(SRCROOT)/gap5/g-struct.h
+tg_contig.o: $(SRCROOT)/gap5/g.h
+tg_contig.o: $(SRCROOT)/gap5/hache_table.h
+tg_contig.o: $(SRCROOT)/gap5/io_utils.h
+tg_contig.o: $(SRCROOT)/gap5/list_proc.h
+tg_contig.o: $(SRCROOT)/gap5/tg_anno.h
+tg_contig.o: $(SRCROOT)/gap5/tg_bin.h
+tg_contig.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_contig.o: $(SRCROOT)/gap5/tg_check.h
+tg_contig.o: $(SRCROOT)/gap5/tg_contig.h
+tg_contig.o: $(SRCROOT)/gap5/tg_gio.h
+tg_contig.o: $(SRCROOT)/gap5/tg_iface.h
+tg_contig.o: $(SRCROOT)/gap5/tg_library.h
+tg_contig.o: $(SRCROOT)/gap5/tg_register.h
+tg_contig.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_contig.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_contig.o: $(SRCROOT)/gap5/tg_struct.h
+tg_contig.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_contig.o: $(SRCROOT)/gap5/tg_track.h
+tg_contig.o: $(SRCROOT)/gap5/tg_utils.h
+tg_contig.o: $(SRCROOT)/seq_utils/dna_utils.h
 tg_gio.o: $(PWD)/staden_config.h
+tg_gio.o: $(SRCROOT)/Misc/array.h
+tg_gio.o: $(SRCROOT)/Misc/misc.h
+tg_gio.o: $(SRCROOT)/Misc/os.h
+tg_gio.o: $(SRCROOT)/Misc/tree.h
+tg_gio.o: $(SRCROOT)/Misc/xalloc.h
+tg_gio.o: $(SRCROOT)/Misc/xerror.h
+tg_gio.o: $(SRCROOT)/gap5/actf.h
+tg_gio.o: $(SRCROOT)/gap5/b+tree2.h
+tg_gio.o: $(SRCROOT)/gap5/g-alloc.h
+tg_gio.o: $(SRCROOT)/gap5/g-connect.h
+tg_gio.o: $(SRCROOT)/gap5/g-db.h
+tg_gio.o: $(SRCROOT)/gap5/g-defs.h
+tg_gio.o: $(SRCROOT)/gap5/g-error.h
+tg_gio.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_gio.o: $(SRCROOT)/gap5/g-io.h
+tg_gio.o: $(SRCROOT)/gap5/g-misc.h
+tg_gio.o: $(SRCROOT)/gap5/g-os.h
+tg_gio.o: $(SRCROOT)/gap5/g-request.h
+tg_gio.o: $(SRCROOT)/gap5/g-struct.h
+tg_gio.o: $(SRCROOT)/gap5/g.h
+tg_gio.o: $(SRCROOT)/gap5/hache_table.h
+tg_gio.o: $(SRCROOT)/gap5/io_utils.h
+tg_gio.o: $(SRCROOT)/gap5/tg_anno.h
+tg_gio.o: $(SRCROOT)/gap5/tg_bin.h
+tg_gio.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_gio.o: $(SRCROOT)/gap5/tg_contig.h
+tg_gio.o: $(SRCROOT)/gap5/tg_gio.h
+tg_gio.o: $(SRCROOT)/gap5/tg_iface.h
+tg_gio.o: $(SRCROOT)/gap5/tg_iface_g.h
+tg_gio.o: $(SRCROOT)/gap5/tg_library.h
+tg_gio.o: $(SRCROOT)/gap5/tg_register.h
+tg_gio.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_gio.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_gio.o: $(SRCROOT)/gap5/tg_struct.h
+tg_gio.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_gio.o: $(SRCROOT)/gap5/tg_track.h
+tg_gio.o: $(SRCROOT)/gap5/tg_utils.h
 tg_iface_g.o: $(PWD)/staden_config.h
+tg_iface_g.o: $(SRCROOT)/Misc/array.h
+tg_iface_g.o: $(SRCROOT)/Misc/misc.h
+tg_iface_g.o: $(SRCROOT)/Misc/os.h
+tg_iface_g.o: $(SRCROOT)/Misc/tree.h
+tg_iface_g.o: $(SRCROOT)/Misc/xalloc.h
+tg_iface_g.o: $(SRCROOT)/Misc/xerror.h
+tg_iface_g.o: $(SRCROOT)/gap5/b+tree2.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-alloc.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-connect.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-db.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-defs.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-error.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-io.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-misc.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-os.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-request.h
+tg_iface_g.o: $(SRCROOT)/gap5/g-struct.h
+tg_iface_g.o: $(SRCROOT)/gap5/g.h
+tg_iface_g.o: $(SRCROOT)/gap5/hache_table.h
+tg_iface_g.o: $(SRCROOT)/gap5/io_utils.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_anno.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_bin.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_contig.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_gio.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_iface.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_iface_g.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_library.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_register.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_struct.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_track.h
+tg_iface_g.o: $(SRCROOT)/gap5/tg_utils.h
+tg_iface_g.o: $(SRCROOT)/seq_utils/dna_utils.h
 tg_index.o: $(PWD)/staden_config.h
+tg_index.o: $(SRCROOT)/Misc/array.h
+tg_index.o: $(SRCROOT)/Misc/misc.h
+tg_index.o: $(SRCROOT)/Misc/os.h
+tg_index.o: $(SRCROOT)/Misc/string_alloc.h
+tg_index.o: $(SRCROOT)/Misc/tree.h
+tg_index.o: $(SRCROOT)/Misc/xalloc.h
+tg_index.o: $(SRCROOT)/Misc/xerror.h
+tg_index.o: $(SRCROOT)/gap5/ace.h
+tg_index.o: $(SRCROOT)/gap5/afg.h
+tg_index.o: $(SRCROOT)/gap5/b+tree2.h
+tg_index.o: $(SRCROOT)/gap5/baf.h
+tg_index.o: $(SRCROOT)/gap5/caf.h
+tg_index.o: $(SRCROOT)/gap5/fasta.h
+tg_index.o: $(SRCROOT)/gap5/g-alloc.h
+tg_index.o: $(SRCROOT)/gap5/g-connect.h
+tg_index.o: $(SRCROOT)/gap5/g-db.h
+tg_index.o: $(SRCROOT)/gap5/g-defs.h
+tg_index.o: $(SRCROOT)/gap5/g-error.h
+tg_index.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_index.o: $(SRCROOT)/gap5/g-io.h
+tg_index.o: $(SRCROOT)/gap5/g-misc.h
+tg_index.o: $(SRCROOT)/gap5/g-os.h
+tg_index.o: $(SRCROOT)/gap5/g-request.h
+tg_index.o: $(SRCROOT)/gap5/g-struct.h
+tg_index.o: $(SRCROOT)/gap5/g.h
+tg_index.o: $(SRCROOT)/gap5/hache_table.h
+tg_index.o: $(SRCROOT)/gap5/io_utils.h
+tg_index.o: $(SRCROOT)/gap5/maq.h
+tg_index.o: $(SRCROOT)/gap5/maqmap.h
+tg_index.o: $(SRCROOT)/gap5/sam_index.h
+tg_index.o: $(SRCROOT)/gap5/tg_anno.h
+tg_index.o: $(SRCROOT)/gap5/tg_bin.h
+tg_index.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_index.o: $(SRCROOT)/gap5/tg_contig.h
+tg_index.o: $(SRCROOT)/gap5/tg_gio.h
+tg_index.o: $(SRCROOT)/gap5/tg_iface.h
+tg_index.o: $(SRCROOT)/gap5/tg_index.h
+tg_index.o: $(SRCROOT)/gap5/tg_index_common.h
+tg_index.o: $(SRCROOT)/gap5/tg_library.h
+tg_index.o: $(SRCROOT)/gap5/tg_register.h
+tg_index.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_index.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_index.o: $(SRCROOT)/gap5/tg_struct.h
+tg_index.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_index.o: $(SRCROOT)/gap5/tg_track.h
+tg_index.o: $(SRCROOT)/gap5/tg_utils.h
 tg_index_common.o: $(PWD)/staden_config.h
+tg_index_common.o: $(SRCROOT)/Misc/array.h
+tg_index_common.o: $(SRCROOT)/Misc/misc.h
+tg_index_common.o: $(SRCROOT)/Misc/os.h
+tg_index_common.o: $(SRCROOT)/Misc/string_alloc.h
+tg_index_common.o: $(SRCROOT)/Misc/tree.h
+tg_index_common.o: $(SRCROOT)/Misc/xalloc.h
+tg_index_common.o: $(SRCROOT)/Misc/xerror.h
+tg_index_common.o: $(SRCROOT)/gap5/b+tree2.h
+tg_index_common.o: $(SRCROOT)/gap5/break_contig.h
+tg_index_common.o: $(SRCROOT)/gap5/g-alloc.h
+tg_index_common.o: $(SRCROOT)/gap5/g-connect.h
+tg_index_common.o: $(SRCROOT)/gap5/g-db.h
+tg_index_common.o: $(SRCROOT)/gap5/g-defs.h
+tg_index_common.o: $(SRCROOT)/gap5/g-error.h
+tg_index_common.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_index_common.o: $(SRCROOT)/gap5/g-io.h
+tg_index_common.o: $(SRCROOT)/gap5/g-misc.h
+tg_index_common.o: $(SRCROOT)/gap5/g-os.h
+tg_index_common.o: $(SRCROOT)/gap5/g-request.h
+tg_index_common.o: $(SRCROOT)/gap5/g-struct.h
+tg_index_common.o: $(SRCROOT)/gap5/g.h
+tg_index_common.o: $(SRCROOT)/gap5/hache_table.h
+tg_index_common.o: $(SRCROOT)/gap5/io_utils.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_anno.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_bin.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_contig.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_gio.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_iface.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_index.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_index_common.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_library.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_register.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_struct.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_track.h
+tg_index_common.o: $(SRCROOT)/gap5/tg_utils.h
 tg_library.o: $(PWD)/staden_config.h
+tg_library.o: $(SRCROOT)/Misc/array.h
+tg_library.o: $(SRCROOT)/Misc/misc.h
+tg_library.o: $(SRCROOT)/Misc/os.h
+tg_library.o: $(SRCROOT)/Misc/tree.h
+tg_library.o: $(SRCROOT)/Misc/xalloc.h
+tg_library.o: $(SRCROOT)/Misc/xerror.h
+tg_library.o: $(SRCROOT)/gap5/b+tree2.h
+tg_library.o: $(SRCROOT)/gap5/g-alloc.h
+tg_library.o: $(SRCROOT)/gap5/g-connect.h
+tg_library.o: $(SRCROOT)/gap5/g-db.h
+tg_library.o: $(SRCROOT)/gap5/g-defs.h
+tg_library.o: $(SRCROOT)/gap5/g-error.h
+tg_library.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_library.o: $(SRCROOT)/gap5/g-io.h
+tg_library.o: $(SRCROOT)/gap5/g-misc.h
+tg_library.o: $(SRCROOT)/gap5/g-os.h
+tg_library.o: $(SRCROOT)/gap5/g-request.h
+tg_library.o: $(SRCROOT)/gap5/g-struct.h
+tg_library.o: $(SRCROOT)/gap5/g.h
+tg_library.o: $(SRCROOT)/gap5/hache_table.h
+tg_library.o: $(SRCROOT)/gap5/io_utils.h
+tg_library.o: $(SRCROOT)/gap5/tg_anno.h
+tg_library.o: $(SRCROOT)/gap5/tg_bin.h
+tg_library.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_library.o: $(SRCROOT)/gap5/tg_contig.h
+tg_library.o: $(SRCROOT)/gap5/tg_gio.h
+tg_library.o: $(SRCROOT)/gap5/tg_iface.h
+tg_library.o: $(SRCROOT)/gap5/tg_library.h
+tg_library.o: $(SRCROOT)/gap5/tg_register.h
+tg_library.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_library.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_library.o: $(SRCROOT)/gap5/tg_struct.h
+tg_library.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_library.o: $(SRCROOT)/gap5/tg_track.h
+tg_library.o: $(SRCROOT)/gap5/tg_utils.h
 tg_register.o: $(PWD)/staden_config.h
+tg_register.o: $(SRCROOT)/Misc/array.h
+tg_register.o: $(SRCROOT)/Misc/misc.h
+tg_register.o: $(SRCROOT)/Misc/os.h
+tg_register.o: $(SRCROOT)/Misc/tree.h
+tg_register.o: $(SRCROOT)/Misc/xalloc.h
+tg_register.o: $(SRCROOT)/Misc/xerror.h
+tg_register.o: $(SRCROOT)/gap5/b+tree2.h
+tg_register.o: $(SRCROOT)/gap5/g-alloc.h
+tg_register.o: $(SRCROOT)/gap5/g-connect.h
+tg_register.o: $(SRCROOT)/gap5/g-db.h
+tg_register.o: $(SRCROOT)/gap5/g-defs.h
+tg_register.o: $(SRCROOT)/gap5/g-error.h
+tg_register.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_register.o: $(SRCROOT)/gap5/g-io.h
+tg_register.o: $(SRCROOT)/gap5/g-misc.h
+tg_register.o: $(SRCROOT)/gap5/g-os.h
+tg_register.o: $(SRCROOT)/gap5/g-request.h
+tg_register.o: $(SRCROOT)/gap5/g-struct.h
+tg_register.o: $(SRCROOT)/gap5/g.h
+tg_register.o: $(SRCROOT)/gap5/hache_table.h
+tg_register.o: $(SRCROOT)/gap5/io_utils.h
+tg_register.o: $(SRCROOT)/gap5/tg_anno.h
+tg_register.o: $(SRCROOT)/gap5/tg_bin.h
+tg_register.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_register.o: $(SRCROOT)/gap5/tg_contig.h
+tg_register.o: $(SRCROOT)/gap5/tg_gio.h
+tg_register.o: $(SRCROOT)/gap5/tg_iface.h
+tg_register.o: $(SRCROOT)/gap5/tg_library.h
+tg_register.o: $(SRCROOT)/gap5/tg_register.h
+tg_register.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_register.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_register.o: $(SRCROOT)/gap5/tg_struct.h
+tg_register.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_register.o: $(SRCROOT)/gap5/tg_track.h
+tg_register.o: $(SRCROOT)/gap5/tg_utils.h
+tg_register.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tg_register.o: $(SRCROOT)/tk_utils/text_output.h
 tg_scaffold.o: $(PWD)/staden_config.h
+tg_scaffold.o: $(SRCROOT)/Misc/array.h
+tg_scaffold.o: $(SRCROOT)/Misc/misc.h
+tg_scaffold.o: $(SRCROOT)/Misc/os.h
+tg_scaffold.o: $(SRCROOT)/Misc/tree.h
+tg_scaffold.o: $(SRCROOT)/Misc/xalloc.h
+tg_scaffold.o: $(SRCROOT)/Misc/xerror.h
+tg_scaffold.o: $(SRCROOT)/gap5/b+tree2.h
+tg_scaffold.o: $(SRCROOT)/gap5/consensus.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-alloc.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-connect.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-db.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-defs.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-error.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-io.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-misc.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-os.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-request.h
+tg_scaffold.o: $(SRCROOT)/gap5/g-struct.h
+tg_scaffold.o: $(SRCROOT)/gap5/g.h
+tg_scaffold.o: $(SRCROOT)/gap5/gap4_compat.h
+tg_scaffold.o: $(SRCROOT)/gap5/hache_table.h
+tg_scaffold.o: $(SRCROOT)/gap5/io_utils.h
+tg_scaffold.o: $(SRCROOT)/gap5/list_proc.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_anno.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_bin.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_contig.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_gio.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_iface.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_library.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_register.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_struct.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_track.h
+tg_scaffold.o: $(SRCROOT)/gap5/tg_utils.h
 tg_sequence.o: $(PWD)/staden_config.h
+tg_sequence.o: $(SRCROOT)/Misc/array.h
+tg_sequence.o: $(SRCROOT)/Misc/misc.h
+tg_sequence.o: $(SRCROOT)/Misc/os.h
+tg_sequence.o: $(SRCROOT)/Misc/tree.h
+tg_sequence.o: $(SRCROOT)/Misc/xalloc.h
+tg_sequence.o: $(SRCROOT)/Misc/xerror.h
+tg_sequence.o: $(SRCROOT)/gap5/b+tree2.h
+tg_sequence.o: $(SRCROOT)/gap5/consensus.h
+tg_sequence.o: $(SRCROOT)/gap5/g-alloc.h
+tg_sequence.o: $(SRCROOT)/gap5/g-connect.h
+tg_sequence.o: $(SRCROOT)/gap5/g-db.h
+tg_sequence.o: $(SRCROOT)/gap5/g-defs.h
+tg_sequence.o: $(SRCROOT)/gap5/g-error.h
+tg_sequence.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_sequence.o: $(SRCROOT)/gap5/g-io.h
+tg_sequence.o: $(SRCROOT)/gap5/g-misc.h
+tg_sequence.o: $(SRCROOT)/gap5/g-os.h
+tg_sequence.o: $(SRCROOT)/gap5/g-request.h
+tg_sequence.o: $(SRCROOT)/gap5/g-struct.h
+tg_sequence.o: $(SRCROOT)/gap5/g.h
+tg_sequence.o: $(SRCROOT)/gap5/hache_table.h
+tg_sequence.o: $(SRCROOT)/gap5/io_utils.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_anno.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_bin.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_contig.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_gio.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_iface.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_library.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_register.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_struct.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_track.h
+tg_sequence.o: $(SRCROOT)/gap5/tg_utils.h
+tg_sequence.o: $(SRCROOT)/seq_utils/dna_utils.h
 tg_tcl.o: $(PWD)/staden_config.h
+tg_tcl.o: $(SRCROOT)/Misc/array.h
+tg_tcl.o: $(SRCROOT)/Misc/misc.h
+tg_tcl.o: $(SRCROOT)/Misc/os.h
+tg_tcl.o: $(SRCROOT)/Misc/tree.h
+tg_tcl.o: $(SRCROOT)/Misc/xalloc.h
+tg_tcl.o: $(SRCROOT)/Misc/xerror.h
+tg_tcl.o: $(SRCROOT)/gap5/b+tree2.h
+tg_tcl.o: $(SRCROOT)/gap5/consensus.h
+tg_tcl.o: $(SRCROOT)/gap5/g-alloc.h
+tg_tcl.o: $(SRCROOT)/gap5/g-connect.h
+tg_tcl.o: $(SRCROOT)/gap5/g-db.h
+tg_tcl.o: $(SRCROOT)/gap5/g-defs.h
+tg_tcl.o: $(SRCROOT)/gap5/g-error.h
+tg_tcl.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_tcl.o: $(SRCROOT)/gap5/g-io.h
+tg_tcl.o: $(SRCROOT)/gap5/g-misc.h
+tg_tcl.o: $(SRCROOT)/gap5/g-os.h
+tg_tcl.o: $(SRCROOT)/gap5/g-request.h
+tg_tcl.o: $(SRCROOT)/gap5/g-struct.h
+tg_tcl.o: $(SRCROOT)/gap5/g.h
+tg_tcl.o: $(SRCROOT)/gap5/gap4_compat.h
+tg_tcl.o: $(SRCROOT)/gap5/gap_cli_arg.h
+tg_tcl.o: $(SRCROOT)/gap5/hache_table.h
+tg_tcl.o: $(SRCROOT)/gap5/io_utils.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_anno.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_bin.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_check.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_contig.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_gio.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_iface.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_library.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_register.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_struct.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_track.h
+tg_tcl.o: $(SRCROOT)/gap5/tg_utils.h
+tg_tcl.o: $(SRCROOT)/tk_utils/tcl_utils.h
 tg_track.o: $(PWD)/staden_config.h
+tg_track.o: $(SRCROOT)/Misc/array.h
+tg_track.o: $(SRCROOT)/Misc/misc.h
+tg_track.o: $(SRCROOT)/Misc/os.h
+tg_track.o: $(SRCROOT)/Misc/tree.h
+tg_track.o: $(SRCROOT)/Misc/xalloc.h
+tg_track.o: $(SRCROOT)/Misc/xerror.h
+tg_track.o: $(SRCROOT)/gap5/b+tree2.h
+tg_track.o: $(SRCROOT)/gap5/g-alloc.h
+tg_track.o: $(SRCROOT)/gap5/g-connect.h
+tg_track.o: $(SRCROOT)/gap5/g-db.h
+tg_track.o: $(SRCROOT)/gap5/g-defs.h
+tg_track.o: $(SRCROOT)/gap5/g-error.h
+tg_track.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_track.o: $(SRCROOT)/gap5/g-io.h
+tg_track.o: $(SRCROOT)/gap5/g-misc.h
+tg_track.o: $(SRCROOT)/gap5/g-os.h
+tg_track.o: $(SRCROOT)/gap5/g-request.h
+tg_track.o: $(SRCROOT)/gap5/g-struct.h
+tg_track.o: $(SRCROOT)/gap5/g.h
+tg_track.o: $(SRCROOT)/gap5/hache_table.h
+tg_track.o: $(SRCROOT)/gap5/io_utils.h
+tg_track.o: $(SRCROOT)/gap5/tg_anno.h
+tg_track.o: $(SRCROOT)/gap5/tg_bin.h
+tg_track.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_track.o: $(SRCROOT)/gap5/tg_contig.h
+tg_track.o: $(SRCROOT)/gap5/tg_gio.h
+tg_track.o: $(SRCROOT)/gap5/tg_iface.h
+tg_track.o: $(SRCROOT)/gap5/tg_library.h
+tg_track.o: $(SRCROOT)/gap5/tg_register.h
+tg_track.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_track.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_track.o: $(SRCROOT)/gap5/tg_struct.h
+tg_track.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_track.o: $(SRCROOT)/gap5/tg_track.h
+tg_track.o: $(SRCROOT)/gap5/tg_utils.h
 tg_tracks.o: $(PWD)/staden_config.h
+tg_tracks.o: $(SRCROOT)/Misc/array.h
+tg_tracks.o: $(SRCROOT)/Misc/misc.h
+tg_tracks.o: $(SRCROOT)/Misc/os.h
+tg_tracks.o: $(SRCROOT)/Misc/tree.h
+tg_tracks.o: $(SRCROOT)/Misc/xalloc.h
+tg_tracks.o: $(SRCROOT)/Misc/xerror.h
+tg_tracks.o: $(SRCROOT)/gap5/b+tree2.h
+tg_tracks.o: $(SRCROOT)/gap5/g-alloc.h
+tg_tracks.o: $(SRCROOT)/gap5/g-connect.h
+tg_tracks.o: $(SRCROOT)/gap5/g-db.h
+tg_tracks.o: $(SRCROOT)/gap5/g-defs.h
+tg_tracks.o: $(SRCROOT)/gap5/g-error.h
+tg_tracks.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_tracks.o: $(SRCROOT)/gap5/g-io.h
+tg_tracks.o: $(SRCROOT)/gap5/g-misc.h
+tg_tracks.o: $(SRCROOT)/gap5/g-os.h
+tg_tracks.o: $(SRCROOT)/gap5/g-request.h
+tg_tracks.o: $(SRCROOT)/gap5/g-struct.h
+tg_tracks.o: $(SRCROOT)/gap5/g.h
+tg_tracks.o: $(SRCROOT)/gap5/hache_table.h
+tg_tracks.o: $(SRCROOT)/gap5/io_utils.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_anno.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_bin.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_contig.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_gio.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_iface.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_library.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_register.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_struct.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_track.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_tracks.h
+tg_tracks.o: $(SRCROOT)/gap5/tg_utils.h
 tg_utils.o: $(PWD)/staden_config.h
+tg_utils.o: $(SRCROOT)/Misc/array.h
+tg_utils.o: $(SRCROOT)/Misc/misc.h
+tg_utils.o: $(SRCROOT)/Misc/os.h
+tg_utils.o: $(SRCROOT)/Misc/tree.h
+tg_utils.o: $(SRCROOT)/Misc/xalloc.h
+tg_utils.o: $(SRCROOT)/Misc/xerror.h
+tg_utils.o: $(SRCROOT)/gap5/b+tree2.h
+tg_utils.o: $(SRCROOT)/gap5/g-alloc.h
+tg_utils.o: $(SRCROOT)/gap5/g-connect.h
+tg_utils.o: $(SRCROOT)/gap5/g-db.h
+tg_utils.o: $(SRCROOT)/gap5/g-defs.h
+tg_utils.o: $(SRCROOT)/gap5/g-error.h
+tg_utils.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_utils.o: $(SRCROOT)/gap5/g-io.h
+tg_utils.o: $(SRCROOT)/gap5/g-misc.h
+tg_utils.o: $(SRCROOT)/gap5/g-os.h
+tg_utils.o: $(SRCROOT)/gap5/g-request.h
+tg_utils.o: $(SRCROOT)/gap5/g-struct.h
+tg_utils.o: $(SRCROOT)/gap5/g.h
+tg_utils.o: $(SRCROOT)/gap5/hache_table.h
+tg_utils.o: $(SRCROOT)/gap5/io_utils.h
+tg_utils.o: $(SRCROOT)/gap5/tg_anno.h
+tg_utils.o: $(SRCROOT)/gap5/tg_bin.h
+tg_utils.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_utils.o: $(SRCROOT)/gap5/tg_contig.h
+tg_utils.o: $(SRCROOT)/gap5/tg_gio.h
+tg_utils.o: $(SRCROOT)/gap5/tg_iface.h
+tg_utils.o: $(SRCROOT)/gap5/tg_library.h
+tg_utils.o: $(SRCROOT)/gap5/tg_register.h
+tg_utils.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_utils.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_utils.o: $(SRCROOT)/gap5/tg_struct.h
+tg_utils.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_utils.o: $(SRCROOT)/gap5/tg_track.h
+tg_utils.o: $(SRCROOT)/gap5/tg_utils.h
 tg_view.o: $(PWD)/staden_config.h
+tg_view.o: $(SRCROOT)/Misc/array.h
+tg_view.o: $(SRCROOT)/Misc/misc.h
+tg_view.o: $(SRCROOT)/Misc/os.h
+tg_view.o: $(SRCROOT)/Misc/tree.h
+tg_view.o: $(SRCROOT)/Misc/xalloc.h
+tg_view.o: $(SRCROOT)/Misc/xerror.h
+tg_view.o: $(SRCROOT)/gap5/b+tree2.h
+tg_view.o: $(SRCROOT)/gap5/g-alloc.h
+tg_view.o: $(SRCROOT)/gap5/g-connect.h
+tg_view.o: $(SRCROOT)/gap5/g-db.h
+tg_view.o: $(SRCROOT)/gap5/g-defs.h
+tg_view.o: $(SRCROOT)/gap5/g-error.h
+tg_view.o: $(SRCROOT)/gap5/g-filedefs.h
+tg_view.o: $(SRCROOT)/gap5/g-io.h
+tg_view.o: $(SRCROOT)/gap5/g-misc.h
+tg_view.o: $(SRCROOT)/gap5/g-os.h
+tg_view.o: $(SRCROOT)/gap5/g-request.h
+tg_view.o: $(SRCROOT)/gap5/g-struct.h
+tg_view.o: $(SRCROOT)/gap5/g.h
+tg_view.o: $(SRCROOT)/gap5/hache_table.h
+tg_view.o: $(SRCROOT)/gap5/io_utils.h
+tg_view.o: $(SRCROOT)/gap5/tg_anno.h
+tg_view.o: $(SRCROOT)/gap5/tg_bin.h
+tg_view.o: $(SRCROOT)/gap5/tg_cache_item.h
+tg_view.o: $(SRCROOT)/gap5/tg_contig.h
+tg_view.o: $(SRCROOT)/gap5/tg_gio.h
+tg_view.o: $(SRCROOT)/gap5/tg_iface.h
+tg_view.o: $(SRCROOT)/gap5/tg_library.h
+tg_view.o: $(SRCROOT)/gap5/tg_register.h
+tg_view.o: $(SRCROOT)/gap5/tg_scaffold.h
+tg_view.o: $(SRCROOT)/gap5/tg_sequence.h
+tg_view.o: $(SRCROOT)/gap5/tg_struct.h
+tg_view.o: $(SRCROOT)/gap5/tg_tcl.h
+tg_view.o: $(SRCROOT)/gap5/tg_track.h
+tg_view.o: $(SRCROOT)/gap5/tg_utils.h
 tk-io-reg.o: $(PWD)/staden_config.h
+tk-io-reg.o: $(SRCROOT)/Misc/array.h
+tk-io-reg.o: $(SRCROOT)/Misc/misc.h
+tk-io-reg.o: $(SRCROOT)/Misc/os.h
+tk-io-reg.o: $(SRCROOT)/Misc/tree.h
+tk-io-reg.o: $(SRCROOT)/Misc/xalloc.h
+tk-io-reg.o: $(SRCROOT)/Misc/xerror.h
+tk-io-reg.o: $(SRCROOT)/gap5/b+tree2.h
+tk-io-reg.o: $(SRCROOT)/gap5/contig_selector.h
+tk-io-reg.o: $(SRCROOT)/gap5/cs-object.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-alloc.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-connect.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-db.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-defs.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-error.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-filedefs.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-io.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-misc.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-os.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-request.h
+tk-io-reg.o: $(SRCROOT)/gap5/g-struct.h
+tk-io-reg.o: $(SRCROOT)/gap5/g.h
+tk-io-reg.o: $(SRCROOT)/gap5/gap4_compat.h
+tk-io-reg.o: $(SRCROOT)/gap5/gap_cli_arg.h
+tk-io-reg.o: $(SRCROOT)/gap5/gap_globals.h
+tk-io-reg.o: $(SRCROOT)/gap5/hache_table.h
+tk-io-reg.o: $(SRCROOT)/gap5/io_utils.h
+tk-io-reg.o: $(SRCROOT)/gap5/list.h
+tk-io-reg.o: $(SRCROOT)/gap5/newgap_cmds.h
+tk-io-reg.o: $(SRCROOT)/gap5/newgap_structs.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_anno.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_bin.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_cache_item.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_contig.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_gio.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_iface.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_library.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_register.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_scaffold.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_sequence.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_struct.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_tcl.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_track.h
+tk-io-reg.o: $(SRCROOT)/gap5/tg_utils.h
+tk-io-reg.o: $(SRCROOT)/gap5/tk-io-reg.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/canvas_box.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tk-io-reg.o: $(SRCROOT)/tk_utils/tcl_utils.h
 tkAppInit.o: $(PWD)/staden_config.h
+tkAppInit.o: $(SRCROOT)/Misc/array.h
+tkAppInit.o: $(SRCROOT)/Misc/misc.h
+tkAppInit.o: $(SRCROOT)/Misc/os.h
+tkAppInit.o: $(SRCROOT)/Misc/tree.h
+tkAppInit.o: $(SRCROOT)/Misc/xalloc.h
+tkAppInit.o: $(SRCROOT)/Misc/xerror.h
+tkAppInit.o: $(SRCROOT)/gap5/b+tree2.h
+tkAppInit.o: $(SRCROOT)/gap5/g-alloc.h
+tkAppInit.o: $(SRCROOT)/gap5/g-connect.h
+tkAppInit.o: $(SRCROOT)/gap5/g-db.h
+tkAppInit.o: $(SRCROOT)/gap5/g-defs.h
+tkAppInit.o: $(SRCROOT)/gap5/g-error.h
+tkAppInit.o: $(SRCROOT)/gap5/g-filedefs.h
+tkAppInit.o: $(SRCROOT)/gap5/g-io.h
+tkAppInit.o: $(SRCROOT)/gap5/g-misc.h
+tkAppInit.o: $(SRCROOT)/gap5/g-os.h
+tkAppInit.o: $(SRCROOT)/gap5/g-request.h
+tkAppInit.o: $(SRCROOT)/gap5/g-struct.h
+tkAppInit.o: $(SRCROOT)/gap5/g.h
+tkAppInit.o: $(SRCROOT)/gap5/gap-tcl.h
+tkAppInit.o: $(SRCROOT)/gap5/gap_globals.h
+tkAppInit.o: $(SRCROOT)/gap5/hache_table.h
+tkAppInit.o: $(SRCROOT)/gap5/io_utils.h
+tkAppInit.o: $(SRCROOT)/gap5/list.h
+tkAppInit.o: $(SRCROOT)/gap5/newgap_cmds.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_anno.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_bin.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_cache_item.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_contig.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_gio.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_iface.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_library.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_register.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_scaffold.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_sequence.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_struct.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_tcl.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_track.h
+tkAppInit.o: $(SRCROOT)/gap5/tg_utils.h
+tkAppInit.o: $(SRCROOT)/tk_utils/tcl_utils.h
 tkEdNames.o: $(PWD)/staden_config.h
+tkEdNames.o: $(SRCROOT)/Misc/array.h
+tkEdNames.o: $(SRCROOT)/Misc/misc.h
+tkEdNames.o: $(SRCROOT)/Misc/os.h
+tkEdNames.o: $(SRCROOT)/Misc/tree.h
+tkEdNames.o: $(SRCROOT)/Misc/xalloc.h
+tkEdNames.o: $(SRCROOT)/Misc/xerror.h
+tkEdNames.o: $(SRCROOT)/gap5/b+tree2.h
+tkEdNames.o: $(SRCROOT)/gap5/consensus.h
+tkEdNames.o: $(SRCROOT)/gap5/editor_view.h
+tkEdNames.o: $(SRCROOT)/gap5/g-alloc.h
+tkEdNames.o: $(SRCROOT)/gap5/g-connect.h
+tkEdNames.o: $(SRCROOT)/gap5/g-db.h
+tkEdNames.o: $(SRCROOT)/gap5/g-defs.h
+tkEdNames.o: $(SRCROOT)/gap5/g-error.h
+tkEdNames.o: $(SRCROOT)/gap5/g-filedefs.h
+tkEdNames.o: $(SRCROOT)/gap5/g-io.h
+tkEdNames.o: $(SRCROOT)/gap5/g-misc.h
+tkEdNames.o: $(SRCROOT)/gap5/g-os.h
+tkEdNames.o: $(SRCROOT)/gap5/g-request.h
+tkEdNames.o: $(SRCROOT)/gap5/g-struct.h
+tkEdNames.o: $(SRCROOT)/gap5/g.h
+tkEdNames.o: $(SRCROOT)/gap5/hache_table.h
+tkEdNames.o: $(SRCROOT)/gap5/io_utils.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_anno.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_bin.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_cache_item.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_contig.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_gio.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_iface.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_library.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_register.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_scaffold.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_sequence.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_struct.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_tcl.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_track.h
+tkEdNames.o: $(SRCROOT)/gap5/tg_utils.h
+tkEdNames.o: $(SRCROOT)/gap5/tkEdNames.h
+tkEdNames.o: $(SRCROOT)/gap5/tkEditor.h
+tkEdNames.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkEdNames.o: $(SRCROOT)/tk_utils/sheet.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkEdNames.o: $(SRCROOT)/tk_utils/tk_defs.h
 tkEditor.o: $(PWD)/staden_config.h
+tkEditor.o: $(SRCROOT)/Misc/array.h
+tkEditor.o: $(SRCROOT)/Misc/dstring.h
+tkEditor.o: $(SRCROOT)/Misc/misc.h
+tkEditor.o: $(SRCROOT)/Misc/os.h
+tkEditor.o: $(SRCROOT)/Misc/tree.h
+tkEditor.o: $(SRCROOT)/Misc/xalloc.h
+tkEditor.o: $(SRCROOT)/Misc/xerror.h
+tkEditor.o: $(SRCROOT)/gap5/b+tree2.h
+tkEditor.o: $(SRCROOT)/gap5/consensus.h
+tkEditor.o: $(SRCROOT)/gap5/editor_oligo.h
+tkEditor.o: $(SRCROOT)/gap5/editor_view.h
+tkEditor.o: $(SRCROOT)/gap5/g-alloc.h
+tkEditor.o: $(SRCROOT)/gap5/g-connect.h
+tkEditor.o: $(SRCROOT)/gap5/g-db.h
+tkEditor.o: $(SRCROOT)/gap5/g-defs.h
+tkEditor.o: $(SRCROOT)/gap5/g-error.h
+tkEditor.o: $(SRCROOT)/gap5/g-filedefs.h
+tkEditor.o: $(SRCROOT)/gap5/g-io.h
+tkEditor.o: $(SRCROOT)/gap5/g-misc.h
+tkEditor.o: $(SRCROOT)/gap5/g-os.h
+tkEditor.o: $(SRCROOT)/gap5/g-request.h
+tkEditor.o: $(SRCROOT)/gap5/g-struct.h
+tkEditor.o: $(SRCROOT)/gap5/g.h
+tkEditor.o: $(SRCROOT)/gap5/gap4_compat.h
+tkEditor.o: $(SRCROOT)/gap5/gap_globals.h
+tkEditor.o: $(SRCROOT)/gap5/hache_table.h
+tkEditor.o: $(SRCROOT)/gap5/io_utils.h
+tkEditor.o: $(SRCROOT)/gap5/notedb.h
+tkEditor.o: $(SRCROOT)/gap5/tagdb.h
+tkEditor.o: $(SRCROOT)/gap5/tg_anno.h
+tkEditor.o: $(SRCROOT)/gap5/tg_bin.h
+tkEditor.o: $(SRCROOT)/gap5/tg_cache_item.h
+tkEditor.o: $(SRCROOT)/gap5/tg_contig.h
+tkEditor.o: $(SRCROOT)/gap5/tg_gio.h
+tkEditor.o: $(SRCROOT)/gap5/tg_iface.h
+tkEditor.o: $(SRCROOT)/gap5/tg_library.h
+tkEditor.o: $(SRCROOT)/gap5/tg_register.h
+tkEditor.o: $(SRCROOT)/gap5/tg_scaffold.h
+tkEditor.o: $(SRCROOT)/gap5/tg_sequence.h
+tkEditor.o: $(SRCROOT)/gap5/tg_struct.h
+tkEditor.o: $(SRCROOT)/gap5/tg_tcl.h
+tkEditor.o: $(SRCROOT)/gap5/tg_track.h
+tkEditor.o: $(SRCROOT)/gap5/tg_utils.h
+tkEditor.o: $(SRCROOT)/gap5/tkEdNames.h
+tkEditor.o: $(SRCROOT)/gap5/tkEditor.h
+tkEditor.o: $(SRCROOT)/gap5/tman_display.h
+tkEditor.o: $(SRCROOT)/gap5/tman_interface.h
+tkEditor.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkEditor.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkEditor.o: $(SRCROOT)/tk_utils/postscript.h
+tkEditor.o: $(SRCROOT)/tk_utils/sheet.h
+tkEditor.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkEditor.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkEditor.o: $(SRCROOT)/tk_utils/tk_defs.h
 tman_display.o: $(PWD)/staden_config.h
+tman_display.o: $(SRCROOT)/Misc/array.h
+tman_display.o: $(SRCROOT)/Misc/dstring.h
+tman_display.o: $(SRCROOT)/Misc/misc.h
+tman_display.o: $(SRCROOT)/Misc/os.h
+tman_display.o: $(SRCROOT)/Misc/tree.h
+tman_display.o: $(SRCROOT)/Misc/xalloc.h
+tman_display.o: $(SRCROOT)/Misc/xerror.h
+tman_display.o: $(SRCROOT)/gap5/b+tree2.h
+tman_display.o: $(SRCROOT)/gap5/consensus.h
+tman_display.o: $(SRCROOT)/gap5/editor_view.h
+tman_display.o: $(SRCROOT)/gap5/g-alloc.h
+tman_display.o: $(SRCROOT)/gap5/g-connect.h
+tman_display.o: $(SRCROOT)/gap5/g-db.h
+tman_display.o: $(SRCROOT)/gap5/g-defs.h
+tman_display.o: $(SRCROOT)/gap5/g-error.h
+tman_display.o: $(SRCROOT)/gap5/g-filedefs.h
+tman_display.o: $(SRCROOT)/gap5/g-io.h
+tman_display.o: $(SRCROOT)/gap5/g-misc.h
+tman_display.o: $(SRCROOT)/gap5/g-os.h
+tman_display.o: $(SRCROOT)/gap5/g-request.h
+tman_display.o: $(SRCROOT)/gap5/g-struct.h
+tman_display.o: $(SRCROOT)/gap5/g.h
+tman_display.o: $(SRCROOT)/gap5/gap_globals.h
+tman_display.o: $(SRCROOT)/gap5/hache_table.h
+tman_display.o: $(SRCROOT)/gap5/io_utils.h
+tman_display.o: $(SRCROOT)/gap5/tg_anno.h
+tman_display.o: $(SRCROOT)/gap5/tg_bin.h
+tman_display.o: $(SRCROOT)/gap5/tg_cache_item.h
+tman_display.o: $(SRCROOT)/gap5/tg_contig.h
+tman_display.o: $(SRCROOT)/gap5/tg_gio.h
+tman_display.o: $(SRCROOT)/gap5/tg_iface.h
+tman_display.o: $(SRCROOT)/gap5/tg_library.h
+tman_display.o: $(SRCROOT)/gap5/tg_register.h
+tman_display.o: $(SRCROOT)/gap5/tg_scaffold.h
+tman_display.o: $(SRCROOT)/gap5/tg_sequence.h
+tman_display.o: $(SRCROOT)/gap5/tg_struct.h
+tman_display.o: $(SRCROOT)/gap5/tg_tcl.h
+tman_display.o: $(SRCROOT)/gap5/tg_track.h
+tman_display.o: $(SRCROOT)/gap5/tg_utils.h
+tman_display.o: $(SRCROOT)/gap5/tkEdNames.h
+tman_display.o: $(SRCROOT)/gap5/tkEditor.h
+tman_display.o: $(SRCROOT)/gap5/tman_display.h
+tman_display.o: $(SRCROOT)/gap5/tman_interface.h
+tman_display.o: $(SRCROOT)/tk_utils/cli_arg.h
+tman_display.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tman_display.o: $(SRCROOT)/tk_utils/postscript.h
+tman_display.o: $(SRCROOT)/tk_utils/sheet.h
+tman_display.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tman_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tman_display.o: $(SRCROOT)/tk_utils/tkSheet.h
+tman_display.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tman_display.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tman_display.o: $(SRCROOT)/tk_utils/tkTrace.h
 tman_interface.o: $(PWD)/staden_config.h
-zfio.o: $(PWD)/staden_config.h
+tman_interface.o: $(SRCROOT)/Misc/array.h
+tman_interface.o: $(SRCROOT)/Misc/dstring.h
+tman_interface.o: $(SRCROOT)/Misc/misc.h
+tman_interface.o: $(SRCROOT)/Misc/os.h
+tman_interface.o: $(SRCROOT)/Misc/tree.h
+tman_interface.o: $(SRCROOT)/Misc/xalloc.h
+tman_interface.o: $(SRCROOT)/Misc/xerror.h
+tman_interface.o: $(SRCROOT)/gap5/b+tree2.h
+tman_interface.o: $(SRCROOT)/gap5/consensus.h
+tman_interface.o: $(SRCROOT)/gap5/editor_view.h
+tman_interface.o: $(SRCROOT)/gap5/g-alloc.h
+tman_interface.o: $(SRCROOT)/gap5/g-connect.h
+tman_interface.o: $(SRCROOT)/gap5/g-db.h
+tman_interface.o: $(SRCROOT)/gap5/g-defs.h
+tman_interface.o: $(SRCROOT)/gap5/g-error.h
+tman_interface.o: $(SRCROOT)/gap5/g-filedefs.h
+tman_interface.o: $(SRCROOT)/gap5/g-io.h
+tman_interface.o: $(SRCROOT)/gap5/g-misc.h
+tman_interface.o: $(SRCROOT)/gap5/g-os.h
+tman_interface.o: $(SRCROOT)/gap5/g-request.h
+tman_interface.o: $(SRCROOT)/gap5/g-struct.h
+tman_interface.o: $(SRCROOT)/gap5/g.h
+tman_interface.o: $(SRCROOT)/gap5/hache_table.h
+tman_interface.o: $(SRCROOT)/gap5/io_utils.h
+tman_interface.o: $(SRCROOT)/gap5/tg_anno.h
+tman_interface.o: $(SRCROOT)/gap5/tg_bin.h
+tman_interface.o: $(SRCROOT)/gap5/tg_cache_item.h
+tman_interface.o: $(SRCROOT)/gap5/tg_contig.h
+tman_interface.o: $(SRCROOT)/gap5/tg_gio.h
+tman_interface.o: $(SRCROOT)/gap5/tg_iface.h
+tman_interface.o: $(SRCROOT)/gap5/tg_library.h
+tman_interface.o: $(SRCROOT)/gap5/tg_register.h
+tman_interface.o: $(SRCROOT)/gap5/tg_scaffold.h
+tman_interface.o: $(SRCROOT)/gap5/tg_sequence.h
+tman_interface.o: $(SRCROOT)/gap5/tg_struct.h
+tman_interface.o: $(SRCROOT)/gap5/tg_tcl.h
+tman_interface.o: $(SRCROOT)/gap5/tg_track.h
+tman_interface.o: $(SRCROOT)/gap5/tg_utils.h
+tman_interface.o: $(SRCROOT)/gap5/tkEdNames.h
+tman_interface.o: $(SRCROOT)/gap5/tkEditor.h
+tman_interface.o: $(SRCROOT)/gap5/tman_display.h
+tman_interface.o: $(SRCROOT)/gap5/tman_interface.h
+tman_interface.o: $(SRCROOT)/tk_utils/cli_arg.h
+tman_interface.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tman_interface.o: $(SRCROOT)/tk_utils/postscript.h
+tman_interface.o: $(SRCROOT)/tk_utils/sheet.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkSheet.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tman_interface.o: $(SRCROOT)/tk_utils/tkTrace.h
diff --git a/gap5/ace.c b/gap5/ace.c
index 410e8fa..4ba6959 100644
--- a/gap5/ace.c
+++ b/gap5/ace.c
@@ -10,7 +10,7 @@
 #include "ace.h"
 #include "dna_utils.h"
 #include "tg_index_common.h"
-#include "zfio.h"
+#include "io_lib/zfio.h"
 
 /*
  * Code for reading the new-ACE format as described at:
diff --git a/gap5/actf.c b/gap5/actf.c
index 3683175..45a76dc 100644
--- a/gap5/actf.c
+++ b/gap5/actf.c
@@ -262,7 +262,9 @@ int actf_lock(int read_only, char *file, int new) {
 #endif
     namelen = strlen(content);
     sprintf(content + namelen, " %d\n", (int)getpid());
-    write(fd, content, namelen + strlen(content + namelen));
+    // Failure to write here isn't a serious problem.
+    if (-1 == write(fd, content, namelen + strlen(content + namelen)))
+	verror(ERR_WARN, "actf_lock", "Failed to write to lock file\n");
 
     lock_files[numu_lock_files].pathname = fname; fname = NULL;
     lock_files[numu_lock_files].db_name = strdup(db_name);
diff --git a/gap5/assemble_single.tcl b/gap5/assemble_single.tcl
index e06b0e6..695d363 100644
--- a/gap5/assemble_single.tcl
+++ b/gap5/assemble_single.tcl
@@ -28,6 +28,10 @@ proc AssemblySingle {io} {
     # fasta/q input file name
     getFname $w.file "File name" load
     
+    xentry $w.qual \
+	-label "Override quality" \
+	-default ""
+
     okcancelhelp $w.ok \
 	-ok_command "AssemblySingle2 $io $w" \
 	-cancel_command "destroy $w" \
@@ -35,7 +39,7 @@ proc AssemblySingle {io} {
 
     pack $w.label -side top -fill both -expand 1
     pack $w.sep -side top -fill both -expand 1 -padx 10 -pady 10
-    pack $w.format $w.file $w.ok -side top -fill both -expand 1
+    pack $w.format $w.file $w.qual $w.ok -side top -fill both -expand 1
     
 }
 
@@ -63,6 +67,13 @@ proc AssemblySingle2 {io w} {
 	return
     }
 
+    set qual [$w.qual get]
+    if {$qual == ""} {set qual -3}
+    if {![regexp {^[-+]?[0-9]+$} $qual]} {
+	bell
+	return
+    }
+
     destroy $w
     SetBusy
 
@@ -71,14 +82,15 @@ proc AssemblySingle2 {io w} {
 		       -append 1 \
 		       -file $fn \
 		       -format $format \
-		       -index_names 1 } ]
+		       -index_names 1 \
+		       -qual $qual} ]
      } {
 	verror ERR_WARN "AssemblySingle" "Import failed"
 	tk_messageBox -icon error -type ok -title "Import failed" \
 		-message "Error detected while importing reads."
 	$io flush
 	ClearBusy
-	PostLoadSetup
+	AssemblySinglePostLoad $io
 	return
     }
 
@@ -86,5 +98,33 @@ proc AssemblySingle2 {io w} {
 
     $io flush
     ClearBusy
-    PostLoadSetup
+    AssemblySinglePostLoad $io
 }
+
+proc AssemblySinglePostLoad {io} {
+    global gap5_defs
+
+    # Display contig selector if appropriate.
+    set cs_win [keylget gap5_defs CONTIG_SEL.WIN]
+    global do_csel
+    if {![winfo exists $cs_win] && $do_csel} {
+	if {$do_csel == 2 || [db_info num_contigs $io] <= 1000} {
+	    ContigSelector $io
+	} else {
+	    vmessage "\nSkipping contig selector due to large number of contigs."
+	}
+    } else {
+	ContigInitReg $io
+	catch {raise $cs_win}
+    }
+
+    # We may be going from 0 contigs to N contigs, so "un-grey" menus if so.
+    ActivateMenu_Open 
+    Menu_Check_RO $io
+
+    # Check CurContig/LREG/RREG if not already done
+    global CurContig
+    if {![info exists CurContig] || $CurContig == ""} {
+	InitContigGlobals $io
+    }
+}
\ No newline at end of file
diff --git a/gap5/auto_break.c b/gap5/auto_break.c
index aa3b709..0d6d939 100644
--- a/gap5/auto_break.c
+++ b/gap5/auto_break.c
@@ -43,6 +43,7 @@
 
 #include <assert.h>
 #include <math.h>
+#include <ctype.h>
 #include <io_lib/hash_table.h>
 
 #include "tg_gio.h"
@@ -55,6 +56,7 @@
 #include "qual.h"
 #include "qualIO.h"
 #include "dstring.h"
+#include "consensus.h"
 
 #define MIN3(a,b,c) (MIN(MIN((a),(b)),(c)))
 #define MAX3(a,b,c) (MAX(MAX((a),(b)),(c)))
@@ -372,7 +374,7 @@ int64_t word_count_cons(GapIO *io, int argc, contig_list_t *argv) {
     for (cnum = 0; cnum < argc; cnum++) {
 	contig_t *c;
 	int clen;
-	char *s;
+	unsigned char *s;
 	unsigned int word, cword;
 
 	c = cache_search(io, GT_Contig, argv[cnum].contig);
@@ -389,7 +391,7 @@ int64_t word_count_cons(GapIO *io, int argc, contig_list_t *argv) {
 	if (clen <= 2*CONTIG_END_IGNORE)
 	    continue;
 
-	s = cons + CONTIG_END_IGNORE;
+	s = (unsigned char *) cons + CONTIG_END_IGNORE;
 	cons[clen-1-CONTIG_END_IGNORE] = 0;
 
 	cword = word = 0;
@@ -520,7 +522,7 @@ int filter_common_words(char *seq, char *filt, size_t len, int tw,
 	    continue;
 	}
 
-	word = (word << 2) | lookup[seq[i]];
+	word = (word << 2) | lookup[(unsigned char) seq[i]];
 	j++;
     }
     
@@ -549,7 +551,7 @@ int filter_common_words(char *seq, char *filt, size_t len, int tw,
 	    continue;
 	}
 
-	word = (word << 2) | lookup[seq[i]];
+	word = (word << 2) | lookup[(unsigned char) seq[i]];
 	
 	if (debug)
 	    printf("Seq pos %ld %.*s: => %d",
@@ -634,7 +636,7 @@ static Array suspect_joins(GapIO *io, tg_rec contig, int64_t tw,
 			   HashTable *clip_hash, int end_skip_len) {
     int i, clen, cstart, cend;
     char *valid = NULL, *cp;
-    int *clip_depth = NULL, *total_depth;
+    int *clip_depth = NULL, *total_depth = NULL;
     char legal_chars[256];
     Array gaps;
     char *cons = NULL;
@@ -655,7 +657,7 @@ static Array suspect_joins(GapIO *io, tg_rec contig, int64_t tw,
 
     memset(legal_chars, 0, 256);
     for (cp = "ACGTacgt"; *cp; cp++)
-	legal_chars[*cp] = 1;
+	legal_chars[(unsigned char) *cp] = 1;
 
     /* Compute consensus */
     if (NULL == (cons = (char *)xmalloc(clen+1)))
@@ -670,7 +672,7 @@ static Array suspect_joins(GapIO *io, tg_rec contig, int64_t tw,
      */
     ci = contig_iter_new(io, contig, 1, CITER_FIRST |CITER_ISTART |CITER_PAIR,
 			 CITER_CSTART, CITER_CEND);
-    while (r = contig_iter_next(io, ci)) {
+    while (NULL != (r = contig_iter_next(io, ci))) {
 	seq_t *s = cache_search(io, GT_Seq, r->rec), *sorig = s;
 	char *seq, *fseq;
 	size_t len;
@@ -986,10 +988,10 @@ static int consistent_pair(GapIO *io, rangec_t *r, HashTable *lt_h,
  */
 static int pair_in_range(GapIO *io, rangec_t *r, HashTable *lt_h,
 			 int start, int end) {
-    int isize_min, isize_max, isize, lib_type;
+    int isize_min, isize_max;
 
-    lib_type = compute_lib_type(io, r->library_rec, lt_h,
-				&isize_min, &isize_max, NULL);
+    compute_lib_type(io, r->library_rec, lt_h,
+		     &isize_min, &isize_max, NULL);
 
     if (r->start      < start && start - r->start      < isize_max) return 1;
     if (r->end        < start && start - r->end        < isize_max) return 1;
@@ -1053,7 +1055,7 @@ static void dump_template_dist(GapIO *io, tg_rec contig) {
     sum = 0;
     sum_sq = 0;
     last_i = cstart;
-    while (r = contig_iter_next(io, ci)) {
+    while (NULL != (r = contig_iter_next(io, ci))) {
 	int st, en, severity;
 
 	sequence_get_range_pair_position(io, r, contig, 0);
@@ -1148,7 +1150,6 @@ static void dump_template_dist(GapIO *io, tg_rec contig) {
 		if (!stats[x])
 		    continue;
 
-		int isz  = x;
 		int ibin = isize2ibin(x);
 		int iwid = ibin_width(x);
 		double e = ((double)lib->size_hist[0][ibin]/iwid) / count * N;
@@ -1276,7 +1277,7 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
     HashIter *iter;
     HashItem *hi;
     int cstart, cend;
-    int last_gap, next_gap;
+    // int last_gap, next_gap;
     int first_pass = 1;
     
     lt_h = HashTableCreate(256, HASH_POOL_ITEMS | HASH_DYNAMIC_SIZE);
@@ -1290,8 +1291,8 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
     if (consensus_valid_range(io, contig, &cstart, &cend) == -1)
 	goto cleanup;
 
- second_pass:
-    last_gap = INT_MIN;
+    // second_pass:
+    // last_gap = INT_MIN;
 
     /* Now process gaps validating by read-pair */
     for (i = 0; i < ArrayMax(gaps); i++) {
@@ -1324,9 +1325,9 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 	    if (!(arrp(contig_region_t, gaps, j))->valid)
 		break;
 	}
-	next_gap = j < ArrayMax(gaps) 
-	    ? (arrp(contig_region_t, gaps, j))->start
-	    : INT_MAX;
+	/* next_gap = j < ArrayMax(gaps) 
+	   ? (arrp(contig_region_t, gaps, j))->start
+	   : INT_MAX; */
 
 	printf("Gap %d..%d ", gap->start, gap->end);
 
@@ -1365,7 +1366,7 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 	     * a contig missing.
 	     */
 	    if (!r[j].pair_rec) {
-		int x, valid = 0, lib_type;
+		int valid = 0, lib_type;
 		int isize_min, isize_max, isize_mid;
 
 		if (!r[j].library_rec)
@@ -1387,36 +1388,40 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 		case LIB_T_INWARD:
 		    if ((r[j].flags & GRANGE_FLAG_COMP1) == 0) {
 			if (gap->start > r[j].start && 
-			    gap->start - r[j].start < isize_mid)
+			    gap->start - r[j].start < isize_mid) {
 			    if (r[j].mqual >= unique_mqual)
 				num_unique_single++;
 			    else
 				num_single++;
+			}
 		    } else {
 			if (r[j].end > gap->end &&
-			    r[j].end - gap->end < isize_mid)
+			    r[j].end - gap->end < isize_mid) {
 			    if (r[j].mqual >= unique_mqual)
 				num_unique_single++;
 			    else
 				num_single++;
+			}
 		    }
 		    break;
 
 		case LIB_T_OUTWARD:
 		    if ((r[j].flags & GRANGE_FLAG_COMP1) != 0) {
 			if (gap->start > r[j].start &&
-			    gap->start - r[j].start < isize_mid)
+			    gap->start - r[j].start < isize_mid) {
 			    if (r[j].mqual >= unique_mqual)
 				num_unique_single++;
 			    else
 				num_single++;
+			}
 		    } else {
 			if (r[j].end > gap->end &&
-			    r[j].end - gap->end < isize_mid)
+			    r[j].end - gap->end < isize_mid) {
 			    if (r[j].mqual >= unique_mqual)
 				num_unique_single++;
 			    else
 				num_single++;
+			}
 		    }
 		    break;
 
@@ -1513,11 +1518,12 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 		/* Shouldn't get here as we only added pairs */
 		int x, valid;
 		compute_lib_type(io, r->library_rec, lt_h, &x, &x, &valid);
-		if (valid)
+		if (valid) {
 		    if (r->mqual >= unique_mqual)
 			num_unique_single++;
 		    else
 			num_single++;
+		}
 		continue;
 	    }
 	    /* Check consistency */
@@ -1577,21 +1583,23 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 			break;
 
 		    if (gap->start > r->start &&
-			gap->start - r->start < isize_mid)
+			gap->start - r->start < isize_mid) {
 			// just left of gap
 			if (unique)
 			    num_unique_spanning++;
 			else
 			    num_spanning++;
+		    }
 		} else {
 		    if (r->end - cstart < isize_max)
 			break;
 
-		    if (r->end > gap->end && r->end - gap->end < isize_mid)
+		    if (r->end > gap->end && r->end - gap->end < isize_mid) {
 			if (unique)
 			    num_unique_spanning++;
 			else
 			    num_spanning++;
+		    }
 		}
 		break;
 
@@ -1601,35 +1609,38 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 			break;
 
 		    if (gap->start > r->start &&
-			gap->start - r->start < isize_mid)
+			gap->start - r->start < isize_mid) {
 			if (unique)
 			    num_unique_spanning++;
 			else
 			    num_spanning++;
+		    }
 		} else {
 		    if (r->end - cstart < isize_max)
 			break;
 
-		    if (r->end > gap->end && r->end - gap->end < isize_mid)
+		    if (r->end > gap->end && r->end - gap->end < isize_mid) {
 			if (unique)
 			    num_unique_spanning++;
 			else
 			    num_spanning++;
+		    }
 		}
 		break;
 
 	    case LIB_T_SAME:
 		/* We can't tell which is 1st and 2nd read easily? */
-		if (gap->start > r->start && gap->start - r->start < isize_mid)
+		if (gap->start > r->start && gap->start - r->start < isize_mid){
 		    if (unique)
 			num_unique_spanning++;
 		    else
 			num_spanning++;
-		else if (r->end > gap->end && r->end - gap->end < isize_mid)
+		} else if (r->end > gap->end && r->end - gap->end < isize_mid) {
 		    if (unique)
 			num_unique_spanning++;
 		    else
 			num_spanning++;
+		}
 		break;
 
 	    default:
@@ -1683,7 +1694,7 @@ static void confirm_gaps(GapIO *io, tg_rec contig, Array gaps,
 	    gap->r  = r;
 	    gap->nr = nr;
 
-	    last_gap = gap->end;
+	    // last_gap = gap->end;
 	}
 
 	fflush(stdout);
@@ -1775,7 +1786,6 @@ static void merge_gaps(Array gaps, int min_distance) {
 static void break_gaps(GapIO *io, tg_rec contig, Array gaps, char *tag_params,
 		       HashTable *clip_hash, dstring_t *ds) {
     int i, j, new_start;
-    tg_rec right_start = 0;
 
     for (i = 0; i < ArrayMax(gaps); i++) {
 	contig_region_t *gap = arrp(contig_region_t, gaps, i);
@@ -1976,8 +1986,7 @@ dstring_t *auto_break_contigs(GapIO *io, int argc, contig_list_t *argv,
 			      int singleton_score, int singleton_unique_score)
 {
     int i;
-    int64_t tw;
-    double gc;
+    int64_t tw = 0;
     int depth = 1; // filter by consensus
 
     dstring_t *ds = dstring_create(NULL);
diff --git a/gap5/b+tree2.c b/gap5/b+tree2.c
index 205660f..569da6f 100644
--- a/gap5/b+tree2.c
+++ b/gap5/b+tree2.c
@@ -708,6 +708,7 @@ int btree_count(btree_t *t, btree_node_t *n) {
     return cnt;
 }
 
+#if 0
 #define FRONT_COMPRESSION
 int btree_size(btree_t *t, btree_node_t *n) {
     int sz = 0, sz2 = 0;
@@ -752,6 +753,7 @@ int btree_size(btree_t *t, btree_node_t *n) {
 
     return sz + sz2;
 }
+#endif
 
 void btree_list(btree_t *t, char *prefix) {
     btree_node_t *n;
diff --git a/gap5/baf.c b/gap5/baf.c
index e27cfea..8fc5f2b 100644
--- a/gap5/baf.c
+++ b/gap5/baf.c
@@ -14,7 +14,7 @@
 #include "tg_index_common.h"
 #include "hache_table.h"
 #include "baf.h"
-#include "zfio.h"
+#include "io_lib/zfio.h"
 
 #define CC2(a,b) ((((unsigned char)a)<<8) | ((unsigned char)b))
 
diff --git a/gap5/break_contig.c b/gap5/break_contig.c
index 1d68449..763b194 100644
--- a/gap5/break_contig.c
+++ b/gap5/break_contig.c
@@ -762,6 +762,7 @@ static int break_contig_recurse(GapIO *io, HacheTable *h,
 	    range_t *r = arrp(range_t, bin->rng, i);
 	    int cstart; /* clipped sequence positions */
 	    seq_t *s;
+	    HacheData hd;
 
 	    if (r->flags & GRANGE_FLAG_UNUSED)
 		continue;
@@ -784,19 +785,9 @@ static int break_contig_recurse(GapIO *io, HacheTable *h,
 		cstart = NMIN(r->start, r->end) + s->left-1;
 	    }
 	    
-	    if (cstart >= pos)  {
-		HacheData hd; hd.i = 1;
-		HacheTableAdd(h, (char *)&r->rec, sizeof(r->rec), hd, NULL);
-		//printf("Add seq #%"PRIrec" to hash value 1\n", r->rec);
-	    } else {
-		int end;
-
-		HacheData hd; hd.i = 0;
-		HacheTableAdd(h, (char *)&r->rec, sizeof(r->rec), hd, NULL);
-		//printf("Add seq #%"PRIrec" to hash value 0\n", r->rec);
-
-		end = NMAX(r->start, r->end);
-	    }
+	    hd.i = cstart >= pos ? 1 : 0;
+	    HacheTableAdd(h, (char *)&r->rec, sizeof(r->rec), hd, NULL);
+	    //printf("Add seq #%"PRIrec" to hash value %"PRIu64"\n", r->rec, hd.i);
 	}
 	
 	/* Pass 2 - do the moving of anno/seqs */
diff --git a/gap5/check_assembly.c b/gap5/check_assembly.c
index 743e218..953792a 100644
--- a/gap5/check_assembly.c
+++ b/gap5/check_assembly.c
@@ -132,7 +132,7 @@ int check_uassembly_single(GapIO *io, char *cons, int contig, rangec_t *r,
  */
 void *checkass_obj_func(int job, void *jdata, obj_checkass *obj,
 			mobj_checkass *ca) {
-    static char buf[80];
+    static char buf[160];
     obj_cs *cs;
     int cs_id;
 
@@ -151,12 +151,10 @@ void *checkass_obj_func(int job, void *jdata, obj_checkass *obj,
 	case -1: /* Information from results manager */
 	    start_message();
 	    vmessage("check_assembly match:\n");
-	    vmessage("    From contig %s(=%"PRIrec") at %d\n",
+	    vmessage("    In contig %s(=%"PRIrec") at %d %s\n",
 		     get_contig_name(ca->io, ABS(obj->c1)),
-		     ABS(obj->c1), obj->pos1);
-	    vmessage("    With contig %s(=%"PRIrec") at %d\n",
-		     get_contig_name(ca->io, ABS(obj->c2)),
-		     ABS(obj->c2), obj->pos2);
+		     ABS(obj->c1), obj->pos1,
+		     seq_name(ca->io, obj->read));
 	    vmessage("    Length %d, mismatch %2.2f%%\n\n",
 		     obj->length, ((float)obj->score)/10000);
 	    end_message(cs->window);
diff --git a/gap5/configure.tcl b/gap5/configure.tcl
index d727e9c..f0da373 100644
--- a/gap5/configure.tcl
+++ b/gap5/configure.tcl
@@ -7,10 +7,12 @@
 # for a disclaimer of all warranties.
 #
 
+set seq_techs [list Sanger Illumina SOLiD 454 Helico IonTorrent PacBio ONT]
+
 #-----------------------------------------------------------------------------
 # Sets the consensus and quality cutoff values
 #
-proc ConfigureCutoffs {} {
+proc ConfigureCutoffs {io} {
     global gap5_defs consensus_iub
 
     set l [keylget gap5_defs CONFIGURE]
@@ -49,6 +51,17 @@ proc ConfigureCutoffs {} {
     global $t.iub.v
     set $t.iub.v $consensus_iub
 
+    global seq_techs default_seq_tech
+    xcombobox $t.seq_tech \
+	-label "Seq. tech. for unknown datasets" \
+	-fixed_list 1 \
+	-values $seq_techs
+    $t.seq_tech set [lindex $seq_techs [expr {$default_seq_tech-1}]]
+
+    if {[$io read_only]} {
+	$t.seq_tech configure -state disabled
+    }
+
     radiolist $t.mode \
 	-title [keylget l CMODE_NAME] \
 	-bd 2 -relief groove \
@@ -62,22 +75,23 @@ proc ConfigureCutoffs {} {
 		[list "scalebox_configure $t.quality -state disabled"]]
 
     okcancelhelp $t.ok -bd 2 -relief groove \
-	-ok_command "ConfigureCutoffs2 0 $t $t.consensus $t.quality \
-		$t.chem.v $t.mode $t.iub.v" \
-	-perm_command "ConfigureCutoffs2 1 $t $t.consensus $t.quality \
+	-ok_command "ConfigureCutoffs2 $io 0 $t $t.consensus $t.quality \
+		$t.chem.v $t.mode $t.iub.v $t.seq_tech" \
+	-perm_command "ConfigureCutoffs2 $io 1 $t $t.consensus $t.quality \
 		$t.chem.v $t.mode $t.iub.v" \
 	-cancel_command "destroy $t" \
 	-help_command "show_help gap5 {Con-Calculation}"
 
     pack $t.mode $t.consensus $t.quality -side top -fill both
-    pack $t.chem -pady 7 -side top -fill both
-    pack $t.iub -pady 7 -side top -fill both
+    pack $t.chem -pady 7 -side top -anchor w
+    pack $t.iub -pady 7 -side top -anchor w
+    pack $t.seq_tech -side top -anchor w
     pack $t.ok -side top -fill both
 }
 
-proc ConfigureCutoffs2 {perm t consensus quality chem mode iub} {
+proc ConfigureCutoffs2 {io perm t consensus quality chem mode iub seq_tech} {
     global gap5_defs consensus_cutoff quality_cutoff chem_as_double $chem env
-    global consensus_mode consensus_iub $iub
+    global consensus_mode consensus_iub $iub default_seq_tech seq_techs
 
     set consensus_mode [expr [radiolist_get $mode]-1]
     if {$consensus_mode == 0} {
@@ -91,6 +105,21 @@ proc ConfigureCutoffs2 {perm t consensus quality chem mode iub} {
     set consensus_cutoff [expr [scalebox_get $consensus]/100.0]
     set chem_as_double [set $chem]
     set consensus_iub [set $iub]
+    set seq_tech [lsearch $seq_techs [$seq_tech get]]
+    if {$seq_tech >= 0} {
+	incr seq_tech
+	if {$seq_tech != $default_seq_tech} {
+	    # Warning: changing this invalidates cached consensus. We should
+	    # warn the user and clear it.
+	    set yn [tk_messageBox -type yesno -title "Clear cached consensus" -message "Changing the default sequencing technology may invalidate any precomputed consensus.  Hence the consensus cache will need to be purged, which may take a few minutes.  Do you wish to make this configuration change?"]
+
+	    if {$yn == "yes"} {
+		set default_seq_tech $seq_tech
+		invalidate_consensus_cache $io
+		set_database_param $io default_seq_tech $default_seq_tech
+	    }
+	}
+    }
 
     keylset gap5_defs CONSENSUS_MODE   $consensus_mode
     keylset gap5_defs CONSENSUS_CUTOFF $consensus_cutoff
@@ -107,6 +136,62 @@ proc ConfigureCutoffs2 {perm t consensus quality chem mode iub} {
     destroy $t
 }
 
+# Stores variable 'var'/'val' in the global database CNFG annotation.
+proc set_database_param {io var val} {
+    set db [$io get_database]
+    if {[set arec [$db get_config_anno]] == 0} {
+	set arec [$io new_anno_ele 16 0 0 0]
+	if {$arec == 0} {
+	    return -1
+	}
+
+	set ae [$io get_anno_ele $arec]
+	$ae set_type CNFG
+
+	$db set_config_anno $arec
+    } else {
+	set ae [$io get_anno_ele $arec]
+    }
+
+    set comment [$ae get_comment]
+    array set vars ""
+
+    foreach line [split $comment "\n"] {
+	if {$line == "\n"} continue
+	if {[regexp {set ([^ ]*) (.*)} $line _ a b] != 1} continue
+
+	set vars($a) $b
+    }
+    set vars($var) $val
+
+    set comment ""
+    foreach key [array names vars] {
+	append comment "set $key $vars($key)\n"
+    }
+    
+    $ae set_comment $comment
+
+    $io flush
+
+    return 0
+}
+
+# Invalidates the consensus cache for all contigs
+proc invalidate_consensus_cache {io} {
+    set db [$io get_database]
+    set nc [$db get_num_contigs]
+
+    vfuncheader "Purging consensus cache"
+    for {set i 0} {$i < $nc} {incr i} {
+	set crec [$io contig_order $i]
+	set c [$io get_contig $crec]
+	vmessage "Purging consensus for contig [expr {$i+1}] of $nc (=$crec)"
+	$c invalidate_consensus
+	$c delete
+	$io flush
+    }
+}
+
 #-----------------------------------------------------------------------------
 # Sets the 'maxseq' variable
 proc SetMaxseq {io} {
diff --git a/gap5/consen.c b/gap5/consen.c
index 91351ed..0fd672d 100644
--- a/gap5/consen.c
+++ b/gap5/consen.c
@@ -35,6 +35,7 @@
 #include <unistd.h>
 #include "io_utils.h"
 #include <io_lib/expFileIO.h>
+#include <io_lib/hash_table.h>
 #include "misc.h"
 #include "consen.h"
 #include "consensus.h"
@@ -307,138 +308,54 @@ void maskit ( char *seq, int seq_length, int job) {
 }
 
 /****************************************************************************/
-#if 0
-int mask_consensus(GapIO *io, char *consensus, int contig, int lreg, int rreg, 
+int mask_consensus(GapIO *io, char *consensus, tg_rec crec, int lreg, int rreg, 
 		   int job) {
-    GAnnotations *ap;
-    GContigs c;
-    GReadings r;
-    int gel;
     extern char **active_tag_types;
     extern int number_of_active_tags;
-
-    /* Routine to mask regions of a consensus	*/
-
-    /* *consensus		the consensus
-       *active_tag_types	the list of tag types
-       number_of_active_tags	the number of tag types in the list
-       lreg, rreg		the start and end points for the consensus
-                                note consensus[0] corresponds to lreg
-                                and  consensus[rreg-lreg] to rreg
-
-       Deal with tags on the consensus (send -contig to vtagget) and on
-       the individual reads. Mask_job = 1, mark_job = 2;
-       Masking and marking are done by changing the bases to new character sets.
-       The algorithm may mask the same bases several times if they are
-       covered by several tags that appear on the list, but it is the
-       simplest thing to do.
-       */
+    contig_iterator *ci;
+    rangec_t *r;
+    HashTable *h;
+    int i;
 
     /* Is there anything to do ? */
-
     if ( number_of_active_tags == 0 )
 	return 0;
 
-    /* init */
-
-    if (0 != contig_read(io, contig, c))
-	return -1;
-
-    if (!lreg)
-	lreg = 1;
-    if (!rreg)
-	rreg= c.length;
-    
-    /* do the tags on readings first	*/
-
-    gel = c.left;
-
-    while (gel) {
-	gel_read(io, gel, r);
-
-	if ( r.position <= rreg ) {
-	    /* init vtagget() */
-	    ap = vtagget(io, gel, number_of_active_tags, active_tag_types);
-
-
-	    while (ap && ap != (GAnnotations *)-1) {
-		int e;
-
-		/* Normalise tags if necessary */
-		if (r.sense)
-		    ap->position = r.length - ap->position - ap->length + 2;
-
-		/* 100% cutoff data - reject tag */
-		if (ap->position + ap->length - 1 <= r.start ||
-		    ap->position >= r.end)
-		    goto next;
-
-		/* overlap cutoff with used - clip appropriately */
-		if (ap->position <= r.start) {
-		    ap->length   -= r.start - ap->position + 1;
-		    ap->position += r.start - ap->position + 1;
-		}
-
-		e = r.position - r.start + ap->position - 1;
-
-		if ((e + ap->length > lreg) && ( e <= rreg ) ) {
-		    if (e < lreg) {
-			ap->length -= lreg-e;
-			e = lreg;
-		    }
-
-		    if (e <= rreg && e + ap->length - 1 > rreg) {
-			ap->length = rreg - e + 1;
-		    }
-
-		    e = e - lreg + 1;
-		    (void) maskit ( &consensus[e-1], ap->length, job);
-
-		}
-
-	    next:
-		ap = vtagget(io, 0, number_of_active_tags, active_tag_types);
-	    }
-	}
-	gel = r.right;
+    h = HashTableCreate(16, HASH_DYNAMIC_SIZE);
+    for (i = 0; i < number_of_active_tags; i++) {
+	HashData hd = {0};
+	uint32_t type = str2type(active_tag_types[i]);
+	HashTableAdd(h, (char *)&type, 4, hd, NULL);
     }
 
+    ci = contig_iter_new_by_type(io, crec, 0, CITER_FIRST | CITER_ISTART,
+                                 lreg, rreg, GRANGE_FLAG_ISANNO);
+    if (!ci)
+        return -1;
 
-    /* now do the tags on the consensus	*/
-
-
-	/* init vtagget() */
+    while ((r = contig_iter_next(io, ci))) {
+	int st, en;
 
-    gel = -contig;
+	/* FIXME: deal with consensus vs reading tags, cons only to start with? */
+	if (r->flags & GRANGE_FLAG_TAG_SEQ)
+	    continue;
 
-    ap = vtagget(io, gel, number_of_active_tags, active_tag_types);
-
-    while (ap && ap != (GAnnotations *)-1 && ap->position <= rreg) {
-	int e;
-
-	e = ap->position;
-	    
-	if (e + ap->length >= lreg) {
-	    if (e < lreg) {
-		ap->length -= lreg-e;
-		e = lreg;
-	    }
+	/* FIXME: deal with cutoff data, but only needed for seq tags. */
 
-	    if (e <= rreg && e + ap->length - 1 > rreg) {
-		ap->length = e + ap->length - 1 - rreg;
-	    }
-	    
-	    (void) maskit ( &consensus[e-1], ap->length, job);
+	/* Check type, disgustingly it's r->mqual for tags */
+	if (!HashTableSearch(h, (char *)&r->mqual, 4))
+	    continue;
 
-	}
+	st = MAX(0, r->start-lreg);
+	en = MIN(rreg-lreg, r->end-lreg);
+	maskit(&consensus[st], en-st+1, job);
+    }
 
-	ap = vtagget(io, 0, number_of_active_tags, active_tag_types);
+    contig_iter_del(ci);
+    HashTableDestroy(h, 0);
 
-    }
     return 0;
-
 }
-#endif
 
 /****************************************************************************/
 
@@ -1619,7 +1536,7 @@ int make_consensus( int task_mask, GapIO *io,
 	    contig_list[i].contig_right_extension = right_extension;
 
 	}
-#if 0
+
 	if ( task_mask & MASKING ) {
 /*	    printf("do masking\n");*/
             if ( mask_consensus(io, 
@@ -1645,7 +1562,7 @@ int make_consensus( int task_mask, GapIO *io,
 		return -2;
 	    }
 	}
-#endif
+
 	/* note the element number of the last base each contig */
 
 	contig_list[i].contig_end_offset = *consensus_length - consensus_start - 1;
diff --git a/gap5/consen.h b/gap5/consen.h
index 812c527..b878544 100644
--- a/gap5/consen.h
+++ b/gap5/consen.h
@@ -141,7 +141,7 @@ void maskc_ (char *seq, f_int *seq_len, f_int *jobin, f_implicit seq_l);
        covered by several tags that appear on the list, but it is the
        simplest thing to do.
        */
-int mask_consensus(GapIO *io, char *consensus, int contig, int lreg, int rreg, 
+int mask_consensus(GapIO *io, char *consensus, tg_rec crec, int lreg, int rreg, 
 		   int job);
 
 
diff --git a/gap5/consen.tcl b/gap5/consen.tcl
index a4e53eb..03c9152 100644
--- a/gap5/consen.tcl
+++ b/gap5/consen.tcl
@@ -65,6 +65,11 @@ proc NormalDialog { io } {
 	    -relief groove -bd 2 -orient horizontal\
 	    -default [keylget gap5_defs CONSENSUS.NORMAL.STRIP_PADS]
 
+    yes_no $f.ambig \
+	    -title "Output ambiguity codes" \
+	    -relief groove -bd 2 -orient horizontal\
+	    -default [keylget gap5_defs CONSENSUS.NORMAL.AMBIGUITY_CODES]
+
     ###########################################################################
     #Reading annotations
     radiolist $f.annos \
@@ -126,7 +131,7 @@ proc NormalDialog { io } {
     #OK and Cancel buttons
     okcancelhelp $f.ok_cancel \
 	    -ok_command "Normal_OK_Pressed $f $io $f.infile $f.id \
-	    $f.sel_mask.rl $f.pads $f.notes $f.template $f.annos \
+	    $f.sel_mask.rl $f.pads $f.ambig $f.notes $f.template $f.annos \
 	    $f.format.main $f.output" \
 	    -cancel_command "destroy $f" \
 	    -help_command "show_help gap5 {Con-Normal}" \
@@ -137,6 +142,7 @@ proc NormalDialog { io } {
     pack $f.id -fill x
     pack $f.sel_mask -fill x
     pack $f.pads -fill x
+    pack $f.ambig -fill x
     pack $f.template -fill x
     pack $f.format -fill x
     pack $f.annos -fill x
@@ -146,7 +152,7 @@ proc NormalDialog { io } {
 
 }
 
-proc Normal_OK_Pressed {f io infile id sel_mask strippads notes template annos format output} {
+proc Normal_OK_Pressed {f io infile id sel_mask strippads ambig notes template annos format output} {
     global gap5_defs
 
     set gel_anno 0; #no gel annotations with expt file
@@ -157,6 +163,15 @@ proc Normal_OK_Pressed {f io infile id sel_mask strippads notes template annos f
     #single or list or file
     if {[lorf_in_get $infile] == 4} {
 	set gel_name [contig_id_gel $id]
+	if {$gel_name == ""} {
+	    bell
+	    tk_messageBox \
+		-message "Unrecognised contig name" \
+		-icon error \
+		-type ok
+	    raise $f
+	    return
+	}
 	set lreg [contig_id_lreg $id]
 	set rreg [contig_id_rreg $id]
 	SetContigGlobals $io $gel_name $lreg $rreg
@@ -181,6 +196,7 @@ proc Normal_OK_Pressed {f io infile id sel_mask strippads notes template annos f
     set out_format [radiolist_get $format]
 
     set strip [yes_no_get $strippads]
+    set ambig [yes_no_get $ambig]
 
     #expt format chosen
     if { $out_format == 3 } {
@@ -211,6 +227,7 @@ proc Normal_OK_Pressed {f io infile id sel_mask strippads notes template annos f
 	    -outfile $out_file \
 	    -tag_types $active_tags \
 	    -strip_pads $strip \
+	    -hets $ambig \
 	    -name_format [radiolist_get $template]
     ClearBusy
     destroy $f
@@ -562,7 +579,89 @@ proc Strip_Pads {cons qual new_cons_var new_qual_var} {
     }
 }
 
+# Applies map to $str over the (start,end) tuples in $pos.
+# Assumes the positions are sorted by start coordinate.
+#
+# This has linear complexity, unlike simply modifying and returning the
+# full str every time.
+proc map_str {str map pos} {
+    set last 0
+    set new_str ""
+    foreach {start end} $pos {
+	if {$end < $last} continue
+	if {$start > $last} {
+	    append new_str [string range $str $last [expr {$start-1}]]
+	} else {
+	    set start $last
+	}
+	set sub [string range $str $start $end]
+	append new_str [string map $map $sub]
+	set last [expr {$end+1}]
+    }
+    append new_str [string range $str $last [string length $str]]
+    return $new_str
+}
+
+# Masks (defi) or marks (acgt) consensus using the tags array
+proc mask_consensus {io crec start end cons tags mask} {
+    if {$tags != "*"} {
+	foreach t $tags {
+	    if {[scan $t "%c%c%c%c" a b c d] != 4} {
+		puts stderr "Badly formatted tag type '$t'"
+		continue
+	    }
+	    set id [expr {($a<<24)+($b<<16)+($c<<8)+$d}]
+	    set filter($id) 1
+	}
+    }
+
+    set c [$io get_contig $crec]
+
+    if {$mask == "mask"} {
+	set map {A d C e G f T i N n}
+    } elseif {$mask == "mark"} {
+	set map {A a C c G g T t N n}
+    } elseif {$mask == "" || $mask == "none"} {
+	return $cons
+    } else {
+	if {[string length $mask] == 1} {
+	    set m $mask$mask$mask$mask$mask
+	} else {
+	    set m ${mask}nnnnn
+	}
+	set map [list \
+		     A [string index $m 0] \
+		     C [string index $m 1] \
+		     G [string index $m 2] \
+		     T [string index $m 3] \
+		     N [string index $m 4]]
+    }
+
+    set pos_list {}
+    foreach anno [$c anno_in_range $start $end] {	
+	set t [lindex $anno 3]
+	set t [format "%c%c%c%c" \
+		   [expr {($t>>24)&0xff}] \
+		   [expr {($t>>16)&0xff}] \
+		   [expr {($t>> 8)&0xff}] \
+		   [expr {($t>> 0)&0xff}]]
+	if {$tags != "*" && ![info exists filter([lindex $anno 3])]} continue
+
+	foreach {tag_st tag_en} $anno break
+	if {$tag_st < $start} {set tag_st $start}
+	if {$tag_en > $end}   {set tag_en $end}
+	incr tag_st [expr {-($start)}]
+	incr tag_en [expr {-($start)}]
+	lappend pos_list $tag_st $tag_en
+    }
+
+    $c delete
+
+    return [map_str $cons $map $pos_list]
+}
+
 proc get_consensus {args} {
+    set opt(-hets) "0"
     foreach {key value} $args {
 	set opt($key) $value
     }
@@ -590,11 +689,21 @@ proc get_consensus {args} {
 	    if {$end   == ""} {set end   [$c get_visible_end]}
 	    $c delete
 
-	    set cons [calc_consensus -io $io -contigs "{=$crec $start $end}"]
+	    set cons [calc_consensus -io $io \
+			  -contigs "{=$crec $start $end}" \
+			  -hets $opt(-hets)]
+	    if {[info exists opt(-mask)] && $opt(-mask) != "none" && \
+		    $opt(-mask) != "" && [info exists opt(-tag_types)] && \
+		    $opt(-tag_types) != ""} {
+		set cons [mask_consensus $io $crec $start $end \
+			      $cons $opt(-tag_types) $opt(-mask)]
+	    }
 	    switch $opt(-format) {
 		1 {
 		    # Fastq
-		    set qual [calc_quality -io $io -contigs "{=$crec $start $end}"]
+		    set qual [calc_quality -io $io \
+				  -contigs "{=$crec $start $end}" \
+				  -hets $opt(-hets)]
 		    if {$opt(-strip_pads)} {
 			Strip_Pads $cons $qual new_cons new_qual
 			set cons $new_cons; unset new_cons
diff --git a/gap5/consensus.c b/gap5/consensus.c
index c44c6bb..444aa02 100644
--- a/gap5/consensus.c
+++ b/gap5/consensus.c
@@ -10,6 +10,7 @@
 #include <tg_gio.h>
 
 #include "consensus.h"
+#include "gap_globals.h"
 
 #define CONS_BLOCK_SIZE 4096
 
@@ -103,7 +104,7 @@ int calculate_consensus_simple2(GapIO *io, tg_rec contig, int start, int end,
 		if (con)
 		    con[i-start+j] = "ACGT*N"[q[j].call];
 		if (qual)
-		    qual[i-start+j] = q[j].scores[q[j].call];
+		    qual[i-start+j] = q[j].phred;
 	    }
 	}
     }
@@ -163,6 +164,11 @@ int calculate_consensus_simple(GapIO *io, tg_rec contig, int start, int end,
 	if (bin->size >= CONS_BIN_SIZE && (bin->child[0] || bin->child[1]))
 	    continue;
 
+	// Too large implies something suspect is going on. Best just
+	// give up and fall back to computing from scratch.
+	if (bin->size >= 4*CONS_BIN_SIZE)
+	    continue;
+
 	if (j != i) r[j] = r[i];
 	j++;
     }
@@ -517,6 +523,87 @@ int calculate_consensus_simple(GapIO *io, tg_rec contig, int start, int end,
 }
 
 /*
+ * As per calculate_consensus_simple2 but producing heterozygous bases
+ * in the consensus.
+ *
+ * Note that there is no ambiguity code for base/gap so we use lowercase
+ * letters to represent that code. The quality value represents the
+ * likelihood of the heterozygous base being a real het rather than
+ * a single base type.
+ */
+int calculate_consensus_simple_het(GapIO *io, tg_rec contig,
+				   int start, int end,
+				   char *con, float *qual) {
+    
+    int i, j;
+    consensus_t q[CONS_BLOCK_SIZE];
+    contig_t *c = (contig_t *)cache_search(io, GT_Contig, contig);
+
+    if (NULL == c) return -1;
+    cache_incr(io, c);
+    
+    /* Compute in small ranges */
+    for (i = start; i <= end; i += CONS_BLOCK_SIZE) {
+	rangec_t *r = NULL;
+	int nr;
+	int st = i;
+	int en = st + CONS_BLOCK_SIZE-1; /* inclusive range */
+	if (en > end)
+	    en = end;
+
+	/* Find sequences visible */
+	r = contig_seqs_in_range(io, &c, st, en, CSIR_SORT_BY_X, &nr);
+
+	if (NULL == r ||
+	    0 != calculate_consensus_bit_het(io, contig, st, en,
+					     qual ? CONS_SCORES : 0,
+					     r, nr, q)){
+	    for (j = 0; j < en-st; j++) {
+		if (con)
+		    con[i-start+j] = 'N';
+		if (qual)
+		    qual[i-start+j] = 0;
+	    }
+	    if (NULL != r) free(r);
+	    cache_decr(io, c);
+	    return -1;
+	}
+
+	free(r);
+
+	for (j = 0; j < en-st+1; j++) {
+	    if (q[j].call == 6) {
+		if (con)
+		    con[i-start+j] = ' ';
+		if (qual)
+		    qual[i-start+j] = 0;
+	    } else {
+		if (q[j].scores[6] > 0) {
+		    static char *map = 
+			"AMRWa" // A
+			"MCSYc" // C
+			"RSGKg" // G
+			"WYKTt" // T
+			"acgt*";// *
+		    if (con)
+			con[i-start+j] = map[q[j].het_call];
+		    if (qual)
+			qual[i-start+j] = q[j].scores[6];
+		} else {
+		    if (con)
+			con[i-start+j] = "ACGT*N"[q[j].call];
+		    if (qual)
+			qual[i-start+j] = q[j].scores[q[j].call];
+		}
+	    }
+	}
+    }
+
+    cache_decr(io, c);
+    return 0;
+}
+
+/*
  * The consensus calculation function - rewritten for tgap style
  * databases.
  *
@@ -987,20 +1074,96 @@ static int calculate_consensus_bit(GapIO *io, tg_rec contig,
 
 #define P_HET 1e-6
 
+
+#if 0
+double p_overcall[] = {
+    0.001, // unknown
+    0.010, // sanger
+    0.001, // solexa/illumina
+    0.001, // solid
+    0.010, // 454
+    0.010, // helicos
+    0.010, // iontorrent
+    0.010, // pacbio
+    0.050, // ont
+};
+
+double p_undercall[] = {
+    0.001, // unknown
+    0.010, // sanger
+    0.001, // solexa/illumina
+    0.001, // solid
+    0.010, // 454
+    0.010, // helicos
+    0.010, // iontorrent
+    0.010, // pacbio
+    0.280, // ont
+};
+#endif
+
+double tech_undercall[] = {
+    1.00, // unknown
+    1.00, // sanger
+    1.00, // solexa/illumina
+    1.00, // solid
+    1.00, // 454
+    1.00, // helicos
+    1.00, // iontorrent
+    1.00, // pacbio
+    1.63, // ont
+};
+
 static double prior[25];     /* Sum to 1.0 */
 static double lprior15[15];  /* 15 combinations of {ACGT*} */
-static double acc_prior[25]; /* Cumulative values up to 32768 */
 
 /* Precomputed matrices for the consensus algorithm */
-static double pMM[101], p__[101], p_M[101];
+static double pMM[9][101], p__[9][101], p_M[9][101], po_[9][101], poM[9][101];
+static double poo[9][101], puu[9][101], pum[9][101], pmm[9][101];
 
 static double e_tab_a[1002];
 static double *e_tab = &e_tab_a[500];
 static double e_log[501];
 
+/*
+ * Lots of confusing matrix terms here, so some definitions will help.
+ *
+ * M = match base
+ * m = match pad
+ * _ = mismatch
+ * o = overcall
+ * u = undercall
+ *
+ * We need to distinguish between homozygous columns and heterozygous columns,
+ * done using a flat prior.  This is implemented by treating every observation
+ * as coming from one of two alleles, giving us a 2D matrix of possibilities
+ * (the hypotheses) for each and every call (the observation).
+ *
+ * So pMM[] is the chance that given a call 'x' that it came from the
+ * x/x allele combination.  Similarly p_o[] is the chance that call
+ * 'x' came from a mismatch (non-x) / overcall (consensus=*) combination.
+ *
+ * Examples with observation (call) C and * follows
+ *
+ *  C | A  C  G  T  *          * | A  C  G  T  * 
+ *  -----------------	       ----------------- 
+ *  A | __ _M __ __ o_	       A | uu uu uu uu um
+ *  C | _M MM _M _M oM	       C | uu uu uu uu um
+ *  G | __ _M __ __ o_	       G | uu uu uu uu um
+ *  T | __ _M __ __ o_	       T | uu uu uu uu um
+ *  * | o_ oM o_ o_ oo	       * | um um um um mm
+ *
+ * In calculation terms, the _M is half __ and half MM, similarly o_ and um.
+ *
+ * Relative weights of substitution vs overcall vs undercall are governed on a
+ * per base basis using the P_OVER and P_UNDER scores (subst is 1-P_OVER-P_UNDER).
+ *
+ * The heterozygosity weight though is a per column calculation as we're
+ * trying to model whether the column is pure or mixed. Hence this is done
+ * once via a prior and has no affect on the individual matrix cells.
+ */
+
 static void consensus_init(double p_het) {
-    int i;
-    double acc = 0;
+    int i, t;
 
     memset(lookup, 5, 256*sizeof(lookup[0]));
     lookup['A'] = lookup['a'] = 0;
@@ -1014,6 +1177,7 @@ static void consensus_init(double p_het) {
     for (i = 0; i <= 500; i++)
 	e_log[i] = log(i);
 
+    // Heterozygous locations
     for (i = 0; i < 25; i++)
 	prior[i] = p_het / 20;
     prior[0] = prior[6] = prior[12] = prior[18] = prior[24] = (1-p_het)/5;
@@ -1034,21 +1198,61 @@ static void consensus_init(double p_het) {
     lprior15[13] = log(prior[19]*2);
     lprior15[14] = log(prior[24]);
 
-    for (i = 0; i < 25; i++) {
-	acc += prior[i];
-	acc_prior[i] = acc * (0xffffff+1);
-    }
 
-    for (i = 1; i < 101; i++) {
-	double prob = 1 - pow(10, -i / 10.0);
-	 
-	pMM[i] = log(prob/5);
-	p__[i] = log((1-prob)/20);
-	p_M[i] = log(prob/10 + (1-prob)/40);
+    // Rewrite as new form
+    for (t = STECH_UNKNOWN; t <= STECH_LAST; t++) {
+	for (i = 1; i < 101; i++) {
+	    double prob = 1 - pow(10, -i / 10.0);
+	    // double norm;
+
+//	    if (t == STECH_ONT)
+//		prob = 0.85; // Fake FIXED prob for now
+
+	    // May want to multiply all these by 5 so pMM[i] becomes close
+	    // to -0 for most data. This makes the sums increment very slowly,
+	    // keeping bit precision in the accumulator.
+#if 0
+	    norm = (1-p_overcall[t])*prob + 3*((1-p_overcall[t])*(1-prob)/3)
+		+ p_overcall[t]*(1-prob);
+	    pMM[t][i] = log((1-p_overcall[t]) * prob /norm);
+	    p__[t][i] = log((1-p_overcall[t]) * (1-prob)/3 /norm);
+	    poo[t][i] = log((p_overcall[t]*(1-prob)) /norm);
+
+	    p_M[t][i] = log((exp(pMM[t][i]) + exp(p__[t][i]))/2);
+	    po_[t][i] = log((exp(p__[t][i]) + exp(poo[t][i]))/2);
+	    poM[t][i] = log((exp(pMM[t][i]) + exp(poo[t][i]))/2);
+
+	    // [t]* observation vs base
+	    norm = p_undercall[t]*(1-prob)*4 + (1-p_undercall[t])*prob;
+	    puu[t][i] = log((p_undercall[t] * (1-prob)) /norm);
+	    pmm[t][i] = log((1-p_undercall[t])*prob /norm);
+	    pum[t][i] = log((exp(puu[t][i]) + exp(pmm[t][i]))/2);
+#else
+	    pMM[t][i] = log(prob/5);
+	    p__[t][i] = log((1-prob)/20);
+	    p_M[t][i] = log((exp(pMM[t][i]) + exp(p__[t][i]))/2);
+
+	    puu[t][i] = p__[t][i];
+
+	    poM[t][i] = p_M[t][i] *= tech_undercall[t];
+	    po_[t][i] = p__[t][i] *= tech_undercall[t];
+	    poo[t][i] = p__[t][i] *= tech_undercall[t];
+	    pum[t][i] = p_M[t][i] *= tech_undercall[t];
+	    pmm[t][i] = pMM[t][i] *= tech_undercall[t];
+#endif
+	}
+
+	pMM[t][0] = pMM[t][1];
+	p__[t][0] = p__[t][1];
+	p_M[t][0] = p_M[t][1];
+
+	pmm[t][0] = pmm[t][1];
+	poo[t][0] = poo[t][1];
+	po_[t][0] = po_[t][1];
+	poM[t][0] = poM[t][1];
+	puu[t][0] = puu[t][1];
+	pum[t][0] = pum[t][1];
     }
-    pMM[0] = pMM[1];
-    p__[0] = p__[1];
-    p_M[0] = p_M[1];
 }
 
 /* 
@@ -1112,7 +1316,7 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
     double min_e_exp = DBL_MIN_EXP * log(2) + 1;
 
     double (*scores)[15] = NULL;
-    double (*sumsC)[6] = NULL, *sumsE = NULL;
+    double (*sumsC)[6] = NULL, (*sumsE)[6] = NULL;
     char *perfect = NULL; /* quality=100 bases */
     int *depth = NULL, vst, ven;
 
@@ -1146,7 +1350,7 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
     if (flags & CONS_DISCREP) {
 	if (NULL == (sumsC = (double (*)[6])calloc(len, 6 * sizeof(double))))
 	    return -1;
-	if (NULL == (sumsE = (double *)calloc(len, sizeof(double))))
+	if (NULL == (sumsE = (double (*)[6])calloc(len, 6 * sizeof(double))))
 	    return -1;
     }
 
@@ -1201,8 +1405,9 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 	for (j = left-1; j < right; j++) {
 	    char base;
 	    uint8_t base_l;
-	    int qual;
-	    double *S, MM, __, _M, qe;
+	    int qual, stech;
+	    double *S, qe;
+	    double MM, __, _M, oo, oM, o_, uu, um, mm;
 
 	    if (sp+j > end)
 		continue;
@@ -1220,19 +1425,32 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 		perfect[sp-start+j] |= (1<<base_l);
 	    
 	    /* Quality 0 should never be permitted as it breaks the math */
-	    if (qual < 1)
-		qual = 1;
+	    if (qual < 2)
+		qual = 2;
 	    if (qual > 100)
 		qual = 100;
 
 	    S = scores[sp-start+j];
-	    __ = p__[qual];
-	    MM = pMM[qual];
-	    _M = p_M[qual];
+
+	    /* MM=match  _M=half-match  __=mismatch */
+	    stech = s->seq_tech ? s->seq_tech : default_seq_tech;
+	    __ = p__[stech][qual];
+	    MM = pMM[stech][qual];
+	    _M = p_M[stech][qual];
+
+	    /* observation ACGT, but against hypothesis ** or *base */
+	    oo = poo[stech][qual];
+	    oM = poM[stech][qual];
+	    o_ = po_[stech][qual];
+
+	    /* observation * */
+	    uu = puu[stech][qual];
+	    um = pum[stech][qual];
+	    mm = pmm[stech][qual];
 
 	    if (flags & CONS_DISCREP) {
 		qe = q2p[qual];
-		sumsE[sp-start+j] += qe;
+		sumsE[sp-start+j][base_l] += qe;
 		sumsC[sp-start+j][base_l] += 1 - qe;
 	    }
 
@@ -1240,53 +1458,62 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 		cons[sp-start+j].counts[base_l]++;
 
 
+	    // FIXME:
+	    // Todo - consensus shouldn't consider every base as independent.
+	    // Like Gap4, we need to consider the best quality one on each
+	    // library/technology/strand combination and then all others
+	    // to be simply additional information, with less confidence.
+	    //
+	    // This will have the effect of making SNPs more likely perhaps?
+
+
 	    switch (base_l) {
-	    case 0:
-		S[0] += MM; S[1 ]+= _M; S[2 ]+= _M; S[3 ]+= _M; S[4 ]+= _M;
-		            S[5 ]+= __; S[6 ]+= __; S[7 ]+= __; S[8 ]+= __;
-			                S[9 ]+= __; S[10]+= __; S[11]+= __; 
-					            S[12]+= __; S[13]+= __; 
-						                S[14]+= __;
+	    case 0: //  match       subst     subst       subst     overcall
+		S[0] += MM; S[1 ]+= _M; S[2 ]+= _M; S[3 ]+= _M; S[4 ]+= oM;
+		            S[5 ]+= __; S[6 ]+= __; S[7 ]+= __; S[8 ]+= o_;
+			                S[9 ]+= __; S[10]+= __; S[11]+= o_; 
+					            S[12]+= __; S[13]+= o_; 
+						                S[14]+= oo;
 		break;
 
 	    case 1:
-		S[0] += __; S[1 ]+= _M; S[2 ]+= __; S[3 ]+= __; S[4 ]+= __;
-		            S[5 ]+= MM; S[6 ]+= _M; S[7 ]+= _M; S[8 ]+= _M;
-			                S[9 ]+= __; S[10]+= __; S[11]+= __; 
-					            S[12]+= __; S[13]+= __; 
-						                S[14]+= __;
+		S[0] += __; S[1 ]+= _M; S[2 ]+= __; S[3 ]+= __; S[4 ]+= o_;
+		            S[5 ]+= MM; S[6 ]+= _M; S[7 ]+= _M; S[8 ]+= oM;
+			                S[9 ]+= __; S[10]+= __; S[11]+= o_; 
+					            S[12]+= __; S[13]+= o_; 
+						                S[14]+= oo;
 		break;
 
 	    case 2:
-		S[0] += __; S[1 ]+= __; S[2 ]+= _M; S[3 ]+= __; S[4 ]+= __;
-		            S[5 ]+= __; S[6 ]+= _M; S[7 ]+= __; S[8 ]+= __;
-			                S[9 ]+= MM; S[10]+= _M; S[11]+= _M; 
-					            S[12]+= __; S[13]+= __; 
-						                S[14]+= __;
+		S[0] += __; S[1 ]+= __; S[2 ]+= _M; S[3 ]+= __; S[4 ]+= o_;
+		            S[5 ]+= __; S[6 ]+= _M; S[7 ]+= __; S[8 ]+= o_;
+			                S[9 ]+= MM; S[10]+= _M; S[11]+= oM; 
+					            S[12]+= __; S[13]+= o_; 
+						                S[14]+= oo;
 		break;
 
 	    case 3:
-		S[0] += __; S[1 ]+= __; S[2 ]+= __; S[3 ]+= _M; S[4 ]+= __;
-		            S[5 ]+= __; S[6 ]+= __; S[7 ]+= _M; S[8 ]+= __;
-			                S[9 ]+= __; S[10]+= _M; S[11]+= __; 
-					            S[12]+= MM; S[13]+= _M; 
-						                S[14]+= __;
+		S[0] += __; S[1 ]+= __; S[2 ]+= __; S[3 ]+= _M; S[4 ]+= o_;
+		            S[5 ]+= __; S[6 ]+= __; S[7 ]+= _M; S[8 ]+= o_;
+			                S[9 ]+= __; S[10]+= _M; S[11]+= o_; 
+					            S[12]+= MM; S[13]+= oM; 
+						                S[14]+= oo;
 		break;
 
-	    case 4:
-		S[0] += __; S[1 ]+= __; S[2 ]+= __; S[3 ]+= __; S[4 ]+= _M;
-		            S[5 ]+= __; S[6 ]+= __; S[7 ]+= __; S[8 ]+= _M;
-			                S[9 ]+= __; S[10]+= __; S[11]+= _M; 
-					            S[12]+= __; S[13]+= _M; 
-						                S[14]+= MM;
+	    case 4: // undercall  under       under      under  agree-no-base
+		S[0] += uu; S[1 ]+= uu; S[2 ]+= uu; S[3 ]+= uu; S[4 ]+= um;
+		            S[5 ]+= uu; S[6 ]+= uu; S[7 ]+= uu; S[8 ]+= um;
+			                S[9 ]+= uu; S[10]+= uu; S[11]+= um; 
+					            S[12]+= uu; S[13]+= um; 
+						                S[14]+= mm;
 		break;
 
 	    case 5: /* N => equal weight to all A,C,G,T but not a pad */
-		S[0] += MM; S[1 ]+= MM; S[2 ]+= MM; S[3 ]+= MM; S[4 ]+= _M;
-		            S[5 ]+= MM; S[6 ]+= MM; S[7 ]+= MM; S[8 ]+= _M;
-			                S[9 ]+= MM; S[10]+= MM; S[11]+= _M; 
-					            S[12]+= MM; S[13]+= _M; 
-						                S[14]+= __;
+		S[0] += MM; S[1 ]+= MM; S[2 ]+= MM; S[3 ]+= MM; S[4 ]+= oM;
+		            S[5 ]+= MM; S[6 ]+= MM; S[7 ]+= MM; S[8 ]+= oM;
+			                S[9 ]+= MM; S[10]+= MM; S[11]+= oM; 
+					            S[12]+= MM; S[13]+= oM; 
+						                S[14]+= oo;
 		break;
 	    }
 
@@ -1387,6 +1614,7 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 	shift = -DBL_MAX;
 	max = -DBL_MAX;
 	max_het = -DBL_MAX;
+
 	for (j = 0; j < 15; j++) {
 	    S[j] += lprior15[j];
 	    if (shift < S[j]) {
@@ -1429,6 +1657,10 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 	    norm[j] = 0;
 	}
 
+        /*
+	 * This leaves norm[j] as an array of SUM(norm[]) over all values
+	 * except j'th.
+	 */
 	tot1 = tot2 = 0;
 	for (j = 0; j < 15; j++) {
 	    norm[j]    += tot1;
@@ -1445,7 +1677,6 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 //	      fabs(norm[0] - norm[14]) < FLT_EPSILON)) {
 
 	if (depth[i] && depth[i] != cons[i].counts[5] /* all N */) {
-	    double m;
 
 	    cons[i].depth = depth[i];
 
@@ -1491,9 +1722,17 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
 
 	    /* Compute discrepancy score */
 	    if (flags & CONS_DISCREP) {
-		m = sumsC[i][0]+sumsC[i][1]+sumsC[i][2]+sumsC[i][3]+sumsC[i][4]
-		    - sumsC[i][cons[i].call];
-		cons[i].discrep = (m-sumsE[i])/sqrt(m+sumsE[i]);
+		double max = 0, m;
+		int b;
+		for (b = 0; b < 5; b++) {
+		    if (b == cons[i].call)
+			continue;
+		    m = (sumsC[i][b]+.1)/(sumsE[i][b]+.1)-1;
+		    //m = (sumsC[i][b]+xx)/(sumsE[i][b]+xx)-1;
+		    if (max < m)
+			max = m;
+		}
+		cons[i].discrep = max/10;
 	    }
 	} else {
 	    if (i < vst || i > ven)
@@ -1534,7 +1773,6 @@ int calculate_consensus_bit_het(GapIO *io, tg_rec contig,
  */
 int calculate_consensus_pileup(int flags, pileup_base_t *p, consensus_t *cons){
     int i, j;
-    static int loop = 0;
     static int init_done =0;
     static double q2p[101];
     double min_e_exp = DBL_MIN_EXP * log(2) + 1;
@@ -1542,7 +1780,7 @@ int calculate_consensus_pileup(int flags, pileup_base_t *p, consensus_t *cons){
     double S[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     double sumsC[6] = {0,0,0,0,0,0}, sumsE = 0;
     char perfect = 0; /* quality=100 bases */
-    int depth = 0, vst, ven;
+    int depth = 0;
 
     /* Map the 15 possible combinations to 1-base or 2-base encodings */
     static int map_sing[15] = {0, 5, 5, 5, 5,
@@ -1583,7 +1821,7 @@ int calculate_consensus_pileup(int flags, pileup_base_t *p, consensus_t *cons){
 	seq_t *s = p->s;
 	char base;
 	uint8_t base_l;
-	int qual;
+	int qual, stech;
 	double MM, __, _M, qe;
 
 	if (p->base_index < s->left-1)
@@ -1610,9 +1848,10 @@ int calculate_consensus_pileup(int flags, pileup_base_t *p, consensus_t *cons){
 	if (qual > 100)
 	    qual = 100;
 
-	__ = p__[qual];
-	MM = pMM[qual];
-	_M = p_M[qual];
+	stech = s->seq_tech ? s->seq_tech : default_seq_tech;
+	__ = p__[stech][qual];
+	MM = pMM[stech][qual];
+	_M = p_M[stech][qual];
 
 	if (flags & CONS_DISCREP) {
 	    qe = q2p[qual];
@@ -2486,7 +2725,6 @@ int consensus_pileup(GapIO *io, tg_rec contig, int start, int end,
 
     pos = start;
     while ((r = contig_iter_next(io, ci))) {
-	int i, j;
 
 	if (pos == CITER_CSTART)
 	    pos = r->start;
@@ -2549,7 +2787,6 @@ int consensus_pileup(GapIO *io, tg_rec contig, int start, int end,
 
     /* Terminating case, draining queue only */
     for (; head; pos++) {
-	int i, j;
 
 	if (cons_flags)
 	    calculate_consensus_pileup(cons_flags, head, &cons);
diff --git a/gap5/consensus.h b/gap5/consensus.h
index 5a348c0..41ca3c2 100644
--- a/gap5/consensus.h
+++ b/gap5/consensus.h
@@ -53,6 +53,20 @@ typedef struct {
 int calculate_consensus_simple(GapIO *io, tg_rec contig, int start, int end,
 			       char *con, float *qual);
 
+
+/*
+ * As per calculate_consensus_simple but producing heterozygous bases
+ * in the consensus.
+ *
+ * Note that there is no ambiguity code for base/gap so we use lowercase
+ * letters to represent that code. The quality value represents the
+ * likelihood of the heterozygous base being a real het rather than
+ * a single base type.
+ */
+int calculate_consensus_simple_het(GapIO *io, tg_rec contig,
+				   int start, int end,
+				   char *con, float *qual);
+
 /*
  * The consensus calculation function - rewritten for tgap style
  * databases.
diff --git a/gap5/contig_editor.tcl b/gap5/contig_editor.tcl
index faa1847..8669216 100644
--- a/gap5/contig_editor.tcl
+++ b/gap5/contig_editor.tcl
@@ -163,51 +163,11 @@ proc io_undo_exec {w crec cmdu} {
 
 	    C_INS {
 		set contig [$io get_contig $op1]
-		$contig insert_base $op2
+		# puts stderr "1. $contig insert_column $op2"
+		$contig insert_column $op2 $op3
 		foreach seq $op3 {
 		    foreach {rec pos base val cut start} $seq break;
 		    set seq [$io get_sequence $rec]
-
-		    # Find right clip point in contig orientation
-		    foreach {l r} [$seq get_clips] break;
-		    if {[$seq get_orient]} {
-			set r [expr { abs([$seq get_length]) - $l + 1 }]
-		    }
-		    # puts "pos = $pos; r = $r"
-		    if {$pos >= $r} {
-			# Add to end as "$contig insert_base" hasn't
-			$seq insert_base $pos $base $val
-
-			# Whether or not the insert also moved depends on
-			# orientation, so we may also need to fix this
-			set s_pos [$seq get_position]
-			if {$s_pos != $start} {
-			    # puts stderr "rec = $rec; s_pos = $s_pos; start = $start"
-			    $contig move_seq $rec [expr {$start-$s_pos}]
-			}
-		    } else {
-			set s_pos [$seq get_position]
-			# puts stderr "rec = $rec; start = $start; s_pos = $s_pos"
-			if {$start != $s_pos} {
-			    # $contig insert_base moved the sequence instead
-			    # of inserting to it, probably because we're
-			    # adding to the first base. Manually insert instead
-			    $seq insert_base $pos $base $val
-
-			    # Whether or not the insert also moved depends on
-			    # orientation, so we may also need to fix this
-			    set s_pos [$seq get_position]
-			    if {$s_pos != $start} {
-				$contig move_seq $rec [expr {$start-$s_pos}]
-			    }
-			} else {
-			    # Otherwise it did insert a *, but it may not have
-			    # been the original base we removed and the quality
-			    # is almost certainly wrong. Replace it with the
-			    # correct value.
-			    $seq replace_base $pos $base $val
-			}
-		    }
 			
 		    foreach {b q c} [$seq get_base $pos] break
 		    if {$c != $cut} {
@@ -226,7 +186,7 @@ proc io_undo_exec {w crec cmdu} {
 			    incr r -1
 			}
 
-			# puts stderr "rec = $rec c = $c cut = $cut l = $l r = $r"
+			# puts stderr "7. rec = $rec c = $c cut = $cut l = $l r = $r"
 			$seq set_clips $l $r
 		    }
 		    $seq delete
@@ -372,6 +332,18 @@ proc io_undo_exec {w crec cmdu} {
 		$c delete
 	    }
 
+	    RP_SET {
+		set c [$io get_contig $op1]
+		eval $c set_refpos $op2 $op3
+		$c delete
+	    }
+
+	    RP_DEL {
+		set c [$io get_contig $op1]
+		$c delete_refpos $op2
+		$c delete
+	    }
+
 	    default {
 		puts stderr "Unknown undo command: $cmd"
 	    }
@@ -459,9 +431,7 @@ proc contig_register_callback {ed type id args} {
     global $ed
     set w [set ${ed}(top)]
     global $w
-
-    #puts [info level [info level]]
-
+    
     switch $type {
 	QUERY_NAME {
 	    return "Contig Editor"
@@ -635,6 +605,7 @@ proc contig_register_callback {ed type id args} {
 	}
 
 	HIGHLIGHT_READ {
+	    set ${w}(OutputList) [regsub { \([0-9]+\)$} [set ${w}(OutputList)] ""]
 	    set ${w}(ListSize) [ListSize [set ${w}(OutputList)]]
 	    $ed redraw
 	}
@@ -826,7 +797,14 @@ proc contig_editor {w args} {
     }
     if {![info exists opt(-pos)]} {
 	if {$opt(-reading) != 0 && $opt(-reading) != $opt(-contig)} {
-	    set s [$opt(-io) get_sequence $opt(-reading)]
+	    set s [$opt(io) get_sequence $opt(-reading)]
+	    if { ! [$s get_mapped] } {
+	    	$s delete
+		bell
+		verror ERR_WARN "contig_editor" "Reading #$opt(-reading) is not mapped"
+		io_detach $opt(-contig)
+	    	return
+	    }
 	    foreach {cl cr} [$s get_clips] break;
 	    if {[$s get_orient]} {
 		set cl [expr {abs([$s get_length])-$cr}]
@@ -844,7 +822,7 @@ proc contig_editor {w args} {
 	    if {[regexp {^\#([0-9]+)$} $opt(-reading2) _dummy rec]} {
 		set opt(-reading2) $rec
 	    } else {
-		set opt(-reading2) [$opt(io) seq_name2rec $opt(-reading2)]
+		set opt(-reading2) [$opt(io2) seq_name2rec $opt(-reading2)]
 		if {$opt(-reading2) == -1} { set opt(-reading2) 0 }
 	    }
 	} else {
@@ -852,7 +830,15 @@ proc contig_editor {w args} {
 	}
 	if {![info exists opt(-pos2)]}     {
 	    if {$opt(-reading2) != 0 && $opt(-reading2) != $opt(-contig2)} {
-		set s [$opt(-io) get_sequence $opt(-reading2)]
+		set s [$opt(io2) get_sequence $opt(-reading2)]
+		if { ! [$s get_mapped] } {
+		    $s delete
+		    bell
+		    verror ERR_WARN "contig_editor" "Reading #$opt(-reading2) is not mapped"
+		    io_detach $opt(-contig)
+		    io_detach $opt(-contig2)
+		    return
+		}
 		foreach {cl cr} [$s get_clips] break;
 		if {[$s get_orient]} {
 		    set cl [expr {abs([$s get_length])-$cr}]
@@ -916,7 +902,7 @@ proc contig_editor {w args} {
 	-command editor_olist_switch \
  	-postcommand "editor_olist_populate $tool.list_xc" \
 	-default readings \
-	-width 15
+	-width 20
     bind $tool.list_xc <Any-Leave> {
 	editor_olist_switch %W [%W get]
 	focus [winfo toplevel %W]
@@ -1190,7 +1176,7 @@ proc editor_join {w} {
 
 # Returns true if we really want to exit
 #         false if we cannot exit (user hit cancel, or failed to save).
-proc editor_exit {w {get_lock 0}} {
+proc editor_exit {w {get_lock 0} {force 0}} {
     global $w
 
     log_str editor_exit $w $get_lock
@@ -1199,7 +1185,7 @@ proc editor_exit {w {get_lock 0}} {
 
     set ret ""
     foreach ed [set ${w}(all_editors)] {
-	if {![[set ${w}(io)] read_only] && [$ed edits_made]} {
+	if {!$force && ![[set ${w}(io)] read_only] && [$ed edits_made]} {
 	    if {$ret == ""} {
 		# Ask once only and apply to both in join editor
 		raise $w
@@ -1873,6 +1859,64 @@ proc editor_sort_by_sequence {w} {
     }
 }
 
+proc editor_show_haplotypes {w} {
+    set w2 [selection own]
+    upvar #0 $w opt
+    
+    if {$w2 == ""} {
+    	set w2 $w
+    } else {
+    	if {[winfo class $w2] != "Editor"} {
+	    bell
+	    return
+	}
+    }
+    
+    foreach {otype orec start end} [$w2 select get] break
+   
+    if {$start == $end || $otype != 17} {
+    	return
+    }
+
+    # Find haplotypes
+    upvar \#0 contigIO_$orec cio
+    set hap [find_haplotypes -io $cio(io) -contigs "{=$orec $start $end}"]
+
+    # Clear old lists
+    global NGLists
+    set l $NGLists
+    foreach n $l {
+	if {[string match haplotype_* $n]} {
+	    if {[ListExists2 $n]} {
+		ListDelete $n
+	    }
+	}
+    }
+    set NGLists $n
+    
+    # Create new lists
+    set count 1
+    set meta_list ""
+    foreach hlist $hap {
+	ListCreate2 haplotype_$count [regsub -all {^| } $hlist &#] SEQID
+	lappend meta_list haplotype_$count
+	incr count
+    }
+
+    # Access with "{haplotypes}"
+    ListCreate2 haplotypes $meta_list LIST_OF_LISTS
+
+    InitListTrace haplotypes
+    UpdateReadingDisplays haplotypes
+    $w configure -haplotype_list haplotypes
+
+    # Force redraw
+    global $opt(top)
+    set ed [set $opt(top)(curr_editor)]
+    eval $ed set_cursor [$ed get_cursor relative] 1
+    $ed redraw
+}
+
 #-----------------------------------------------------------------------------
 # Output list handling
 proc editor_olist_populate {w} {
@@ -1882,7 +1926,7 @@ proc editor_olist_populate {w} {
     set valid_lists ""
     foreach l $NGLists {
 	if {[lsearch -exact $NGSpecial $l] == -1 || $l == "readings"} {
-	    lappend valid_lists $l
+	    lappend valid_lists "$l ([ListSize $l])"
 	}
     }
     $w configure -values $valid_lists
@@ -1892,18 +1936,20 @@ proc editor_olist_switch {w l} {
     set w [winfo toplevel $w]
     upvar #0 $w opt
 
+    set l [regsub { \([0-9]+\)$} $l ""]
     global NGList
     if {![ListExists2 $l]} {
 	ListCreate2 $l {} SEQID
     }
     InitListTrace $l
+    UpdateReadingDisplays $l
     set opt(OutputList) $l
     set opt(ListSize) [ListSize $opt(OutputList)]
 
     foreach ed $opt(all_editors) {
 	$ed configure -output_list $l 
 	$ed redraw
-   }
+    }
 }
 
 #-----------------------------------------------------------------------------
@@ -1934,7 +1980,7 @@ proc editor_undo_info {top {clear 0}} {
 
     upvar \#0 contigIO_$crec cio
 
-    if {$clear || ![info exists cio(Undo)] || $cio(Undo) == ""} {
+    if {$clear || ![info exists cio(Undo)] || [llength [set cio(Undo)]] == 0} {
 	set opt(Status) ""
 	return
     }
@@ -2057,6 +2103,14 @@ proc editor_undo_info {top {clear 0}} {
 	    S_ADD {
 		lappend msg "Add read #$op2"
 	    }
+
+	    RP_SET {
+		lappend msg "Set reference position marker at $op2"
+	    }
+
+	    RP_DEL {
+		lappend msg "Delete reference position marker at $op2"
+	    }
 	    
 	    default {
 		lappend msg "Unknown undo command: $cmd"
@@ -2608,6 +2662,16 @@ proc editor_delete_cons_base { w io type rec pos powerup } {
 	}
     }
 
+    # Look for refpos markers
+    for { set i [expr $pos - 1] } { $i <= $pos + 1 } { incr i } {
+	set rp [$contig find_refpos $i]
+	if { [llength $rp] > 0 } {
+	    lprepend undo [list RP_SET $rec $i $rp]
+	} else {
+	    lprepend undo [list RP_DEL $rec $i]
+	}
+    }
+
     # Now we can remove the sequences
     foreach { srec cpos } [array get to_del] {
 	# puts stderr "Removing sequence $srec"
@@ -3258,6 +3322,64 @@ proc editor_align_cutoff {ed} {
 	set start $tmp
     }
 
+    set band_size  [keylget gap5_defs SHUFFLE_PADS.EDITOR_BAND_SIZE]
+    set max_pass   [keylget gap5_defs SHUFFLE_PADS.EDITOR_MAX_PASS]
+    set soft_clips [keylget gap5_defs SHUFFLE_PADS.EDITOR_SOFT_CLIPS]
+
+    global editor_right_click
+    if {!$editor_right_click} {
+	set t $ed.realign_seq
+	if {[xtoplevel $t] == ""} return
+	wm title $t "Realign Selection"
+
+	# Positional parameters
+	xentry $t.start \
+	    -label "From consensus base" \
+	    -default $start \
+	    -type int
+
+	xentry $t.end \
+	    -label "To consensus base" \
+	    -default $end \
+	    -type int
+
+	xentry $t.band_size \
+	    -label "Band size" \
+	    -default $band_size
+
+	xentry $t.max_pass \
+	    -label "Maximum number of passes" \
+	    -default $max_pass
+
+	xyn $t.soft_clips \
+	    -label "Use cutoff data" \
+	    -orient horizontal \
+	    -default $soft_clips
+
+	okcancelhelp $t.ok \
+	    -bd 2 -relief groove \
+	    -ok_command "set $t.pressed 1" \
+	    -cancel_command "set $t.pressed 0;destroy $t" \
+	    -help_command "show_help gap5 {Editor-Realign-Selection}"
+	
+	pack $t.start $t.end $t.band_size $t.max_pass $t.soft_clips $t.ok \
+	    -side top -fill both
+
+	global $t.pressed
+	vwait $t.pressed
+
+	if {[set $t.pressed] == 0} {
+	    return
+	}
+	
+	set start [$t.start get]
+	set end [$t.end get]
+	set band_size [$t.band_size get]
+	set soft_clips [$t.soft_clips get]
+	set max_pass [$t.max_pass get]
+	destroy $t
+    }
+    
     # Fetch start/end relative to sequence start
     if {$type != 18} {
 	# In consensus => shuffle pads / multiple realignment of seqs.
@@ -3275,7 +3397,9 @@ proc editor_align_cutoff {ed} {
 	    -io $io \
 	    -contigs "{=[$ed contig_rec] $start $end}" \
 	    -flush 0 \
-	    -band [keylget gap5_defs SHUFFLE_PADS.EDITOR_BAND_SIZE]
+	    -band $band_size \
+	    -soft_clips $soft_clips \
+	    -max_pass $max_pass
 	$ed clear_visibility_cache
 	$ed redraw
 
@@ -4700,7 +4824,7 @@ bind EdNames <<menu>> {
 		    -label "Goto [$s get_name] (Contig '$cname' @ $pos, size ~ $dist)" \
 		    -command "create_or_move_editor $base_io $sc $orec 0"
 
-		set ts [$io get_seq $rec]
+		set ts [[$ed io] get_seq $rec]
 
 		if {[$ts get_template_orient] != [$s get_template_orient]} {
 		    lappend to_join \
@@ -4746,6 +4870,33 @@ bind EdNames <<menu>> {
 	}
     }
 
+    set lsep 0
+    set w [set ${ed}(top)]
+    global $w
+    set olist [set ${w}(OutputList)]
+    global NGList_read_hash_$olist
+    if {[info exists NGList_read_hash_${olist}(#$rec)]} {
+	if {!$lsep} {
+	    %W.m add separator
+	    set lsep 1
+	}
+	%W.m add command \
+	    -label "View list $olist" \
+	    -command "ListEditMulti [list $olist]"
+    }
+
+    global NGList_read_hash_haplotypes
+    if {[info exists NGList_read_hash_haplotypes(#$rec)]} {
+	set hnum $NGList_read_hash_haplotypes(#$rec)
+	if {!$lsep} {
+	    %W.m add separator
+	    set lsep 1
+	}
+	%W.m add command \
+	    -label "View list haplotype_$hnum" \
+	    -command "ListEditMulti haplotype_$hnum"
+    }
+
     tk_popup %W.m [expr %X-20] [expr %Y-10]
 
     # $ed set_cursor 18 $other_end 1
@@ -4912,10 +5063,16 @@ proc run_cons_command {e args} {
                   -contigs [list [list =[$ed contig_rec] $start $end]]]
     set fn [tmpnam]
     set fd [open $fn w]
-    puts $fd [string map {* {}} $cons]
+    if {[string match "*%S*" $args]} {
+	puts $fd $cons
+    } else {
+	puts $fd [string map {* {}} $cons]
+    }
     close $fd
 
     set cmd [regsub -all {%s} $args $fn]
+    set cmd [regsub -all {%S} $cmd $fn]
+    set cmd [regsub -all {%x} $cmd $start]
     vfuncheader $cmd
     set fd [open "|$cmd" r]
     fconfigure $fd -blocking 0
@@ -5146,6 +5303,22 @@ bind Editor <<menu>> {
     editor_menu %W %x %y
 }
 
+bind Editor <<ctrl-menu>> {
+    set _sel [%W get_number @%x @%y 0 1]
+    if {$_sel == ""} {
+	unset _sel
+	return
+    } else {
+	eval %W set_cursor $_sel
+    }
+    unset _sel
+
+    global editor_right_click
+    set editor_right_click 0
+    tag_repopulate_menu %W
+    editor_menu %W %x %y
+}
+
 bind Editor <<menu-release>> {
     puts menu_release
     global editor_right_click
diff --git a/gap5/contig_extend.c b/gap5/contig_extend.c
index 3861fcc..59459da 100644
--- a/gap5/contig_extend.c
+++ b/gap5/contig_extend.c
@@ -42,6 +42,7 @@
 #include "consensus.h"
 #include "text_output.h"
 #include "gap4_compat.h"  /* complement_contig */
+#include "break_contig.h" /* contig_visible_{start,end} */
 
 #define CSZ 1024 /* consensus size - how far back in contig we'll look */
 #define ESZ 1024 /* extension size - how far we can extend */
@@ -98,7 +99,7 @@ static int contig_extend_single(GapIO *io, tg_rec crec, int dir, int min_depth,
     for (i = 0; i < nr; i++) {
 	seq_t *s = cache_search(io, GT_Seq, r[i].rec);
 	seq_t *sorig = s;
-	int cstart, cend;
+	int cend;
 	int j, k, slen;
 
 	if ((s->len < 0) ^ r[i].comp) {
@@ -106,7 +107,6 @@ static int contig_extend_single(GapIO *io, tg_rec crec, int dir, int min_depth,
 	    complement_seq_t(s);
 	}
 
-	cstart = r[i].start + s->left-1;
 	cend   = r[i].start + s->right-1;
 
 	/* Does cutoff extend to contig end, if so does it match cons? */
diff --git a/gap5/contig_id.tcl b/gap5/contig_id.tcl
index 0cbd4f4..bed3bfd 100644
--- a/gap5/contig_id.tcl
+++ b/gap5/contig_id.tcl
@@ -307,10 +307,14 @@ proc contig_id_callback {io entry path {_ {}}} {
     if {![info exists $entry.Last]} {
 	set $entry.Last ""
     }
+
     if {[string compare [set $entry.Last] [$entry get]] != 0} {
 	set $entry.Last [$entry get]
-	UpdateContigLimits $io $path.lreg.scale $path.rreg.scale $entry
+	if {[UpdateContigLimits $io $path.lreg.scale $path.rreg.scale $entry] != 0} {
+	    return 0
+	}
     }
+    return 1
 }
 
 # Only called when "-range 0" is used.
diff --git a/gap5/cs-object.h b/gap5/cs-object.h
index 151e875..6e5470a 100644
--- a/gap5/cs-object.h
+++ b/gap5/cs-object.h
@@ -189,6 +189,8 @@ typedef struct mobj_fij_t {
 		     reg_data *jdata);
     float max_mismatch;
     int min_length;
+    int min_overlap;
+    int max_overlap;
 } mobj_fij;
 
 typedef struct mobj_checkass_t {
diff --git a/gap5/depth.tcl b/gap5/depth.tcl
index 8493914..2d0a7f5 100644
--- a/gap5/depth.tcl
+++ b/gap5/depth.tcl
@@ -49,6 +49,7 @@ proc 1.5Dplot {w io wid hei {cnum {}} {pos {}}} {
     set ${w}(last_x1) -9999999
     set ${w}(last_x2) -9999999
     set ${w}(ntracks) 0
+    set ${w}(Track_Visibility) {}
     set ${w}(FilterAutoUpdate) [keylget gap5_defs TEMPLATE.AUTO_UPDATE]
 
     # something to store the common x range information
@@ -67,8 +68,8 @@ proc 1.5Dplot {w io wid hei {cnum {}} {pos {}}} {
     }
     
     # starting tracks
-    set ${w}(template) 1
-    set ${w}(depth) 1
+    set ${w}(Show_Template) 1
+    set ${w}(Show_Depth) 1
 
     wm title $w "Contig [$c get_name]"
     
@@ -131,6 +132,13 @@ proc 1.5Dplot {w io wid hei {cnum {}} {pos {}}} {
 
     $c delete
 
+    # Key bindings
+    for {set i 1} {$i <= 10} {incr i} {
+	bind $w <Shift-Key-F$i> "1.5plot_store_settings %W $i"
+	catch {bind $w <XF86_Switch_VT_$i> "1.5plot_store_settings %W $i"}
+	bind $w <Key-F$i> "1.5plot_restore_settings %W $i"
+    }
+
     # Contig registration
     set ${w}(reg) [contig_register \
 		       -io $io \
@@ -170,6 +178,25 @@ proc 1.5plot_contig_event {w type id cdata args} {
 	    }
 	    set cid $arg(id)
 
+	    global gap5_defs
+	    set margin1 [expr {[keylget gap5_defs TEMPLATE.SCROLL_MARGIN1]/100.0}]
+	    set margin2 [expr {[keylget gap5_defs TEMPLATE.SCROLL_MARGIN2]/100.0}]
+
+	    # Ensure it's visible. Not important if we invoked it.
+	    set x [expr {int([x2c $w $arg(abspos)])}]
+	    incr x -2
+	    if {![info exists ${w}(invoking_editor)] && \
+		    ($x < $margin1*[set ${w}(pwidth)] || \
+		     $x >= (1-$margin1)*[set ${w}(pwidth)])} {
+		set bw [expr {[set ${w}(x2)]-[set ${w}(x1)]+1}]
+		if {$x < $margin1*[set ${w}(pwidth)]} {
+		    set m [expr {$arg(abspos) - int($margin2*$bw)}]
+		} else {
+		    set m [expr {$arg(abspos) - int((1-$margin2)*$bw)}]
+		}
+		scrollx1.5 $w set_xpos $m
+	    }
+
 	    foreach id [set ${w}(tracks)] {
 		set t $w.track$id
 		global $t $t.Cursors $t.Id2Cid
@@ -199,6 +226,10 @@ proc 1.5plot_contig_event {w type id cdata args} {
 		set x [expr {int([x2c $w $arg(abspos)])}]
 		incr x -2
 
+		if {[info exists ${w}(cursor_drag)]} {
+		    set ${w}(cursor_drag) $cid
+		}
+
 		global $t.cursorx$cid
 		set $t.cursorx$cid $x
 		place $t.cursor$cid -x $x
@@ -336,6 +367,84 @@ proc 1.5cursor_release {t id} {
     catch {unset $t.cursor_selected_$id}
 }
 
+
+# Key bindings to save & restore user settings
+# Lowercase elements are considered internal changable things (x, y, width,
+# io, etc). Uppercase are considered to be settings to save (FilterPair,
+# ReadsOnly, PlotDepth, etc).
+proc 1.5plot_store_settings {w n} {
+    set N .read_depth.$n
+    global $w $N
+    array set $N [array get $w {[_A-Z]*}]
+
+    # Repeat for tracks
+    foreach tnum [set ${w}(tracks)] {
+	set t $w.track$tnum
+	set N .read_depth.track$tnum.$n
+	global $t $N
+
+	array set $N [array get $t {[_A-Z]*}]
+    }
+}
+
+proc 1.5plot_restore_settings {w n} {
+    set N .read_depth.$n
+    global $w $N
+
+    set old_tracks [set ${w}(Track_Visibility)]
+
+    # Copy params
+    array set $w [array get $N]
+    set ${w}(ForceRedraw) 1
+    set new_tracks [set ${w}(Track_Visibility)]
+
+    # Update tracks
+    set i 0
+    foreach tnum [set ${w}(tracks)] {
+	set t $w.track$tnum
+	set N .read_depth.track$tnum.$n
+	global $t $N
+	array set $t [array get $N]
+
+	if {[lindex $old_tracks $i] != [lindex $new_tracks $i]} {
+	    if {[lindex $new_tracks $i]} {
+		show_plot $w [set ${t}(func)] 0
+	    } else {
+		remove_plot $w [set ${t}(func)] 0
+	    }
+	}
+
+	incr i
+    }
+
+    update idletasks
+    redraw_plot $w
+}
+
+# Save current settings to gap5rc
+proc 1.5plot_save_config {w} {
+    global $w gap5_defs env
+    1.5plot_store_settings $w 0
+
+    set keys {}
+
+    for {set n 0} {$n <= 10} {incr n} {
+	global .read_depth.$n
+	keylset gap5_defs TEMPLATE_DISPLAY.SETTINGS_$n.BASE \
+	    [array get .read_depth.$n]
+	foreach tnum [set ${w}(tracks)] {
+	    set t $w.track$tnum
+	    global .read_depth.$n
+	    keylset gap5_defs TEMPLATE_DISPLAY.SETTINGS_$n.TRACK$tnum \
+		[array get .read_depth.$n]
+	}
+	lappend keys TEMPLATE_DISPLAY.SETTINGS_$n
+    }
+
+    eval update_defs gap5_defs [list $env(HOME)/.gap5rc] $keys
+}
+
+
 # Resize events
 proc resize1.5 {w} {
     global $w
@@ -510,6 +619,7 @@ proc add_plot {w func height has_scroll has_scale visible args} {
     incr ${w}(ntracks)
     set tnum [set ${w}(ntracks)]
     lappend ${w}(tracks) $tnum
+    lappend ${w}(Track_Visibility) $visible
     set t $w.track$tnum
     global $t
 
@@ -553,6 +663,8 @@ proc add_plot {w func height has_scroll has_scale visible args} {
     if {$visible} {
 	grid rowconfigure $w $tnum -weight $weight
     }
+
+    return $t
 }
 
 #
@@ -994,9 +1106,9 @@ proc show_track {w track_type height show} {
     }
 }
 
-proc show_plot {w track_type} {
+proc show_plot {w track_type {replot 1}} {
     global $w
-    
+
     foreach id [set ${w}(tracks)] {
     	set t $w.track$id
 	global $t
@@ -1015,13 +1127,20 @@ proc show_plot {w track_type} {
 	    }
 	    
 	    grid rowconfigure $w $id -weight 1
+
+	    set i [lsearch [set ${w}(tracks)] $id]
+	    set ${w}(Track_Visibility) [lreplace [set ${w}(Track_Visibility)] $i $i 1]
+	    if {!$replot} {
+		catch {[set ${t}(func)]_config $w $t}
+	    }
 	}
     }
     
-    redraw_plot $w
+
+    if {$replot} {redraw_plot $w}
 }
 
-proc remove_plot {w track_type} {
+proc remove_plot {w track_type {replot 1}} {
     global $w
     
     foreach id [set ${w}(tracks)] {
@@ -1046,11 +1165,16 @@ proc remove_plot {w track_type} {
 	    }
 	    
 	    grid rowconfigure $w $id -weight 0
+
+	    set i [lsearch [set ${w}(tracks)] $id]
+	    set ${w}(Track_Visibility) [lreplace [set ${w}(Track_Visibility)] $i $i 0]
 	}
     }
-    
-    update idletasks
-    redraw_plot $w
+
+    if {$replot} {
+	update idletasks
+	redraw_plot $w
+    }
 }
 
 
@@ -1326,13 +1450,15 @@ proc template_item_init {w t} {
     bind $d <B2-ButtonRelease> "puts \$firstx-%x,\[c2x $w \$firstx\]-\[c2x $w %x\]"
     bind $d <3> "$d delete withttag tline"
 
-    bind $d <B1-Motion> "drag_x $w $t %x %y"
-    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y"
+    bind $d <B1-Motion> "drag_x $w $t %x %y %X %Y"
+    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y;
+                                catch {unset ${w}(cursor_drag)}"
 
     bind $d <Any-Motion> "cross_hair $w $t %x %y"
     bind $d <Any-Leave>  "cross_hair_leave $w"
 
-    bind $d <<use>> "invoke_editor $w $t %x"
+    bind $d <<use>> "set ${w}(cursor_drag) {};
+                     invoke_editor $w $t %x"
 
     set ${t}(Init) 1
 }
@@ -1437,13 +1563,15 @@ proc depth_item_init {w t} {
     bind $d <B2-Motion> "addLine $d %x %y"
     bind $d <3> "$d delete withttag tline"
 
-    bind $d <B1-Motion> "drag_x $w $t %x %y"
-    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y"
+    bind $d <B1-Motion> "drag_x $w $t %x %y %X %Y"
+    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y;
+                                catch {unset ${w}(cursor_drag)}"
 
     bind $d <Any-Motion> "cross_hair $w $t %x %y"
     bind $d <Any-Leave>  "cross_hair_leave $w"
 
-    bind $d <<use>> "invoke_editor $w $t %x"
+    bind $d <<use>> "set ${w}(cursor_drag) {};
+                     invoke_editor $w $t %x"
 
     set ${t}(Init) 1
 }
@@ -1587,9 +1715,14 @@ proc addLine {d x y} {
 # functions used by tracks
 #
 
-proc drag_x {w t x y} {
+proc drag_x {w t x y {X 0} {Y 0}} {
     global $w $t
     
+    if {[info exists ${w}(cursor_drag)]} {
+	1.5cursor_press $t [set ${w}(cursor_drag)]
+	return [1.5cursor_motion $w $t [set ${w}(cursor_drag)] $X]
+    } 
+
     set start [set ${t}(m_start)]
     set d  [set ${t}(canvas)]
     set td [set ${t}(track)]
@@ -1614,6 +1747,11 @@ proc drag_x {w t x y} {
 proc end_drag_x {w t x y} {
     global $w $t
 
+    if {[info exists ${w}(cursor_drag)]} {
+	1.5cursor_release $t [set ${w}(cursor_drag)]
+	return
+    }
+
     set start [set ${t}(m_start)]
     set end   [set ${t}(m_stop)]
     
@@ -1813,11 +1951,13 @@ proc invoke_editor {w t x} {
 		        pos     $x \
 		        sent_by 0]
     } else {
+	set ${w}(invoking_editor) 1
 	edit_contig \
 	    -io $io \
 	    -contig  [set ${w}(cnum)] \
 	    -reading [set ${w}(cnum)] \
 	    -pos $x
+	unset ${w}(invoking_editor)
     }
 }
 
@@ -1934,7 +2074,7 @@ proc seq_seqs_filter {w t} {
     label $f2.min_label -text "Min. Qual"
     scale $f2.min_qual \
 	-from 0 \
-	-to 80 \
+	-to 255 \
 	-orient horiz \
 	-variable ${w}(_MinQual) \
 	-command "seq_seqs_filter_update $w $t $f min"
@@ -1942,7 +2082,7 @@ proc seq_seqs_filter {w t} {
     label $f2.max_label -text "Max. Qual"
     scale $f2.max_qual \
 	-from 0 \
-	-to 80 \
+	-to 255 \
 	-orient horiz \
 	-variable ${w}(_MaxQual) \
 	-command "seq_seqs_filter_update $w $t $f max"
@@ -2059,6 +2199,9 @@ proc seq_seqs_filter_update {w t f {cmd {}} args} {
     if {[set ${w}(FilterAutoUpdate)]} {
 	seq_seqs_filter_apply $w $t $f 0
     }
+
+    global template_size_tolerance
+    set template_size_tolerance [set ${w}(ValidSD)]
 }
 
 
@@ -2341,33 +2484,35 @@ proc quality_item_init {w t} {
     $m add separator
     $m add checkbutton \
 	-label "Consensus Quality" \
-        -variable ${w}(quality) \
+        -variable ${w}(Show_Quality) \
 	-command "quality_item_config $w $t"
     $m add checkbutton \
 	-label "Consensus Heterozygosity" \
-	-variable ${w}(hetero) \
+	-variable ${w}(Show_Hetero) \
 	-command "quality_item_config $w $t"
     $m add checkbutton \
 	-label "Consensus Discrepancies" \
-	-variable ${w}(discrep) \
+	-variable ${w}(Show_Discrep) \
 	-command "quality_item_config $w $t"
 
-    set ${w}(quality) 0
-    set ${w}(hetero)  0
-    set ${w}(discrep) 0
+    set ${w}(Show_Quality) 0
+    set ${w}(Show_Hetero)  0
+    set ${w}(Show_Discrep) 0
 #    quality_item_config $w $t
 
     bind $d <2> "set lastx %x; set lasty %y"
     bind $d <B2-Motion> "addLine $d %x %y"
     bind $d <3> "$d delete withttag tline"
 
-    bind $d <B1-Motion> "drag_x $w $t %x %y"
-    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y"
+    bind $d <B1-Motion> "drag_x $w $t %x %y %X %Y"
+    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y;
+                                catch {unset ${w}(cursor_drag)}"
 
     bind $d <Any-Motion> "cross_hair $w $t %x %y"
     bind $d <Any-Leave>  "cross_hair_leave $w"
 
-    bind $d <<use>> "invoke_editor $w $t %x"
+    bind $d <<use>> "set ${w}(cursor_drag) {};
+                     invoke_editor $w $t %x"
 }
 
 proc quality_item_config {w t} {
@@ -2375,16 +2520,16 @@ proc quality_item_config {w t} {
 
     # Do we need it to be visible
     set visible 0
-    if {[set ${w}(quality)]} {set visible 1}
-    if {[set ${w}(hetero)]}  {set visible 1}
-    if {[set ${w}(discrep)]} {set visible 1}
+    if {[set ${w}(Show_Quality)]} {set visible 1}
+    if {[set ${w}(Show_Hetero)]}  {set visible 1}
+    if {[set ${w}(Show_Discrep)]} {set visible 1}
 
     set d [set ${t}(canvas)]
     set td [set ${t}(track)]
     $d itemconfigure $td \
-	-quality        [set ${w}(quality)] \
-	-heterozygosity [set ${w}(hetero)] \
-	-discrepancies  [set ${w}(discrep)]
+	-quality        [set ${w}(Show_Quality)] \
+	-heterozygosity [set ${w}(Show_Hetero)] \
+	-discrepancies  [set ${w}(Show_Discrep)]
     
     if {$visible} {
 	show_plot $w quality_item
@@ -2438,22 +2583,29 @@ proc tag_item_init {w t} {
     $m add separator
     $m add checkbutton \
 	-label "Tags" \
-        -variable ${w}(tags) \
+        -variable ${w}(Show_Tags) \
 	-command "tag_item_config $w $t"
 
-    set ${w}(tags) 0
+#    trace add variable ${w}(Show_Tags) write "tag_item_config $w $t"
+#    if {![info exists ${w}(Show_Tags)]} {
+#	set ${w}(Show_Tags) 0
+#    } else {
+#	set ${w}(Show_Tags) [set ${w}(Show_Tags)]
+#    }
 
     bind $d <2> "set lastx %x; set lasty %y"
     bind $d <B2-Motion> "addLine $d %x %y"
     bind $d <3> "$d delete withttag tline"
 
-    bind $d <B1-Motion> "drag_x $w $t %x %y"
-    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y"
+    bind $d <B1-Motion> "drag_x $w $t %x %y %X %Y"
+    bind $d <B1-ButtonRelease> "end_drag_x $w $t %x %y;
+                                catch {unset ${w}(cursor_drag)}"
 
     bind $d <Any-Motion> "cross_hair $w $t %x %y"
     bind $d <Any-Leave>  "cross_hair_leave $w"
 
-    bind $d <<use>> "invoke_editor $w $t %x"
+    bind $d <<use>> "set ${w}(cursor_drag) {};
+                     invoke_editor $w $t %x"
 }
 
 proc tag_item_config {w t} {
@@ -2461,7 +2613,7 @@ proc tag_item_config {w t} {
 
     # Do we need it to be visible
     set visible 0
-    if {[set ${w}(tags)]} {set visible 1}
+    if {[set ${w}(Show_Tags)]} {set visible 1}
 
     set d [set ${t}(canvas)]
     set td [set ${t}(track)]
@@ -2583,6 +2735,7 @@ proc CreateTemplateDisplay {io cnum {pos {}}} {
     set pwin .read_depth[counter]
     set width  [keylget gap5_defs TEMPLATE.WIDTH]
     set height [keylget gap5_defs TEMPLATE.HEIGHT]
+    global $pwin
 
     1.5Dplot $pwin $io $width $height $cnum $pos
 #    add_plot $pwin seq_seqs    250  1 1 -bd 0 -relief raised
@@ -2595,7 +2748,43 @@ proc CreateTemplateDisplay {io cnum {pos {}}} {
     add_plot $pwin tag_item        0 0 0 0 -bd 0 -relief raised -bg black
     add_plot $pwin seq_ruler      50 0 0 1 -bd 1 -relief sunken
 
+    set db [[set ${pwin}(io)] get_database]
+    set nc [$db get_num_libraries]
+    array set lib_recs ""
+    for {set i 0} {$i < $nc} {incr i} {
+	set lib_recs([$db get_library_rec $i]) 1
+    }
+
+    # Query global settings and initialise
+    for {set i 0} {$i <= 10} {incr i} {
+	if {![catch {keylget gap5_defs TEMPLATE_DISPLAY.SETTINGS_$i}]} {
+	    set k [keylget gap5_defs TEMPLATE_DISPLAY.SETTINGS_$i]
+	    global .read_depth.$i
+	    array set .read_depth.$i [keylget k BASE]
+	    for {set j 1} {$j <= [set ${pwin}(ntracks)]} {incr j} {
+		global .read_depth.track$j.$i
+		array set .read_depth.track$j.$i [keylget k "TRACK$j"]
+	    }
+
+	    # Correct (Libs) element to see if it's valid for this database.
+	    catch {unset .read_depth.${i}(Libs~)}
+	    catch {unset .read_depth.${i}(_Libs)}
+	    if {[info exists .read_depth.${i}(Libs)]} {
+		foreach rec [set .read_depth.${i}(Libs)] {
+		    if {![info exists lib_recs($rec)]} {
+			set .read_depth.${i}(Libs) ""
+			break;
+		    }
+		}
+	    }
+	}
+    }
+
     tkwait visibility $pwin
+    update
+
+    1.5plot_restore_settings $pwin 0
+
     after 1 "redraw_plot $pwin"
 }
 
diff --git a/gap5/dis_readings.c b/gap5/dis_readings.c
index c088d7a..7bdd418 100644
--- a/gap5/dis_readings.c
+++ b/gap5/dis_readings.c
@@ -476,6 +476,8 @@ int remove_contig_holes(GapIO *io, tg_rec contig, int start, int end,
 	    vmessage("GAP from %d..%d; breaking.\n", cend, last);
 	    if (!empty_contigs_only)
 		r = break_contig(io, contig, last, 0);
+	    else
+		r = 0;
 
 	    /* Who knows what impact break_contig has - restart to be safe */
 	    contig_iter_del(iter);
@@ -700,7 +702,6 @@ static int create_contig_from(GapIO *io, r_pos_t *pos, int npos,
     static tg_rec last_contig=-1;
     int offset;
     bin_index_t *bin;
-    int old_comp;
     int dest_start = INT_MAX, dest_end = INT_MIN;
     int src_start = INT_MAX, src_end = INT_MIN;
     contig_map *map;
@@ -727,8 +728,6 @@ static int create_contig_from(GapIO *io, r_pos_t *pos, int npos,
     } while (contig_index_query(io, name) != -1);
 
     bin = cache_search(io, GT_Bin, c_old->bin);
-    old_comp = (bin->flags & BIN_COMPLEMENTED) ? 1 : 0;
-
 
     /* Create the new contig */
     c_new = contig_new(io, name);
@@ -825,7 +824,7 @@ static int create_contig_from(GapIO *io, r_pos_t *pos, int npos,
  * based on overlaps. Calls create_contig_from to do the grunt work.
  */
 static int move_reads(GapIO *io, r_pos_t *pos, int npos, Array cmap) {
-    int i, start, end;
+    int i, end;
     tg_rec contig;
     int i_start, err = 0;
 
@@ -834,7 +833,6 @@ static int move_reads(GapIO *io, r_pos_t *pos, int npos, Array cmap) {
 
     i_start = 0;
     contig  = pos[0].contig;
-    start   = pos[0].start;
     end     = pos[0].end;
     for (i = 1; i < npos; i++) {
 	if (pos[i].contig != contig ||
@@ -843,7 +841,6 @@ static int move_reads(GapIO *io, r_pos_t *pos, int npos, Array cmap) {
 		err = 1;
 	    i_start = i;
 	    contig  = pos[i].contig;
-	    start   = pos[i].start;
 	    end     = pos[i].end;
 	} else {
 	    if (end < pos[i].end)
diff --git a/gap5/dis_readings.tcl b/gap5/dis_readings.tcl
index e565582..a9aa60c 100644
--- a/gap5/dis_readings.tcl
+++ b/gap5/dis_readings.tcl
@@ -93,6 +93,14 @@ proc OK_Pressed_DisReading { io f cs infile id sel_task constags } {
 	if {[set list [lorf_get_list $infile]] == ""} {bell; return}
     }
 
+    # Check if list of lists, if so recurse
+    set loop ""
+    if {[lorf_in_get $infile] == 1} {
+	if {[ListType [lorf_in_name $infile]] == "LIST_OF_LISTS"} {
+	    set loop $list
+	}
+    }
+
     #convert reading numbers into reading names
 #    set list [eval get_read_names -io $io $list]
     destroy $f
@@ -103,12 +111,25 @@ proc OK_Pressed_DisReading { io f cs infile id sel_task constags } {
 	return
     }
 
-    set result [log_call disassemble_readings \
-		    -io $io \
-		    -readings $list \
-		    -move $iopt \
-		    -duplicate_tags $dup_tags \
-		    -remove_holes [set $f.Break]]
+    if {$loop == ""} {
+	log_call disassemble_readings \
+	    -io $io \
+	    -readings $list \
+	    -move $iopt \
+	    -duplicate_tags $dup_tags \
+	    -remove_holes [set $f.Break]
+    } else {
+	foreach l $loop {
+	    set list [ListGet $l]
+	    log_call disassemble_readings \
+		-io $io \
+		-readings $list \
+		-move $iopt \
+		-duplicate_tags $dup_tags \
+		-remove_holes [set $f.Break]
+	}
+    }
+
     #if database is empty, destroy contig selector and set menus back to
     #as if opened new database
     if {[db_info num_contigs $io] == 0} {
diff --git a/gap5/do_fij.c b/gap5/do_fij.c
index 9173ef7..679eb83 100644
--- a/gap5/do_fij.c
+++ b/gap5/do_fij.c
@@ -56,7 +56,6 @@ static int check_containment_or_end(add_fij_t *cd,
     GapIO    *io = cd->fij_args->io;
     tg_rec crec1 = cd->contig_list1[contig1_num].contig_number;
     tg_rec crec2 = cd->contig_list2[contig2_num].contig_number;
-    contig_t        *c;
     int cstart1, cend1, cstart2, cend2;
     int contain = 0;
 
@@ -105,7 +104,7 @@ static int check_depth(add_fij_t *cd, int orient,
     tg_rec crec1 = cd->contig_list1[contig1_num].contig_number;
     tg_rec crec2 = cd->contig_list2[contig2_num].contig_number;
     consensus_t *cons = NULL;
-    int i, depth, d1, d2;
+    int i, depth;
     int *d;
 
 
@@ -117,8 +116,8 @@ static int check_depth(add_fij_t *cd, int orient,
 	int ti;
 
 	tc = crec1; crec1 = crec2; crec2 = tc;
-	i = s1l; s1l = s2l; s2l = i;
-	i = s1r; s1r = s2r; s2r = i;
+	ti = s1l; s1l = s2l; s2l = ti;
+	ti = s1r; s1r = s2r; s2r = ti;
     }
 
 
@@ -892,7 +891,7 @@ int do_it_fij(fij_arg *fij_args, char *seq, int seq_len,
 	    h->filter_words = 0;
 	}
 	if (h->filter_words)
-	    vmessage("Filtering words occuring more than %d times.\n",
+	    vmessage("Filtering words occurring more than %d times.\n",
 		     h->filter_words);
 
 	for (contig2_num = (contig1_num < first_shared1
diff --git a/gap5/editor_join.c b/gap5/editor_join.c
index eb030b9..3eb9618 100644
--- a/gap5/editor_join.c
+++ b/gap5/editor_join.c
@@ -1396,7 +1396,7 @@ static int join_move_bins(GapIO *io, contig_t *cl, contig_t *cr,
 	head = head->next;
 	free(item);
     }
-    return 0;
+    return ret;
 }
 
 /*
diff --git a/gap5/editor_search.c b/gap5/editor_search.c
index 837a242..e78267d 100644
--- a/gap5/editor_search.c
+++ b/gap5/editor_search.c
@@ -232,8 +232,8 @@ int edview_search_sequence(edview *xx, int dir, int strand, char *value) {
     int patlen;
     char *uppert, *upperb;
     int found = 0;
-    tg_rec fseq;
-    int fpos, i;
+    tg_rec fseq = 0;
+    int fpos = 0, i;
     contig_iterator *iter;
     rangec_t *(*ifunc)(GapIO *io, contig_iterator *ci);
     rangec_t *r;
@@ -962,8 +962,8 @@ int edview_search_edit(edview *xx, int dir, int strand, char *value) {
     rangec_t *(*ifunc)(GapIO *io, contig_iterator *ci);
     rangec_t *r;
     int best_pos, found = 0;
-    int fpos;
-    tg_rec fseq;
+    int fpos = 0;
+    tg_rec fseq = 0;
 
     if (dir) {
 	start = xx->cursor_apos + 1;
diff --git a/gap5/editor_view.c b/gap5/editor_view.c
index 36b38cd..03a6c1b 100644
--- a/gap5/editor_view.c
+++ b/gap5/editor_view.c
@@ -719,6 +719,18 @@ char *edGetBriefSeq(edview *xx, tg_rec seq, int pos, char *format) {
 		case STECH_454:
 		    add_string(status_buf, &j, l1, l2, "454");
 		    break;
+		case STECH_HELICOS:
+		    add_string(status_buf, &j, l1, l2, "Helicos");
+		    break;
+		case STECH_IONTORRENT:
+		    add_string(status_buf, &j, l1, l2, "IonTorrent");
+		    break;
+		case STECH_PACBIO:
+		    add_string(status_buf, &j, l1, l2, "PacBio");
+		    break;
+		case STECH_ONT:
+		    add_string(status_buf, &j, l1, l2, "ONT");
+		    break;
 		default:
 		    add_string(status_buf, &j, l1, l2, "unknown");
 		    break;
@@ -1329,10 +1341,18 @@ static void tk_redisplaySeqTags(edview *xx, XawSheetInk *ink, seq_t *s,
 /* Returns 1 if rec is in the global "readings" list, 0 if not */
 static int seq_in_readings_list(edview *xx, tg_rec rec) {
     char srec[20], list[1024];
+    char *v;
 
     sprintf(list, "NGList_read_hash_%s", xx->ed->output_list);
     sprintf(srec, "#%"PRIrec, rec);
-    return Tcl_GetVar2(xx->interp, list, srec, TCL_GLOBAL_ONLY) ? 1 : 0;
+    v = Tcl_GetVar2(xx->interp, list, srec, TCL_GLOBAL_ONLY);
+    if (v)
+	return 1;
+
+    sprintf(list, "NGList_read_hash_%s", xx->ed->haplotype_list);
+    sprintf(srec, "#%"PRIrec, rec);
+    v = Tcl_GetVar2(xx->interp, list, srec, TCL_GLOBAL_ONLY);
+    return v ? atoi(v)+1 : 0;
 }
 
 static void tk_redisplaySeqSequences(edview *xx, rangec_t *r, int nr) {
@@ -1508,11 +1528,25 @@ static void tk_redisplaySeqSequences(edview *xx, rangec_t *r, int nr) {
 
 			case 3:
 			    if (ubase != xx->displayedConsensus[p2]) {
-				ink[p2].sh |= sh_bg;
-				if (qual >= xx->ed->display_differences_qual)
-				    ink[p2].bg = xx->ed->diff2_bg->pixel;
-				else
-				    ink[p2].bg = xx->ed->diff1_bg->pixel;
+				if (qual >= xx->ed->display_differences_qual) {
+				    if (ink[p2].sh & sh_light) {
+					ink[p2].fg = xx->ed->diff2_bg->pixel;
+					ink[p2].sh &= ~(sh_bg|sh_light);
+					ink[p2].sh |= sh_fg;
+				    } else {
+					ink[p2].sh |= sh_bg;
+					ink[p2].bg = xx->ed->diff2_bg->pixel;
+				    }
+				} else {
+				    if (ink[p2].sh & sh_light) {
+					ink[p2].fg = xx->ed->diff1_bg->pixel;
+					ink[p2].sh &= ~(sh_bg|sh_light);
+					ink[p2].sh |= sh_fg;
+				    } else {
+					ink[p2].sh |= sh_bg;
+					ink[p2].bg = xx->ed->diff1_bg->pixel;
+				    }
+				}
 			    }
 			    break;
 			}
@@ -1538,6 +1572,8 @@ static void tk_redisplaySeqSequences(edview *xx, rangec_t *r, int nr) {
 		    int p2 = r[i].end   - xx->displayPos;
 		    int bg = -1, t;
 		    double nc = xx->names->sw.columns;
+		    int h;
+
 		    if (p < 0) p = 0;
 		    p = p * (nc / xx->displayWidth);
 		    if (p2 < 0) p2 = 0;
@@ -1547,25 +1583,32 @@ static void tk_redisplaySeqSequences(edview *xx, rangec_t *r, int nr) {
 		    while (nline[p] != ' ')
 			p++;
 
-		    if (seq_in_readings_list(xx, s->rec)) {
-			int ptmp = p;
-			do {
-			    nink[ptmp].sh |= sh_bold;
-			    nink[ptmp++].sh |= box_alt ? sh_box : sh_box_alt;
-			} while (ptmp < p2);
-			qual_bg = xx->ed->qual_bg2;
-			bg = xx->ed->qual_bg2[9]->pixel;
-		    }
-
-		    if (xx->ed->display_mapping_quality) {
-			int qbin = s->mapping_qual / 10;
-			if (qbin < 0) qbin = 0;
-			if (qbin > 9) qbin = 9;
-			bg = qual_bg[qbin]->pixel;
+		    h = seq_in_readings_list(xx, s->rec);
+		    if (h > 1) {
+			bg = xx->ed->qual_haplo[h%10]->pixel;
 		    } else {
-			t = sequence_get_template_info(xx->io, sorig,
-						       NULL, NULL);
-			bg = xx->ed->tmpl_bg[t+1]->pixel;
+			if (h == 1) {
+			    int ptmp = p;
+			    do {
+				nink[ptmp].sh |= sh_bold;
+				nink[ptmp++].sh |= box_alt
+				    ? sh_box
+				    : sh_box_alt;
+			    } while (ptmp < p2);
+			    qual_bg = xx->ed->qual_bg2;
+			    bg = xx->ed->qual_bg2[9]->pixel;
+			}
+
+			if (xx->ed->display_mapping_quality) {
+			    int qbin = s->mapping_qual / 10;
+			    if (qbin < 0) qbin = 0;
+			    if (qbin > 9) qbin = 9;
+			    bg = qual_bg[qbin]->pixel;
+			} else {
+			    t = sequence_get_template_info(xx->io, sorig,
+							   NULL, NULL);
+			    bg = xx->ed->tmpl_bg[t+1]->pixel;
+			}
 		    }
 
 		    nline[p] = dir;
@@ -1583,8 +1626,8 @@ static void tk_redisplaySeqSequences(edview *xx, rangec_t *r, int nr) {
 		    }
 
 		} else {
-		    XColor **qual_bg = xx->ed->qual_bg;
-		    int t;
+		    XColor **qual_bg;
+		    int t, h;
 
 		    nline[0] = dir;
 		    if (nl > 0)
@@ -1595,24 +1638,39 @@ static void tk_redisplaySeqSequences(edview *xx, rangec_t *r, int nr) {
 		    nink[0].sh = sh_bg;
 		    nink[0].bg = xx->ed->tmpl_bg[t+1]->pixel;
 
-		    if (seq_in_readings_list(xx, s->rec)) {
-			qual_bg = xx->ed->qual_bg2;
-			for (k = 1; k < ncol && k < MAX_NAME_WIDTH; k++) {
-			    nink[k].sh |= sh_bg |
-				(box_alt ? sh_box : sh_box_alt);
-			    nink[k].bg = qual_bg[9]->pixel;
-			}
-		    }
+		    h = seq_in_readings_list(xx, s->rec);
 
-		    /*if (xx->ed->display_mapping_quality)*/ {
+		    if (h <= 1) {
 			int qbin = s->mapping_qual / 10;
 			if (qbin < 0) qbin = 0;
 			if (qbin > 9) qbin = 9;
 
+			if (h == 1) {
+			    // Normal selection
+			    qual_bg = xx->ed->qual_bg2;
+			    for (k = 1; k < ncol && k < MAX_NAME_WIDTH; k++) {
+				nink[k].sh |= sh_bg |
+				    (box_alt ? sh_box : sh_box_alt);
+				nink[k].bg = qual_bg[qbin]->pixel;
+			    }
+			} else {
+			    // No selection
+			    qual_bg = xx->ed->qual_bg;
+			    for (k = 1; k < ncol && k < MAX_NAME_WIDTH; k++) {
+				nink[k].sh |= sh_bg;
+				nink[k].bg = qual_bg[qbin]->pixel;
+			    }
+			}
+
+		    } else {
+			// Haplotype; colour without tinting by mapping quality
+			int qp = xx->ed->qual_haplo[h%10]->pixel;
+
 			for (k = 1; k < ncol && k < MAX_NAME_WIDTH; k++) {
 			    nink[k].sh |= sh_bg;
-			    nink[k].bg = qual_bg[qbin]->pixel;
+			    nink[k].bg = qp;
 			}
+			
 		    }
 		}
 	    }
@@ -1869,15 +1927,13 @@ static int generate_ruler(edview *xx, char *ruler, XawSheetInk *ink,
 
 	padded_to_reference_array(xx->io, xx->cnum, xx->displayPos,
 				  xx->displayPos+xx->displayWidth+10-1,
-				  rpos, rid);
+				  rpos, rid, NULL, NULL);
 
 	k += 10;
 	K += 10;
 	for (i = 0; i < xx->displayWidth+10; i++) {
-	    int len = log(ABS(rpos[i] ? rpos[i] : 1)) * 0.4342945;
-	    len++;
-
 	    if (rpos[i] % 10 == 0 && rid[i] != -1) {
+		int len = log(ABS(rpos[i] ? rpos[i] : 1)) * 0.4342945 + 1;
 		if (i - last_x > len) {
 		    sprintf(&k[i-(len-1)], "%.*d", len, rpos[i]);
 		    k[i+1+(rpos[i]<0)] = ' ';
@@ -2286,6 +2342,9 @@ int edSetCursorPos(edview *xx, int type, tg_rec rec, int pos, int visible) {
 	int left = s->left-1;
 	int right = s->right;
 
+	if (s == NULL || (s->flags & SEQ_UNMAPPED) != 0)
+	    return -1;
+
 	if (xx->ed->display_cutoffs) {
 	    left = 0;
 	    right = ABS(s->len);
@@ -3092,6 +3151,9 @@ Array edview_items_between(edview *xx, tg_rec from_rec, tg_rec to_rec) {
 	if (y < from_y || y > to_y)
 	    continue;
 
+	if ((xx->r[i].flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISSEQ)
+	    continue;
+
 	if ((y == from_y || y == to_y) && xx->ed->stack_mode) {
 	    int p1 = xx->r[i].start - xx->displayPos;
 	    if (p1 < 0) p1 = 0;
@@ -3788,8 +3850,8 @@ void ed_set_sequence_sort(edview *xx) {
     	xx->sort_settings.start = xx->select_start;
     	xx->sort_settings.end   = xx->select_end;
     } else {
-    	xx->sort_settings.start = xx->select_start;
-    	xx->sort_settings.end   = xx->select_end;
+    	xx->sort_settings.start = xx->select_end;
+    	xx->sort_settings.end   = xx->select_start;
     }
 }
     
diff --git a/gap5/export_contigs.c b/gap5/export_contigs.c
index ccbc6da..da4afb2 100644
--- a/gap5/export_contigs.c
+++ b/gap5/export_contigs.c
@@ -141,12 +141,13 @@ int tcl_export_tags(ClientData clientData, Tcl_Interp *interp,
     return res == 0 ? TCL_OK : -1;
 }
 
+
 /* ------------------------------------------------------------------------
  * export_contigs implementation
  */
 
-
 /*
+ * ------------------------------------------------------------------------
  * A FIFO queue. We stack up sequences in here until we have sufficient
  * data to punt the entire thing out including all the annotations.
  */
@@ -277,6 +278,43 @@ static void fifo_queue_swap(fifo_queue_t *f, fifo_t *a, fifo_t *b) {
 	f->tail = a;
 }
 
+
+/*
+ * ------------------------------------------------------------------------
+ * A TREE equivalent to the FIFO queue, allowing insertion into a sorted
+ * tree.  Annotations go fine on the fifo as it's a simple queue.
+ * Sequences however need to be sorted by clipped start coordinate if we're
+ * outputting to SAM, so a sorted data structure is more efficient than
+ * attempting to maintain a sorted linked list.
+ *
+ * See Misc/tree.h for the macros.
+ */
+
+typedef struct clip_start {
+    SPLAY_ENTRY(clip_start) link;
+    int clipped_pos;
+    int count;
+    rangec_t r;
+} clip_start;
+
+static int clip_cmp(clip_start *vp1, clip_start *vp2) {
+    int d;
+
+    return (d = (vp1->clipped_pos - vp2->clipped_pos))
+	? d : vp1->count - vp2->count;
+}
+
+// xt         = function name prefix.
+// clip_start = tree node type.
+SPLAY_HEAD(xt, clip_start);
+SPLAY_PROTOTYPE(xt, clip_start, link, clip_cmp);
+SPLAY_GENERATE(xt, clip_start, link, clip_cmp);
+
+
+/* ------------------------------------------------------------------------
+ * export_contigs main guts
+ */
+
 /*
  * Computes and returns a false name for when the sequence has no read name.
  * This is just the record number of the sequence or it's pair (whatever is
@@ -302,7 +340,7 @@ static char *false_name(GapIO *io, seq_t *s, int suffix, int *name_len) {
 
 static int export_header_sam(GapIO *io, scram_fd *bf,
 			     int cc, contig_list_t *cv,
-			     int fixmates,
+			     int fixmates, int depad,
 			     char *ref_fn, int format) {
     int i;
     char len_buf[100];
@@ -325,9 +363,14 @@ static int export_header_sam(GapIO *io, scram_fd *bf,
 	    if (NULL == (c = cache_search(io, GT_Contig, cnum)))
 		return -1;
 	    
-	    len = c->end;
-	    if (c->start <= 0)
-		len += 1-c->start;
+	    consensus_valid_range(io, c->rec, NULL, &len);
+	    if (depad == 2) {
+		len = padded_to_reference_pos(io, c->rec, len, NULL, NULL);
+	    } else {
+		len = c->end;
+		if (c->start <= 0)
+		    len += 1-c->start;
+	    }
 
 	    sprintf(len_buf, "%d", len);
 	    sam_hdr_add(scram_get_header(bf), "SQ", "SN",
@@ -341,9 +384,14 @@ static int export_header_sam(GapIO *io, scram_fd *bf,
 	    if (NULL == (c = cache_search(io, GT_Contig, cv[i].contig)))
 		return -1;
 
-	    len = c->end;
-	    if (c->start <= 0)
-		len += 1-c->start;
+	    consensus_valid_range(io, c->rec, NULL, &len);
+	    if (depad == 2) {
+		len = padded_to_reference_pos(io, c->rec, len, NULL, NULL);
+	    } else {
+		len = c->end;
+		if (c->start <= 0)
+		    len += 1-c->start;
+	    }
 
 	    sprintf(len_buf, "%d", len);
 	    sam_hdr_add(scram_get_header(bf), "SQ", "SN",
@@ -465,6 +513,144 @@ static uint32_t *sam_padded_cigar(char *seq, int left, int right, int olen,
     return cigar;
 }
 
+static uint32_t *sam_refbased_cigar(GapIO *io, contig_t *c, int cpos,
+				    char *seq, int left, int right, int olen,
+				    int *ncigar_p, int *ref_pos) {
+    static uint32_t *cigar = NULL;
+    static int cg_alloc = 0;
+    int i, j;
+    int oplen = 0;
+    enum cigar_op op = BAM_CSOFT_CLIP, last_op = -1;
+    int ncigar = 0, last_oplen = 0;
+    int *rpos, last_rpos, np;
+
+    rpos = malloc(olen*sizeof(int));
+    padded_to_reference_array(io, c->rec, cpos, cpos+olen-1,
+			      rpos, NULL, ref_pos, &np);
+    last_rpos = *ref_pos-1;
+
+    //printf("Read %d..%d at %d..%d (ref %d)\n", left, right, cpos, cpos+olen-1, *ref_pos);
+
+    for (i = j = 0; i < olen; i++,j++) {
+	//printf("%2d %c, %d /  %d\n", i, seq[i], i+left+1, rpos[j]);
+	if (ncigar >= cg_alloc) {
+	    cg_alloc += 32;
+	    cigar = realloc(cigar, cg_alloc*4);
+	}
+
+	/*
+	 *  Seq   Ref-pos  Op
+	 *  A     >0       M
+	 *  A     0        I
+	 *  A     (D)      D+M?
+	 *  *     >0       D
+	 *  *     0        P
+	 *  *     (D)      D+D?
+	 */
+	if (seq[i] == '*') {
+	    if (i < left || i >= right) {
+		// remove gap in soft-clip as SAM cannot represent this
+		op = BAM_CSOFT_CLIP;
+		oplen = 0;
+		j--;
+	    } else if (rpos[j] == INT_MIN) {
+		// Insertion, but not in this seq
+		op = BAM_CPAD;
+		oplen = 1;
+	    } else if (rpos[j] - last_rpos > 1) {
+		// Deletion in seq matching deletion in consensus
+		op = BAM_CDEL;
+		oplen = rpos[j] - last_rpos;
+		last_rpos = rpos[j];
+	    } else {
+		// Deletion in seq vs match in consensus
+		op = BAM_CDEL;
+		oplen = 1;
+		last_rpos = rpos[j];
+	    }
+	} else {
+	    if (i < left || i >= right) {
+		op = BAM_CSOFT_CLIP;
+		oplen = 1;
+		j--;
+	    } else if (rpos[j] == INT_MIN) {
+		// Insertion of base
+		if (i == left && np) {
+		    // First visible base is an inserted one, add P if needed
+		    if (last_op != -1) {
+			if (ncigar >= cg_alloc) {
+			    cg_alloc += 32;
+			    cigar = realloc(cigar, cg_alloc*4);
+			}
+			cigar[ncigar++] = (last_oplen<<4) + last_op;
+			//printf("%d%c (%d%c)\n", last_oplen, "MIDNSHP=X"[last_op],
+			//       oplen, "MIDNSHP=X"[op]);
+		    }
+		    last_op = BAM_CPAD;
+		    last_oplen = np;
+		}
+		op = BAM_CINS;
+		oplen = 1;
+	    } else if (rpos[j] - last_rpos > 1) {
+		// Deletion in consensus + match
+		op = BAM_CDEL;
+		oplen = rpos[j] - (last_rpos+1);
+
+		if (last_op != -1) {
+		    if (ncigar >= cg_alloc) {
+			cg_alloc += 32;
+			cigar = realloc(cigar, cg_alloc*4);
+		    }
+		    cigar[ncigar++] = (last_oplen<<4) + last_op;
+		    //printf("%d%c (%d%c)\n", last_oplen, "MIDNSHP=X"[last_op],
+		    //	   oplen, "MIDNSHP=X"[op]);
+		}
+		last_op = op;
+		last_oplen = oplen;
+
+		op = BAM_CMATCH;
+		oplen = 1;
+		last_rpos = rpos[j];
+	    } else {
+		// Match
+		op = BAM_CMATCH;
+		oplen = 1;
+		last_rpos = rpos[j];
+	    }
+	}
+
+	if (op == last_op) {
+	    last_oplen += oplen;
+	} else {
+	    if (last_op != -1) {
+		if (ncigar >= cg_alloc) {
+		    cg_alloc += 32;
+		    cigar = realloc(cigar, cg_alloc*4);
+		}
+		cigar[ncigar++] = (last_oplen<<4) + last_op;
+		//printf("%d%c (%d%c)\n", last_oplen, "MIDNSHP=X"[last_op],
+		//       oplen, "MIDNSHP=X"[op]);
+	    }
+	    last_op = op;
+	    last_oplen = oplen;
+	}
+    }
+
+    if (last_oplen > 0) {
+	if (ncigar >= cg_alloc) {
+	    cg_alloc += 32;
+	    cigar = realloc(cigar, cg_alloc*4);
+	}
+	cigar[ncigar++] = (last_oplen<<4) + last_op;
+	//printf("%d%c\n", last_oplen, "MIDNSHP=X"[last_op]);
+    }
+
+    free(rpos);
+
+    *ncigar_p = ncigar;
+    return cigar;
+}
+
 static uint32_t *sam_depadded_cigar(char *seq, int left, int right, int olen,
 				    char *cons, int *ncigar_p) {
     static uint32_t *cigar = NULL;
@@ -594,7 +780,7 @@ static uint32_t *sam_depadded_cigar(char *seq, int left, int right, int olen,
 /*
  * Exports a single consensus tag as a fake sam sequence.
  */
-static void sam_export_cons_tag(GapIO *io, scram_fd *bf, fifo_t *fi,
+static void sam_export_cons_tag(GapIO *io, scram_fd *bf, clip_start *fi,
 				contig_t *c, int offset,
 				int depad, char *cons,
 				int *npad, int *pad_to) {
@@ -610,7 +796,11 @@ static void sam_export_cons_tag(GapIO *io, scram_fd *bf, fifo_t *fi,
     start = fi->r.start;
     end   = fi->r.end;
 
-    if (depad) {
+    switch (depad) {
+    case 0:
+	break;
+
+    case 1: {
 	int np2, i;
 
 	/* pos is currently padded */
@@ -628,6 +818,13 @@ static void sam_export_cons_tag(GapIO *io, scram_fd *bf, fifo_t *fi,
 		np2++;
 	}
 	end -= np2;
+	break;
+    }
+
+    case 2:
+	start = padded_to_reference_pos(io, c->rec, start, NULL, NULL);
+	end   = padded_to_reference_pos(io, c->rec, end,   NULL, NULL);
+	break;
     }
 
 
@@ -664,6 +861,7 @@ static void sam_export_cons_tag(GapIO *io, scram_fd *bf, fifo_t *fi,
     scram_put_seq(bf, bam);
 }
 
+
 /*
  * Exports a single sam sequence, marrying up annotations to the appropriate
  * sequences and adding these in auxillary tags.
@@ -676,7 +874,8 @@ static void sam_export_cons_tag(GapIO *io, scram_fd *bf, fifo_t *fi,
  * update these fields as we go (with an assumption data is in sorted order).
  */
 static void sam_export_seq(GapIO *io, scram_fd *bf,
-			   fifo_t *fi, fifo_queue_t *tq,
+			   //fifo_t *fi, fifo_queue_t *tq,
+			   clip_start *fi, fifo_queue_t *tq,
 			   int fixmates, tg_rec crec, contig_t *c, int offset,
 			   int depad, char *cons, int *npad, int *pad_to) {
     seq_t *s = (seq_t *)cache_search(io, GT_Seq, fi->r.rec), *sorig = s;
@@ -705,7 +904,7 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 
     /* Cigar encoding */
     uint32_t *cigar = NULL, *cigar_tmp;
-    int ncigar, ncigar_tmp;
+    int ncigar = 0, ncigar_tmp;
 
     /* A single SAM line */
     static dstring_t *ds = NULL;
@@ -808,7 +1007,7 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 	       if ((fi->r.flags & GRANGE_FLAG_END_MASK) !=
 		   (fi->r.flags & GRANGE_FLAG_PEND_MASK)) {
 		   /* Opposite orientations */
-		   //flag |= 0x02; /* proper pair */
+		   flag |= 0x02; /* proper pair */
 	       }
 
 	       /*
@@ -840,12 +1039,22 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
     }
 
     /*--- Generate cigar string. */
-    if (depad)
+    switch (depad) {
+    case 0:
+	cigar = sam_padded_cigar(s->seq, left, right, olen, &ncigar);
+	break;
+
+    case 1:
 	cigar = sam_depadded_cigar(s->seq, left, right, olen,
 				   &cons[pos - c->start + *npad],
 				   &ncigar);
-    else
-	cigar = sam_padded_cigar(s->seq, left, right, olen, &ncigar);
+	break;
+
+    case 2:
+	cigar = sam_refbased_cigar(io, c, pos+*npad, s->seq, left, right, olen,
+				   &ncigar, &pos);
+	break;
+    }
     
     /*--- Compute start and end value for bin */
     start = end =  pos + offset;
@@ -871,9 +1080,18 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 	sequence_get_position2(io, fi->r.pair_rec, &other_c, &other_st,
 			       &other_en, &other_dir, NULL, &pair_r, &pair_s);
 
-	comp = (pair_s->len >= 0) ^ other_dir;
+	comp = (pair_s->len < 0) ^ other_dir;
+
+	if (comp) {
+	    other_st += ABS(pair_s->len) - pair_s->right;
+	    other_en -= pair_s->left-1;
+	} else {
+	    other_st += pair_s->left-1;
+	    other_en -= ABS(pair_s->len) - pair_s->right;
+	}
+
 	cache_decr(io, pair_s);
-	    
+
 	iend = other_st < other_en ? other_st : other_en;
 
 	if (crec == other_c) {
@@ -881,6 +1099,11 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 	    mate_ref = "=";
 	    ll = (sorig->len >= 0) ? pos : pos - sorig->len - 1;
 	    rr = comp ? other_st-1 : other_en+1;
+	    if (depad == 2) {
+		ll   = padded_to_reference_pos(io, crec, ll,   NULL, NULL);
+		rr   = padded_to_reference_pos(io, crec, rr,   NULL, NULL);
+		iend = padded_to_reference_pos(io, crec, iend, NULL, NULL);
+	    }
 	    isize = rr-ll;
 	} else {
 	    contig_t *oc = cache_search(io, GT_Contig, other_c);
@@ -888,8 +1111,10 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 	    isize = 0;
 	}
 
-	if (!comp)
+	if (comp)
 	    flag |=  0x20; /* strand of mate */
+	else
+	    flag &= ~0x20;
 
 	/* FIXME: Can also check here if proper pair, based on
 	 * library type.
@@ -933,8 +1158,8 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 		      tname, tname_len,
 		      flag,
 		      ref_id,
-		      pos+offset,
-		      end+offset,
+		      start,
+		      end,
 		      mqual,
 		      ncigar_tmp, cigar_tmp,
 		      mate_ref_id,
@@ -969,7 +1194,7 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
     if (fifo_queue_head(tq)) {
 	char *d;
 	int i = 0, j = 0, l = ABS(s->len), n = 0;
-	int op, op_len = 0;
+	int op = 0, op_len = 0;
 	depad_map = malloc(l * sizeof(*depad_map));
 	if (!depad_map)
 	    return;
@@ -984,12 +1209,38 @@ static void sam_export_seq(GapIO *io, scram_fd *bf,
 	    }
 
 	    depad_map[i] = j;
-	    if (d[i] != '*' || op == BAM_CPAD || (!depad && op == BAM_CDEL)) {
-		//printf("%2d %c/%c %2d  %d%c\n", i+1, d[i], S[j], j+1, op_len, op);
-		op_len--;
-		j++;
-	    } else {
-		//printf("%2d %c/- %2d  -\n", i+1, d[i], j+1);
+	    switch (depad) {
+	    case 0:
+		if (d[i] != '*' || op == BAM_CPAD) {
+		    op_len--;
+		    j++;
+		}
+		break;
+
+	    case 1:
+		if (d[i] != '*' || op == BAM_CPAD || op == BAM_CDEL) {
+		    op_len--;
+		    j++;
+		}
+		break;
+
+	    case 2:
+		if (op == BAM_CDEL && d[i] != '*') {
+		    j+=op_len;
+		    op_len=0;
+		    i--; // Don't consume this sequence base
+		    
+		} else if (op == BAM_CMATCH ||
+			   op == BAM_CINS ||
+			   op == BAM_CPAD ||
+			   op == BAM_CDEL ||
+			   op == BAM_CSOFT_CLIP ||
+			   op == BAM_CBASE_MATCH ||
+			   op == BAM_CBASE_MISMATCH) {
+		    op_len--;
+		    j++;
+		}
+		break;
 	    }
 	}
     }
@@ -1099,11 +1350,13 @@ static int export_contig_sam(GapIO *io, scram_fd *bf,
     int offset, ustart, uend;
     char *cons = NULL;
     /* Seq fragment and tag queues */
-    fifo_queue_t *fq = fifo_queue_create(), *tq = fifo_queue_create();
-    fifo_t *fi;
+    fifo_queue_t *tq = fifo_queue_create();
     int last_start = 0;
     int npads = 0, pad_to;
     int expanded_start, expanded_end;
+    clip_start *cs, *cs_next;
+    struct xt ptree = SPLAY_INITIALIZER(&ptree);
+    int count = 0;
 
     c = (contig_t *)cache_search(io, GT_Contig, crec);
     if (!c)
@@ -1139,77 +1392,75 @@ static int export_contig_sam(GapIO *io, scram_fd *bf,
 	/* Add new items to fifo */
 	if ((r->flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISSEQ) {
 	    seq_t *s;
-	    fifo_t *fi, *fl;
 
 	    if (r->end < start || r->start > end)
 		continue;
 
-	    fi = fifo_queue_push(fq, r);
+	    cs = malloc(sizeof(*cs));
+	    cs->r = *r;
+	    cs->count = count++;
 
 	    /* Compute clipped start */
-	    s = cache_search(io, GT_Seq, fi->r.rec);
-	    if ((s->len >= 0) ^ fi->r.comp) {
-		fi->clipped_pos = fi->r.start + s->left-1;
+	    s = cache_search(io, GT_Seq, cs->r.rec);
+	    if ((s->len >= 0) ^ cs->r.comp) {
+		cs->clipped_pos = cs->r.start + s->left-1;
 	    } else {
-		fi->clipped_pos = fi->r.start + (ABS(s->len) - s->right);
+		cs->clipped_pos = cs->r.start + (ABS(s->len) - s->right);
 	    }
 
-	    /* Sort by clipped left-end */
-	    while ((fl = fi->prev) && fi->clipped_pos < fl->clipped_pos) {
-		fifo_queue_swap(fq, fi, fl);
-	    }
+	    SPLAY_INSERT(xt, &ptree, cs);
 
 	    last_start = r->start;
 	} else if ((r->flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISANNO) {
 	    if (r->flags & GRANGE_FLAG_TAG_SEQ) {
 		fifo_queue_push(tq, r);
 	    } else {
-		fifo_t *fi, *fl;
-
-		fi = fifo_queue_push(fq, r); /* consensus tag */
-		fi->clipped_pos = r->start;
+		cs = malloc(sizeof(*cs));
+		cs->r = *r;
+		cs->count = count++;
+		cs->clipped_pos = r->start;
 
-		/* Sort by clipped left-end */
-		while ((fl = fi->prev) && fi->clipped_pos < fl->clipped_pos) {
-		    fifo_queue_swap(fq, fi, fl);
-		}
+		SPLAY_INSERT(xt, &ptree, cs);
 
 		last_start = r->start;
 	    }
 	}
 
 	/* And pop off when they're history */
-	while (NULL != (fi = fifo_queue_head(fq))) {
-	    if (fi->r.end < last_start) {
-		fifo_queue_pop(fq);
-		if ((fi->r.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISANNO) {
-		    sam_export_cons_tag(io, bf, fi, c, offset,
+	for (cs = SPLAY_MIN(xt, &ptree); cs; cs = cs_next) {
+	    if (cs->r.end < last_start) {
+		if ((cs->r.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISANNO) {
+		    sam_export_cons_tag(io, bf, cs, c, offset,
 					depad, cons+1, &npads, &pad_to);
 		} else {
-		    sam_export_seq(io, bf, fi, tq, fixmates, crec, c, offset,
+		    sam_export_seq(io, bf, cs, tq, fixmates, crec, c, offset,
 				   depad, cons+1, &npads, &pad_to);
 		}
-		free(fi);
+
+		cs_next = SPLAY_NEXT(xt, &ptree, cs);
+		SPLAY_REMOVE(xt, &ptree, cs);
+		free(cs);
 	    } else {
 		break;
 	    }
 	}
     }
 
-    /* Flush the rest of queues */
-    while (NULL != (fi = fifo_queue_head(fq))) {
-	fifo_queue_pop(fq);
-	if ((fi->r.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISANNO) {
-	    sam_export_cons_tag(io, bf, fi, c, offset,
-				depad, cons+1, &npads, &pad_to);
+    for (cs = SPLAY_MIN(xt, &ptree); cs; cs = cs_next) {
+	cs_next = SPLAY_NEXT(xt, &ptree, cs);
+
+	if ((cs->r.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISANNO) {
+		    sam_export_cons_tag(io, bf, cs, c, offset,
+					depad, cons+1, &npads, &pad_to);
 	} else {
-	    sam_export_seq(io, bf, fi, tq, fixmates, crec, c, offset,
+	    sam_export_seq(io, bf, cs, tq, fixmates, crec, c, offset,
 			   depad, cons+1, &npads, &pad_to);
 	}
-	free(fi);
-    }
 
-    fifo_queue_destroy(fq);
+	SPLAY_REMOVE(xt, &ptree, cs);
+	free(cs);
+    }
+	    
     fifo_queue_destroy(tq);
 
     contig_iter_del(ci);
@@ -1989,13 +2240,79 @@ static int export_contig_ace(GapIO *io, FILE *fp,
 }
 
 /*
+ * Converts a padded consensus sequence into a reference sequence using
+ * the refpos array markers.
+ *
+ * The existing seq is passed in with length end-start+1.
+ *
+ * Returns a new malloced sequence of length *len on success
+ *         NULL on failure
+ */
+static char *ref_pad_seq(GapIO *io, tg_rec crec, int start, int end,
+			 char *seq_in, int *len) {
+    char *seq_out;
+    int *rpos;
+    int min, max, last, i, j;
+
+    if (!(rpos = calloc(end - start + 1, sizeof(int))))
+	return NULL;
+
+    // Compute padded_pos to reference_pos mapping
+    if (padded_to_reference_array(io, crec, start, end, rpos, NULL,
+				  NULL, NULL) != 0) {
+	free(rpos);
+	return NULL;
+    }
+
+
+    // Determine if mapping is valid (low->high with no discontinuities.
+    // Also find min/max values
+    max = last = INT_MIN;
+    min = INT_MAX;
+    for (i = 0; i < end-start+1; i++) {
+	if (rpos[i] == INT_MIN)
+	    continue;
+	if (min > rpos[i])
+	    min = rpos[i];
+	if (max < rpos[i])
+	    max = rpos[i];
+
+	if (rpos[i] < last)
+	    return NULL;
+    }
+
+    *len = max-min+1;
+    seq_out = malloc(*len);
+    if (!seq_out) {
+	free(rpos);
+	return NULL;
+    }
+
+    // Transcribe consensus.
+    last = min-1;
+    for (i = j = 0; i < end-start+1; i++) {
+	if (rpos[i] == INT_MIN)
+	    continue;
+	while (rpos[i] - last > 1)
+	    seq_out[j++] = 'N', last++;
+	seq_out[j++] = seq_in[i] == '*' ? 'N' : seq_in[i];
+	last = rpos[i];
+    }
+    assert(j == *len);
+
+    free(rpos);
+    return seq_out;
+}
+
+/*
  * Saves the consensus to <fn>.fasta and creates a samtools style
  * <fn>.fasta.fai index.
  *
  * Returns <fn>.fasta on success
  *         NULL on failure
  */
-static char *create_ref_seq(GapIO *io, int cc, contig_list_t *cv, char *fn) {
+static char *create_ref_seq(GapIO *io, int cc, contig_list_t *cv, char *fn,
+			    int depad) {
     static char fn1[PATH_MAX], fn2[PATH_MAX];
     FILE *fp1 = NULL, *fp2 = NULL;
     int i;
@@ -2012,7 +2329,7 @@ static char *create_ref_seq(GapIO *io, int cc, contig_list_t *cv, char *fn) {
     for (i = 0; i < cc; i++) {
 	char *seq = NULL;
 	contig_t *c;
-	int len;
+	int len, len_N;
 
 	if (!(c = cache_search(io, GT_Contig, cv[i].contig)))
 	    goto err;
@@ -2029,53 +2346,75 @@ static char *create_ref_seq(GapIO *io, int cc, contig_list_t *cv, char *fn) {
 	    free(seq);
 	}
 
-	depad_seq(seq, &len, NULL);
+	switch (depad) {
+	case 0:
+	    break;
+
+	case 1:
+	    depad_seq(seq, &len, NULL);
+	    break;
+	    
+	case 2: {
+	    char *rseq;
+	    rseq = ref_pad_seq(io, cv[i].contig, cv[i].start, cv[i].end,
+			       seq, &len);
+	    free(seq);
+	    if (!rseq)
+		goto err;
+	    seq = rseq;
+	    break;
+	}
+	}
 
 	offset += fprintf(fp1, ">%s\n", contig_get_name(&c));
+	len_N = 0;
 	if (cv[i].start > 1) {
 	    int n = cv[i].start - 1;
 	    while (n > 0) {
 		int l = MIN(1024, n);
-		offset += fwrite("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
-				 "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-				 1, l, fp1);
+		int w;
+		w = fwrite("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
+			   "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+			   1, l, fp1);
+		len_N  += w;
 		n -= l;
 	    }
 	}
 
-	fprintf(fp2, "%s\t%d\t%"PRId64"\t%d\t%d\n",
-		contig_get_name(&c), len, offset, len, len+1);
+	fprintf(fp2, "%s\t%d\t%"PRId64"\t%d\t%d\n", contig_get_name(&c),
+		len+len_N, offset, len+len_N, len+len_N+1);
 
+	offset += len_N;
 	offset += fprintf(fp1, "%.*s\n", len, seq);
 	    
 	cache_decr(io, c);
@@ -2119,7 +2458,7 @@ static int export_contigs(GapIO *io, int cc, contig_list_t *cv, int format,
 
     case FORMAT_CRAM:
 	/* Create fasta reference first */
-	if (!(ref_fn = create_ref_seq(io, cc, cv, fn))) {
+	if (!(ref_fn = create_ref_seq(io, cc, cv, fn, depad))) {
 	    perror(fn);
 	    return -1;
 	}
@@ -2150,7 +2489,7 @@ static int export_contigs(GapIO *io, int cc, contig_list_t *cv, int format,
     case FORMAT_SAM:
     case FORMAT_BAM:
     case FORMAT_CRAM:
-	export_header_sam(io, bf, cc, cv, fixmates, ref_fn, format);
+	export_header_sam(io, bf, cc, cv, fixmates, depad, ref_fn, format);
 	break;
     }
 
@@ -2427,12 +2766,11 @@ static int export_tags_gff(GapIO *io, FILE *fp,
 	    char key[1024], val[8192];
 	    size_t key_len, val_len;
 
-	    printf("ACD TAG with comm %s\n", a->comment ? a->comment : "(null)");
+	    //printf("ACD TAG with comm %s\n", a->comment ? a->comment : "(null)");
 	    while (NULL != (cp = parse_acd_tag(cp,
 					       key, (key_len=1024, &key_len),
 					       val, (val_len=8192, &val_len)))){
-		printf("Key='%.*s' val='%.*s'\n",
-		       (int) key_len, key, (int) val_len, val);
+		//printf("Key='%.*s' val='%.*s'\n", (int) key_len, key, (int) val_len, val);
 		if (key_len == 5 && strncmp(key, "score", 5) == 0) {
 		    if ((val_len > 0) &&
 			(*val == '+' || *val == '-' || isdigit(*val))) {
diff --git a/gap5/export_contigs.tcl b/gap5/export_contigs.tcl
index 2672490..e23c532 100644
--- a/gap5/export_contigs.tcl
+++ b/gap5/export_contigs.tcl
@@ -36,7 +36,6 @@ proc ExportSequences {io} {
 	     [list fastq -command "ExportSequences_format $io $f"] \
 	     [list fasta -command "ExportSequences_format $io $f"]]
 	
-
     #--- Output options
     checkbutton $f.fixmates \
 	-text "Fix mate-pair information (CRAM/SAM/BAM only)" \
@@ -45,13 +44,24 @@ proc ExportSequences {io} {
     global $f.FixMates
     set $f.FixMates [keylget gap5_defs EXPORT.FIX_MATES] \
 
-    checkbutton $f.depad \
-	-text "Use depadded coordinates (CRAM/SAM/BAM only)" \
-	-variable $f.Depad \
-	-anchor w
-    global $f.Depad
-    set $f.Depad [keylget gap5_defs EXPORT.DEPAD] \
-
+#     radiolist $f.depad \
+# 	-title "CRAM/SAM/BAM padding variety" \
+# 	-default 2 \
+# 	-orient vertical \
+# 	-buttons [list \
+# 		      [list "Padded consensus coordinates"] \
+# 		      [list "Unpadded consensus coordinates (CRAM/SAM/BAM)"] \
+# 		      [list "Original reference coordinates (CRAM/SAM/BAM)"]]
+
+    xradiobox $f.depad \
+	-labeltext "CRAM/SAM/BAM padding variety:" \
+	-orient vertical \
+	-relief groove
+    $f.depad add 0 -text "Padded consensus coordinates"
+    $f.depad add 1 -text "Unpadded consensus coordinates"
+    $f.depad add 2 -text "Original reference coordinates"
+    $f.depad select [keylget gap5_defs EXPORT.DEPAD]
+			   
     #--- OK/cancel/help
     okcancelhelp $f.ok \
 	-ok_command "ExportSequences2 $io $f" \
@@ -102,7 +112,7 @@ proc ExportSequences2 {io f} {
     }
 
     export_contigs -io $io -contigs $list -format $format -outfile $fn \
-	-fixmates [set $f.FixMates] -depad [set $f.Depad]
+	-fixmates [set $f.FixMates] -depad [$f.depad get]
     destroy $f
 }
 
diff --git a/gap5/export_snps.c b/gap5/export_snps.c
new file mode 100644
index 0000000..559bbdb
--- /dev/null
+++ b/gap5/export_snps.c
@@ -0,0 +1,350 @@
+/*
+ * NOTE: This is experimental and is here simply for purposes of evaluating
+ * how well Gap5's consensus algorithm and shuffle pads is working. It has hard
+ * coded values and contig names (eg "chr20") and is not suitable yet as a
+ * general purpose VCF generator. It also has bugs in the output when dealing
+ * with compound SNPs/Indels.
+ */
+
+/* ------------------------------------------------------------------------
+ * export_snps implementation.
+ *
+ * This computes the consensus in heterozygous mode and then generates a
+ * VCF file of the heterozygous differences.  Homozygous differences require
+ * an external reference to call, which isn't yet utilised.
+ */
+
+#include <staden_config.h>
+
+#include <tcl.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include <tg_gio.h>
+#include "misc.h"
+#include "export_snps.h"
+#include "gap_cli_arg.h"
+#include "list_proc.h"
+#include "xalloc.h"
+#include "consensus.h"
+#include "dstring.h"
+#include <io_lib/cram.h>
+
+static int export_snps(GapIO *io, int cc, contig_list_t *cv,
+		       int depad, char *fn, char *fai);
+
+typedef struct {
+    GapIO *io;
+    char *inlist;
+    char *outfile;
+    char *fai;
+    int   unpadded;
+} es_arg;
+
+int tcl_export_snps(ClientData clientData, Tcl_Interp *interp,
+		    int objc, Tcl_Obj *CONST objv[])
+{
+    int rargc, res;
+    contig_list_t *rargv;
+    es_arg args;
+    cli_args a[] = {
+	{"-io",		ARG_IO,  1, NULL,     offsetof(es_arg, io)},
+	{"-contigs",	ARG_STR, 1, NULL,     offsetof(es_arg, inlist)},
+	{"-outfile",    ARG_STR, 1, "out.vcf",offsetof(es_arg, outfile)},
+	{"-fai",        ARG_STR, 1, "",       offsetof(es_arg, fai)},
+	{"-unpadded",   ARG_INT, 1, "1",      offsetof(es_arg, unpadded)},
+	{NULL,	    0,	     0, NULL, 0}
+    };
+
+    if (-1 == gap_parse_obj_args(a, &args, objc, objv))
+	return TCL_ERROR;
+
+    active_list_contigs_extended(args.io, args.inlist, &rargc, &rargv);
+
+    res = export_snps(args.io, rargc, rargv, args.unpadded, args.outfile, args.fai);
+
+    free(rargv);
+
+    return res == 0 ? TCL_OK : -1;
+}
+
+static int export_snps_contig(GapIO *io, tg_rec contig, int start, int end,
+			      int depad, refs_t *ref, FILE *fp) {
+    int *ref_pos = NULL, *ref_id = NULL;
+    unsigned char *cons = NULL;
+    float *qual = NULL, last_qual = 30;
+    int ret = -1, i, start_pos, last_pos, last_id = -1;
+    char *ref_seq = NULL;
+
+    if (!(ref_pos = malloc((end-start+1) * sizeof(int))))
+	goto error;
+
+    if (!(ref_id = malloc((end-start+1) * sizeof(int))))
+	goto error;
+
+    if (!(cons = malloc(end-start+1)))
+	goto error;
+
+    if (!(qual = malloc((end-start+1)*sizeof(*qual))))
+	goto error;
+
+    if (calculate_consensus_simple_het(io, contig, start, end, (char *) cons, qual))
+	goto error;
+
+    if (padded_to_reference_array(io, contig, start, end, ref_pos,
+				  ref_id, &start_pos, NULL))
+	goto error;
+    last_pos = start_pos;
+
+    for (i = 0; i <= end-start; i++) {
+	float score;
+	int j;
+
+	if (ref_pos[i] == INT_MIN) {
+	    char ins[1024];
+	    int upper = isupper(cons[i]);
+	    int len = 0;
+
+	    char ref_base = ref_seq
+		? ref_seq[last_pos - start_pos]
+		: (i ? toupper(cons[i-1]) : 'N');
+	    char con_base = i ? toupper(cons[i-1]) : 'N';
+
+	    score = 0;
+	    while (ref_pos[i] == INT_MIN && i <= end-start) {
+		if (cons[i] != '*' && isupper(cons[i]) == upper) {
+		    ins[len++] = toupper(cons[i]);
+		    score += qual[i];
+		}
+		i++;
+	    }
+	    i--;
+	    if (len) {
+		if (upper)
+		    //fprintf(fp, "%d\tINS %d %.*s\t%.0f\n", last_pos, len,
+		    //	    len,ins, score/len);
+		    fprintf(fp,
+			    "chr20\t%d\t.\t%c\t%c%.*s\t%.0f\tPASS\t.\tGT\t1/1\n",
+			    last_pos,
+			    ref_base, con_base,
+			    len,ins, score/len);
+		else
+		    //fprintf(fp, "%d\tins %d %.*s\t%.0f\n", last_pos, len,
+		    //	    len,ins, score/len);
+		    fprintf(fp,
+			    "chr20\t%d\t.\t%c\t%c%.*s\t%.0f\tPASS\t.\tGT\t0/1\n",
+			    last_pos,
+			    ref_base, con_base,
+			    len,ins, score/len);
+	    }
+	    continue;
+
+	} else {
+	    //if (ref_id[i] != last_id) {
+	    if (last_id != 20) {
+		if (ref && ref->fp) {
+		    ref_entry *e;
+		    //e = ref->ref_id[ref_id[i]];
+		    e = ref->ref_id[22]; // HACK FOR TESTING
+		    printf("Loading %d..%d\n", start_pos, (int)e->length);
+		    ref_seq = load_ref_portion(ref->fp, e, start_pos, e->length);
+		}
+
+		//last_id = ref_id[i];
+		last_id = 20;
+		for (j = i; ref_pos[j] == INT_MIN; j--) ;
+		last_pos = ref_pos[j]-1;
+	    }
+
+	    if (ref_pos[i] > last_pos+1 || cons[i] == '*') {
+		char ref_base = ref_seq
+		    ? ref_seq[last_pos - start_pos]
+		    : (i ? toupper(cons[i-1]) : 'N');
+		char con_base = i ? toupper(cons[i-1]) : 'N';
+
+		while (cons[i] == '*' && i <= end-start)
+		    i++;
+		//fprintf(fp, "%d\tDEL %d %.*s\t%.0f\n", last_pos,
+		//	ref_pos[i]-(last_pos+1),
+		//	ref_pos[i]-(last_pos+1), ref_seq + last_pos+1-start_pos,
+		//	(last_qual+qual[i])/2);
+		fprintf(fp, "chr20\t%d\t.\t%c%.*s\t%c\t%.0f\tPASS\t.\tGT\t1/1\n",
+			last_pos, ref_base, 
+			ref_pos[i]-(last_pos+1), ref_seq + last_pos+1-start_pos,
+			con_base,
+			(last_qual+qual[i])/2);
+		//if (i && cons[i-1] == '*') i--;
+	    }
+	}
+
+	switch(cons[i]) {
+	    #define _A 'A'
+	    #define _C 'C'
+	    #define _G 'G'
+	    #define _T 'T'
+	    static char B1[] = {
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 00
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 10
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 20
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 30
+	     //    A  B  C   D  E  F  G   H  I  J  K   L  M  N  O
+		0,_A,_C,_C, _A, 0, 0,_G, _A, 0, 0,_G,  0,_A,_A, 0, // 40
+	     // P  Q  R  S   T  U  V  W   X  Y  Z
+		0, 0,_A,_C, _T,_T,_A,_A,  0,_C, 0, 0,  0, 0, 0, 0, // 50
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 60
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 70
+	    };
+	    static char B2[] = {
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 00
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 10
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 20
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 30
+	     //    A  B  C   D  E  F  G   H  I  J  K   L  M  N  O
+		0,_A,_G,_C, _G, 0, 0,_G, _C, 0, 0,_T,  0,_C,_C, 0, // 40
+	     // P  Q  R  S   T  U  V  W   X  Y  Z
+		0, 0,_G,_G, _T,_T,_C,_T,  0,_T, 0, 0,  0, 0, 0, 0, // 50
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 60
+		0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0, // 70
+	    };
+	    char b1, b2, r;
+
+	case 'A': case 'C': case 'G': case 'T':
+	    if (ref_seq && ref_seq[ref_pos[i] - start_pos] != cons[i]) {
+		//fprintf(fp, "%d\tHOM %c %c\t%.0f\n", ref_pos[i],
+		//	ref_seq[ref_pos[i] - start_pos], cons[i], qual[i]);
+		fprintf(fp, "chr20\t%d\t.\t%c\t%c\t%.0f\tPASS\t.\tGT\t1/1\n",
+			ref_pos[i],
+			ref_seq[ref_pos[i] - start_pos], toupper(cons[i]), qual[i]);
+	    }
+	    break;
+
+	case 'M':
+	case 'R':
+	case 'W':
+	case 'S':
+	case 'Y':
+	case 'K':
+	    b1 = B1[cons[i]];
+	    b2 = B2[cons[i]];
+	    r = toupper(ref_seq[ref_pos[i] - start_pos]);
+	    //fprintf(fp, "%d\tHET %c ", ref_pos[i], r);
+	    fprintf(fp, "chr20\t%d\t.\t%c\t", ref_pos[i], r);
+	    if (b1 == r)	
+		//fprintf(fp, "%c\t%.0f\n", b2, qual[i]);
+		fprintf(fp, "%c\t%.0f\tPASS\t.\tGT\t0/1\n", b2, qual[i]);
+	    else if (b2 == r)
+		//fprintf(fp, "%c\t%.0f\n", b1, qual[i]);
+		fprintf(fp, "%c\t%.0f\tPASS\t.\tGT\t0/1\n", b1, qual[i]);
+	    else
+		//fprintf(fp, "%c,%c\t%.0f\n", b1,b2, qual[i]);
+		fprintf(fp, "%c,%c\t%.0f\tPASS\t.\tGT\t1/2\n", b1,b2, qual[i]);
+	    break;
+
+	case 'N':
+	    //fprintf(fp, "%d\tunknown-call\n", ref_pos[i]);
+	    break;
+
+	case 'a':
+	case 'c':
+	case 'g':
+	case 't': {
+	    int len = 0, j;
+	    float score = 0;
+
+	    //char ref_base = ref_seq
+	    //	? ref_seq[last_pos - start_pos]
+	    //	: (i ? toupper(cons[i-1]) : 'N');
+	    char con_base = i ? toupper(cons[i-1]) : 'N';
+
+	    // heterozygous deletion, see how long
+	    // Assuming it's a simple case, track how many [acgt] match the ref
+	    // and produce xACGT->x 0/1 call.
+	    while (islower(cons[i]) &&
+		   ref_pos[i] != INT_MIN &&
+		   toupper(cons[i]) == ref_seq[ref_pos[i] - start_pos] &&
+		   i <= end-start)
+		score+=qual[i], i++;
+
+	    
+	    for (j=i; ref_pos[j] == INT_MIN; j--)
+		;
+	    len = ref_pos[j] - last_pos + i-j;
+
+	    //fprintf(fp, "%d\tdel %.*s %.0f\n", last_pos,
+	    //	    len, &ref_seq[last_pos - start_pos],
+	    //	    score/len);
+	    fprintf(fp, "chr20\t%d\t.\t%.*s\t%c\t%.0f\tPASS\t.\tGT\t0/1\n",
+		    last_pos, len, &ref_seq[last_pos - start_pos],
+		    con_base, score/len);
+	    
+	    //if (len) i--;
+	    break;
+	}
+	}
+
+	for (j = i; ref_pos[j] == INT_MIN; j--) ;
+	last_pos = ref_pos[j];
+	last_qual = qual[j];
+
+	// Homozygous deletion+change?
+	// Ref = GAAT. Seqs = GCCT + GT
+	// GAAT -> GCCT,GT  1/2
+
+	// What about compound homozygous + heterozygous deletion?
+	// Ie one allele losing 3bp and the other losing 6bp.
+	//
+	// GTCTAAA -> GTCT,G 1/2
+
+	// Also compound deletion + insertion?
+	// GTCT -> G     1/1
+	// G    -> GACC  1/1
+	// Or is it just 3 SNPs in a row?
+    }
+
+    ret = 0;
+ error:
+    if (ref_pos)
+	free(ref_pos);
+
+    if (ref_id)
+	free(ref_id);
+
+    if (cons)
+	free(cons);
+
+    if (qual)
+	free(qual);
+
+    return ret;
+}
+
+static int export_snps(GapIO *io, int cc, contig_list_t *cv,
+		       int depad, char *fn, char *fai) {
+    int i, r = 0;
+    FILE *fp;
+    refs_t *refs = NULL;
+
+    fp = fopen(fn, "w");
+    if (!fp)
+	return -1;
+    
+    fprintf(fp, "##fileformat=VCFv4.0\n");
+    fprintf(fp, "##source=VCFWriter\n");
+    fprintf(fp, "##INFO=<ID=OP,Number=1,Type=Integer,Description=\"Original position before normalization\">\n");
+    fprintf(fp, "##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">\n");
+    fprintf(fp, "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tgap5\n");
+
+    if (fai && *fai)
+	refs = refs_load_fai(NULL, fai, 1);
+
+    for (i = 0; i < cc; i++) {
+	r |= export_snps_contig(io, cv[i].contig, cv[i].start, cv[i].end,
+				depad, refs, fp);
+    }
+
+    fclose(fp);
+    if (refs)
+	refs_free(refs);
+
+    return r;
+}
diff --git a/gap5/export_snps.h b/gap5/export_snps.h
new file mode 100644
index 0000000..0d56495
--- /dev/null
+++ b/gap5/export_snps.h
@@ -0,0 +1,9 @@
+#ifndef _EXPORT_SNPS_H_
+#define _EXPORT_SNPS_H_
+
+#include <tcl.h>
+
+int tcl_export_snps(ClientData clientData, Tcl_Interp *interp,
+		       int objc, Tcl_Obj *CONST objv[]);
+
+#endif /* _EXPORT_SNPS_H_ */
diff --git a/gap5/fasta.c b/gap5/fasta.c
index 9565267..f52a555 100644
--- a/gap5/fasta.c
+++ b/gap5/fasta.c
@@ -19,7 +19,7 @@
 #include "text_output.h"
 #include "tg_gio.h"
 #include "tg_index_common.h"
-#include "zfio.h"
+#include "io_lib/zfio.h"
 #include "fasta.h"
 
 #define HDR_FASTA '>'
@@ -290,7 +290,7 @@ int parse_fasta_or_fastq(GapIO *io, char *fn, tg_args *a, int format) {
 	seq.conf = dummy_qual;
 	assert(seq.conf);
 
-	if (ent.qual) {
+	if (ent.qual && a->qual < 0) {
 	    int i;
 	    for (i = 0; i < ent.seq_len; i++) {
 		int q = ent.qual[i] - '!';
@@ -302,7 +302,7 @@ int parse_fasta_or_fastq(GapIO *io, char *fn, tg_args *a, int format) {
 	    }
 	} else {
 	    assert(dummy_qual);
-	    memset(dummy_qual, 0, dummy_qual_len);
+	    memset(dummy_qual, ABS(a->qual), dummy_qual_len);
 	}
 
 	seq.trace_name     = NULL;
diff --git a/gap5/fij.c b/gap5/fij.c
index 74ee976..e7971cf 100644
--- a/gap5/fij.c
+++ b/gap5/fij.c
@@ -27,7 +27,7 @@ static int auto_join(GapIO *io, mobj_fij *r);
 
 void *fij_obj_func(int job, void *jdata, obj_fij *obj,
 		      mobj_fij *fij) {
-    static char buf[80];
+    static char buf[160];
     obj_cs *cs;
     int cs_id;
 
@@ -123,14 +123,10 @@ void *fij_obj_func(int job, void *jdata, obj_fij *obj,
 
 	case 4: /* Invoke contig editors */ {
 	    tg_rec cnum;
-	    int pos, reveal;
+	    int pos;
 	    
 	    cnum  = ABS(obj->c1);
 	    pos   = obj->pos1;
-	    reveal= (obj->pos1 <= 0 ||
-		     obj->pos2 <= 0 ||
-		     obj->pos1 >= io_clength(fij->io, ABS(obj->c1)) ||
-		     obj->pos2 >= io_clength(fij->io, ABS(obj->c2))) ? 1 : 0;
 
 	    edit_contig(fij->io, cnum, 0, pos);
 
@@ -773,7 +769,7 @@ fij(fij_arg *fij_args,
     GapIO *io = fij_args->io;
     char *consensus = NULL;
     mobj_fij *FIJMatch = NULL;
-    int id;
+    int id = 0;
     char *val;
     Contig_parms *contig_list = NULL;
     contig_list_t *combined = NULL;
@@ -894,6 +890,8 @@ fij(fij_arg *fij_args,
     FIJMatch->match_type = REG_TYPE_FIJ;
     FIJMatch->max_mismatch = fij_args->max_mis;
     FIJMatch->min_length = fij_args->min_match;
+    FIJMatch->min_overlap = fij_args->min_overlap;
+    FIJMatch->max_overlap = fij_args->max_overlap;
 
     /* Filter matches */
     if (fij_args->unique_ends)
@@ -1034,6 +1032,14 @@ static int auto_join(GapIO *io, mobj_fij *r) {
 	    continue;
 	}
 
+	/* Check that the predicted overlapLength falls within the specified
+	 * maximum size range, to avoid potential huge alignments.
+	 */
+	if (overlapLength >= r->max_overlap) {
+	    vmessage("Skipping as predicted alignment length is too large.\n");
+	    continue;
+	}
+
 	/* Double check to avoid any bugs above. Must touch edges */
 	if (left1 > l1 && left2 > l2) {
 	    vmessage("BUG: Found local alignment - forcing to be global.\n");
@@ -1077,11 +1083,16 @@ static int auto_join(GapIO *io, mobj_fij *r) {
 	}
 
 	/* Check the alignment is still acceptable */
-	if (a->match_len < r->min_length) {
+	if (a->match_len < r->min_overlap) {
 	    vmessage("Skipping join as match too short.\n");
 	    alignment_free(a);
 	    continue;
 	}
+	if (a->match_len > r->max_overlap) {
+	    vmessage("Skipping join as match too long.\n");
+	    alignment_free(a);
+	    continue;
+	}
 
 	if (100 - 100.0*a->match_count / a->match_len > r->max_mismatch) {
 	    vmessage("Skipping join as percentage mismatch too high.\n");
diff --git a/gap5/fij.tcl b/gap5/fij.tcl
index e3b5e8a..d8cb629 100644
--- a/gap5/fij.tcl
+++ b/gap5/fij.tcl
@@ -143,6 +143,31 @@ proc FIJDialog { w io } {
     pack $f.hidden.options -side top -anchor w
 
 
+    #--- select mode
+    SetDefaultTags FIJ.TAGS
+
+    labelframe $f.sel_mode -text "Consensus masking"
+    button $f.sel_mode.but \
+	    -text "Select tags" \
+	    -command "TagDialog FIJ.TAGS $f[keylget gap5_defs SELECT_TAGS.WIN] {}"
+
+    radiolist $f.sel_mode.l \
+	    -bd 0 \
+            -title "Remove tagged sequence" \
+	    -orient horizontal \
+	    -default [keylget gap5_defs FIJ.SELMODE.VALUE]\
+	    -buttons [format {
+		{None -command { %s configure -state disabled}} \
+		{Mark -command { %s configure -state normal; \
+		                SetDefaultTags %s } } \
+		{Mask -command { %s configure -state normal; \
+				SetDefaultTags %s } } } \
+	    [list $f.sel_mode.but] \
+	    [list $f.sel_mode.but] FIJ.TAGS \
+	    [list $f.sel_mode.but] FIJ.TAGS ]
+    pack $f.sel_mode.l -side top -fill x
+    pack $f.sel_mode.but -side top -anchor w
+
     #---- select word length
     set st [keylget gap5_defs FIJ.WORDLENGTH]
     set b1 [keylget st BUTTON.1]
@@ -255,6 +280,7 @@ proc FIJDialog { w io } {
     pack $f.blocks -fill x
     pack $f.location -fill x
     pack $f.hidden -fill x
+    pack $f.sel_mode -fill x
     pack $f.padding1
     pack $f.s -fill x
     pack $f.padding2
@@ -399,41 +425,13 @@ proc FIJDialog { w io } {
     pack $f.rp -fill x
 
 
-#    ###########################################################################
-#    #select mode
-#    SetDefaultTags FIJ.TAGS
-#
-#    set sm [keylget gap5_defs FIJ.SELMODE]
-#    set b1 [keylget sm BUTTON.1]
-#    set b2 [keylget sm BUTTON.2]
-#    set b3 [keylget sm BUTTON.3]
-#    frame $f.sel_mode -bd 2 -relief groove
-#    button $f.sel_mode.but \
-#	    -text "Select tags" \
-#	    -command "TagDialog FIJ.TAGS $f[keylget gap5_defs SELECT_TAGS.WIN] \
-#			{}"
-#
-#    radiolist $f.sel_mode.rl \
-#	    -title [keylget sm NAME] \
-#	    -default [keylget sm VALUE]\
-#	    -buttons [format { \
-#	    {%s -command { %s configure -state disabled}} \
-#	    { %s -command { %s configure -state normal; \
-#	    SetDefaultTags %s }} \
-#	    { %s -command { %s configure -state normal; \
-#	    SetDefaultTags %s } } } \
-#	    [list $b1] [list $f.sel_mode.but] \
-#	    [list $b2] [list $f.sel_mode.but] FIJ.TAGS \
-#	    [list $b3] [list $f.sel_mode.but] FIJ.TAGS ]
-#    pack $f.sel_mode.rl -side left
-#    pack $f.sel_mode.but -side right
-
     ###########################################################################
     #OK and Cancel buttons
     okcancelhelp $w.ok_cancel \
 	-ok_command "FIJ_OK_Pressed $w $io $w.ops \
                     $f_i.l1.infile1 $f_i.l1.id1 $f_i.l2.infile2 $f_i.l2.id2 \
-                    $f_s.word_length $f_s.blocks $f_s.location $f_f.rp.mode" \
+                    $f_s.word_length $f_s.blocks $f_s.location $f_s.sel_mode.l\
+                    $f_f.rp.mode" \
 	-cancel_command "destroy $w" \
 	-help_command "show_help gap5 {FIJ-Dialogue}" \
 	-bd 2 \
@@ -476,7 +474,7 @@ proc FIJ_config_contig_ids { f id { state unchanged } } {
 
 ###########################################################################
 proc FIJ_OK_Pressed { f io aname infile1 id1 infile2 id2 
-		      word_length blocks location rp_mode } {
+		      word_length blocks location sel_mode rp_mode } {
     
     global CurContig
     global LREG
@@ -540,6 +538,12 @@ proc FIJ_OK_Pressed { f io aname infile1 id1 infile2 id2
 
     set ends         [expr {[radiolist_get $location]&1}]
     set containments [expr {([radiolist_get $location]&2)==2}]
+    set masking      [radiolist_get $sel_mode]
+    if {($masking == 2) || ($masking == 3)} {
+        set active_tags [GetDefaultTags FIJ.TAGS]
+    } else {
+	set active_tags {}
+    }
 
     if {$data(use_filter) == 0} {
 	set filter_words 0
@@ -558,6 +562,8 @@ proc FIJ_OK_Pressed { f io aname infile1 id1 infile2 id2
 
     SetBusy
     set id [log_call find_internal_joins \
+		-mask [lindex {"" none mark mask} $masking] \
+		-tag_types $active_tags \
 		-io            $io \
 		-min_overlap   $data(min_overlap) \
 		-max_overlap   $data(max_overlap) \
diff --git a/gap5/find_haplotypes.0.c b/gap5/find_haplotypes.0.c
new file mode 100644
index 0000000..4cd293e
--- /dev/null
+++ b/gap5/find_haplotypes.0.c
@@ -0,0 +1,456 @@
+/*
+ * ---------------------------------------------------------------------------
+ * Identifies SNP sites and forms haplotypes from these by linking SNPs
+ * together based on spanning readings. 
+ *
+ * This isn't as advanced as Gap4's solution, having no knowledge of
+ * read-pairs and no reverse correlation (only 2 haplotypes, so lack of
+ * presence on one implies the other), but Gap4's version is very slow.
+ * Here we take a quick and dirty approach.
+ *
+ * - Find primary SNPs and add to haplotype_pos array
+ *   Primary SNPs are the two main alleles only; b1 and b2 bases.
+ *
+ * - Find reads covering SNPs and (if matching b1/b2) and increment
+ *   l_b1, l_b2 counters.
+ *
+ * - Extract primary links from haplotype_pos[] array, nulling the
+ *   weak ones. (Forming haplotype-contigs.)
+ *
+ * FAIL: if we have mix of real SNPs and some error-rich regions, we need
+ * to tease out real SNPs from errors, so daisy chaining left to right is
+ * not sufficient.   Need NxN linkage matrix instead?
+ *
+ * Try 2:
+ *
+ * Foreach SNP of A/B alleles, assign them arbitrarily.
+ *
+ * Foreach read
+ *     Foreach pair of SNP base covered, increment counters of A/B
+ *     (4 reads may give 0/4 or 4/0 if all consistent, or something like
+ *      1/3 2/2 or 3/1 if inconsistent.)
+ *
+ * Foreach SNP, compute ratio of SUM(MIN(A,B)) / SUM(MAX(A,B)).  Any SNP which
+ *    has, say, > 0.5 ratio can be removed as conflicting. (Needs recomputation
+ *    of neighbouring ones then? That makes it O(N^3) instead of O(N^2)?)
+ *
+ * Cruder try 3:
+ *
+ * Foreach neighbouring position (not N vs N, just neighbours), count
+ * purity of matching reads to prev/next SNP.  Eg bin A/A A/B B/A B/B counts.
+ * For correct cases we expect A/A+B/B or A/B+B/A to be high but not the
+ * other combinations.  If left is bad and right not or vice versa then
+ * maybe it is OK, but if both are bad then we probably have a false SNP.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "misc.h"
+#include "find_haplotypes.h"
+#include "consensus.h"
+#include "align.h"
+
+/*
+ * A simple linked list of haplotypic sites, forming a doubly linked list so we can easily remove from it.
+ */
+typedef struct haplotype_pos {
+    char b1, b2;         // bases 1 and 2
+    int pos;             // pos
+    int score[2];        // score based on links to prev/next.
+    int same, opp, mis;  // counts of match/mismatch with next haplotype
+    struct haplotype_pos *prev, *next;
+} haplotype_pos;
+
+int add_haplotype_pos(haplotype_pos **phead, haplotype_pos **ptail,
+		      int pos, int b1, int b2) {
+    haplotype_pos *p = calloc(1, sizeof(*p));
+    if (!p)
+	return -1;
+
+    p->pos = pos;
+    p->b1  = b1;
+    p->b2  = b2;
+
+    if (*ptail) {
+	(*ptail)->next = p;
+	p->prev = *ptail;
+	*ptail = p;
+    } else {
+	*phead = *ptail = p;
+    }
+
+    return 0;
+}
+
+void del_haplotype_pos(haplotype_pos **phead, haplotype_pos **ptail,
+		       haplotype_pos *p) {
+    if (p == *phead)
+	*phead = p->next;
+    else
+	p->prev->next = p->next;
+
+    if (p == *ptail)
+	*ptail = p->prev;
+    else
+	p->next->prev = p->prev;
+
+    free(p);
+}
+
+
+static int find_haplotypes_single(GapIO *io, tg_rec crec, int start, int end) {
+    consensus_t *cons = NULL;
+    int ret = -1, i;
+    haplotype_pos *phead = NULL, *ptail = NULL;
+    int pass;
+    rangec_t *rng = NULL;
+    int nr;
+    contig_t *c;
+
+    // Accumulate a list of haplotypes
+    if (!(cons = calloc(end-start+1, sizeof(*cons))))
+	goto err;
+
+    if (-1 == calculate_consensus(io, crec, start, end, cons))
+	goto err;
+
+    for (i = start; i <= end; i++) {
+	if (cons[i-start].scores[6]>0) {
+	    printf("Pos %5d: het %c/%c  score %d\n",
+		   i,
+		   "ACGT*"[cons[i-start].het_call / 5],
+		   "ACGT*"[cons[i-start].het_call % 5],
+		   (int)cons[i-start].scores[6]);
+
+	    add_haplotype_pos(&phead, &ptail, i,
+			      "ACGT*"[cons[i-start].het_call / 5],
+			      "ACGT*"[cons[i-start].het_call % 5]);
+	}
+    }
+
+    c = cache_search(io, GT_Contig, crec);
+    if (!c)
+	goto err;
+
+    rng = contig_seqs_in_range(io, &c, start, end,
+			       CSIR_SORT_BY_X | CSIR_SORT_BY_CLIPPED, &nr);
+    if (!rng)
+	goto err;
+
+    pass = 1;
+    while (1) {
+	int changed = -1;
+	printf("\n=== Pass %d ===\n", pass);
+
+	{
+	    haplotype_pos *p;
+
+	    for (p = phead; p; p = p->next) {
+		p->same = p->opp = p->mis = p->score[0] = p->score[1] = 0;
+	    }
+	}
+
+	// Accumulate haplotypes
+	{
+	    rangec_t *r;
+	    haplotype_pos *p1, *p2;
+	    int i;
+
+	    p1 = phead;
+	    for (i = 0; i < nr; i++) {
+		rangec_t *r = &rng[i];
+		int left, right;
+		seq_t *s;
+		char b;
+
+		if ((r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISSEQ)
+		    continue;
+
+		s = cache_search(io, GT_Seq, r->rec);
+		if (s->right < s->left)
+		    continue; // ERROR: no unclipped bases.
+
+		if ((s->len < 0) ^ r->comp) {
+		    left = r->start + ABS(s->len) - (s->right-1) - 1;
+		    right = r->start + ABS(s->len) - (s->left-1) - 1;
+		} else {
+		    left = r->start + s->left - 1;
+		    right = r->start + s->right - 1;
+		}
+
+		while (p1 && p1->pos < left)
+		    p1 = p1->next;
+		if (!p1)
+		    break;
+
+		if (right < p1->pos)
+		    continue;
+
+		if ((s->len < 0) ^ r->comp) {
+		    b = complement_base(s->seq[ABS(s->len)-1 - (p1->pos - r->start)]);
+		} else {
+		    b = s->seq[p1->pos - r->start];
+		}
+		for (p2 = p1; p2->next && p2->next->pos <= right; p2 = p2->next) {
+		    char bn;
+		    if ((s->len < 0) ^ r->comp) {
+			bn = complement_base(s->seq[ABS(s->len)-1 - (p2->next->pos - r->start)]);
+		    } else {
+			bn = s->seq[p2->next->pos - r->start];
+		    }
+
+		    //printf("Pos %d, rec %c%"PRIrec", base %c(%c)\n",
+		    //	   p2->pos, "+-"[(s->len < 0) ^ r->comp],
+		    //	   r->rec, b, bn);
+		
+		    if ((p2->b1 == b && p2->next->b1 == bn) ||
+			(p2->b2 == b && p2->next->b2 == bn))
+			p2->same++;
+		    else if ((p2->b1 == b && p2->next->b2 == bn) ||
+			     (p2->b2 == b && p2->next->b1 == bn))
+			p2->opp++;
+		    else
+			p2->mis++;
+
+		    b = bn;
+		}
+	    }
+	}
+
+	// Score haplotypes
+	{
+	    haplotype_pos *p;
+	    int p_score = 0;
+
+	    for (p = phead; p; p = p->next) {
+		int count = p->same + p->opp; // + p->mis?
+		int score = ABS(p->same - p->opp) * ((2.0 * MAX(p->same, p->opp)) / count -1) -  count/2;
+
+		score = score>0 ? sqrt(100*score) : -sqrt(100*-score);
+
+		p->score[0] = p_score;
+		p->score[1] = score;
+
+		printf("Hap %5d %c/%c   score %5d/%5d  count %3d     %3d %3d %3d %c\n",
+		       p->pos, p->b1, p->b2,
+		       p_score, score, count, p->same, p->opp, p->mis,
+		       " .*"[(p->score[0] < 0) + (p->score[1] < 0)]);
+
+		p_score = score;
+	    }
+	}
+
+	// Cull bad haplotypes
+	{
+	    haplotype_pos *p, *pn;
+
+	    for (p = phead; p; p = pn) {
+		pn = p->next;
+
+		if ((pass == 1 &&  p->score[0] < 0 && p->score[1] < 0) ||
+		    (pass == 2 && (p->score[0] < 0 || p->score[1] < 0))) {
+		    del_haplotype_pos(&phead, &ptail, p);
+		    changed = 1;
+		}
+	    }
+	}
+
+	if (changed == -1) {
+	    if (pass == 1)
+		pass = 2;
+	    else
+		break;
+	}
+    }
+
+    // Dump haplotype
+    {
+	int allele;
+	int al = 0;
+	haplotype_pos *p;
+
+	// Allele 2
+	for (p = phead; p; p = p->next) {
+	    putchar(al ? p->b1 : p->b2);
+
+	    if (al) {
+		char tmp = p->b1;
+		p->b1 = p->b2;
+		p->b2 = tmp;
+	    }
+
+	    if (p->score[1] > 0) {
+		al = p->same >= p->opp ? al : 1-al;
+	    } else {
+		putchar(' ');
+		al = 0;
+	    }
+	}
+	putchar('\n');
+
+	// Allele 1
+	for (p = phead; p; p = p->next) {
+	    putchar(p->b1);
+
+	    if (p->score[1] <= 0)
+		putchar(' ');
+	}
+	putchar('\n');
+    }
+
+
+    // Assign reads to haplotypes & build consensus
+    if (0) {
+	rangec_t *r;
+	haplotype_pos *p1, *p2;
+	int i;
+	rangec_t *r1, *r2;
+	int nr1 = 0, nr2 = 0;
+	consensus_t *cons_allele;
+	char *cons1, *cons2;
+
+	r1 = malloc(nr * sizeof(*r1));
+	r2 = malloc(nr * sizeof(*r1));
+
+	cons_allele = malloc((end-start+1) * sizeof(*cons_allele));
+
+	cons1 = malloc(end-start+2);
+	cons2 = malloc(end-start+2);
+
+	p1 = phead;
+	for (i = 0; i < nr; i++) {
+	    rangec_t *r = &rng[i];
+	    int left, right;
+	    seq_t *s;
+	    int a1, a2, an;
+
+	    if ((r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISSEQ)
+		continue;
+
+	    s = cache_search(io, GT_Seq, r->rec);
+	    if (s->right < s->left)
+		continue; // ERROR: no unclipped bases.
+
+	    if ((s->len < 0) ^ r->comp) {
+		left = r->start + ABS(s->len) - (s->right-1) - 1;
+		right = r->start + ABS(s->len) - (s->left-1) - 1;
+	    } else {
+		left = r->start + s->left - 1;
+		right = r->start + s->right - 1;
+	    }
+
+	    while (p1 && p1->pos < left)
+		p1 = p1->next;
+	    if (!p1)
+		break;
+
+	    if (right < p1->pos)
+		continue;
+
+	    a1 = a2 = an = 0;
+	    for (p2 = p1; p2 && p2->pos <= right; p2 = p2->next) {
+		char bn;
+		if ((s->len < 0) ^ r->comp) {
+		    bn = complement_base(s->seq[ABS(s->len)-1 - (p2->pos - r->start)]);
+		} else {
+		    bn = s->seq[p2->pos - r->start];
+		}
+		
+		//printf("Pos %d, rec %c%"PRIrec", base %c (%c %c)\n",
+		//       p2->pos, "+-"[(s->len < 0) ^ r->comp],
+		//       r->rec, bn, p2->b1, p2->b2);
+		
+		if (p2->b1 == bn)
+		    a1++;
+		else if (p2->b2 == bn)
+		    a2++;
+		else
+		    an++;
+	    }
+
+	    if (a1 / .9 > a1+a2+an) {
+		r1[nr1++] = *r;
+		//printf("1: %"PRIrec"\n", r->rec);
+	    } else if (a2 / .9 > a1+a2+an) {
+		r2[nr2++] = *r;
+		//printf("2: %"PRIrec"\n", r->rec);
+	    } else {
+		//printf("?: %"PRIrec"\n", r->rec);
+	    }
+	}
+
+	calculate_consensus_bit_het(io, crec, start, end, 0, r1, nr1, cons_allele);
+	for (i = 0; i <= end-start; i++) {
+	    cons1[i] = "ACGT*N"[cons_allele[i].call];
+//	    if (cons1[i] == 'N')
+//		cons1[i] = "ACGT*N"[cons[i].call];
+	}
+	cons1[i] = 0;
+
+	calculate_consensus_bit_het(io, crec, start, end, 0, r2, nr2, cons_allele);
+	for (i = 0; i <= end-start; i++) {
+	    cons2[i] = "ACGT*N"[cons_allele[i].call];
+//	    if (cons2[i] == 'N')
+//		cons2[i] = "ACGT*N"[cons[i].call];
+	}
+	cons2[i] = 0;
+
+	printf(">allele1\n%s\n>allele2\n%s\n", cons1, cons2);
+
+
+	// Align cons1 to cons2 to see if any shift improves things.
+	// If so it demonstrates the best way to edit our contigs.
+	align_int *S = (align_int *)xcalloc((end-start+1)*2+1, sizeof(*S));
+	calign(cons1, cons2, end-start+1, end-start+1,
+	       NULL, NULL, NULL, NULL,
+	       0, 0, 4, 1,
+	       3, // job. Also see  ALIGN_GAP_[ES][12]
+	       //3 | ALIGN_GAP_E1 | ALIGN_GAP_E2 | ALIGN_GAP_S1 | ALIGN_GAP_S2,
+	       0, S);
+
+	cdisplay(cons1, cons2, end-start+1, end-start+1, 3, S, 1, 1);
+
+	if (*S > 0) {
+	    printf("Shift left by %d\n", *S);
+	} else if (*S < 0) {
+	    printf("Shift right by %d\n", -*S);
+	}
+
+	free(S);
+	free(cons_allele);
+	free(cons1);
+	free(cons2);
+
+	free(r1);
+	free(r2);
+    }
+
+    ret = 0;
+ err:
+    if (cons)
+	free(cons);
+    if (rng)
+	free(rng);
+
+    return ret;
+}
+
+/*
+ * Splits readings into haplotypic groups and also returns haplotype consensus?
+ * Works via lists? Files?
+ *
+ * Returns 0 for success
+ *        -1 for failure
+ */
+int find_haplotypes(GapIO *io, contig_list_t *contigs, int ncontigs) {
+    int i, err = 0;
+
+    for (i = 0; i < ncontigs; i++) {
+	err |= find_haplotypes_single(io, contigs[i].contig,
+				      contigs[i].start, contigs[i].end);
+    }
+
+    return err;
+}
diff --git a/gap5/find_haplotypes.c b/gap5/find_haplotypes.c
new file mode 100644
index 0000000..49e353c
--- /dev/null
+++ b/gap5/find_haplotypes.c
@@ -0,0 +1,891 @@
+/*
+ * ---------------------------------------------------------------------------
+ * Identifies SNP sites and forms haplotypes from these by linking SNPs
+ * together based on spanning readings. 
+ *
+ * Trim anything that maybe dodgy (quality differs to background?).
+ *
+ * Iteratively build up haplotypes. Haplotype is [ACGT*-]+.
+ * Ie a sequence or unknown (-).
+ * A sequence matches a known haplotype if it disagrees with - only.
+ * Eg ---ACGTA--- and ----CGTAC-- align and will be merged.
+ *
+ * For efficiency leading and trailing "-" are run-length encoded.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+#include "misc.h"
+#include "find_haplotypes.h"
+#include "consensus.h"
+#include "align.h"
+#include "array.h"
+#include "interval_tree.h"
+#include "dna_utils.h"
+
+/*
+ * This is an attempt to allow <short-match> to be entirely put into <long-match>
+ * when it is contained within it during haplotype_str_add().  It reduces the
+ * number of things to combine later on, and so speeds up the algorithm.
+ *
+ * Unfortunately it also gives poorer matches as we do not know what is best
+ * to merge until later on.
+ */
+// #define ALLOW_CONTAINMENTS
+
+/*
+ * A string of haplotypic bases. This excludes non-SNP sites
+ */
+typedef struct haplotype_str {
+    struct haplotype_str *next;
+    char *snps;          // string of [ACGT*-]
+    int *count;          // depth of snps[]
+    int nseq;
+    // start by ignoring this and use noddy implementation
+    int start;           // number of leading "-"
+    int end;             // (end-start) = len
+    Array recs;
+} haplotype_str;
+
+/*
+ * Compares 'snps' against the known haplotypes hs[0..n_hs-1].
+ *
+ * If it matches it incorporates it, otherwise it adds a new
+ * haplotype.
+ *
+ * Returns 0 on success;
+ *        -1 on failure.
+ */
+int haplotype_str_add(interval_tree *it, char *snps, int start, int end,
+		      tg_rec rec1, tg_rec rec2) {
+    haplotype_str *tmp;
+    interval_iter *iter = interval_range_iter(it, start, end);
+    interval *hs, *best_hs = NULL;
+    int overlap = 0;
+#ifdef ALLOW_CONTAINMENTS
+    int best_overlap = 0;
+#endif
+    int i;
+
+    for (hs = interval_iter_next(iter); hs; hs = interval_iter_next(iter)) {
+	haplotype_str *tmp = (haplotype_str *)hs->data.p;
+	int i, i_end; // idx to snps
+	int j, j_end; // idx to tmp->snps
+
+#ifndef ALLOW_CONTAINMENTS
+	if (start != tmp->start || end != tmp->end)
+	    continue;
+#endif
+	// absolute positions
+	i     = MAX(tmp->start, start);
+	i_end = MIN(tmp->end, end);
+
+	// relative positions to start
+	j = MAX(0, i - tmp->start);
+	i = MAX(0, i - start);
+
+	j_end = MIN(tmp->end, i_end) - tmp->start;
+	i_end = MIN(end,      i_end) - start;
+
+	assert(i_end - i == j_end - j);
+
+	overlap = 0;
+	for (; i <= i_end; i++, j++) {
+	    assert(snps[i] >= ' ' && snps[i] <= '~');
+	    if (tmp->snps[j] != '-' && snps[i] != '-') {
+		if (tmp->snps[j] == snps[i]) {
+		    overlap++;
+		} else {
+		    break;
+		}
+	    }
+	}
+
+	if (i != i_end+1)
+	    continue; // didn't overlap
+#ifdef ALLOW_CONTAINMENTS
+	if (best_overlap < overlap) {
+	    best_overlap = overlap;
+	    best_hs = hs;
+	}
+#else
+	if (tmp->start == start && tmp->end == end) {
+	    best_hs = hs;
+	    break;
+	}
+#endif
+    }
+    interval_iter_destroy(iter);
+
+#ifdef ALLOW_CONTAINMENTS
+//    if (best_hs && (best_overlap >= end-start+1 ||
+//		    best_overlap == best_hs->end - best_hs->start+1))
+//		    // two way containment
+    if (best_hs && best_hs->start <= start && best_hs->end >= end)  // larger
+#else
+    if (best_hs && best_hs->start == start && best_hs->end == end)  // exact match
+#endif
+    {
+	// Overlaps an existing haplotype, so append.
+	// NB: no attempt to do joinining made here,
+	// but we're processing in left to right order
+	// so it is unlikely to be needed.
+	hs = best_hs;
+	tmp = (haplotype_str *)best_hs->data.p;
+
+	assert(tmp->start <= start);
+
+//        printf("%*s%.*s Update %*s%.*s -> ", start, "", end-start+1, snps,
+//	       tmp->start, "", tmp->end - tmp->start + 1, tmp->snps);
+
+#ifdef ALLOW_CONTAINMENTS
+	if (tmp->end < end) {
+	    interval_tree_del(it, hs);
+	    tmp->snps  = realloc(tmp->snps,  end - tmp->start+1);
+	    tmp->count = realloc(tmp->count, (end - tmp->start+1)*sizeof(int));
+	    memset(&tmp->count[tmp->end-tmp->start+1], 0, (end-tmp->end)*sizeof(int));
+	    tmp->end = end;
+	    interval_tree_add(it, tmp->start, tmp->end, (interval_data)(void *)tmp);
+	}
+#endif
+
+	// Consider \0 to be the undef snp and then we can just do
+	// tmp->snps[i-tmp->start] |= snps[i-start];
+	for (i = start; i <= end; i++) {
+	    if (snps[i-start] != '-') {
+		tmp->snps[i-tmp->start] = snps[i-start];
+		tmp->count[i-tmp->start]++;
+	    }
+	}
+
+//	printf("%*s%.*s\n", tmp->start, "", tmp->end - tmp->start + 1, tmp->snps);
+	tmp->nseq++;
+
+//	// Maintain sorted list by nseq
+//	if (last && tmp->nseq > last->nseq) {
+//	    if (last_last) {
+//		last_last->next = tmp;
+//		last->next = tmp->next;
+//		tmp->next = last;
+//	    } else {
+//		*hs = tmp;
+//		last->next = tmp->next;
+//		tmp->next = last;
+//	    }
+//	}
+
+	if (rec1)
+	    ArrayPush(tmp->recs, tg_rec, rec1);
+	if (rec2)
+	    ArrayPush(tmp->recs, tg_rec, rec2);
+
+	return 0;
+    }
+
+
+    // Hasn't been merged, so start a new haplotype string
+    tmp = calloc(1, sizeof(*tmp));
+    tmp->snps = (char *)malloc(end-start+1);
+    tmp->count = (int *)calloc(end-start+1, sizeof(int));
+    tmp->start = start;
+    tmp->end = end;
+    tmp->nseq = 1;
+    for (i = start; i <= end; i++) {
+	if ((tmp->snps[i-start] = snps[i-start]) != '-')
+	    tmp->count[i-start] = 1;
+    }
+//    printf("ADD %*s%.*s\n", tmp->start, "", tmp->end - tmp->start + 1, tmp->snps);
+    interval_tree_add(it, start, end, (interval_data)(void *)tmp);
+
+    tmp->recs = ArrayCreate(sizeof(tg_rec), 1);
+    if (rec1)
+	ArrayPush(tmp->recs, tg_rec, rec1);
+    if (rec2)
+	ArrayPush(tmp->recs, tg_rec, rec2);
+
+    return 0;
+}
+
+void haplotype_str_free(void *vp) {
+    haplotype_str *hs = (haplotype_str *)vp;
+    if (hs->recs)
+	ArrayDestroy(hs->recs);
+    if (hs->snps)
+	free(hs->snps);
+    free(hs);
+}
+
+void haplotype_str_filter(interval_tree *it, int min_count) {
+    interval_iter *iter = interval_range_iter(it, INT_MIN, INT_MAX);
+    interval *iv;
+    interval *iv_list = NULL;
+
+    for (iv = interval_iter_next(iter); iv; iv = interval_iter_next(iter)) {
+	haplotype_str *hs = (haplotype_str *)iv->data.p;
+	if (hs->nseq < min_count) {
+	    // Delay deletion as it breaks iterators
+	    iv->u_next = iv_list;
+	    iv_list = iv;
+	}
+    }
+
+    while (iv_list) {
+	haplotype_str *hs = (haplotype_str *)iv_list->data.p;
+	iv = iv_list->u_next;
+
+	interval_tree_del(it, iv_list);
+	haplotype_str_free(hs);
+
+	iv_list = iv;
+    }
+
+    interval_iter_destroy(iter);
+}
+
+
+// Sort by number of sequences (largest first)
+// then start and end coordinates (smallest first).
+int ivp_sort(const void *vp1, const void *vp2) {
+    haplotype_str *hs1 = (haplotype_str *)(*((interval **)vp1))->data.p;
+    haplotype_str *hs2 = (haplotype_str *)(*((interval **)vp2))->data.p;
+    //haplotype_str *hs1 = (haplotype_str *)(*ivp1)->data.p;
+    //haplotype_str *hs2 = (haplotype_str *)(*ivp2)->data.p;
+
+    int nl1 = sqrt(hs1->end - hs1->start + 1) * hs1->nseq;
+    int nl2 = sqrt(hs2->end - hs2->start + 1) * hs2->nseq;
+
+    return (nl2 - nl1)
+	 ? (nl2 - nl1)
+	: ((hs1->start - hs2->start)
+	   ?hs1->start - hs2->start
+	   :hs1->end   - hs2->end); 
+}
+
+// Clusters a block of haplotypes in intervals head to tail, returning a
+// new head/tail.
+int haplotype_str_cluster_subregion(interval **head_p, interval **tail_p, int count) {
+    interval **ivp, *iv;
+    interval *iv_head, *iv_tail;
+    interval *iv_prev, *iv_next;
+    int i;
+
+    if (count < 1)
+	return 0;
+
+    if (!head_p || !*head_p || !tail_p || !*tail_p)
+	return -1;
+
+    iv_head = *head_p;
+    iv_tail = *tail_p;
+    iv_prev = iv_head->u_prev; iv_head->u_prev = NULL;
+    iv_next = iv_tail->u_next; iv_tail->u_next = NULL;
+
+//    puts("::sub_start::");
+//    for (iv = iv_head; iv; iv = iv->u_next) {
+//	haplotype_str *hs = (haplotype_str *)iv->data.p;
+//	printf("%4d %*s%.*s\n", hs->nseq, hs->start, "", hs->end - hs->start+1, hs->snps);
+//    }
+
+    // Sort it.
+    ivp = malloc(count * sizeof(*ivp));
+    for (count = 0, iv = iv_head; iv; iv = iv->u_next, count++)
+	ivp[count] = iv;
+    qsort(ivp, count, sizeof(*ivp), ivp_sort);
+
+    iv_head = ivp[0]; iv_tail = ivp[count-1];
+    for (i = 0; i < count; i++) {
+	ivp[i]->u_prev = i         ? ivp[i-1] : NULL;
+	ivp[i]->u_next = i+1<count ? ivp[i+1] : NULL;
+    }
+
+    /*
+     * TODO:
+     *
+     * If we have strings like:
+     *
+     * 1) AGCTGACAAATGC
+     * 2) AGCAAGCAAATGC
+     * 3)         AATGCGGTA
+     *
+     * 3 matches both 1 and 2. In this case, assuming we start with 1,
+     * we cannot "recruit" 3 as it could be recruited elsewhere and
+     * the elsewhere read is not compatible.  Essentially this has to
+     * remain as 3 contigs.
+     *
+     * Contrast this to:
+     *
+     * 1)   CTGACAAATGC
+     * 2) AGCTGACAAAT
+     * 3)         AATGCGGTA
+     *
+     * Formally:
+     * For string S_a, Y_a is the set of {b,...} where S_a and S_b match
+     *                 N_a is the set of {b,...} where S_a and S_b mismatch
+     *
+     * S_a and S_b can be merged if
+     *     Y_a intersection N_b is empty &&
+     *     Y_b intersection N_a is empty
+     *
+     * During merge of S_b into S_a:
+     *     Y_a becomes Y_a union Y_b
+     *     N_a becomes N_a union N_b
+     */
+
+    // Recruit overlapping nodes.
+    // O(N^2) complexity, hence keep block size small
+    for (iv = iv_head; iv; iv = iv->u_next) {
+	haplotype_str *hs = (haplotype_str *)iv->data.p;
+	interval *iv2, *next;
+	int recruited;
+	int iv_start = iv->start, iv_end = iv->end;
+
+	//printf("> %4d %*s%.*s\n", hs->nseq, hs->start, "", hs->end - hs->start+1, hs->snps);
+
+    again:
+	recruited = 0;
+	for (iv2 = iv->u_next; iv2; iv2 = next) {
+	    haplotype_str *hs2 = (haplotype_str *)iv2->data.p;
+	    int mismatch = 0, nsnp;
+	    next = iv2->u_next;
+
+	    if (iv2->start > iv_end || iv2->end < iv_start)
+		continue;
+
+	    for (i = MAX(hs->start, hs2->start); i <= MIN(hs->end, hs2->end); i++) {
+		if (hs->snps[i-hs->start] != hs2->snps[i-hs2->start] &&
+		    hs->snps[i-hs->start] != '-' &&
+		    hs2->snps[i-hs2->start] != '-') {
+		    mismatch=1;
+		    break;
+		}
+	    }
+
+	    //if (mismatch) printf("! %4d %*s%.*s\n", hs2->nseq, hs2->start, "", hs2->end - hs2->start+1, hs2->snps);
+
+	    if (mismatch)
+		continue;
+
+	    //printf("+ %4d %*s%.*s\n", hs2->nseq, hs2->start, "", hs2->end - hs2->start+1, hs2->snps);
+	    recruited = 1;
+
+	    // Overlap. Merge hs2 into hs.
+	    nsnp = MAX(hs->end, hs2->end) - MIN(hs->start, hs2->start)+1;
+	    if (hs2->start <= hs->start) {
+		hs2->snps = realloc(hs2->snps, nsnp+1);
+		for (i = MAX(hs->start, hs2->start); i <= hs->end; i++) {
+		    if (hs->snps[i-hs->start] != '-' || i > hs2->end)
+			hs2->snps[i-hs2->start] = hs->snps[i-hs->start];
+		}
+		hs2->snps[nsnp] = 0;
+		free(hs->snps);
+		hs->snps = hs2->snps;
+	    } else {
+		hs->snps = realloc(hs->snps, nsnp+1);
+		for (i = MAX(hs->start, hs2->start); i <= hs2->end; i++) {
+		    if (hs2->snps[i-hs2->start] != '-' || i > hs->end)
+			hs->snps[i-hs->start] = hs2->snps[i-hs2->start];
+		}
+		hs->snps[nsnp] = 0;
+		free(hs2->snps);
+	    }
+
+	    hs->nseq += hs2->nseq;
+	    hs->start = MIN(hs->start, hs2->start);
+	    hs->end   = MAX(hs->end,   hs2->end);
+
+	    hs2->nseq = 0;
+	    hs2->snps = NULL;
+	    hs2->end = hs2->start-1;
+
+	    // merge arrays
+	    ArrayConcat(hs->recs, hs2->recs);
+	    ArrayDestroy(hs2->recs);
+	    hs2->recs = NULL;
+
+	    // unlink iv2
+	    if (iv2->u_prev)
+		iv2->u_prev->u_next = iv2->u_next;
+	    else
+		iv_head = iv2->u_next;
+
+	    if (iv2->u_next)
+		iv2->u_next->u_prev = iv2->u_prev;
+	    else
+		iv_tail = iv2->u_prev;
+	}
+
+	// Warning: don't change iv->start and iv->end directly as
+	// that is modifying our interval tree structure, rather than
+	// the data held within it (hs).
+	//
+	// Doing this breaks the tree consistency, causing _del to fail
+	// in the haplotype_str_filter() function.
+	iv_start = hs->start;
+	iv_end   = hs->end;
+
+	// If we're recruited more reads into our haplotype_str then try again,
+	// as we may now have overlaps that we originally dismissed.  Maybe
+	// this needs a limited number of passes.
+	if (recruited)
+	    goto again;
+    }
+
+    // This is a sub-list, so link back the lists either side of
+    // the head..tail.
+    if (iv_prev) {
+	iv_prev->u_next = iv_head;
+	iv_head->u_prev = iv_prev;
+    }
+    if (iv_next) {
+	iv_next->u_prev = iv_tail;
+	iv_tail->u_next = iv_next;
+    }
+
+    *head_p = iv_head;
+    *tail_p = iv_tail;
+
+//    puts("::sub_end::");
+//    for (iv = iv_head; iv; iv = iv->u_next) {
+//	haplotype_str *hs = (haplotype_str *)iv->data.p;
+//	printf("%4d %*s%.*s\n", hs->nseq, hs->start, "", hs->end - hs->start+1, hs->snps);
+//    }
+
+    free(ivp);
+
+    return 0;
+}
+
+// Merge haplotypes with best overlapping cluster
+void haplotype_str_cluster(interval_tree *it) {
+    interval *iv_head = NULL, *iv_tail = NULL, *iv = NULL;
+    interval_iter *iter = interval_range_iter(it, INT_MIN, INT_MAX);
+    int count = 0;
+    interval *iv_sub_head;
+    int longest_haplo = INT_MIN;
+
+    // FIXME: Chunk into blocks of overlapping haplotypes, or maximum counts.
+    // Eg 3 blocks:
+    // 1111111  2222   333333
+    // -----
+    //  ------
+    //      --
+    //          ----
+    //                 ----
+    //                   ----
+
+
+    // Produce a linear linked list.
+    for (iv = interval_iter_next(iter); iv; iv = interval_iter_next(iter)) {
+	if (longest_haplo == INT_MIN) {
+	    longest_haplo = iv->end;
+	    iv_sub_head = iv;
+	} else {
+	    if (iv->start > longest_haplo) {
+		if (iv_head == iv_sub_head) {
+		    // First sub-list
+		    haplotype_str_cluster_subregion(&iv_head, &iv_tail, count);
+		} else {
+		    haplotype_str_cluster_subregion(&iv_sub_head, &iv_tail, count);
+		}
+		iv_sub_head = iv;
+		longest_haplo = iv->end;
+		count = 0;
+	    } else {
+		longest_haplo = MAX(longest_haplo, iv->end);
+	    }
+	}
+
+	if ((iv->u_prev = iv_tail))
+	    iv_tail->u_next = iv;
+	else
+	    iv_head = iv;
+	iv->u_next = NULL;
+	iv_tail = iv;
+	
+	count++;
+    }
+
+    interval_iter_destroy(iter);
+
+    if (count == 0)
+	return;
+
+    if (iv_head == iv_sub_head)
+	haplotype_str_cluster_subregion(&iv_head, &iv_tail, count);
+    else
+	haplotype_str_cluster_subregion(&iv_sub_head, &iv_tail, count);
+
+    // Dump the merged data
+//    puts("--");
+//    for (iv = iv_head; iv; iv = iv->u_next) {
+//	haplotype_str *hs = (haplotype_str *)iv->data.p;
+//	printf("%4d %*s%.*s\n", hs->nseq, hs->start, "", hs->end - hs->start+1, hs->snps);
+//    }
+}
+
+void haplotype_str_dump(interval_tree *it) {
+    interval_iter *iter = interval_range_iter(it, INT_MIN, INT_MAX);
+    interval *iv;
+
+    for (iv = interval_iter_next(iter); iv; iv = interval_iter_next(iter)) {
+	haplotype_str *hs = (haplotype_str *)iv->data.p;
+	// int i;
+
+	if (!hs->nseq)
+	    continue;
+
+	printf("%5d %*s%.*s\n",
+	       hs->nseq, 
+	       hs->start, "",
+	       hs->end - hs->start+1, hs->snps);
+//	printf("%5d ", hs->nseq);
+//	for (i = 0; i < hs->nsnps; i++)
+//	    putchar('!'+MIN(90,hs->count[i]));
+//	putchar('\n');
+    }
+    puts("");
+
+    interval_iter_destroy(iter);
+}
+
+
+void haplotype_str_reclist(interval_tree *it, Array rec_list) {
+    interval_iter *iter = interval_range_iter(it, INT_MIN, INT_MAX);
+    interval *iv;
+
+    for (iv = interval_iter_next(iter); iv; iv = interval_iter_next(iter)) {
+	haplotype_str *hs = (haplotype_str *)iv->data.p;
+	if (!hs->nseq)
+	    continue;
+
+	ArrayPush(rec_list, Array, hs->recs);
+	hs->recs = NULL; // avoid it being freed later
+    }
+
+    interval_iter_destroy(iter);
+}
+
+/*
+ * A simple linked list of haplotypic sites, forming a doubly linked list so we can easily remove from it.
+ */
+typedef struct haplotype_pos {
+    int pos;             // pos
+    int score;           // FIXME: define this.
+    struct haplotype_pos *prev, *next;
+} haplotype_pos;
+
+int add_haplotype_pos(haplotype_pos **phead, haplotype_pos **ptail, int pos) {
+    haplotype_pos *p = calloc(1, sizeof(*p));
+    if (!p)
+	return -1;
+
+    p->pos = pos;
+
+    if (*ptail) {
+	(*ptail)->next = p;
+	p->prev = *ptail;
+	*ptail = p;
+    } else {
+	*phead = *ptail = p;
+    }
+
+    return 0;
+}
+
+void del_haplotype_pos(haplotype_pos **phead, haplotype_pos **ptail,
+		       haplotype_pos *p) {
+    if (p == *phead)
+	*phead = p->next;
+    else
+	p->prev->next = p->next;
+
+    if (p == *ptail)
+	*ptail = p->prev;
+    else
+	p->next->prev = p->prev;
+
+    free(p);
+}
+
+
+static int find_haplotypes_single(GapIO *io, tg_rec crec, int start, int end,
+				  int min_count, int pairs,
+				  float het_score, float discrep_score,
+				  Array rec_list) {
+    consensus_t *cons = NULL;
+    int ret = -1, i;
+    haplotype_pos *phead = NULL, *ptail = NULL;
+    rangec_t *rng = NULL;
+    int nr;
+    contig_t *c;
+    int nsnps = 0;
+    char *hstr = NULL;
+    interval_tree *it = NULL;
+
+    // Accumulate a list of haplotypes
+    if (!(cons = calloc(end-start+1, sizeof(*cons))))
+	goto err;
+
+    if (-1 == calculate_consensus(io, crec, start, end, cons))
+	goto err;
+
+    if (!(it = interval_tree_create()))
+	goto err;
+
+    for (i = start; i <= end; i++) {
+	if (cons[i-start].scores[6]>=het_score ||
+	    cons[i-start].discrep>=discrep_score) {
+	    printf("Pos %5d: het %c/%c  score %d %f\n",
+		   i,
+		   "ACGT*"[cons[i-start].het_call / 5],
+		   "ACGT*"[cons[i-start].het_call % 5],
+		   (int)cons[i-start].scores[6],
+		   cons[i-start].discrep);
+
+	    add_haplotype_pos(&phead, &ptail, i);
+	    nsnps++;
+	}
+    }
+
+    hstr = malloc(nsnps+1);
+
+    c = cache_search(io, GT_Contig, crec);
+    if (!c)
+	goto err;
+
+    rng = contig_seqs_in_range(io, &c, start, end,
+			       CSIR_SORT_BY_X | CSIR_SORT_BY_CLIPPED, &nr);
+    if (!rng)
+	goto err;
+
+
+    // Pair up the read-pairs, replacing r->pair_rec with -array_index
+    // if pair found.
+    {
+	HashTable *h = HashTableCreate(nr, HASH_DYNAMIC_SIZE);
+	if (!h)
+	    goto err;
+
+	for (i = 0; i < nr; i++) {
+	    HashData hd;
+	    HashItem *hi;
+	    rangec_t *r = &rng[i];
+
+	    hi = HashTableSearch(h, (char *)&r->pair_rec, sizeof(r->pair_rec));
+	    if (hi) {
+		rng[hi->data.i].pair_rec = -i;
+		HashTableDel(h, hi, 0);
+	    } else {
+		hd.i = i;
+		HashTableAdd(h, (char *)&r->rec, sizeof(r->rec), hd, NULL);
+	    }
+	}
+
+	HashTableDestroy(h, 0);
+    }
+
+
+    // Accumulate haplotypes
+    {
+	haplotype_pos *p1, *p2;
+	int i;
+	int snp_no = 0;
+
+	p1 = phead;
+	for (i = 0; i < nr; i++) {
+	    rangec_t *r = &rng[i];
+	    int left, right;
+	    seq_t *s;
+	    char b;
+	    int snp_no2;
+
+	    // FIXME: optimise, no need to reset all the while.
+	    // Fill out bits we need and remember start/end.
+	    //memset(hstr, '-', nsnps); 
+
+	    if ((r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISSEQ)
+		continue;
+
+	    s = cache_search(io, GT_Seq, r->rec);
+	    if (s->right < s->left)
+		continue; // ERROR: no unclipped bases.
+
+	    if ((s->len < 0) ^ r->comp) {
+		left = r->start + ABS(s->len) - (s->right-1) - 1;
+		right = r->start + ABS(s->len) - (s->left-1) - 1;
+	    } else {
+		left = r->start + s->left - 1;
+		right = r->start + s->right - 1;
+	    }
+	    left = MAX(left, r->start);
+	    right = MIN(right, r->end);
+
+	    while (p1 && p1->pos < left) {
+		p1 = p1->next;
+		snp_no++;
+	    }
+	    if (!p1)
+		break;
+
+	    if (right < p1->pos)
+		continue;
+
+	    snp_no2 = snp_no;
+	    for (p2 = p1; p2 && p2->pos <= right; p2 = p2->next) {
+		if ((s->len < 0) ^ r->comp) {
+		    b = complement_base(s->seq[ABS(s->len)-1 - (p2->pos - r->start)]);
+		} else {
+		    b = s->seq[p2->pos - r->start];
+		}
+
+		hstr[snp_no2++-snp_no] = b;
+		assert(b >= ' ' && b <= '~');
+	    }
+	    hstr[snp_no2-snp_no] = 0;
+
+
+	    //haplotype_str_add(it, hstr, snp_no, snp_no2-1, r->rec);
+	    // Added single which helps to bulk up duplicates and get the 
+	    // best haplotypes represented. (Rejected for now)
+
+	    // Now produce pairs. These are more variable in size/distance so
+	    // represented with low duplicate count, so will get added near end.
+	    // However they can link haplotypes together.
+	    //
+	    // Do we also need a NOT join set? Ideally should resolve pairs first?
+	    //
+	    // FIXME brute force. Add hash or similar to speed up
+	    {
+//		int j;
+		rangec_t *rp;
+
+//		for (j = i+1; j < nr; j++) {
+//		    rp = &rng[j];
+//
+//		    if (rp->rec == r->pair_rec && r->rec == rp->pair_rec)
+//			break;
+//		}
+//
+//		if (j == nr) {
+
+		if (r->pair_rec >= 0 || !pairs) {
+		    // single ended only
+		    haplotype_str_add(it, hstr, snp_no, snp_no2-1, r->rec, 0);
+		    continue;
+		}
+		rp = &rng[-r->pair_rec];
+
+		if ((rp->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISSEQ)
+		    continue;
+
+		s = cache_search(io, GT_Seq, rp->rec);
+		if (s->right < s->left)
+		    continue; // ERROR: no unclipped bases.
+
+		if ((s->len < 0) ^ rp->comp) {
+		    left = rp->start + ABS(s->len) - (s->right-1) - 1;
+		    right = rp->start + ABS(s->len) - (s->left-1) - 1;
+		} else {
+		    left = rp->start + s->left - 1;
+		    right = rp->start + s->right - 1;
+		}
+
+		// FIXME: if pair overlaps, may want to pick best quality base
+		// p2 is next SNP loc beyond the first end 'r'.
+		// Fill out p2 to 'rp' first pos with '-'
+		while (p2 && p2->pos < left) {
+		    hstr[snp_no2++-snp_no] = '-';
+		    p2 = p2->next;
+		}
+
+		while (p2 && p2->pos <= right) {
+		    if ((s->len < 0) ^ rp->comp) {
+			b = complement_base(s->seq[ABS(s->len)-1 - (p2->pos - rp->start)]);
+		    } else {
+			b = s->seq[p2->pos - rp->start];
+		    }
+
+		    hstr[snp_no2++-snp_no] = b;
+		    p2 = p2->next;
+		}
+		hstr[snp_no2-snp_no] = 0;
+		haplotype_str_add(it, hstr, snp_no, snp_no2-1, r->rec, rp->rec);
+		
+		rp->flags = GRANGE_FLAG_ISCONS; // prevent use later on
+	    }
+	}
+    }
+
+    //puts("=== After str_add");
+    //haplotype_str_dump(it);
+
+    haplotype_str_cluster(it);
+
+    //puts("=== After cluster");
+    //haplotype_str_dump(it);
+
+    haplotype_str_filter(it, min_count);
+
+    puts("=== After filter");
+    haplotype_str_dump(it);
+
+    haplotype_str_reclist(it, rec_list);
+
+    ret = 0;
+ err:
+
+    // Free positions
+    {
+	haplotype_pos *curr, *next = NULL;
+	for (curr = phead; curr; curr = next) {
+	    next = curr->next;
+	    free(curr);
+	}
+    }
+
+    // Free tree / strings
+    if (it) {
+	interval_tree_destroy(it, haplotype_str_free);
+    }
+
+    if (cons)
+	free(cons);
+    if (rng)
+	free(rng);
+    if (hstr)
+	free(hstr);
+
+    return ret;
+}
+
+/*
+ * Splits readings into haplotypic groups and also returns haplotype consensus?
+ * Works via lists? Files?
+ *
+ * Returns an Array of Arrat of seq record numbers.
+ * Returns NULL for failure.a
+ */
+Array find_haplotypes(GapIO *io, contig_list_t *contigs, int ncontigs,
+		      int pairs, float het_score, float discrep_score,
+		      int min_count) {
+    int i;
+    Array rec_list = ArrayCreate(sizeof(Array), 0);
+
+    for (i = 0; i < ncontigs; i++) {
+	printf("find_haplotypes =%"PRIrec"\t%d..%d\n",
+	       contigs[i].contig, contigs[i].start, contigs[i].end);
+	if (-1 == find_haplotypes_single(io, contigs[i].contig,
+					 contigs[i].start, contigs[i].end,
+					 min_count, pairs,
+					 het_score, discrep_score,
+					 rec_list)) {
+	    // FIXME: free
+	    return NULL;
+	}
+    }
+
+    return rec_list;
+}
diff --git a/gap5/find_haplotypes.h b/gap5/find_haplotypes.h
new file mode 100644
index 0000000..9d896ed
--- /dev/null
+++ b/gap5/find_haplotypes.h
@@ -0,0 +1,10 @@
+#ifndef _FIND_HAPLOTYPES_H_
+#define _FIND_HAPLOTYPES_H_
+
+#include <tg_gio.h>
+
+Array find_haplotypes(GapIO *io, contig_list_t *contigs, int ncontigs,
+		      int pairs, float het_score, float discrep_score,
+		      int min_count);
+
+#endif /* _FIND_HAPLOTYPES_H_ */
diff --git a/gap5/find_oligo.c b/gap5/find_oligo.c
index 800f06b..8628285 100644
--- a/gap5/find_oligo.c
+++ b/gap5/find_oligo.c
@@ -34,7 +34,7 @@ void *find_oligo_obj_func1(int job,
 			   obj_match *obj,
 			   mobj_find_oligo *find_oligo)
 {
-    static char buf[80];
+    static char buf[160];
     obj_cs *cs;
     int cs_id;
 
@@ -173,7 +173,7 @@ void *find_oligo_obj_func2(int job,
 			   obj_match *obj,
 			   mobj_find_oligo *find_oligo)
 {
-    static char buf[80];
+    static char buf[160];
     obj_cs *cs;
     int cs_id;
 
diff --git a/gap5/find_repeats.c b/gap5/find_repeats.c
index 0fb4e96..8cd74f3 100644
--- a/gap5/find_repeats.c
+++ b/gap5/find_repeats.c
@@ -23,7 +23,7 @@
  */
 void *repeat_obj_func(int job, void *jdata, obj_match *obj,
 		      mobj_repeat *repeat) {
-    static char buf[80];
+    static char buf[160];
     obj_cs *cs;
     int cs_id;
 
diff --git a/gap5/g-alloc.c b/gap5/g-alloc.c
index da3308a..db5e3c4 100644
--- a/gap5/g-alloc.c
+++ b/gap5/g-alloc.c
@@ -681,6 +681,7 @@ int heap_free(dheap_t *h, int64_t pos) {
     return 0;
 }
 
+#ifdef HEAP_CHECKER
 /*
  * Brute force check on the heap validity.
  * It's pretty inefficient and could be sped up, but for now this is just
@@ -916,6 +917,10 @@ void heap_check(dheap_t *h) {
 	type[23] = "SeqBlock";
 	type[24] = "AnnoEleBlock";
 	type[25] = "SeqCons";
+	type[26] = "ContigBlock";
+	type[27] = "Scaffold";
+	type[28] = "ScaffoldBlock";
+	
 
 	comp_mode[0] = "Zlib";
 	comp_mode[1] = "Uncompressed";
@@ -1041,7 +1046,6 @@ void heap_check(dheap_t *h) {
     }
 }
 
-#ifdef HEAP_CHECKER
 int main(int argc, char **argv) {
     dheap_t *h;
 
diff --git a/gap5/g-request.c b/gap5/g-request.c
index fb08b2e..8ae3d1a 100644
--- a/gap5/g-request.c
+++ b/gap5/g-request.c
@@ -689,6 +689,7 @@ static void update_header(GFile *gfile, GTimeStamp edtime)
      */
     gfile->header.last_time = edtime;
     err = g_write_aux_header(gfile);
+    fsync(gfile->fd);
     fsync(gfile->fdaux);
     /*
      * If we get an error here, something is seriously wrong!
diff --git a/gap5/gap5.tcl b/gap5/gap5.tcl
index 335ab21..da08d18 100644
--- a/gap5/gap5.tcl
+++ b/gap5/gap5.tcl
@@ -645,6 +645,7 @@ if {$argc == 1} {
 	exit 1
     }
     $io debug_level $debug_level
+    set_database_defaults $io
 
     if {$origtype == "d" && $licence(type) == "v"} {
 	viewer_mode
@@ -663,18 +664,8 @@ if {$argc == 1} {
     gap5_usage
 }
 
-set consensus_mode          [keylget gap5_defs CONSENSUS_MODE]
-set consensus_cutoff        [keylget gap5_defs CONSENSUS_CUTOFF]
-set quality_cutoff          [keylget gap5_defs QUALITY_CUTOFF]
-set chem_as_double          [keylget gap5_defs CHEM_AS_DOUBLE]
-set consensus_iub           [keylget gap5_defs CONSENSUS_IUB]
-set template_size_tolerance [keylget gap5_defs TEMPLATE_TOLERANCE]
-set min_vector_len          [keylget gap5_defs MIN_VECTOR_LENGTH]
-set align_open_cost         [keylget gap5_defs ALIGNMENT.OPEN.COST]
-set align_extend_cost       [keylget gap5_defs ALIGNMENT.EXTEND.COST]
-load_alignment_matrix       [keylget gap5_defs ALIGNMENT.MATRIX_FILE]
-set ignore_all_ptype        [keylget gap5_defs IGNORE_ALL_PTYPE]
-set ignore_custom_ptype     [keylget gap5_defs IGNORE_CUSTOM_PTYPE]
+set_global_defaults
+
 if {[catch {load_genetic_code -filename [keylget gap5_defs GENETIC_CODE]} err]} {
     verror ERR_WARNING load_genetic_code $err
 }
diff --git a/gap5/gap5_cmd.tcl b/gap5/gap5_cmd.tcl
index e9033cb..48388f2 100644
--- a/gap5/gap5_cmd.tcl
+++ b/gap5/gap5_cmd.tcl
@@ -16,18 +16,7 @@ load_package tk_utils
 tk_utils_init
 load_package gap5
 
-set consensus_mode          [keylget gap5_defs CONSENSUS_MODE]
-set consensus_cutoff        [keylget gap5_defs CONSENSUS_CUTOFF]
-set quality_cutoff          [keylget gap5_defs QUALITY_CUTOFF]
-set chem_as_double          [keylget gap5_defs CHEM_AS_DOUBLE]
-set consensus_iub           [keylget gap5_defs CONSENSUS_IUB]
-set template_size_tolerance [keylget gap5_defs TEMPLATE_TOLERANCE]
-set min_vector_len          [keylget gap5_defs MIN_VECTOR_LENGTH]
-set align_open_cost         [keylget gap5_defs ALIGNMENT.OPEN.COST]
-set align_extend_cost       [keylget gap5_defs ALIGNMENT.EXTEND.COST]
-load_alignment_matrix       [keylget gap5_defs ALIGNMENT.MATRIX_FILE]
-set ignore_all_ptype        [keylget gap5_defs IGNORE_ALL_PTYPE]
-set ignore_custom_ptype     [keylget gap5_defs IGNORE_CUSTOM_PTYPE]
+set_global_defaults
 	
 # Error reporting, override the tk route
 catch {rename tk_messageBox {}}
@@ -147,6 +136,8 @@ proc db_open {db access} {
 	exit 1
     }
 
+    set_database_defaults $io
+
     return $io
 }
 
@@ -161,10 +152,12 @@ set ::cmd::export::opts {
     h|help  0 0    {}     {Shows this help.}
     {} {} {} {} {}
 
-    contigs 1 {*}  {list} {Output only specific contigs. 'list' is a space separated list of contig names.}
-    f|format  1 sam  {fmt}  {Controls the output format. 'fmt' should be one of sam, ace, baf, fasta or fastq.}
-    o|out     1 "out.*" {filename} {Where to write output. Suffix defaults to 'fmt'. Output "-" indicates stdout.}
-    fixmates 0 0   {}     {Attempts to fix up SAM mate pairing flags prior to output.}
+    contigs  1 {*} {list} {Output only specific contigs. 'list' is a space separated list of contig names.}
+    f|format 1 sam {fmt}  {Controls the output format. 'fmt' should be one of sam, bam, cram, ace, baf, fasta or fastq.}
+    o|out    1 "out.*" {filename} {Where to write output. Suffix defaults to 'fmt'. Output "-" indicates stdout.}
+    fixmates 0 0 {}       {Attempts to fix up SAM mate pairing flags prior to output.}
+    depad    0 0 {}       {Uses depadded consensus for coordinates (CRAM/SAM/BAM)}
+    refpos   0 0 {}       {Attempts to use original reference coordinates (CRAM/SAM/BAM)}
 }
 
 proc ::cmd::export::run {dbname _options} {
@@ -177,12 +170,21 @@ proc ::cmd::export::run {dbname _options} {
 
     set opt(out) [regsub {\*} $opt(out) $opt(format)]
     
+    if {$opt(refpos)} {
+	set depad 2
+    } elseif {$opt(depad)} {
+	set depad 1
+    } else {
+	set depad 0
+    }
+
     if {[catch {export_contigs \
 		    -io $io \
 		    -contigs $opt(contigs) \
 		    -format $opt(format) \
 		    -fixmates $opt(fixmates) \
-		    -outfile $opt(out)} err]} {
+		    -outfile $opt(out) \
+		    -depad $depad} err]} {
 	puts stderr "Failed in export_contigs call: $err"
     }
 
@@ -203,6 +205,8 @@ set ::cmd::consensus::opts {
     contigs    1 {*}      list     {Output only specific contigs. 'list' is a space separated list of contig names}
     f|format     1 fastq    {fmt}    {Controls the output format. 'fmt' should fasta or fastq.}
     strip_pads 0 0        {}       {Removes padding characters.}
+    mask       1 {}       mode     {Apply 'mode' "mask" (ACGTN->'mask') on 'tag_types'. E.g. -mask acgtn or -mask N}
+    tag_types  1 {REPT}   list     {Consensus tags types to mask out.}
     o|out        1 "cons.*" filename {Where to write output. Suffix defaults to 'fmt'.}
 }
 
@@ -219,6 +223,8 @@ proc ::cmd::consensus::run {dbname _options} {
 
     if {[catch {get_consensus \
 		    -io $io \
+		    -tag_types $opt(tag_types) \
+		    -mask $opt(mask) \
 		    -contigs $opt(contigs) \
 		    -format $format \
 		    -strip_pads $opt(strip_pads) \
@@ -293,6 +299,7 @@ set ::cmd::shuffle_pads::opts "
 
     contigs    1 {*}      list     {Output only specific contigs. 'list' is a space separated list of contig names}
     band_size  1 [keylget gap5_defs SHUFFLE_PADS.BAND_SIZE] {num} {Set the alignment band size.}
+    soft_clips 1 [keylget gap5_defs SHUFFLE_PADS.SOFT_CLIPS] {num} {Adjust and align soft-clips/cutoff positions.}
 "
 
 proc ::cmd::shuffle_pads::run {dbname _options} {
@@ -306,7 +313,8 @@ proc ::cmd::shuffle_pads::run {dbname _options} {
     if {[catch {shuffle_pads \
 		    -io $io \
 		    -contigs $opt(contigs) \
-		    -band $opt(band_size)} err]} {
+		    -band $opt(band_size) \
+	            -soft_clips $opt(soft_clips)} err]} { \
 	puts stderr "Failed in shuffle_pads call: $err"
 	#$io close
 	exit 1
@@ -907,30 +915,117 @@ set ::cmd::check_assembly::opts {
 
 proc ::cmd::check_assembly::run {dbname _options} {
     upvar $_options opt
-    set io [db_open $dbname rw]
+    #set io [db_open $dbname rw]
+    set io [db_open $dbname r]
 
     if {$opt(contigs) == "*"} {
 	set opt(contigs) [CreateAllContigList=Numbers $io]
     }
 
-    set id [check_assembly \
-		-io            $io \
-		-contigs       $opt(contigs) \
-		-max_pmismatch $opt(max_pmismatch) \
-		-win_size      $opt(win_size) \
-		-ignore_N      $opt(ignore_N)]
+ #    set id [check_assembly \
+ #		-io            $io \
+ #		-contigs       $opt(contigs) \
+ #		-max_pmismatch $opt(max_pmismatch) \
+ #		-win_size      $opt(win_size) \
+ #		-ignore_N      $opt(ignore_N)]
+ #
+ #    result_notify \
+ #	-io $io \
+ #	-id $id \
+ #	-type GENERIC \
+ #	-args "{task TASK_CS_SAVE data [list $opt(out)]}"
+
+    find_haplotypes -io $io -contigs $opt(contigs)
 
-    result_notify \
-	-io $io \
-	-id $id \
-	-type GENERIC \
-	-args "{task TASK_CS_SAVE data [list $opt(out)]}"
+    $io close
+}
+
+
+#-----------------------------------------------------------------------------
+# COMMAND: extend or trim
+namespace eval cmd::trim {
+    set name "Trim and/or Extend Contigs"
+}
+
+set ::cmd::trim::opts {
+    h|help  0 0    {}     {Shows this help.}
+    {} {} {} {} {}
+    
+    contigs       1 {*} list {Output only specific contigs. 'list' is a space separated list of contig names}
+    {} {} {} {} {}    	  
+    
+    trim             0 0    {} {Whether to trim contigs [off]}
+    min_trim_depth   1 3   val {Minimum depth for trimming}
+    {} {} {} {} {}    	  
+
+    extend           0 0    {} {Whether to extend contigs [off]}
+    min_extend_depth 1 3   val {Minimum depth for extend}
+    match_score      1 1   val {Score for a match when extending}
+    mismatch_score   1 -3  val {Score for a mismatch when extending}
+}
+
+proc ::cmd::trim::run {dbname _options} {
+    upvar $_options opt
+    set io [db_open $dbname rw]
+
+    if {$opt(trim) == 0 && $opt(extend) == 0} {
+	puts stderr "Please use -trim and/or -extend to indicate which methods \
+you wish to apply."
+	exit 1
+    }
+
+    if {$opt(contigs) == "*"} {
+	set opt(contigs) [CreateAllContigList=Numbers $io]
+    }
+
+    contig_extend \
+	-io             $io \
+	-contigs        $opt(contigs) \
+	-extend         $opt(extend) \
+	-min_depth      $opt(min_extend_depth) \
+	-match_score    $opt(match_score) \
+	-mismatch_score $opt(mismatch_score) \
+	-trim           $opt(trim) \
+	-trim_depth     $opt(min_trim_depth)
 
     $io close
 }
 
 
 #-----------------------------------------------------------------------------
+# COMMAND: func (generic function calling)
+namespace eval cmd::func {
+    set name "Execute arbitrary function (experts only!)"
+}
+
+set ::cmd::func::opts {
+    h|help        0 0   {}   {Shows this help.}
+    {} {} {} {} {}
+    
+    contigs       1 {*} list {Output only specific contigs. 'list' is a space separated list of contig names}
+    {} {} {} {} {}    	  
+    
+    func          1 {}  val  {Tcl function to execute}
+    args          0 {}  val  {Arguments to function}
+}
+
+proc ::cmd::func::run {dbname _options} {
+    upvar $_options opt
+    set io [db_open $dbname rw]
+
+    if {$opt(contigs) == "*"} {
+	set opt(contigs) [CreateAllContigList=Numbers $io]
+    }
+
+    eval $opt(func) \
+	-io             $io \
+	-contigs        $opt(contigs) \
+	$opt(args)
+
+    $io close
+}
+
+#-----------------------------------------------------------------------------
 # Main entry
 
 set cmd [lindex $argv 0]
diff --git a/gap5/gap5_del_test.tcl b/gap5/gap5_del_test.tcl
index 2a15291..64f238e 100644
--- a/gap5/gap5_del_test.tcl
+++ b/gap5/gap5_del_test.tcl
@@ -167,7 +167,7 @@ proc check_contig { io crec { expected "" } } {
     set checked [$c check]
     if {[lindex $checked 0] != 0} {
 	puts stderr "Errors found ($checked), quitting."
-	exit 1
+	return 1
     }
     set vs [$c get_visible_start]
     set ve [$c get_visible_end]
@@ -189,15 +189,19 @@ proc check_contig { io crec { expected "" } } {
 	    } else {
 		puts stderr "Got      $cons"
 	    }
-	    exit 1
+	    return 1
 	}
     }
+    return 0
 }
 
-proc check_sequence { io srec expected } {
+proc check_sequence { io srec expected comp } {
     set s [$io get_sequence $srec]
     set dna [$s get_seq]
     $s delete
+    if { $comp } {
+	set dna [ string_reverse [ string map { A T C G G C T A } $dna ] ]
+    }
     if { $dna ne $expected } {
 	puts stderr "Sequence mismatch, quitting."
 	set el [string length $expected]
@@ -212,8 +216,9 @@ proc check_sequence { io srec expected } {
 	} else {
 	    puts stderr "Got      $dna"
 	}
-	exit 1
+	return 1
     }
+    return 0
 }
 
 proc check_tags { io crec clen etags } {
@@ -231,11 +236,11 @@ proc check_tags { io crec clen etags } {
 	    foreach { trec tstart tend } $tags($arec) break
 	    if { $trec != $rec || $tstart != $astart || $tend != $aend } {
 		puts stderr "Tag mismatch for $arec: expected ($trec, $tstart, $tend) got ($rec $astart $aend)"
-		exit 1
+		return 1
 	    }
 	} else {
 	    puts stderr "Tag mismatch for $arec: expected (deleted) got ($rec $astart $aend)"
-	    exit 1
+	    return 1
 	}
     }
     foreach arec [array names tags] {
@@ -243,9 +248,10 @@ proc check_tags { io crec clen etags } {
 	if { ![info exists seen($arec)] } {
 	    foreach { trec tstart tend } $tags($arec) break
 	    puts stderr "Tag mismatch for $arec: expected ($trec, $tstart, $tend) got (absent)"
-	    exit 1
+	    return 1
 	}
     }
+    return 0
 }
 
 proc sim_ctrl_delete { undo exp pos {tags {}}} {
@@ -321,7 +327,7 @@ proc sim_undo { undo uip exp {tags {}} } {
     } 
 }
 
-proc basic_tests { base_io ed clen crec srec dna tags_array pos } {
+proc basic_tests { base_io ed clen crec srec dna tags_array pos comp } {
     global $ed
     upvar \#0 $ed opt
     upvar $tags_array tags
@@ -340,13 +346,19 @@ proc basic_tests { base_io ed clen crec srec dna tags_array pos } {
 	    update idletasks
 	    # after 100
 	    sim_ctrl_delete u expected strpos etags
-	    check_contig [$w io] $crec $expected
-	    check_sequence [$w io] $srec $expected
-	    check_tags [$w io] $crec $clen etags
+	    if {[check_contig [$w io] $crec $expected] != 0
+		|| [check_sequence [$w io] $srec $expected $comp] != 0
+		|| [check_tags [$w io] $crec $clen etags] != 0} {
+		editor_save $ed
+		$base_io flush
+		return 1
+	    }
 	}
 	editor_save $ed
 	$base_io flush
-	check_contig $base_io $crec $expected
+	if {[check_contig $base_io $crec $expected] != 0} {
+	    return 1
+	}
 
 	set ui [expr {[llength $u] - 1}]
 	for {set i $pos} {$i < $clen} {incr i} {
@@ -354,13 +366,19 @@ proc basic_tests { base_io ed clen crec srec dna tags_array pos } {
 	    update idletasks
 	    # after 100
 	    sim_undo $u ui expected etags
-	    check_contig [$w io] $crec $expected
-	    check_sequence [$w io] $srec $expected
-	    check_tags [$w io] $crec $clen etags
+	    if {[check_contig [$w io] $crec $expected] != 0
+		|| [check_sequence [$w io] $srec $expected $comp] != 0
+		|| [check_tags [$w io] $crec $clen etags] != 0} {
+		editor_save $ed
+		$base_io flush
+		return 1
+	    }
 	}
 	editor_save $ed
 	$base_io flush
-	check_contig $base_io $crec $expected
+	if {[check_contig $base_io $crec $expected] != 0} {
+	    return 1
+	}
     }
 
     if {$pos > 1} {
@@ -373,27 +391,40 @@ proc basic_tests { base_io ed clen crec srec dna tags_array pos } {
 	    editor_delete_base $w [list 17 $crec $i] 1 0 1
 	    update idletasks
 	    sim_ctrl_backspace u expected strpos etags
-	    check_contig [$w io] $crec $expected
-	    check_sequence [$w io] $srec $expected
-	    check_tags [$w io] $crec $clen etags
+	    if {[check_contig [$w io] $crec $expected] != 0
+		|| [check_sequence [$w io] $srec $expected $comp] != 0
+		|| [check_tags [$w io] $crec $clen etags] != 0} {
+		editor_save $ed
+		$base_io flush
+		return 1
+	    }
 	}
 	editor_save $ed
 	$base_io flush
-	check_contig $base_io $crec $expected
+	if {[check_contig $base_io $crec $expected] != 0} {
+	    return 1
+	}
 	
 	set ui [expr {[llength $u] - 1}]
 	for { set i $pos } { $i > 0 } { incr i -1 } {
 	    editor_undo $ed
 	    update idletasks
 	    sim_undo $u ui expected etags
-	    check_contig [$w io] $crec $expected
-	    check_sequence [$w io] $srec $expected
-	    check_tags [$w io] $crec $clen etags
+	    if {[check_contig [$w io] $crec $expected] != 0
+		|| [check_sequence [$w io] $srec $expected $comp] != 0
+		|| [check_tags [$w io] $crec $clen etags] != 0} {
+		editor_save $ed
+		$base_io flush
+		return 1
+	    }
 	}
 	editor_save $ed
 	$base_io flush
-	check_contig $base_io $crec $expected
+	if {[check_contig $base_io $crec $expected] != 0} {
+	    return 1
+	}
     }
+    return 0
 }
 
 proc del_undo_test { base_io ed clen crec dna } {
@@ -410,23 +441,35 @@ proc del_undo_test { base_io ed clen crec dna } {
 	$w set_cursor 17 $crec 1
 	editor_delete_base $w [list 17 $crec 1] 1 1 1
 	sim_ctrl_delete u expected strpos
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
     }
     editor_save $ed
     $base_io flush
-    check_contig $base_io $crec $expected
+    if {[check_contig $base_io $crec $expected] != 0} {
+	return 1
+    }
 
     set ui [expr {[llength $u] - 1}]
     for {set i 0} {$i <= $clen} {incr i} {
 	editor_undo $ed
 	sim_undo $u ui expected
-	check_contig [$w io] $crec
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
     }
     editor_save $ed
     $base_io flush
-    check_contig $base_io $crec $expected
+    if {[check_contig $base_io $crec $expected] != 0} {
+	return 1
+    }
 
     set u {}
     set expected $dna
@@ -435,23 +478,35 @@ proc del_undo_test { base_io ed clen crec dna } {
 	$w set_cursor 17 $crec $i
 	editor_delete_base $w [list 17 $crec $i] 1 0 1
 	sim_ctrl_backspace u expected strpos
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
     }
     editor_save $ed
     $base_io flush
-    check_contig $base_io $crec $expected
+    if {[check_contig $base_io $crec $expected] != 0} {
+	return 1
+    }
 
     set ui [expr {[llength $u] - 1}]
     for {set i 0} {$i <= $clen} {incr i} {
 	editor_undo $ed
 	sim_undo $u ui expected
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
     }
     editor_save $ed
     $base_io flush
-    check_contig $base_io $crec $expected
+    if {[check_contig $base_io $crec $expected] != 0} {
+	return 1
+    }
 
     set mid [expr { int($clen / 2 + 1) }]
     set u {}
@@ -462,35 +517,56 @@ proc del_undo_test { base_io ed clen crec dna } {
 	$w set_cursor 17 $crec $edpos
 	editor_delete_base $w [list 17 $crec $edpos] 1 1 1
 	sim_ctrl_delete u expected strpos
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
 	editor_delete_base $w [list 17 $crec $edpos] 1 0 1
 	sim_ctrl_backspace u expected strpos
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	# puts stderr $expected
 	update idletasks
     }
     editor_save $ed
     $base_io flush
-    check_contig $base_io $crec $expected
+    if {[check_contig $base_io $crec $expected] != 0} {
+	return 1
+    }
 
     set ui [expr {[llength $u] - 1}]
     for {set i 0} {$i <= $mid} {incr i} {
 	editor_undo $ed
 	sim_undo $u ui expected
 	# puts stderr $expected
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
 	editor_undo $ed
 	sim_undo $u ui expected
-	check_contig [$w io] $crec $expected
+	if {[check_contig [$w io] $crec $expected] != 0} {
+	    editor_save $ed
+	    $base_io flush
+	    return 1
+	}
 	update idletasks
     }
 
     puts stderr "Saving."
     editor_save $ed
     $base_io flush
-    check_contig $base_io $crec $expected
+    if {[check_contig $base_io $crec $expected] != 0} {
+	return 1
+    }
+    return 0
 }
 
 proc close_editor { w } {
@@ -517,7 +593,7 @@ proc get_curr_editor {} {
     return [lsearch -inline -regexp [winfo children .] {^\.e\d+$}]
 }
 
-proc do_basic_test { clen } {
+proc do_basic_test { clen comp } {
     puts stderr "Generating test data..."
     set dna [gen_dna $clen]
     set sam_name ""
@@ -540,6 +616,12 @@ proc do_basic_test { clen } {
     $io debug_level 1
 
     set cnum [cname2crec $io "c0000"]
+
+    if { $comp } {
+	complement_contig -io $io -contigs =$cnum
+	set dna [ string_reverse [ string map { A T C G G C T A } $dna ] ]
+    }
+
     set snum [$io seq_name2rec "r000001"]
     set half [expr { int($clen / 2) }]
     set quart [expr { int($clen / 4) }]
@@ -556,15 +638,104 @@ proc do_basic_test { clen } {
 	     [list $snum [expr { $clen - 2 }] $clen]]
     edit_contig -io $io -contig $cnum
     set ed [get_curr_editor]
-    basic_tests $io $ed $clen $cnum $snum $dna tags 1
-    basic_tests $io $ed $clen $cnum $snum $dna tags [expr { int($clen / 2) }]
-    basic_tests $io $ed $clen $cnum $snum $dna tags $clen
+    if {[basic_tests $io $ed $clen $cnum $snum $dna tags 1 $comp] != 0} {
+	tkwait window $ed
+	exit 1
+    }
+    if {[basic_tests $io $ed $clen $cnum $snum $dna tags [expr { int($clen / 2) }] $comp] != 0 } {
+	tkwait window $ed
+	exit 1
+    }
+    if {[basic_tests $io $ed $clen $cnum $snum $dna tags $clen $comp] != 0} {
+	tkwait window $ed
+	exit 1
+    }
     close_editor $ed
     $io close
     unset io
     return 0
 }
 
+proc do_cutoff_test { clean } {
+    puts stderr "Generating test data..."
+    set clen 32
+    set dna [gen_dna $clen]
+    set sam_name ""
+    set samfd [ make_tmp "deltest" sam_name ]
+    puts $samfd [ format "@SQ\tSN:c%04d\tLN:%d" 0 $clen ]
+    set reads [list [list 1 0 [expr {$clen / 2 - 2}] 0 0 0 [expr {$clen  / 2 + 2} ] 0]\
+		   [list 2 [expr {$clen / 2}] [expr {$clen / 2}] 0 0 [expr {$clen / 2}] 0 0]]
+    for { set p 0 } { $p < $clen } { incr p } {
+	lappend reads [list [expr { $p + 3 } ] $p 1 0 0 0 0 0]
+    }
+    write_sam_reads $samfd $dna $reads
+    close $samfd
+
+    if {[catch { exec tg_index -z 1 -o $sam_name $sam_name >@stdout 2>@stderr } msg]} {
+	puts stderr "Error running tg_index -o $sam_name $sam_name : $msg"
+	return 1
+    }
+    if {[catch \
+     	     {set io [g5::open_database -name $sam_name -access rw]} \
+     	     err]} {
+     	puts stderr "Couldn't open database '$sam_name': $err"
+     	return 1
+    }
+    $io debug_level 1
+
+    set cname "c0000"
+    set cnum [cname2crec $io $cname]
+
+    export_contigs -io $io -contigs "{=$cnum 1 $clen}" -format sam \
+	-outfile "$sam_name.before"
+    edit_contig -io $io -contig $cnum
+    set ed [get_curr_editor]
+
+    if {[del_undo_test $io $ed $clen $cnum $dna] != 0} {
+	tkwait window $ed
+	exit 1
+    }
+
+    export_contigs -io $io -contigs "{=$cnum 1 $clen}" -format sam \
+	-outfile "$sam_name.after"
+
+    if [catch {exec cmp "$sam_name.before" "$sam_name.after" } res] {
+	if {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
+	    puts stderr "cmp failed."
+	    tkwait window $ed
+	    return 1
+	} else {
+	    puts stderr "Error running cmp : $res"
+	}
+    }
+
+    close_editor $ed
+
+    complement_contig -io $io -contigs =$cnum
+    set dna [ string_reverse [ string map { A T C G G C T A } $dna ] ]
+
+    edit_contig -io $io -contig $cnum
+    set ed [get_curr_editor]
+
+    if {[del_undo_test $io $ed $clen $cnum $dna] != 0} {
+	tkwait window $ed
+	exit 1
+    }
+
+    close_editor $ed
+
+    $io close
+    unset io
+    if { $clean } {
+	puts stderr "Tidying up..."
+	file delete "$sam_name"
+	file delete "${sam_name}.g5d"
+	file delete "${sam_name}.g5x"
+	file delete "${sam_name}.log"
+    }
+    return 0
+}
+
 proc do_test { clean mode clen args } {
     puts stderr "Generating test data..."
     # set clen [ expr { 100 + [exprand 1000] } ]
@@ -605,13 +776,20 @@ proc do_test { clean mode clen args } {
 
     add_contig_tags $io $cnum $clen
 
+    if { $mode eq "pattern" } {
+	return 0
+    }
+
     export_contigs -io $io -contigs "{=$cnum 1 $clen}" -format sam \
 	-outfile "$sam_name.before"
 
     edit_contig -io $io -contig $cnum
     set ed [get_curr_editor]
 
-    del_undo_test $io $ed $clen $cnum $dna
+    if {[del_undo_test $io $ed $clen $cnum $dna] != 0} {
+    	tkwait window $ed
+    	exit 1
+    }
 
     export_contigs -io $io -contigs "{=$cnum 1 $clen}" -format sam \
 	-outfile "$sam_name.after"
@@ -619,6 +797,37 @@ proc do_test { clean mode clen args } {
     if [catch {exec cmp "$sam_name.before" "$sam_name.after" } res] {
 	if {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
 	    puts stderr "cmp failed."
+	    tkwait window $ed
+	    return 1
+	} else {
+	    puts stderr "Error running cmp : $res"
+	}
+    }
+
+    close_editor $ed
+
+    complement_contig -io $io -contigs =$cnum
+    set dna [ string_reverse [ string map { A T C G G C T A } $dna ] ]
+
+    export_contigs -io $io -contigs "{=$cnum 1 $clen}" -format sam \
+	-outfile "$sam_name.cbefore"
+
+    edit_contig -io $io -contig $cnum
+    set ed [get_curr_editor]
+
+    if {[del_undo_test $io $ed $clen $cnum $dna] != 0} {
+	tkwait window $ed
+	exit 1
+    }
+
+    export_contigs -io $io -contigs "{=$cnum 1 $clen}" -format sam \
+	-outfile "$sam_name.cafter"
+
+    if [catch {exec cmp "$sam_name.cbefore" "$sam_name.cafter" } res] {
+	if {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
+	    puts stderr "cmp failed."
+	    tkwait window $ed
+	    return 1
 	} else {
 	    puts stderr "Error running cmp : $res"
 	}
@@ -631,9 +840,13 @@ proc do_test { clean mode clen args } {
     if { $clean } {
 	puts stderr "Tidying up..."
 	file delete "$sam_name"
-	file delete "${sam_name}.g5d"
-	file delete "${sam_name}.g5x"
-	file delete "${sam_name}.log"
+	file delete "$sam_name.g5d"
+	file delete "$sam_name.g5x"
+	file delete "$sam_name.log"
+	file delete "$sam_name.before"
+	file delete "$sam_name.after"
+	file delete "$sam_name.cbefore"
+	file delete "$sam_name.cafter"
     }
 
     return 0
@@ -650,10 +863,19 @@ proc run_child { seed clean } {
     puts stderr "Using seed $seed"
     expr srand($seed)
 
-    if {[do_basic_test 80]} {
+    if {[do_basic_test 80 0]} {
 	puts stderr "Basic test failed."
 	exit 1
     }
+    if {[do_basic_test 80 1]} {
+	puts stderr "Complement basic test failed."
+	exit 1
+    }
+
+    if {[do_cutoff_test $clean]} {
+    	puts stderr "Cutoff test failed."
+    	exit 1
+    }
 
     set patterns [list [list 100 1 1 0 1 1 1] \
 		      [ list 100 1 1 1 1 1 1] \
@@ -669,6 +891,7 @@ proc run_child { seed clean } {
 
     if { [do_test $clean sim [ expr { 100 + [exprand 1000] } ] ] } {
 	puts stderr "Simulated data test failed"
+	exit 1
     }
 }
 
@@ -682,8 +905,8 @@ load $env(STADLIB)/${lib_prefix}tk_utils${lib_suffix}
 package require Tk
 
 set seed [expr {int(rand() * 2147483647)}]
-if {[lindex $argv 1] != ""} {
-    set seed [lindex $argv 1]
+if {[lindex $argv 0] != ""} {
+    set seed [lindex $argv 0]
 }
 set clean 0
 
diff --git a/gap5/gap5_thrash.tcl b/gap5/gap5_thrash.tcl
index 049f771..9de5d92 100644
--- a/gap5/gap5_thrash.tcl
+++ b/gap5/gap5_thrash.tcl
@@ -106,7 +106,7 @@ proc test_insertions {io {cycle 0}} {
     set end 100
     #if {$cycle == 67} {set end 50}
     for {set i 0} {$i < $end} {incr i; incr l 1} {
-	set p [expr {int(rand()*$l)+$s}]
+	set p [expr {int(rand()*($l+100))+$s-50}]
 	#puts "   ///Ins $p/$s..$e"
 	$c insert_base $p * 11
 	#$io flush
@@ -392,7 +392,7 @@ proc test_consensus {io} {
 	}
 
 	puts "/// Computing consensus for contig $crec at $l to $r ///"
-	calc_consensus -io $io -contigs [list =$crec $l $r]
+	calc_consensus -io $io -contigs [list [list =$crec $l $r]]
     }
 }
 
@@ -437,6 +437,7 @@ for {set cycle 0} {$cycle < $ncycles} {incr cycle} {
 
     #if {$r != 1 && $r != 2 && $r != 0} {incr cycle -1; continue}
     #if {$r != 3 && $r != 4 && $r != 2 && $r != 1 && $r != 11} {incr cycle -1; continue}
+    if {$r != 3 && $r != 4 && $r != 7 && $r != 8} {incr cycle -1; continue}
 
     puts "///$cycle r=$r"
 
diff --git a/gap5/gap5rc b/gap5/gap5rc
index ae5ad37..5059957 100644
--- a/gap5/gap5rc
+++ b/gap5/gap5rc
@@ -75,6 +75,11 @@ set_def TEMPLATE.SPAN_CONTIG_INCONS_COLOUR	"yellow3"
 set_def	TEMPLATE.RULER_COLOUR			"black"
 set_def	TEMPLATE.HIGHLIGHT_COLOUR		"white"
 
+# MARGIN1 is the percentage distance from edge to auto-scroll when visible
+# MARGIN2 is the percentage distance from edge after auto-scroll when not visible
+set_def TEMPLATE.SCROLL_MARGIN1 10
+set_def TEMPLATE.SCROLL_MARGIN2 30
+
 set_def TAG_BRIEF_FORMAT  \
 	{Tag type:%t  Dir:%d   Comment:"%.100c"}
 
@@ -917,6 +922,7 @@ set_def CONSENSUS.EXPT.BUTTON.3			"no annotations"
 set_def CONSENSUS.OUTPUT.NAME			"Output file"
 set_def CONSENSUS.OUTPUT.VALUE			cons
 set_def CONSENSUS.NORMAL.STRIP_PADS		1
+set_def CONSENSUS.NORMAL.AMBIGUITY_CODES	0
 set_def CONSENSUS.EXTENDED.STRIP_PADS		1
 set_def CONSENSUS.UNFINISHED.STRIP_PADS		1
 set_def CONSENSUS.READ_NOTES			0
@@ -1063,7 +1069,11 @@ set_def CHECK_ASSEMBLY.USED.WINSIZE.VALUE	50
 # Shuffle Pads
 set_def SHUFFLE_PADS.INFILE		$defs_c_in
 set_def SHUFFLE_PADS.BAND_SIZE		15
+set_def SHUFFLE_PADS.SOFT_CLIPS		1
+set_def SHUFFLE_PADS.MAX_PASS		10
 set_def SHUFFLE_PADS.EDITOR_BAND_SIZE	51
+set_def SHUFFLE_PADS.EDITOR_SOFT_CLIPS	1
+set_def SHUFFLE_PADS.EDITOR_MAX_PASS    10
 
 # Remove Pad Columns
 set_def REMOVE_PAD_COLUMNS.INFILE		$defs_c_in
diff --git a/gap5/gap5rc_menu_full b/gap5/gap5rc_menu_full
index 759859c..3e1b5c1 100644
--- a/gap5/gap5rc_menu_full
+++ b/gap5/gap5rc_menu_full
@@ -146,7 +146,7 @@ add_command	{View.List Base Confidence}	 8 14 {ListBaseConfidence \$io}
 add_command     {View.List Libraries}            8 14 {ListLibraries \$io}
 #add_command     {View.Contig Navigation}         1 2 {ViewNavigationData \$io}
 
-add_command	{Options.Consensus algorithm}	1  2 {ConfigureCutoffs}
+add_command	{Options.Consensus algorithm}	4  6 {ConfigureCutoffs \$io}
 #add_command	{Options.Set maxseq/maxdb}	1  2 {SetMaxseq \$io}
 add_command	{Options.Set fonts}		1  2 {SetFonts}
 if { $tcl_platform(platform) != "windows" } {
@@ -155,7 +155,7 @@ if { $tcl_platform(platform) != "windows" } {
 add_command	{Options.Configure menus}	1  2 {ConfigureMenus}
 add_command	{Options.Set genetic code}	1  2 {SetGeneticCode} {e}
 add_command	{Options.Alignment scores}	1  2 {SetAlignmentScores} {e}
-add_command	{Options.Trace file location}   4  6 {SetRawData \$io} {e}
+#add_command	{Options.Trace file location}   4  6 {SetRawData \$io} {e}
 #add_command	{Options.Template Status} \
 #			     		 1 2 {SetTemplateStatusConfig} {e}
 
@@ -216,8 +216,8 @@ add_command	{Help.Introduction}	1 0 {show_help gap5 Gap4-Introduction}
 add_command	{Help.Output Window}	1 0 {show_help interface {UI-Output}}
 add_separator	{Help.S1}
 add_command	{Help.Index}		1 0 {show_help gap5 Index}
-add_separator	{Help.S2}
-add_command	{Help.Show Licence}	1 0 {ShowLicence}
+#add_separator	{Help.S2}
+#add_command	{Help.Show Licence}	1 0 {ShowLicence}
 
 #For testing busy mode
 #add_command	{File.Busy On}	1 2 {SetBusy}
@@ -261,6 +261,7 @@ add_command	{Commands.Change Contig Name}	3 6 {editor_set_name \[curr_ed $e\]}
 add_command	{Commands.Template Display}	3 6 {editor_template_display \[curr_ed $e\]}
 add_separator 	{Commands.S5}
 add_command 	{Commands.Sort By Sequence} 	3 6 {editor_sort_by_sequence \[curr_ed $e\]}
+add_command	{Commands.Show Haplotypes} 	3 6 {editor_show_haplotypes \[curr_ed $e\]}
 
 #add_command	{Commands.Save Contig}		3 2 {$e save}
 #add_command	{Commands.Dump Contig to File}	1 0 {dump_contig_dialog $e}
@@ -673,12 +674,13 @@ add_menu File			1 0 left
 add_menu Tracks			1 0 left
 add_menu Help			1 0 right
 
+add_command {File.Save Settings} 1 0 {1.5plot_save_config $w}
 add_command {File.Exit}		1 0 {1.5plot_exit $w}
 
-add_check {Tracks.Template}     1 0 {${w}(template)} \
-    	    	    	    	{show_track $w template_item -200 \[set ${w}(template)\]}
-add_check {Tracks.Depth}    	1 0 {${w}(depth)} \
-    	    	    	    	{show_track $w depth_item -50 \[set ${w}(depth)\]}
+add_check {Tracks.Template}     1 0 {${w}(Show_Template)} \
+    	    	    	    	{show_track $w template_item -200 \[set ${w}(Show_Template)\]}
+add_check {Tracks.Depth}    	1 0 {${w}(Show_Depth)} \
+    	    	    	    	{show_track $w depth_item -50 \[set ${w}(Show_Depth)\]}
 
 add_command {Help.Main plot} 	1 0 {show_help gap5 {Template Display}}
 add_command {Help.Template button} 	1 0 {show_help gap5 {Template-Template}}
diff --git a/gap5/gap_canvas_box.c b/gap5/gap_canvas_box.c
index cfc9d50..2119c1b 100644
--- a/gap5/gap_canvas_box.c
+++ b/gap5/gap_canvas_box.c
@@ -132,14 +132,13 @@ int canvas_cursor_move(Tcl_Interp *interp,
 		       WorldPtr *world,
 		       int cursor_show)
 {
-    int i, apos, ret;
+    int i, apos;
     double cx, cy;
     char cmd[1024];
 
 #ifdef DEBUG
     printf("canvas_cursor_move %d\n", cursor->abspos);
 #endif
-    ret = 0;
     apos = cursor->abspos;
     if (apos < 1)
 	apos = 1;
diff --git a/gap5/gap_globals.c b/gap5/gap_globals.c
index 0fa6afe..1b14d6a 100644
--- a/gap5/gap_globals.c
+++ b/gap5/gap_globals.c
@@ -43,6 +43,8 @@ int min_vector_len = 0;
 int template_check_flags = 0;
 double template_size_tolerance = 1;
 
+int default_seq_tech = STECH_SOLEXA;
+
 static char *gap5_defs_trace(ClientData cd, Tcl_Interp *interp,
 			     char *n1, char *n2, int flags);
 
@@ -60,6 +62,7 @@ int   gap4_global_get_gopenval( void )			{ return gopenval; }
 void  gap4_global_set_gopenval( int ov )		{ gopenval=ov; }
 int   gap4_global_get_gextendval( void )		{ return gextendval; }
 void  gap4_global_set_gextendval( int ev )		{ gextendval=ev; }
+void  gap4_global_set_seq_tech( int t )                 { default_seq_tech=t; }
 double gap4_global_get_template_size_tolerance ( void ) {
     return template_size_tolerance;
 }
@@ -120,9 +123,7 @@ int init_globals(Tcl_Interp *interp) {
     set_char_set(1);    /* 1 == DNA */
     set_dna_lookup(); 	/* general lookup and complementing */
     set_iubc_lookup();	/* iubc codes for restriction enzymes */
-#if 0
     set_mask_lookup();  /* used to mask/mark consensus */
-#endif
     init_genetic_code();
 #if 0
     inits_();		/* fortran stuff */
@@ -240,6 +241,9 @@ int init_globals(Tcl_Interp *interp) {
     Tcl_LinkVar(interp, "template_check_flags", (char *)&template_check_flags,
 		TCL_LINK_INT);
 
+    /* default_seq_tech */
+    Tcl_LinkVar(interp, "default_seq_tech", (char *)&default_seq_tech,
+		TCL_LINK_INT);
 
     return TCL_OK;
 }
diff --git a/gap5/gap_globals.h b/gap5/gap_globals.h
index 57b51a7..83d9e71 100644
--- a/gap5/gap_globals.h
+++ b/gap5/gap_globals.h
@@ -24,6 +24,7 @@ int    gap4_global_get_gextendval( void );
 void   gap4_global_set_gextendval( int ev );
 double gap4_global_get_template_size_tolerance( void );
 void   gap4_global_set_template_size_tolerance( double ts );
+void   gap4_global_set_seq_tech( int t );
 
 
 
@@ -68,6 +69,8 @@ extern double template_size_tolerance;  /* "template_size_tolerance" */
 extern int    min_vector_len;		/* Minimum length of SVEC tag */
 extern int    template_check_flags;	/* TEMP_OFLAG_* for template.c */
 
+extern int default_seq_tech;            /* sequencing technology if unknown */
+
 #define CONSENSUS_MODE_FREQ	  0
 #define CONSENSUS_MODE_WEIGHTED	  1 	/* as FREQ, determined by qual_cut >= 0 */
 #define CONSENSUS_MODE_CONFIDENCE 2
diff --git a/gap5/gap_globals.tcl b/gap5/gap_globals.tcl
new file mode 100644
index 0000000..3c358b1
--- /dev/null
+++ b/gap5/gap_globals.tcl
@@ -0,0 +1,43 @@
+proc set_global_defaults {} {
+    uplevel #0 {
+	global gap5_defs
+	set consensus_mode          [keylget gap5_defs CONSENSUS_MODE]
+	set consensus_cutoff        [keylget gap5_defs CONSENSUS_CUTOFF]
+	set quality_cutoff          [keylget gap5_defs QUALITY_CUTOFF]
+	set chem_as_double          [keylget gap5_defs CHEM_AS_DOUBLE]
+	set consensus_iub           [keylget gap5_defs CONSENSUS_IUB]
+	set template_size_tolerance [keylget gap5_defs TEMPLATE_TOLERANCE]
+	set min_vector_len          [keylget gap5_defs MIN_VECTOR_LENGTH]
+	set align_open_cost         [keylget gap5_defs ALIGNMENT.OPEN.COST]
+	set align_extend_cost       [keylget gap5_defs ALIGNMENT.EXTEND.COST]
+	load_alignment_matrix       [keylget gap5_defs ALIGNMENT.MATRIX_FILE]
+	set ignore_all_ptype        [keylget gap5_defs IGNORE_ALL_PTYPE]
+	set ignore_custom_ptype     [keylget gap5_defs IGNORE_CUSTOM_PTYPE]
+    }
+}
+
+proc set_database_defaults {io} {
+    global default_seq_tech
+    set default_seq_tech 2
+
+    set db [$io get_database]
+    set arec [$db get_config_anno]
+    if {$arec <= 0} return
+
+    set ae [$io get_anno_ele $arec]
+    foreach line [split [$ae get_comment] "\n"] {
+	if {$line == "\n"} continue
+	if {[regexp {set ([^ ]*) (.*)} $line _ a b] != 1} continue
+
+	switch $a {
+	    default_seq_tech {
+		global $a
+		set $a $b
+	    }
+
+	    default {
+		puts stderr "Unknown configuration variable \"$a\" = \"$b\""
+	    }
+	}
+    }
+}
\ No newline at end of file
diff --git a/gap5/gap_range.c b/gap5/gap_range.c
index aad7677..2472a78 100644
--- a/gap5/gap_range.c
+++ b/gap5/gap_range.c
@@ -581,7 +581,7 @@ int gap_range_x(gap_range_t *gr, double ax_conv, double bx_conv,
 		    verror(ERR_WARN, "gap_range_x",
 			   "start %d/%d end %d/%d",
 			   r->pair_start, tl->x[0], r->pair_end, tl->x[3]);	
-	}
+		}
 	    }
 		
 	}
diff --git a/gap5/hash_lib.c b/gap5/hash_lib.c
index 55c5d50..505d2a6 100644
--- a/gap5/hash_lib.c
+++ b/gap5/hash_lib.c
@@ -1113,7 +1113,7 @@ void overlap_mismatch(Hash *h, EDIT_PAIR *edit_pair, OVERLAP *overlap,
     total = mat = score = 0;
     op1 = op2 = 0;
     while (i < seq1_len && j < seq2_len) {
-	char c1, c2;
+	char c1 = 0, c2 = 0;
 
 	while (op1 == 0) {
 	    op1 = *S1++;
@@ -1819,12 +1819,15 @@ int align_blocks (Hash *h, ALIGN_PARAMS *params, OVERLAP *overlap) {
 			 (h->block_match[j].pos_seq2+
 			  h->block_match[j].length));
 		len2 = MAX(len2, 0);
-		t += len2/1.3 -2; // assume approx 75% match in gaps, with
+		t += len2/1.4 -2; // assume approx 75% match in gaps, with
 		                  // at least 2 errs (1 each end).
 
-		//t -= pow(len2,1.5)/10;
-		t -= pow(len2,1.3)/3;
-
+		if (len2-2 > h->word_length) {
+		    if (len2-2 - h->word_length < 1000)
+			t -= (len2-2) * (1-pow(.99, len2-2 - h->word_length));
+		    else
+			t -= (len2-2);
+		}
 		
 		if ( t > h->block_match[i].best_score ) {
 		    h->block_match[i].best_score = t;
diff --git a/gap5/import_contigs.tcl b/gap5/import_contigs.tcl
index 4015771..e8a25cd 100644
--- a/gap5/import_contigs.tcl
+++ b/gap5/import_contigs.tcl
@@ -193,5 +193,5 @@ proc ImportSequences2 { old_io f job } {
     vmessage "Import finished."
 
     ClearBusy
-    PostLoadSetup
+    AssemblySinglePostLoad $io; # from assemble_single.tcl
 }
diff --git a/gap5/import_gff.c b/gap5/import_gff.c
index 0b28a61..976ca59 100644
--- a/gap5/import_gff.c
+++ b/gap5/import_gff.c
@@ -10,7 +10,7 @@
 
 #include <tg_gio.h>
 #include "export_contigs.h"
-#include "zfio.h"
+#include "io_lib/zfio.h"
 #include "gap_cli_arg.h"
 #include "import_gff.h"
 #include "consensus.h"
diff --git a/gap5/interval_tree.c b/gap5/interval_tree.c
new file mode 100644
index 0000000..1ecf3ee
--- /dev/null
+++ b/gap5/interval_tree.c
@@ -0,0 +1,698 @@
+/*
+ * An interval tree.  It's a simple alternative to an R-Tree.
+ *
+ * These can be implemented as a normal one dimensional tree, provided the tree
+ * supports having data held in internal nodes as well as leaf nodes. 
+ *
+ * Each tree node has a single point and houses all data that overlaps that
+ * point. The left/right nodes hold data that overlaps points to the left or
+ * right of that root node.
+ */
+
+// RB_AUGMENT is used to turn the RB tree into an interval tree.
+// See http://en.wikipedia.org/wiki/Interval_tree
+// and http://www.mjmwired.net/kernel/Documentation/rbtree.txt
+#define RB_AUGMENT(x) interval_augment((x))
+
+#include "interval_tree.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <limits.h>
+
+#include "tree.h"
+
+// FIXME: should we just define interval to be a struct
+// of a defined but fixed size, with a minimum set of values?
+//
+// Eg *next, nbytes, start, end.  Then we can add whatever other
+// values we want into the struct, without having to have two
+// memory blocks and a pointer from interval to the "payload"?
+//
+// (A poor mans template.)
+
+// The nodes in our tree.
+typedef struct interval_node {
+    RB_ENTRY(interval_node) link;
+    int start;
+    int end;
+    int last;
+    interval *intervals;
+} interval_node;
+
+RB_HEAD(interval_t, interval_node);
+
+// The primary tree object
+struct interval_tree {
+    struct interval_t tree;
+};
+
+static void interval_augment(interval_node *n) {
+    interval_node *nc;
+
+    //printf("interval_augment %p (%d..%d)\n", n, n->start, n->end);
+    int last = n->end;
+    n->last = last;
+
+    if ((nc = RB_LEFT(n, link)) && last < nc->last)
+	last = nc->last;
+    if ((nc = RB_RIGHT(n, link)) && last < nc->last)
+	last = nc->last;
+    while (n && n->last < last) {
+	//printf("Aug %p last=%d\n", n, last);
+	n->last = last;
+	n = RB_PARENT(n, link);
+    }
+}
+
+static int interval_cmp(interval_node *n1, interval_node *n2) {
+    return (n1->start == n2->start)
+	? (n1->end - n2->end)
+	: (n1->start - n2->start);
+}
+
+RB_PROTOTYPE(interval_t, interval_node, link, interval_cmp);
+RB_GENERATE(interval_t, interval_node, link, interval_cmp);
+
+/*
+ * Creates a new interval tree.
+ *
+ * Returns pointer on success;
+ *        NULL on failure.
+ */
+interval_tree *interval_tree_create(void) {
+    interval_tree *it = malloc(sizeof(*it));
+    if (!it)
+	return NULL;
+
+    RB_INIT(&it->tree);
+    return it;
+}
+
+/*
+ * Frees an interval tree. If free_func is non-NULL then it is
+ * called for each interval_data struct held within the tree.
+ */
+void interval_tree_destroy(interval_tree *it, void (*free_func)(void *ptr)) {
+    interval_node *next = NULL, *node;
+
+    for (node = RB_MIN(interval_t, &it->tree); node; node = next) {
+	next = RB_NEXT(interval_t, &it->tree, node);
+	interval *i, *i_next;
+	for (i = node->intervals; i; i = i_next) {
+	    i_next = i->next;
+	    if (free_func)
+		free_func(i->data.p);
+	    free(i);
+	}
+	RB_REMOVE(interval_t, &it->tree, node);
+	free(node);
+    }
+
+    free(it);
+}
+
+/*
+ * Adds an interval to an interval tree. 
+ *
+ * Returns 0 on success;
+ *        -1 on failure.
+ */
+int interval_tree_add(interval_tree *it, int start, int end, interval_data data) {
+    interval *node = malloc(sizeof(*node));
+    interval_node *i_node = NULL, n;
+    if (!node)
+	return -1;
+
+    node->next  = NULL;
+    node->start = start;
+    node->end   = end;
+    node->data  = data;
+
+    // find interval_node that immediately preceeds start.
+    n.start  = start;
+    n.end    = end;
+    n.last   = end;
+    i_node = RB_NFIND(interval_t, &it->tree, &n);
+    if (i_node && i_node->start > start)
+	i_node = RB_PREV(interval_t, &it_tree, i_node);
+    //if (!i_node || i_node->start > end) {
+    if (!i_node || i_node->start != start) {
+	// No overlap, so new node
+	i_node = malloc(sizeof(*i_node));
+	if (!i_node) {
+	    free(node);
+	    return -1;
+	}
+	i_node->start = start;
+	i_node->end   = end;
+	i_node->intervals = node;
+	i_node->last = end;
+	RB_INSERT(interval_t, &it->tree, i_node);
+    } else {
+	// Overlaps, so add to intervals packed in this node.
+	node->next = i_node->intervals;
+	i_node->intervals = node;
+	if (i_node->end < end)
+	    i_node->end = end;
+
+	while (i_node && i_node->last < end) {
+	    //printf("aug %p last=%d\n", i_node, end);
+	    i_node->last = end;
+	    i_node = RB_PARENT(i_node, link);
+	}
+    }
+
+    return 0;
+}
+
+/*
+ * Updates n->end following a deletion to this node and
+ * updates n->last on this node and any parent nodes that
+ * may need changing.
+ */
+#define MAX(a,b) ((a)>(b)?(a):(b))
+static void interval_recompute_last_del(interval_node *n, int end) {
+    int last = INT_MIN;
+    interval *i;
+    interval_node *nc;
+
+    // Removing the end item means we must recompute to see if it shrunk.
+    if (n->end == end) {
+	for (i = n->intervals; i; i = i->next)
+	    if (last < i->end)
+		last = i->end;
+
+	n->end = last;
+    } else {
+	last = n->end;
+    }
+
+    if ((nc = RB_LEFT(n, link)) && last < nc->last)
+	last = nc->last;
+    if ((nc = RB_RIGHT(n, link)) && last < nc->last)
+	last = nc->last;
+
+    n->last = last;
+    
+    for (n = RB_PARENT(n, link); n; n = RB_PARENT(n, link)) {
+	last = n->end;
+	if ((nc = RB_LEFT(n, link)) && last < nc->last)
+	    last = nc->last;
+	if ((nc = RB_RIGHT(n, link)) && last < nc->last)
+	    last = nc->last;
+
+	n->last = last;
+    }
+}
+
+/*
+ * Removes an interval from an interval tree.
+ *
+ * Returns 0 on success;
+ *        -1 on failure.
+ */
+static int counter = 0;
+int interval_tree_del(interval_tree *it, interval *node) {
+    interval_node *i_node, in;
+    interval *n, *l = NULL;
+
+    counter++;
+
+    // Get the node containing this interval
+    in.start = node->start;
+    in.end   = node->end;
+    in.last  = node->end;
+    i_node = RB_NFIND(interval_t, &it->tree, &in);
+    if (!i_node)
+	return -1;
+
+    // Find the interval itself
+    for (n = i_node->intervals; n; l = n, n = n->next) {
+	if (n == node)
+	    break;
+    }
+    if (!n)
+	return -1;
+
+    // Remove it
+    if (l) {
+	l->next = n->next;
+    } else {
+	i_node->intervals = n->next;
+    }
+
+    if (!i_node->intervals) {
+	//printf("Removing i_node %p\n", i_node);
+	RB_REMOVE(interval_t, &it->tree, i_node);
+
+	if (RB_PARENT(i_node, link))
+	    interval_recompute_last_del(RB_PARENT(i_node, link), node->end);
+
+	free(i_node);
+    } else {
+	interval_recompute_last_del(i_node, node->end);
+    }
+
+    free(n);
+
+    return 0;
+}
+
+
+static int interval_recurse(interval_node *i_node, int start, int end,
+			    int (*func)(interval *i, void *cd),
+			    void *clientdata) {
+    interval *i;
+    interval_node *n;
+    int count = 0, tmp;
+
+    if (!i_node)
+	return -1;
+
+    if ((n = RB_LEFT(i_node, link))) {
+	//printf("L: %d..%d\n", n->start, n->last);
+	if (n->last >= start) {
+	    tmp = interval_recurse(n, start, end, func, clientdata);
+	    if (tmp < 0)
+		return -1;
+	    count += tmp;
+	}
+    }
+
+    //printf("Node %p, %d..%d\n", i_node, i_node->start, i_node->last);
+    if (end >= i_node->start && start <= i_node->end) {
+	for (i = i_node->intervals; i; i = i->next) {
+	    if (i->start <= end && i->end >= start) {
+		//printf("%d..%d\n", i->start, i->end);
+		count++;
+		if (func) {
+		    tmp = func(i, clientdata);
+		    if (tmp < 0)
+			return -1;
+		    if (tmp == 0)
+			return count;
+		}
+	    }
+	}
+    }
+
+    if (i_node->start <= end && (n = RB_RIGHT(i_node, link))) {
+	//printf("R: %d..%d\n", n->start, n->last);
+	tmp = interval_recurse(n, start, end, func, clientdata);
+	if (tmp < 0)
+	    return -1;
+	count += tmp;
+    }
+
+    return count;
+}
+
+/*
+ * Finds a set of intervals overlapping a given range.
+ * The resulting intervals are returned by executing a
+ * callback function per element, if non-NULL.  The clientdata parameter is
+ * passed through to the callback function as-is.
+ *
+ * The callback function return values are:
+ *     <0 error
+ *      0 do not generate more callbacks for this query
+ *     >0 keep generating callbacks, if more intervals are found.
+ * 
+ *
+ * Returns the number of items found on success.
+ *         -1 on failure.
+ */
+int interval_range_query(interval_tree *it, int start, int end,
+			 int (*func)(interval *i, void *cd),
+			 void *clientdata) {
+    return interval_recurse(RB_ROOT(&it->tree), start, end,
+			    func, clientdata);
+}
+
+static void interval_tree_dump_(interval_node *n, int verbosity, int indent) {
+    interval *i;
+    int c = 0, min = INT_MAX, max = INT_MIN;
+    for (i = n->intervals; i; i = i->next) {
+	c++;
+	if (min > i->start) min = i->start;
+	if (max < i->end)   max = i->end;
+    }
+
+    printf("%*sNode %p, %d..%d, last %d, range %d..%d, count %d\n",
+	   indent, "", n, n->start, n->end, n->last, min, max, c);
+
+    assert(min == n->start);
+    assert(max == n->end);
+    assert(n->last >= n->end);
+
+    if (verbosity) {
+	for (i = n->intervals; i; i = i->next) {
+	    printf("%*sInterval %p %d..%d\n", indent, "", i, i->start, i->end);
+	}
+    }
+
+    if (RB_LEFT(n, link))
+	interval_tree_dump_(RB_LEFT(n, link), verbosity, indent+2);
+    if (RB_RIGHT(n, link))
+	interval_tree_dump_(RB_RIGHT(n, link), verbosity, indent+2);
+}
+
+void interval_tree_dump(interval_tree *it, int verbosity) {
+    interval_tree_dump_(RB_ROOT(&it->tree), verbosity, 0);
+    puts("");
+}
+
+
+int interval_tree_check_(interval_node *n, int *end_p) {
+    int err = 0;
+    int start = INT_MAX, end = INT_MIN, end_l = INT_MIN, end_r = INT_MIN;
+    interval *i;
+
+    if (!n)
+	return 0;
+
+    for (i = n->intervals; i; i = i->next) {
+	if (start > i->start)
+	    start = i->start;
+	if (end   < i->end)
+	    end   = i->end;
+    }
+
+    if (start != n->start || end != n->end) {
+	fprintf(stderr, "CHECK node %p: start/end mismatch\n", n);
+	err |= 1;
+    }
+
+    if (RB_LEFT(n, link))
+	err |= interval_tree_check_(RB_LEFT(n, link), &end_l);
+    if (end < end_l)
+	end = end_l;
+
+    if (RB_RIGHT(n, link))
+	err |= interval_tree_check_(RB_RIGHT(n, link), &end_r);
+    if (end < end_r)
+	end = end_r;
+
+    if (end != n->last) {
+	fprintf(stderr, "CHECK node %p: last mismatch\n", n);
+	err |= 1;
+    }
+
+    if (end_p)
+	*end_p = end;
+
+    return err;
+}
+
+/*
+ * Recursively checks an interval tree to ensure that all the internal
+ * requirements hold true.
+ *
+ * Returns 0 on success
+ *        -1 on failure
+ */
+int interval_tree_check(interval_tree *it) {
+    return interval_tree_check_(RB_ROOT(&it->tree), NULL);
+}
+
+
+struct interval_iter {
+    interval_tree *tree;
+    interval_node *node;
+    interval      *iv;
+    int start, end, done_lr;
+};
+
+interval_iter *interval_range_iter(interval_tree *it, int start, int end) {
+    interval_iter *iter;
+
+    if (!(iter = malloc(sizeof(*iter))))
+	return NULL;
+    
+    iter->tree      = it;
+    iter->node      = RB_ROOT(&it->tree);
+    iter->iv        = iter->node ? iter->node->intervals : NULL;
+    iter->done_lr   = 0;
+    iter->start     = start;
+    iter->end       = end;
+
+    //printf("N: %p %d..%d\n", iter->node, iter->node->start, iter->node->last);
+
+    return iter;
+}
+
+void interval_iter_destroy(interval_iter *iter) {
+    if (iter)
+	free(iter);
+}
+
+interval *interval_iter_next_old(interval_iter *iter) {
+    interval *i;
+    interval_node *n;
+
+    if (!iter->node)
+	return NULL;
+
+    //printf("N: %p %d..%d\n", iter->node, iter->node->start, iter->node->last);
+
+    // Current interval array
+    for (i = iter->iv; i; i = i->next) {
+	//printf("i: %p %d..%d\n", i, i->start, i->end);
+	if (i->start <= iter->end && i->end >= iter->start) {
+	    iter->iv = i->next;
+	    return i;
+	}
+    }
+
+
+    // Next node, left if able.
+    if ((n = RB_LEFT(iter->node, link))) {
+	if (n->last >= iter->start) {
+	    //printf("L: %p %d..%d\n", n, n->start, n->last);
+	    iter->node = n;
+	    if (iter->end >= iter->node->start && iter->start <= iter->node->end)
+		iter->iv = iter->node->intervals;
+	    else
+		iter->iv = NULL;
+	    return interval_iter_next(iter);
+	}
+    }
+
+    while (iter->node) {
+	// then right, or up-right.
+	//printf("iter->node = %p\n", iter->node);
+	n = RB_RIGHT(iter->node, link);
+	if (iter->node->start <= iter->end && n) {
+	    //printf("R: %p %d..%d\n", n, n->start, n->last);
+	    iter->node = n;
+	    if (iter->end >= iter->node->start && iter->start <= iter->node->end)
+		iter->iv = iter->node->intervals;
+	    else
+		iter->iv = NULL;
+	    return interval_iter_next(iter);
+	}
+
+	do {
+	    n = iter->node;
+	    iter->node = RB_PARENT(iter->node, link);
+	    //printf("U: %p\n", iter->node);
+	} while (iter->node && RB_RIGHT(iter->node, link) == n);
+    }
+
+    return NULL;
+}
+
+interval *interval_iter_next(interval_iter *iter) {
+    interval *i;
+    interval_node *n;
+
+    if (!iter->node)
+	return NULL;
+
+    //printf("N %p\n", iter->node);
+
+    // Next node, left if able.
+    if (!iter->done_lr && (n = RB_LEFT(iter->node, link))) {
+	if (n->last >= iter->start) {
+	    //printf("L: %p %d..%d\n", n, n->start, n->last);
+	    iter->node = n;
+	    if (iter->end >= iter->node->start && iter->start <= iter->node->end)
+		iter->iv = iter->node->intervals;
+	    else
+		iter->iv = NULL;
+	    iter->done_lr = 0;
+    	    return interval_iter_next(iter);
+	}
+    }
+
+    iter->done_lr = 1;
+
+    while (iter->node) {
+	// Current interval array
+	for (i = iter->iv; i; i = i->next) {
+	    //printf("i: %p %d..%d\n", i, i->start, i->end);
+	    if (i->start <= iter->end && i->end >= iter->start) {
+		iter->iv = i->next;
+		return i;
+	    }
+	}
+
+	// then right, or up-right.
+	//printf("iter->node = %p\n", iter->node);
+	n = RB_RIGHT(iter->node, link);
+	if (iter->node->start <= iter->end && n) {
+	    //printf("R: %p %d..%d\n", n, n->start, n->last);
+	    iter->node = n;
+	    if (iter->end >= iter->node->start && iter->start <= iter->node->end)
+		iter->iv = iter->node->intervals;
+	    else
+		iter->iv = NULL;
+	    iter->done_lr = 0;
+	    return interval_iter_next(iter);
+	}
+
+	do {
+	    n = iter->node;
+	    iter->node = RB_PARENT(iter->node, link);
+	    //printf("U: %p\n", iter->node);
+	} while (iter->node && RB_RIGHT(iter->node, link) == n);
+
+	if (iter->node) {
+	    if (iter->end >= iter->node->start && iter->start <= iter->node->end)
+		iter->iv = iter->node->intervals;
+	    else
+		iter->iv = NULL;
+	}
+
+	iter->done_lr = 1;
+    }
+
+    return NULL;
+}
+
+#ifdef TEST_MAIN
+#define NITEMS 100000
+#define RLEN   10000000
+#define SLEN   10
+
+static interval intervals[NITEMS];
+
+int brute_force_count(int start, int end) {
+    int i, c;
+    for (i = c = 0; i < NITEMS; i++)
+	if (intervals[i].start <= end && intervals[i].end >= start)
+	    c++;
+
+    return c;
+}
+
+int print_result(interval *i, void *prefix) {
+    printf("%s%d..%d\n", (char *)prefix, i->start, i->end);
+    return 1;
+}
+
+int main(int argc, char **argv) {
+    interval_tree *it = interval_tree_create();
+    int i, st, en, count1, count2 = 0, tc = 0;
+
+    st = argc>1?atoi(argv[1]):500;
+    en = argc>2?atoi(argv[2]):st;
+
+    srand(0);
+    for (i = 0; i < NITEMS; i++) {
+	interval_data d = {0};
+        int x1 = drand48()*RLEN;
+        int x2 = x1 + drand48()*SLEN;
+        //printf("Adding %d..%d\n", x1, x2);
+	interval_tree_add(it, x1, x2, d);
+
+	// For cross-checking
+	intervals[i].start = x1;
+	intervals[i].end   = x2;
+	//interval_tree_dump(it, 0);
+    }
+
+    //interval_tree_dump(it, 1);
+
+    if (0) {
+	interval_range_query(it, INT_MIN, INT_MAX, print_result, "> ");
+    }
+
+    if (0) {
+	interval_iter *iter = interval_range_iter(it, INT_MIN, INT_MAX);
+	interval *iv;
+	while (iv = interval_iter_next(iter))
+	    printf("> %d..%d\n", iv->start, iv->end);
+    }
+    
+    //interval_tree_dump(it, 1);
+    //exit(0);
+
+    puts("Checking");
+    interval_tree_check(it);
+    puts("Done");
+
+    count1 = interval_range_query(it, INT_MIN, INT_MAX, NULL, NULL);
+
+    for (i = 0; i < 10000; i++) {
+	st = drand48()*(RLEN-SLEN*10);
+	en = st + (drand48()*(SLEN*10));
+
+	printf("%d: %d..%d\n", i, st, en);
+
+	count1 = brute_force_count(st, en);
+
+	//count1 = interval_range_query(it, st, en, NULL, NULL);
+	//interval_iter *iter = interval_range_iter(it, st, en);
+	//for (count1 = 0; interval_iter_next(iter); count1++);
+
+	//count2 = interval_range_query(it, st, en, print_result, "> ");
+	count2 = interval_range_query(it, st, en, NULL, NULL);
+	////printf("%d..%d: %d found (brute force=%d)\n", st, en, count2, count1);
+	assert(count1 == count2);
+
+	interval_iter *iter = interval_range_iter(it, st, en);
+	//interval *iv; for (count2 = 0; iv = interval_iter_next(iter); count2++) printf("iv %d..%d\n", iv->start, iv->end);
+	for (count2 = 0; interval_iter_next(iter); count2++);
+	//printf("%d..%d: %d found (brute force=%d)\n", st, en, count2, count1);
+	assert(count1 == count2);
+	interval_iter_destroy(iter);
+
+//	iter = interval_range_iter(it, st, en);
+//	interval *iv = interval_iter_next(iter);
+//	interval *iv_list = NULL;
+//	while (iv) {
+//	    //printf("Del %d..%d\n", iv->start, iv->end);
+//	    // Delay deletion as it breaks iterators.
+//	    iv->u_next = iv_list;
+//	    iv_list = iv;
+//	    iv = interval_iter_next(iter);
+//	}
+//	interval_iter_destroy(iter);
+//
+//	while (iv_list) {
+//	    iv = iv_list->u_next;
+//	    if (0 != interval_tree_del(it, iv_list))
+//		abort();
+//	    iv_list = iv;
+//	    count1--;
+//	}
+//
+//	count2 = interval_range_query(it, INT_MIN, INT_MAX, NULL, NULL);
+//	assert(count1 == count2);
+//
+//	interval_tree_check(it);
+
+	tc += count1;
+    }
+
+    interval_tree_destroy(it, NULL);
+
+    printf("Total total = %d\n", tc);
+
+    return 0;
+}
+#endif
diff --git a/gap5/interval_tree.h b/gap5/interval_tree.h
new file mode 100644
index 0000000..1d3f8a1
--- /dev/null
+++ b/gap5/interval_tree.h
@@ -0,0 +1,89 @@
+/*
+ * A very simplistic interval tree. These are similar to the the
+ * degenerate case of a 1-dimensional R-Tree.
+ *
+ * There is no removal system in place yet. The data is not entirely
+ * sorted (although defining a sort order on a range is debatable).
+ * However the purpose of how to quickly intervals which items are
+ * present within a range is quickly solved.
+ */
+
+#ifndef _INTERVAL_TREE_H_
+#define _INTERVAL_TREE_H_
+
+#include <stdint.h>
+#include "tree.h"
+
+// The "payload" of an interval
+typedef union {
+    uint64_t i;
+    void *p;
+} interval_data;
+
+// Intervals themselves
+typedef struct interval {
+    //RB_ENTRY(interval) link;
+    struct interval *next;
+    struct interval *u_next, *u_prev; // temporary user-defined lists
+    int start, end;
+    interval_data data;
+} interval;
+
+// Opaque data type. See interval_tree.c for implementation details.
+typedef struct interval_tree interval_tree;
+typedef struct interval_iter interval_iter;
+
+/*
+ * Creates a new interval tree.
+ *
+ * Returns pointer on success;
+ *        NULL on failure.
+ */
+interval_tree *interval_tree_create(void);
+
+/*
+ * Frees an interval tree. If free_func is non-NULL then it is
+ * called for each interval_data struct held within the tree.
+ */
+void interval_tree_destroy(interval_tree *it, void (*free_func)(void *ptr));
+
+/*
+ * Adds an interval to an interval tree. 
+ *
+ * Returns 0 on success;
+ *        -1 on failure.
+ */
+int interval_tree_add(interval_tree *it, int start, int end, interval_data data);
+
+/*
+ * Removes an interval from an interval tree.
+ *
+ * Returns 0 on success;
+ *        -1 on failure.
+ */
+int interval_tree_del(interval_tree *it, interval *node);
+
+/*
+ * Finds a set of intervals overlapping a given range.
+ * The resulting intervals are returned by executing a
+ * callback function per element, if non-NULL.  The clientdata parameter is
+ * passed through to the callback function as-is.
+ *
+ * The callback function return values are:
+ *     <0 error
+ *      0 do not generate more callbacks for this query
+ *     >0 keep generating callbacks, if more intervals are found.
+ * 
+ *
+ * Returns the number of items found on success.
+ *         -1 on failure.
+ */
+int interval_range_query(interval_tree *it, int start, int end,
+			 int (*func)(interval *i, void *cd),
+			 void *clientdata);
+
+interval_iter *interval_range_iter(interval_tree *it, int start, int end);
+void interval_iter_destroy(interval_iter *iter);
+interval *interval_iter_next(interval_iter *iter);
+
+#endif /* _INTERVAL_TREE_H_ */
diff --git a/gap5/libraries.tcl b/gap5/libraries.tcl
index c97cf04..1985df4 100644
--- a/gap5/libraries.tcl
+++ b/gap5/libraries.tcl
@@ -1,5 +1,30 @@
 package require Plotchart
 
+# Registers the xcombobox as a suitable editing tool for tablelist
+;proc tablelist_add_xcombobox {} {
+    set name xcombobox
+    array set ::tablelist::editWin [list \
+	$name-creationCmd   "xcombobox %W" \
+	$name-putValueCmd   "%W set %T" \
+	$name-getValueCmd   "%W get" \
+	$name-putTextCmd    "%W set %T" \
+	$name-getTextCmd    "%W get" \
+	$name-putListCmd    "" \
+	$name-getListCmd    "" \
+	$name-selectCmd     "" \
+	$name-invokeCmd     {[%W subwidget button] invoke} \
+	$name-fontOpt       -font \
+	$name-useFormat     1 \
+	$name-useReqWidth   0 \
+	$name-usePadX       1 \
+	$name-isEntryLike   1 \
+	$name-focusWin      {[%W subwidget entry]} \
+	$name-reservedKeys  {Left Right Up Down}
+       ]
+}
+
+tablelist_add_xcombobox
+
 ;proc ListLibrariesPopulate {io w} {
     # Clear any existing data
     $w selection clear 0 end
@@ -16,7 +41,7 @@ package require Plotchart
 	set mean    [$lib get_insert_size]
 	set sd      [$lib get_insert_sd]
 	set count   [$lib get_count]
-	set type [lindex [list unknown sanger illumina solid 454] $type]
+	set type [lindex [list unknown Sanger Illumina SOLiD 454 Helicos IonTorrent PacBio ONT] $type]
 	
 	# Find most likely library orientation
 	set max 0
@@ -44,6 +69,54 @@ package require Plotchart
     #$db delete
 }
 
+proc ListLibraries_editStartCmd {tbl row col text} {
+    set w [$tbl editwinpath]
+
+    puts [info level [info level]]
+
+    switch $col {
+	3 {
+	    # Machine type
+            $w configure -values [list unknown Sanger Illumina SOLiD 454 Helicos IonTorrent PacBio ONT]
+	    $w configure -fixed_list 1
+	}
+    }
+
+    return $text
+}
+
+proc ListLibraries_editEndCmd {io tbl row col text} {
+    set w [$tbl editwinpath]
+
+    puts [info level [info level]]
+
+    set db [$io get_database]
+    set rec [$db get_library_rec $row]
+    set lib [$io get_library $rec]
+    puts "Processing [$lib get_name]"
+
+    switch $col {
+       1 {
+	   # Entry name
+	   puts [$w get]
+	   $lib set_name [$w get]
+       }
+
+       3 {
+	   # Machine type
+	   set id [lsearch [list unknown Sanger Illumina SOLiD 454 Helicos IonTorrent PacBio ONT] [$w get]]
+	   puts [$w get]:$id
+	   $lib set_machine_type $id
+       }
+    }
+
+    $lib delete
+
+    $io flush
+
+    return $text
+}
+
 proc ListLibraries {io} {
     set t [xtoplevel .list_libraries]
     if {$t == ""} return
@@ -62,10 +135,14 @@ proc ListLibraries {io} {
         -labelcommand tablelist::sortByColumn \
 	-exportselection 0 \
 	-stretch 0 \
-        -yscrollcommand [list $t.yscroll set]
+        -yscrollcommand [list $t.yscroll set] \
+	-editstartcommand ListLibraries_editStartCmd \
+	-editendcommand "ListLibraries_editEndCmd $io"
 
     $t.list columnconfigure 0 -sortmode integer
+    $t.list columnconfigure 1 -editable yes -editwindow entry
     $t.list columnconfigure 2 -sortmode integer
+    $t.list columnconfigure 3 -editable yes -editwindow xcombobox
     $t.list columnconfigure 4 -sortmode integer
     $t.list columnconfigure 5 -sortmode real
     
diff --git a/gap5/list_proc.tcl b/gap5/list_proc.tcl
index a22f580..a46eb07 100644
--- a/gap5/list_proc.tcl
+++ b/gap5/list_proc.tcl
@@ -47,6 +47,16 @@ proc ListGet {name} {
     }
 }
 
+proc ListType {name} {
+    global NGListTag
+
+    if {![info exists NGListTag($name)]} {
+	return ""
+    } else {
+	return $NGListTag($name)
+    }
+}
+
 #############################################################################
 # List file IO
 proc ListLoad {file name {tag {}}} {
@@ -1183,6 +1193,7 @@ set NGList_urd 1
 # to the hash.
 proc UpdateReadingDisplays {list args} {
     global NGList io NGList_urd NGList_read_hash_$list  NGList_size
+    global NGListTag
     upvar #0 NGList_read_hash_$list hash
 
     # Optimisation for when this gets triggered LOTS of times, eg
@@ -1191,11 +1202,25 @@ proc UpdateReadingDisplays {list args} {
 	return
     }
 
-    PruneReadingList $list
-
     array set tmp ""
-    foreach r_name $NGList($list) {
-	set tmp($r_name) 1
+    if {[info exists NGListTag($list)] && $NGListTag($list) == "LIST_OF_LISTS"} {
+	set c 1
+	foreach l $NGList($list) {
+	    PruneReadingList $l
+	    if {[info exists NGList($l)]} {
+		foreach r_name $NGList($l) {
+		    set tmp($r_name) $c
+		}
+		incr c
+	    } else {
+		set tmp($r_name) ""
+	    }
+	}
+    } else {
+	PruneReadingList $list
+	foreach r_name $NGList($list) {
+	    set tmp($r_name) ""
+	}
     }
 
     contig_notify -io $io -type BUFFER_START -cnum 0 -args {}
@@ -1210,7 +1235,7 @@ proc UpdateReadingDisplays {list args} {
 		    continue
 		}
 	    }
-	    set hash($r_name) ""
+	    set hash($r_name) $tmp($r_name)
 	}
     }
 
@@ -1221,8 +1246,11 @@ proc UpdateReadingDisplays {list args} {
 	}
     }
 
-    set NGList($list) [array names hash]
-    set NGList_size($list) [llength $NGList($list)]
+    if {[info exists NGListTag($list)] && $NGListTag($list) == "LIST_OF_LISTS"} {
+    } else {
+	set NGList($list) [array names hash]
+	set NGList_size($list) [llength $NGList($list)]
+    }
 
     contig_notify -io $io -type BUFFER_END -cnum 0 -args {}
 
@@ -1690,7 +1718,7 @@ proc ListEditMulti {name {read_only 0}} {
     if {[set t [ListEditMultiExists $name]] == ""} {
         set t "${ed_list_multi}_[ListNextEditor]"
         xtoplevel $t
-	wm geometry $t 990x400
+	wm geometry $t 1130x400
 	if {$read_only} {
 	    wm title $t "Viewing list: \"$name\""
 	} else {
@@ -1705,24 +1733,24 @@ proc ListEditMulti {name {read_only 0}} {
 
         # The text display and it's scrollbars.
 	tablelist $t.list \
-	    -columns {20 Name 10 Number 15 Contig 10 Position 15 Scaffold 10 {Pair Num} 15 {Pair Contig} 10 {Pair Pos} 15 {Pair Scaf}} \
+	    -columns {20 Name 10 Library 10 T.Status 10 Number 15 Contig 10 Position 15 Scaffold 10 {Pair Num} 15 {Pair Contig} 10 {Pair Pos} 15 {Pair Scaf}} \
 	    -labelcommand tablelist::sortByColumn \
 	    -exportselection 0 \
 	    -selectmode extended \
 	    -yscrollcommand [list $t.scrolly set]
 	
 	$t.list columnconfigure 0 -bg #e0e0e0
-	$t.list columnconfigure 1 -sortmode integer
 	$t.list columnconfigure 3 -sortmode integer
-	$t.list columnconfigure 4 -sortmode command \
+	$t.list columnconfigure 5 -sortmode integer
+	$t.list columnconfigure 6 -sortmode command \
 	    -formatcommand ListContigsScaffoldFormat \
 	    -sortcommand [list ListContigsScaffoldSort $t.list]
-	$t.list columnconfigure 5 -bg #e0e0e0 -sortmode command \
-	    -sortcommand SortOptionalInteger
-	$t.list columnconfigure 6 -bg #e0e0e0
 	$t.list columnconfigure 7 -bg #e0e0e0 -sortmode command \
 	    -sortcommand SortOptionalInteger
-	$t.list columnconfigure 8 -bg #e0e0e0 -sortmode command \
+	$t.list columnconfigure 8 -bg #e0e0e0
+	$t.list columnconfigure 9 -bg #e0e0e0 -sortmode command \
+	    -sortcommand SortOptionalInteger
+	$t.list columnconfigure 10 -bg #e0e0e0 -sortmode command \
 	    -formatcommand ListContigsScaffoldFormat \
 	    -sortcommand [list ListContigsScaffoldSort $t.list]
 
@@ -1845,6 +1873,7 @@ proc ListEditMultiUpdate {t name args} {
     }
 
     $t delete 0 end
+    array set lname ""
     if {$NGListTag($name) != ""} {
 	if {$NGListTag($name) == "SEQID"} {
 	    foreach i $NGList($name) {
@@ -1855,6 +1884,23 @@ proc ListEditMultiUpdate {t name args} {
 		    continue
 		}
 		set s [$io get_sequence $rec]
+		if { ! [$s get_mapped] } continue
+		set lib [$s get_lib]
+		if {![info exists lname($lib)]} {
+		    if {$lib} {
+			set l [$io get_library $lib]
+			set lname($lib) [$l get_name]
+			$l delete
+		    } else {
+			set lname($lib) "(None)"
+		    }
+		}
+		set lib $lname($lib)
+		# See tg_sequence.h
+		set status [$s get_template_status]
+		set status [lindex {? Single Paired !Size !Orient Spanning} \
+			    [expr {$status+1}]]
+
 		set sname [$s get_name]
 		set pos [$s get_position]
 		set crec [$s get_contig]
@@ -1887,10 +1933,12 @@ proc ListEditMultiUpdate {t name args} {
 		    }
 		    $c delete
 		    
-		    $t insert end [list $sname $rec $cname $pos $fname \
-				      $pair_rec $pcname $pair_start $pfname]
+		    $t insert end [list $sname $lib $status \
+				       $rec $cname $pos $fname \
+				       $pair_rec $pcname $pair_start $pfname]
 		} else {
-		    $t insert end [list $sname $rec $cname $pos $fname]
+		    $t insert end [list $sname $lib $status \
+				       $rec $cname $pos $fname]
 		}
 		$s delete
 	    }
@@ -1957,13 +2005,13 @@ proc ListEditMultiSave {w op} {
     }
     foreach r $l {
 	if {$opt(End) & 1} {
-	    set val [lindex $r 1]
+	    set val [lindex $r 3]
 	    if { $val != "" } {
 		lappend reads "#$val"
 	    }
 	}
 	if {$opt(End) & 2} {
-	    set val [lindex $r 5]
+	    set val [lindex $r 7]
 	    if { $val != ""} {
 		lappend reads "#$val"
 	    }
diff --git a/gap5/newgap5_cmds.c b/gap5/newgap5_cmds.c
index d857a7d..6d40b1f 100644
--- a/gap5/newgap5_cmds.c
+++ b/gap5/newgap5_cmds.c
@@ -37,6 +37,7 @@
 #include "break_contig.h"
 #include "template_display.h"
 #include "export_contigs.h"
+#include "export_snps.h"
 #include "import_gff.h"
 #include "find_oligo.h"
 #include "tg_index_common.h"
@@ -56,6 +57,7 @@
 #include "editor_join.h"
 #include "restriction_enzymes.h"
 #include "auto_break.h"
+#include "find_haplotypes.h"
 
 #include "sam_index.h"
 #include <io_lib/bam.h>
@@ -1116,15 +1118,24 @@ int tcl_list_base_confidence(ClientData clientData, Tcl_Interp *interp,
     return TCL_OK;
 }
 
+typedef struct {
+    GapIO *io;
+    char *inlist;
+    int hets;
+    int ref_pos;
+} cons_arg;
+
 int tcl_calc_consensus(ClientData clientData, Tcl_Interp *interp,
 		       int objc, Tcl_Obj *CONST objv[])
 {
     int rargc;
     contig_list_t *rargv;
-    list2_arg args;
+    cons_arg args;
     cli_args a[] = {
-	{"-io",		ARG_IO,  1, NULL,  offsetof(list2_arg, io)},
-	{"-contigs",	ARG_STR, 1, NULL,  offsetof(list2_arg, inlist)},
+	{"-io",		ARG_IO,  1, NULL,  offsetof(cons_arg, io)},
+	{"-contigs",	ARG_STR, 1, NULL,  offsetof(cons_arg, inlist)},
+	{"-hets",       ARG_INT, 1, "0",   offsetof(cons_arg, hets)},
+	{"-ref_pos",    ARG_INT, 0, "0",   offsetof(cons_arg, ref_pos)},
 	{NULL,	    0,	     0, NULL, 0}
     };
 
@@ -1134,15 +1145,70 @@ int tcl_calc_consensus(ClientData clientData, Tcl_Interp *interp,
     active_list_contigs_extended(args.io, args.inlist, &rargc, &rargv);
 
     if (rargc >= 1) {
+	int *rp = NULL;
 	char *buf;
 
 	if (NULL == (buf = (char *)ckalloc(rargv[0].end - rargv[0].start + 2)))
-	    return TCL_OK;
+	    return TCL_ERROR;
+
+	if (args.ref_pos) {
+	    rp = (int *)ckalloc((rargv[0].end - rargv[0].start + 1) * sizeof(*rp));
+	    if (NULL == rp) {
+		ckfree(buf);
+		return TCL_ERROR;
+	    }
 
-	calculate_consensus_simple(args.io, rargv[0].contig, rargv[0].start,
-				   rargv[0].end, buf, NULL);
+	    if (0 != padded_to_reference_array(args.io,
+					       rargv[0].contig,
+					       rargv[0].start,
+					       rargv[0].end,
+					       rp,
+					       NULL, NULL, NULL)) {
+		ckfree((char *)rp);
+		return TCL_ERROR;
+	    }
+	}
+
+	if (args.hets) {
+	    calculate_consensus_simple_het(args.io, rargv[0].contig,
+					   rargv[0].start, rargv[0].end,
+					   buf, NULL);
+	} else {
+	    calculate_consensus_simple(args.io, rargv[0].contig,
+				       rargv[0].start, rargv[0].end,
+				       buf, NULL);
+	}
 	buf[rargv[0].end - rargv[0].start + 1] = 0;
+
+	if (args.ref_pos) {
+	    int i, j;
+	    char *rbuf;
+
+	    for (j = rargv[0].end - rargv[0].start; j > 0; j--)
+		if (rp[j] > 0)
+		    break;
+
+	    rbuf = ckalloc(rp[j]+1);
+	    if (!rbuf) {
+		ckfree((char *)rp);
+	    }
+
+	    /* Map to ref pos coords. Only works if not complemented */
+	    for (j = 1, i = 0; i <= rargv[0].end - rargv[0].start; i++) {
+		if (rp[i] == INT_MIN)
+		    continue; // Insertion
+
+		while (j < rp[i])
+		    rbuf[j++-1] = 'N';
+		rbuf[j++-1] = buf[i];
+	    }
+	    ckfree(buf);
+	    buf = rbuf;
+	}
+
 	Tcl_SetResult(interp, buf, TCL_VOLATILE);
+	if (rp)
+	    ckfree((char *)rp);
 	ckfree(buf);
     }
 
@@ -1155,10 +1221,11 @@ int tcl_calc_quality(ClientData clientData, Tcl_Interp *interp,
 {
     int rargc;
     contig_list_t *rargv;
-    list2_arg args;
+    cons_arg args;
     cli_args a[] = {
-	{"-io",		ARG_IO,  1, NULL,  offsetof(list2_arg, io)},
-	{"-contigs",	ARG_STR, 1, NULL,  offsetof(list2_arg, inlist)},
+	{"-io",		ARG_IO,  1, NULL,  offsetof(cons_arg, io)},
+	{"-contigs",	ARG_STR, 1, NULL,  offsetof(cons_arg, inlist)},
+	{"-hets",       ARG_INT, 1, "0",   offsetof(cons_arg, hets)},
 	{NULL,	    0,	     0, NULL, 0}
     };
 
@@ -1180,8 +1247,15 @@ int tcl_calc_quality(ClientData clientData, Tcl_Interp *interp,
 	    return TCL_ERROR;
 	}
 
-	calculate_consensus_simple(args.io, rargv[0].contig, rargv[0].start,
-				   rargv[0].end, NULL, flt);
+	if (args.hets) {
+	    calculate_consensus_simple_het(args.io, rargv[0].contig,
+					   rargv[0].start, rargv[0].end,
+					   NULL, flt);
+	} else {
+	    calculate_consensus_simple(args.io, rargv[0].contig,
+				       rargv[0].start, rargv[0].end,
+				       NULL, flt);
+	}
 	for (i = 0; i < len; i++) {
 	    int q = rint(flt[i]);
 	    if (q < -127) q = -127;
@@ -1200,6 +1274,52 @@ int tcl_calc_quality(ClientData clientData, Tcl_Interp *interp,
     return TCL_OK;
 }
 
+int tcl_calc_ref_positions(ClientData clientData, Tcl_Interp *interp,
+			   int objc, Tcl_Obj *CONST objv[])
+{
+    int rargc;
+    contig_list_t *rargv;
+    list2_arg args;
+    cli_args a[] = {
+	{"-io",		ARG_IO,  1, NULL,  offsetof(list2_arg, io)},
+	{"-contigs",	ARG_STR, 1, NULL,  offsetof(list2_arg, inlist)},
+	{NULL,	    0,	     0, NULL, 0}
+    };
+
+    if (-1 == gap_parse_obj_args(a, &args, objc, objv))
+	return TCL_ERROR;
+
+    active_list_contigs_extended(args.io, args.inlist, &rargc, &rargv);
+
+    if (rargc >= 1) {
+	int *rp, i;
+	Tcl_Obj *cons = Tcl_NewListObj(0, NULL);
+
+	rp = (int *)ckalloc((rargv[0].end - rargv[0].start + 1) * sizeof(*rp));
+	if (NULL == rp)
+	    return TCL_ERROR;
+
+	if (0 != padded_to_reference_array(args.io,
+					   rargv[0].contig,
+					   rargv[0].start,
+					   rargv[0].end,
+					   rp,
+					   NULL, NULL, NULL)) {
+	    ckfree((char *)rp);
+	    return TCL_ERROR;
+	}
+
+	for (i = 0; i < rargv[0].end - rargv[0].start + 1; i++)
+	    Tcl_ListObjAppendElement(interp, cons, Tcl_NewIntObj(rp[i]));
+
+	Tcl_SetObjResult(interp, cons);
+	ckfree((char *)rp);
+    }
+
+    xfree(rargv);
+    return TCL_OK;
+}
+
 /*
  * Returns the full consensus information as a Tcl list of lists
  * which each sub-list containing call; probabilities of A, C, G, T, *;
@@ -1932,6 +2052,7 @@ tcl_import_reads(ClientData clientData,
 	{"-pair_queue",    ARG_INT, 1, "0",    offsetof(ir_arg, a.pair_queue)},
 	{"-remove_dups",   ARG_INT, 1, "1",    offsetof(ir_arg, a.remove_dups)},
 	{"-link_pairs",    ARG_INT, 1, "1",    offsetof(ir_arg, a.link_pairs)},
+	{"-qual",          ARG_INT, 1, "-3",   offsetof(ir_arg, a.qual)},
 	{NULL,		   0,	    0, NULL,   0}
     };
 
@@ -2028,9 +2149,6 @@ tcl_import_reads(ClientData clientData,
 
     /* Add to our sequence name B+Tree */
     if (args.a.tmp) {
-	char *name;
-	tg_rec rec;
-
 	vmessage("Sorting sequence name index\n");
 
 	vmessage("Adding to name index\n");
@@ -2152,7 +2270,9 @@ int tcl_shuffle_pads(ClientData clientData, Tcl_Interp *interp,
 	{"-io",		ARG_IO,  1, NULL,  offsetof(shuffle_arg, io)},
 	{"-contigs",	ARG_STR, 1, "*",   offsetof(shuffle_arg, inlist)},
 	{"-band",	ARG_INT, 1, "8",   offsetof(shuffle_arg, band)},
+	{"-soft_clips", ARG_INT, 1, "0",   offsetof(shuffle_arg, soft_clips)},
 	{"-flush",	ARG_INT, 1, "1",   offsetof(shuffle_arg, flush)},
+	{"-max_pass",   ARG_INT, 1, "10",  offsetof(shuffle_arg, max_pass)},
 	{NULL,	    0,	     0, NULL, 0}
     };
     int rargc;
@@ -2164,7 +2284,8 @@ int tcl_shuffle_pads(ClientData clientData, Tcl_Interp *interp,
     vfuncheader("Shuffle Pads");
 
     active_list_contigs(args.io, args.inlist, &rargc, &rargv);
-    shuffle_contigs_io(args.io, rargc, rargv, args.band, args.flush);
+    shuffle_contigs_io(args.io, rargc, rargv, args.band,
+		       args.soft_clips, args.max_pass, args.flush);
 
     xfree(rargv);
 
@@ -2630,6 +2751,84 @@ int tcl_iter_test(ClientData clientData,
 }
 		  
 
+typedef struct {
+    GapIO *io;
+    char *inlist;
+    float het_score;
+    float discrep_score;
+    int min_count;
+} fh_args;
+int
+tcl_find_haplotypes(ClientData clientData,
+		    Tcl_Interp *interp,
+		    int objc,
+		    Tcl_Obj *CONST objv[])
+{
+    fh_args args;
+    contig_list_t *contig_array = NULL;
+    int ncontigs;
+    GapIO *io;
+    Array rec_list;
+    Tcl_Obj *lobj;
+    int i;
+
+    /* Parse arguments */
+    cli_args a[] = {
+	{"-io",	          ARG_IO,   1,NULL,  offsetof(fh_args, io)},
+	{"-contigs",      ARG_STR,  1,NULL,  offsetof(fh_args, inlist)},
+	{"-het_score",    ARG_FLOAT,1,"10.0",offsetof(fh_args, het_score)},
+	{"-discrep_score",ARG_FLOAT,1, "5.0",offsetof(fh_args, discrep_score)},
+	{"-min_count",    ARG_INT,  1, "3",  offsetof(fh_args, min_count)},
+	{NULL,	           0,	    0,NULL, 0}
+    };
+
+    vfuncheader("Find Haplotypes");
+
+    if (-1 == gap_parse_obj_args(a, &args, objc, objv))
+	return TCL_ERROR;
+
+    /* Fetch the list of contig records */
+    io = args.io;
+    active_list_contigs(io, args.inlist, &ncontigs, &contig_array);
+    if (ncontigs == 0) {
+	if (contig_array)
+	    xfree(contig_array);
+	return TCL_OK;
+    }
+
+    /* Do it */
+    rec_list = find_haplotypes(args.io, contig_array, ncontigs, 1,
+			       args.het_score, args.discrep_score,
+			       args.min_count);
+    if (!rec_list)
+	return TCL_ERROR;
+
+    lobj = Tcl_NewListObj(0, NULL);
+    for (i = 0; i < ArrayMax(rec_list); i++) {
+	Array x = arr(Array, rec_list, i);
+	int j;
+	Tcl_Obj *lobj2 = Tcl_NewListObj(0, NULL);
+
+	for (j = 0; j < ArrayMax(x); j++) {
+	    Tcl_ListObjAppendElement(interp, lobj2,
+				     Tcl_NewWideIntObj(arr(tg_rec, x, j)));
+	}
+	Tcl_ListObjAppendElement(interp, lobj, lobj2);
+    }
+    
+    Tcl_SetObjResult(interp, lobj);
+
+    for (i = 0; i < ArrayMax(rec_list); i++)
+	ArrayDestroy(arr(Array, rec_list, i));
+    ArrayDestroy(rec_list);
+
+    if (contig_array)
+	xfree(contig_array);
+
+    return TCL_OK;
+}
+
+
 /* set up tcl commands which call C procedures */
 /*****************************************************************************/
 /*				   NewGap_Init				     */
@@ -2804,6 +3003,8 @@ NewGap_Init(Tcl_Interp *interp) {
 			 (ClientData) NULL, NULL);
     Tcl_CreateObjCommand(interp, "calc_quality", tcl_calc_quality,
 			 (ClientData) NULL, NULL);
+    Tcl_CreateObjCommand(interp, "calc_ref_positions", tcl_calc_ref_positions,
+			 (ClientData) NULL, NULL);
     Tcl_CreateObjCommand(interp, "calc_consensus_full",
 			 tcl_calc_consensus_full,
 			 (ClientData) NULL, NULL);
@@ -2845,6 +3046,10 @@ NewGap_Init(Tcl_Interp *interp) {
 			 tcl_import_gff,
 			 (ClientData) NULL, NULL);
 
+    Tcl_CreateObjCommand(interp, "export_snps",
+			 tcl_export_snps,
+			 (ClientData) NULL, NULL);
+
     Tcl_CreateObjCommand(interp, "find_oligo",
 			 tcl_find_oligo,
 			 (ClientData) NULL, NULL);
@@ -2891,6 +3096,9 @@ NewGap_Init(Tcl_Interp *interp) {
     Tcl_CreateObjCommand(interp, "pair_readings",
 			 tcl_pair_readings,
 			 (ClientData) NULL, NULL);
+    Tcl_CreateObjCommand(interp, "find_haplotypes",
+			 tcl_find_haplotypes,
+			 (ClientData) NULL, NULL);
 			 
     
     Tk_CreateItemType(&tkTDItem);
diff --git a/gap5/newgap_structs.h b/gap5/newgap_structs.h
index 8ee7c5b..f09757a 100644
--- a/gap5/newgap_structs.h
+++ b/gap5/newgap_structs.h
@@ -557,7 +557,12 @@ typedef struct {
     GapIO *io;
     char *inlist;
     int band;
+    int soft_clips;
     int flush;
+    int max_pass;
+    float het_score;
+    float discrep_score;
+    int min_haplo_depth;
 } shuffle_arg;
 
 #ifdef USE_BIOLIMS
diff --git a/gap5/ng_fb_cmds.tcl b/gap5/ng_fb_cmds.tcl
index 36f8fce..b0b04de 100644
--- a/gap5/ng_fb_cmds.tcl
+++ b/gap5/ng_fb_cmds.tcl
@@ -205,6 +205,8 @@ proc New_Open_Database { f entry_content browsed_path } {
     #catch {file delete -force $db_name.$version.BUSY}
     set io [g5::open_database -name $file -access $access -create $create]
 
+    set_database_defaults $io
+
     return $io
 }
 
@@ -242,6 +244,7 @@ proc DB_Load { file } {
 
     set orig_type $licence(type)
     set new_io [g5::open_database -name "$db_name" -access $access]
+    set_database_defaults $new_io
     global debug_level
     $new_io debug_level $debug_level
 
diff --git a/gap5/qualIO.c b/gap5/qualIO.c
index 39b9674..49beb12 100644
--- a/gap5/qualIO.c
+++ b/gap5/qualIO.c
@@ -363,7 +363,7 @@ double list_base_confidence(int *matfreqs, int *misfreqs, long matrix[6][6])
     /* Substitution matrix */
     {
 	int b1, b2;
-	long tmis = 0, tins = 0, tdel = 0;
+	long tmis = 0, tins = 0, tdel = 0, tmat = 0;
 
 	vmessage("Substitution matrix:\n");
 	vmessage("call\\cons  A        C        G        T        N        *");
@@ -373,18 +373,25 @@ double list_base_confidence(int *matfreqs, int *misfreqs, long matrix[6][6])
 		vmessage(" %8ld", matrix[b1][b2]);
 		if (b1 != b2) {
 		    if (b1 == 5)
-			tdel += matrix[b1][b2];
-		    else if (b2 == 5)
 			tins += matrix[b1][b2];
+		    else if (b2 == 5)
+			tdel += matrix[b1][b2];
 		    else
 			tmis += matrix[b1][b2];
+		} else if (b1 < 4) {
+		    tmat += matrix[b1][b2];
 		}
 	    }
 	}
-	vmessage("\n\nTotal mismatches = %ld, insertions = %ld, "
-		 "deletions = %ld\n\n",
-		 tmis, tins, tdel);
-    }
+	vmessage("\n\nTotal matches = %ld, mismatches = %ld, "
+		 "insertions = %ld, deletions = %ld\n\n",
+		 tmat, tmis, tins, tdel); 
+
+	tmat += tdel; // aligned against non-* consensus.
+	vmessage("Substitution rate %5.2f%%\n",   100.0 * tmis / tmat);
+	vmessage("Insertion rate    %5.2f%%\n",   100.0 * tins / tmat);
+	vmessage("Deletion rate     %5.2f%%\n\n", 100.0 * tdel / tmat);
+   }
 
     /* Headings */
     vmessage("Conf.        Match        Mismatch           Expected      Over-\n");
diff --git a/gap5/quality_plot.c b/gap5/quality_plot.c
index 24ce2d9..f13cb99 100644
--- a/gap5/quality_plot.c
+++ b/gap5/quality_plot.c
@@ -285,7 +285,7 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
     XSegment *xs = NULL;
     consensus_t *cons;
     int i, len;
-    float yz, xz;
+    double yz, xz;
     int mode = 0;
 
     if (!qp->pm)
@@ -304,20 +304,35 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
     /* Fetch consensus */
     len = (int)qp->wx1 - (int)qp->wx0 + 1;
     cons = malloc(len * sizeof(*cons));
+    if (NULL == cons) return;
     //calculate_consensus_fast(qp->io, qp->contig, qp->wx0, qp->wx1, cons);
     calculate_consensus_bit_het(qp->io, qp->contig, qp->wx0, qp->wx1, mode,
     				qp->gr->r, qp->gr->nr, cons);
 
     yz = qp->height / (MAX_QUAL+1 + 10.0);
-    xz = len / (double)qp->width;
+    xz = (double)qp->width / len;
     qp->yz = yz;
 
     /* Plot it */
-    xp = malloc(qp->width * sizeof(*xp));
-    xs = malloc(qp->width * sizeof(*xs));
+    if (xz > 1) {
+	xp = malloc(qp->width * sizeof(*xp));
+	if (NULL == xp) {
+	    free(cons);
+	    return;
+	}
+    } else {
+	/* +1 here to deal with possible rounding error
+	   when calculating xz * i below. */
+	xs = malloc((qp->width + 1) * sizeof(*xs));
+	if (NULL == xs) {
+	    free(cons);
+	    return;
+	}
+    }
 
     if (qp->quality) {
-	if (xz <= 1) {
+	if (xz > 1) {
+	    assert(xp != NULL);
 	    for (i = 0; i < qp->width; i++) {
 		int J = i * (qp->wx1 - qp->wx0) / qp->width;
 		int v = cons[J].phred;
@@ -333,13 +348,14 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
 		       CoordModeOrigin);
 	} else {
 	    int ox = -1;
+	    assert(xs != NULL);
 	    for (i = 0; i < len; i++) {
 		int x, v = cons[i].phred;
 		if (v > MAX_QUAL) v = MAX_QUAL;
 		if (v < 0)        v = 0;
 	    
-		x = i / xz;
-		assert(x >= 0 && x < qp->width);
+		x = i * xz;
+		assert(x >= 0 && x <= qp->width);
 		if (x == ox) {
 		    if (xs[x].y1 < yz * (MAX_QUAL+1-v + 5))
 			xs[x].y1 = yz * (MAX_QUAL+1-v + 5);
@@ -365,7 +381,8 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
     }
 
     if (qp->hetero) {
-	if (xz <= 1) {
+	if (xz > 1) {
+	    assert(xp != NULL);
 	    for (i = 0; i < qp->width; i++) {
 		int J = i * (qp->wx1 - qp->wx0) / qp->width;
 		int v = cons[J].scores[6];
@@ -382,14 +399,15 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
 		       CoordModeOrigin);
 	} else {
 	    int ox = -1;
+	    assert(xs != NULL);
 	    for (i = 0; i < len; i++) {
 		int x, v = cons[i].scores[6];
 		//v = cons[i].phred;
 		if (v > MAX_QUAL) v = MAX_QUAL;
 		if (v < 0)        v = 0;
 	    
-		x = i / xz;
-		assert(x >= 0 && x < qp->width);
+		x = i * xz;
+		assert(x >= 0 && x <= qp->width);
 		if (x == ox) {
 		    if (xs[x].y2 > yz * (MAX_QUAL+1-v + 5))
 			xs[x].y2 = yz * (MAX_QUAL+1-v + 5);
@@ -407,7 +425,8 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
     }
 
     if (qp->discrep) {
-	if (xz <= 1) {
+	if (xz > 1) {
+	    assert(xp != NULL);
 	    for (i = 0; i < qp->width; i++) {
 		int J = i * (qp->wx1 - qp->wx0) / qp->width;
 		int v = cons[J].discrep * 10;
@@ -423,13 +442,14 @@ static void qplot_redraw(QualityPlot *qp, Display *display) {
 		       CoordModeOrigin);
 	} else {
 	    int ox = -1;
+	    assert(xs != NULL);
 	    for (i = 0; i < len; i++) {
 		int x, v = cons[i].discrep * 10;
 		if (v > MAX_QUAL) v = MAX_QUAL;
 		if (v < 0)        v = 0;
 	    
-		x = i / xz;
-		assert(x >= 0 && x < qp->width);
+		x = i * xz;
+		assert(x >= 0 && x <= qp->width);
 		if (x == ox) {
 		    if (xs[x].y2 > yz * (MAX_QUAL+1-v + 5))
 			xs[x].y2 = yz * (MAX_QUAL+1-v + 5);
diff --git a/gap5/replay_log.tcl b/gap5/replay_log.tcl
new file mode 100644
index 0000000..c01532f
--- /dev/null
+++ b/gap5/replay_log.tcl
@@ -0,0 +1,401 @@
+# This script reads a gap5 .log file (written if DO_LOGGING is enabled) and
+# attempts to produce a script that can be pasted into the gap5 console
+# to reproduce the events recorded in the log.  It's not very elegant and
+# is incomplete (e.g. disassemble reads is not supported) so the results may
+# diverge from reality after a while.  It was useful for tracking down bugs
+# with pair_rec updates and shuffle_pads, though.
+
+# To use, it needs a copy of the database as it was before the events being
+# replayed happened, and a .log file.  The script converts the .log file
+# into a fragment of tcl script:
+
+# tclsh replay_log.tcl < db.0.log > cmds
+
+# Then open the database in gap5 and bring up the console window.  
+# To ensure the right libraries are present, type 'edit_contig'.
+# Then cut and paste the contents of the generated file into the console.
+
+# N.B. As the replay may diverge from the original edits, it's possible
+# for things to happen that wouldn't be allowed normally.  For example,
+# if a break happens in a location slightly different from the original
+# it's possible to clip sequences from the wrong contig editor later on,
+# resulting in inconsistencies or worse when the contigs are saved.
+# It's important to check for a faulty replay when finding the cause of
+# database inconsistencies and crashes, to avoid wasting time on false
+# leads.
+
+# Map original contig numbers to new ones.  Needed because break_contig
+# may return a different number to the one in the original log file.
+proc map_ctg { ctg ccmap } {
+    upvar $ccmap cmap
+    if { [ info exists cmap($ctg) ] } {
+	return $cmap($ctg)
+    }
+    return $ctg
+}
+
+set last_pid_host {}
+set cmds {}
+set main_io {}
+array set saved {}
+array set join_eds {}
+array set contig_editors {}
+array set editor_contigs {}
+
+# Parse the log file.
+while {[gets stdin line] >= 0} {
+
+    # Ensure we only replay data from a single gap5 run by checking
+    # that the host name and pid don't change.
+    regexp {\[\d+@\w+\]} $line pid_host
+    if { $last_pid_host eq "" } { set last_pid_host $pid_host }
+    if { $last_pid_host ne $pid_host } { break }
+
+    if { [regexp {log_call contig_editor (\.e\d+) -io io=(0x[0-9a-f]+) -contig (\d+)} $line cmd ed_num io ctg_num ] } {
+
+	# Parse contig_editor command.  Keep track of which editors
+	# are open on each contig, and which contig is in each editor.
+
+	if { ! [regexp { \-pos (-?\d+)} $line dummy pos] } { set pos "" }
+	if {[regexp { \-contig2 (\d+)} $line dummy ctg2]} {
+	    # Join editor version
+	    if { ! [regexp { \-pos2 (-?\d+)} $line dummy pos2] } { set pos2 "" }
+	    lappend cmds [list contig_editor $ed_num $ctg_num $ctg2 $pos $pos2]
+	    array set join_eds [list "$ctg_num/$ctg2" $ed_num]
+	    lappend contig_editors($ctg_num) "$ed_num.ed1.pane.seq.sheet"
+	    lappend contig_editors($ctg2) "$ed_num.ed0.pane.seq.sheet"
+	    lappend editor_contigs($ed_num) $ctg_num $ctg2
+	} else {
+	    # Ordinary contig editor
+	    lappend cmds [list contig_editor $ed_num $ctg_num $pos]
+	    lappend contig_editors($ctg_num) "$ed_num.ed1.pane.seq.sheet"
+	    lappend editor_contigs($ed_num) $ctg_num
+	}
+	puts stderr ":: $ed_num $editor_contigs($ed_num)"
+	if { $main_io eq "" } {
+	    set main_io $io
+	}
+	array set saved [list $ed_num -1]
+
+    } elseif { [regexp { log_str editor_exit (\.e\d+) } $line cmd ed_num ] } {
+
+	# Parse editor_exit
+
+	lappend cmds [list editor_exit $ed_num ]
+	puts stderr "exit $ed_num"
+	if { [info exists editor_contigs($ed_num)] } {
+	    foreach ctg $editor_contigs($ed_num) {
+		set new_list {}
+		foreach ed $contig_editors($ctg) {
+		    # puts stderr "xx $ctg $ed"
+		    if { [regexp {^(\.e\d+)\.} $ed dummy e] } {
+			# puts stderr "xx $ctg $ed $e $ed_num"
+			if { $e ne $ed_num } {
+			    lappend new_list $ed
+			}
+		    }
+		}
+		puts stderr "yy $ctg $new_list"
+		set contig_editors($ctg) $new_list
+		set editor_contigs($ed_num) {}
+	    }
+	}
+
+    } elseif { [regexp { log_call (\.e\d+)\.ed(\d)\.pane\.seq\.sheet save} $line cmd ed_num ed] } {
+
+	# Parse contig editor save button
+
+	set s [array get saved $ed_num]
+	if { $s eq "" } {
+	    puts stderr "save on unknown editor $ed_num"
+	    exit 1
+	}
+	array set saved [list $ed_num [llength $cmds]]
+
+	# If the previous command was editor_exit, user closed the window
+	# then said 'yes' to save.  In this case we need to reverse the
+	# order of events to we save before exit.
+
+	set prev [lindex $cmds end]
+	if {[lindex $prev 0] eq "editor_exit" && [lindex $prev 1] eq $ed_num} {
+	    lset cmds end [list save $ed_num $ed]
+	    lappend cmds $prev
+	} else {
+	    lappend cmds [list save $ed_num $ed]
+	}
+
+    } elseif { [regexp { log_call (\.e\d+)\.ed(\d)\.pane\.seq\.sheet join} $line cmd ed_num ed] } {
+
+	# Parse join editor join button
+
+	array set saved [list $ed_num [llength $cmds]]
+	lappend cmds [list join $ed_num $ed]
+
+	foreach { ctg1 ctg2 } $editor_contigs($ed_num) break
+	foreach ed $contig_editors($ctg2) {
+	    if { [regexp {^(\.e\d+)\.} $ed dummy e] } {
+		lappend contig_editors($ctg1) "$ed"
+		set editor_contigs($e) $ctg1
+	    }
+	}
+	set contig_editors($ctg2) {}
+
+    } elseif { [regexp { edJoinAlign fixed_left=(\d) fixed_right=(\d) =(\d+)@(-?\d+) =(\d+)@(-?\d+)} $line cmd fleft fright ctg1 pos1 ctg2 pos2] } {
+
+	# Parse join editor align button
+
+	set ed [array get join_eds "$ctg2/$ctg1"]
+	if {$ed ne ""} {
+	    lappend cmds [list edJoinAlign [lindex $ed 1] $fleft $fright $ctg1 $pos1 $ctg2 $pos2]
+	} else {
+	    puts stderr "No join editor for $ctg1 $ctg2"
+	    exit 1
+	}
+
+    } elseif { [regexp { editor_delete_base (\.e\d+)\.ed(\d)\.pane\.seq\.sheet {(\d+) (\d+) (-?\d+)} (\d) (\d) (\d)} $line cmd ed_num ed type ctg pos end dir powerup] } {
+
+	# Parse editor_delete_base
+
+	lappend cmds [list editor_delete_base $ed_num $ed $type $ctg $pos $end $dir $powerup]
+
+    } elseif { [regexp { editor_clip_seq (\.e\d+)\.ed(\d)\.pane\.seq\.sheet {(\d+) (\d+) (-?\d+)} ([lr])} $line cmd ed_num ed type ctg pos dirn] } {
+
+	# Parse editor_clip_seq
+
+	lappend cmds [list editor_clip_seq $ed_num $ed $type $ctg $pos $dirn]
+
+    } elseif { [regexp { editor_clip_contig (\.e\d+)\.ed(\d)\.pane\.seq\.sheet {(\d+) (\d+) (-?\d+)} ([lr])} $line cmd ed_num ed type ctg pos dirn] } {
+
+	# Parse editor_clip_contig
+	# Only bother to record if it wasn't preceeded by editor_clip_seq
+	# on the same contig.
+
+	if { [llength $cmds] > 0 \
+		 && !( [lindex $cmds end 0] eq "editor_clip_seq"
+		      && [lindex $cmds end 1] eq "$ed_num"
+		      && [lindex $cmds end 3] == $type
+		      && [lindex $cmds end 4] == $ctg) } {
+	    lappend cmds [list editor_clip_contig $ed_num $ed $type $ctg $pos $dirn]
+	}
+
+    } elseif { [regexp { break_contig -io io=0x[0-9a-f]+ -contig (\d+) -pos (-?\d+) -break_holes (\d)} $line cmd ctg pos holes] } {
+
+	# Parse break_contig
+
+	lappend cmds [list break_contig 0 $ctg $pos $holes]
+
+    } elseif { [regexp {shuffle_pads -io io=(0x[0-9a-f]+) -contigs {((?:{=\d+ -?\d+ -?\d+})+)} -flush (\d+) -band (\d+) -soft_clips (\d+) -max_pass (\d+)} $line cmd io contigs do_flush band soft_clips max_pass] } {
+
+	# Parse shuffle_pads
+
+	if { $io eq $main_io } {
+	    # Verision invoked from the main menu
+	    lappend cmds [list shuffle_pads main $contigs $do_flush $band $soft_clips $max_pass]
+	} else {
+	    # Version invoked from a contig editor.  We need to work out
+	    # which one it was, as this isn't recorded in the log file.
+	    puts stderr "$contigs"
+	    foreach { item } $contigs {
+		puts stderr "$item"
+		foreach { eqctg from to } $item { 
+		    set ctg [string range $eqctg 1 end]
+		    puts stderr "$eqctg $ctg $contig_editors($ctg)"
+		    if { [llength $contig_editors($ctg)] > 0 } {
+			set ed [lindex $contig_editors($ctg) 0]
+			lappend cmds [list shuffle_pads $ed [list [list $ctg $from $to]] $do_flush $band $soft_clips $max_pass]
+		    } else {
+			lappend cmds [list shuffle_pads {unknown} [list [list $ctg $from $to]] $do_flush $band $soft_clips $max_pass]
+		    }
+		}
+	    }
+	}
+
+    } elseif {[regexp { io_undo_exec (\.e\d+)\.ed(\d)\.pane\.seq\.sheet (\d+)} $line cmd ed_num ed ctg]} {
+
+	# Parse io_undo_exec
+
+	lappend cmds [list io_undo $ed_num $ed $ctg]
+    }
+}
+
+
+# Generate the new script fragment.
+
+set p 0
+array set used {}
+array set cmap {}
+set new_ctg 0
+for { set ci 0 } { $ci < [llength $cmds] } { incr ci } {
+    set cmd [lindex $cmds $ci]
+    set c [lindex $cmd 0]
+    set ed_num [lindex $cmd 1]
+    set s [array get saved $ed_num]
+    if { $s ne "" } {
+	set sp [lindex $s 1]
+    } else {
+	set sp -1
+    }
+    puts "# $cmd"
+    if { 1 || $p <= $sp \
+	     || ($c eq "editor_exit" && [array get used $ed_num] ne "") \
+	     || $c eq "break_contig" } {
+	if { $c eq "contig_editor" } {
+	    array set used [list $ed_num 1]
+	}
+
+	if { $c eq "contig_editor" } {
+
+	    # contig_editor command
+
+	    if {[llength $cmd] == 4} {
+		# Ordinary contig editor
+		set ctg1 [map_ctg [lindex $cmd 2] cmap]
+		if {[lindex $cmd 3] ne ""} {
+		    set pos " -pos [lindex $cmd 3]"
+		} else {
+		    set pos ""
+		}
+		puts "contig_editor $ed_num -io \$io -contig $ctg1$pos"
+	    } else {
+		# Join editor
+		set ctg1 [map_ctg [lindex $cmd 2] cmap]
+		set ctg2 [map_ctg [lindex $cmd 3] cmap]
+		if {[lindex $cmd 4] ne ""} {
+		    set pos " -pos [lindex $cmd 4]"
+		} else {
+		    set pos ""
+		}
+		if {[lindex $cmd 5] ne ""} {
+		    set pos2 " -pos2 [lindex $cmd 5]"
+		} else {
+		    set pos2 ""
+		}
+		puts "contig_editor $ed_num -io \$io -contig $ctg1$pos -contig2 $ctg2$pos2"
+	    }
+	    # Call update so the editor appears
+	    puts "update idletasks"
+
+	} elseif { $c eq "editor_exit" } {
+
+	    # editor_exit command
+
+	    puts "editor_exit $ed_num 0 1"
+	    puts "update idletasks"
+
+	} elseif { $c eq "save" } {
+
+	    # contig editor save
+
+	    set ed [lindex $cmd 2]
+	    puts "log_call $ed_num.ed$ed.pane.seq.sheet save"
+
+	} elseif { $c eq "join" } {
+
+	    # contig editor join
+
+	    set ed [lindex $cmd 2]
+	    puts "$ed_num.ed$ed.pane.seq.sheet join"
+
+	} elseif { $c eq "editor_delete_base" } {
+
+	    # editor_delete_base
+	    # Need to set cursor to the right position first for this to
+	    # work properly.
+
+	    foreach { ed type ctg pos end dir powerup } [lrange $cmd 2 end] {
+		set mctg [map_ctg $ctg cmap]
+		puts "$ed_num.ed$ed.pane.seq.sheet set_cursor 17 $mctg $pos"
+		puts "editor_delete_base $ed_num.ed$ed.pane.seq.sheet \[list $type $mctg $pos\] $end $dir $powerup"
+		puts "update idletasks"
+	    }
+
+	} elseif { $c eq "editor_clip_seq" } {
+
+	    # editor_clip_seq
+
+	    foreach { ed type ctg pos dirn } [lrange $cmd 2 end] {
+		set mctg [map_ctg $ctg cmap]
+		puts "editor_clip_seq $ed_num.ed$ed.pane.seq.sheet \[list $type $mctg $pos\] $dirn"
+	    }
+
+	} elseif { $c eq "editor_clip_contig" } {
+
+	    # editor_clip_contig
+
+	    foreach { ed type ctg pos dirn } [lrange $cmd 2 end] {
+		set mctg [map_ctg $ctg cmap]
+		puts "editor_clip_contig $ed_num.ed$ed.pane.seq.sheet \[list $type $mctg $pos\] $dirn"
+	    }
+
+	} elseif { $c eq "edJoinAlign" } {
+
+	    # contig editor align button
+
+	    foreach { fleft fright ctg1 pos1 ctg2 pos2 } [lrange $cmd 2 end] {
+		puts "set $ed_num\(Lock) 0"
+		puts "editor_lock $ed_num"
+		puts "$ed_num.ed1.pane.seq.sheet xview $pos1"
+		puts "$ed_num.ed0.pane.seq.sheet xview $pos2"
+		puts "set $ed_num\(Lock) 1"
+		puts "editor_lock $ed_num"
+		puts "$ed_num.ed0.pane.seq.sheet join_align $fleft $fright"
+	    }
+
+	} elseif { $c eq "break_contig" } {
+
+	    # break_contig
+	    # We have to capture the record number for the new contig,
+	    # and add it to cmap so we can translate the number that was
+	    # used in the log file.  We get the old contig number by
+	    # looking for the second contig editor to come up after
+	    # break contig.
+
+	    foreach { ctg pos holes } [lrange $cmd 2 end] {
+		set mctg [map_ctg $ctg cmap]
+		incr new_ctg
+		puts "set new_ctg_$new_ctg \[break_contig -io \$io -contig $mctg -pos $pos -break_holes $holes\]"
+	    }
+	    if { [lindex $cmds [expr { $ci + 2 } ] 0 ] eq "contig_editor" } {
+		set ctg [lindex $cmds [expr { $ci + 2 } ] 2]
+		array set cmap [list $ctg "\$new_ctg_$new_ctg"]
+	    } else {
+		puts stderr "Couldn't get old contig name for break_contig"
+		exit 1
+	    }
+
+	} elseif { $c eq "shuffle_pads" } {
+
+	    # Shuffle pads
+
+	    foreach { ed contigs do_flush band soft_clips max_pass } [lrange $cmd 1 end] {
+		if { $ed eq "unknown" } {
+		    # puts -nonewline "# "
+		}
+		puts -nonewline "log_call shuffle_pads -io "
+		if { $ed eq "main" || $ed eq "unknown" } {
+		    # Shuffle pads from main menu
+		    puts -nonewline "\$io -contigs \[list"
+		} else {
+		    # Shuffle pads from contig editor
+		    puts -nonewline "\[$ed io\] -contigs \[list"
+		}
+		# Translate the contig numbers if necessary
+		foreach { contig } $contigs {
+		    foreach { ctg from to } $contig break
+		    set mctg [map_ctg $ctg cmap]
+		    puts -nonewline " \[list \"=${mctg}\" $from $to\]"
+		}
+		puts "\] -flush $do_flush -band $band -soft_clips $soft_clips -max_pass $max_pass"
+	    }
+
+	} elseif { $c eq "io_undo" } {
+
+	    # undo pressed.
+
+	    foreach { ed ctg } [lrange $cmd 2 end] break
+	    set mctg [map_ctg $ctg cmap]
+	    puts "io_undo $ed_num.ed$ed.pane.seq.sheet $mctg"
+	}
+    }
+    incr p
+}
diff --git a/gap5/sam_index.c b/gap5/sam_index.c
index ae06216..df3eabd 100644
--- a/gap5/sam_index.c
+++ b/gap5/sam_index.c
@@ -8,6 +8,7 @@
 #include "tg_gio.h"
 #include "tg_struct.h"
 #include "tg_index_common.h"
+#include "break_contig.h" /* For contig_visible_{start,end} */
 #include "sam_index.h"
 
 #include <staden_config.h>
@@ -97,6 +98,18 @@ int stech_str2int(const char *str) {
     if (strcasecmp(str, "SOLID") == 0)
 	return STECH_SOLID;
 
+    if (strcasecmp(str, "HELICOS") == 0)
+	return STECH_HELICOS;
+
+    if (strcasecmp(str, "IONTORRENT") == 0)
+	return STECH_IONTORRENT;
+
+    if (strcasecmp(str, "PACBIO") == 0)
+	return STECH_PACBIO;
+
+    if (strcasecmp(str, "ONT") == 0)
+	return STECH_ONT;
+
     return STECH_UNKNOWN;
 }
 
@@ -318,59 +331,6 @@ bio_seq_t *bio_new_seq(bam_io_t *bio, pileup_t *p, int pos) {
 }
 
 
-static char *append_int(char *cp, int i) {
-    int j, k = 0;
-
-    if (i < 0) {
-	*cp++ = '-';
-	i = -i;
-    } else if (i == 0) {
-	*cp++ = '0';
-	return cp;
-    }
-
-    if (i < 1000)
-	goto b1;
-    if (i < 100000)
-	goto b2;
-    if (i < 100000000)
-	goto b3;
-
-    j = i / 1000000000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 1000000000;
-
-    j = i / 100000000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 100000000;
-    
- b3:
-    j = i / 10000000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 10000000;
-    
-    j = i / 1000000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 1000000;
-    
-    j = i / 100000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 100000;
-    
- b2:
-    j = i / 10000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 10000;
-
-    j = i / 1000;
-    if (j || k) *cp++ = j + '0', k=1, i %= 1000;
-
- b1:
-    j = i / 100;
-    if (j || k) *cp++ = j + '0', k=1, i %= 100;
-
-    j = i / 10;
-    if (j || k) *cp++ = j + '0', k=1, i %= 10;
-
-    if (i || k) *cp++ = i + '0';
-
-    return cp;
-}
-
 #define APPEND_FMT(fmt) \
     *cp++ = s[0]; \
     *cp++ = s[1]; \
@@ -713,8 +673,9 @@ int faster_fprintf(FILE *fp, char *fmt, ...) {
 #endif
 
 char *sam_aux_stringify(char *s, int len) {
-    static char str[8192];
-    char *cp = str, *s_end = s+len;
+    static unsigned char str[8192];
+    unsigned char *cp = str;
+    char *s_end = s+len;
     int first = 1;
 
     //write(2, s, (int)(((char *)&b->ref) + b->blk_size - (uint8_t *)s));
@@ -797,7 +758,7 @@ char *sam_aux_stringify(char *s, int len) {
 		float f;
 		memcpy(&f, s+3, 4);
 		APPEND_FMT('f');
-		cp += sprintf(cp, "%f", f);
+		cp += sprintf((char *) cp, "%f", f);
 	    }
 	    s+=7;
 	    break;
@@ -807,7 +768,7 @@ char *sam_aux_stringify(char *s, int len) {
 		double d;
 		memcpy(&d, s+3, 8);
 		APPEND_FMT('f');
-		cp += sprintf(cp, "%f", d);
+		cp += sprintf((char *) cp, "%f", d);
 	    }
 	    s+=11;
 	    break;
@@ -828,12 +789,12 @@ char *sam_aux_stringify(char *s, int len) {
 
     *cp = 0;
 
-    return str;
+    return (char *) str;
 }
 
 char *bam_aux_stringify(bam_seq_t *b, int no_RG) {
-    static char str[8192];
-    char *s = (char *)bam_aux(b), *cp = str;
+    static unsigned char str[8192];
+    unsigned char *s = (unsigned char *) bam_aux(b), *cp = str;
     int first = 1;
     int keep;
 
@@ -841,7 +802,7 @@ char *bam_aux_stringify(bam_seq_t *b, int no_RG) {
 
     //write(2, s, (int)(b->data + b->data_len - (uint8_t *)s));
 
-    while ((uint8_t *)s < ((uint8_t *)&b->ref) + b->blk_size) {
+    while (s < ((unsigned char *) &b->ref) + b->blk_size) {
 
 	keep = (no_RG && s[0] == 'R' && s[1] == 'G') ? 0 : 1;
 	if (keep) {
@@ -929,7 +890,7 @@ char *bam_aux_stringify(bam_seq_t *b, int no_RG) {
 		float f;
 		memcpy(&f, s+3, 4);
 		APPEND_FMT('f');
-		cp += sprintf(cp, "%f", f);
+		cp += sprintf((char *) cp, "%f", f);
 	    }
 	    s+=7;
 	    break;
@@ -939,7 +900,7 @@ char *bam_aux_stringify(bam_seq_t *b, int no_RG) {
 		double d;
 		memcpy(&d, s+3, 8);
 		APPEND_FMT('f');
-		cp += sprintf(cp, "%f", d);
+		cp += sprintf((char *) cp, "%f", d);
 	    }
 	    s+=11;
 	    break;
@@ -965,7 +926,7 @@ char *bam_aux_stringify(bam_seq_t *b, int no_RG) {
 
     *cp = 0;
 
-    return str;
+    return (char *) str;
 }
 
 /*
@@ -1113,17 +1074,9 @@ int bio_add_unmapped(bam_io_t *bio, bam_seq_t *b) {
     }
 
     /* Fetch read-group and pretend it's a library for now */
-    stech = STECH_UNKNOWN;
-    if ((LB = bam_aux_find(b, "RG"))) {
-	SAM_RG *rg_tag = sam_hdr_find_rg(scram_get_header(bio->fp), ++LB);
-	if (rg_tag) {
-	    SAM_hdr_tag *t = sam_hdr_find_key(scram_get_header(bio->fp),
-					      rg_tag->ty, LB, NULL);
-	    if (t)
-		stech = stech_str2int(t->str);
-	}
-    }
-    if (!LB)
+    if ((LB = bam_aux_find(b, "RG")))
+	LB++;  // bam_aux_find returned the type code too.
+    else
 	LB = bio->fn;
 
     suffix = bam_aux_find(b, "FS");
@@ -1134,6 +1087,15 @@ int bio_add_unmapped(bam_io_t *bio, bam_seq_t *b) {
     hi = HacheTableAdd(bio->libs, (char *)LB, strlen(LB), hd, &new);
     if (new) {
 	tg_rec lrec;
+	SAM_RG *rg_tag = sam_hdr_find_rg(scram_get_header(bio->fp), LB);
+	if (rg_tag) {
+	    SAM_hdr_tag *t = sam_hdr_find_key(scram_get_header(bio->fp),
+					      rg_tag->ty, "PL", NULL);
+	    stech = t ? stech_str2int(t->str+3) : STECH_UNKNOWN;
+	} else {
+	    stech = STECH_UNKNOWN;
+	}
+
 	printf("New library %s\n", LB);
 
 	lrec = library_new(bio->io, (char *)LB);
@@ -1144,6 +1106,7 @@ int bio_add_unmapped(bam_io_t *bio, bam_seq_t *b) {
 	cache_incr(bio->io, lib);
     }
     lib = hi->data.p;
+    stech = lib->machine;
 
     /* Construct a seq_t struct */
     name = bam_name(b);
@@ -1269,7 +1232,9 @@ int bio_add_unmapped(bam_io_t *bio, bam_seq_t *b) {
     recno = save_range_sequence(bio->io, &s, s.mapping_qual, bio->pair,
     				is_pair, tname, bio->c, bio->a, flags, lib,
 				&bin_rec);
-
+    if (recno < 0) {
+	return -1;
+    }
 
 #ifdef SAM_AUX_AS_TAG
     /* Make an annotation out of the sam auxillary data */
@@ -1468,7 +1433,7 @@ int bio_del_seq(bam_io_t *bio, pileup_t *p) {
     bam_seq_t *b;
     seq_t s;
     HacheItem *hi;
-    tg_rec recno, bin_rec;
+    tg_rec recno = 0, bin_rec;
     int i, paired;
     int is_pair = 0;
     int flags;
@@ -1499,17 +1464,9 @@ int bio_del_seq(bam_io_t *bio, pileup_t *p) {
 	goto anno_only; /* Yes I know! The code needs splitting up */
 
     /* Fetch read-group and pretend it's a library for now */
-    stech = STECH_UNKNOWN;
-    if ((LB = bam_aux_find(b, "RG"))) {
-	SAM_RG *rg_tag = sam_hdr_find_rg(scram_get_header(bio->fp), ++LB);
-	if (rg_tag) {
-	    SAM_hdr_tag *t = sam_hdr_find_key(scram_get_header(bio->fp),
-					      rg_tag->ty, LB, NULL);
-	    if (t)
-		stech = stech_str2int(t->str);
-	}
-    }
-    if (!LB)
+    if ((LB = bam_aux_find(b, "RG")))
+	LB++;  // bam_aux_find returned the type code too.
+    else
 	LB = bio->fn;
 
     suffix = bam_aux_find(b, "FS");
@@ -1520,6 +1477,15 @@ int bio_del_seq(bam_io_t *bio, pileup_t *p) {
     hi = HacheTableAdd(bio->libs, (char *)LB, strlen(LB), hd, &new);
     if (new) {
 	tg_rec lrec;
+	SAM_RG *rg_tag = sam_hdr_find_rg(scram_get_header(bio->fp), LB);
+	if (rg_tag) {
+	    SAM_hdr_tag *t = sam_hdr_find_key(scram_get_header(bio->fp),
+					      rg_tag->ty, "PL", NULL);
+	    stech = t ? stech_str2int(t->str+3) : STECH_UNKNOWN;
+	} else {
+	    stech = STECH_UNKNOWN;
+	}
+
 	printf("New library %s\n", LB);
 
 	lrec = library_new(bio->io, (char *)LB);
@@ -1530,6 +1496,7 @@ int bio_del_seq(bam_io_t *bio, pileup_t *p) {
 	cache_incr(bio->io, lib);
     }
     lib = hi->data.p;
+    stech = lib->machine;
 
     /*
     printf("\nSeq %d @ %6d: '%.*s' '%.*s' => nseq=%d\n",
@@ -1555,7 +1522,7 @@ int bio_del_seq(bam_io_t *bio, pileup_t *p) {
 	}
 	for (i = p->seq_offset+1; i < b->len; i++) {
 	    bs->seq [bs->seq_len] = bam_nt16_rev_table[bam_seqi(b_seq,i)];
-	    bs->conf[bs->seq_len] = b_qual[i];
+	    bs->conf[bs->seq_len] = b_qual[i] > 3 && b_qual[i] < 255 ?b_qual[i] :ABS(bio->a->qual);
 	    bs->pad[bs->seq_len] = bs->padded_pos++;
 	    bs->seq_len++;
 	}
@@ -1679,7 +1646,9 @@ int bio_del_seq(bam_io_t *bio, pileup_t *p) {
     recno = save_range_sequence(bio->io, &s, s.mapping_qual, bio->pair,
     				is_pair, tname, bio->c, bio->a, flags, lib,
 				&bin_rec);
-
+    if (recno < 0) {
+	return -1;
+    }
 
 #ifdef SAM_AUX_AS_TAG
     /* Make an annotation out of the sam auxillary data */
@@ -1979,14 +1948,15 @@ static int sam_add_seq(void *cd, scram_fd *fp, pileup_t *p,
 	bio_new_contig(bio, tid);
 
     /* tg_index -g mode */
+    //printf("%d/%d +%d -%d\n", pos, nth, bio->n_inserts, bio->npads);
     if (bio->a->repad) {
 	pos += bio->c_start-1;
 
 	/* Pad these sequences based on existing pads in the padded contig */
-	if ((np=padtree_pad_at(bio->tree, pos+bio->n_inserts-bio->npads))) {
+	if (!nth && (np=padtree_pad_at(bio->tree, pos+bio->n_inserts-bio->npads))) {
 	    int j;
 
-	    //printf("Pos %d pads %d\n", pos, np);
+	    //printf("Pos %d pads %d, skip = %d\n", pos, np, bio->skip);
 
 	    /* Add pads to match existing consensus gaps */
 	    for (j = nth; j < np; j++) {
@@ -2072,7 +2042,7 @@ static int sam_add_seq(void *cd, scram_fd *fp, pileup_t *p,
 	s = (bio_seq_t *)p->cd;
 
 	/* Extend sequence */
-	if (s->seq_len >= s->alloc_len) {
+	if (s->seq_len >= s->alloc_len || s->padded_pos >= s->alloc_len) {
 	    s->alloc_len = (s->alloc_len + 100)*1.5;
 	    if (NULL == (s->seq  = (char *)realloc(s->seq,  s->alloc_len)))
 		return -1;
@@ -2091,7 +2061,7 @@ static int sam_add_seq(void *cd, scram_fd *fp, pileup_t *p,
 		s->seq [s->seq_len] = 'N';
 	    }
 	    if (bio->a->data_type & DATA_QUAL) {
-		s->conf[s->seq_len] = p->qual;
+	        s->conf[s->seq_len] = p->qual > 3 && p->qual < 255 ?p->qual :ABS(bio->a->qual);
 	    } else {
 		s->conf[s->seq_len] = 0;
 	    }
diff --git a/gap5/sam_pileup.h b/gap5/sam_pileup.h
index 4ad9404..481a9c6 100644
--- a/gap5/sam_pileup.h
+++ b/gap5/sam_pileup.h
@@ -29,6 +29,7 @@ typedef struct pileup {
     char start;		  // True if this is a new sequence
     char ref_skip;        // True if the cause of eof or start is cigar N
     char padding;         // True if the base was added due to another seq
+                          //   or a deletion.
 } pileup_t;
 
 int pileup_loop(scram_fd *fp,
diff --git a/gap5/shuffle_pads.c b/gap5/shuffle_pads.c
index 7f56bbf..914f94f 100644
--- a/gap5/shuffle_pads.c
+++ b/gap5/shuffle_pads.c
@@ -81,6 +81,8 @@
 #include "consensus.h"
 #include "tg_contig.h"
 #include "break_contig.h" /* contig_visible_start(), contig_visible_end() */
+#include "io_lib/hash_table.h"
+#include "str_finder.h"
 
 typedef struct {
     int pos;
@@ -90,6 +92,32 @@ typedef struct {
 void print_malign(MALIGN *malign);
 void print_moverlap(MALIGN *malign, MOVERLAP *o, int offset);
 
+static int common_word_L(int *counts, char *seq, int len);
+static int common_word_R(int *counts, char *seq, int len);
+int *find_adapter(GapIO *io, int ncontigs, contig_list_t *contigs);
+int rewrite_soft_clips(GapIO *io, tg_rec crec, int start, int end,
+		       HashTable *h_clips, int set_to_old);
+
+/* Returns depadded 'pos' in s */
+static int depad_clip(seq_t *s, int pos) {
+    int i, p;
+    for (i = p = 0; i < ABS(s->len) && i < pos; i++) {
+	if (s->seq[i] != '*')
+	    p++;
+    }
+    return p;
+}
+
+/* Repads 'pos' in s */
+static int repad_clip(seq_t *s, int pos) {
+    int i, p;
+    for (i = p = 0; i < ABS(s->len) && p < pos; i++)
+	if (s->seq[i] != '*')
+	    p++;
+    return i;
+}
+
+
 /*
  * Insert 'size' pads into a contig at position 'pos'.
  */
@@ -276,7 +304,7 @@ static void remove_pads(GapIO *io, MALIGN *malign, contig_t *c,
     cl_list *head = NULL, *c2, *last, *next;
     int npads, depth;
 
-    for (i = 0; i < malign->length; i++) {
+    for (i = start; i <= end; i++) {
 	/* Add new seqs to the depth array as we meet them */
 	while (cl && cl->mseg->offset == i) {
 	    c2 = (cl_list *)xmalloc(sizeof(cl_list));
@@ -320,7 +348,59 @@ static void remove_pads(GapIO *io, MALIGN *malign, contig_t *c,
 	}
     }
 
-    malign_recalc_scores(malign, 0, malign->length-1);
+    malign_recalc_scores(malign, start, end);
+}
+
+/*
+ * Seeds the malign structure with suitable regions to realign. This
+ * is a stab at speeding up the initial scan.
+ */
+void seed_malign_region(GapIO *io, MALIGN *malign, contig_list_t cl,
+			int indels_only) {
+    char *cons = malloc(cl.end - cl.start + 1);
+    int i;
+
+    if (!cons || 
+	calculate_consensus_simple_het(io,
+				       cl.contig,
+				       cl.start,
+				       cl.end,
+				       cons,
+				       NULL) != 0) {
+	malign_add_region(malign,
+			  cl.start,
+			  cl.end);
+	return;
+    }
+
+    for (i = cl.start; i <= cl.end; i++) {
+	int j;
+	if (islower(cons[i-cl.start])) {
+	    // het indel
+	    for (j = i+1; j <= cl.end && islower(cons[j-cl.start]); j++)
+		;
+	    malign_add_region(malign, i-100, j+100);
+	    i = j + 99;
+	} else if (!indels_only &&
+		   (cons[i-cl.start] != 'A' &&
+		    cons[i-cl.start] != 'C' &&
+		    cons[i-cl.start] != 'G' &&
+		    cons[i-cl.start] != 'T' &&
+		    cons[i-cl.start] != 'N' &&
+		    cons[i-cl.start] != '*')) {
+	    malign_add_region(malign, i-100, i+100);
+	    i += 99;
+	}
+    }
+
+//    for (i = 0; i < malign->nregion; i++) {
+//	printf("REGION %d/%d: \t%d\t%d\n",
+//	       i+1, malign->nregion,
+//	       malign->region[i].start,
+//	       malign->region[i].end);
+//    }
+
+    free(cons);
 }
 
 /*
@@ -332,7 +412,8 @@ static void remove_pads(GapIO *io, MALIGN *malign, contig_t *c,
  * To do this we may need to shuffle the start position of sequences
  * downstream, and hence also move consensus tags.
  */
-MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels) {
+MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels,
+		     int end) {
     CONTIGL *lastl = NULL, *contigl;
     int r;
     int old_start, old_end, new_start, new_end;
@@ -361,6 +442,9 @@ MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels) {
 	ALIGN_PARAMS *p;
 	int cons_pos;
 	int npads;
+
+	if (contigl->mseg->offset > end)
+	    break;
 #if 1
 	if (contigl->mseg->offset > rend) {
 	    if (++rnum >= malign->nregion) {
@@ -394,7 +478,7 @@ MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels) {
 			  8, /*gap_open*/
 			  8, /*gap_extend*/
 			  /* EDGE_GAPS_COUNT, */
-			  EDGE_GAPS_ZEROX | BEST_EDGE_TRACE,
+			  EDGE_GAPS_ZEROX | BEST_EDGE_TRACE | EDGE_GAPS_MAXY,
 			  RETURN_EDIT_BUFFERS | RETURN_SEQ |
 			  RETURN_NEW_PADS,
 			  0,  /*seq1_start*/
@@ -406,7 +490,7 @@ MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels) {
 	o = create_moverlap();
 	init_moverlap(o, malign, contigl->mseg->seq, malign->length, len);
 
-	cons_pos = contigl->mseg->offset;
+	cons_pos = contigl->mseg->offset - malign->start;
 	o->malign_len = malign->length - cons_pos;
 
 	/* 3 bases overhang to the right */
@@ -435,8 +519,10 @@ MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels) {
 
 	    /* fixed_malign(o, p); */
 	    r = realigner_malign(o, p); /* o->score = alignment score */
-	    
+
 	    /*
+	    printf("Score = %f\n", o->score);
+
 	    if (!r)
 		print_moverlap(malign, o, cons_pos);
 	    else
@@ -446,6 +532,7 @@ MALIGN *realign_seqs(int contig, MALIGN *malign, int band, Array indels) {
 	    malign->consensus = old_cons;
 	    malign->counts    = old_counts;
 	    malign->scores    = old_scores;
+	    cons_pos += malign->start;
 	}
 
 	/* Edit the sequence with the alignment */
@@ -648,6 +735,7 @@ MALIGN *build_malign(GapIO *io, tg_rec cnum, int start, int end) {
 		s->left = s->right = ABS(s->len);
 	}
 
+	/* Copy from s->left to s->right into mseg */
 	if ((s->len < 0) ^ r->comp) {
 	    s = dup_seq(s);
 	    complement_seq_t(s);
@@ -667,7 +755,7 @@ MALIGN *build_malign(GapIO *io, tg_rec cnum, int start, int end) {
 	seq[j] = 0;
 
 	init_mseg(contig->mseg, seq, len, r->start-1 + s->left-1);
-	contig->mseg->comp = (s != sorig);
+	contig->mseg->comp  = (s != sorig);
 
 	if (last_contig) {
 	    last_contig->next = contig;
@@ -681,7 +769,6 @@ MALIGN *build_malign(GapIO *io, tg_rec cnum, int start, int end) {
     }
     contig_iter_del(citer);
 
-    /* for 454 data -6 to -10 seem to work fine */
     return contigl_to_malign(first_contig, -7, -7);
 }
 
@@ -777,7 +864,7 @@ void print_moverlap(MALIGN *malign, MOVERLAP *o, int offset) {
 		continue;
 	    ndepth++;
 	    /* runaway loops completely kills deskpros */
-	    if (ndepth > 1000)
+	    if (ndepth > 5000)
 		abort();
 	    depth = (struct clist *)realloc(depth, ndepth * sizeof(*depth));
 	    depth[ndepth-1].seq = cl->mseg->seq + i-(cl->mseg->offset+cins);
@@ -835,6 +922,7 @@ void print_moverlap(MALIGN *malign, MOVERLAP *o, int offset) {
 int64_t malign_diffs(MALIGN *malign, int64_t *tot) {
     CONTIGL *cl;
     int64_t diff_count = 0, tot_count = 0;
+    int st;
 
     for (cl = malign->contigl; cl; cl = cl->next) {
 	int i;
@@ -882,11 +970,12 @@ int64_t malign_diffs(MALIGN *malign, int64_t *tot) {
 	    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
 	    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5  /* 255 */
 	};
+	st = malign->start;
 	for (i = 0; i < cl->mseg->length; i++) {
 	    unsigned char s = l[(uint8_t) cl->mseg->seq[i]];
 
 	    /*printf("%c", c==s ? '.' : s);*/
-	    diff_count += malign->scores[i+cl->mseg->offset][s];
+	    diff_count += malign->scores[i-st + cl->mseg->offset][s];
 	}
 	tot_count  += 128 * cl->mseg->length;
 #endif
@@ -1038,14 +1127,17 @@ static void tag_shift_for_delete(GapIO *io, tg_rec crec, tg_rec srec,
  * Takes a multiple alignment and updates the on-disk data structures to
  * match. This needs to correct confidence values, original positions and
  * tags too.
+ *
+ * Returns total number of bases added/removed to consensus
  */
-void update_io(GapIO *io, tg_rec cnum, MALIGN *malign, Array indels) {
+int update_io(GapIO *io, tg_rec cnum, MALIGN *malign, Array indels) {
     CONTIGL *cl;
     tg_rec rnum;
     range_t r, *r_out;
     bin_index_t *bin;
     contig_t *c = cache_search(io, GT_Contig, cnum);
     size_t i, nindel;
+    int npads = 0;
 
     cache_incr(io, c);
 
@@ -1069,6 +1161,8 @@ void update_io(GapIO *io, tg_rec cnum, MALIGN *malign, Array indels) {
 	con_indel_t *id = arrp(con_indel_t, indels, i);
 	int j;
 
+	npads += id->size;
+
 	if (id->size > 0) {
 	    contig_insert_bases(io, &c, id->pos+1, '*', -1, id->size);
 	} else {
@@ -1349,6 +1443,7 @@ void update_io(GapIO *io, tg_rec cnum, MALIGN *malign, Array indels) {
     /* Step 3 (remove pad columns) done in calling function. */
 
     cache_decr(io, c);
+    return npads;
 }
 
 #if 0
@@ -1434,135 +1529,580 @@ void reassign_confidence_values(GapIO *io, int cnum) {
 }
 #endif
 
+/*
+ * The start..end range constitutes a previous range of Ns in the
+ * consensus, probably due to artificially scaffolding contigs by
+ * butting them end to end with a few Ns inbetween.
+ *
+ * The realigner may correctly identify the overlap, or it may just
+ * give us garbage. We check here whether the new overlap (assuming
+ * there is one) is valid and if not we slip the reads relative to one
+ * another to reintroduce the gap.
+ *
+ * Returns 0 on success;
+ *        -1 on failure
+ */
+static int validate_N(GapIO *io, HashTable *h_clips, tg_rec trec,
+		      tg_rec crec, int start, int end) {
+    contig_iterator *citer;
+    rangec_t *r;
+    consensus_t *cons;
+    int failed_reads = 0, all_reads = 0;
+    int x_start = start - 50;
+    int x_end = end + 50;
+    int mid = (start+end)/2;
+    int left_most = start;
+    int right_most = end;
+    int i, snp, tot;
+
+    if (!(cons = calloc(x_end-x_start+1, sizeof(*cons))))
+	return -1;
+    calculate_consensus(io, crec, x_start, x_end, cons);
+
+    citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+    while ((r = contig_iter_next(io, citer))) {
+	int i, diff_l, diff_r, i_start;
+	seq_t *s, *sorig;
+	int ignore = 0;
+
+	// Limit this check to only reads that we have extended
+	if (!HashTableSearch(h_clips, (char *)&r->rec, sizeof(tg_rec)))
+	    continue;
+
+	s = sorig = cache_search(io, GT_Seq, r->rec);
+
+	if ((s->len < 0) ^ r->comp) {
+	    s = dup_seq(s);
+	    complement_seq_t(s);
+	}
+
+	//printf("#%"PRIrec"\n", r->rec);
+
+	// Left side
+	i_start = MAX(s->left-1, x_start - r->start);
+	for (diff_l = 0, i = i_start; i < s->right; i++) {
+	    if (r->start + i > mid)
+		break;
+
+	    //printf("  Chk %c %c\n", s->seq[i], cons[r->start+i - x_start]);
+	    if (s->seq[i] != "ACGT*N"[cons[r->start+i - x_start].call])
+		diff_l++;
+	}
+	diff_l = (diff_l > .3*(i-i_start)); // boolean, either good or bad
+	//printf("  L %d bases, %d diff\n", i-i_start, diff_l);
+	
+	if (r->start+s->right - mid > mid - (r->start+s->left-1))
+	    if (left_most > r->start + s->left-1)
+		left_most = r->start + s->left-1;
+
+	if (i-i_start <= 0)
+	    ignore = 1;
+
+	// Right side
+	for (diff_r = 0; i < s->right; i++) {
+	    if (r->start + i > x_end)
+		break;
+	    //printf("  Chk %c %c\n", s->seq[i], cons[r->start+i - x_start]);
+	    if (s->seq[i] != "ACGT*N"[cons[r->start+i - x_start].call])
+		diff_r++;
+	}
+	diff_r = (diff_r > .3*(r->start+i - mid));
+	//printf("  R %d bases, %d diff\n", r->start+i - mid, diff_r);
+
+	if (r->start+s->right - mid < mid - (r->start+s->left-1))
+	    if (right_most < r->start + s->right)
+		right_most = r->start + s->right;
+
+	if (r->start+i - mid <= 0)
+	    ignore = 1;
+
+	if (ignore)
+	    continue;
+
+	if (diff_l || diff_r)
+	    failed_reads++;
+	all_reads++;
+
+	if (s != sorig)
+	    free(s);
+    }
+    contig_iter_del(citer);
+
+    tot = snp = 0;
+    for (i = MAX(left_most,mid-20); i <= MIN(right_most,mid+20); i++) {
+	if (i < x_start)
+	    continue;
+	if (i > x_end)
+	    break;
+	if (cons[i-x_start].scores[6]>0)
+	    snp++;
+	tot++;
+    }
+
+
+    printf("For %d..%d => %d of %d poor, snp=%d of %d\n", left_most, right_most, failed_reads, all_reads, snp, tot);
+
+    /* If more than 1/4tr are poor then we shift, otherwise it's ok */
+    if (failed_reads*3 <= all_reads && snp*4 < tot) {
+	contig_t *c = cache_search(io, GT_Contig, crec);
+	bin_remove_item(io, &c, GT_AnnoEle, trec);
+	vmessage("Consensus N in =%"PRIrec" at %d..%d resolved/ignored\n",
+		 crec, start, end);
+    } else {
+	char *n_cons;
+
+	printf("Leftmost unclipped = %d, rightmost = %d\n",
+	       left_most, right_most);
+
+	// Unclip and see if it reintroduces the N
+	citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+	while ((r = contig_iter_next(io, citer))) {
+	    seq_t *s;
+	    HashItem *hi;
+	    soft_clips *sc;
+
+	    hi = HashTableSearch(h_clips, (char *)&r->rec, sizeof(tg_rec));
+	    if (!hi) continue;
+	    sc = (soft_clips *)hi->data.p;
+
+	    s = cache_search(io, GT_Seq, r->rec);
+	    s = cache_rw(io, s);
+	    s->left  = repad_clip(s, sc->left);
+	    s->right = repad_clip(s, sc->right);
+	}
+	contig_iter_del(citer);
+
+	n_cons = malloc(x_end - x_start + 1);
+	calculate_consensus_simple(io, crec, x_start, x_end, n_cons, NULL);
+	printf("%d..%d %.*s\n", x_start, x_end, x_end - x_start+1, n_cons);
+	for (i = 0; i <= x_end - x_start + 1; i++) {
+	    if (n_cons[i] == 'N')
+		break;
+	}
+	free(n_cons);
+
+	if (i <= x_end - x_start + 1) {
+	    // has N
+	    contig_t *c = cache_search(io, GT_Contig, crec);
+	    bin_remove_item(io, &c, GT_AnnoEle, trec);
+
+	    vmessage("Consensus N in =%"PRIrec" at %d..%d "
+		     "resolved by unclipping.\n",
+		     crec, start, end);
+	} else {
+	    vmessage("Consensus N in =%"PRIrec" at %d..%d retained\n",
+		     crec, start, end);
+	}
+    }
+
+
+    free(cons);
+
+    return 0;
+}
+
+/*
+ * Checks soft-clipping by counting SNPs over a region and comparing
+ * to the original unclipped version (TODO). If it is significantly
+ * more then we conclude the soft-clips are masking a misassembly so
+ * we keep the tag. Otherwise we remove the tag and consider the
+ * problem as resolved.
+ *
+ * Returns 0 on success;
+ *        -1 on failure
+ */
+static int validate_clip(GapIO *io, HashTable *h_clips, tg_rec trec,
+			 tg_rec crec, int start, int end) {
+    consensus_t *cons;
+    int i, snp = 0, expected_snp = 0;
+    anno_ele_t *e = cache_search(io, GT_AnnoEle, trec);
+    contig_iterator *citer;
+    rangec_t *r;
+    int mismatch = 0, tot = 0;
+
+    /* Compute pair-wise consensus and look for high SNP rates */
+    if (!(cons = calloc(end-start+1, sizeof(*cons))))
+	return -1;
+
+    if (e->comment)
+	sscanf(e->comment, "SNPs=%d\n", &expected_snp);
+
+    calculate_consensus(io, crec, start, end, cons);
+    for (i = start; i <= end; i++) {
+	if (cons[i-start].scores[6]>0)
+	    snp++;
+    }
+
+    if ((snp-expected_snp) >= 0.3 * (end - start + 1)) {
+	vmessage("Validation of concordant soft-clip =%"PRIrec
+		 " at %d..%d failed\n", crec, start, end);
+	free(cons);
+	return 0;
+    }
+
+    // Passed easy validation, now look harder incase it's deep
+    // and SNPs wouldn't be called.
+    citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+    while ((r = contig_iter_next(io, citer))) {
+	HashItem *hi;
+	soft_clips *c;
+	int left, right;
+	seq_t *s;
+
+	if (!(hi = HashTableSearch(h_clips, (char *)&r->rec, sizeof(r->rec))))
+	    continue;
+
+	c = (soft_clips *)hi->data.p;
+	s = cache_search(io, GT_Seq, r->rec);
+	    
+	left  = repad_clip(s, c->left);
+	right = repad_clip(s, c->right);
+
+	// Right end
+	if (right != s->right) {
+	    int p, b;
+	    if ((s->len<0) ^ r->comp) {
+		for (i = right; i < s->right; i++, tot++) {
+		    if (r->end -i -1 >= end)
+			continue;
+		    if (r->end -i -1 < start)
+			break;
+		    p = r->end - i - start;
+		    b = toupper(complement_base(s->seq[i]));
+		    if (p < 0 || p > end-start)
+			continue;
+		    if ((cons[p].phred &&
+			 b != "ACGT*"[cons[p].call]) ||
+			(cons[p].phred == 0 &&
+			 b != "ACGT*"[cons[p].het_call/5] &&
+			 b != "ACGT*"[cons[p].het_call%5]))
+			mismatch++;
+		}
+	    } else {
+		for (i = right; i < s->right; i++, tot++) {
+		    if (r->start + i < start)
+			continue;
+		    if (r->start + i >= end)
+			break;
+		    p = r->start + i - start;
+		    b = toupper(s->seq[i]);
+		    if (p < 0 || p > end-start)
+			continue;
+		    if ((cons[p].phred &&
+			 b != "ACGT*"[cons[p].call]) ||
+			(cons[p].phred == 0 &&
+			 b != "ACGT*"[cons[p].het_call/5] &&
+			 b != "ACGT*"[cons[p].het_call%5]))
+			mismatch++;
+		}
+	    }
+	}
+
+
+	// Left end
+	if (left != s->left) {
+	    int p, b;
+	    if ((s->len<0) ^ r->comp) {
+		for (i = s->left-1; i <= left; i++, tot++) {
+		    if (r->end -i -1 >= end)
+			continue;
+		    if (r->end -i -1 < start)
+			break;
+		    p = r->end - i - start;
+		    b = toupper(complement_base(s->seq[i]));
+		    if (p < 0 || p > end-start)
+			continue;
+		    if ((cons[p].phred &&
+			 b != "ACGT*"[cons[p].call]) ||
+			(cons[p].phred == 0 &&
+			 b != "ACGT*"[cons[p].het_call/5] &&
+			 b != "ACGT*"[cons[p].het_call%5]))
+			mismatch++;
+		}
+	    } else {
+		for (i = s->left-1; i <= left; i++, tot++) {
+		    if (r->start + i < start)
+			continue;
+		    if (r->start + i >= end)
+			break;
+		    p = r->start + i - start;
+		    b = toupper(s->seq[i]);
+		    if (p < 0 || p > end-start)
+			continue;
+		    if ((cons[p].phred &&
+			 b != "ACGT*"[cons[p].call]) ||
+			(cons[p].phred == 0 &&
+			 b != "ACGT*"[cons[p].het_call/5] &&
+			 b != "ACGT*"[cons[p].het_call%5]))
+			mismatch++;
+		}
+	    }
+	}
+    }
+
+    contig_iter_del(citer);
+    
+    if (3*mismatch < tot) {
+	contig_t *c = cache_search(io, GT_Contig, crec);
+	
+	bin_remove_item(io, &c, GT_AnnoEle, trec);
+	vmessage("Validation of concordant soft-clip =%"PRIrec
+		 " at %d..%d passed\n", crec, start, end);
+    } else {
+	vmessage("Validation of concordant soft-clip =%"PRIrec
+		 " at %d..%d failed\n", crec, start, end);
+    }
+
+    free(cons);
+    return 0;
+}
+
+/*
+ * Validates tagged soft-clip regions to verify that the extension looks
+ * valid. If it has a large degree of discrepancy and relatively few
+ * spanning reads, then we assume it was two contigs in a scaffold
+ * butted up end to end, so we slip one past the other to ensure we
+ * still have no overlap.
+ */
+static void validate_clip_regions(GapIO *io, HashTable *h_clips,
+				  Array tag_arr) {
+    int i;
+
+    for (i = 0; i < ArrayMax(tag_arr); i++) {
+	tg_rec trec = arr(tg_rec, tag_arr, i), crec;
+	int start, end;
+	anno_ele_t *e = cache_search(io, GT_AnnoEle, trec);
+	
+	if (!e)
+	    continue;
+
+	if (0 != anno_get_position(io, trec, &crec, &start, &end, NULL)) {
+	    verror(ERR_WARN, "validate_clip_regions",
+		   "Annotation %"PRIrec" has been removed.", trec);
+	    continue;
+	}
+	if (e->tag_type == str2type("NCLP"))
+	    validate_N(io, h_clips, trec, crec, start, end);
+	else
+	    validate_clip(io, h_clips, trec, crec, start, end);
+    }
+}
+
+
+#define CHUNK_SIZE 32768
+//#define CHUNK_SIZE 1000
 
 int shuffle_contigs_io(GapIO *io, int ncontigs, contig_list_t *contigs,
-		       int band, int flush) {
+		       int band, int soft_clips, int max_pass, int flush) {
     int i; //, start;
     Array indels;
-    
+    int *counts = NULL;
+
     set_malign_lookup(5);
     /* set_alignment_matrix("/tmp/nuc_matrix", "ACGTURYMWSKDHVB-*"); */
 
     indels = ArrayCreate(sizeof(con_indel_t), 0);
 
+    if (soft_clips)
+	counts = find_adapter(io, ncontigs, contigs);
+
     for (i = 0; i < ncontigs; i++) {
 	tg_rec cnum = contigs[i].contig;
 	int64_t old_score, new_score, tot_score, orig_score;
-	//for (start = 0; start < 1000000; start += 1000) {
-	//  MALIGN *malign = build_malign(io, cnum, start, start + 1000);
 	MALIGN *malign;
-	int c_start, c_shift;
+	contig_t *c;
+	HashTable *h_clips = NULL;
+	Array tag_arr;
+	int sub_start, sub_end;
 
-	vmessage("Shuffling pads for contig %s\n", get_contig_name(io, cnum));
+	if (DB_VERS(io) >= 5) {
+	    c = cache_search(io, GT_Contig, cnum);
+	    if (!c)
+		continue;
+	    if (c->nseqs / (c->end - c->start + 1) >= 100) {
+		verror(ERR_WARN, "shuffle_contigs_io",
+		       "Skipping contig %s due to excessive depth\n",
+		       get_contig_name(io, cnum));
+		continue;
+	    }
+	}
 
 	/*
-	 * The shuffle pads code (malign) comes from gap4 and has lots of
-	 * assumptions that the contig goes from base 1 to base N.
-	 * Fixing these assumptions is a lot of work, so for now we will take
-	 * the cheat route of moving the contig to ensure the assumption
-	 * is valid.
+	 * Iterate over 33k chunks from end going backwards. Decrement
+	 * our sub-range by 32k each time. This reduces the maximum
+	 * memory capacity and also prevents our multi-pass method
+	 * from purging the in-memory cache on long contigs.
 	 */
-	if (-1 == consensus_valid_range(io, cnum, &c_start, NULL)) {
-	    verror(ERR_WARN, "shuffle_contigs_io",
-		   "Failure in consensus_valid_range()");
-	    return -1;
-	}
-	//printf("Contig starts at base %d\n", c_start);
-	c_shift = 1-c_start;
-	if (c_shift != 0) {
-	    if (move_contig(io, cnum, c_shift) != 0)
-		return -1;
-	}
-
-	//printf("Shuffle #%"PRIrec" from %d..%d, shift %d\n",
-	//       contigs[i].contig, contigs[i].start, contigs[i].end, c_shift);
-
-	malign = build_malign(io, cnum,
-			      contigs[i].start + c_shift,
-			      contigs[i].end   + c_shift);
-	resort_contigl(malign);
+	sub_end = contigs[i].end;
+	sub_start = sub_end - (CHUNK_SIZE+200);
 
-	malign_add_region(malign,
-			  contigs[i].start + c_shift,
-			  contigs[i].end + c_shift);
-
-	ArrayMax(indels) = 0;
-	orig_score = new_score = malign_diffs(malign, &tot_score);
-	vmessage("Initial score %.2f%% mismatches (%"PRId64" mismatches)\n",
-		 (100.0 * orig_score)/tot_score, orig_score/128);
-	if (flush)
-	    UpdateTextOutput();
-	//print_malign(malign);
 	do {
-	    old_score = new_score;
-	    malign = realign_seqs(cnum, malign, band, indels);
-	    //print_malign(malign);
-	    new_score = malign_diffs(malign, &tot_score);
-	    vmessage("  Consensus difference score: %"PRId64"\n", new_score);
+	    contig_list_t cl;
+	    int pass;
+
+	    if (sub_start < contigs[i].start)
+		sub_start = contigs[i].start;
+
+	    cl.contig = contigs[i].contig;
+	    cl.start  = sub_start;
+	    cl.end    = sub_end;
+
+	    vmessage("Shuffling pads for contig %s %d..%d\n",
+		     get_contig_name(io, cnum),
+		     sub_start, sub_end);
+
+	    if (soft_clips)
+		h_clips = concordant_soft_clips(io,
+						cl.contig,
+						cl.start,
+						cl.end,
+						counts,
+						//0, 3, 5,
+						0, 2, 4,
+						&tag_arr);
+
+	    //cache_flush(io); break; // uncomment to unclip and do nothing else.
+
+	    //printf("Shuffle #%"PRIrec" from %d..%d\n",
+	    //       contigs[i].contig, contigs[i].start, contigs[i].end);
+
+	    malign = build_malign(io,
+				  cl.contig,
+				  cl.start,
+				  cl.end);
+	    resort_contigl(malign);
+
+	    // FIXME: Add an option to control whether we set the
+	    // indel_only parameter.
+	    seed_malign_region(io, malign, cl, 0);
+
+	    ArrayMax(indels) = 0;
+	    orig_score = new_score = malign_diffs(malign, &tot_score);
+	    vmessage("Initial score %"PRId64"\n", orig_score);
 	    if (flush)
 		UpdateTextOutput();
-	} while (new_score < old_score);
 
-	if (new_score < orig_score) {
+	    // HACK! Try with an alternative pad scoring algorithm.
+	    //
+	    // gap_extend is abused as a flag in scale_malign_scores to
+	    // switch between sinh and log based scoring transforms.
+	    //
+	    //FIXME: evaluate which order is best.
+	    malign->gap_extend = -7;
+	    scale_malign_scores(malign, malign->start, malign->end);
+
 	    //print_malign(malign);
-	    update_io(io, cnum, malign, indels);
+	    pass = 0;
+	    do {
+		old_score = new_score;
+		malign = realign_seqs(cnum, malign, band, indels, sub_end);
+		//print_malign(malign);
+		new_score = malign_diffs(malign, &tot_score);
+		vmessage("  Consensus difference score: %"PRId64"\n",
+			 new_score);
+		if (flush)
+		    UpdateTextOutput();
+	    } while (new_score < old_score && pass++ < max_pass);
+
+	    // Second try; this time with sinh table.
+	    malign->gap_extend = 0;
+	    scale_malign_scores(malign, malign->start, malign->end);
+
+	    pass = 0;
+	    do {
+		old_score = new_score;
+		malign = realign_seqs(cnum, malign, band, indels, sub_end);
+		//print_malign(malign);
+		new_score = malign_diffs(malign, &tot_score);
+		vmessage("  Consensus difference score: %"PRId64"\n",
+			 new_score);
+		if (flush)
+		    UpdateTextOutput();
+	    } while (new_score < old_score && pass++ < max_pass);
+
+	    if (new_score < orig_score) {
+		//print_malign(malign);
+		int npads = update_io(io, cnum, malign, indels);
+
+		/*
+		 * It's possible the contig ends could move if a sequence that
+		 * was previously the end of a contig has been moved such that
+		 * it's no longer the contig end. This can lead to tags off the
+		 * end of the contig, so trim them (reusing break_contig
+		 * code).
+		 *
+		 * FIXME: only needed for first/last block?
+		 */
+		contig_visible_start(io, cnum, CITER_CSTART);
+		contig_visible_end(io, cnum, CITER_CEND);
+
+		if (npads > 0)
+		    cl.end += npads;
+	    } else {
+		vmessage("Could not reduce number of consensus "
+			 "differences.\n");
+	    }
 
-	    /*
-	     * It's possible the contig ends could move if a sequence that
-	     * was previously the end of a contig has been moved such that
-	     * it's no longer the contig end. This can lead to tags off the
-	     * end of the contig, so trim them (reusing break_contig
-	     * code).
-	     */
-	     contig_visible_start(io, cnum, CITER_CSTART);
-	     contig_visible_end(io, cnum, CITER_CEND);
-	} else {
-	    vmessage("Could not reduce number of consensus differences.\n");
-	}
+	    destroy_malign(malign, 1);
 
-	/* Remove pad columns */
-	//printf("New score=%d, orig_score=%d\n", new_score, orig_score);
-	if (new_score < orig_score) {
-	    contigs[i].start += c_shift;
-	    contigs[i].end += c_shift;
-	    remove_pad_columns(io, 1, &contigs[i], 100, 1);
+	    vmessage("Final score %.2f%% mismatches\n",
+		     (100.0 * new_score)/tot_score);
 
-	    //contig_t *c;
-	    //c = cache_search(io, GT_Contig, cnum);
-	    //cache_incr(io, c);
-	    //remove_pads(io, malign, c, contigs[i].start, contigs[i].end);
-	    //cache_decr(io, c);
-	}
+	    /*
+	     * Sequences like
+	     *   AGCT**GATGC
+	     *             TGGATCGA
+	     * can end up causing holes. We break the contig in this case to
+	     * avoid minor database inconsistencies.
+	     */
+	    // remove_contig_holes(io, cnum);
 
-	destroy_malign(malign, 1);
+	    /* reassign_confidence_values(io, cnum); */
+	    //}
 
-	vmessage("Final score %.2f%% mismatches\n",
-		 (100.0 * new_score)/tot_score);
+	    if (h_clips) {
+		validate_clip_regions(io, h_clips, tag_arr);
+		ArrayDestroy(tag_arr);
+	    }
 
-	/*
-	 * Sequences like
-	 *   AGCT**GATGC
-	 *             TGGATCGA
-	 * can end up causing holes. We break the contig in this case to
-	 * avoid minor database inconsistencies.
-	 */
-	// remove_contig_holes(io, cnum);
+	    /* Remove pad columns. Both before and after soft-clipping */
+	    if (soft_clips || new_score < orig_score) {
+		remove_pad_columns(io, 1, &cl, 100, 1);
+	    }
 
-	/* reassign_confidence_values(io, cnum); */
-      //}
+	    if (h_clips) {
+		rewrite_soft_clips(io,
+				   cl.contig,
+				   cl.start,
+				   cl.end,
+				   h_clips,
+				   1);
+		rewrite_soft_clips(io,
+				   cl.contig,
+				   cl.start,
+				   cl.end,
+				   h_clips,
+				   0);
+		HashTableDestroy(h_clips, 1);
+	    }
 
-	/* Shift contig back */
-	if (c_shift != 0) {
-	    if (move_contig(io, cnum, -c_shift) != 0)
-		return -1;
-	}
+	    if (soft_clips || new_score < orig_score) {
+		remove_pad_columns(io, 1, &cl, 100, 1);
+	    }
 
-	if (flush)
-	    cache_flush(io);
+	    if (flush)
+		cache_flush(io);
+	    
+	    sub_start -= CHUNK_SIZE;
+	    sub_end   -= CHUNK_SIZE;
+	} while (sub_end > contigs[i].start);
     }
 
     ArrayDestroy(indels);
 
+    if (counts)
+	free(counts);
+
     return 0;
 }
 
@@ -1636,3 +2176,985 @@ int remove_pad_columns(GapIO *io, int ncontigs, contig_list_t *contigs,
 
     return 0;
 }
+
+
+/*
+ * ----------------------------------------------------------------------
+ * Unclip matching data.
+ *
+ * This algorithm hunts down the softclipped data and builds a
+ * histogram of values per consensus column. Any regions of high depth
+ * and high concordancy are deemed to be worthy of unclipping and
+ * realigning.
+ *
+ * Almost always this ambiguity comes from misassemblies or collapsed
+ * repeats, or at the very least it is valuable information we should
+ * know about and tag.
+ * ----------------------------------------------------------------------
+ */
+
+/*
+ * Tags a region of consensus. 
+ *
+ * Returns the tag record number on success;
+ *         -1 on failure
+ */
+tg_rec tag_softclip(GapIO *io, tg_rec crec, int start, int end,
+		    int snp, double avg_depth, int (*depth)[7], int dir) {
+    int j;
+    tg_rec r;
+    char *comment = malloc(end-start+1 + 100), *cp;
+    int type;
+
+    if (!comment)
+	return -1;
+
+    cp = comment;
+    if (depth) {
+	cp += sprintf(comment, "SNPs=%d\nAvg. depth=%5.1f\n"
+		      "Soft-clip consensus=", snp, avg_depth);
+	for (j = start; j <= end; j++) {
+	    *cp++ = (*depth++)[6];
+	}
+	*cp++ = 0;
+	type = str2type("CLIP");
+    } else {
+	sprintf(comment, "Consensus N");
+	type = str2type("NCLP");
+    }
+
+    r = anno_ele_add(io, GT_Contig, crec, 0, type, comment, start, end, dir);
+
+    free(comment);
+
+    return r;
+}
+
+/*
+ * Returns a hash table of soft_clips structures, indexed on read names. 
+ * To iterate use HashTableIterCreate.
+ *
+ * Also, if non-NULL, fills out clips array holding the tag recs.
+ * These can be used to identify regions of interest for further
+ * study.  Tags are added for both the concordant soft clips themselves
+ * and also any Ns in consensus caused by contig gaps.  These are
+ * important as we wish to preserve them unless the realignment is
+ * good.
+ *
+ * Returns NULL on failure.
+ *         Hash of soft_clips* on success; caller to free().
+ */
+HashTable *concordant_soft_clips(GapIO *io, tg_rec crec, int start, int end,
+				 int *counts, int tag_only,
+				 int min_depth, int min_tag_length,
+				 Array *tag_arr) {
+    contig_iterator *citer;
+    rangec_t *r;
+    int (*Ldepth)[7]; // ACGTN* total
+    int (*Rdepth)[7]; // ACGTN* total
+    int i, j, changed;
+    HashTable *h;
+    int pass = 0;
+    consensus_t *cons;
+
+    static int L[256] = {
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //00
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //10
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 5, 4, 4, 4, 4, 4, //20
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //30
+	4, 0, 4, 1, 4, 4, 4, 2,   4, 4, 4, 4, 4, 4, 4, 4, //40
+	4, 4, 4, 4, 3, 3, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //50
+	4, 0, 4, 1, 4, 4, 4, 2,   4, 4, 4, 4, 4, 4, 4, 4, //60
+	4, 4, 4, 4, 3, 3, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //70
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //80
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //90
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //a0
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //b0
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //c0
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //d0
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //e0
+	4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4};//f0
+    
+    if (!(Ldepth = malloc((end - start + 1) * 7*sizeof(int))))
+	return NULL;
+    if (!(Rdepth = malloc((end - start + 1) * 7*sizeof(int)))) {
+	free(Ldepth);
+	return NULL;
+    }
+
+    h = HashTableCreate(128, HASH_DYNAMIC_SIZE);
+    if (!h) {
+	free(Ldepth);
+	free(Rdepth);
+	return NULL;
+    }
+
+    if (tag_arr) {
+	if (!(*tag_arr = ArrayCreate(sizeof(tg_rec), 0)))
+	    return NULL;
+    }
+
+    // Add N tags, to validate later
+    if (!(cons = calloc(end-start+1, sizeof(*cons))))
+	return NULL;
+    calculate_consensus(io, crec, start, end, cons);
+    for (i=start; i<end; i++) {
+	if (cons[i-start].call == 5) {
+	    tg_rec rec;
+	    int j=i;
+	    while(i < end && cons[i-start].call == 5)
+		i++;
+	    rec = tag_softclip(io, crec, j, --i, 0, 0, 0, '+');
+	    if (tag_arr) ArrayPush(*tag_arr, tg_rec, rec);
+	}
+    }
+    
+ second_pass:
+    memset(Ldepth, 0, (end - start + 1) * 7*sizeof(int));
+    memset(Rdepth, 0, (end - start + 1) * 7*sizeof(int));
+    changed = 0;
+
+    /* Gather cutoff depth analysis */
+    citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+
+    while ((r = contig_iter_next(io, citer))) {
+	seq_t *s, *sorig;
+
+	s = sorig = cache_search(io, GT_Seq, r->rec);
+
+	if ((s->len < 0) ^ r->comp) {
+	    s = dup_seq(s);
+	    complement_seq_t(s);
+	}
+
+	if (!common_word_L(counts, &s->seq[MAX(s->left-13, 0)],
+			   MIN(12, s->left-1))) {
+	    for (i = 0; i < s->left-1; i++) {
+		if (r->start + i >= start &&
+		    r->start + i <= end) {
+		    if (s->conf[i] < 20)
+			continue;
+		    Ldepth[r->start+i - start][L[(unsigned char) s->seq[i]]]++;
+		    Ldepth[r->start+i - start][6]++;
+		}
+	    }
+	}
+
+	if (!common_word_R(counts, &s->seq[s->right], ABS(s->len)-s->right)) {
+	    for (i = s->right; i < ABS(s->len); i++) {
+		if (r->start + i >= start &&
+		    r->start + i <= end) {
+		    if (s->conf[i] < 20)
+			continue;
+		    Rdepth[r->start+i - start][L[(unsigned char) s->seq[i]]]++;
+		    Rdepth[r->start+i - start][6]++;
+		}
+	    }
+	}
+
+	if (s != sorig)
+	    free(s);
+    }
+
+    contig_iter_del(citer);
+
+
+    /* Compute cutoff consensus */
+    for (j = 0; j < 2; j++) {
+	int (*depth)[7] = j ? Rdepth : Ldepth;
+	int tag_start, tag_depth = 0;
+
+	for (i = start; i <= end; i++) {
+	    int b, c = 0, m = 0, M = 0;
+	    if (depth[i-start][6] < min_depth) {
+		if (tag_depth && i-1 - tag_start + 1 >= min_tag_length && 
+		    tag_depth/(i-1 - tag_start + 1.0) >= min_depth) {
+		    tg_rec rec;
+		    int snp = 0, x;
+		    vmessage("Concordant %s softclip, length %5d depth %5.1f, "
+			     "from %d to %d\n",
+			     j ? "right" : "left", i-1 - tag_start + 1,
+			     tag_depth/(i-1 - tag_start + 1.0),
+			     tag_start, i-1);
+		    for (x = start; x <= i-1; x++)
+			if (cons[x-start].scores[6]>0)
+			    snp++;
+		    rec = tag_softclip(io, crec, tag_start, i-1, snp,
+				       tag_depth/(i-1 - tag_start + 1.0),
+				       &depth[tag_start-start], "-+"[j]);
+		    if (tag_arr) ArrayPush(*tag_arr, tg_rec, rec);
+		}
+
+		depth[i-start][6] = 0;
+		tag_depth = 0;
+		continue;
+	    }
+
+	    if (m < depth[i-start][0]) M=m, m = depth[i-start][0],c=0; // A
+	    else if (M < depth[i-start][0]) M = depth[i-start][0];
+
+	    if (m < depth[i-start][1]) M=m, m = depth[i-start][1],c=1; // C
+	    else if (M < depth[i-start][1]) M = depth[i-start][1];
+
+	    if (m < depth[i-start][2]) M=m, m = depth[i-start][2],c=2; // G
+	    else if (M < depth[i-start][2]) M = depth[i-start][2];
+
+	    if (m < depth[i-start][3]) M=m, m = depth[i-start][3],c=3; // T
+	    else if (M < depth[i-start][3]) M = depth[i-start][3];
+
+	    if (m < depth[i-start][5]) M=m, m = depth[i-start][5],c=5; // *
+	    else if (M < depth[i-start][5]) M = depth[i-start][5];
+
+	    // At least 60% for 1 base
+	    b = m*100 >= depth[i-start][6]*60 ? "ACGTN*"[c] : 'N';
+
+	    // Or at least 90% for the top two base types.
+	    if (b == 'N')
+		b = (m+M)*100 >= depth[i-start][6]*90 ? "ACGTN*"[c] : 'N';
+
+	    //printf("%6d: %2d %2d %2d %2d %2d %2d / %2d => %c\n",
+	    //	   i,
+	    //	   depth[i-start][0], depth[i-start][1], depth[i-start][2],
+	    //	   depth[i-start][3], depth[i-start][4], depth[i-start][5],
+	    //	   depth[i-start][6], b);
+
+	    depth[i-start][6] = b;
+
+	    if (b == 'N') {
+		//printf("tag_depth %d,  start %d, len %d, avg_depth %f\n",
+		//       tag_depth, tag_start, i-1 - tag_start+1,
+		//       tag_depth/(i-1 - tag_start + 1.0));
+		if (tag_depth && i-1 - tag_start + 1 >= min_tag_length && 
+		    tag_depth/(i-1 - tag_start + 1.0) >= min_depth) {
+		    tg_rec rec;
+		    int snp = 0, x;
+		    vmessage("Concordant %s softclip, length %5d depth %5.1f, "
+			     "from %d to %d\n",
+			     j ? "right" : "left", i-1 - tag_start + 1,
+			     tag_depth/(i-1 - tag_start + 1.0),
+			     tag_start, i-1);
+		    for (x = start; x <= i-1; x++)
+			if (cons[x-start].scores[6]>0)
+			    snp++;
+		    rec = tag_softclip(io, crec, tag_start, i-1, snp,
+				       tag_depth/(i-1 - tag_start + 1.0),
+				       &depth[tag_start-start], "-+"[j]);
+		    if (tag_arr) ArrayPush(*tag_arr, tg_rec, rec);
+		    tag_depth = 0;
+		} else if (tag_depth) {
+		    tag_depth = 0;
+		}
+	    } else {
+		if (tag_depth == 0)
+		    tag_start = i;
+		tag_depth += depth[i-start][c];
+	    }
+	}
+
+	if (tag_depth && i-1 - tag_start + 1 >= min_tag_length &&
+	    tag_depth/(i-1 - tag_start + 1.0) >= min_depth) {
+	    tg_rec rec;
+	    int snp = 0, x;
+	    vmessage("Concordant %s softclip, length %5d depth %5.1f, "
+		     "from %d to %d\n",
+		     j ? "right" : "left", i-1 - tag_start + 1,
+		     tag_depth/(i-1 - tag_start + 1.0),
+		     tag_start, i-1);
+	    for (x = start; x <= i-1; x++)
+		if (cons[x-start].scores[6]>0)
+		    snp++;
+	    rec = tag_softclip(io, crec, tag_start, i-1, snp,
+			       tag_depth/(i-1 - tag_start + 1.0),
+			       &depth[tag_start-start], "-+"[j]);
+	    if (tag_arr) ArrayPush(*tag_arr, tg_rec, rec);
+	}
+    }
+
+
+    if (tag_only) {
+	free(Ldepth);
+	free(Rdepth);
+	return NULL;
+    }
+
+
+    /* Extend cutoffs where matching depth */
+    citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+
+    while ((r = contig_iter_next(io, citer))) {
+	seq_t *s, *sorig;
+	int new_l, new_r;
+	int i_max, score, score_max;
+
+	s = sorig = cache_search(io, GT_Seq, r->rec);
+	new_l = s->left;
+	new_r = s->right;
+
+	if ((s->len < 0) ^ r->comp) {
+	    s = dup_seq(s);
+	    complement_seq_t(s);
+	}
+
+#define MIS_SCORE -1
+//#define MIS_SCORE 0
+#define MAT_SCORE 2
+	    
+	// Left clip
+	if (!common_word_L(counts, &s->seq[MAX(s->left-13,0)],
+			   MIN(12, s->left-1))) {
+	    score = score_max = 0;
+	    for (i_max = i = s->left-2; i >= 0; i--) {
+		if (!(r->start + i >= start &&
+		      r->start + i <= end))
+		    break;
+
+		if (s->seq[i] != Ldepth[r->start+i - start][6]) {
+		    if ((score+=MIS_SCORE) < -6)
+			break;
+		} else {
+		    if (score_max < (score+=MAT_SCORE))
+			score_max = score, i_max = i;
+		}
+	    }
+	    //i_max = -1; // TEST: ALL
+	    i = i_max;
+	    if (i < s->left-2) {
+		if (s == sorig)
+		    new_l = i+1;
+		else
+		    new_r = ABS(s->len) - i + 1;
+	    
+		//printf("%"PRIrec"<%.*s\n", s->rec, s->left-2 -i, &s->seq[i+1]);
+	    }
+	}
+
+	// Right clip
+	if (!common_word_R(counts, &s->seq[s->right], ABS(s->len)-s->right)) {
+	    score = score_max = 0;
+	    for (i_max = i = s->right; i < ABS(s->len); i++) {
+		if (!(r->start + i >= start &&
+		      r->start + i <= end))
+		    break;
+
+		if (s->seq[i] != Rdepth[r->start+i - start][6]) {
+		    if ((score+=MIS_SCORE) < -6)
+			break;
+		} else {
+		    if (score_max < (score+=MAT_SCORE))
+			score_max = score, i_max = i+1;
+		}
+	    }
+	    //i_max = ABS(s->len); // TEST: ALL
+	    i = i_max;
+	    if (i > s->right) {
+		if (s == sorig)
+		    new_r = i;
+		else
+		    new_l = ABS(s->len) - i + 1;
+		//printf("%"PRIrec">%.*s\n", s->rec, i - s->right, &s->seq[s->right]);
+	    }
+	}
+
+	if (s != sorig)
+	    free(s);
+
+	/*
+	 * This will produce inconsistencies like:
+	 *   Seq 180892: left/right clips outside of sequence bounds.
+	 *
+	 * We will patch up the data later to fix these.
+	 */
+	if (new_r != sorig->right ||
+	    new_l != sorig->left) {
+	    HashData hd;
+	    int new_rec;
+	    soft_clips *c = malloc(sizeof(*c));
+
+	    c->rec   = sorig->rec;
+	    c->left  = depad_clip(sorig, sorig->left);
+	    c->right = depad_clip(sorig, sorig->right);
+
+	    hd.p = c;
+	    HashTableAdd(h, (char *)&c->rec, sizeof(c->rec), hd, &new_rec);
+	    if (!new_rec)
+		free(c);
+
+	    changed=1;
+
+	    s = cache_rw(io, sorig);
+	    s->right = new_r;
+	    s->left  = new_l;
+	}
+    }
+
+    contig_iter_del(citer);
+
+    /*
+     * We may have neighbouring blocks of concordant soft-clips due to SNPs.
+     * This is easiest resolved with multiple passes.
+     */
+    if (++pass < 3 && changed)
+	goto second_pass;
+
+    free(Ldepth);
+    free(Rdepth);
+    free(cons);
+
+    return h;
+}
+
+
+/*
+ * Scans through a contig paying particular attention to the known
+ * soft-clips.  We can ether extend a sequence if the soft clipped
+ * data matches the consensus, or if it was previously extended by
+ * concordant_soft_clip then we can increase soft-clipping back to the
+ * former value if it disagrees with the new consensus.
+ *
+ * Returns 0 on success
+ *        -1 on failure
+ */
+int rewrite_soft_clips(GapIO *io, tg_rec crec, int start, int end,
+		       HashTable *h_clips, int set_to_old) {
+    contig_iterator *citer;
+    rangec_t *r;
+    int i;
+    consensus_t *cons;
+    char *str = NULL, *cons_simple = NULL;
+
+    vmessage("Extend soft-clips for contig =%"PRIrec" at %d..%d\n",
+	     crec, start, end);
+
+    /* Compute consensus to align against */
+    if (!(cons = calloc(end - start + 1, sizeof(*cons)))) {
+	return -1;
+    }
+    if (!(cons_simple = malloc(end-start+1)))
+	return -1;
+
+    /*
+     * Firstly retrim reads back to their original clip positions so we
+     * can compute the newly aligned consensus based on the original bases,
+     * albeit in potentially different positions.
+     *
+     * This is so we can tell which bases were formerly heterozygous and
+     * not include places that have only become heterozygous due to adjusting
+     * the soft-clips.
+     */
+    if (!set_to_old)
+	goto skip_reset;
+
+    citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+    while ((r = contig_iter_next(io, citer))) {
+	HashItem *hi;
+	seq_t *s = cache_search(io, GT_Seq, r->rec);
+
+	/*
+	 * If this is a read we previously unclipped, then back up to
+	 * that point and verify it from there.
+	 */
+	if ((hi = HashTableSearch(h_clips, (char *)&r->rec, sizeof(r->rec)))) {
+	    soft_clips *c = (soft_clips *)hi->data.p;
+	    int p_l, p_r;
+	    s = cache_rw(io, s);
+	    
+	    if (s->left < (p_l = repad_clip(s, c->left)))
+		s->left = p_l;
+	    if (s->right > (p_r = repad_clip(s, c->right)))
+		s->right = p_r;
+	}
+    }
+    contig_iter_del(citer);
+
+    /* Now compute the consensus and rescan */
+ skip_reset:
+    calculate_consensus(io, crec, start, end, cons);
+
+    if (!set_to_old) {
+	// Generate consensus including [ACGT]/* hets.
+	//
+	// So A* het becomes A, allowing it to be hashed and included
+	// in the STR finder.
+	for (i = 0; i < end-start+1; i++) {
+	    if (cons[i].het_call % 5 == 4 && cons[i].scores[6] > 0)
+		cons_simple[i] = "acgt*"[cons[i].het_call / 5];
+	    else
+		cons_simple[i] = "ACGT*"[cons[i].call];
+	}
+
+	/* Array of STR regions to filter */
+	if (!(str = cons_mark_STR(cons_simple, end-start+1, 1))) {
+	    free(cons_simple);
+	    return -1;
+	}
+    }
+
+    citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+    while ((r = contig_iter_next(io, citer))) {
+	seq_t *s = cache_search(io, GT_Seq, r->rec);
+	int score = 0, best_score = 0, best_i = 0;
+	//int orig_right = s->right;
+	//int orig_left  = s->left;
+	int p, b;
+
+	// Right end
+	if ((s->len<0) ^ r->comp) {
+	    for (i = s->right; i < ABS(s->len); i++) {
+		if (r->end -i -1 < start)
+		    break;
+		p = r->end - i - start;
+		b = toupper(complement_base(s->seq[i]));
+		if (p < 0)
+		    break;
+		if (p > end-start) {
+		    score -= 5*(p - (end-start) -1);
+		    i += p - (end-start) -1;
+		    continue;
+		}
+
+		if ((cons[p].phred && b == "ACGT*"[cons[p].call]) ||
+		    (!cons[p].phred &&
+		     (b == "ACGT*"[cons[p].het_call/5] ||
+		      b == "ACGT*"[cons[p].het_call%5]))) {
+		    if (best_score < ++score) {
+			best_score = score;
+			best_i = i+1;
+		    }
+		} else {
+		    if ((score -= 5) <= -20)
+			break;
+		}
+		//printf("-%4d %7d: %c %c\n",
+		//       i, r->end - i,
+		//       complement_base(s->seq[i]),
+		//       cons[r->end - i - start]);
+	    }
+	} else {
+	    for (i = s->right; i < ABS(s->len); i++) {
+		if (r->start + i > end)
+		    break;
+		p = r->start + i - start;
+		b = toupper(s->seq[i]);
+		if (p < 0) {
+		    i += -p-1;
+		    score -= 5*(-p-1);
+		    continue;
+		}
+		if (p > end-start)
+		    break;
+		if ((cons[p].phred && b == "ACGT*"[cons[p].call]) ||
+		    (!cons[p].phred &&
+		     (b == "ACGT*"[cons[p].het_call/5] ||
+		      b == "ACGT*"[cons[p].het_call%5]))) {
+		    if (best_score < ++score) {
+			best_score = score;
+			best_i = i+1;
+		    }
+		} else {
+		    if ((score -= 5) <= -20)
+			break;
+		}
+		//printf("+%4d %7d: %c %c\n", i, r->start + i,
+		//       s->seq[i], cons[r->start + i - start]);
+	    }
+	}
+
+	if (best_score > 0) {
+	    //vmessage("#%"PRIrec": Extend 5' end by %d\n",
+	    //	     s->rec, best_i - s->right);
+	    s = cache_rw(io, s);
+	    while (best_i > 1 && s->seq[best_i-1] == '*')
+		best_i--;
+	    s->right = best_i;
+	}
+	//if (s->right < orig_right) {
+	//    printf("#%"PRIrec": Trim 5' end by %d\n",
+	//	   s->rec, orig_right - s->right);
+	//}
+
+
+	// Left end
+	best_i = best_score = score = 0;
+	if ((s->len<0) ^ r->comp) {
+	    for (i = s->left-2; i >= 0; i--) {
+		if (r->end -i -1 > end)
+		    break;
+		p = r->end - i - start;
+		b = toupper(complement_base(s->seq[i]));
+
+		if (p < 0) {
+		    i -= -p-1;
+		    score -= 5*(-p-1);
+		    continue;
+		}
+
+		if (p > end-start)
+		    break;
+
+		if ((cons[p].phred && b == "ACGT*"[cons[p].call]) ||
+		    (!cons[p].phred &&
+		     (b == "ACGT*"[cons[p].het_call/5] ||
+		      b == "ACGT*"[cons[p].het_call%5]))) {
+		    if (best_score < ++score) {
+			best_score = score;
+			best_i = i+1;
+		    }
+		} else {
+		    if ((score -= 5) <= -20)
+			break;
+		}
+		//printf("-%4d %7d: %c %c %d\n",
+		//       i, r->end - i,
+		//       complement_base(s->seq[i]),
+		//       cons[r->end - i - start], score);
+	    }
+	} else {
+	    for (i = s->left-2; i >= 0; i--) {
+		if (r->start + i < start)
+		    break;
+		p = r->start + i - start;
+		b = toupper(s->seq[i]);
+
+		if (p < 0)
+		    break;
+
+		if (p > end-start) {
+		    score -= 5*(p - (end-start) -1);
+		    i -= p - (end-start) -1;
+		    continue;
+		}
+		if ((cons[p].phred && b == "ACGT*"[cons[p].call]) ||
+		    (!cons[p].phred &&
+		     (b == "ACGT*"[cons[p].het_call/5] ||
+		      b == "ACGT*"[cons[p].het_call%5]))) {
+		    if (best_score < ++score) {
+			best_score = score;
+			best_i = i+1;
+		    }
+		} else {
+		    if ((score -= 5) <= -20)
+			break;
+		}
+		//printf("+%4d %7d: %c %c %d\n", i, r->start + i,
+		//       s->seq[i], cons[r->start + i - start], score);
+	    }
+	}
+
+	if (best_score > 0) {
+	    //vmessage("#%"PRIrec": Extend 3' end by %d\n",
+	    //	     s->rec, s->left - best_i);
+	    s = cache_rw(io, s);
+	    while (best_i < s->right && s->seq[best_i-1] == '*')
+		best_i++;
+	    s->left = best_i;
+	}
+	//if (s->left > orig_left) {
+	//    printf("#%"PRIrec": Trim 3' end by %d\n",
+	//	   s->rec, s->left - orig_left);
+	//}
+
+	// Update the range? Not needed as start/end haven't changed.
+	// However the consensus valid range flag may be incorrect.
+
+	if (set_to_old)
+	    // Skip the STR finding step as we'll do another loop yet
+	    continue;
+
+	// We've extended as far as we can, but was it justified? We now
+	// check against previously detected short tandem repeats and trim
+	// back (if possible) any sequences that end mid-repeat without
+	// correctly observing the correct repeat size.
+	//
+	// Note: only do this for heterozygous indel regions.
+
+	//if (don't trim STRs)
+	//    continue;
+
+	//continue;
+
+	if ((s->len<0) ^ r->comp) {
+	    // Right end (left of comp. seq)
+	    p = r->end - s->right + 1 - start;
+	    if (p >= 0 && p <= end-start && str[p]) {
+		int p2, v, bit;
+		for (v = str[p], bit = 1; bit < 256; bit <<= 1) {
+		    if (!(v & bit))
+			continue;
+		
+		    for (p2 = p; p2 < end-start+1 && (str[p2] & bit); p2++)
+			;
+
+		    if (p2-1 > p) {
+			s = cache_rw(io, s);
+			s->right = MIN(s->right,
+				       MAX(r->end - p2 + 1 - start,
+					   s->left+1));
+		    }
+		}
+	    }
+
+	    // Left end
+	    p = r->end - s->left + 1 - start + 1;
+	    if (p >= 0 && p <= end-start && str[p]) {
+		int p2, v, bit;
+		for (v = str[p], bit = 1; bit < 256; bit <<= 1) {
+		    if (!(v & bit))
+			continue;
+		
+		    for (p2 = p; p2 > 0 && (str[p2] & bit); p2--)
+			;
+
+		    if (p2+1 < p) {
+			s = cache_rw(io, s);
+			s->left = MAX(s->left,
+				      MIN(r->end - p2 + 1 - start,
+					  s->right-1));
+		    }
+		}
+	    }
+	} else {
+	    // Right end
+	    p = r->start + s->right-1 - start;
+	    if (p >= 0 && p <= end-start && str[p]) {
+		int p2, v, bit;
+		for (v = str[p], bit = 1; bit < 256; bit <<= 1) {
+		    if (!(v & bit))
+			continue;
+		
+		    for (p2 = p; p2 > 0 && (str[p2] & bit); p2--)
+			;
+
+		    if (p2+1 < p) {
+			s = cache_rw(io, s);
+			s->right = MIN(s->right,
+				       MAX(p2 - (r->start - start) + 1,
+					   s->left+1));
+		    }
+		}
+	    }
+
+	    // Left end
+	    p = r->start + s->left-1 - start;
+	    if (p >= 0 && p <= end-start && str[p]) {
+		int p2, v, bit;
+		for (v = str[p], bit = 1; bit < 256; bit <<= 1) {
+		    if (!(v & bit))
+			continue;
+		
+		    for (p2 = p; p2 < end-start+1 && (str[p2] & bit); p2++)
+			;
+
+		    if (p2-1 > p) {
+			s = cache_rw(io, s);
+			s->left = MAX(s->left,
+				      MIN(p2 - (r->start - start - 1),
+					  s->right-1));
+		    }
+		}
+	    }
+	}
+    }
+    contig_iter_del(citer);
+
+    free(cons);
+    if (str) free(str);
+    if (cons_simple) free(cons_simple);
+
+    return 0;
+}
+
+/*
+ * Does a word usage scan on soft-clips to try and identify likely
+ * adapter sequences.
+ *
+ * We compare common words in cutoffs vs common words in used portions
+ * and identify the discrepancies.
+ */
+#define ADAPTER_WORD 12
+#define ADAPTER_SIZE (1<<(2*ADAPTER_WORD))
+#define ADAPTER_MASK (ADAPTER_SIZE-1)
+static int L[256] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*   0-15 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  16 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  32 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  48 */
+    0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, /*  64 */
+    0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  80 */
+    0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, /*  96 */
+    0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 112-127 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  /* 255 */
+};
+
+static unsigned int hash_word(char *seq) {
+    unsigned int w = 0, i;
+    for (i = 0; i < ADAPTER_WORD; i++) {
+	w <<= 2;
+	w |= L[(unsigned char)seq[i]];
+    }
+    return w;
+}
+
+static char *W(unsigned int w) {
+    static char buf[ADAPTER_WORD+1];
+    int i;
+    for (i = 0; i < ADAPTER_WORD; i++)
+	buf[i] = "ACGT"[(w>>(2*(ADAPTER_WORD-i-1)))&3];
+    buf[ADAPTER_WORD]=0;
+    return buf;
+}
+
+static int common_word_L(int *counts, char *seq, int len) {
+    unsigned int w = 0, i;
+    if (len < 4 || !counts)
+	return 0;
+
+    for (i = 0; i < ADAPTER_WORD && i < len; i++) {
+	w <<= 2;
+	w |= L[(unsigned char)seq[i]];
+    }
+    return counts[w];
+}
+
+static int common_word_R(int *counts, char *seq, int len) {
+    unsigned int w = 0, i;
+    if (len < 4 || !counts)
+	return 0;
+
+    for (i = 0; i < ADAPTER_WORD && i < len; i++) {
+	w <<= 2;
+	w |= L[(unsigned char)seq[i]];
+    }
+    return counts[w << (2*(ADAPTER_WORD - MIN(ADAPTER_WORD,len)))];
+}
+
+/*
+ * Returns a malloced array of ADAPTER_WORD bases long holding 1 for an
+ * unusually common word and 0 for a normal/expected word usage.
+ *
+ * Returns NULL on failure.
+ */
+int *find_adapter(GapIO *io, int ncontigs, contig_list_t *contigs) {
+    int i;
+    //int j;
+    int *counts_clip, *counts_used;
+    uint64_t clip_tot = 0;
+    uint64_t used_tot = 0;
+    uint64_t t1, t2;
+
+    counts_clip = calloc(ADAPTER_SIZE, sizeof(int));
+    counts_used = calloc(ADAPTER_SIZE, sizeof(int));
+
+    for (i = 0; i < ncontigs; i++) {
+	tg_rec crec = contigs[i].contig;
+	int start = contigs[i].start;
+	int end = contigs[i].end;
+	contig_iterator *citer;
+	rangec_t *r;
+	unsigned int w;
+
+	citer = contig_iter_new(io, crec, 0, CITER_FIRST, start, end);
+	while ((r = contig_iter_next(io, citer))) {
+	    seq_t *s, *sorig;
+
+	    sorig = s = cache_search(io, GT_Seq, r->rec);
+
+	    if (s->left < ADAPTER_WORD+1 &&
+		ABS(s->len) - s->right < ADAPTER_WORD)
+		continue;
+
+	    if ((s->len < 0) ^ r->comp) {
+		s = dup_seq(s);
+		complement_seq_t(s);
+	    }
+
+	    // FIXME: needs to work on depadded sequence.
+	    if (s->left > ADAPTER_WORD) {
+		//printf("#%"PRIrec" L %.*s\n",
+		//       s->rec, ADAPTER_WORD, &s->seq[s->left-1-ADAPTER_WORD]);
+		counts_clip[hash_word(&s->seq[s->left-1-ADAPTER_WORD])]++;
+		clip_tot++;
+	    }
+
+	    if (ABS(s->len) - s->right >= ADAPTER_WORD) {
+		//printf("#%"PRIrec" R %.*s\n",
+		//       s->rec, ADAPTER_WORD, &s->seq[s->right]);
+		counts_clip[hash_word(&s->seq[s->right])]++;
+		clip_tot++;
+	    }
+
+	    // First and last word of used portion.
+	    if (s->right - s->left > ADAPTER_WORD) {
+		w = hash_word(&s->seq[s->left-1]);
+		//printf("#%"PRIrec" M %s\n", s->rec, W(w));
+		counts_used[w]++;
+		w = hash_word(&s->seq[s->right-ADAPTER_WORD]);
+		//printf("#%"PRIrec" M %s\n", s->rec, W(w));
+		counts_used[w]++;
+		used_tot+=2;
+	    }
+
+//	    w = hash_word(&s->seq[s->left-1]);
+//	    j = s->left-1 + ADAPTER_WORD;
+//	    do {
+//		counts_used[w]++;
+//		//printf("#%"PRIrec" M %s\n", s->rec, W(w));
+//		w <<= 2;
+//		w |= L[s->seq[j]];
+//		w &= (1<<(2*ADAPTER_WORD))-1;
+//		used_tot++;
+//	    } while (++j <= s->right);
+
+	    if (s != sorig)
+		free(s);
+	}
+	contig_iter_del(citer);
+    }
+
+    // Filter to common words in clips only
+    t1 = clip_tot * 0.01;  // 1%
+    t2 = used_tot * 0.005; // 0.5%
+    if (clip_tot > 1000 && used_tot > 1000) {
+	for (i = 0; i < ADAPTER_SIZE; i++) {
+	    //if (counts_clip[i] > t1)
+	    //	printf("Clip: %s %5.1f\n",
+	    //	       W(i), 100.0 * counts_clip[i]/clip_tot);
+	    //if (counts_used[i] > t2)
+	    //	printf("Used: %s %5.1f\n",
+	    //	       W(i), 100.0 * counts_used[i]/used_tot);
+
+	    if (counts_clip[i]>t1 && counts_used[i]<t2) {
+		counts_clip[i] = 1;
+		vmessage("Discarding word %s as likely adpater (%5.1f%%)\n",
+			 W(i), 100.0 * counts_clip[i]/clip_tot);
+	    } else {
+		counts_clip[i] = 0;
+	    }
+	}
+    } else {
+	memset(counts_clip, 0, ADAPTER_SIZE * sizeof(int));
+    }
+
+    // Expand clipped words to partial matches, down to 4 bp.
+    for (i = 0; i < ADAPTER_SIZE; i++) {
+	int j;
+	if (!counts_used[i])
+	    continue;
+	
+	for (j = 4; j < ADAPTER_WORD; j++) {
+	    counts_used[i & ((1<<(2*j))-1)] = 1;
+	    counts_used[(i << (2*(ADAPTER_WORD-j))) & ADAPTER_MASK] = 1;
+	}
+    }
+
+    free(counts_used);
+
+    return counts_clip;
+}
+
diff --git a/gap5/shuffle_pads.h b/gap5/shuffle_pads.h
index 6142d76..39a9c3a 100644
--- a/gap5/shuffle_pads.h
+++ b/gap5/shuffle_pads.h
@@ -3,11 +3,23 @@
 
 #include <tg_gio.h>
 #include "io_utils.h"
+#include "io_lib/hash_table.h"
 
 int shuffle_contigs_io(GapIO *io, int ncontigs, contig_list_t *contigs,
-		       int band, int flush);
+		       int band, int soft_clips, int max_pass, int flush);
 
 int remove_pad_columns(GapIO *io, int rargc, contig_list_t *rargv,
 		       int percent_pad, int quiet);
 
+/* Original left/right soft-clips */
+typedef struct {
+    tg_rec rec;
+    int left;
+    int right;
+} soft_clips;
+
+HashTable *concordant_soft_clips(GapIO *io, tg_rec crec, int start, int end,
+				 int *counts, int tag_only, int min_depth,
+				 int min_tag_length, Array *tag_arr);
+
 #endif /* _SHUFFLE_PADS_H */
diff --git a/gap5/shuffle_pads.tcl b/gap5/shuffle_pads.tcl
index c8077a9..d71b9c9 100644
--- a/gap5/shuffle_pads.tcl
+++ b/gap5/shuffle_pads.tcl
@@ -19,16 +19,27 @@ proc ShufflePads {io} {
 	-label "Band size" \
 	-default [keylget gap5_defs SHUFFLE_PADS.BAND_SIZE]
 
+    xyn $t.soft_clips \
+	-label "Use cutoff data" \
+	-orient horizontal \
+	-default [keylget gap5_defs SHUFFLE_PADS.SOFT_CLIPS]
+
+    xentry $t.max_pass \
+	-label "Maximum number of passes" \
+	-default [keylget gap5_defs SHUFFLE_PADS.MAX_PASS]
+
     okcancelhelp $t.ok \
-	-ok_command "ShufflePads2 $io $t $t.infile $t.id $t.band_size" \
+	-ok_command "ShufflePads2 $io $t $t.infile $t.id $t.band_size \
+                     $t.soft_clips $t.max_pass" \
 	-cancel_command "destroy $t" \
 	-help_command "show_help gap5 {Tidying up alignments}" \
 	-bd 2 -relief groove
 
-    pack $t.infile $t.id $t.band_size $t.ok -side top -fill x
+    pack $t.infile $t.id $t.band_size $t.max_pass $t.soft_clips $t.ok \
+	-side top -fill x
 }
 
-;proc ShufflePads2 {io t infile id band_size} {
+;proc ShufflePads2 {io t infile id band_size soft_clips max_pass} {
     if {[lorf_in_get $infile] == 4} {
 	set list [list [contig_id_gel $id]]
 	set lreg [contig_id_lreg $id]
@@ -44,15 +55,27 @@ proc ShufflePads {io} {
 	return
     }
 
+    if {[set max_pass [$max_pass get]] < 1} {
+	bell
+	return
+    }
+
     if {![quit_displays -io $io -msg "shuffle_pads"]} {
 	# Someone's too busy to shutdown?
 	return
     }
 
+    set clips [$soft_clips get]
+
     destroy $t
 
     SetBusy
-    log_call shuffle_pads -io $io -contigs $list -band $band_size
+    log_call shuffle_pads \
+	-io $io \
+	-contigs $list \
+	-band $band_size \
+	-soft_clips $clips \
+	-max_pass $max_pass
     ClearBusy
 
     ContigInitReg $io
diff --git a/gap5/str_finder.c b/gap5/str_finder.c
new file mode 100644
index 0000000..b5ebe31
--- /dev/null
+++ b/gap5/str_finder.c
@@ -0,0 +1,341 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <ctype.h>
+
+#include "str_finder.h"
+#include "utlist.h"
+
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#define MIN(a,b) ((a)<(b)?(a):(b))
+
+static int L[256] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*   0-15 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  16 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  32 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  48 */
+    0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, /*  64 */
+    0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*  80 */
+    0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, /*  96 */
+    0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 112-127 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128 */
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  /* 255 */
+};
+
+static void add_rep(rep_ele **list, char *cons, int clen, int pos, int rlen,
+		    int lower_only, int w) {
+    rep_ele *el, *tmp, *prev;
+    char *cp1, *cp2, *cp_end;
+    int i;
+
+    // Already handled this in previous overlap?
+    if (*list) {
+	tmp = DL_TAIL(*list);
+	if (tmp->start <= pos-rlen*2+1 && tmp->end >= pos)
+	    return;
+    }
+
+    // Find current and last occurence of repeated word.
+
+    cp2 = &cons[pos+1];
+    // If unpadded, this is quicker: cp1 = &cons[pos+1-rlen];
+
+    for (cp1 = &cons[pos], i = 1; i < rlen; cp1--) // compensate for pads
+	if (*cp1 == '*')
+	    continue;
+	else
+	    i++;
+    while (*cp1 == '*')
+	cp1--;
+
+
+    // Scan ahead to see how much further it goes.
+    cp_end = &cons[clen];
+    while (cp2 < cp_end) {
+	while (*cp1 == '*') cp1++;
+	while (*cp2 == '*') cp2++;
+
+	if (L[(unsigned char) *cp1] != L[(unsigned char) *cp2])
+	    break;
+
+	w<<=2;
+	w|=L[(unsigned char) *cp2];
+	cp1++;
+	cp2++;
+    }
+
+    if (!(el = malloc(sizeof(*el))))
+	return;
+
+    el->end   = pos + cp2-&cons[pos+1];
+    pos++;
+    while (rlen--) {
+	while (cons[--pos] == '*');
+	while (cons[--pos] == '*');
+    }
+    //pos++;
+    while (pos > 1 && cons[pos-1] == '*') pos--;
+    el->start = pos;
+
+    // Check it meets the lower-case only criteria
+    if (lower_only) {
+	int lc = 0;
+	for (i = el->start; i <= el->end; i++) {
+	    if (islower(cons[i])) {
+		lc = 1;
+		break;
+	    }
+	}
+
+	if (!lc)
+	    return;
+    }
+
+    // Remove any older items on the list that are entirely contained within el
+    if (*list) {
+	tmp = DL_TAIL(*list);
+	do {
+	    prev = tmp->prev;
+	    if (tmp->end < el->start)
+		break;
+
+	    if (tmp->start >= el->start) {
+		DL_DELETE(*list, tmp);
+		free(tmp);
+	    }
+
+	    if (tmp == DL_HEAD(*list))
+		break;
+	    tmp = prev;
+	} while (*list);
+    }
+
+    DL_APPEND(*list, el);
+
+    return;
+}
+
+/*
+ * Finds repeated homopolymers up to 8-mers.
+ *
+ * Returns a list of rep_ele structs holding the start,end tuples of repeats;
+ *         NULL on failure.
+ */
+rep_ele *find_STR(char *cons, int len, int lower_only) {
+    int i, j;
+    uint32_t w = 0;
+    rep_ele *reps = NULL;
+
+    for (i = j = 0; i < len && j < 15; i++) {
+	if (cons[i] == '*') continue;
+
+	w <<= 2;
+	w |= L[(unsigned char) cons[i]];;
+	//printf("%3d %c w=%08x\n", i, cons[i], w);
+	if (j>= 1 && (w&0x0003) == ((w>> 2)&0x0003))
+	    add_rep(&reps, cons, len, i, 1, lower_only, w);
+	if (j>= 3 && (w&0x000f) == ((w>> 4)&0x000f))
+	    add_rep(&reps, cons, len, i, 2, lower_only, w);
+	if (j>= 5 && (w&0x003f) == ((w>> 6)&0x003f))
+	    add_rep(&reps, cons, len, i, 3, lower_only, w);
+	if (j>= 7 && (w&0x00ff) == ((w>> 8)&0x00ff))
+	    add_rep(&reps, cons, len, i, 4, lower_only, w);
+	if (j>= 9 && (w&0x03ff) == ((w>>10)&0x03ff))
+	    add_rep(&reps, cons, len, i, 5, lower_only, w);
+	if (j>=11 && (w&0x0fff) == ((w>>12)&0x0fff))
+	    add_rep(&reps, cons, len, i, 6, lower_only, w);
+	if (j>=13 && (w&0x3fff) == ((w>>14)&0x3fff))
+	    add_rep(&reps, cons, len, i, 7, lower_only, w);
+
+	j++;
+    }
+
+    for (; i < len; i++) {	
+	if (cons[i] == '*') continue;
+
+	w <<= 2;
+	w |= L[(unsigned char) cons[i]];
+	//printf("%3d %c w=%08x\n", i, cons[i], w);
+	if ((w&0xffff) == ((w>>16)&0xffff)) 
+	    add_rep(&reps, cons, len, i, 8, lower_only, w);
+	else if ((w&0x3fff) == ((w>>14)&0x3fff)) 
+	    add_rep(&reps, cons, len, i, 7, lower_only, w);
+	else if ((w&0x0fff) == ((w>>12)&0x0fff)) 
+	    add_rep(&reps, cons, len, i, 6, lower_only, w);
+	else if ((w&0x03ff) == ((w>>10)&0x03ff)) 
+	    add_rep(&reps, cons, len, i, 5, lower_only, w);
+	else if ((w&0x00ff) == ((w>> 8)&0x00ff)) 
+	    add_rep(&reps, cons, len, i, 4, lower_only, w);
+	else if ((w&0x003f) == ((w>> 6)&0x003f)) 
+	    add_rep(&reps, cons, len, i, 3, lower_only, w);
+	else if ((w&0x000f) == ((w>> 4)&0x000f)) 
+	    add_rep(&reps, cons, len, i, 2, lower_only, w);
+	else if ((w&0x0003) == ((w>> 2)&0x0003)) 
+	    add_rep(&reps, cons, len, i, 1, lower_only, w);
+    }
+
+    return reps;
+}
+
+/* -----------------------------------------------------------------------------
+ * Computes repeat regions in the consensus and then provides a bit mask
+ * indicating the extend of the STRs.
+ *
+ * The purpose of this is to identify where a read needs to span the entire
+ * region in order to validate how many copies of a repeat word are present.
+ * This only really has a major impact when indels are involved.
+ *
+ * For example, given this multiple alignment:
+ *
+ * S1 GATCGGACGAGAG
+ * S2 GATCGGACGAGAGAGAGAGAGT
+ * S3 GATCGGACGAGAGAGAGAG**TCGGAC
+ * S4     GGACGAGAGAGAGAGAGTCGGAC
+ * S5        CGAGAGAGAGAG**TCGGAC
+ * S6              AGAGAGAGTCGGAC
+ *
+ * We have subseq of GAGAGAGAGAG** vs GAGAGAGAGAGAG. The first and last
+ * (S1 and S6) sequences do not span and so we do not know which allele they
+ * match. Specifically as the pad is at the right hand end, the alignment of
+ * S6 gives incorrect weight to the consensus as it is stating AG when it
+ * may actually be ** at that point.
+ *
+ * By identifying the repeats we can soft clip as follows:
+ *
+ * S1 GATCGGACgagag
+ * S2 GATCGGACGAGAGAGAGAGAGT
+ * S3 GATCGGACGAGAGAGAGAG**TCGGAC
+ * S4     GGACGAGAGAGAGAGAGTCGGAC
+ * S5        CGAGAGAGAGAG**TCGGAC
+ * S6              agagagagTCGGAC
+ *
+ * Returns an array of STR vs no-STR values.
+ *         0  => non repetitive.
+ *         1+ => repeat with consecutive bit-number for repeat size.
+ *
+ * Eg:  AGGGGAGGAGAAGAC
+ *       1111  1111
+ *         2222222
+ *              444444
+ * =>   011331137754440
+ */
+char *cons_mark_STR(char *cons, int len, int lower_only) {
+    rep_ele *reps, *elt, *tmp;
+    char *str;
+
+    str = calloc(1, len);
+    reps = find_STR(cons, len, lower_only);
+
+    DL_FOREACH_SAFE(reps, elt, tmp) {
+	int i, v = 0;
+	
+	//printf("%2d .. %2d %.*s\n", elt->start, elt->end,
+	//       elt->end - elt->start+1, &cons[elt->start]);
+
+	// What is there?
+	for (i = MAX(elt->start-1,0); i <= MIN(elt->end+1,len-1); i++)
+	    v |= str[i];
+
+	for (i = 0; i < 8; i++) {
+	    if (!(v&(1<<i)))
+		break;
+	}
+	v = (i == 8) ? 1 : (1<<i);
+
+	// Add new if available, or just overload 1 if not
+	for (i = elt->start; i <= elt->end; i++)
+	    str[i] |= v;
+
+	DL_DELETE(reps, elt);
+	free(elt);
+    }
+
+    return str;
+}
+
+#ifdef TEST_MAIN
+int main(int argc, char **argv) {
+    rep_ele *reps, *elt, *tmp;
+    char *str;
+    int i, len = strlen(argv[1]);
+
+    reps = find_STR(argv[1], len, 0);
+
+    DL_FOREACH_SAFE(reps, elt, tmp) {
+	printf("%2d .. %2d %.*s\n", elt->start, elt->end,
+	       elt->end - elt->start+1, &argv[1][elt->start]);
+	DL_DELETE(reps, elt);
+	free(elt);
+    }
+
+    //str = cons_mark_STR(argv[1], len, 1);
+    //for (i = 0; i < len; i++) {
+    //	printf("%3d %c %d\n", i, argv[1][i], str[i]);
+    //}
+
+    return 0;
+}
+#endif
+
+#ifdef TEST_MAIN2
+#define BS 1024*1024
+static unsigned char *load(uint64_t *lenp) {
+    unsigned char *data = NULL;
+    uint64_t dsize = 0;
+    uint64_t dcurr = 0;
+    signed int len;
+
+    do {
+	if (dsize - dcurr < BS) {
+	    dsize = dsize ? dsize * 2 : BS;
+	    data = realloc(data, dsize);
+	}
+
+	len = read(0, data + dcurr, BS);
+	if (len > 0)
+	    dcurr += len;
+    } while (len > 0);
+
+    if (len == -1) {
+	perror("read");
+    }
+
+    *lenp = dcurr;
+    return data;
+}
+
+int main(int argc, char **argv) {
+    rep_ele *reps, *elt, *tmp;
+    char *str;
+    uint64_t i, in_len;
+    int count = 0;
+
+    str = load(&in_len);
+
+    reps = find_STR(str, in_len, 0);
+
+    DL_FOREACH_SAFE(reps, elt, tmp) {
+	printf("%2d .. %2d %.*s\n", elt->start, elt->end,
+	       elt->end - elt->start+1, &str[elt->start]);
+	count++;
+	DL_DELETE(reps, elt);
+	free(elt);
+    }
+
+    printf("Found %d reps\n", count);
+
+    //str = cons_mark_STR(argv[1], len, 1);
+    //for (i = 0; i < len; i++) {
+    //	printf("%3d %c %d\n", i, argv[1][i], str[i]);
+    //}
+
+    return 0;
+}
+#endif
diff --git a/gap5/str_finder.h b/gap5/str_finder.h
new file mode 100644
index 0000000..c16cd6e
--- /dev/null
+++ b/gap5/str_finder.h
@@ -0,0 +1,37 @@
+#ifndef _STR_FINDER_H_
+#define _STR_FINDER_H_
+
+typedef struct rep_ele {
+    int start, end;
+    struct rep_ele *prev;
+    struct rep_ele *next;
+} rep_ele;
+
+/*
+ * Finds repeated homopolymers up to 8-mers.
+ *
+ * If lower_only is true then it only adds STRs for regions that
+ * contain at least one lower-case base. This can be used as a marker
+ * for looking for specific types of repeats.
+ * (One use for this is to only mark STRs that overlap a heterozygous
+ * indel region.)
+ *
+ * Returns a list of rep_ele structs holding the start,end tuples of repeats;
+ *         NULL on failure.
+ */
+rep_ele *find_STR(char *cons, int len, int lower_only);
+
+/*
+ * Returns an array of STR vs no-STR values.
+ *         0  => non repetitive.
+ *         1+ => repeat with consecutive bit-number for repeat size.
+ *
+ * Eg:  AGGGGAGGAGAAGAC
+ *       1111  1111
+ *         2222222
+ *              444444
+ * =>   011331137754440
+ */
+char *cons_mark_STR(char *cons, int len, int lower_only);
+
+#endif /* _STR_FINDER_H_ */
diff --git a/gap5/tag_plot.c b/gap5/tag_plot.c
index c44bbcd..58bb101 100644
--- a/gap5/tag_plot.c
+++ b/gap5/tag_plot.c
@@ -367,8 +367,6 @@ static int compute_ypos(TagPlot  *tp, int xgap, tline *tl, int ntl) {
 	    nleft--;
 
 	    if ((node = SPLAY_MIN(xtag_TREE, &xtree)) != NULL && tl[i].x[0] >= node->x) {
-		int try_cull = 0;
-
 		/* We found a node, is it the smallest in y? */
 		curr = SPLAY_NEXT(xtag_TREE, &xtree, node);
 		while (curr && tl[i].x[0] >= curr->x) {
@@ -384,7 +382,6 @@ static int compute_ypos(TagPlot  *tp, int xgap, tline *tl, int ntl) {
 		    if (curr != node) {
 			SPLAY_REMOVE(xtag_TREE, &xtree, curr);
 			SPLAY_INSERT(ytag_TREE, &ytree, curr);
-			try_cull = 1;
 		    }
 		    curr = next;
 		}
diff --git a/gap5/tclIndex b/gap5/tclIndex
index c94a7bf..b1f447b 100644
--- a/gap5/tclIndex
+++ b/gap5/tclIndex
@@ -11,6 +11,7 @@ set auto_index(AlterRelationships) [list source [file join $dir alter_rel.tcl]]
 set auto_index(DirectAssembly) [list source [file join $dir assemble_direct.tcl]]
 
 set auto_index(AssemblySingle) [list source [file join $dir assemble_single.tcl]]
+set auto_index(AssemblySinglePostLoad) [list source [file join $dir assemble_single.tcl]]
 
 set auto_index(NormalShotgun) [list source [file join $dir auto_assemble.tcl]]
 set auto_index(Screen) [list source [file join $dir auto_assemble.tcl]]
@@ -121,6 +122,8 @@ set auto_index(InitListContigs) [list source [file join $dir list_contigs.tcl]]
 set auto_index(ListContigsScaffoldSort) [list source [file join $dir list_contigs.tcl]]
 set auto_index(ListContigsScaffoldFormat) [list source [file join $dir list_contigs.tcl]]
 
+set auto_index(ListGet) [list source [file join $dir list_proc.tcl]]
+set auto_index(ListType) [list source [file join $dir list_proc.tcl]]
 set auto_index(ListLoad) [list source [file join $dir list_proc.tcl]]
 set auto_index(ListSave) [list source [file join $dir list_proc.tcl]]
 set auto_index(ListCreate) [list source [file join $dir list_proc.tcl]]
@@ -306,3 +309,6 @@ set auto_index(CheckDatabase) [list source [file join $dir check_database.tcl]]
 set auto_index(CheckAssembly) [list source [file join $dir check_assembly.tcl]]
 
 set auto_index(ContigExtend) [list source [file join $dir contig_extend.tcl]]
+
+set auto_index(set_global_defaults) [list source [file join $dir gap_globals.tcl]]
+set auto_index(set_database_defaults) [list source [file join $dir gap_globals.tcl]]
diff --git a/gap5/template_display.c b/gap5/template_display.c
index 56557d2..e8ce576 100644
--- a/gap5/template_display.c
+++ b/gap5/template_display.c
@@ -9,6 +9,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include <ctype.h>
 #include <tcl.h>
 #include <X11/Xlib.h>
 
@@ -776,8 +777,6 @@ static int compute_ypos(TemplateDisplayItem  *tdi, int xgap, tline *tl, int ntl)
 	    nleft--;
 
 	    if ((node = SPLAY_MIN(XTREE, &xtree)) != NULL && tl[i].x[0] >= node->x) {
-		int try_cull = 0;
-
 		/* We found a node, is it the smallest in y? */
 		curr = SPLAY_NEXT(XTREE, &xtree, node);
 		while (curr && tl[i].x[0] >= curr->x) {
@@ -793,7 +792,6 @@ static int compute_ypos(TemplateDisplayItem  *tdi, int xgap, tline *tl, int ntl)
 		    if (curr != node) {
 			SPLAY_REMOVE(XTREE, &xtree, curr);
 			SPLAY_INSERT(YTREE, &ytree, curr);
-			try_cull = 1;
 		    }
 		    curr = next;
 		}
diff --git a/gap5/template_draw.c b/gap5/template_draw.c
index 99687ea..9d98e19 100644
--- a/gap5/template_draw.c
+++ b/gap5/template_draw.c
@@ -19,7 +19,13 @@
  * them here so we can choose which functions to call.
  */
 #ifndef _WIN32
+#    ifdef ckfree
+#        undef ckfree
+#    endif
 #    define ckfree(x) free((x))
+#    ifdef ckalloc
+#        undef ckalloc
+#    endif
 #    define ckalloc(x) malloc((x))
 #endif
 
diff --git a/gap5/tg_anno.c b/gap5/tg_anno.c
index f9d5c33..15526ca 100644
--- a/gap5/tg_anno.c
+++ b/gap5/tg_anno.c
@@ -47,7 +47,10 @@ tg_rec anno_ele_add(GapIO *io, int obj_type, tg_rec obj_rec, tg_rec anno_rec,
     tg_rec seq_bin = 0;
 
     /* Find contig for obj_rec/obj_type */
-    if (obj_type == GT_Contig) {
+    if (obj_type == GT_Database) {
+	// fake bin 1 in order to make sure it is written (bin 0 => unused)
+	return anno_ele_new(io, 1, obj_type, obj_rec, 0, type, dir, comment);
+    } else if (obj_type == GT_Contig) {
 	crec = obj_rec;
     } else {
 	int st, en;
@@ -207,7 +210,7 @@ int anno_ele_set_type(GapIO *io, anno_ele_t **e, char *str) {
     ae->tag_type = type;
 
     /* Also update range_t cached copy of type */
-    if (ae->bin) {
+    if (ae->bin && ae->obj_type != GT_Database) {
 	bin_index_t *bin = (bin_index_t *)cache_search(io, GT_Bin, ae->bin);
 	range_t *r = NULL;
 	int i, nranges;
diff --git a/gap5/tg_bin.c b/gap5/tg_bin.c
index f3e6010..6df023c 100644
--- a/gap5/tg_bin.c
+++ b/gap5/tg_bin.c
@@ -664,6 +664,13 @@ bin_index_t *bin_add_to_range(GapIO *io, contig_t **c, tg_rec brec, range_t *r,
 	    contig_set_end(io, c, r->end);
 	    (*c)->clipped_timestamp = 0;
 	}
+	
+	/* Check if the sequence may have changed visible start/end even if
+	   it was within the boundaries of used start/end */
+	if ((*c)->clipped_timestamp == (*c)->timestamp
+	    && (r->start < (*c)->clipped_start || r->end > (*c)->clipped_end)) {
+	    (*c)->clipped_timestamp = 0;
+	}
     }
 
     if (brec) {
@@ -813,8 +820,10 @@ int bin_get_item_position(GapIO *io, int type, tg_rec rec,
     int i, offset1 = 0, offset2 = 0, found = 0;
     int comp = 0;
     int idx = -1;
+#if 0
     int orig_start, orig_end;
     tg_rec orig_bin;
+#endif
 
     if (type == GT_AnnoEle) {
 	anno_ele_t *a = cache_search(io, GT_AnnoEle, rec);
@@ -885,16 +894,16 @@ int bin_get_item_position(GapIO *io, int type, tg_rec rec,
 
     if (!found) goto fail;
 
+#if 0
     orig_start = offset1;
     orig_end   = offset2;
     orig_bin   = bin->rec;
 
-#if 0
     {
 	bin_check_cache(io, bin);
 	if (contig) *contig = bin->cached_contig;
 	if (start)  *start  = bin->cached_abspos + offset1;
-	if (end)    *start  = bin->cached_abspos + offset2;
+	if (end)    *end    = bin->cached_abspos + offset2;
 	if (orient) *orient = bin->cached_orient;
 	/*
 	printf("Orig range=%d..%d final=%d..%d in =%"PRIrec"\n",
@@ -1079,21 +1088,6 @@ int bin_remove_item_from_bin(GapIO *io, contig_t **c, bin_index_t **binp,
 	    *c = cache_rw(io, *c);
 	    bin_incr_nseq(io, bin, -1);
 
-	    /* Also fix pair's timestamp for where we are */
-	    if (r->pair_rec) {
-		seq_t *s;
-		bin_index_t *b;
-		range_t *r2;
-		
-		s = cache_search(io, GT_Seq, r->pair_rec);
-		b = cache_search(io, GT_Bin, s->bin);
-		b = cache_rw(io, b);
-		r2 = arrp(range_t, b->rng, s->bin_index);
-		assert(r2->rec == s->rec);
-			 
-		r2->pair_timestamp = 0;
-	    }
-
 	    /* 
 	     * Invalidate clipped start/end - FIXME: should check if this is
 	     * really necessary.
@@ -1122,14 +1116,17 @@ int bin_remove_item_from_bin(GapIO *io, contig_t **c, bin_index_t **binp,
 	tg_rec bnum;
 
 	for (;;) {
+	    int tmp;
 	    if (bin->flags & BIN_COMPLEMENTED) {
 		if (seq_start != INT_MAX) {
-		    seq_start = bin->size-1 - seq_start;
-		    seq_end   = bin->size-1 - seq_end;
+		    tmp = bin->size-1 - seq_start;
+		    seq_start   = bin->size-1 - seq_end;
+		    seq_end = tmp;
 		}
 
-		item_start = bin->size-1 - item_start;
-		item_end   = bin->size-1 - item_end;
+		tmp = bin->size-1 - item_start;
+		item_start   = bin->size-1 - item_end;
+		item_end = tmp;
 		comp ^= 1;
 	    }
 	    if (seq_start != INT_MAX) {
diff --git a/gap5/tg_cache.c b/gap5/tg_cache.c
index 521d6d2..4cacab2 100644
--- a/gap5/tg_cache.c
+++ b/gap5/tg_cache.c
@@ -53,7 +53,7 @@
  *
  *    As before, the parent has the ref count boosted by 1.
  *    The child I/O obj has ref count of 2. (Why 2?)
-
+ *
  *    eg:
  *    b=cache_search(io_child, GT_Bin, 30); // base rc 0
  *    cache_rw(io_child, b);                // base rc 1, child rc 2.
@@ -412,6 +412,9 @@ static void contig_unload(GapIO *io, cached_item *ci, int unlock) {
     if (c->link)
 	ArrayDestroy(c->link);
 
+    if (c->haplo_hash)
+	HashTableDestroy(c->haplo_hash, 0);
+
     if (unlock)
 	io->iface->contig.unlock(io->dbh, ci->view);
     cache_free(ci);
@@ -431,6 +434,10 @@ static void contig_block_unload(GapIO *io, cached_item *ci, int unlock) {
 
 	    if (c->link)
 		ArrayDestroy(c->link);
+
+	    if (c->haplo_hash)
+		HashTableDestroy(c->haplo_hash, 0);
+
 	    if (si)
 		free(si);
 	}
@@ -1045,6 +1052,168 @@ int qsort_ci_rec(const void *p1, const void *p2) {
     return (*c1)->rec - (*c2)->rec;
 }
 
+/*
+ * Update a pair_rec entry.
+ */
+
+static int update_pair_rec(GapIO *io, tg_rec seq_to_update, tg_rec val_to_set,
+			   int *orig_ref_count_out) {
+    seq_t *sp;
+    bin_index_t *bp;
+    range_t *rp;
+
+    /* Get sequence */
+    sp = cache_search(io, GT_Seq, seq_to_update);
+    if (NULL == sp) {
+	verror(ERR_WARN, "update_pair_rec",
+	       "Couldn't load sequence #%"PRIrec, seq_to_update);
+	return -1;
+    }
+
+    if (sp->bin < 0) {
+	/* Pair sequence is unmapped.  Is this possible? Not sure, but
+	   assume it's OK. */
+	return 0;
+    }
+
+    cache_incr(io, sp);
+
+    /* Get bin */
+    bp = cache_search(io, GT_Bin, sp->bin);
+    if (NULL == bp) {
+	verror(ERR_WARN, "update_pair_rec",
+	       "Couldn't load bin %"PRIrec, sp->bin);
+	goto fail;
+    }
+
+    if (NULL != orig_ref_count_out) {
+	cached_item *ci = cache_master(ci_ptr(bp));
+
+	*orig_ref_count_out = ci->hi->ref_count;
+    }
+
+    /* Get range */
+    rp = arrp(range_t, bp->rng, sp->bin_index);
+    assert(rp->rec == sp->rec);
+
+    if (rp->pair_rec != val_to_set) {
+	/* Do update */
+	bp = cache_rw(io, bp);
+	if (NULL == bp) {
+	    verror(ERR_WARN, "update_pair_rec",
+		   "Couldn't get write on bin %"PRIrec, sp->bin);
+	    goto fail;
+	}
+	
+	rp->pair_rec = val_to_set;
+	rp->pair_timestamp = 0;
+	bp->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
+    }
+
+    cache_decr(io, sp);
+    return 0;
+
+ fail:
+    cache_decr(io, sp);
+    return -1;
+}
+
+/*
+ * Apply any deferred updates to range pair_rec.  These updates will be
+ * to the pairs of sequences that have been deleted or resurrected in a
+ * contig.  As some of the updates may be to sequences in other contigs, the
+ * updates have to wait until cache_flush time to avoid problems caused by
+ * data from more than one contig getting into a single child IO.  If that
+ * were to happen, it would be possible to have the same data in two
+ * child IOs which could lead to inconsistencies when saving.
+ *
+ * Note that this implementation does pull the paired read's bin into
+ * the child IO to update it.  This shouldn't matter as it is immediately
+ * flushed out again.  It also takes care to update any other copies
+ * of the pair_rec in other child IOs so that it will still be right after
+ * they are saved.
+ */
+
+static int apply_pair_rec_updates(GapIO *io) {
+    HacheIter *iter = NULL;
+    HacheItem *item;
+
+    if (NULL == io->pair_rec_updates)
+	return 0;
+
+    assert(io->base != NULL); /* Updates should only be in a child IO */
+    
+    /* Iterate through the set of updates */
+    iter = HacheTableIterCreate();
+    if (NULL == iter) {
+	verror(ERR_WARN, "apply_pair_rec_updates", "Out of memory");
+	return -1;
+    }
+    
+    for (item = HacheTableIterNext(io->pair_rec_updates, iter);
+	 NULL != item;
+	 item = HacheTableIterNext(io->pair_rec_updates, iter)) {
+	tg_rec seq_to_update;
+	tg_rec val_to_set;
+	int    orig_ref_count = 0;
+	
+	assert(item->key_len == sizeof(tg_rec));
+	seq_to_update = *((tg_rec *) item->key);
+	val_to_set    = (tg_rec) item->data.i;
+
+	if (0 != update_pair_rec(io, seq_to_update, val_to_set,
+				 &orig_ref_count)) {
+	    goto fail;
+	}
+
+	if (orig_ref_count > 0) {
+	    /* Looks like pair has been locked, so need to check if it's in
+	       any other child IOs and fix the copy there if it is */
+	    GapIO *i;
+
+	    for (i = gio_base(io)->next; NULL != i; i = i->next) {
+		seq_t *sp;
+		cache_key_t k;
+		HacheItem *hi;
+
+		if (i == io) continue; /* Ignore the one we just did */
+		
+		/* Fetch the sequence in this IO in case it has moved
+		   to a different bin. */
+		sp = cache_search(i, GT_Seq, seq_to_update);
+		if (NULL == sp) {
+		    verror(ERR_WARN, "apply_pair_rec_updates",
+			   "Couldn't load sequence #%"PRIrec, seq_to_update);
+		    goto fail;
+		}
+
+		if (sp->bin < 0) continue;  /* Unmapped itself? */
+
+		/* Check if the bin is in this child IO. If it is, it
+		   must have had cache_rw run on it.  Fix it up so it
+		   that the pair_rec doesn't revert when it gets saved. */
+		construct_key(sp->bin, GT_Bin, &k);
+		hi = HacheTableQuery(i->cache, (char *)&k, sizeof(k));
+
+		if (!hi) continue; /* Not there, no need to fix */
+
+		/* Do the update in this child IO */
+		if (0 != update_pair_rec(i, seq_to_update, val_to_set, NULL)) {
+		    goto fail;
+		}
+	    }
+	}
+    }
+
+    HacheTableIterDestroy(iter);
+    HacheTableDestroy(io->pair_rec_updates, 0); /* No longer needed */
+    io->pair_rec_updates = NULL;
+    return 0;
+
+ fail:
+    HacheTableIterDestroy(iter);
+    return -1;
+}
 
 /*
  * Flushes changes in the cache back to disk.
@@ -1064,6 +1233,11 @@ int cache_flush(GapIO *io) {
 	bin_add_range(io, NULL, NULL, NULL, NULL, -1);
     }
 
+    if (0 != apply_pair_rec_updates(io)) {
+	verror(ERR_WARN, "cache_flush", "Failed to update pair records");
+	return -1;
+    }
+
     //printf("\n>>> cache flush <<<\n");
     //HacheTableRefInfo(io->cache, stdout);
 
@@ -1144,6 +1318,8 @@ int cache_flush(GapIO *io) {
 			} else if (bo->contig[j]) {
 			    if (bo->contig[j]->link)
 				ArrayDestroy(bo->contig[j]->link);
+			    if (bo->contig[j]->haplo_hash)
+				HashTableDestroy(bo->contig[j]->haplo_hash, 0);
 			    if (strcmp(bo->contig[j]->name,
 				       bn->contig[j]->name) &&
 				!io->base->base) {
@@ -2752,6 +2928,11 @@ cached_item *cache_dup(GapIO *io, cached_item *sub_ci) {
 	    } else {
 		c->link = NULL; /* Just incase! */
 	    }
+
+	    /* Force creation of a new haplo_hash, if needed */
+	    c->haplo_hash = NULL;
+	    c->haplo_timestamp = 0;
+
 	    break;
 	}
 
@@ -2948,6 +3129,11 @@ cached_item *cache_dup(GapIO *io, cached_item *sub_ci) {
 		       ArrayMax(oc->link) * sizeof(contig_link_t));
 	    }
 
+	    /* Force creation of a new haplo_hash, if needed */
+	    c->haplo_hash = NULL;
+	    c->haplo_timestamp = 0;
+
+
 	    c->block = b;
 	    b->contig[c->idx] = c;
 
@@ -3011,6 +3197,18 @@ cached_item *cache_dup(GapIO *io, cached_item *sub_ci) {
 }
 
 /*
+ * Returns the current cache lock mode for an item.
+ */
+int cache_lock_mode(GapIO *io, void *data) {
+    cached_item *ci = ci_ptr(data);
+    cached_item *mi = cache_master(ci);
+
+    /* Ignore io->base for now */
+
+    return mi->lock_mode;
+}
+
+/*
  * Locks a cached item for read-write access, returning a new pointer.
  * For 'derived' GapIOs this locks the original but returns the duplicated
  * (copy on write) version. Otherwise it locks in situ and returns the
diff --git a/gap5/tg_check.c b/gap5/tg_check.c
index 30106ef..25449f3 100644
--- a/gap5/tg_check.c
+++ b/gap5/tg_check.c
@@ -261,6 +261,10 @@ static int check_anno(GapIO *io, int fix, bin_index_t *bin, range_t *r,
     int err = 0;
     anno_ele_t *a = cache_search(io, GT_AnnoEle, r->rec);
 
+    if (!a) {
+	vmessage("Anno %"PRIrec": failed to read.\n", r->rec);
+	return 1;
+    }
     cache_incr(io, a);
 
     /* Bin records match */
@@ -286,7 +290,15 @@ static int check_anno(GapIO *io, int fix, bin_index_t *bin, range_t *r,
 					    sizeof(a->obj_rec));
 	    if (!hi || hi->data.i != a->bin) {
 		vmessage("Anno %"PRIrec": attached to seq %"PRIrec" held "
-			 "within a different bin.\n", a->rec, a->obj_rec);
+			 "within a different bin.\n"
+			 "  Anno %"PRIrec" is in bin %"PRIrec"\n",
+			 a->rec, a->obj_rec, a->rec, a->bin);
+		if (hi) {
+		    vmessage("  Seq  %"PRIrec" is in bin %"PRIrec"\n",
+			     a->obj_rec, (tg_rec) hi->data.i);
+		} else {
+		    vmessage("  Seq  %"PRIrec" not seen yet\n", a->obj_rec);
+		}
 		err++;
 	    }
 	}
@@ -373,6 +385,12 @@ static int check_anno(GapIO *io, int fix, bin_index_t *bin, range_t *r,
 	    
 	    err++;
 
+#if 0
+	    /* Disable this for now.  Moving an annotation to a different
+	     * bin causes other checks (e.g. for the nanno count) to fail
+	     * even though nothing is really wrong.  Worse, the resulting
+	     * attempted fixes leave the database in much worse shape than
+	     * it was originally */
 	    if (fix && !io->base) {
 		bin_index_t *abin;
 		contig_t *ca, *co;
@@ -398,6 +416,7 @@ static int check_anno(GapIO *io, int fix, bin_index_t *bin, range_t *r,
 		if (ca)   cache_decr(io, ca);
 		if (co)   cache_decr(io, co);
 	    }
+#endif
 	}
     }
 
@@ -902,8 +921,10 @@ static int bin_walk(GapIO *io, int fix, tg_rec rec, int offset, int complement,
 
     /* Check count validity to ensure this + children are correct */
     if (bin->nseqs != bs->nseq) {
-	vmessage("bin %"PRIrec": nseqs does not match observed counts\n",
-		 bin->rec);
+	vmessage("bin %"PRIrec": nseqs does not match observed counts:\n"
+		 "  bin     : %d\n"
+		 "  observed: %d\n",
+		 bin->rec, bin->nseqs, bs->nseq);
 	if (fix) {
 	    bin = cache_rw(io, bin);
 	    bin->flags |= BIN_BIN_UPDATED;
@@ -913,8 +934,10 @@ static int bin_walk(GapIO *io, int fix, tg_rec rec, int offset, int complement,
 	err++;
     }
     if (db_vers > 1 && bin->nanno != bs->nanno) {
-	vmessage("bin %"PRIrec": nanno does not match observed counts\n",
-		 bin->rec);
+	vmessage("bin %"PRIrec": nanno does not match observed counts\n"
+		 "  bin     : %d\n"
+		 "  observed: %d\n",
+		 bin->rec, bin->nanno, bs->nanno);
 	if (fix) {
 	    bin = cache_rw(io, bin);
 	    bin->flags |= BIN_BIN_UPDATED;
@@ -930,8 +953,10 @@ static int bin_walk(GapIO *io, int fix, tg_rec rec, int offset, int complement,
 	if (fixed) (*fixed)++;
     }
     if (db_vers > 1 && bin->nrefpos != bs->nref) {
-	vmessage("bin %"PRIrec": nrefpos does not match observed counts\n",
-		 bin->rec);
+	vmessage("bin %"PRIrec": nrefpos does not match observed counts\n"
+		 "  bin     : %d\n"
+		 "  observed: %d\n",
+		 bin->rec, bin->nrefpos, bs->nref);
 	if (fix) {
 	    bin = cache_rw(io, bin);
 	    bin->flags |= BIN_BIN_UPDATED;
@@ -1178,8 +1203,9 @@ int check_contig(GapIO *io, tg_rec crec, int fix, int level,
 
     if (bs.cstart != c->start ||
 	bs.cend   != c->end) {
-	vmessage("Contig %"PRIrec": used start/end range are incorrect\n",
-		 crec);
+	vmessage("Contig %"PRIrec": used start/end range are incorrect\n"
+		 "  Contig:   %d .. %d\n  Bin walk: %d .. %d\n",
+		 crec, c->start, c->end, bs.cstart, bs.cend);
 	err++;
 	if (fix) {
 	    c = cache_rw(io, c);
diff --git a/gap5/tg_contig.c b/gap5/tg_contig.c
index 5ece1a0..333df44 100644
--- a/gap5/tg_contig.c
+++ b/gap5/tg_contig.c
@@ -13,6 +13,11 @@
 #include "break_contig.h"
 #include "tg_check.h"
 #include "list_proc.h"
+#include "find_haplotypes.h"
+#include "io_lib/hash_table.h"
+
+/* Uncomment to turn on debugging output for the insertion / deletion code */
+//#define DEBUG_INDEL
 
 #define NORM(x) (f_a * (x) + f_b)
 #define NMIN(x,y) (MIN(NORM((x)),NORM((y))))
@@ -28,6 +33,21 @@ typedef struct bin_list {
   struct bin_list *next;
 } bin_list;
 
+#ifdef DEBUG_INDEL
+#include <stdarg.h>
+static inline void debug(char *fmt, ...) {
+    va_list args;
+    va_start(args, fmt);
+    vfprintf(stderr, fmt, args);
+    va_end(args);
+}
+#else
+static inline void debug(char *fmt, ...) {}
+#endif
+
+static inline int delete_refpos_marker2(GapIO *io, bin_index_t *bin,
+					int bin_idx, range_t *r);
+
 /*
  * Sets the contig start position
  *
@@ -165,28 +185,108 @@ int contig_offset(GapIO *io, contig_t **c) {
  * position and offset computed against that absolute pos. These get passed
  * around in apos / aoffset.
  *
+ * io   is the current GapIO struct
+ * crec is the contig record number
+ * bnum is the record number of the current bin.
+ * pos  is the position to be deleted wrt. parent bin/contig
+ * apos is the position to be deleted wrt. contig
+ * start_of_contig is a flag to say that the deletion is the first base of the
+ *   contig.
+ * offset  is the position of the bin wrt. its parent
+ * aoffset is the position of the bin wrt. the contig
+ * base is the base to insert (shift only if 0)
+ * conf is the confidence value for the inserted base
+ * nbases is the number of bases to insert
+ * comp is 1 if the parent bin was complemented, 0 otherwise
+ * hash is a hache table tracking sequences that have moved
+ * cstart is the start position of the contig
+ * cend is the end position of the contig
+ * *moved_left is the leftmost contig position where a sequence that overlaps
+               pos has moved.
+ * *moved_right is the rightmost contig position where a sequence has moved
+ * *fixed_right is the rightmost contig position where a sequence has not
+ *              moved.
+ *
+ *
  * Returns >=0 for success (0 => no insertion made, 1 => insert done)
  *          -1 for failure
  */
+
+/* Note on sequence range updates.
+ *
+ * For the uncomplemented case, this is fairly simple.  If the position
+ * to be inserted (pos) is in the visible part of a sequence, the sequence
+ * base gets bigger and r->end is incremented by nbases.  If the visible part
+ * of the sequence is entirely to the right of pos, the sequence needs to
+ * shift right so both r->start and r->end are incremented by nbases.
+ *
+ * When all the sequences have been grown or moved, bin->size is
+ * incremented by nbases as the entire bin is now nbases longer.
+ *
+ * In ascii art:
+ *    bin->pos                bin->pos + bin->size     bin->size+=nbases
+ *    v                       v
+ *    ===========*============>
+ *      r->start..r->end
+ *      v         v
+ *      ---=====---                           no change 
+ *          ---==*==---                       r->end+=nbases (inserting bases)
+ *          ---=====---                       no change (shift only)
+ *              ---=====---                   r->start+=nbases,r->end+=nbases
+ *               ^
+ *               pos
+ *
+ * In the complemented case, as the bin's size has changed,
+ * the entire contents will already have moved right with respect to the
+ * contig.  Also, r->end is the left end of the sequence in the contig
+ * and r->start is the right.  Incrementing them will move the position
+ * to the left in the contig.  Hence, when pos is in the visible part
+ * of the sequence, we need to increment r->end by nbases so the left end of
+ * the sequence stays still.  (Note that this is the same update as needed
+ * in the uncomplemented case).  For the shift case, any reads where
+ * pos is to the right of the visible start in the contig need to
+ * have both r->start and r->end incremented by nbases.  This compensates the
+ * move of the bin to the left, resulting in the sequence staying still.
+ *
+ *    bin->pos                bin->pos + bin->size   bin->size+=nbases
+ *    v                       v                      (moves everything right) 
+ *    <==========*=============
+ *      r->end....r->start
+ *      v         v
+ *      ---=====---                r->start+=bases,r->end+=nbases
+ *          ---==*==---            r->end+=nbases  (inserting bases)
+ *          ---=====---            r->start+=nbases,r->end+=nbases (shift only)
+ *              ---=====---        no change
+ *               ^
+ *               pos
+ */
+
 static int contig_insert_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 			       int pos, int apos, int start_of_contig,
 			       int offset, int aoffset, char base, int conf,
-			       int nbases, int comp, HacheTable *hash) {
-    int i, ins = 0;
+			       int nbases, int comp, HacheTable *hash,
+			       int cstart, int cend,
+			       int *moved_left, int *moved_right,
+			       int *fixed_right, HacheTable *pileup,
+			       int *fail) {
     bin_index_t *bin;
-    HacheData hd;
-    int f_a, f_b;
+    int bin_start = INT_MAX;
+    int bin_end   = INT_MIN;
+    int ins       = 0;
+    int i, f_a, f_b;
 
     bin = get_bin(io, bnum);
-    cache_incr(io, bin);
-
+    if (!bin) return -1;
     if (!(bin = cache_rw(io, bin)))
 	return -1;
 
+    debug("Raw used range bin %"PRIrec" %d..%d\n",
+    	   bnum, bin->start_used, bin->end_used);
+
     /* Normalise pos for complemented bins */
     if (bin->flags & BIN_COMPLEMENTED) {
 	comp ^= 1;
-	pos = offset + bin->size - pos;
+	pos = offset + bin->size-1 - pos;
     } else {
 	pos -= offset;
     }
@@ -199,227 +299,233 @@ static int contig_insert_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 	f_b = aoffset;
     }
 
-    /* FIXME: add end_used (or start_used if complemented?) check here,
-     * so we can shortcut looping through the bin if we're inserting beyond
-     * any of the bin contents.
-     */
+    assert(NORM(pos) == apos);
+    debug("Bin %"PRIrec" pos = %d apos = %d\n", bnum, pos, apos);
 
     /* Perform the insert into objects first */
     for (i = 0; bin->rng && i < ArrayMax(bin->rng); i++) {
 	range_t *r = arrp(range_t, bin->rng, i);
+	seq_t *s = NULL;
+	int rtype, astart, aend, grow = 0;
 
 	if (r->flags & GRANGE_FLAG_UNUSED)
 	    continue;
 
-	if ((start_of_contig &&
-	     pos <= MAX(r->start, r->end)+1 &&
-	     pos >= MIN(r->start, r->end))  ||
-	    (!start_of_contig &&
-	     pos <= MAX(r->start, r->end)   &&
-	     pos >  MIN(r->start, r->end))) {
-	    //printf("pos overlap obj #%"PRIrec" %d in %d..%d\n",
-	    //	   r->rec, pos,
-	    //	   MIN(r->start, r->end),
-	    //	   MAX(r->start, r->end));
-	    /* Insert */
-	    if ((r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISREFPOS &&
-		(r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISANNO) {
-		/* ISCONS? skip perhaps as we invalidate them anyway */
-		seq_t *s = cache_search(io, GT_Seq, r->rec);
-		int no_ins;
+	rtype = r->flags & GRANGE_FLAG_ISMASK;
 
-		if (!s) {
-		    verror(ERR_WARN, "contig_insert_base2",
-			   "failed to load seq #%"PRIrec, r->rec);
-		    continue;
-		}
+	debug("Item type %d rec %"PRIrec" %d..%d\n",
+	      rtype, r->rec, r->start, r->end);
 
-		if (ABS(r->end - r->start) + 1 != ABS(s->len)) {
-		    verror(ERR_WARN, "contig_insert_base2", 
-			   "Range start/end are inconsistent with seq len. ");
-		}
+	switch (rtype) {
+	case GRANGE_FLAG_ISSEQ: 
+	case GRANGE_FLAG_ISCONS:
+	case GRANGE_FLAG_ISREF: {
+	    col_inserted_base *ins_base = NULL;
 
-		no_ins = 0;
-		if (base) {
-		    int r_start, r_end;
-		    if (/*comp ^ */(s->len < 0)) {
-			r_start = MIN(r->end - (s->right-1),
-				      r->end - (s->left-1));
-			r_end = MAX(r->end - (s->right-1),
-				    r->end - (s->left-1));
-		    } else {
-			r_start = MIN(r->start + s->left-1,
-				      r->start + s->right-1);
-			r_end = MAX(r->start + s->right-1,
-				    r->start + s->left-1);
-		    }
-		    if (pos <= r_start || pos > r_end)
-			no_ins = 1;
-
-		    // printf("Rec %"PRIrec" visible %d..%d abs %d..%d\n",
-		    //	   r->rec, r_start, r_end,
-		    //	   NORM(r_start), NORM(r_end));
-
-		    if (!no_ins) {
-			//printf("INS %"PRIrec" at %d\n", r->rec,
-			//       pos - MIN(r->start, r->end));
-			//int i;
-			//for (i = 0; i < nbases; i++)
-			//    sequence_insert_base(io, &s,
-			//			 pos - MIN(r->start, r->end),
-			//			 base, conf, 0);
-			sequence_insert_bases(io, &s,
-					      pos - MIN(r->start, r->end),
-					      base, conf, nbases, 0);
-			if (hash) {
-			    //printf("1 Mov %"PRIrec"\n", r->rec);
-			    hd.i = MAX(NMIN(r_start, r_end), apos);
-			    HacheTableAdd(hash, (char *)&r->rec,
-					  sizeof(r->rec), hd, NULL);
-			}
-			//printf("1 %"PRIrec"->end++\n", r->rec);
-			r->end+=nbases;
-			ins = 1;
-		    }
-		}
+	    /* sequences use visible start/end */
+	    s = cache_search(io, GT_Seq, r->rec);
+	    if (!s) {
+		verror(ERR_WARN, "contig_insert_base2",
+		       "failed to load seq #%"PRIrec, r->rec);
+		/*
+		 * Keep going regardless!
+		 *
+		 * This is less problematic than simply bailing out here,
+		 * as doing that will leave some reads with an insertion
+		 * and some without, along with reads to the right
+		 * not being shifted.
+		 *
+		 * It is better to attempt to fix the problem or to
+		 * work around it than to cause an even bigger one by
+		 * simply aborting the action.
+		 */
+		*fail = 1;
+		continue;
+	    }
+	    if (ABS(r->end - r->start) + 1 != ABS(s->len)) {
+		verror(ERR_WARN, "contig_insert_base2", 
+		       "Range start/end are inconsistent with seq length "
+		       "for #%"PRIrec, r->rec);
+		/* Fix it! */
+		r->end = ABS(s->len) + r->start - 1;
+
+		*fail = 1;
+	    }
+	    if (s->len < 0) {
+		astart = NMIN(r->end - (s->right-1), r->end - (s->left-1));
+		aend   = NMAX(r->end - (s->right-1), r->end - (s->left-1));
+	    } else {
+		astart = NMIN(r->start + s->left-1, r->start + s->right-1);
+		aend   = NMAX(r->start + s->left-1, r->start + s->right-1);
+	    }
 
-		if (!base || no_ins) {
-		    /* Shift instead, but only if in left-cutoff data */ 
-		    if (/*comp ^ */ (s->len < 0)) {
-			if (MIN(r->end - (s->right-1), r->end - (s->left-1))
-			    >= pos) {
-			    if (hash) {
-				//printf("2 Mov %"PRIrec"\n", r->rec);
-				hd.i = comp ? INT_MAX : INT_MIN;
-				HacheTableAdd(hash, (char *)&r->rec,
-					      sizeof(r->rec), hd, NULL);
-			    }
-			    //printf("2 %"PRIrec"->start/end++\n", r->rec);
-			    r->start+=nbases;
-			    r->end+=nbases;
-			    ins = 1;
-			}
-		    } else {
-			if (MIN(r->start + s->left-1, r->start + s->right-1)
-			    >= pos) {
-			    if (hash) {
-				//printf("3 Mov %"PRIrec"\n", r->rec);
-				hd.i = comp ? INT_MAX : INT_MIN;
-				HacheTableAdd(hash, (char *)&r->rec,
-					      sizeof(r->rec), hd, NULL);
-			    }
-			    //printf("3 %"PRIrec"->start/end++\n", r->rec);
-			    r->start+=nbases;
-			    r->end+=nbases;
-			    ins = 1;
-			}
-		    }
-		}
-	    } else if ((r->flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISANNO) {
-		if (base && !(r->flags & GRANGE_FLAG_TAG_SEQ)) {
-		    //printf("grow anno %"PRIrec"\n", r->rec);
-		    r->end+=nbases;
-		    ins = 1;
+	    debug("Seq %"PRIrec" visible abs %d..%d\n", s->rec, astart, aend);
+
+	    /* Look for seq record in pileup */
+	    if (pileup && rtype == GRANGE_FLAG_ISSEQ) {
+		HacheItem *hi = HacheTableSearch(pileup, (char *) &r->rec,
+						 sizeof(r->rec));
+		if (hi) {
+		    ins_base = (col_inserted_base *) hi->data.p;
+		    HacheTableDel(pileup, hi, 0);
 		}
 	    }
 	    
-	    bin->flags |= BIN_RANGE_UPDATED;
+	    /* Do the insert */
+	    if ((ins_base && apos >= astart && apos <= aend + 1)
+		|| (base && apos > astart && apos <= aend)) {
+		int res;
+		if (ins_base) {
+		    debug("Insert pileup base %c at %d\n",
+			  ins_base->base, pos - r->start + (comp ? 1 : 0));
+		    res = sequence_insert_bases(io, &s,
+						pos - r->start + (comp ? 1 : 0),
+						ins_base->base,
+						ins_base->conf,
+						nbases, 0, comp);
+		} else {
+		    debug("Insert base %c at %d\n",
+			  base, pos - r->start + (comp ? 1 : 0));
+		    res = sequence_insert_bases(io, &s,
+						pos - r->start + (comp ? 1 : 0),
+						base, conf,
+						nbases, 0, comp);
+		}
+		if (0 != res) *fail = 1;
+		grow = 1;
+	    }
+	    break;
+	}
+	case GRANGE_FLAG_ISANNO:
+	    /* Defer seq annotations to contig_insert_tag2
+	       This is because seqs that move instead of grow need
+	       tags to move along the whole length, not just
+	       the ones to the right of apos. */
+	    if (0 != (r->flags & GRANGE_FLAG_TAG_SEQ)) continue;
+	    /* Fall through */
+	case GRANGE_FLAG_ISUMSEQ:
+	case GRANGE_FLAG_ISREFPOS: {
+	    astart = NMIN(r->start, r->end);
+	    aend   = NMAX(r->start, r->end);
+	    grow   = (GRANGE_FLAG_ISANNO
+		      ? (base && apos > astart && apos <= aend) : 0);
+	    debug("abs %d..%d grow = %d\n", astart, aend, grow);
+	    break;
+	}
+	default:
+	    verror(ERR_WARN, "contig_insert_base2",
+		   "Unknown record type %d found\n", rtype);
+	    continue;
+	}
 
-	} else if (MIN(r->start, r->end) >= pos) {
-	    //printf("pos to left of obj #%"PRIrec" %d %d..%d\n", 
-	    //	   r->rec, pos,
-	    //	   MIN(r->start, r->end),
-	    //	   MAX(r->start, r->end));
-	    if ( (r->flags&GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISANNO) {
-		/* Move */
-		//printf("4 %"PRIrec"->start/end++\n", r->rec);
-		r->start+=nbases;
-		r->end+=nbases;
-		ins = 1;
+	/* Update range */
+	if (grow) {
+	    debug("r->end += %d\n", nbases);
+	    r->end += nbases;
+	    bin->flags |= BIN_RANGE_UPDATED;
+	} else {
+	    if (comp ? (apos > astart) : (apos <= astart)) {
+		debug("r->start += %d; r->end += %d\n", nbases, nbases);
+		r->start += nbases;
+		r->end   += nbases;
 		bin->flags |= BIN_RANGE_UPDATED;
+	    }
+	}
 
-		if (hash) {
-		    //printf("4 Mov %"PRIrec"\n", r->rec);
-		    hd.i = comp ? INT_MAX : INT_MIN;
-		    HacheTableAdd(hash, (char *)&r->rec,
-				  sizeof(r->rec), hd, NULL);
+	if (rtype == GRANGE_FLAG_ISSEQ) {
+	    /* Update moved_left/right, fixed_right */
+	    if (grow || apos <= astart) { /* Seq moved */
+		if (!grow) {
+		    *moved_left  = MIN(NMIN(r->start, r->end), *moved_left);
 		}
-	    } else if (!(r->flags & GRANGE_FLAG_TAG_SEQ)) {
-		/* Consensus tag */
-		r->start+=nbases;
-		r->end+=nbases;
-		ins = 1;
-		bin->flags |= BIN_RANGE_UPDATED;
+		*moved_right = MAX(NMAX(r->start, r->end), *moved_right);
+		debug("moved_left = %d moved_right = %d\n",
+		      *moved_left, *moved_right);
+	    } else { /* stayed put */
+		*fixed_right = MAX(NMAX(r->start, r->end), *fixed_right);
+		debug("fixed_right = %d\n", *fixed_right);
 	    }
-	} /* else pos to right of object */
+
+	    /* Add to hash so contig_insert_tag2 knows which tags to move */
+	    if (hash && (grow || (comp ? (apos > astart) : (apos <= astart)))) {
+		HacheData hd;
+		hd.i = grow ? apos : (comp ? INT_MAX : INT_MIN);
+		if (NULL == HacheTableAdd(hash, (char *)&r->rec,
+					  sizeof(r->rec), hd, NULL)) {
+		    *fail = 1;
+		}
+	    }
+	}
+
+	/* Keep track of bin start / end */
+	if (bin_start > r->start) bin_start = r->start;
+	if (bin_end   < r->end)   bin_end   = r->end;
     }
 
     /* Adjust the bin dimensions */
-    {
-	bin->size+=nbases;
+    bin->size += nbases;
+    if (bin_start != INT_MAX) {
+	debug("Update bin used range to %d..%d\n", bin_start, bin_end);
+	bin->start_used = bin_start;
+	bin->end_used   = bin_end;
 	ins = 1;
-	if (bin->rng && ArrayMax(bin->rng)) {
-	    int start = INT_MAX;
-	    int end   = INT_MIN;
-	    for (i = 0; i < ArrayMax(bin->rng); i++) {
-		range_t *r = arrp(range_t, bin->rng, i);
-	    
-		if (r->flags & GRANGE_FLAG_UNUSED)
-		    continue;
-
-		if (start > r->start)
-		    start = r->start;
-		if (end   < r->end)
-		    end   = r->end;
-	    }
-	    if (start != INT_MAX) {
-		bin->start_used = start;
-		bin->end_used = end;
-	    } else {
-		bin->start_used = 0;
-		bin->end_used = 0;
-	    }
-	}
-	bin->flags |= BIN_BIN_UPDATED;
+    } else {
+	debug("Bin empty, set ued range to 0..0\n");
+	bin->start_used = bin->end_used = 0;
     }
+    bin->flags |= BIN_BIN_UPDATED;
 
     /* Recurse */
-    if (bin->child[0] || bin->child[1]) {
+    for (i = 0; i < 2; i++) {
 	bin_index_t *ch = NULL;
+	int astart, aend;
 
-	/* Find the correct child node */
-       	for (i = 0; i < 2; i++) {
-	    if (!bin->child[i])
-		continue;
+	if (!bin->child[i]) continue;
 
-	    ch = get_bin(io, bin->child[i]);
+	ch = get_bin(io, bin->child[i]);
+	if (NULL == ch) {
+	    verror(ERR_WARN, "contig_insert_base2",
+		   "Failed to load bin %"PRIrec, bin->child[i]);
+	    continue;
+	}
+	astart = NMIN(ch->pos, ch->pos + ch->size-1);
+	aend   = NMAX(ch->pos, ch->pos + ch->size-1);
 
-	    if (pos >= MIN(ch->pos, ch->pos + ch->size-1) &&
-		pos <= MAX(ch->pos, ch->pos + ch->size-1)) {
-		ins |= contig_insert_base2(io, crec, bin->child[i], pos, apos,
-					   start_of_contig,
-					   MIN(ch->pos, ch->pos + ch->size-1),
-					   NMIN(ch->pos, ch->pos + ch->size-1),
-					   base, conf, nbases, comp, hash);
-		/* Children to the right of this one need pos updating too */
-	    } else if (pos < MIN(ch->pos, ch->pos + ch->size-1)) {
-		ch = get_bin(io, bin->child[i]);
-		if (!(ch = cache_rw(io, ch))) {
-		    cache_decr(io, bin);
-		    return -1;
-		}
+	debug("Child bin %"PRIrec" abs %d..%d\n", ch->rec, astart, aend);
 
-		//printf("Mov bin %"PRIrec"\n", ch->rec);
+	/* Using absolute coordinates, measure the impact on contig
+	 * start and end locations.
+	 */
 
-		ch->pos+=nbases;
-		if (ch->nseqs)
-		    ins=1;
-		ch->flags |= BIN_BIN_UPDATED;
-	    }
+	if (ch->nseqs && apos < astart && cend >= astart) {
+	    // Child entirely to right
+	    debug("BIN %"PRIrec" entirely right\n", ch->rec);
+	    /* The rightmost seq that has moved must be
+	       at least at astart */
+	    *moved_right = MAX(astart, *moved_right);
 	}
-    }
 
-    cache_decr(io, bin);
+	if (apos >= astart && apos <= aend) {
+	    /* Go into overlapping child bin */
+	    ins |= contig_insert_base2(io, crec, bin->child[i], pos, apos,
+				       start_of_contig,
+				       MIN(ch->pos, ch->pos + ch->size-1),
+				       astart,
+				       base, conf, nbases, comp, hash,
+				       cstart, cend,
+				       moved_left, moved_right,
+				       fixed_right, pileup, fail);
+	    if (ins < 0) *fail = 1;
+	} else if (pos < MIN(ch->pos, ch->pos + ch->size-1)) {
+	    /* Child is to the right (parent uncomplemented), or
+	       left (parent complemented) so need to update pos */
+	    if (NULL == (ch = cache_rw(io, ch))) return -1;
+	    debug("Child bin %"PRIrec" ch->pos += %d\n", ch->rec, nbases);
+	    ch->pos += nbases;
+	    if (ch->nseqs) ins = 1;
+	    ch->flags |= BIN_BIN_UPDATED;
+	}
+    }
 
     return ins;
 }
@@ -462,8 +568,8 @@ static int contig_insert_tag2(GapIO *io, tg_rec crec, tg_rec bnum,
 	f_b = aoffset;
     }
 
-    //printf("Bin %"PRIrec" => pos=%d, offset=%d, comp=%d\n",
-    //	   bin->rec, pos, offset, comp);
+    debug("Bin %"PRIrec" => pos=%d, offset=%d, comp=%d\n",
+	  bin->rec, pos, offset, comp);
 
     /*
      * Loop again through contents if hash is non-null and move tags. Seq
@@ -481,7 +587,7 @@ static int contig_insert_tag2(GapIO *io, tg_rec crec, tg_rec bnum,
      * We're safe provided the same logic is also applied to the tag, which
      * I believe it should be. Need to test.
      */
-    //printf("Pass 2\n");
+    debug("Pass 2\n");
     for (i = 0; bin->rng && i < ArrayMax(bin->rng); i++) {
 	range_t *r = arrp(range_t, bin->rng, i);
 	HacheItem *hi;
@@ -494,11 +600,11 @@ static int contig_insert_tag2(GapIO *io, tg_rec crec, tg_rec bnum,
 
 	hi = HacheTableSearch(hash, (char *)&r->pair_rec, sizeof(tg_rec));
 	if (hi) {
-	    //printf("Tag #%"PRIrec" in hash.  %d..%d (%d..%d) vs pos %d\n",
-	    //	   r->rec, r->start, r->end,
-	    //	   NMIN(r->start, r->end),
-	    //	   NMAX(r->start, r->end),
-	    //	   hi->data.i);
+	    debug("Tag #%"PRIrec" in hash.  %d..%d (%d..%d) vs pos %d\n",
+		  r->rec, r->start, r->end,
+		  NMIN(r->start, r->end),
+		  NMAX(r->start, r->end),
+		  (int) hi->data.i);
 
 	    if (comp) {
 		if (NMAX(r->start, r->end) <= (int64_t)hi->data.i) {
@@ -580,7 +686,8 @@ static int contig_insert_tag2(GapIO *io, tg_rec crec, tg_rec bnum,
 }
 
 int contig_insert_base_common(GapIO *io, contig_t **c,
-			      int pos, char base, int conf, int nbases) {
+			      int pos, char base, int conf, int nbases,
+			      HacheTable *pileup) {
     contig_t *n;
     int rpos, add_indel = 1;
     bin_index_t *bin;
@@ -590,23 +697,22 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
     tg_rec ref_id = 0;
     int dir;
     HacheTable *hash = NULL;
-    int ret;
-    int cstart, cend;
-    int nbases2 = nbases;
+    int ret, fail = 0;
+    int nbases2 = nbases; 
+    int cstart = (*c)->start, cend = (*c)->end;
+    int moved_left, moved_right, fixed_right;
 
-    if (pos < (*c)->start || pos > (*c)->end)
-	return 0;
-    
-    consensus_valid_range(io, (*c)->rec, &cstart, &cend);
+    debug("PRE %d..%d\n", (*c)->start, (*c)->end);
 
-    if (pos < cstart || pos > cend) {
+    if (pos < cstart || pos > cend + (pileup ? 1 : 0))
 	return 0;
-    }
     
     if (!(n = cache_rw(io, *c)))
 	return -1;
     *c = n;
 
+    rpos = padded_to_reference_pos(io, (*c)->rec, pos, &dir, NULL);
+
     if (base == 0) {
 	/*
 	 * Shift rather than insert+shift. The difference between consensus
@@ -619,10 +725,15 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
     hash = HacheTableCreate(4096, HASH_NONVOLATILE_KEYS | HASH_POOL_ITEMS
 			    | HASH_ALLOW_DUP_KEYS | HASH_DYNAMIC_SIZE);
 
+    moved_left = INT_MAX;
+    moved_right = fixed_right = INT_MIN;
     ret = contig_insert_base2(io, n->rec, contig_get_bin(c), pos, pos,
 			      pos == n->start,
 			      contig_offset(io, c), contig_offset(io, c),
-			      base, conf, nbases, 0, hash);
+			      base, conf, nbases, 0, hash,
+			      cstart, cend, &moved_left, &moved_right,
+			      &fixed_right, pileup, &fail);
+
     ret |= contig_insert_tag2(io, n->rec, contig_get_bin(c), pos, pos,
 			      pos == n->start,
 			      contig_offset(io, c), contig_offset(io, c),
@@ -636,14 +747,38 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
      * Similarly inserting a base *may* shrink the contig if the
      * left-most read is in left-cutoff data at pos.
      *
-     * For safety, we simply have to recompute start/end.
+     * To work out if we need to update, we keep track of the left and
+     * rightmost positions where a sequence has moved (moved_left,
+     * moved_right) and the rightmost position where a sequence overlapping
+     * pos did not move.
+     *
+     * We only need to recalculate the contig start if moved_left <= cstart.
+     *
+     * If moved_right > fixed_right we know that the contig has grown,
+     * otherwise we have to recalculate.
      */
 
-    /* Best guess */
-    contig_set_end(io, c, contig_get_end(c)+nbases);
+    debug("I moved_left = %d\nI cstart = %d\n"
+	  "I moved_right = %d\nI fixed_right = %d\n",
+	  moved_left, cstart, moved_right, fixed_right);
+
+    if (moved_left <= cstart + nbases)
+	consensus_unclipped_range(io, (*c)->rec, &cstart, NULL);
+
+    if (moved_right > fixed_right + nbases) {
+	cend += nbases;
+    } else {
+	/* Best guess */
+	contig_set_end(io, c, contig_get_end(c)+nbases);
+	consensus_unclipped_range(io, (*c)->rec, NULL, &cend);
+    }
 
     /* Verify */
-    consensus_unclipped_range(io, (*c)->rec, &cstart, &cend);
+//    int cs = cstart, ce = cend;
+//    consensus_unclipped_range(io, (*c)->rec, &cstart, &cend); // TEST only
+//    assert(cs == cstart);
+//    assert(ce == cend);
+
     if (contig_get_start(c) != cstart)
 	contig_set_start(io, c, cstart);
     if (contig_get_end(c) != cend)
@@ -654,17 +789,18 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
     /* Force update of clipped start/end */
     (*c)->clipped_timestamp = 0;
 
-    contig_visible_start(io, (*c)->rec, CITER_CSTART);
-    contig_visible_end(io, (*c)->rec, CITER_CEND);
+// Delay updating until we need them.
+//    contig_visible_start(io, (*c)->rec, CITER_CSTART);
+//    contig_visible_end(io, (*c)->rec, CITER_CEND);
 
-    if (1 != ret)
-	return 0;
+    if (ret != 1)
+	return fail ? -1 : 0;
 
-    rpos = padded_to_reference_pos(io, (*c)->rec, pos, &dir, NULL);
     rpos -= dir; /* Compensate for complemented contigs */
+    rpos--;
 
     /* Add a pad marker too for reference adjustments */
-    if (find_refpos_marker(io, (*c)->rec, pos + 1, // or pos + nbases?
+    if (find_refpos_marker(io, (*c)->rec, pos + nbases,
 			   &bin_rec, &bin_idx, &rc) == 0) {
 	assert((rc.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISREFPOS);
 	if ((rc.flags & GRANGE_FLAG_REFPOS_INDEL) == GRANGE_FLAG_REFPOS_DEL) {
@@ -676,16 +812,11 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
 	    r = arrp(range_t, bin->rng, bin_idx);
 
 	    if (rc.pair_rec <= nbases) {
-		//printf("Remove DEL of size %d\n", rc.pair_rec);
-		r->flags |= GRANGE_FLAG_UNUSED;
-		r->rec = bin->rng_free;
-		bin->rng_free = bin_idx;
-		bin_incr_nrefpos(io, bin, -1);
-		if (bin->start_used == r->start || bin->end_used == r->end)
-		    bin_set_used_range(io, bin);
+		debug("Remove DEL of size %d\n", rc.pair_rec);
+		delete_refpos_marker2(io, bin, bin_idx, r);
 		nbases2 -= rc.pair_rec;
 	    } else {
-		//printf("Decrement DEL of size %d\n", rc.pair_rec);
+		debug("Decrement DEL of size %d\n", rc.pair_rec);
 		r->pair_rec -= nbases;
 		nbases2 = 0;
 	    }
@@ -709,16 +840,11 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
 	    r = arrp(range_t, bin->rng, bin_idx);
 
 	    if (rc.pair_rec <= nbases2) {
-		//printf("Remove DEL of size %d\n", rc.pair_rec);
-		r->flags |= GRANGE_FLAG_UNUSED;
-		r->rec = bin->rng_free;
-		bin->rng_free = bin_idx;
-		bin_incr_nrefpos(io, bin, -1);
-		if (bin->start_used == r->start || bin->end_used == r->end)
-		    bin_set_used_range(io, bin);
+		debug("Remove DEL of size %d\n", rc.pair_rec);
+		delete_refpos_marker2(io, bin, bin_idx, r);
 		nbases2 -= rc.pair_rec;
 	    } else {
-		//printf("Decrement DEL of size %d\n", rc.pair_rec);
+		debug("Decrement DEL of size %d\n", rc.pair_rec);
 		r->pair_rec -= nbases2;
 		nbases2 = 0;
 	    }
@@ -729,12 +855,19 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
 	ref_id = rc.rec;
     }
 
+    if (dir == -1 && add_indel) {
+	/* No ref pos yet, so start it rolling */
+	dir = 0;
+	rpos-=1+nbases2;
+    }
+
     if (dir != -1 && add_indel) {
 	range_t r;
 	int i;
 
-	for (i = 0; i < nbases2; i++) {
-	    //printf("Adding insertion REFPOS at %d/%d\n", pos, rpos);
+	rpos += dir ? 2 : 0;
+	for (i = 0; i < nbases2; i++, pos++) {
+	    debug("Adding insertion REFPOS at %d/%d\n", pos, rpos);
 	    r.start    = pos;
 	    r.end      = pos;
 	    r.rec      = ref_id;
@@ -749,23 +882,99 @@ int contig_insert_base_common(GapIO *io, contig_t **c,
 	}
     }
 
+    debug("POST %d..%d\n", (*c)->start, (*c)->end);
+
     if (hash)
 	HacheTableDestroy(hash, 0);
 
-    return ret;
+    return fail ? -1 : ret;
 }
 
 int contig_insert_base(GapIO *io, contig_t **c, int pos, char base, int conf) {
-    return contig_insert_base_common(io, c, pos, base, conf, 1) >= 0 ? 0 : -1;
+    return contig_insert_base_common(io, c, pos, base, conf, 1, NULL)
+	>= 0 ? 0 : -1;
 }
 
 int contig_insert_bases(GapIO *io, contig_t **c, int pos, char base, int conf,
 			int nbases) {
-    return contig_insert_base_common(io, c, pos, base, conf, nbases)
+    return contig_insert_base_common(io, c, pos, base, conf, nbases, NULL)
 	>= 0 ? 0 : -1;
     return 0;
 }
 
+int contig_insert_column(GapIO *io, contig_t **c, int pos,
+			 size_t count, col_inserted_base *bases) {
+    HacheTable *pileup = NULL;
+    size_t i;
+    int inserted;
+
+    pileup = HacheTableCreate(count, HASH_NONVOLATILE_KEYS | HASH_POOL_ITEMS);
+    if (NULL == pileup) return -1;
+
+    for (i = 0; i < count; i++) {
+	HacheData hd;
+	hd.p = &bases[i];
+	if (NULL == HacheTableAdd(pileup, (char *) &bases[i].rec,
+				  sizeof(bases[i].rec), hd, NULL)) {
+	    HacheTableDestroy(pileup, 0);
+	    return -1;
+	}
+    }
+
+    inserted = contig_insert_base_common(io, c, pos, '*', -1, 1, pileup);
+
+    if (pileup->nused > 0) {
+	/* Some reads have not been inserted into, probably as the insertions
+	   were to the ends of reads in bins that don't overlap the
+	   insertion position.  Fix them up now. */
+	HacheIter *iter = HacheTableIterCreate();
+	HacheItem *hi = NULL;
+
+	if (NULL != iter) {	    
+	    while (NULL != (hi = HacheTableIterNext(pileup, iter))) {
+		col_inserted_base *ins_base = (col_inserted_base *) hi->data.p;
+		seq_t *s;
+		tg_rec brec, crec;
+		int start, end, orient;
+		
+		if (0 != bin_get_item_position(io, GT_Seq, ins_base->rec,
+					       &crec, &start, &end, &orient,
+					       &brec, NULL, (void **) &s)) {
+		    break;
+		}
+		
+		assert(NULL != s);
+		assert(crec == (*c)->rec);
+		if (start < pos) {
+		    assert(pos == end + 1);
+		} else {
+		    /* Read will have already been shifted by 1 base */
+		    assert(pos == start - 2);
+		}
+		if (0 != sequence_insert_base(io, &s,
+					      start < pos ? pos - start : 0,
+					      ins_base->base,
+					      ins_base->conf, 1)) {
+		    cache_decr(io, s);
+		    break;
+		}
+		if (0 != sequence_move(io, &s, c, start < pos ? 0 : -2)) {
+		    cache_decr(io, s);
+		    break;
+		}
+		cache_decr(io, s);
+	    }
+	    if (NULL != hi) inserted = -1; /* Something went wrong... */
+	    HacheTableIterDestroy(iter);
+	} else {
+	    inserted = -1; /* Couldn't make iterator */
+	}
+    }
+
+    HacheTableDestroy(pileup, 0);
+    return inserted >= 0 ? 0 : -1;
+}
+
 /*
  * FIXME: This cannot be finished until tg_index is rewritten to use the
  * cache instead of array entries.
@@ -796,12 +1005,93 @@ static int bin_delete(GapIO *io, bin_index_t *bin) {
     return 0;
 }
 
+/*
+ * Recursive delete consensus base function.  Gets called for each bin
+ * that overlaps the position to be deleted.
+ *
+ * io   is the current GapIO struct
+ * crec is the contig record number
+ * bnum is the record number of the current bin.
+ * pos  is the position to be deleted wrt. parent bin/contig
+ * apos is the position to be deleted wrt. contig
+ * start_of_contig is a flag to say that the deletion is the first base of the
+ *   contig.
+ * offset  is the position of the bin wrt. its parent
+ * aoffset is the position of the bin wrt. the contig
+ * base is a flag to say that the base should be deleted (otherwise just shift)
+ * comp is 1 if the parent bin was complemented, 0 otherwise
+ * hash is a hache table tracking sequences that have moved
+ * bcall if non-zero only delete this type of base
+ * cstart is the start position of the contig
+ * cend is the end position of the contig
+ * *moved_left is the leftmost contig position where a sequence that
+ *             overlaps pos has moved.
+ * *moved_right is the rightmost contig position where a sequence has moved
+ * *fixed_right is the rightmost contig position where a sequence has not
+ *              moved.
+ *
+ * Returns -1 on failure
+ *          1 if a base was deleted
+ *          0 if no base was deleted (shift only)
+ */
+
+/* Note on sequence range updates.
+ *
+ * For the uncomplemented case, this is fairly simple.  If the position
+ * to be deleted (pos) is in the visible part of a sequence, the sequence
+ * base is deleted and r->end is decremented.  If the visible part of
+ * the sequence is entirely to the right of pos, the sequence needs to
+ * shift left so both r->start and r->end are decremented.
+ *
+ * In ascii art:
+ *    bin->pos                bin->pos + bin->size     bin->size--
+ *    v                       v
+ *    ===========*============>
+ *      r->start..r->end
+ *      v         v
+ *      ---=====---                           no change 
+ *          ---==*==---                       r->end--  (deleting base)
+ *          ---=====---                       no change (shift only)
+ *              ---=====---                   r->start--,r->end--
+ *               ^
+ *               pos
+ *
+ * When all the sequences have been shrunk or moved, bin->size is
+ * decremented as the entire bin is now one base shorter.
+ *
+ * In the complemented case, as the bin's size has changed,
+ * the entire contents will already have moved left with respect to the
+ * contig.  Also, r->end is the left end of the sequence in the contig
+ * and r->start is the right.  Decrementing them will move the position
+ * to the right in the contig.  Hence, when pos is in the visible part
+ * of the sequence, we need to decrement r->end so the left end of the
+ * sequence stays still.  (Note that this is the same update as needed
+ * in the uncomplemented case).  For the shift case, any reads where
+ * pos is to the right of the visible start in the contig need to
+ * have both r->start and r->end decremented.  This compensates the move
+ * of the bin to the left, resulting in the sequence staying still.
+ *
+ *    bin->pos                bin->pos + bin->size   bin->size--
+ *    v                       v                      (moves everything left) 
+ *    <==========*=============
+ *      r->end....r->start
+ *      v         v
+ *      ---=====---                           r->start--,r->end--
+ *          ---==*==---                       r->end--  (deleting base)
+ *          ---=====---                       r->start--,r->end-- (shift only)
+ *              ---=====---                   no change
+ *               ^
+ *               pos
+ */
+
 static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 			       int pos, int apos, int start_of_contig,
 			       int offset, int aoffset,
 			       int base, int comp, HacheTable *hash,
-			       int bcall) {
-    int i, ins = 0;
+			       int bcall, int cstart, int cend,
+			       int *moved_left, int *moved_right,
+			       int *fixed_right) {
+    int i, del = 0;
     bin_index_t *bin;
     HacheData hd;
     int f_a, f_b;
@@ -821,6 +1111,7 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 	pos -= offset;
     }
 
+    /* Parameters for NORM, NMIN and NMAX macros */
     if (comp) {
 	f_a = -1;
 	f_b = aoffset + bin->size-1;
@@ -842,49 +1133,52 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 	    continue;
 
 	if (MAX(r->start, r->end) >= pos && MIN(r->start, r->end) <= pos) {
-	    //printf("pos overlap obj %d/#%"PRIrec" %d in %d..%d\n",
-	    //	   r->flags & GRANGE_FLAG_ISMASK, r->rec, pos,
-	    //	   MIN(r->start, r->end),
-	    //	   MAX(r->start, r->end));
-	    /* Delete */
+	    /* Range overlaps pos */
+
+	    debug("pos overlap obj %d/#%"PRIrec" %d in %d..%d\n",
+	    	   r->flags & GRANGE_FLAG_ISMASK, r->rec, pos,
+	    	   MIN(r->start, r->end),
+	    	   MAX(r->start, r->end));
+
 	    if ((r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISREFPOS &&
 		(r->flags & GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISANNO) {
 		/* ISCONS? skip perhaps as we invalidate them anyway */
 		seq_t *s = cache_search(io, GT_Seq, r->rec);
-		int no_ins;
+		int v_start, v_end; /* Visible start/end wrt. bin */
+		int no_del;
 
 		if (ABS(r->end - r->start) + 1 != ABS(s->len)) {
 		    verror(ERR_WARN, "contig_delete_base2", 
 			   "Range start/end are inconsistent with seq len. ");
 		}
 
-		no_ins = 0;
-		if (base) {
-		    int r_start, r_end;
-		    if (/*comp ^ */(s->len < 0)) {
-			r_start = MIN(r->end - (s->right-1),
-				      r->end - (s->left-1));
-			r_end = MAX(r->end - (s->right-1),
-				    r->end - (s->left-1));
-		    } else {
-			r_start = MIN(r->start + s->left-1,
-				      r->start + s->right-1);
-			r_end = MAX(r->start + s->right-1,
-				    r->start + s->left-1);
-		    }
-		    if (pos < r_start || pos > r_end)
-			no_ins = 1;
+		no_del = 0;
+		/* Find visible start/end of seq in bin */
+		if (s->len < 0) {
+		    v_start = MIN(r->end - (s->right-1), r->end - (s->left-1));
+		    v_end   = MAX(r->end - (s->right-1), r->end - (s->left-1));
+		} else {
+		    v_start = MIN(r->start + s->left-1, r->start + s->right-1);
+		    v_end   = MAX(r->start + s->left-1, r->start + s->right-1);
+		}
+
+		if (base) { /* See if we need to delete any bases */
+		    /* No need to delete if pos is outside visible portion */
+		    if (pos < v_start || pos > v_end)
+			no_del = 1;
 
-		    // printf("Rec %"PRIrec" visible %d..%d abs %d..%d\n",
-		    //	   r->rec, r_start, r_end,
-		    //	   NORM(r_start), NORM(r_end));
+		    debug("Rec %"PRIrec" visible %d..%d abs %d..%d\n",
+			  r->rec, v_start, v_end,
+			  NORM(v_start), NORM(v_end));
+
+		    if (!no_del) {
+			/* In visible part, so delete */
 
-		    if (!no_ins) {
 			if (r->start == r->end) {
 			    /* Remove completely */
 			    if (hash) {
-				//printf("1 Mov %"PRIrec"\n", r->rec);
-				hd.i = MAX(NMIN(r_start, r_end), apos);
+				debug("1 Mov %"PRIrec"\n", r->rec);
+				hd.i = MAX(NMIN(v_start, v_end), apos);
 				HacheTableAdd(hash, (char *)&r->rec,
 					      sizeof(r->rec), hd, NULL);
 			    }
@@ -894,15 +1188,20 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 
 			    bin->rng_free = i;
 			    bin->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
-			    bin_incr_nseq(io, bin, -1);
+
+			    if ((r->flags & GRANGE_FLAG_ISMASK)
+				== GRANGE_FLAG_ISSEQ) {
+				bin_incr_nseq(io, bin, -1);
+			    }
 
 			    if (bin->start_used == r->start ||
 				bin->end_used == r->end)
 				bin_set_used_range(io, bin);
 			} else {
+			    /* delete the base */
 			    int bb;
-			    //printf("DEL %"PRIrec" at %d\n", r->rec,
-			    //       pos - MIN(r->start, r->end));
+			    debug("DEL %"PRIrec" at %d\n", r->rec,
+				  pos - MIN(r->start, r->end));
 
 			    bb = ((r->flags & GRANGE_FLAG_ISMASK) ==
 				  GRANGE_FLAG_ISCONS)
@@ -911,47 +1210,79 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 						  pos - MIN(r->start, r->end),
 						  0, bb);
 			    if (hash) {
-				//printf("1 Mov %"PRIrec"\n", r->rec);
-				hd.i = MAX(NMIN(r_start, r_end), apos);
+				debug("1 Mov %"PRIrec"\n", r->rec);
+				hd.i = MAX(NMIN(v_start, v_end), apos);
 				HacheTableAdd(hash, (char *)&r->rec,
 					      sizeof(r->rec), hd, NULL);
 			    }
-			    //printf("1 %"PRIrec"->end--\n", r->rec);
+			    debug("1 %"PRIrec"->end--\n", r->rec);
 			    r->end--;
-			    ins = 1;
+			    del = 1;
+			    if ((r->flags & GRANGE_FLAG_ISMASK) ==
+				GRANGE_FLAG_ISSEQ) {
+				/* The sequence has got one base shorter,
+				   so the right end will have moved */
+				*moved_right = MAX(NMAX(r->start, r->end),
+						   *moved_right);
+			    }
 			}
 		    }
 		}
 
-		if (!base || no_ins) {
-		    /* Shift instead, but only if in left-cutoff data */ 
-		    if (/*comp ^ */ (s->len < 0)) {
-			if (MIN(r->end - (s->right-1), r->end - (s->left-1))
-			    >= pos) {
-			    if (hash) {
-				//printf("2 Mov %"PRIrec"\n", r->rec);
-				hd.i = comp ? INT_MAX : INT_MIN;
-				HacheTableAdd(hash, (char *)&r->rec,
-					      sizeof(r->rec), hd, NULL);
+		if (!base || no_del) {
+		    /* Shift instead.
+		       For uncomplemented bins, need to shift if
+		       v_start >= pos.
+		       For complemented bins, the entire bin will shift
+		       as the parent gets one base shorter.  To keep the
+		       reads to the right in the correct place we need to
+		       shift them if pos < visible end.
+		     */
+		    if (comp ? (pos < v_end) : (v_start >= pos)) {
+			if (hash) {
+			    debug("2 Mov %"PRIrec"\n", r->rec);
+			    hd.i = comp ? INT_MAX : INT_MIN;
+			    HacheTableAdd(hash, (char *)&r->rec,
+					  sizeof(r->rec), hd, NULL);
+			}
+
+			debug("2 %"PRIrec"->start/end--\n", r->rec);
+			r->start--;
+			r->end--;
+
+			if ((r->flags & GRANGE_FLAG_ISMASK) ==
+			    GRANGE_FLAG_ISSEQ) {
+			    if (comp) {
+				/* This sequence did not move, so
+				   update *fixed_right */
+				*fixed_right = MAX(NMAX(r->start, r->end),
+						   *fixed_right);
+			    } else {
+				/* This sequence moved to the left, so
+				   update *moved_left and *moved_right */
+				*moved_left = MIN(NMIN(r->start, r->end),
+						  *moved_left);
+				*moved_right = MAX(NMAX(r->start, r->end),
+						   *moved_right);
 			    }
-			    //printf("2 %"PRIrec"->start/end--\n", r->rec);
-			    r->start--;
-			    r->end--;
-			    ins = 1;
 			}
+			del = 1;
 		    } else {
-			if (MIN(r->start + s->left-1, r->start + s->right-1)
-			    >= pos) {
-			    if (hash) {
-				//printf("3 Mov %"PRIrec"\n", r->rec);
-				hd.i = comp ? INT_MAX : INT_MIN;
-				HacheTableAdd(hash, (char *)&r->rec,
-					      sizeof(r->rec), hd, NULL);
+			if ((r->flags & GRANGE_FLAG_ISMASK) ==
+			    GRANGE_FLAG_ISSEQ) {
+			    if (comp) {
+				/* This sequence moved to the left, so
+				   update *moved_left and *moved_right */
+				*moved_left = MIN(NMIN(r->start, r->end),
+						  *moved_left);
+				*moved_right = MAX(NMAX(r->start, r->end),
+						   *moved_right);
+			    } else {
+				/* This sequence did not move, so
+				   update *fixed_right */
+				*fixed_right = MAX(NMAX(r->start, r->end),
+						   *fixed_right);
 			    }
-			    //printf("3 %"PRIrec"->start/end--\n", r->rec);
-			    r->start--;
-			    r->end--;
-			    ins = 1;
 			}
 		    }
 		}
@@ -972,27 +1303,41 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 		    } else {
 			r->end--;
 		    }
-		    ins = 1;
+		    del = 1;
 		}
 	    }
 	    
 	    bin->flags |= BIN_RANGE_UPDATED;
 
 	} else if (MIN(r->start, r->end) >= pos) {
-	    //printf("pos to left of obj #%"PRIrec" %d %d..%d\n", 
-	    //	   r->rec, pos,
-	    //	   MIN(r->start, r->end),
-	    //	   MAX(r->start, r->end));
+	    debug("pos to left of obj #%"PRIrec" %d %d..%d\n", 
+		  r->rec, pos,
+		  MIN(r->start, r->end),
+		  MAX(r->start, r->end));
 	    if ( (r->flags&GRANGE_FLAG_ISMASK) != GRANGE_FLAG_ISANNO) {
 		/* Move */
-		//printf("4 %"PRIrec"->start/end--\n", r->rec);
+		debug("4 %"PRIrec"->start/end--\n", r->rec);
 		r->start--;
 		r->end--;
-		ins = 1;
+		if ((r->flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISSEQ) {
+		    if (comp) {
+			/* This sequence did not move, so
+			   update *fixed_right */
+			*fixed_right = MAX(NMAX(r->start, r->end),
+					   *fixed_right);
+		    } else {
+			/* This sequence moved to the left, so
+			   update *moved_left and *moved_right */
+			*moved_left = MIN(NMIN(r->start, r->end), *moved_left);
+			*moved_right = MAX(NMAX(r->start, r->end),
+					   *moved_right);
+		    }
+		}
+		del = 1;
 		bin->flags |= BIN_RANGE_UPDATED;
 
 		if (hash) {
-		    //printf("4 Mov %"PRIrec"\n", r->rec);
+		    debug("4 Mov %"PRIrec"\n", r->rec);
 		    hd.i = comp ? INT_MAX : INT_MIN;
 		    HacheTableAdd(hash, (char *)&r->rec,
 				  sizeof(r->rec), hd, NULL);
@@ -1001,7 +1346,7 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 		/* Move consensus tags */
 		r->start--;
 		r->end--;
-		ins = 1;
+		del = 1;
 		bin->flags |= BIN_RANGE_UPDATED;
 	    }
 	} /* else pos to right of object */
@@ -1023,9 +1368,9 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 	if (!hi)
 	    continue;
 
-	//printf("Rec %"PRIrec" hd.i=%ld comp=%d NORM=%d,%d\n",
-	//       r->rec, (long)hd.i, comp,
-	//       NORM(r->start), NORM(r->end));
+	debug("Rec %"PRIrec" hd.i=%ld comp=%d NORM=%d,%d\n",
+	      r->rec, (long)hd.i, comp,
+	      NORM(r->start), NORM(r->end));
 
 	if (r->start == r->end && NORM(r->start) == (int64_t)hi->data.i) {
 	    //puts("del1/2");
@@ -1080,11 +1425,11 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
     {
 	if (bin->size != max_r+1) {
 	    if (--bin->size <= 0) {
-		fprintf(stderr, "Delete bin bin-%"PRIrec"\n", bin->rec);
+		debug("Delete bin bin-%"PRIrec"\n", bin->rec);
 		bin->size = 0;
 		bin_delete(io, bin);
 	    } else {
-		ins = 1;
+		del = 1;
 		if (bin->rng && ArrayMax(bin->rng)) {
 		    if (min_r != INT_MAX) {
 			bin->start_used = min_r;
@@ -1121,26 +1466,48 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 
 	    ch = get_bin(io, bin->child[i]);
 
+	    /* Using absolute coordinates, measure the impact on contig
+	     * start and end locations.
+	     */
+	    if (ch->nseqs > 0 && 
+		apos <  NMIN(ch->pos, ch->pos + ch->size-1) &&
+		cend >= NMIN(ch->pos, ch->pos + ch->size-1)) {
+		// Child entirely to right
+		debug("BIN %"PRIrec" entirely right\n", bin->rec);
+		
+		/* Assumption: at lease one of the seqs in the
+		   child bin has a visible base, so the rightmost
+		   visible base that has moved must be at least at 
+		   NMIN(ch->pos, ch->pos + ch->size-1) */
+		*moved_right = MAX(NMIN(ch->pos, ch->pos + ch->size-1),
+				   *moved_right);
+	    }
+
 	    if (pos >= MIN(ch->pos, ch->pos + ch->size-1) &&
 		pos <= MAX(ch->pos, ch->pos + ch->size-1)) {
-		ins |= contig_delete_base2(io, crec, bin->child[i], pos, apos,
+		/* pos is within the child bin, so recurse into it */
+		del |= contig_delete_base2(io, crec, bin->child[i], pos, apos,
 					   start_of_contig,
 					   MIN(ch->pos, ch->pos + ch->size-1),
 					   NMIN(ch->pos, ch->pos + ch->size-1),
-					   base, comp, hash, bcall);
-		/* Children to the right of this one need pos updating too */
+					   base, comp, hash, bcall,
+					   cstart, cend,
+					   moved_left, moved_right,
+					   fixed_right);
 	    } else if (pos < MIN(ch->pos, ch->pos + ch->size-1)) {
+		/* Children to the right of pos need their position
+		   updating too */
 		ch = get_bin(io, bin->child[i]);
 		if (!(ch = cache_rw(io, ch))) {
 		    cache_decr(io, bin);
 		    return -1;
 		}
 
-		//printf("Mov bin %"PRIrec"\n", ch->rec);
+		debug("Mov bin %"PRIrec"\n", ch->rec);
 
 		ch->pos--;
 		if (ch->nseqs)
-		    ins=1;
+		    del=1;
 		ch->flags |= BIN_BIN_UPDATED;
 	    }
 	}
@@ -1148,7 +1515,7 @@ static int contig_delete_base2(GapIO *io, tg_rec crec, tg_rec bnum,
 
     cache_decr(io, bin);
 
-    return ins;
+    return del;
 }
 
 
@@ -1188,9 +1555,9 @@ static int contig_delete_base_fix(GapIO *io, tg_rec crec, tg_rec bnum,
 	if (r->start < 0) {
 	    bin_index_t *new_bin;
 
-	    //printf("Bin %"PRIrec" obj %"PRIrec" with start %d. Loc %d..%d\n",
-	    //	   bin->rec, r->rec, r->start,
-	    //	   NORM(r->start), NORM(r->end));
+	    debug("Bin %"PRIrec" obj %"PRIrec" with start %d. Loc %d..%d\n",
+		  bin->rec, r->rec, r->start,
+		  NORM(r->start), NORM(r->end));
 
 	    /* Convert range coords to absolute locations */
 	    r2 = *r;
@@ -1229,8 +1596,8 @@ static int contig_delete_base_fix(GapIO *io, tg_rec crec, tg_rec bnum,
 		s->bin = new_bin->rec;
 		s->bin_index = r_out - ArrayBase(range_t, new_bin->rng);
 
-		//printf("Old bin comp=%d new bin comp=%d\n",
-		//       old_comp, new_comp);
+		debug("Old bin comp=%d new bin comp=%d\n",
+		      old_comp, new_comp);
 
 		if (new_comp != old_comp) {
 		    s->len *= -1;
@@ -1273,23 +1640,34 @@ static int contig_delete_base_fix(GapIO *io, tg_rec crec, tg_rec bnum,
     return r;
 }
 
+/*
+ * Common entry-point for delete / shift contig base code.
+ *
+ * pos   is the contig position to delete or shift
+ * shift is a flag to say we want to shift only
+ * base  if non-zero, prevents bases other than this type from being removed.
+ */
+
 int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
 			      int base) {
     contig_t *n;
-    int bin_idx;
+    int bin_idx, refpos_bin_idx;
     tg_rec bin_rec;
     rangec_t rc;
     int cur_del = 0;
     int done = 0, reduced;
     HacheTable *hash = NULL;
-    int cstart, cend;
+    int cstart = (*c)->start, cend = (*c)->end;
+    int moved_left, moved_right;
+    int fixed_right;
+    bin_index_t *refpos_bin = NULL;
 
-    consensus_valid_range(io, (*c)->rec, &cstart, &cend);
+    debug("contig_delete_base_common contig =%"PRIrec
+	  " pos %d shift %d base %d\n",
+	  (*c)->rec, pos, shift, base);
 
-    if (pos < cstart || pos > cend) {
-	puts("Do nothing");
+    if (pos < cstart - 1 || pos > cend)
 	return 0;
-    }
 
     if (!(n = cache_rw(io, *c)))
 	return -1;
@@ -1301,34 +1679,31 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
      * If we do have one neighbouring, either increment it (if deletion) or
      * remove it (if insertion).
      */
-    if (find_refpos_marker(io, (*c)->rec, pos, &bin_rec, &bin_idx, &rc) == 0) {
+    if (find_refpos_marker(io, (*c)->rec, pos, &bin_rec,
+			   &refpos_bin_idx, &rc) == 0) {
 	range_t *r;
-	bin_index_t *bin;
 
 	assert((rc.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISREFPOS);
 
-	bin = cache_search(io, GT_Bin, bin_rec);
-	bin = cache_rw(io, bin);
-	r = arrp(range_t, bin->rng, bin_idx);
+	refpos_bin = cache_search(io, GT_Bin, bin_rec);
+	refpos_bin = cache_rw(io, refpos_bin);
+	r = arrp(range_t, refpos_bin->rng, refpos_bin_idx);
 
 	if ((rc.flags & GRANGE_FLAG_REFPOS_INDEL) == GRANGE_FLAG_REFPOS_INS) {
-	    /* Existing insertion, so remove it */
-	    //printf("Remove insertion marker\n");
-	    r->flags |= GRANGE_FLAG_UNUSED;
-	    r->rec = bin->rng_free;
-	    bin->rng_free = bin_idx;
-	    bin_incr_nrefpos(io, bin, -1);
-
-	    if (bin->start_used == r->start || bin->end_used == r->end)
-		bin_set_used_range(io, bin);
+	    /* Existing insertion, so remove it.  Insertions are always
+	       1 long, so the deletion cancels it and there's nothing else
+	       left to do. */
+	    debug("Remove insertion marker\n");
 	    done = 1;
 	} else {
 	    /* Existing deletion, add it to neighbouring position */
-	    //printf("DEL %d marker to apply to right\n", r->pair_rec);
+	    debug("DEL %d marker to apply to right\n", r->pair_rec);
 	    cur_del = r->pair_rec;
 	}
 
-	bin->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
+	/* The base this marker on is about to disappear, so it needs
+	   to go too.  But we defer removal until later in case we
+	   need to call padded_to_reference_pos below. */
     }
 
     if (!done && find_refpos_marker(io, (*c)->rec, pos+1, &bin_rec,
@@ -1337,6 +1712,9 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
 	bin_index_t *bin;
 	int ins_type;
 
+	/* Found a marker to the right.  Work out the new indel length and
+	   update as necessary */
+
 	assert((rc.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISREFPOS);
 
 	bin = cache_search(io, GT_Bin, bin_rec);
@@ -1344,50 +1722,47 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
 	r = arrp(range_t, bin->rng, bin_idx);
 
 	ins_type = (rc.flags & GRANGE_FLAG_REFPOS_INDEL);
-	cur_del++;
+	cur_del++; /* The deletion we are about to make */
+	if (ins_type == GRANGE_FLAG_REFPOS_INS) {
+	    cur_del--;               /* -1 for an insertion */
+	} else {
+	    cur_del += r->pair_rec;  /* + the length of the deletion */
+	}
 
-	if (ins_type == GRANGE_FLAG_REFPOS_INS && cur_del == 1) {
-	    //printf("Remove INS marker\n");
+	if (cur_del == 0) {
+	    debug("Remove INS marker\n");
 	    /* 1 del + 1 ins => remove marker */
-	    r->flags |= GRANGE_FLAG_UNUSED;
-	    r->rec = bin->rng_free;
-	    bin->rng_free = bin_idx;
-	    bin_incr_nrefpos(io, bin, -1);
-
-	    if (bin->start_used == r->start || bin->end_used == r->end)
-		bin_set_used_range(io, bin);
+	    delete_refpos_marker2(io, bin, bin_idx, r);
 	} else {
-	    /* Otherwise N del + 1 ins => N-1 del */
-	    if (ins_type == GRANGE_FLAG_REFPOS_INS) {
-		cur_del--;
-		r->flags &= ~GRANGE_FLAG_REFPOS_INDEL;
-		r->flags |= GRANGE_FLAG_REFPOS_DEL;
-		r->pair_rec = cur_del;
-		//printf("Replace INS with DEL %d\n", r->pair_rec);
-	    } else {
-		/* N del + M ndel => N+M del */
-		//printf("Inc DEL %d to DEL %d\n",
-		//       r->pair_rec, r->pair_rec + cur_del);
-		r->pair_rec += cur_del;
-	    }
+	    /* Ensure it's now a deletion */
+	    r->flags = ((r->flags & ~GRANGE_FLAG_REFPOS_INDEL)
+			| GRANGE_FLAG_REFPOS_DEL);
+	    r->pair_rec = cur_del;
+	    debug("Set refpos marker to %d base deletion\n", cur_del);
 	}
 	
 	bin->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
 
     } else if (!done) {
-	/* No existing marker at pos or pos+1 => a new +1 DEL marker */
-	range_t r;
+	/* No existing marker at pos+1 => a new +1 DEL marker */
+	range_t r = {0};
 	int dir;
-	int rpos = padded_to_reference_pos(io, (*c)->rec, pos+1, &dir, NULL);
+	int id;
+	int rpos = padded_to_reference_pos(io, (*c)->rec, pos+1, &dir, &id);
+
+	if (dir == -1) {
+	    /* No ref pos yet, so start it rolling */
+	    dir = 0;
+	}
 
 	if (dir != -1) {
 	    rpos += dir; /* Compensate for complemented contigs */
 
 	    /* Create a deletion marker */
-	    //printf("Adding deletion REFPOS at %d/%d\n", pos, rpos);
+	    debug("Adding deletion REFPOS at %d/%d\n", pos, rpos);
 	    r.start    = pos+1;
 	    r.end      = pos+1;
-	    r.rec      = 0;
+	    r.rec      = id;
 	    r.pair_rec = 1+cur_del;
 	    r.mqual    = rpos;
 
@@ -1399,6 +1774,13 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
 	} /* else no refpos data => don't keep tracking it */
     }
 
+    if (NULL != refpos_bin) {
+	/* Remove the doomed refpos marker here */
+	delete_refpos_marker2(io, refpos_bin, refpos_bin_idx,
+			      arrp(range_t, refpos_bin->rng, refpos_bin_idx));	
+	refpos_bin->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
+    }
+
     /*
      * When shifting only we need to track which sequences moved so we can
      * move annotations too. See comments in insertion code for why.
@@ -1406,10 +1788,14 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
     hash = HacheTableCreate(4096, /*HASH_NONVOLATILE_KEYS | */HASH_POOL_ITEMS
 			    | HASH_ALLOW_DUP_KEYS | HASH_DYNAMIC_SIZE);
 
+    moved_left  = INT_MAX;
+    moved_right = fixed_right = INT_MIN;
     reduced = contig_delete_base2(io, n->rec, contig_get_bin(c), pos, pos,
 				  pos == n->start,
 				  contig_offset(io, c), contig_offset(io, c),
-				  !shift, 0, hash, base);
+				  !shift, 0, hash, base,
+				  cstart, cend, &moved_left, &moved_right,
+				  &fixed_right);
 
     /*
      * Deletion can move objects left if the deleted coord is in the left
@@ -1429,11 +1815,29 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
      * sometimes it moves sequences and other times it deletes from sequences,
      * depending on whether we're in cutoff data or not.
      *
-     * The easiest solution is just recalculate both ends.
+     * To work out if we need to update, we keep track of the left and
+     * rightmost positions where a sequence has moved (moved_left,
+     * moved_right) and the rightmost position where a sequence overlapping
+     * pos did not move.
+     *
+     * We only need to recalculate the contig start if moved_left <= cstart.
+     *
+     * If moved_right > fixed_right we know that the contig has shrunk,
+     * otherwise we have to recalculate.
      */
-    contig_visible_start(io, (*c)->rec, CITER_CSTART);
-    contig_visible_end(io, (*c)->rec, CITER_CEND);
-    consensus_unclipped_range(io, (*c)->rec, &cstart, &cend);
+
+    debug("D moved_left = %d\nD cstart = %d\n"
+	  "D moved_right = %d\nD fixed_right = %d\n",
+	  moved_left, cstart, moved_right, fixed_right);
+
+    if (moved_left <= cstart)
+	consensus_unclipped_range(io, (*c)->rec, &cstart, NULL);
+
+    if (moved_right > fixed_right)
+	cend -= 1;
+    else
+	consensus_unclipped_range(io, (*c)->rec, NULL, &cend);
+
     if (contig_get_start(c) != cstart)
 	contig_set_start(io, c, cstart);
     if (contig_get_end(c) != cend)
@@ -1441,6 +1845,9 @@ int contig_delete_base_common(GapIO *io, contig_t **c, int pos, int shift,
 
     (*c)->timestamp = io_timestamp_incr(io);
 
+    /* Force update of clipped start/end */
+    (*c)->clipped_timestamp = 0;
+
     if (hash)
 	HacheTableDestroy(hash, 0);
 
@@ -1462,16 +1869,18 @@ int contig_delete_pad(GapIO *io, contig_t **c, int pos) {
  * The code shares a lot with ins/del, so we just call those functions with
  * specific arguments. Eg insertion base==0 implies shift only.
  *
- * dir +1 => shift right
- *     -1 => shift left
- *
- * Currently 1bp only, but in future we may support +n/-n
+ * dir +N => shift right by N bases
+ *     -N => shift left by N bases
  */
 int contig_shift_base(GapIO *io, contig_t **c, int pos, int dir) {
-    if (dir > 0)
-	return contig_insert_base_common(io, c, pos, 0, 0, 1);
-    else
-	return contig_delete_base_common(io, c, pos+1, 1, 0);
+    if (dir > 0) {
+	return contig_insert_base_common(io, c, pos, 0, 0, dir, NULL);
+    } else {
+	int r = 0;
+	while (dir++ < 0)
+	    r |= contig_delete_base_common(io, c, pos+1, 1, 0);
+	return r;
+    }
 }
 
 contig_t *contig_new(GapIO *io, char *name) {
@@ -2245,118 +2654,84 @@ static int (*set_sort(int job))(const void *, const void *) {
 }
 
 
-static int find_string_match_values(GapIO *io, rangec_t *r, seq_sort_t *setting, int count) {
-    char *seq = NULL;
-    int seq_size = (setting->end - setting->start) + 1;
-    int i, j, k;
-    int c_start = setting->start;
-    int c_end   = setting->end;
+static int find_haplo_match_values(GapIO *io, tg_rec crec, int start, int end,
+				   rangec_t *r, seq_sort_t *setting, int count) {
     
-    if (NULL == (seq = (char *)malloc(seq_size * sizeof(char)))) {
-    	fprintf(stderr, "Error: memory allocation failure in find_string_match_values\n");
+    contig_list_t clist;
+    Array rec_list;
+    HashTable *h;
+    contig_t *c;
+    int i, j;
+
+    c = cache_search(io, GT_Contig, crec);
+    if (!c)
 	return 1;
+
+    // Use selection if set, otherwise the current visible portion.
+    if (setting->type == GT_Contig && setting->rec == crec &&
+	ABS(setting->end - setting->start) > 0) {
+	crec  = setting->rec;
+	start = MIN(setting->start, setting->end);
+	end   = MAX(setting->start, setting->end);
     }
-    
-    seq[seq_size - 1] = 0;
-    
-    // get the selection, either from the consensus or a read
-    
-    if (setting->rec == 0) return 1;
 
-    if (setting->type == GT_Contig) {
-    	if (-1 == (calculate_consensus_simple(io, setting->rec,
-	    	     setting->start, setting->end, seq, NULL))) {
-	    fprintf(stderr, "Error: unable to retrieve consensus data\n");
-	    free(seq);
-	    return 1;
-	}
+    if (c->timestamp <= c->haplo_timestamp &&
+	start == c->haplo_start &&
+	end == c->haplo_end &&
+	setting->rec == c->haplo_rec) {
+	// cached
+	h = c->haplo_hash;
     } else {
-    	seq_t *s = cache_search(io, GT_Seq, setting->rec);
-	
-	// look for the right record in range for the pos info
-	// there is probably a better way but do this for now
-	
-	for (i = 0; i < count; i++) {
-	    if (r[i].rec == setting->rec) break;
-	}
-	
-	if (i == count) { // rec not there, probably out of range
-	    free(seq);
+	clist.contig = crec;
+	clist.start  = start;
+	clist.end    = end;
+
+	if (!(rec_list = find_haplotypes(io, &clist, 1, 1, 10.0, 5.0, 3)))
 	    return 1;
-	}
-	
-	
-	k = 0;
-	
-	// map the select start to the consensus start
-	c_start += r[i].start;
-	c_end   += r[i].start;;
-	
-    	for (j = setting->start; j <=  setting->end; j++) {
-	    char base;
-	    int cutoff;
-	    
-	    if (get_base(s, &r[i], j, &base, &cutoff) || cutoff) {
-	    	seq[k] = '_';
-	    } else {
-	    	seq[k] = base;
-	    }
-	    
-	    k++;
-	}
-    }
-    
-    // go through the reads and assign matching scores
-    
-    for (i = 0; i < count; i++) {
-    	rangec_t *rn = &r[i];
-	
-    	if ((rn->flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISSEQ) {
-    	    seq_t *s = cache_search(io, GT_Seq, rn->rec);
 
-	    k = 0;
-	    rn->seq_match = 0;
-	    
-	    // create a hash to group like sequences together
-	    rn->seq_hash = 1315423911;
+	if (c->haplo_hash)
+	    HashTableDestroy(c->haplo_hash, 0);
 
-	    for (j = (c_start - rn->start); j <= (c_end - rn->start); j++) {
-		char base;
-		int cutoff;
+	c->haplo_start = start;
+	c->haplo_end = end;
+	c->haplo_rec = setting->rec;
+	c->haplo_hash = HashTableCreate(count, 0);
+	c->haplo_timestamp = c->timestamp;
 
-		if (get_base(s, &r[i], j, &base, &cutoff) || cutoff) {
-		    base = '_';
-		}
-		
-		// naive match scoring, +3 match, -1 mismatch, 0 for off the read end
-		
-		if (seq[k] == base) {
-	    	    rn->seq_match += 3;
-		} else if (base != '_') {
-	    	    rn->seq_match --;
-		}
+	h = c->haplo_hash;
 
-		k++;
-		
-		rn->seq_hash ^= ((rn->seq_hash << 5) + base + (rn->seq_hash >> 2));
+	// Index
+	for (i = 0; i < ArrayMax(rec_list); i++) {
+	    Array x = arr(Array, rec_list, i);
+	    for (j = 0; j < ArrayMax(x); j++) {
+		HashData hd = {ArrayMax(rec_list) - i};
+		HashTableAdd(h, (char *)arrp(tg_rec, x, j), sizeof(tg_rec), hd, NULL);
 	    }
-	    
-	    rn->seq_hash &= 0x0FFF;
+	}
+
+	for (i = 0; i < ArrayMax(rec_list); i++)
+	    ArrayDestroy(arr(Array, rec_list, i));
+	ArrayDestroy(rec_list);
+    }
 
+    // Loop through 'r' using indexed haplotype
+    for (i = 0; i < count; i++) {
+    	rangec_t *rn = &r[i];
+	HashItem *hi;
+
+	if ((hi = HashTableSearch(h, (char *)&rn->rec, sizeof(rn->rec)))) {
+	    rn->seq_match = hi->data.i;
 	} else {
-	   rn->seq_match = 0;
-	   rn->seq_hash  = 0; 
-	} 
+	    rn->seq_match = -1;
+	}
+	rn->seq_hash = 0;
     }
-    
-    free(seq);
 
     return 0;
 }
 
 
 
-
 /* Pick Y coordinates for ranges */
 int x_cmp(struct xy_pair *y1, struct xy_pair *y2) {
     int d = (y1->x) - (y2->x);
@@ -2920,7 +3295,7 @@ static rangec_t *contig_objects_in_range(GapIO *io, contig_t **c, seq_sort_t *so
 	    }
 	    
 	    if (job & CSIR_SORT_BY_SEQUENCE) {
-	    	if (find_string_match_values(io, r, sort_set, *count)) {
+		if (find_haplo_match_values(io, (*c)->rec, start, end, r, sort_set, *count)) {
 		    // something wrong, possibly selection not set. Default to tech sort
 		    first ^= CSIR_SORT_BY_SEQUENCE;
 		    first |= CSIR_SORT_BY_X | CSIR_SORT_BY_SEQ_TECH;
@@ -5103,7 +5478,7 @@ int padded_to_reference_pos(GapIO *io, tg_rec cnum, int ppos, int *dir_p,
     contig_iterator *ci;
     rangec_t *r;
     int rpos;
-    int dir;
+    int dir, d;
 
     ci = contig_iter_new_by_type(io, cnum, 1, CITER_FIRST | CITER_ISTART, 
 				 ppos, CITER_CEND, GRANGE_FLAG_ISREFPOS);
@@ -5137,20 +5512,32 @@ int padded_to_reference_pos(GapIO *io, tg_rec cnum, int ppos, int *dir_p,
 	    if (ref_id) *ref_id = -1;
 	    return ppos;
 	}
-
-	dir = 0 ^ r->comp;
+	/*
+	 * d is the delta to add to our reference position while dir is the
+	 * direction (fwd/rev) for subsequent numbers.
+	 *
+	 * Mostly the two agree, but around indels there are some corner
+	 * cases.
+	 */
+	if ((r->flags & GRANGE_FLAG_REFPOS_INDEL) == GRANGE_FLAG_REFPOS_DEL)
+	    d = 1 ^ r->comp;
+	else
+	    d = 0 ^ r->comp;
     } else {
-	dir = 1 ^ r->comp;
+	d = 1 ^ r->comp;
     }
+    dir = 1 ^ r->comp;
 
     if (((r->flags & GRANGE_FLAG_REFPOS_DIR) == GRANGE_FLAG_REFPOS_FWD) ^ r->comp)
-	rpos = r->mqual + (ppos - r->start + dir);
+	rpos = r->mqual + (ppos - r->start + d);
     else
-	rpos = r->mqual - (ppos - r->start - dir);
+	rpos = r->mqual - (ppos - r->start - d);
 
     if ((r->flags & GRANGE_FLAG_REFPOS_INDEL) == GRANGE_FLAG_REFPOS_DEL) {
 	if (dir == 1) /* fwd */
 	    rpos -= (ppos < r->start) * r->pair_rec + 1;
+	else
+	    rpos -= (ppos >= r->start) * r->pair_rec;
     }
     
     if (dir_p)
@@ -5205,6 +5592,107 @@ int find_refpos_marker(GapIO *io, tg_rec cnum, int ppos,
     return -1;
 }
 
+static inline int delete_refpos_marker2(GapIO *io, bin_index_t *bin,
+					int bin_idx, range_t *r) {
+    r->flags |= GRANGE_FLAG_UNUSED;
+    r->rec = bin->rng_free;
+    if (0 != bin_incr_nrefpos(io, bin, -1)) return -1;
+    if (bin->start_used == r->start || bin->end_used == r->end) {
+	if (0 != bin_set_used_range(io, bin)) return -1;
+    }
+    return 0;
+}
+
+/*
+ * Remove refpos marker if present.
+ * 
+ * io   is the GapIO struct for the database.
+ * crec is the contig record number
+ * pos  is the padded position in the contig
+ *
+ * Returns  0 if marker removed or no marker found
+ *         -1 on failure 
+ */
+int delete_refpos_marker(GapIO *io, tg_rec crec, int pos) {
+    tg_rec       bin_rec;
+    int          bin_idx;
+    rangec_t     rc;
+    bin_index_t *bin;
+    range_t     *r;
+
+    if (0 == find_refpos_marker(io, crec, pos, &bin_rec, &bin_idx, &rc)) {
+	assert((rc.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISREFPOS);
+	bin = cache_search(io, GT_Bin, bin_rec);
+	if (NULL == bin) return -1;
+	bin = cache_rw(io, bin);
+	if (NULL == bin) return -1;
+	r = arrp(range_t, bin->rng, bin_idx);
+	if (0 != delete_refpos_marker2(io, bin, bin_idx, r)) return -1;
+	bin->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
+    }
+
+    return 0;
+}
+
+/*
+ * Set a refpos marker.  Will alter an existing one, or create a new one
+ * as necessary.
+ *
+ * io   is the GapIO struct for the database.
+ * c    is the contig_t struct ** for the contig
+ * pos  is the padded position on the contig
+ * type is the type of refpos (GRANGE_FLAG_REFPOS_INS or GRANGE_FLAG_REFPOS_DEL)
+ * dir  is the direction (GRANGE_FLAG_REFPOS_FWD or GRANGE_FLAG_REFPOS_REV)
+ * id   is the reference ID
+ * rpos is the reference position
+ * len  is the number of deleted bases (GRANGE_FLAG_REFPOS_DEL only)
+ *
+ * Returns  0 on success
+ *         -1 on failure
+ */
+
+int set_refpos_marker(GapIO *io, contig_t **c, int pos,
+		      int type, int dir, int id, int rpos, int len) {
+    tg_rec       bin_rec;
+    int          bin_idx;
+    rangec_t     rc;
+    bin_index_t *bin;
+    int          is_del = type & GRANGE_FLAG_REFPOS_DEL;
+
+    /* Check if a refpos marker is already present */
+    if (0 == find_refpos_marker(io, (*c)->rec, pos, &bin_rec, &bin_idx, &rc)) {
+	range_t *r;
+	assert((rc.flags & GRANGE_FLAG_ISMASK) == GRANGE_FLAG_ISREFPOS);
+	bin = cache_search(io, GT_Bin, bin_rec);
+	if (NULL == bin) return -1;
+	bin = cache_rw(io, bin);
+	if (NULL == bin) return -1;
+	r = arrp(range_t, bin->rng, bin_idx);
+
+	r->mqual = rpos;
+	r->rec   = id;
+	if (is_del) r->pair_rec = len;
+	r->flags = (r->flags & ~GRANGE_FLAG_REFPOS_INDEL)
+	    | (type & GRANGE_FLAG_REFPOS_INDEL)
+	    | (dir & GRANGE_FLAG_REFPOS_DIR);
+
+	bin->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
+	
+    } else {
+	range_t r = {0};
+	r.start = r.end = pos;
+	r.rec = id;
+	if (is_del) r.pair_rec = len;
+	r.mqual = rpos;
+
+	r.flags = GRANGE_FLAG_ISREFPOS
+	    | (type & GRANGE_FLAG_REFPOS_INDEL)
+	    | (dir & GRANGE_FLAG_REFPOS_DIR);
+	if (NULL == bin_add_range(io, c, &r, NULL, NULL, 0)) return -1;
+    }
+
+    return 0;
+}
 
 /*
  * Converts a range of padded coordinates to reference coordinates.
@@ -5212,13 +5700,20 @@ int find_refpos_marker(GapIO *io, tg_rec cnum, int ppos,
  *
  * ref_pos and ref_id should be allocated by the caller to be of
  * appropriate size (paddeed_end - padded_start + 1).
+ * Insertions get ref_id of -1 (if non NULL) and ref_pos[] element of INT_MIN.
+ *
+ * If non-NULL start_pos is the first reference coordinate used. Note that the
+ * read may start in an insertion, in which case nP (if non NULL) is the
+ * number of preceeding padding characters before the first base in order
+ * to keep the multiple sequence alignment.
  *
  * Returns 0 on success
  *        -1 on failure
  */
 int padded_to_reference_array(GapIO *io, tg_rec cnum,
 			      int padded_start, int padded_end,
-			      int *ref_pos, int *ref_id) {
+			      int *ref_pos, int *ref_id,
+			      int *start_pos, int *nP) {
     int dir, rpos, i, rid;
     contig_iterator *ci;
     int len = padded_end - padded_start + 1;
@@ -5226,6 +5721,12 @@ int padded_to_reference_array(GapIO *io, tg_rec cnum,
 
     /* Starting point */
     rpos = padded_to_reference_pos(io, cnum, padded_start, &dir, &rid);
+    if (start_pos)
+	*start_pos = rpos;
+
+    if (nP)
+	*nP = 0;
+
     switch (dir) {
     case -1: dir = +1; break; /* guess */
     case  0: dir = +1; break;
@@ -5248,7 +5749,31 @@ int padded_to_reference_array(GapIO *io, tg_rec cnum,
 
     i = 0;
     while ((r = contig_iter_next(io, ci))) {
-	int fwd;
+	int fwd, d;
+
+	if (nP && i == 0 &&
+	    r->start == padded_start &&
+	    (r->flags & GRANGE_FLAG_REFPOS_INDEL) != GRANGE_FLAG_REFPOS_DEL) {
+	    /* Starts in an insertion, to compute leading pad count */
+	    contig_iterator *pi;
+	    rangec_t *pr;
+	    int ppos = padded_start-1;
+	    pi = contig_iter_new_by_type(io, cnum, 0,
+					 CITER_LAST | CITER_ISTART, 
+					 CITER_CSTART, padded_start-1,
+					 GRANGE_FLAG_ISREFPOS);
+	    *nP = 0;
+	    while ((pr = contig_iter_prev(io, pi))) {
+		if ((pr->flags & GRANGE_FLAG_REFPOS_INDEL) ==
+		    GRANGE_FLAG_REFPOS_DEL)
+		    break;
+		if (pr->start < ppos)
+		    break;
+		(*nP)++;
+		ppos--;
+	    }
+	    contig_iter_del(pi);
+	}
 
 	while (i < len && padded_start < r->start) {
 	    ref_pos[i] = rpos;
@@ -5260,19 +5785,23 @@ int padded_to_reference_array(GapIO *io, tg_rec cnum,
 	    padded_start++;
 	}
 
-	dir = 1 ^ r->comp;
+	dir = 1-2*r->comp; // 0=>1 1=>-1
+	d = 1 ^ r->comp;
 
 	fwd = ((r->flags & GRANGE_FLAG_REFPOS_DIR) == GRANGE_FLAG_REFPOS_FWD);
 	if (fwd ^ r->comp)
-	    rpos = r->mqual + (padded_start - r->start + dir);
+	    rpos = r->mqual + (padded_start - r->start + d);
 	else
-	    rpos = r->mqual - (padded_start - r->start - dir);
+	    rpos = r->mqual - (padded_start - r->start - d);
 
 	if ((r->flags & GRANGE_FLAG_REFPOS_INDEL) == GRANGE_FLAG_REFPOS_DEL) {
-	    if (dir == 1) /* fwd */
+	    if (d == 1) /* fwd */
 		rpos -= (padded_start < r->start) * r->pair_rec + 1;
+	    else
+		rpos -= r->pair_rec;
 	} else {
-	    ref_pos[i] = rpos;
+	    //ref_pos[i] = rpos;
+	    ref_pos[i] = INT_MIN;
 	    if (ref_id)
 		ref_id[i] = -1; /* indel */
 	    i++;
@@ -5288,6 +5817,8 @@ int padded_to_reference_array(GapIO *io, tg_rec cnum,
 	i++;
     }
 
+    contig_iter_del(ci);
+
     return 0;
 }
 
@@ -5621,3 +6152,61 @@ int contig_get_link_positions(GapIO *io,
 
     return 0;
 }
+
+
+/*
+ * Clears all refpos from contig cr1 and copies the refpos from contig
+ * cr2 into contig cr1.
+ *
+ * Returns 0 on success,
+ *        -1 on failure.
+ */
+int copy_refpos(GapIO *io, tg_rec cr1, tg_rec cr2) {
+    contig_t *c1 = cache_search(io, GT_Contig, cr1);
+    contig_t *c2 = cache_search(io, GT_Contig, cr2);
+    contig_iterator *ci;
+    rangec_t *r;
+
+    if (!c1 || !c2)
+	return -1;
+
+    cache_incr(io, c1);
+    cache_incr(io, c2);
+
+
+    /* Clear old refpos markers */
+    ci = contig_iter_new_by_type(io, cr1, 0, CITER_FIRST | CITER_ISTART,
+				 INT_MIN, INT_MAX, GRANGE_FLAG_ISREFPOS);
+    if (!ci)
+	return -1;
+
+    while ((r = contig_iter_next(io, ci))) {
+	bin_index_t *bin = cache_search(io, GT_Bin, r->orig_rec);
+	fast_remove_item_from_bin(io, &c1, &bin, 0, r->rec, r->orig_ind);
+    }
+    contig_iter_del(ci);
+
+
+    /* Copy over new refpos markers */
+    ci = contig_iter_new_by_type(io, cr2, 0, CITER_FIRST | CITER_ISTART,
+				 INT_MIN, INT_MAX, GRANGE_FLAG_ISREFPOS);
+    if (!ci)
+	return -1;
+
+    while ((r = contig_iter_next(io, ci))) {
+	range_t rb = {0};
+	rb.start = rb.end = r->start;
+	rb.rec = r->rec;
+	rb.pair_rec = r->pair_rec;
+	rb.mqual = r->mqual;
+	rb.flags = r->flags;
+	bin_add_range(io, &c1, &rb, NULL, NULL, 0);
+    }
+    contig_iter_del(ci);
+
+
+    cache_decr(io, c1);
+    cache_decr(io, c2);
+
+    return 0;
+}
diff --git a/gap5/tg_contig.h b/gap5/tg_contig.h
index f45f1da..f505e21 100644
--- a/gap5/tg_contig.h
+++ b/gap5/tg_contig.h
@@ -48,6 +48,16 @@ int contig_insert_base(GapIO *io, contig_t **c, int pos, char base, int conf);
 int contig_insert_bases(GapIO *io, contig_t **c, int pos, char base, int conf,
 			int nbases);
 
+typedef struct {
+    tg_rec rec;
+    int    pos;
+    char   base;
+    int8_t conf;
+} col_inserted_base;
+
+int contig_insert_column(GapIO *io, contig_t **c, int pos,
+			 size_t count, col_inserted_base *bases);
+
 int contig_delete_base(GapIO *io, contig_t **c, int pos);
 
 int contig_delete_pad(GapIO *io, contig_t **c, int pos);
@@ -74,6 +84,8 @@ rangec_t *contig_anno_in_range(GapIO *io, contig_t **c, int start, int end,
 			       int job, int *count);
 rangec_t *contig_cons_in_range(GapIO *io, contig_t **c, int start, int end,
 			       int job, int *count);
+rangec_t *contig_refpos_in_range(GapIO *io, contig_t **c, int start, int end,
+				 int job, int *count);
 			       
 void contig_set_default_sort(seq_sort_t *set, int primary, int secondary);
 void contig_set_base_sort_point(int pos);
@@ -282,6 +294,39 @@ int find_refpos_marker(GapIO *io, tg_rec cnum, int ppos,
 		       tg_rec *bin_r, int *bin_idx_r, rangec_t *rp);
 
 /*
+ * Remove refpos marker if present.
+ * 
+ * io   is the GapIO struct for the database.
+ * crec is the contig record number
+ * pos  is the padded position in the contig
+ *
+ * Returns  0 if marker removed or no marker found
+ *         -1 on failure 
+ */
+int delete_refpos_marker(GapIO *io, tg_rec crec, int pos);
+
+/*
+ * Set a refpos marker.  Will alter an existing one, or create a new one
+ * as necessary.
+ *
+ * io   is the GapIO struct for the database.
+ * c    is the contig_t struct ** for the contig
+ * pos  is the padded position on the contig
+ * type is the type of refpos (GRANGE_FLAG_REFPOS_INS or GRANGE_FLAG_REFPOS_DEL)
+ * dir  is the direction (GRANGE_FLAG_REFPOS_FWD or GRANGE_FLAG_REFPOS_REV)
+ * id   is the reference ID
+ * rpos is the reference position
+ * len  is the number of deleted bases (GRANGE_FLAG_REFPOS_DEL only)
+ *
+ * Returns  0 on success
+ *         -1 on failure
+ */
+
+int set_refpos_marker(GapIO *io, contig_t **c, int pos,
+		      int type, int dir, int id, int rpos, int len);
+
+
+/*
  * Given a contig record and a reference position, attempt to return
  * the padded coordinate. Note this may not exist, it may in extreme cases
  * exist multiple times (after breaking and rejoining), or it may exist
@@ -311,13 +356,21 @@ int reference_to_padded_pos2(GapIO *io, tg_rec cnum, int ref_id, int ref_pos,
  *
  * ref_pos and ref_id should be allocated by the caller to be of
  * appropriate size (paddeed_end - padded_start + 1).
+ * Insertions get ref_id of -1 (if non NULL) and ref_pos[] element of INT_MIN.
+ *
+ * If non-NULL start_pos is the first reference coordinate used. Note that the
+ * read may start in an insertion, in which case nP (if non NULL) is the
+ * number of preceeding padding characters before the first base in order
+ * to keep the multiple sequence alignment.
  *
  * Returns 0 on success
  *        -1 on failure
  */
 int padded_to_reference_array(GapIO *io, tg_rec cnum,
 			      int padded_start, int padded_end,
-			      int *ref_pos, int *ref_id);
+			      int *ref_pos, int *ref_id,
+			      int *start_pos, int *nP);
+
 
 /* 
  * Moves an entire contig by a relative amount left (-ve) or right (+ve).
@@ -375,4 +428,13 @@ int contig_get_link_positions(GapIO *io,
 			      contig_link_t *rel_link,
 			      contig_link_t *abs_link);
 
+/*
+ * Clears all refpos from contig cr1 and copies the refpos from contig
+ * cr2 into contig cr1.
+ *
+ * Returns 0 on success,
+ *        -1 on failure.
+ */
+int copy_refpos(GapIO *io, tg_rec cr1, tg_rec cr2);
+
 #endif /* _TG_CONTIG_H_ */
diff --git a/gap5/tg_gio.c b/gap5/tg_gio.c
index af68936..00cfc30 100644
--- a/gap5/tg_gio.c
+++ b/gap5/tg_gio.c
@@ -195,7 +195,18 @@ GapIO *gio_open(char *fn, int ro, int create) {
  * Also frees any associated memory.
  */
 void gio_close(GapIO *io) {
-    if (io->base) {
+    /* Remove from linked list */
+    if (io->prev) {
+	io->prev->next = io->next;
+    }
+    if (io->next) {
+	io->next->prev = io->prev;
+    }
+
+    if (io->base) { /* Child IO */
+	if (io->pair_rec_updates) {
+	    HacheTableDestroy(io->pair_rec_updates, 0);
+	}
 	cache_destroy(io);
 	free(io);
 	return;
@@ -250,6 +261,7 @@ void gio_close(GapIO *io) {
  */
 GapIO *gio_child(GapIO *io_p) {
     GapIO *io = (GapIO *)calloc(1, sizeof(*io));
+    GapIO *base;
 
     assert(0 == io_p->last_bin); /* No pending updates in bin_add_to_range */
 
@@ -264,6 +276,13 @@ GapIO *gio_child(GapIO *io_p) {
     io->debug_fp = io->base->debug_fp;
     io->last_bin = 0;
     io->max_template_size = io->base->max_template_size;
+
+    /* Add to linked list of child IOs */
+    base = gio_base(io_p);
+    if (base->next) base->next->prev = io;
+    io->next = base->next;
+    io->prev = base;
+    base->next = io;
     return io;
 }
 
diff --git a/gap5/tg_gio.h b/gap5/tg_gio.h
index 5cdcad4..5ea2db5 100644
--- a/gap5/tg_gio.h
+++ b/gap5/tg_gio.h
@@ -33,7 +33,10 @@ typedef struct GapIO {
     /* --- Valid always --- */
     /* DB object cache */
     HacheTable *cache;
-    struct GapIO *base;
+    struct GapIO *base;  /* Pointer to parent IO */
+
+    struct GapIO *prev;  /* Linked list of IOs */
+    struct GapIO *next;
 
     /* --- Valid if base == NULL --- */
     /* I/O interface */
@@ -74,6 +77,9 @@ typedef struct GapIO {
     int incr_rvalue;
     int incr_avalue;
 
+    /* Delayed updates to range pair_rec */
+    HacheTable *pair_rec_updates;
+
     /* Maximum template size, for template_max_size */
     int max_template_size;
 
@@ -114,6 +120,7 @@ void *cache_search(GapIO *io, int type, tg_rec rec);
 void *cache_search_no_load(GapIO *io, int type, tg_rec rec);
 int cache_upgrade(GapIO *io, cached_item *ci, int mode);
 void *cache_lock(GapIO *io, int type, tg_rec rec, int mode);
+int cache_lock_mode(GapIO *io, void *data);
 
 void cache_dump(GapIO *io); /* Print cache contents, for debugging */
 
diff --git a/gap5/tg_iface_g.c b/gap5/tg_iface_g.c
index b5c0855..e952500 100644
--- a/gap5/tg_iface_g.c
+++ b/gap5/tg_iface_g.c
@@ -1565,6 +1565,9 @@ static cached_item *io_database_read(void *dbh, tg_rec rec) {
 	db->timestamp = 2;
     }
 
+    // Obtained via index lookup
+    db->config_anno = 0;
+
     g_assert(cp-buf == buf_len, NULL);
     free(buf);
 
@@ -1645,9 +1648,8 @@ static int io_database_write_view(g_io *io, database_t *db, GView v) {
 	cp += intw2u7(db->scaffold, cp);
 	cp += intw2u7(db->scaffold_name_index, cp);
     }
-    if (io->db_vers >= 6) {
+    if (io->db_vers >= 6)
 	cp += int2u7(db->timestamp, cp);
-    }
     
     /* FIXME: Should write block record numbers */
 
@@ -1871,6 +1873,8 @@ static cached_item *io_contig_read(void *dbh, tg_rec rec) {
     c->nrefpos = 0;
     c->timestamp = 1;
     c->clipped_timestamp = 0;
+    c->haplo_hash = NULL;
+    c->haplo_timestamp = 0;
 
     free(ch);
 
@@ -3155,7 +3159,7 @@ static cached_item *io_bin_read(void *dbh, tg_rec rec) {
     /* Load tracks */
     if (b->track) {
 	GViewInfo vi;
-	size_t nitems, i;
+	size_t nitems = 0, i;
 	GBinTrack *bt;
 
 	if (-1 == (v = lock(io, (int)b->track, G_LOCK_RO)))
@@ -3166,6 +3170,10 @@ static cached_item *io_bin_read(void *dbh, tg_rec rec) {
 	io->rdcounts[GT_Track]++;
 
 	bt = (GBinTrack *)io_generic_read_i4(io, v, GT_RecArray, &nitems);
+	if (!bt) {
+	    free(buf);
+	    return NULL;
+	}
 	nitems /= sizeof(GBinTrack) / sizeof(GCardinal);
 	bin->track = ArrayCreate(sizeof(bin_track_t), nitems);
 	bin->track->max = bin->track->dim = nitems;
@@ -3680,8 +3688,8 @@ static tg_rec io_track_create(void *dbh, void *vfrom) {
  * ? byte 'right clip'
  * ? byte sequence length
  * ? byte parent_rec;
- * 1 byte parent_type;
- * 1 byte seq_tech (3 bottom bits)
+ * 1 byte parent_type (6 bits + 2 high bits of seq_tech);
+ * 1 byte seq_tech (3 bottom bits, + 2 high bits of previous byte)
  *      + flags (3 next bits)
  *      + format (2 top bits)
  * 1 byte mapping_quality
@@ -3720,6 +3728,9 @@ static cached_item *seq_decode(unsigned char *buf, size_t len, tg_rec rec) {
 	parent_type = *cp++;
 	format = *cp++;
 	seq_tech = format & ((1<<3)-1);
+	// Steal 2 bits from parent_type to increase data range in seq_tech
+	seq_tech += (parent_type >> 6) << 3;
+	parent_type &= 0x3f;
 	format >>= 3;
 	flags = format & ((1<<3)-1);
 	format >>= 3;
@@ -3983,10 +3994,11 @@ static int io_seq_write_view(g_io *io, seq_t *seq, GView v, tg_rec rec) {
 
     /* Read-pair info */
     cp += intw2u7(seq->parent_rec, cp);
-    *cp++ = seq->parent_type;
+    /* Top two bits are used to increase seq_tech size */
+    *cp++ = seq->parent_type | ((seq->seq_tech >> 3) << 6);
 
     /* flags & m.quality */
-    *cp++ = (seq->format << 6) | (seq->flags << 3) | seq->seq_tech;
+    *cp++ = (seq->format << 6) | (seq->flags << 3) | (seq->seq_tech & 7);
     *cp++ = seq->mapping_qual;
 
     /* Annotations */
@@ -4328,7 +4340,10 @@ static cached_item *io_seq_block_read(void *dbh, tg_rec rec) {
     for (i = 0 ; i < SEQ_BLOCK_SZ; i++) { 
 	if (!in[i].bin) continue;
 	unsigned char f = *cp++;
-	in[i].seq_tech = f & 7;
+	// Steal 2 bits from parent_type to expand seq_tech range
+	in[i].seq_tech = (f & 7) | ((in[i].parent_type >> 6) << 3);
+	in[i].parent_type &= 0x3f;
+
 	in[i].flags = (f >> 3) & 7;
 	in[i].format = (f >> 6) & 3;
 	if (in[i].flags & SEQ_COMPLEMENTED)
@@ -4794,11 +4809,13 @@ static int io_seq_block_write(void *dbh, cached_item *ci) {
 	} else {
 	    out[5] += int2u7((int32_t)s->parent_rec, out[5]);
 	}
-	*out[6]++ = s->parent_type;
+
+	/* Top 2 bits of parent type encode high bits of seq_tech */
+	*out[6]++ = s->parent_type | ((s->seq_tech >> 3) << 6);
 	
 	/* flags & m.quality */
 	s->format = SEQ_FORMAT_CNF1;
-	*out[7]++ = (s->format << 6) | (s->flags << 3) | s->seq_tech;
+	*out[7]++ = (s->format << 6) | (s->flags << 3) | (s->seq_tech & 7);
 
 	/* Duplicated in range, but adds about 1% on test bam input */
 	*out[8]++ = s->mapping_qual;
@@ -5109,12 +5126,16 @@ static cached_item *io_contig_block_read(void *dbh, tg_rec rec) {
     for (i = 0; i < CONTIG_BLOCK_SZ; i++) {
 	cp += u72intw(cp, &i64);
 	in[i].bin = i64;
+
+	/* Nul values as these are in-memory only */
+	in[i].haplo_timestamp = 0;
+	in[i].haplo_hash = NULL;
     }
 
     /* Flags */
     for (i = 0; i < CONTIG_BLOCK_SZ; i++) {
 	if (!in[i].bin) continue;
-	cp += u72int(cp, (uint32_t *)&in[i].flags);
+	cp += u72int(cp, &in[i].flags);
 
 	/* Move elsewhere once we start storing this */
 	in[i].timestamp = 1;
@@ -5719,7 +5740,6 @@ static int io_scaffold_block_write(void *dbh, cached_item *ci) {
     GIOVec vec[2];
     char fmt[2];
     int nparts = 8;
-    tg_rec last_scaffold_rec;
 
     assert(ci->lock_mode >= G_LOCK_RW);
     assert(ci->rec > 0);
@@ -5753,7 +5773,6 @@ static int io_scaffold_block_write(void *dbh, cached_item *ci) {
 	out_start[i] = out[i] = malloc(out_size[i]+1);
     
     /* serialised scaffolds */
-    last_scaffold_rec = 0;
     for (i = 0; i < SCAFFOLD_BLOCK_SZ; i++) {
 	scaffold_t *c = b->scaffold[i];
 
diff --git a/gap5/tg_index.c b/gap5/tg_index.c
index ccb8e8f..d747d66 100644
--- a/gap5/tg_index.c
+++ b/gap5/tg_index.c
@@ -39,7 +39,7 @@
 #include "baf.h"
 #include "caf.h"
 #include "tg_index_common.h"
-#include "zfio.h"
+#include "io_lib/zfio.h"
 #include "fasta.h"
 
 #include "sam_index.h"
@@ -48,8 +48,8 @@
 
 
 void usage(void) {
-    fprintf(stderr, "Usage: g_index [options] data_file ...\n");
-    fprintf(stderr, "      -o output            Specify ouput filename (g_db)\n");
+    fprintf(stderr, "Usage: tg_index [options] data_file ...\n");
+    fprintf(stderr, "      -o output            Specify output filename (g_db)\n");
     fprintf(stderr, "\n");
     fprintf(stderr, "      -m                   Input is MAQ format\n");
     fprintf(stderr, "      -M                   Input is MAQ-long format\n");
@@ -135,8 +135,9 @@ int main(int argc, char **argv) {
     a.remove_dups    = 1;
     a.version        = DB_VERSION;
     a.link_pairs     = 1;
+    a.qual           = -3; // default quality for fasta
 
-    printf("\n\tg_index:\tShort Read Alignment Indexer, version 1.2.13"SVN_VERS"\n");
+    printf("\n\ttg_index:\tGap5 database builder, version 1.2.13"SVN_VERS"\n");
     printf("\n\tAuthor: \tJames Bonfield (jkb at sanger.ac.uk)\n");
     printf("\t        \t2007-2013, Wellcome Trust Sanger Institute\n\n");
 
@@ -402,7 +403,7 @@ int main(int argc, char **argv) {
 	/* Add to our sequence name B+Tree */
 	if (a.tmp) {
 	    // save the last queue
-	    bttmp_build_index(io, a.tmp, 1000, 10);
+	    bttmp_build_index(io, a.tmp, 1000, 128);
 	    bttmp_store_delete(a.tmp);
 	}
     }
diff --git a/gap5/tg_index.h b/gap5/tg_index.h
index 210fb16..11da189 100644
--- a/gap5/tg_index.h
+++ b/gap5/tg_index.h
@@ -17,6 +17,7 @@ typedef struct {
 } bttmp_data_t;
 
 typedef struct {
+    struct sort_node_s *node;
     bttmp_t *file;
     string_alloc_t *data_pool;
     char **data;
@@ -62,6 +63,7 @@ typedef struct {
     int version;
     int link_pairs;
     char *tmp_dir;
+    int qual; // -ve => default if no qual. +ve => forcibly override (fast[aq])
 } tg_args;
 
 #define DATA_SEQ	1
diff --git a/gap5/tg_index_common.c b/gap5/tg_index_common.c
index e7052e2..f2dbdc3 100644
--- a/gap5/tg_index_common.c
+++ b/gap5/tg_index_common.c
@@ -12,10 +12,12 @@
 #include <string.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <math.h>
 
 #include "tg_gio.h"
 #include "tg_index_common.h"
-#include "zfio.h"
+#include "io_lib/zfio.h"
+#include "break_contig.h"  /* For contig_visible_{start,end} */
 
 /* --------------------------------------------------------------------------
  * Temporary file handling for storing name + record.
@@ -30,9 +32,10 @@ static char *get_tmp_directory(void) {
     
     /* Find a place to put the tmp files    
        First *nix then Windows */
-    
-    if (NULL == (dir = getenv("TMP_DIR"))) {
-    	 dir = getenv("TEMP");
+    if (NULL == (dir = getenv("TMPDIR"))) {
+    	if (NULL == (dir = getenv("TMP_DIR"))) {
+    	    dir = getenv("TEMP");
+	}
     }
     
     /* if tmp_dir is null then we will just use the default locations */
@@ -164,13 +167,18 @@ void bttmp_file_sort(bttmp_t *tmp) {
     char new_tmp[L_tmpnam];
     char buf[100+2*L_tmpnam];
 
-    tmpnam(new_tmp);
+    if (!tmpnam(new_tmp)) {
+	verror(ERR_WARN, "bttmp_file_sort",
+	       "Failed to find a temporary file name.\n");
+	return;
+    }
     sprintf(buf, "sort < %s > %s", tmp->name, new_tmp);
     fclose(tmp->fp);
 
     /* Use unix sort for now */
     printf("buf=%s\n", buf);
-    system(buf);
+    if (-1 == system(buf))
+	perror(buf);
     printf("done\n");
 
     // unlink(tmp->name);
@@ -350,52 +358,184 @@ static void bttmp_get_next_entry(bttmp_queue_t *que) {
 }
 
 
+// a binary tree sort to speed up the merging
+typedef struct sort_node_s {
+    struct sort_node_s *up;
+    struct sort_node_s *child_left;
+    struct sort_node_s *child_right;
+    bttmp_queue_t      *data;
+} sort_node;
+
+
+sort_node *new_sort_node(sort_node *up, sort_node *left, sort_node *right) {
+    sort_node *leaf = malloc(sizeof(sort_node));
+    leaf->up = up;
+    leaf->child_left = left;
+    leaf->child_right = right;
+    leaf->data = NULL;
+    
+    return leaf;
+}
+
+
+sort_node *add_sort_leaf(sort_node *last_leaf, bttmp_queue_t *val) {
+    int tier = 0;
+    int not_found = 1;
+    
+    // new tree
+    if (last_leaf == NULL) {
+	last_leaf = new_sort_node(NULL, NULL, NULL);
+	last_leaf->data = val;
+	return last_leaf;
+    }
+    
+    // find where the new leaf should go
+    while (not_found) {
+	if (tier && last_leaf->child_left == NULL) { // create new left child
+	    sort_node *leaf = new_sort_node(last_leaf, NULL, NULL);
+	    last_leaf->child_left = leaf;
+	    tier--;
+	    last_leaf = leaf;
+
+	    if (tier == 0) not_found = 0;
+	} else if (tier && last_leaf->child_right == NULL) { // create a right child
+	    sort_node *leaf = new_sort_node(last_leaf, NULL, NULL);
+	    last_leaf->child_right = leaf;
+	    tier--;
+	    last_leaf = leaf;
+
+	    if (tier == 0) not_found = 0;
+	} else { // go up
+	    if (last_leaf->up) {
+	    	last_leaf = last_leaf->up;
+		tier++;
+	    } else { // new top
+	    	sort_node *leaf = new_sort_node(NULL, last_leaf, NULL);
+	    	last_leaf->up = leaf;
+		last_leaf = leaf;
+		tier++;
+	    }
+	}
+    }
+    
+    last_leaf->data = val;
+    
+    return last_leaf;
+}
+
+
+sort_node *sort_tree_head(sort_node *leaf) {
+    
+    while (leaf->up) {
+    	leaf = leaf->up;
+    }
+    
+    return leaf;
+}
+
+
+void populate_sort_tree(sort_node *node) {
+    if (node->child_left) {
+    	populate_sort_tree(node->child_left);
+    }
+    
+    if (node->child_right) {
+    	populate_sort_tree(node->child_right);
+    }
+    
+    if (node->child_left && node->child_right) {
+    	bttmp_queue_t *left  = node->child_left->data; 
+    	bttmp_queue_t *right = node->child_right->data;
+	
+    	node->data = left;
+	
+	if (right->size && strcmp(left->data[left->index], right->data[right->index]) > 0) {
+	   node->data = right;
+	}
+    }
+    
+    return;
+}
+
+
+sort_node *delete_sort_tree(sort_node *node) {
+    sort_node *child = NULL;
+    
+    if (node->child_left) {
+    	child = delete_sort_tree(node->child_left);
+	if (child) free(child);
+    }
+    
+    if (node->child_right) {
+    	child = delete_sort_tree(node->child_right);
+	if (child) free(child);
+    }
+    
+    return node;
+}
+
+
 static bttmp_t *bttmp_merge_sort(bttmp_sort_t *sort) {
     int i;
-    int still_looking = 1;
+    int next;
     bttmp_t *output = bttmp_file_open();
+    sort_node *head, *last_leaf = NULL;
+    bttmp_queue_t dummy;
     
     for (i = 0; i < sort->index; i++) {
     	bttmp_load_data(&sort->que[i]);
+	last_leaf = add_sort_leaf(last_leaf, &sort->que[i]);
+	sort->que[i].node = last_leaf;
     }
     
-    while (still_looking) {
-    	char *compare = NULL;
-	int file;
-	int done = 0;
+    next = pow(2, ceil(log(sort->index) / log(2)));
+    
+    if (sort->index < next) { // balance the tree
+    	dummy.size = 0;
 	
-	for (i = 0; i < sort->index; i++) {
-	    bttmp_queue_t *que = &sort->que[i];
-	    
-	    if (que->size) {
-	    	done++;
-		
-		if (compare == NULL) {
-		    compare = que->data[que->index];
-		    file = i;
-		} else {
-		    if (strcmp(compare, que->data[que->index]) > 0) {
-		    	compare = que->data[que->index];
-			file = i;
-		    }
-		}
-	    }
+    	for (i = 0; i < (next - sort->index); i++) {
+   	    last_leaf = add_sort_leaf(last_leaf, &dummy);
 	}
+    }
+    
+    head = sort_tree_head(last_leaf);
+    populate_sort_tree(head);
+    
+    // do the actual sorting
+    while (head->data->size) {
+	sort_node *node = head->data->node;
+    	sort_node *left;
+	sort_node *right;
+    	bttmp_queue_t *que = head->data;
 	
-	if (done) {
-	    fprintf(output->fp, "%s", compare);
-	    bttmp_get_next_entry(&sort->que[file]);
-	} else {
-	    still_looking = 0;
+	fprintf(output->fp, "%s", que->data[que->index]);
+	bttmp_get_next_entry(que);
+	
+	// redo tree with new value
+	while (node->up) {
+	    node = node->up;
+	    left  = node->child_left;
+	    right = node->child_right;
+	    
+	    node->data = left->data;
+	    
+	    if ((!node->data->size) || (right->data->size &&  
+	    	strcmp(node->data->data[node->data->index], right->data->data[right->data->index]) > 0)) {
+		node->data = right->data;
+	    }
+	    
 	}
     }
-    
+
+    delete_sort_tree(head);
+    free(head);
+    printf("Partial done %s\n", output->name);
     rewind(output->fp);
     
     return output;
 }
-  
-  
+
+
 static void bttmp_reset_sort(bttmp_sort_t *s) {
     int i;
     
@@ -410,6 +550,7 @@ static void bttmp_reset_sort(bttmp_sort_t *s) {
     s->index = 0;
 }
 
+
 static long bttmp_write_index(GapIO *io, FILE *fp) {
     char *line_in  = NULL;
     long line_size = 0;
@@ -503,6 +644,7 @@ int bttmp_build_index(GapIO *io, bttmp_store_t *bs, long work_size, long group_s
     bttmp_write_index(io, bs->files[0]->fp);
     bttmp_file_close(bs->files[0]);
     bttmp_sort_delete(sort);
+    return 0;
 }
     
 
@@ -682,7 +824,6 @@ static void find_pair(GapIO *io, tg_pair_t *pair, tg_rec recno, char *tname,
     if (!new) {
 	pair_loc_t *po = (pair_loc_t *)hi->data.p;
 	int st, en;
-	//bin_index_t *bo;
 	
 	/* We found one so update r_out now, before flush */
 	st = po->pos;
@@ -701,29 +842,29 @@ static void find_pair(GapIO *io, tg_pair_t *pair, tg_rec recno, char *tname,
 	    r_out->flags |= GRANGE_FLAG_COMP2;
 	
 	if (!a->fast_mode) {
-	    /* TEMP - move later*/
 	    int st = pl->pos;
 	    int en = pl->pos + (pl->orient ? - (pl->len-1) : pl->len-1);
-
-	    fprintf(pair->finish->fp,
-		    "%"PRIrec" %d %"PRIrec" %d %d %d %d %"PRIrec"\n",
-		    po->bin, po->idx, pl->rec, pl->flags,
-		    MIN(st, en), MAX(st, en),
-		    pl->mq, pl->crec);
+	    bin_index_t *bo;
+	    range_t *ro;
+
+	    // Make backwards link only if it's still due to be written out.
+	    bo = (bin_index_t *)cache_search_no_load(io, GT_Bin, po->bin);
+	    if (bo && cache_lock_mode(io, bo) == G_LOCK_RW) {
+		//bo = cache_rw(io, bo);
+		bo->flags |= BIN_RANGE_UPDATED;
+		ro = arrp(range_t, bo->rng, po->idx);
+		ro->flags &= ~GRANGE_FLAG_TYPE_MASK;
+		ro->flags |=  GRANGE_FLAG_TYPE_PAIRED;
+		ro->pair_rec = pl->rec;
+	    } else {
+		fprintf(pair->finish->fp,
+			"%"PRIrec" %d %"PRIrec" %d %d %d %d %"PRIrec"\n",
+			po->bin, po->idx, pl->rec, pl->flags,
+			MIN(st, en), MAX(st, en),
+			pl->mq, pl->crec);
+	    }
 	
 	    if (po->bin > pair->max_bin) pair->max_bin = po->bin;
-	    
-	    /* fprintf(stderr, "Get other side\n"); */
-	    /* Link other end to 'us' too */
-	    /*
-	    bo = (bin_index_t *)cache_search(io, GT_Bin, po->bin);
-	    bo = cache_rw(io, bo);
-	    bo->flags |= BIN_RANGE_UPDATED;
-	    ro = arrp(range_t, bo->rng, po->idx);
-	    ro->flags &= ~GRANGE_FLAG_TYPE_MASK;
-	    ro->flags |=  GRANGE_FLAG_TYPE_PAIRED;
-	    ro->pair_rec = pl->rec;
-	    */
 	}
 	
 	if (lib) {
@@ -1200,8 +1341,8 @@ static void merge_pairs(GapIO *io, tg_pair_t *pair) {
 	int i, nr;
 	char name[8192];
 	seq_t *s2;
-	bin_index_t *b2;
-	range_t *r;
+	bin_index_t *b2 = NULL;
+	range_t *r = NULL;
 	pair_loc_t *p;
 	int st, en;
 	tg_rec bin_rec, contig;
@@ -1270,7 +1411,7 @@ static void merge_pairs(GapIO *io, tg_pair_t *pair) {
 
 
 static void complete_pairs(GapIO *io, tg_pair_t *pair) {
-    bin_index_t *bo;
+    bin_index_t *bo = NULL;
     range_t *ro;
     tg_rec current_bin = -1;
     char line[1024];
diff --git a/gap5/tg_library.c b/gap5/tg_library.c
index e600a73..1ebe904 100644
--- a/gap5/tg_library.c
+++ b/gap5/tg_library.c
@@ -163,7 +163,7 @@ int update_library_stats(GapIO *io, tg_rec rec, int min_count,
     double m, s;
     */
     double N[3];
-    double isize[3], sd_[3], last_sd[3];
+    double isize[3], sd_[3], last_sd[3] = {0};
 
     if (!lib)
 	return -1;
@@ -382,3 +382,47 @@ int template_max_size(GapIO *io) {
 
     return io->max_template_size;
 }
+
+
+/*
+ * Changes the library name.
+ *
+ * Returns 0 on success;
+ *        -1 on failure
+ */
+int library_set_name(GapIO *io, tg_rec rec, char *name) {
+    library_t *lib = cache_search(io, GT_Library, rec);
+
+    if (io->read_only)
+	return -1;
+
+    lib = cache_rw(io, lib);
+    if (NULL == (lib = cache_item_resize(lib, sizeof(*lib) + strlen(name)+1)))
+	return -1;
+    lib->name = (char *)&lib->data;
+    strcpy(lib->name, name);
+
+    return 0;
+}
+
+
+/*
+ * Changes the library machine type.
+ *
+ * Returns 0 on success;
+ *        -1 on failure
+ */
+int library_set_machine(GapIO *io, tg_rec rec, int machine) {
+    library_t *lib = cache_search(io, GT_Library, rec);
+
+    if (io->read_only)
+	return -1;
+
+    if (machine < 0 || machine > STECH_LAST)
+	return -1;
+
+    lib = cache_rw(io, lib);
+    lib->machine = machine;
+
+    return 0;
+}
diff --git a/gap5/tg_library.h b/gap5/tg_library.h
index 7c2576c..8c842f1 100644
--- a/gap5/tg_library.h
+++ b/gap5/tg_library.h
@@ -84,4 +84,22 @@ int get_library_stats(GapIO *io, tg_rec rec,
  */
 int template_max_size(GapIO *io);
 
+
+/*
+ * Changes the library name.
+ *
+ * Returns 0 on success;
+ *        -1 on failure
+ */
+int library_set_name(GapIO *io, tg_rec rec, char *name);
+
+
+/*
+ * Changes the library machine type.
+ *
+ * Returns 0 on success;
+ *        -1 on failure
+ */
+int library_set_machine(GapIO *io, tg_rec rec, int machine);
+
 #endif /* _TG_LIBRARY_ */
diff --git a/gap5/tg_sequence.c b/gap5/tg_sequence.c
index 137ff65..aeeaa63 100644
--- a/gap5/tg_sequence.c
+++ b/gap5/tg_sequence.c
@@ -5,6 +5,7 @@
 
 #include "tg_gio.h"
 #include "consensus.h"
+#include "dna_utils.h"
 
 #ifndef ABS
 #    define ABS(x) ((x) >= 0 ? (x) : -(x))
@@ -190,6 +191,8 @@ int sequence_set_left(GapIO *io, seq_t **s, int value) {
     if (!(n = cache_rw(io, *s)))
 	return -1;
 
+    if (value < 1) value = 1;
+    if (value > ABS(n->len)) value = ABS(n->len);
     n->left = value;
     *s = n;
 
@@ -209,6 +212,8 @@ int sequence_set_right(GapIO *io, seq_t **s, int value) {
     if (!(n = cache_rw(io, *s)))
 	return -1;
 
+    if (value < 1) value = 1;
+    if (value > ABS(n->len)) value = ABS(n->len);
     n->right = value;
     *s = n;
 
@@ -226,6 +231,8 @@ int sequence_set_left_no_invalidate (GapIO *io, seq_t **s, int value) {
     if (!(n = cache_rw(io, *s)))
 	return -1;
 
+    if (value < 1) value = 1;
+    if (value > ABS(n->len)) value = ABS(n->len);
     n->left = value;
     *s = n;
 
@@ -237,6 +244,8 @@ int sequence_set_right_no_invalidate(GapIO *io, seq_t **s, int value) {
     if (!(n = cache_rw(io, *s)))
 	return -1;
 
+    if (value < 1) value = 1;
+    if (value > ABS(n->len)) value = ABS(n->len);
     n->right = value;
     *s = n;
 
@@ -491,59 +500,13 @@ int8_t *seq_conf(GapIO *io, tg_rec rec) {
     return sequence_get_conf(&s);
 }
 
-/* ------------------------------------------------------------------------ */
-/* Sequence manipulation - ripped out of Staden Package's seq_utils.c */
-
 /*
  * Reverses and complements a piece of DNA
  */
-static int complementary_base[256];
 void complement_seq_conf(char *seq, int8_t *conf, int seq_len, int nconf) {
     int i, middle, j;
     unsigned char temp;
     int8_t t[4];
-    static int init = 0;
-
-    if (!init) {
-	for (i = 0; i < 256; i++)
-	    complementary_base[i] = i;
-
-	complementary_base['a'] = 't';
-	complementary_base['c'] = 'g';
-	complementary_base['g'] = 'c';
-	complementary_base['t'] = 'a';
-	complementary_base['u'] = 'a';
-	complementary_base['A'] = 'T';
-	complementary_base['C'] = 'G';
-	complementary_base['G'] = 'C';
-	complementary_base['T'] = 'A';
-	complementary_base['U'] = 'A';
-
-	complementary_base['n'] = 'n';
-	complementary_base['-'] = '-';
-	complementary_base['b'] = 'v';
-	complementary_base['d'] = 'h';
-	complementary_base['h'] = 'd';
-	complementary_base['k'] = 'm';
-	complementary_base['m'] = 'k';
-	complementary_base['r'] = 'y';
-	complementary_base['s'] = 's';
-	complementary_base['v'] = 'b';
-	complementary_base['w'] = 'w';
-	complementary_base['y'] = 'r';
-
-	complementary_base['B'] = 'V';
-	complementary_base['D'] = 'H';
-	complementary_base['H'] = 'D';
-	complementary_base['K'] = 'M';
-	complementary_base['M'] = 'K';
-	complementary_base['R'] = 'Y';
-	complementary_base['S'] = 'S';
-	complementary_base['V'] = 'B';
-	complementary_base['W'] = 'W';
-	complementary_base['Y'] = 'R';
-	init = 1;
-    }
 
     middle = seq_len/2;
     if (nconf == 1) {
@@ -849,8 +812,11 @@ tg_rec sequence_get_pair(GapIO *io, seq_t *s) {
     /* Get range struct for this seq */
     if (!s->bin)
 	return -1;
-    if (NULL == (b = (bin_index_t *)cache_search(io, GT_Bin, s->bin)))
+    if (NULL == (b = (bin_index_t *)cache_search(io, GT_Bin, s->bin))) {
+	verror(ERR_WARN, "sequence_get_pair",
+	       "Couldn't load bin %"PRIrec, s->bin);
 	return -1;
+    }
     if (!b->rng)
 	return -1;
 
@@ -858,10 +824,22 @@ tg_rec sequence_get_pair(GapIO *io, seq_t *s) {
     r = arrp(range_t, b->rng, s->bin_index);
     assert(r->rec == s->rec);
     if (ABS(r->end - r->start) + 1 != ABS(s->len)) {
-	verror(ERR_WARN, "contig_insert_base2", 
+	verror(ERR_WARN, "sequence_get_pair", 
 	       "Range start/end are inconsistent with seq len. ");
     }
 
+    if (r->pair_rec) {
+	/* Ensure pair is mapped */
+	seq_t *sp = cache_search(io, GT_Seq, r->pair_rec);
+	if (NULL == sp) {
+	    verror(ERR_WARN, "sequence_get_pair",
+		   "Couldn't load sequence #%"PRIrec, r->pair_rec);
+	    return -1;
+	}
+	if (sp->bin <= 0 || (sp->flags & SEQ_UNMAPPED) != 0)
+	    return 0;
+    }
+
     return r->pair_rec;
 }
 
@@ -1403,9 +1381,9 @@ int sequence_insert_base(GapIO *io, seq_t **s, int pos, char base, int8_t conf,
  */
 int sequence_insert_bases(GapIO *io, seq_t **s, int pos,
 			  char base, int8_t conf, int nbases,
-			  int contig_orient) {
+			  int contig_orient, int comp) {
     seq_t *n;
-    int comp = 0, i, b, o_len;
+    int i, b, o_len;
     size_t extra_len = sequence_extra_len(*s) + nbases +
 	nbases * sequence_conf_size(*s);
     int8_t *c_old;
@@ -1426,9 +1404,10 @@ int sequence_insert_bases(GapIO *io, seq_t **s, int pos,
 	if (comp)
 	    pos++;
     } else {
-	pos = n->len < 0
-	    ? -n->len - pos
-	    : pos;
+	if (n->len < 0) {
+	    pos = -n->len - pos;
+	    comp = !comp;
+	}
     }
 
     if (pos > ABS(n->len) || pos < 0) {
@@ -1481,6 +1460,7 @@ int sequence_insert_bases(GapIO *io, seq_t **s, int pos,
 	    
     /* Set */
     b = comp ? complementary_base[(unsigned char)base] : base;
+    //printf("comp_base['*']=%c\n", complementary_base['*']);
     for (i = 0; i < nbases; i++)
 	n->seq[pos+i] = b;
     if (n->format == SEQ_FORMAT_CNF4) {
@@ -1623,16 +1603,18 @@ int sequence_delete_base(GapIO *io, seq_t **s, int pos, int contig_orient) {
  * Returns 0 on success
  *        -1 on failure
  */
-int sequence_move(GapIO *io, seq_t **s, int dist) {
+int sequence_move(GapIO *io, seq_t **s, contig_t **c, int dist) {
     bin_index_t *old_bin, *new_bin;
     range_t r, *r_out;
     int orient;
     tg_rec crec;
-    contig_t *c = NULL;
     seq_t *n;
+    int update_contig = 0; /* 1 = start, 2 = end, 4 = clipped_timestamp */
+    int orig_start, orig_end;
     int ret = -1;
 
     cache_incr(io, *s);
+    cache_incr(io, *c);
 
     /* Get old range coords and convert from relative to absolute */
     old_bin = cache_search(io, GT_Bin, (*s)->bin);
@@ -1643,17 +1625,26 @@ int sequence_move(GapIO *io, seq_t **s, int dist) {
     
     sequence_get_position(io, (*s)->rec, &crec, &r.start, &r.end, &orient);
 
-    c = cache_search(io, GT_Contig, crec);
-    if (NULL == c) goto out;
-    cache_incr(io, c);
+    orig_start = r.start;
+    orig_end   = r.end;
 
     /* Remove from bin */
-    if (0 != bin_remove_item(io, &c, GT_Seq, (*s)->rec)) goto out;
+    if (0 != bin_remove_item(io, c, GT_Seq, (*s)->rec)) goto out;
     
     /* Add it back at the new range */
     r.start += dist;
     r.end = r.start + ABS((*s)->len) - 1;
-    new_bin = bin_add_range(io, &c, &r, &r_out, NULL, 0);
+
+    /* Have we changed contig (clipped) start/end? */
+    if (MIN(r.start, orig_start) <= (*c)->start) update_contig |= 1;
+    if (MAX(r.end,   orig_end)   >= (*c)->end)   update_contig |= 2;
+    if ((*c)->clipped_timestamp == (*c)->timestamp
+	&& (MIN(r.start, orig_start) <= (*c)->clipped_start
+	    || MAX(r.end,   orig_end)   >= (*c)->clipped_end)) {
+	update_contig |= 4;
+    }
+
+    new_bin = bin_add_range(io, c, &r, &r_out, NULL, 0);
     if (NULL == new_bin) goto out;
 
     /* Update seq if parent has changed */
@@ -1676,9 +1667,28 @@ int sequence_move(GapIO *io, seq_t **s, int dist) {
 	/* Pull over any annotations too */
 	if (0 != sequence_move_annos(io, s, 0)) goto out;
     }
+
+    if (update_contig) {
+	/* Fix contig start/end/clipped_timestamp as necessary */
+	contig_t *ctg = cache_rw(io, *c);
+	if (NULL == ctg) goto out;
+	*c = ctg;
+
+	if (update_contig & 4) ctg->clipped_timestamp = 0;
+	if (update_contig & 3) {
+	    if (0 != consensus_unclipped_range(io, ctg->rec,
+					       (update_contig & 1
+						? &ctg->start : NULL),
+					       (update_contig & 2
+						? &ctg->end : NULL))) {
+		    goto out;
+		}
+	}
+    }
+
     ret = 0;
  out:
-    if (NULL != c) cache_decr(io, c);
+    cache_decr(io, *c);
     cache_decr(io, *s);
     return ret;
 }
@@ -1721,14 +1731,14 @@ int sequence_range_length(GapIO *io, seq_t **s) {
     r = arrp(range_t, bin->rng, n->bin_index);
     assert(r->rec == n->rec);
 
+    contig = cache_search(io, GT_Contig, crec);
+    if (NULL == contig) return -1;
+
     /* Check if we are about to exceed the bounds of this bin */
     if (r->start + ABS(n->len) - 1 >= bin->size) {
-	return sequence_move(io, s, 0);
+	return sequence_move(io, s, &contig, 0);
     }
 
-    contig = cache_search(io, GT_Contig, crec);
-    if (NULL == contig) return -1;
-
     /* Check if the bin used range may change */
     if (r->start == bin->start_used || r->end == bin->end_used)
 	check_used = 1;
@@ -1799,24 +1809,6 @@ int sequence_range_length(GapIO *io, seq_t **s) {
 	if (NULL == contig) return -1;
 	contig->clipped_timestamp = 0;
     }
-    	
-    /* Also force the pair's r->pair_start/end to be invalidated */
-    if (r->pair_rec) {
-	seq_t *s;
-	bin_index_t *b;
-	range_t *r2;
-		
-	s = cache_search(io, GT_Seq, r->pair_rec);
-	if (NULL == s) return -1;
-	b = cache_search(io, GT_Bin, s->bin);
-	if (NULL == b) return -1;
-	b = cache_rw(io, b);
-	if (NULL == b) return -1;
-	r2 = arrp(range_t, b->rng, s->bin_index);
-	assert(r2->rec == s->rec);
-			 
-	r2->pair_timestamp = 0;
-    }
 
     return 0;
 }
@@ -2123,3 +2115,50 @@ int sequence_get_range_pair_position(GapIO *io, rangec_t *r,
     
     return 0;
 }
+
+/*
+ * Store a pair_rec update.  As paired reads can be in contigs other than
+ * the one associated with a particular IO, these have to be applied when
+ * cache_flush is called for the io rather than make the update immediately.
+ * Here the updates are stored in a HacheTable to be applied later.
+ *
+ * Returns 0 on success
+ *        -1 on failure
+ */
+
+int sequence_store_pair_rec_update(GapIO *io, tg_rec seq_to_update,
+				   tg_rec new_val) {
+    HacheItem *hi;
+    HacheData  hd;
+    int        new = 0;
+
+    /* Create hash table if not already there */
+    if (NULL == io->pair_rec_updates) {
+	io->pair_rec_updates = HacheTableCreate(16, (HASH_OWN_KEYS
+						     | HASH_DYNAMIC_SIZE));
+
+	if (NULL == io->pair_rec_updates) {
+	    verror(ERR_WARN, "sequence_store_pair_rec_update",
+		   "Out of memory");
+	    return -1;
+	}
+    }
+
+    /* Add it into the hash table */
+    hd.i = (uint64_t) new_val;
+    hi = HacheTableAdd(io->pair_rec_updates,
+		       (char *) &seq_to_update, sizeof(seq_to_update),
+		       hd, &new);
+    if (NULL == hi) {
+	verror(ERR_WARN, "sequence_store_pair_rec_update",
+	       "Out of memory");
+	return -1;
+    }
+
+    if (!new) {
+	/* Already there, force it to the new value */
+	hi->data.i = hd.i;
+    }
+
+    return 0;
+}
diff --git a/gap5/tg_sequence.h b/gap5/tg_sequence.h
index ee8aa8a..1ac4f72 100644
--- a/gap5/tg_sequence.h
+++ b/gap5/tg_sequence.h
@@ -108,7 +108,7 @@ int sequence_insert_base(GapIO *io, seq_t **s, int pos, char base, int8_t conf,
 			 int contig_orient);
 int sequence_insert_bases(GapIO *io, seq_t **s, int pos,
 			  char base, int8_t conf, int nbases,
-			  int contig_orient);
+			  int contig_orient, int comp);
 int sequence_insert_base2(GapIO *io, seq_t **s, int pos,
 			  char base, int8_t conf, int nbases,
 			  int contig_orient);
@@ -116,7 +116,18 @@ int sequence_delete_base(GapIO *io, seq_t **s, int pos,
 			 int contig_orient);
 int sequence_delete_base2(GapIO *io, seq_t **s, int pos, int contig_orient,
 			  int check_base);
-			  
+
+/*
+ * Moves a sequence left or right by distance 'dist'.  If dist is negative
+ * the move is to the left, otherwise to the right.  It also recalculates
+ * the range end position so it can be called by sequence_range_length.
+ *
+ * Returns 0 on success
+ *        -1 on failure
+ */
+int sequence_move(GapIO *io, seq_t **s, contig_t **c, int dist);
+
+
 /* Fix range_t length values after insert or delete */
 int sequence_range_length(GapIO *io, seq_t **s);
 
@@ -204,4 +215,14 @@ rangec_t *sequence_get_rangec(GapIO *io, seq_t *s, int abs_pos);
 int sequence_get_range_pair_position(GapIO *io, rangec_t *r,
 				     tg_rec contig1, tg_rec contig2);
 
+/*
+ * Store a pair_rec update, to be applied when the contig is saved.
+ *
+ * Returns 0 on success
+ *        -1 on failure
+ */
+
+int sequence_store_pair_rec_update(GapIO *io, tg_rec seq_to_update,
+				   tg_rec new_val);
+
 #endif /* _TG_SEQUENCE_H_ */
diff --git a/gap5/tg_struct.h b/gap5/tg_struct.h
index 4f44c27..6870bbd 100644
--- a/gap5/tg_struct.h
+++ b/gap5/tg_struct.h
@@ -5,6 +5,8 @@
 #include <array.h>
 #include <inttypes.h>
 
+#include "io_lib/hash_table.h"
+
 /*
  * Record numbers. Note that on disc we assume record numbers are only
  * 32-bit as that's what the "g" library supports with GRec and GCardinal.
@@ -28,6 +30,8 @@ typedef int64_t tg_rec;
 /* ----------------------------------------------------------------------
  * Primary data types. The holes in the numbering are simply ancient history
  * from the xgap and earlier era.
+ *
+ * 6 bits, so max value = 63.
  */
 #define GT_Generic        0
 #define GT_RecArray       3
@@ -131,6 +135,9 @@ typedef struct {
 #define GRANGE_FLAG_REFPOS_REV (1<<2)
 #define GRANGE_FLAG_REFPOS_DIR (1<<2)
 
+/* These three are used in tg_iface_g.c to optimise storage size. */
+/* Do not attempt to set or query these yourself as this will cause */
+/* false warnings from Check Database, as well as being pointless to do. */
 #define GRANGE_FLAG_REFPOS_HAVE_ID   (1<<3)
 #define GRANGE_FLAG_REFPOS_HAVE_POS  (1<<4)
 #define GRANGE_FLAG_REFPOS_HAVE_SIZE (1<<5)
@@ -230,8 +237,20 @@ typedef struct {
     tg_rec anno_ele_brec;    /* Current anno_ele block */
     tg_rec anno_ele_sub_rec; /* Next anno_ele sub-record */
 
-    /* Global incrememnting timestamp */
+    /* Global incremementing timestamp */
     int timestamp;
+
+    /* An annotation holding database-wide configurations.
+     *
+     * In order to avoid bumping the on-disk database_t structure we hold the
+     * config_anno record number in the scaffold_name index as a
+     * "__g5::CONFIG" => rec lookup.  This is a good(!?) general purpose
+     * namespace for holding database-level annotations without the need to
+     * bump the version number further for each new type of field.
+     *
+     * Just whatever you do, don't create real scaffolds named __g5::*.
+     */
+    tg_rec config_anno;
 } database_t;
 
 
@@ -268,9 +287,9 @@ typedef struct {
     tg_rec parent_rec;/* template record or seq record if type == GT_Seq */
     int parent_type;  /* GT_Seq, GT_Template, GT_Ligation, etc */
     tg_rec rec;       /* recno of this seq_t */
-    unsigned int seq_tech:3;
-    unsigned int flags:3;
-    unsigned int format:2;
+    unsigned int seq_tech;
+    unsigned int flags;
+    unsigned int format;
     uint8_t mapping_qual; /* REMOVE? In GRange already. Same for parent_rec */
     int name_len;
     int template_name_len;   /* if name comes from <template><suffix>  */
@@ -301,12 +320,17 @@ typedef struct seq_block {
 } seq_block_t;
 
 
-/* Sequencing technologies for seq_t.seq_tech */
-#define STECH_UNKNOWN 0
-#define STECH_SANGER  1
-#define STECH_SOLEXA  2
-#define STECH_SOLID   3
-#define STECH_454     4
+/* Sequencing technologies for seq_t.seq_tech; 5 bits, so max=31 */
+#define STECH_UNKNOWN    0
+#define STECH_SANGER     1
+#define STECH_SOLEXA     2
+#define STECH_SOLID      3
+#define STECH_454        4
+#define STECH_HELICOS    5
+#define STECH_IONTORRENT 6
+#define STECH_PACBIO     7
+#define STECH_ONT        8
+#define STECH_LAST       8 // highest value
 
 /* Sequence flags for seq_t.flags */
 #define SEQ_COMPLEMENTED (1<<0)
@@ -333,7 +357,7 @@ typedef struct {
     signed int clipped_start, clipped_end;
     tg_rec bin;
     tg_rec scaffold;
-    tg_rec flags; /* For clipped_start/end updating and marking as deleted */
+    uint32_t flags; /* For clipped_start/end updating and marking as deleted */
     int nseqs;
     int nanno;
     int nrefpos;
@@ -342,8 +366,17 @@ typedef struct {
     int    idx;   /* Index to block */
     int    timestamp;
     Array  link;  /* Array of contig_link_t fields */
+
+    // To optimise CSIR_SORT_BY_SEQUENCE sorting
+    int haplo_timestamp;
+    HashTable *haplo_hash;
+    int haplo_start, haplo_end;
+    tg_rec haplo_rec;
+
+    // Variable length data
     char  *name;
     char   data[1];
+
 } contig_t;
 
 #define CONTIG_FLAG_CLIPPED_VALID 1 /* Indicates clipped start/end are valid */
@@ -569,7 +602,7 @@ typedef struct {
 } anno_ele_t;
 
 #define ANNO_DIR_FWD '+'
-#define ANNO_DIR_REV '+'
+#define ANNO_DIR_REV '-'
 #define ANNO_DIR_NUL '.'
 #define ANNO_DIR_UNK '?'
 
diff --git a/gap5/tg_tcl.c b/gap5/tg_tcl.c
index 9ce1566..ea1ca6d 100644
--- a/gap5/tg_tcl.c
+++ b/gap5/tg_tcl.c
@@ -21,10 +21,12 @@
 #include "misc.h"
 #include "tg_gio.h"
 #include "tg_check.h"
+#include "tg_contig.h"
 #include "gap_cli_arg.h"
 #include "tg_struct.h"
 #include "consensus.h"
 #include "gap4_compat.h"  /* io_cclength() */
+#include "tg_sequence.h"  /* sequence_move() */
 
 #if TCL_MINOR_VERSION <= 4
 extern Tcl_Command Tcl_GetCommandFromObj(Tcl_Interp *interp,
@@ -630,6 +632,7 @@ static int tcl_read_depth(tcl_contig *tc, Tcl_Interp *interp,
     Tcl_Obj *items;
     track_t *track;
 
+#if 0
     if (objc != 4) {
 	vTcl_SetResult(interp, "wrong # args: should be "
 		       "\"%s start end bpv\"\n",
@@ -650,6 +653,17 @@ static int tcl_read_depth(tcl_contig *tc, Tcl_Interp *interp,
     }
 
     track_free(track);
+#else
+    consensus_t *cons;
+    cons = malloc((c->end - c->start+1)*sizeof(*cons));
+    calculate_consensus(io, c->rec, c->start, c->end, cons);
+    
+    items = Tcl_NewListObj(0, NULL);
+    for (i = 0; i < c->end-c->start+1; i++) {
+	Tcl_ListObjAppendElement(interp, items, Tcl_NewIntObj(cons[i].depth));
+    }
+    free(cons);
+#endif
 
     Tcl_SetObjResult(interp, items);
 
@@ -673,7 +687,8 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 	"set_visible_start", "invalidate_consensus",    "set_name",
 	"dump_graph",   "add_link",	"get_links",    "get_timestamp",
 	"get_scaffold", "add_to_scaffold", "remove_from_scaffold",
-	(char *)NULL,
+	"insert_column", "find_refpos_marker", "set_refpos_marker",
+	"delete_refpos_marker", "copy_refpos", (char *)NULL,
     };
 
     enum options {
@@ -687,7 +702,8 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 	GET_VISIBLE_START, GET_VISIBLE_END, GET_VISIBLE_LENGTH,
 	SET_VISIBLE_START, INVALIDATE_CONSENSUS,        SET_NAME,
 	DUMP_GRAPH,	ADD_LINK,	GET_LINKS,      GET_TIMESTAMP,
-	GET_SCAFFOLD,   ADD_TO_SCAFFOLD,REMOVE_FROM_SCAFFOLD,
+	GET_SCAFFOLD,   ADD_TO_SCAFFOLD,REMOVE_FROM_SCAFFOLD, INSERT_COLUMN,
+	FIND_REFPOS, SET_REFPOS, DELETE_REFPOS, COPY_REFPOS,
     };
 
     if (objc < 2) {
@@ -944,6 +960,74 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 	break;
     }
 
+    case INSERT_COLUMN: {
+	int pos;
+	Tcl_Obj **pileup;
+	int      pileup_len;
+	int      i;
+	int      res;
+	col_inserted_base *bases;
+
+	if (objc != 4) {
+	    vTcl_SetResult(interp, "wrong # args: should be "
+			   "\"%s insert_column position pileup\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	    return TCL_ERROR;
+	}
+	Tcl_GetIntFromObj(interp, objv[2], &pos);
+	if (Tcl_ListObjGetElements(interp, objv[3],
+				   &pileup_len, &pileup) != TCL_OK
+	    || pileup_len < 0) {
+	    vTcl_SetResult(interp, "insert_column: pileup should be a list\n");
+	    return TCL_ERROR;
+	}
+
+	bases = calloc(pileup_len > 0 ? pileup_len : 1,
+		       sizeof(col_inserted_base));
+	if (NULL == bases) {
+	    vTcl_SetResult(interp, "Out of memory");
+	    return TCL_ERROR;
+	}
+
+	for (i = 0; i < pileup_len; i++) {
+	    Tcl_Obj **row;
+	    int row_len;
+	    Tcl_WideInt srec;
+	    int spos;
+	    char *base;
+	    int conf;
+	    
+	    if (Tcl_ListObjGetElements(interp, pileup[i],
+				       &row_len, &row) != TCL_OK
+		|| row_len < 4
+		|| TCL_OK != Tcl_GetWideIntFromObj(interp, row[0], &srec)
+		|| TCL_OK != Tcl_GetIntFromObj(interp, row[1], &spos)
+		|| NULL == (base = Tcl_GetStringFromObj(row[2], NULL))
+		|| '\0' == *base
+		|| TCL_OK != Tcl_GetIntFromObj(interp, row[3], &conf)) {
+		vTcl_SetResult(interp, "insert_column: pileup row"
+			       " should be { srec pos base conf }\n");
+		free(bases);
+		return TCL_ERROR;
+	    }
+
+	    bases[i].rec  = (tg_rec) srec;
+	    bases[i].pos  = spos;
+	    bases[i].base = base[0];
+	    bases[i].conf = conf;
+	}
+
+	res = contig_insert_column(tc->io, &tc->contig, pos,
+				   pileup_len, bases);
+	free(bases);
+	if (res) {
+	    vTcl_SetResult(interp, "insert_column failed");
+	    return TCL_ERROR;
+	}
+
+	break;
+    }
+
     case DELETE_BASE: {
 	int pos;
 	if (objc != 3) {
@@ -1007,27 +1091,13 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 
 	/* Break link with pair */
 	if (r->pair_rec) {
-	    seq_t *sp;
-	    bin_index_t *bp;
-	    range_t *rp;
-	    sp = cache_search(tc->io, GT_Seq, r->pair_rec);
-	    if (NULL == sp) return TCL_ERROR;
-	    cache_incr(tc->io, sp);
-	    bp = cache_search(tc->io, GT_Bin, sp->bin);
-	    if (NULL != bp) bp = cache_rw(tc->io, bp);
-	    if (NULL == bp) {
-		cache_decr(tc->io, sp);
+	    if (0 != sequence_store_pair_rec_update(tc->io, r->pair_rec, 0)) {
+		vTcl_SetResult(interp, "Failed to store paired record update");
 		return TCL_ERROR;
 	    }
-	    rp = arrp(range_t, bp->rng, sp->bin_index);
-	    assert(rp->rec == sp->rec);
-	    assert(rp->pair_rec == r->rec);
-	    rp->pair_rec = 0;
-	    rp->pair_timestamp = 0;
+
 	    r->pair_rec = 0;
 	    b->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
-	    bp->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
-	    cache_decr(tc->io, sp);
 	}
 
 	bin_remove_item(tc->io, &tc->contig, GT_Seq, rec);
@@ -1092,9 +1162,11 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 	}
 
 	bin = bin_add_range(tc->io, &tc->contig, &r, &r_out, NULL, 0);
+	// fprintf(stderr, "seq %"PRIrec" to bin %"PRIrec"\n",
+	//	s->rec, bin->rec);
 	if ((s->flags & SEQ_UNMAPPED) || s->bin != bin->rec) {
 	    int old_comp = ((s->flags & SEQ_UNMAPPED)
-			    ? bin_get_orient(tc->io, s->bin) : 0);
+			    ? 0 : bin_get_orient(tc->io, s->bin));
 	    int new_comp = bin_get_orient(tc->io, bin->rec);
 
 	    //printf("New seq bin (%d)%d->(%d)%d\n",
@@ -1118,22 +1190,10 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 
 	/* Fix pair's pair_rec */
 	if (r.pair_rec) {
-	    seq_t *sp;
-	    bin_index_t *bp;
-	    range_t *rp;
-	    sp = cache_search(tc->io, GT_Seq, r.pair_rec);
-	    if (NULL == sp) return TCL_ERROR;
-	    cache_incr(tc->io, sp);
-	    bp = cache_search(tc->io, GT_Bin, sp->bin);
-	    if (NULL != bp) bp = cache_rw(tc->io, bp);
-	    if (NULL == bp) { cache_decr(tc->io, sp); return TCL_ERROR; }
-	    rp = arrp(range_t, bp->rng, sp->bin_index);
-	    assert(rp->rec == sp->rec);
-	    assert(rp->pair_rec == 0);
-	    rp->pair_rec = rec;
-	    rp->pair_timestamp = 0;
-	    bp->flags |= BIN_RANGE_UPDATED | BIN_BIN_UPDATED;
-	    cache_decr(tc->io, sp);
+	    if (0 != sequence_store_pair_rec_update(tc->io, r.pair_rec, rec)) {
+		vTcl_SetResult(interp, "Failed to store paired record update");
+		return TCL_ERROR;
+	    }
 	}
 
 	break;
@@ -1143,9 +1203,7 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 	/* A combination of remove and add */
 	Tcl_WideInt rec;
 	seq_t *s;
-	bin_index_t *bin;
-	range_t r, *r_out;
-	int dist, dir;
+	int dist;
 
 	if (objc < 4) {
 	    vTcl_SetResult(interp, "wrong # args: should be \"%s "
@@ -1159,41 +1217,16 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 
 	/* Get old range coords and convert from relative to absolute */
 	s = cache_search(tc->io, GT_Seq, rec);
-	cache_incr(tc->io, s);
-
-	bin = cache_search(tc->io, GT_Bin, s->bin);
-	r = arr(range_t, bin->rng, s->bin_index);
-	assert(r.rec == s->rec);
-	assert(ABS(r.end - r.start) + 1 == ABS(s->len));
-	sequence_get_position(tc->io, s->rec, NULL, &r.start, &r.end, &dir);
-
-	bin_remove_item(tc->io, &tc->contig, GT_Seq, rec);
-
-	/* Add it back at the new range */
-	r.start += dist;
-	r.end += dist;
-	bin = bin_add_range(tc->io, &tc->contig, &r, &r_out, NULL, 0);
-
-	/* Update seq if parent has changed */
-	if (s->bin != bin->rec) {
-	    int old_comp = bin_get_orient(tc->io, s->bin);
-	    int new_comp = bin_get_orient(tc->io, bin->rec);
-
-	    s = cache_rw(tc->io, s);
-	    s->bin = bin->rec;
-	    s->bin_index = r_out - ArrayBase(range_t, bin->rng);
-
-	    /* Check if the new bin has a different complemented status too */
-	    if (new_comp != old_comp) {
-		s->len *= -1;
-		s->flags ^= SEQ_COMPLEMENTED;
-		//tmp = s->left;
-		//s->left  = ABS(s->len) - (s->right-1);
-		//s->right = ABS(s->len) - (tmp-1);
-	    }
+	if (NULL == s) {
+	    vTcl_SetResult(interp,
+			   "move_seq: couldn't get sequence #%"PRIrec"\n",
+			   rec);
+	    return TCL_ERROR;
+	}
+	if (0 != sequence_move(tc->io, &s, &tc->contig, dist)) {
+	    vTcl_SetResult(interp, "move_seq failed\n");
+	    return TCL_ERROR;
 	}
-
-	cache_decr(tc->io, s);
 
 	break;
     }
@@ -1478,6 +1511,153 @@ static int contig_cmd(ClientData clientData, Tcl_Interp *interp,
 
 	break;
     }
+
+    case FIND_REFPOS: {
+	int      pos;
+	tg_rec   bin;
+	int      bin_idx;
+	rangec_t rc;
+
+	if (objc != 3) {
+	    vTcl_SetResult(interp, "wrong # args: should be \"%s "
+			   "find_refpos_marker pos\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	    return TCL_ERROR;
+	}
+
+	if (TCL_OK != Tcl_GetIntFromObj(interp, objv[2], &pos)) {
+	    return TCL_ERROR;
+	}
+
+	if (0 == find_refpos_marker(tc->io, tc->contig->rec, pos,
+				    &bin, &bin_idx, &rc)) {
+	    Tcl_Obj *ov[5];
+	    char type = ((rc.flags & GRANGE_FLAG_REFPOS_INDEL)
+			 == GRANGE_FLAG_REFPOS_DEL ? 'D' : 'I');
+	    char dir = ((rc.flags & GRANGE_FLAG_REFPOS_DIR)
+			== GRANGE_FLAG_REFPOS_FWD ? 'F' : 'R');
+	    Tcl_Obj *items;
+	    ov[0] = Tcl_NewStringObj(&type, 1);
+	    ov[1] = Tcl_NewStringObj(&dir,  1);
+	    ov[2] = Tcl_NewWideIntObj((rc.flags & GRANGE_FLAG_REFPOS_HAVE_ID)
+					? rc.rec : -1);
+	    ov[3] = Tcl_NewIntObj(rc.mqual);
+	    ov[4] = Tcl_NewIntObj(rc.pair_rec);
+	    if (NULL == ov[0] || NULL == ov[1] || NULL == ov[2]
+		|| NULL == ov[3] || NULL == ov[4]) return TCL_ERROR;
+
+	    items = Tcl_NewListObj(sizeof(ov)/sizeof(ov[0]), ov);
+	    if (NULL == items) return TCL_ERROR;
+	    Tcl_SetObjResult(interp, items);
+	} else {
+	    Tcl_FreeResult(interp);
+	}
+	break;
+    }
+
+    case SET_REFPOS: {
+	int pos, type, dir, id, rpos, len = 0;
+	char *stype, *sdir;
+	if (objc < 7 || objc > 8) {
+	    vTcl_SetResult(interp, "wrong # args: should be "
+			   "\"%s pos type dir ref_id ref_pos ?len?\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	}
+	if (TCL_OK != Tcl_GetIntFromObj(interp, objv[2], &pos)
+	    || TCL_OK != Tcl_GetIntFromObj(interp, objv[5], &id)
+	    || TCL_OK != Tcl_GetIntFromObj(interp, objv[6], &rpos)) {
+	    return TCL_ERROR;
+	}
+	stype = Tcl_GetString(objv[3]);
+	if (NULL == stype) return TCL_ERROR;
+	sdir  = Tcl_GetString(objv[4]);
+	if (NULL == sdir) return TCL_ERROR;
+	if (objc > 7 && TCL_OK != Tcl_GetIntFromObj(interp, objv[7], &len)) {
+	    return TCL_ERROR;
+	}
+
+	switch (*stype) {
+	case 'D':
+	    type = GRANGE_FLAG_REFPOS_DEL;
+	    break;
+	case 'I':
+	    type = GRANGE_FLAG_REFPOS_INS;
+	    break;
+	default:
+	    vTcl_SetResult(interp, "type should be 'D' or 'I'\n");
+	    return TCL_ERROR;
+	}
+
+	switch (*sdir) {
+	case 'F':
+	    dir = GRANGE_FLAG_REFPOS_FWD;
+	    break;
+	case 'R':
+	    dir = GRANGE_FLAG_REFPOS_REV;
+	    break;
+	default:
+	    vTcl_SetResult(interp, "dir should be 'F' or 'R'\n");
+	    return TCL_ERROR;
+	}
+
+	if (GRANGE_FLAG_REFPOS_DEL == type && objc < 8) {
+	    vTcl_SetResult(interp, "len is required for DEL markers\n");
+	    return TCL_ERROR;
+	}
+
+	if (0 != set_refpos_marker(tc->io, &tc->contig, pos, type, dir,
+				   id, rpos, len)) {
+	    vTcl_SetResult(interp, "set_refpos_marker failed");
+	    return TCL_ERROR;
+	}
+
+	break;
+    }
+
+    case DELETE_REFPOS: {
+	int pos;
+
+	if (objc != 3) {
+	    vTcl_SetResult(interp, "wrong # args: should be \"%s "
+			   "delete_refpos_marker pos\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	    return TCL_ERROR;
+	}
+
+	if (TCL_OK != Tcl_GetIntFromObj(interp, objv[2], &pos)) {
+	    return TCL_ERROR;
+	}
+
+	if (0 != delete_refpos_marker(tc->io, tc->contig->rec, pos)) {
+	    vTcl_SetResult(interp, "delete_refpos_marker failed");
+	    return TCL_ERROR;
+	}
+
+	break;
+    }
+
+    case COPY_REFPOS: {
+        tg_rec crec2;
+
+	if (objc != 3) {
+	    vTcl_SetResult(interp, "wrong # args: should be \"%s "
+			   "copy_refpos from_contig\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	    return TCL_ERROR;
+	}
+
+	if (TCL_OK != Tcl_GetWideIntFromObj(interp, objv[2], &crec2)) {
+	    return TCL_ERROR;
+	}
+
+	if (0 != copy_refpos(tc->io, tc->contig->rec, crec2)) {
+	    vTcl_SetResult(interp, "copy_refpos failed");
+	    return TCL_ERROR;
+	}
+
+	break;
+    }
+
     }
 
     return TCL_OK;
@@ -1809,7 +1989,8 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 	"get_clipped_position",         "get_orient",   "get_mapping_qual",
 	"get_base",     "insert_base",  "delete_base",  "replace_base",
 	"get_clips",    "set_clips",    "move_annos",   "get_template_orient",
-	"set_clips_no_invalidate",	"get_pair_pos",
+	"get_template_status",          "set_clips_no_invalidate",
+	"get_pair_pos", "get_library",  "get_mapped",
 	(char *)NULL,
     };
 
@@ -1821,7 +2002,8 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 	GET_CLIPPED_POSITION,           GET_ORIENT,     GET_MAPPING_QUAL,
 	GET_BASE,       INSERT_BASE,    DELETE_BASE,    REPLACE_BASE,
 	GET_CLIPS,      SET_CLIPS,      MOVE_ANNOS,     GET_TEMPLATE_ORIENT,
-	SET_CLIPS_NO_INVALIDATE,	GET_PAIR_POS,
+	GET_TEMPLATE_STATUS,            SET_CLIPS_NO_INVALIDATE,
+	GET_PAIR_POS,   GET_LIBRARY,    GET_MAPPED
     };
 
     if (objc < 2) {
@@ -1866,6 +2048,15 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 			 ts->seq->name, ts->seq->name_len);
 	break;
 
+    case GET_LIBRARY: {
+	range_t *r = sequence_get_range(ts->io, ts->seq);
+	if (r)
+	    Tcl_SetIntObj(Tcl_GetObjResult(interp), r->library_rec);
+	else
+	    return TCL_ERROR;
+	break;
+    }
+
     case GET_SEQ:
 	Tcl_SetStringObj(Tcl_GetObjResult(interp),
 			 ts->seq->seq, ABS(ts->seq->len));
@@ -1981,7 +2172,7 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 	tg_rec rec = ts->seq->rec, cnum;
 	int pos, dir;
 	range_t r;
-	seq_t *s;
+	seq_t *s = NULL;
 	sequence_get_position2(ts->io, rec, &cnum, &pos, NULL, &dir, NULL,
 			       &r, &s);
 	if (!s) {
@@ -2009,7 +2200,7 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 	tg_rec rec = ts->seq->rec, cnum;
 	int pos, dir;
 	range_t r;
-	seq_t *s;
+	seq_t *s = NULL;
 	int tdir;
 	int lib_type = LIB_T_INWARD;
 
@@ -2042,6 +2233,12 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 	break;
     }
 
+    case GET_TEMPLATE_STATUS:
+	Tcl_SetIntObj(Tcl_GetObjResult(interp),
+		      sequence_get_template_info(ts->io, ts->seq,
+						 NULL, NULL));
+	break;
+
     case GET_MAPPING_QUAL:
 	Tcl_SetIntObj(Tcl_GetObjResult(interp), ts->seq->mapping_qual);
 	break;
@@ -2199,6 +2396,12 @@ static int sequence_cmd(ClientData clientData, Tcl_Interp *interp,
 
 	break;
     }
+
+    case GET_MAPPED: {
+	Tcl_SetBooleanObj(Tcl_GetObjResult(interp),
+			  (ts->seq->flags & SEQ_UNMAPPED) == 0);
+	break;
+    }
     }
 
     return TCL_OK;
@@ -2656,6 +2859,9 @@ static int tcl_anno_ele_read(GapIO *io, Tcl_Interp *interp,
     Tcl_GetWideIntFromObj(interp, objv[1], &elenum);
     e = (anno_ele_t *)cache_search(io, GT_AnnoEle, elenum);
 
+    if (NULL == e)
+	return TCL_ERROR;
+
     if (NULL == (te = (tcl_anno_ele *)ckalloc(sizeof(*te))))
 	return TCL_ERROR;
     te->io = io;
@@ -2716,15 +2922,16 @@ static int library_cmd(ClientData clientData, Tcl_Interp *interp,
 	"delete",         "io",           "get_rec",
 	"get_orient",     "get_machine",  "get_dist",
 	"get_insert_size","get_insert_sd","get_count",
-	"get_name",	  "update_stats",
-	(char *)NULL,
+	"get_name",	  "update_stats", "set_name",
+	"set_machine_type", (char *)NULL,
     };
 
     enum options {
 	DELETE,          IO,             GET_REC,
 	GET_ORIENT,      GET_MACHINE,    GET_DIST,
 	GET_INSERT_SIZE, GET_INSERT_SD,  GET_COUNT,
-	GET_NAME,	 UPDATE_STATS
+	GET_NAME,	 UPDATE_STATS,   SET_NAME,
+	SET_MACHINE_TYPE
     };
 
     if (objc < 2) {
@@ -2821,6 +3028,39 @@ static int library_cmd(ClientData clientData, Tcl_Interp *interp,
 	}
 	break;
 
+    case SET_NAME: {
+	char *name;
+
+	if (objc != 3) {
+	    vTcl_SetResult(interp, "wrong # args: should be "
+			   "\"%s set_name new_name\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	    return TCL_ERROR;
+	}
+	name = Tcl_GetStringFromObj(objv[2], NULL);
+
+	Tcl_SetIntObj(Tcl_GetObjResult(interp),
+		      library_set_name(tl->io, tl->library->rec, name));
+	break;
+    }
+
+
+    case SET_MACHINE_TYPE: {
+	int type;
+
+	if (objc != 3) {
+	    vTcl_SetResult(interp, "wrong # args: should be "
+			   "\"%s set_machine_type machine_type_integer\"\n",
+			   Tcl_GetStringFromObj(objv[0], NULL));
+	    return TCL_ERROR;
+	}
+	Tcl_GetIntFromObj(interp, objv[2], &type);
+
+	library_set_machine(tl->io, tl->library->rec, type);
+	break;
+    }
+	
+
     case UPDATE_STATS:
 	update_library_stats(tl->io, tl->library->rec, 100, NULL, NULL, NULL);
 	break;
@@ -2869,6 +3109,8 @@ static int tcl_library_read(GapIO *io, Tcl_Interp *interp,
 
     Tcl_GetWideIntFromObj(interp, objv[1], &rec);
     l = (library_t *)cache_search(io, GT_Library, rec);
+    if (!l)
+	return TCL_ERROR;
 
     if (NULL == (tl = (tcl_library *)ckalloc(sizeof(*tl))))
 	return TCL_ERROR;
@@ -2946,13 +3188,13 @@ static int database_cmd(ClientData clientData, Tcl_Interp *interp,
 
     static char *options[] = {
 	"get_num_contigs",  "flush", "get_num_libraries",
-	"get_library_rec",
+	"get_library_rec",  "get_config_anno", "set_config_anno",
 	(char *)NULL,
     };
 
     enum options {
-	GET_NUM_CONTIGS,     FLUSH,   GET_NUM_LIBRARIES,
-	GET_LIBRARY_REC
+	GET_NUM_CONTIGS,     FLUSH,            GET_NUM_LIBRARIES,
+	GET_LIBRARY_REC,     GET_CONFIG_ANNO,  SET_CONFIG_ANNO
     };
 
     if (objc < 2) {
@@ -2987,6 +3229,43 @@ static int database_cmd(ClientData clientData, Tcl_Interp *interp,
 	break;
     }
 
+    case GET_CONFIG_ANNO: {
+	if (!io->db->config_anno)
+	    io->db->config_anno = scaffold_index_query(io, "__g5::CONFIG");
+	Tcl_SetWideIntObj(Tcl_GetObjResult(interp),
+			  io->db->config_anno > 0 ? io->db->config_anno : 0);
+	break;
+    }
+
+    case SET_CONFIG_ANNO: {
+	Tcl_WideInt rec;
+	tg_rec scaf_rec, irec;
+	GapIO *iob = gio_base(io);
+
+	if (objc != 3) {
+	    Tcl_WrongNumArgs(interp, 1, objv, "set_config_anno anno_rec");
+	    return TCL_ERROR;
+	}
+	
+	Tcl_GetWideIntFromObj(interp, objv[2], &rec);
+	io->db = cache_rw(io, io->db);
+	io->db->config_anno = rec;
+
+	/* Add 'rec' to the scaffold index under __g5::CONFIG fake name */
+	scaf_rec = iob->iface->scaffold.index_query(iob->dbh, "__g5::CONFIG", 0);
+	if (scaf_rec > 0) {
+	    irec = iob->iface->scaffold.index_del(iob->dbh, "__g5::CONFIG",
+						  scaf_rec);
+	    if (irec != -1 && irec != io->db->scaffold_name_index)
+		io->db->scaffold_name_index = irec;
+	}
+	irec = iob->iface->scaffold.index_add(iob->dbh, "__g5::CONFIG", rec);
+	if (irec != -1 && irec != io->db->scaffold_name_index)
+	    io->db->scaffold_name_index = irec;
+
+	break;
+    }
+
     case FLUSH:
 	cache_flush(io);
 	break;
diff --git a/gap5/tg_utils.c b/gap5/tg_utils.c
index 8d27521..2ca9d51 100644
--- a/gap5/tg_utils.c
+++ b/gap5/tg_utils.c
@@ -50,16 +50,28 @@ int u72int(unsigned char *u7, uint32_t *out) {
 
 /*
  * Converts an signed value into a 7-bit encoded format.
- * We store the bottom 7 bits of value with either 0 or 1 for the top-bit
+ *
+ * First it is made unsigned by taking the absolute value, shifting left
+ * by 1 bit and setting bit 0 to 0 if the original value was positive and
+ * 1 if it was negative.  Note that INT32_MIN is a special case.  It gets
+ * converted to 1 (effectively -0).
+ *
+ * We then store the bottom 7 bits of value with either 0 or 1 for the top-bit
  * depending on whether any bits are left. We keep repeating this until
  * all significant bits of value have been used.
  *
- * Ie 15551 = hex 3cbf = 0011 1100 1011 1111 becomes:
+ *  Ie     15551 = hex 3cbf = 0011 1100  1011 1111 becomes:
+ *  unsigned representation:  0111 1001  0111 1110   (0x797f)
+ *  in 7-bit chunks:  000 0001  111 0010  111 1110
+ *  output:          0000 0001 1111 0010 1111 1110   (0x01f2fe)
  *
- *     111 1001   011 1111 (0x3cbf input)
- *    0111 1001  1011 1111 (0x79bf output)
+ *   -15551 = hex ffffc341
+ *                   = 1111 1111   1111 1111   1100 0011   0100 0001 becomes:
+ *  unsigned representation:                   0111 1001   0111 1111
+ *  in 7-bit chunks:                    000 0001  111 0010  111 1111
+ *  output:                            0000 0001 1111 0010 1111 1111 (0x01f2ff)
  *
- * Takes an unsigned 32-bit integer and stores in out.
+ * Takes a signed 32-bit integer and stores in out.
  * Returns the number of bytes written to 'out'
  */
 int int2s7(int32_t in, unsigned char *out) {
@@ -91,7 +103,8 @@ int s72int(unsigned char *u7, int32_t *out) {
 	ret |= (*u7 & 0x7f) << (b += 7);
     }
 
-    *out = (ret & 1) ? -(ret >> 1) : (ret >> 1);
+    /* Special-case INT32_MIN, which gets coded as 1 by int2s7 */
+    *out = (ret & 1) ? (1 == ret ? INT32_MIN : -(ret >> 1)) : (ret >> 1);
     return c+1;
 }
 
@@ -135,7 +148,7 @@ int u72intw(unsigned char *u7, uint64_t *out) {
     ret = *u7 & 0x7f;
     while (*u7++ & 0x80) {
 	c++;
-	ret |= (*u7 & 0x7f) << (b += 7);
+	ret |= ((uint64_t)(*u7 & 0x7f)) << (b += 7);
     }
 
     *out = ret;
@@ -144,16 +157,10 @@ int u72intw(unsigned char *u7, uint64_t *out) {
 
 /*
  * Converts an signed value into a 7-bit encoded format.
- * We store the bottom 7 bits of value with either 0 or 1 for the top-bit
- * depending on whether any bits are left. We keep repeating this until
- * all significant bits of value have been used.
  *
- * Ie 15551 = hex 3cbf = 0011 1100 1011 1111 becomes:
+ * See int2s7() for details on how this works.
  *
- *     111 1001   011 1111 (0x3cbf input)
- *    0111 1001  1011 1111 (0x79bf output)
- *
- * Takes an unsigned 32-bit integer and stores in out.
+ * Takes a signed 64-bit integer and stores in out.
  * Returns the number of bytes written to 'out'
  */
 int intw2s7(int64_t in, unsigned char *out) {
@@ -171,7 +178,7 @@ int intw2s7(int64_t in, unsigned char *out) {
 
 /*
  * Takes a 7-bit encoded value in 'u7' and stores in a
- * 32-bit signed int pointed to by 'out'.
+ * 64-bit signed int pointed to by 'out'.
  *
  * Returns the number of bytes read from u7.
  */
@@ -185,7 +192,8 @@ int s72intw(unsigned char *u7, int64_t *out) {
 	ret |= ((uint64_t)(*u7 & 0x7f)) << (b += 7);
     }
 
-    *out = (ret & 1) ? -(ret >> 1) : (ret >> 1);
+    /* Special-case INT64_MIN, which gets coded as 1 by intw2s7 */
+    *out = (ret & 1) ? (1 == ret ? INT64_MIN : -(ret >> 1)) : (ret >> 1);
     return c+1;
 }
 
diff --git a/gap5/tk-io-reg.c b/gap5/tk-io-reg.c
index e5d9102..fb81168 100644
--- a/gap5/tk-io-reg.c
+++ b/gap5/tk-io-reg.c
@@ -1012,7 +1012,8 @@ static void tk_contig_register_cmd(GapIO *io, tg_rec contig, void *fdata,
     sprintf(buf, "%d", crt->id);
     if (Tcl_VarEval(crt->interp, crt->command, " ", type, " ", buf, " ",
 		    Tcl_DStringValue(&ds), NULL) != TCL_OK) {
-	fprintf(stderr, "registration_callback: %s", Tcl_GetStringResult(crt->interp));
+	fprintf(stderr, "registration_callback: %s\n", Tcl_GetStringResult(crt->interp));
+	fprintf(stderr, "%s %s %s %s\n", crt->command, type, buf, Tcl_DStringValue(&ds));
 	verror(ERR_WARN, "registration_callback", "%s",
 	       Tcl_GetStringResult(crt->interp));
     }
diff --git a/gap5/tkEditor.c b/gap5/tkEditor.c
index 71a900f..5950b1f 100644
--- a/gap5/tkEditor.c
+++ b/gap5/tkEditor.c
@@ -119,6 +119,36 @@ static Tk_ConfigSpec configSpecs[] = {
 	 "-qualcolour9","selQualColour9",	"Background",	"#b9b9ff",
 	 offset(qual_bg2[9]),		0, NULL},
     {TK_CONFIG_COLOR,
+	 "-qualcolour0","selQualColour0",	"Background",	"#40c0ff",
+	 offset(qual_haplo[0]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour1","selQualColour1",	"Background",	"#ff40a0",
+	 offset(qual_haplo[1]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour2","selQualColour2",	"Background",	"#80ff30",
+	 offset(qual_haplo[2]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour3","selQualColour3",	"Background",	"#ff8030",
+	 offset(qual_haplo[3]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour4","selQualColour4",	"Background",	"#f000ff",
+	 offset(qual_haplo[4]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour5","selQualColour5",	"Background",	"#00c000",
+	 offset(qual_haplo[5]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour6","selQualColour6",	"Background",	"#00f0a0",
+	 offset(qual_haplo[6]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour7","selQualColour7",	"Background",	"#ff80ff",
+	 offset(qual_haplo[7]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour8","selQualColour8",	"Background",	"#ff3030",
+	 offset(qual_haplo[8]),		0, NULL},
+    {TK_CONFIG_COLOR,
+	 "-qualcolour9","selQualColour9",	"Background",	"#ff8070",
+	 offset(qual_haplo[9]),		0, NULL},
+    {TK_CONFIG_COLOR,
 	 "-qual_fg","qualForeground",	"Foreground","#ff5050",
 	 offset(qual_below),		0, NULL},
     {TK_CONFIG_COLOR,
@@ -241,6 +271,9 @@ static Tk_ConfigSpec configSpecs[] = {
     {TK_CONFIG_STRING,
          "-output_list", "outputList", "OutputList",
          "readings", offset(output_list), TK_CONFIG_NULL_OK, NULL},
+    {TK_CONFIG_STRING,
+         "-haplotype_list", "haplotypeList", "HaplotypeList",
+         NULL, offset(haplotype_list), TK_CONFIG_NULL_OK, NULL},
     {TK_CONFIG_END,
 	 (char *)NULL,	(char *)NULL,	(char *)NULL,	(char *) NULL,
          0,	0,	NULL},
@@ -402,6 +435,7 @@ static int EditorCmd(ClientData clientData, Tcl_Interp *interp,
     for (i = 0; i < 10; i++) {
 	ed->qual_bg[i] = NULL;
 	ed->qual_bg2[i] = NULL;
+	ed->qual_haplo[i] = NULL;
     }
     for (i = 0; i < 4; i++)
 	ed->edit_bg[i] = NULL;
@@ -419,6 +453,7 @@ static int EditorCmd(ClientData clientData, Tcl_Interp *interp,
     ed->yScrollCmd = NULL;
     ed->highlight_cmd = NULL;
     ed->output_list = NULL;
+    ed->haplotype_list = NULL;
     ed->max_height = 0;
     ed->xx = NULL;
     /*
diff --git a/gap5/tkEditor.h b/gap5/tkEditor.h
index 40dfca9..31aacb7 100644
--- a/gap5/tkEditor.h
+++ b/gap5/tkEditor.h
@@ -13,8 +13,9 @@ struct _edview;
 typedef struct {
 #   include "tkSheet_struct.h"
 
-    XColor *qual_bg[10];  /* unhighlighted reads */
-    XColor *qual_bg2[10]; /* highlighted reads => different tint */
+    XColor *qual_bg[10];    /* unhighlighted reads */
+    XColor *qual_bg2[10];   /* highlighted reads => different tint */
+    XColor *qual_haplo[10]; /* haplotype colours */
     XColor *qual_below;
     XColor *diff1_bg;
     XColor *diff2_bg;
@@ -28,6 +29,7 @@ typedef struct {
     char *yScrollCmd;
     char *highlight_cmd;
     char *output_list;
+    char *haplotype_list;
     int max_height;
     
     /* And our data to edit */
diff --git a/gap5/tman_interface.c b/gap5/tman_interface.c
index e126269..f194103 100644
--- a/gap5/tman_interface.c
+++ b/gap5/tman_interface.c
@@ -1045,15 +1045,15 @@ int auto_diff(edview *xx, int seq, int contig_pos) {
  */
 void edScrollTraces(edview *xx, char *path, char *command) {
     DisplayContext *dc;
-    int i, orig;
+    int i;
     DNATrace *t;
     Read *r;
     tman_dc *ed;
 #if 0
     int2 *opos;
     int last = 0;
+    int comp, orig;
 #endif
-    int comp;
     int scroll_dir;
     double gpos;
     int pos;
@@ -1064,7 +1064,6 @@ void edScrollTraces(edview *xx, char *path, char *command) {
     int count;
     tg_rec seq;
     int scroll_mode = TK_SCROLL_UNITS;
-    int seq_len = 1000; /* FIXME */
 
     /* Find trace number */
     dc = trace_path_to_dc(path);
@@ -1200,17 +1199,16 @@ void edScrollTraces(edview *xx, char *path, char *command) {
 
 	pos = 0;
     } else {
-	seq_t *s;
 	seq = ed->seq;
 	pos = ed->pos;
-	s = (seq_t *)cache_search(xx->io, GT_Seq, seq);
+#if 0
 	comp = sequence_get_orient(xx->io, seq);
-	seq_len = ABS(s->len);
+#endif
     }
 
+#if 0
     orig = i;
 
-#if 0
     /* Now convert the original trace base into an edited sequence base no. */
     if (opos = DB_Opos(xx, seq)) {
 	if (comp) {
diff --git a/gap5/utlist.h b/gap5/utlist.h
new file mode 100644
index 0000000..28cf8a3
--- /dev/null
+++ b/gap5/utlist.h
@@ -0,0 +1,761 @@
+/*
+Copyright (c) 2007-2014, Troy D. Hanson   http://troydhanson.github.com/uthash/
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef UTLIST_H
+#define UTLIST_H
+
+#define UTLIST_VERSION 1.9.9
+
+#include <assert.h>
+
+/* 
+ * This file contains macros to manipulate singly and doubly-linked lists.
+ *
+ * 1. LL_ macros:  singly-linked lists.
+ * 2. DL_ macros:  doubly-linked lists.
+ * 3. CDL_ macros: circular doubly-linked lists.
+ *
+ * To use singly-linked lists, your structure must have a "next" pointer.
+ * To use doubly-linked lists, your structure must "prev" and "next" pointers.
+ * Either way, the pointer to the head of the list must be initialized to NULL.
+ * 
+ * ----------------.EXAMPLE -------------------------
+ * struct item {
+ *      int id;
+ *      struct item *prev, *next;
+ * }
+ *
+ * struct item *list = NULL:
+ *
+ * int main() {
+ *      struct item *item;
+ *      ... allocate and populate item ...
+ *      DL_APPEND(list, item);
+ * }
+ * --------------------------------------------------
+ *
+ * For doubly-linked lists, the append and delete macros are O(1)
+ * For singly-linked lists, append and delete are O(n) but prepend is O(1)
+ * The sort macro is O(n log(n)) for all types of single/double/circular lists.
+ */
+
+/* These macros use decltype or the earlier __typeof GNU extension.
+   As decltype is only available in newer compilers (VS2010 or gcc 4.3+
+   when compiling c++ code), this code uses whatever method is needed
+   or, for VS2008 where neither is available, uses casting workarounds. */
+#ifdef _MSC_VER            /* MS compiler */
+#if _MSC_VER >= 1600 && defined(__cplusplus)  /* VS2010 or newer in C++ mode */
+#define LDECLTYPE(x) decltype(x)
+#else                     /* VS2008 or older (or VS2010 in C mode) */
+#define NO_DECLTYPE
+#define LDECLTYPE(x) char*
+#endif
+#elif defined(__ICCARM__)
+#define NO_DECLTYPE
+#define LDECLTYPE(x) char*
+#else                      /* GNU, Sun and other compilers */
+#define LDECLTYPE(x) __typeof(x)
+#endif
+
+/* for VS2008 we use some workarounds to get around the lack of decltype,
+ * namely, we always reassign our tmp variable to the list head if we need
+ * to dereference its prev/next pointers, and save/restore the real head.*/
+#ifdef NO_DECLTYPE
+#define _SV(elt,list) _tmp = (char*)(list); {char **_alias = (char**)&(list); *_alias = (elt); }
+#define _NEXT(elt,list,next) ((char*)((list)->next))
+#define _NEXTASGN(elt,list,to,next) { char **_alias = (char**)&((list)->next); *_alias=(char*)(to); }
+/* #define _PREV(elt,list,prev) ((char*)((list)->prev)) */
+#define _PREVASGN(elt,list,to,prev) { char **_alias = (char**)&((list)->prev); *_alias=(char*)(to); }
+#define _RS(list) { char **_alias = (char**)&(list); *_alias=_tmp; }
+#define _CASTASGN(a,b) { char **_alias = (char**)&(a); *_alias=(char*)(b); }
+#else 
+#define _SV(elt,list)
+#define _NEXT(elt,list,next) ((elt)->next)
+#define _NEXTASGN(elt,list,to,next) ((elt)->next)=(to)
+/* #define _PREV(elt,list,prev) ((elt)->prev) */
+#define _PREVASGN(elt,list,to,prev) ((elt)->prev)=(to)
+#define _RS(list)
+#define _CASTASGN(a,b) (a)=(b)
+#endif
+
+/******************************************************************************
+ * The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort    *
+ * Unwieldy variable names used here to avoid shadowing passed-in variables.  *
+ *****************************************************************************/
+#define LL_SORT(list, cmp)                                                                     \
+    LL_SORT2(list, cmp, next)
+
+#define LL_SORT2(list, cmp, next)                                                              \
+do {                                                                                           \
+  LDECLTYPE(list) _ls_p;                                                                       \
+  LDECLTYPE(list) _ls_q;                                                                       \
+  LDECLTYPE(list) _ls_e;                                                                       \
+  LDECLTYPE(list) _ls_tail;                                                                    \
+  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
+  if (list) {                                                                                  \
+    _ls_insize = 1;                                                                            \
+    _ls_looping = 1;                                                                           \
+    while (_ls_looping) {                                                                      \
+      _CASTASGN(_ls_p,list);                                                                   \
+      list = NULL;                                                                             \
+      _ls_tail = NULL;                                                                         \
+      _ls_nmerges = 0;                                                                         \
+      while (_ls_p) {                                                                          \
+        _ls_nmerges++;                                                                         \
+        _ls_q = _ls_p;                                                                         \
+        _ls_psize = 0;                                                                         \
+        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
+          _ls_psize++;                                                                         \
+          _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list);                          \
+          if (!_ls_q) break;                                                                   \
+        }                                                                                      \
+        _ls_qsize = _ls_insize;                                                                \
+        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
+          if (_ls_psize == 0) {                                                                \
+            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
+              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
+          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
+            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
+              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
+          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
+            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
+              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
+          } else {                                                                             \
+            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
+              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
+          }                                                                                    \
+          if (_ls_tail) {                                                                      \
+            _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
+          } else {                                                                             \
+            _CASTASGN(list,_ls_e);                                                             \
+          }                                                                                    \
+          _ls_tail = _ls_e;                                                                    \
+        }                                                                                      \
+        _ls_p = _ls_q;                                                                         \
+      }                                                                                        \
+      if (_ls_tail) {                                                                          \
+        _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list);                     \
+      }                                                                                        \
+      if (_ls_nmerges <= 1) {                                                                  \
+        _ls_looping=0;                                                                         \
+      }                                                                                        \
+      _ls_insize *= 2;                                                                         \
+    }                                                                                          \
+  }                                                                                            \
+} while (0)
+
+
+#define DL_SORT(list, cmp)                                                                     \
+    DL_SORT2(list, cmp, prev, next)
+
+#define DL_SORT2(list, cmp, prev, next)                                                        \
+do {                                                                                           \
+  LDECLTYPE(list) _ls_p;                                                                       \
+  LDECLTYPE(list) _ls_q;                                                                       \
+  LDECLTYPE(list) _ls_e;                                                                       \
+  LDECLTYPE(list) _ls_tail;                                                                    \
+  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
+  if (list) {                                                                                  \
+    _ls_insize = 1;                                                                            \
+    _ls_looping = 1;                                                                           \
+    while (_ls_looping) {                                                                      \
+      _CASTASGN(_ls_p,list);                                                                   \
+      list = NULL;                                                                             \
+      _ls_tail = NULL;                                                                         \
+      _ls_nmerges = 0;                                                                         \
+      while (_ls_p) {                                                                          \
+        _ls_nmerges++;                                                                         \
+        _ls_q = _ls_p;                                                                         \
+        _ls_psize = 0;                                                                         \
+        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
+          _ls_psize++;                                                                         \
+          _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list);                          \
+          if (!_ls_q) break;                                                                   \
+        }                                                                                      \
+        _ls_qsize = _ls_insize;                                                                \
+        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
+          if (_ls_psize == 0) {                                                                \
+            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
+              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
+          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
+            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
+              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
+          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
+            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
+              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
+          } else {                                                                             \
+            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
+              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
+          }                                                                                    \
+          if (_ls_tail) {                                                                      \
+            _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
+          } else {                                                                             \
+            _CASTASGN(list,_ls_e);                                                             \
+          }                                                                                    \
+          _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list);                     \
+          _ls_tail = _ls_e;                                                                    \
+        }                                                                                      \
+        _ls_p = _ls_q;                                                                         \
+      }                                                                                        \
+      _CASTASGN(list->prev, _ls_tail);                                                         \
+      _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list);                       \
+      if (_ls_nmerges <= 1) {                                                                  \
+        _ls_looping=0;                                                                         \
+      }                                                                                        \
+      _ls_insize *= 2;                                                                         \
+    }                                                                                          \
+  }                                                                                            \
+} while (0)
+
+
+#define DL_HEAD(list) (list)
+#define DL_TAIL(list) ((list) ? (list)->prev : NULL)
+
+#define CDL_SORT(list, cmp)                                                                    \
+    CDL_SORT2(list, cmp, prev, next)
+
+#define CDL_SORT2(list, cmp, prev, next)                                                       \
+do {                                                                                           \
+  LDECLTYPE(list) _ls_p;                                                                       \
+  LDECLTYPE(list) _ls_q;                                                                       \
+  LDECLTYPE(list) _ls_e;                                                                       \
+  LDECLTYPE(list) _ls_tail;                                                                    \
+  LDECLTYPE(list) _ls_oldhead;                                                                 \
+  LDECLTYPE(list) _tmp;                                                                        \
+  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
+  if (list) {                                                                                  \
+    _ls_insize = 1;                                                                            \
+    _ls_looping = 1;                                                                           \
+    while (_ls_looping) {                                                                      \
+      _CASTASGN(_ls_p,list);                                                                   \
+      _CASTASGN(_ls_oldhead,list);                                                             \
+      list = NULL;                                                                             \
+      _ls_tail = NULL;                                                                         \
+      _ls_nmerges = 0;                                                                         \
+      while (_ls_p) {                                                                          \
+        _ls_nmerges++;                                                                         \
+        _ls_q = _ls_p;                                                                         \
+        _ls_psize = 0;                                                                         \
+        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
+          _ls_psize++;                                                                         \
+          _SV(_ls_q,list);                                                                     \
+          if (_NEXT(_ls_q,list,next) == _ls_oldhead) {                                         \
+            _ls_q = NULL;                                                                      \
+          } else {                                                                             \
+            _ls_q = _NEXT(_ls_q,list,next);                                                    \
+          }                                                                                    \
+          _RS(list);                                                                           \
+          if (!_ls_q) break;                                                                   \
+        }                                                                                      \
+        _ls_qsize = _ls_insize;                                                                \
+        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
+          if (_ls_psize == 0) {                                                                \
+            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
+              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
+            if (_ls_q == _ls_oldhead) { _ls_q = NULL; }                                        \
+          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
+            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
+              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
+            if (_ls_p == _ls_oldhead) { _ls_p = NULL; }                                        \
+          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
+            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
+              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
+            if (_ls_p == _ls_oldhead) { _ls_p = NULL; }                                        \
+          } else {                                                                             \
+            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
+              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
+            if (_ls_q == _ls_oldhead) { _ls_q = NULL; }                                        \
+          }                                                                                    \
+          if (_ls_tail) {                                                                      \
+            _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
+          } else {                                                                             \
+            _CASTASGN(list,_ls_e);                                                             \
+          }                                                                                    \
+          _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list);                     \
+          _ls_tail = _ls_e;                                                                    \
+        }                                                                                      \
+        _ls_p = _ls_q;                                                                         \
+      }                                                                                        \
+      _CASTASGN(list->prev,_ls_tail);                                                          \
+      _CASTASGN(_tmp,list);                                                                    \
+      _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp,next); _RS(list);                       \
+      if (_ls_nmerges <= 1) {                                                                  \
+        _ls_looping=0;                                                                         \
+      }                                                                                        \
+      _ls_insize *= 2;                                                                         \
+    }                                                                                          \
+  }                                                                                            \
+} while (0)
+
+/******************************************************************************
+ * singly linked list macros (non-circular)                                   *
+ *****************************************************************************/
+#define LL_PREPEND(head,add)                                                                   \
+    LL_PREPEND2(head,add,next)
+
+#define LL_PREPEND2(head,add,next)                                                             \
+do {                                                                                           \
+  (add)->next = head;                                                                          \
+  head = add;                                                                                  \
+} while (0)
+
+#define LL_CONCAT(head1,head2)                                                                 \
+    LL_CONCAT2(head1,head2,next)
+
+#define LL_CONCAT2(head1,head2,next)                                                           \
+do {                                                                                           \
+  LDECLTYPE(head1) _tmp;                                                                       \
+  if (head1) {                                                                                 \
+    _tmp = head1;                                                                              \
+    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
+    _tmp->next=(head2);                                                                        \
+  } else {                                                                                     \
+    (head1)=(head2);                                                                           \
+  }                                                                                            \
+} while (0)
+
+#define LL_APPEND(head,add)                                                                    \
+    LL_APPEND2(head,add,next)
+
+#define LL_APPEND2(head,add,next)                                                              \
+do {                                                                                           \
+  LDECLTYPE(head) _tmp;                                                                        \
+  (add)->next=NULL;                                                                            \
+  if (head) {                                                                                  \
+    _tmp = head;                                                                               \
+    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
+    _tmp->next=(add);                                                                          \
+  } else {                                                                                     \
+    (head)=(add);                                                                              \
+  }                                                                                            \
+} while (0)
+
+#define LL_DELETE(head,del)                                                                    \
+    LL_DELETE2(head,del,next)
+
+#define LL_DELETE2(head,del,next)                                                              \
+do {                                                                                           \
+  LDECLTYPE(head) _tmp;                                                                        \
+  if ((head) == (del)) {                                                                       \
+    (head)=(head)->next;                                                                       \
+  } else {                                                                                     \
+    _tmp = head;                                                                               \
+    while (_tmp->next && (_tmp->next != (del))) {                                              \
+      _tmp = _tmp->next;                                                                       \
+    }                                                                                          \
+    if (_tmp->next) {                                                                          \
+      _tmp->next = ((del)->next);                                                              \
+    }                                                                                          \
+  }                                                                                            \
+} while (0)
+
+/* Here are VS2008 replacements for LL_APPEND and LL_DELETE */
+#define LL_APPEND_VS2008(head,add)                                                             \
+    LL_APPEND2_VS2008(head,add,next)
+
+#define LL_APPEND2_VS2008(head,add,next)                                                       \
+do {                                                                                           \
+  if (head) {                                                                                  \
+    (add)->next = head;     /* use add->next as a temp variable */                             \
+    while ((add)->next->next) { (add)->next = (add)->next->next; }                             \
+    (add)->next->next=(add);                                                                   \
+  } else {                                                                                     \
+    (head)=(add);                                                                              \
+  }                                                                                            \
+  (add)->next=NULL;                                                                            \
+} while (0)
+
+#define LL_DELETE_VS2008(head,del)                                                             \
+    LL_DELETE2_VS2008(head,del,next)
+
+#define LL_DELETE2_VS2008(head,del,next)                                                       \
+do {                                                                                           \
+  if ((head) == (del)) {                                                                       \
+    (head)=(head)->next;                                                                       \
+  } else {                                                                                     \
+    char *_tmp = (char*)(head);                                                                \
+    while ((head)->next && ((head)->next != (del))) {                                          \
+      head = (head)->next;                                                                     \
+    }                                                                                          \
+    if ((head)->next) {                                                                        \
+      (head)->next = ((del)->next);                                                            \
+    }                                                                                          \
+    {                                                                                          \
+      char **_head_alias = (char**)&(head);                                                    \
+      *_head_alias = _tmp;                                                                     \
+    }                                                                                          \
+  }                                                                                            \
+} while (0)
+#ifdef NO_DECLTYPE
+#undef LL_APPEND
+#define LL_APPEND LL_APPEND_VS2008
+#undef LL_DELETE
+#define LL_DELETE LL_DELETE_VS2008
+#undef LL_DELETE2
+#define LL_DELETE2 LL_DELETE2_VS2008
+#undef LL_APPEND2
+#define LL_APPEND2 LL_APPEND2_VS2008
+#undef LL_CONCAT /* no LL_CONCAT_VS2008 */
+#undef DL_CONCAT /* no DL_CONCAT_VS2008 */
+#endif
+/* end VS2008 replacements */
+
+#define LL_COUNT(head,el,counter)                                                              \
+    LL_COUNT2(head,el,counter,next)                                                            \
+
+#define LL_COUNT2(head,el,counter,next)                                                        \
+{                                                                                              \
+    counter = 0;                                                                               \
+    LL_FOREACH2(head,el,next){ ++counter; }                                                    \
+}
+
+#define LL_FOREACH(head,el)                                                                    \
+    LL_FOREACH2(head,el,next)
+
+#define LL_FOREACH2(head,el,next)                                                              \
+    for(el=head;el;el=(el)->next)
+
+#define LL_FOREACH_SAFE(head,el,tmp)                                                           \
+    LL_FOREACH_SAFE2(head,el,tmp,next)
+
+#define LL_FOREACH_SAFE2(head,el,tmp,next)                                                     \
+  for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp)
+
+#define LL_SEARCH_SCALAR(head,out,field,val)                                                   \
+    LL_SEARCH_SCALAR2(head,out,field,val,next)
+
+#define LL_SEARCH_SCALAR2(head,out,field,val,next)                                             \
+do {                                                                                           \
+    LL_FOREACH2(head,out,next) {                                                               \
+      if ((out)->field == (val)) break;                                                        \
+    }                                                                                          \
+} while(0) 
+
+#define LL_SEARCH(head,out,elt,cmp)                                                            \
+    LL_SEARCH2(head,out,elt,cmp,next)
+
+#define LL_SEARCH2(head,out,elt,cmp,next)                                                      \
+do {                                                                                           \
+    LL_FOREACH2(head,out,next) {                                                               \
+      if ((cmp(out,elt))==0) break;                                                            \
+    }                                                                                          \
+} while(0) 
+
+#define LL_REPLACE_ELEM(head, el, add)                                                         \
+do {                                                                                           \
+ LDECLTYPE(head) _tmp;                                                                         \
+ assert(head != NULL);                                                                         \
+ assert(el != NULL);                                                                           \
+ assert(add != NULL);                                                                          \
+ (add)->next = (el)->next;                                                                     \
+ if ((head) == (el)) {                                                                         \
+  (head) = (add);                                                                              \
+ } else {                                                                                      \
+  _tmp = head;                                                                                 \
+  while (_tmp->next && (_tmp->next != (el))) {                                                 \
+   _tmp = _tmp->next;                                                                          \
+  }                                                                                            \
+  if (_tmp->next) {                                                                            \
+    _tmp->next = (add);                                                                        \
+  }                                                                                            \
+ }                                                                                             \
+} while (0)
+
+#define LL_PREPEND_ELEM(head, el, add)                                                         \
+do {                                                                                           \
+ LDECLTYPE(head) _tmp;                                                                         \
+ assert(head != NULL);                                                                         \
+ assert(el != NULL);                                                                           \
+ assert(add != NULL);                                                                          \
+ (add)->next = (el);                                                                           \
+ if ((head) == (el)) {                                                                         \
+  (head) = (add);                                                                              \
+ } else {                                                                                      \
+  _tmp = head;                                                                                 \
+  while (_tmp->next && (_tmp->next != (el))) {                                                 \
+   _tmp = _tmp->next;                                                                          \
+  }                                                                                            \
+  if (_tmp->next) {                                                                            \
+    _tmp->next = (add);                                                                        \
+  }                                                                                            \
+ }                                                                                             \
+} while (0)                                                                                    \
+
+
+/******************************************************************************
+ * doubly linked list macros (non-circular)                                   *
+ *****************************************************************************/
+#define DL_PREPEND(head,add)                                                                   \
+    DL_PREPEND2(head,add,prev,next)
+
+#define DL_PREPEND2(head,add,prev,next)                                                        \
+do {                                                                                           \
+ (add)->next = head;                                                                           \
+ if (head) {                                                                                   \
+   (add)->prev = (head)->prev;                                                                 \
+   (head)->prev = (add);                                                                       \
+ } else {                                                                                      \
+   (add)->prev = (add);                                                                        \
+ }                                                                                             \
+ (head) = (add);                                                                               \
+} while (0)
+
+#define DL_APPEND(head,add)                                                                    \
+    DL_APPEND2(head,add,prev,next)
+
+#define DL_APPEND2(head,add,prev,next)                                                         \
+do {                                                                                           \
+  if (head) {                                                                                  \
+      (add)->prev = (head)->prev;                                                              \
+      (head)->prev->next = (add);                                                              \
+      (head)->prev = (add);                                                                    \
+      (add)->next = NULL;                                                                      \
+  } else {                                                                                     \
+      (head)=(add);                                                                            \
+      (head)->prev = (head);                                                                   \
+      (head)->next = NULL;                                                                     \
+  }                                                                                            \
+} while (0) 
+
+#define DL_CONCAT(head1,head2)                                                                 \
+    DL_CONCAT2(head1,head2,prev,next)
+
+#define DL_CONCAT2(head1,head2,prev,next)                                                      \
+do {                                                                                           \
+  LDECLTYPE(head1) _tmp;                                                                       \
+  if (head2) {                                                                                 \
+    if (head1) {                                                                               \
+        _tmp = (head2)->prev;                                                                  \
+        (head2)->prev = (head1)->prev;                                                         \
+        (head1)->prev->next = (head2);                                                         \
+        (head1)->prev = _tmp;                                                                  \
+    } else {                                                                                   \
+        (head1)=(head2);                                                                       \
+    }                                                                                          \
+  }                                                                                            \
+} while (0) 
+
+#define DL_DELETE(head,del)                                                                    \
+    DL_DELETE2(head,del,prev,next)
+
+#define DL_DELETE2(head,del,prev,next)                                                         \
+do {                                                                                           \
+  assert((del)->prev != NULL);                                                                 \
+  if ((del)->prev == (del)) {                                                                  \
+      (head)=NULL;                                                                             \
+  } else if ((del)==(head)) {                                                                  \
+      (del)->next->prev = (del)->prev;                                                         \
+      (head) = (del)->next;                                                                    \
+  } else {                                                                                     \
+      (del)->prev->next = (del)->next;                                                         \
+      if ((del)->next) {                                                                       \
+          (del)->next->prev = (del)->prev;                                                     \
+      } else {                                                                                 \
+          (head)->prev = (del)->prev;                                                          \
+      }                                                                                        \
+  }                                                                                            \
+} while (0) 
+
+#define DL_COUNT(head,el,counter)                                                              \
+    DL_COUNT2(head,el,counter,next)                                                            \
+
+#define DL_COUNT2(head,el,counter,next)                                                        \
+{                                                                                              \
+    counter = 0;                                                                               \
+    DL_FOREACH2(head,el,next){ ++counter; }                                                    \
+}
+
+#define DL_FOREACH(head,el)                                                                    \
+    DL_FOREACH2(head,el,next)
+
+#define DL_FOREACH2(head,el,next)                                                              \
+    for(el=head;el;el=(el)->next)
+
+/* this version is safe for deleting the elements during iteration */
+#define DL_FOREACH_SAFE(head,el,tmp)                                                           \
+    DL_FOREACH_SAFE2(head,el,tmp,next)
+
+#define DL_FOREACH_SAFE2(head,el,tmp,next)                                                     \
+  for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp)
+
+/* these are identical to their singly-linked list counterparts */
+#define DL_SEARCH_SCALAR LL_SEARCH_SCALAR
+#define DL_SEARCH LL_SEARCH
+#define DL_SEARCH_SCALAR2 LL_SEARCH_SCALAR2
+#define DL_SEARCH2 LL_SEARCH2
+
+#define DL_REPLACE_ELEM(head, el, add)                                                         \
+do {                                                                                           \
+ assert(head != NULL);                                                                         \
+ assert(el != NULL);                                                                           \
+ assert(add != NULL);                                                                          \
+ if ((head) == (el)) {                                                                         \
+  (head) = (add);                                                                              \
+  (add)->next = (el)->next;                                                                    \
+  if ((el)->next == NULL) {                                                                    \
+   (add)->prev = (add);                                                                        \
+  } else {                                                                                     \
+   (add)->prev = (el)->prev;                                                                   \
+   (add)->next->prev = (add);                                                                  \
+  }                                                                                            \
+ } else {                                                                                      \
+  (add)->next = (el)->next;                                                                    \
+  (add)->prev = (el)->prev;                                                                    \
+  (add)->prev->next = (add);                                                                   \
+  if ((el)->next == NULL) {                                                                    \
+   (head)->prev = (add);                                                                       \
+  } else {                                                                                     \
+   (add)->next->prev = (add);                                                                  \
+  }                                                                                            \
+ }                                                                                             \
+} while (0)
+
+#define DL_PREPEND_ELEM(head, el, add)                                                         \
+do {                                                                                           \
+ assert(head != NULL);                                                                         \
+ assert(el != NULL);                                                                           \
+ assert(add != NULL);                                                                          \
+ (add)->next = (el);                                                                           \
+ (add)->prev = (el)->prev;                                                                     \
+ (el)->prev = (add);                                                                           \
+ if ((head) == (el)) {                                                                         \
+  (head) = (add);                                                                              \
+ } else {                                                                                      \
+  (add)->prev->next = (add);                                                                   \
+ }                                                                                             \
+} while (0)                                                                                    \
+
+
+/******************************************************************************
+ * circular doubly linked list macros                                         *
+ *****************************************************************************/
+#define CDL_PREPEND(head,add)                                                                  \
+    CDL_PREPEND2(head,add,prev,next)
+
+#define CDL_PREPEND2(head,add,prev,next)                                                       \
+do {                                                                                           \
+ if (head) {                                                                                   \
+   (add)->prev = (head)->prev;                                                                 \
+   (add)->next = (head);                                                                       \
+   (head)->prev = (add);                                                                       \
+   (add)->prev->next = (add);                                                                  \
+ } else {                                                                                      \
+   (add)->prev = (add);                                                                        \
+   (add)->next = (add);                                                                        \
+ }                                                                                             \
+(head)=(add);                                                                                  \
+} while (0)
+
+#define CDL_DELETE(head,del)                                                                   \
+    CDL_DELETE2(head,del,prev,next)
+
+#define CDL_DELETE2(head,del,prev,next)                                                        \
+do {                                                                                           \
+  if ( ((head)==(del)) && ((head)->next == (head))) {                                          \
+      (head) = 0L;                                                                             \
+  } else {                                                                                     \
+     (del)->next->prev = (del)->prev;                                                          \
+     (del)->prev->next = (del)->next;                                                          \
+     if ((del) == (head)) (head)=(del)->next;                                                  \
+  }                                                                                            \
+} while (0) 
+
+#define CDL_COUNT(head,el,counter)                                                             \
+    CDL_COUNT2(head,el,counter,next)                                                           \
+
+#define CDL_COUNT2(head, el, counter,next)                                                     \
+{                                                                                              \
+    counter = 0;                                                                               \
+    CDL_FOREACH2(head,el,next){ ++counter; }                                                   \
+}
+
+#define CDL_FOREACH(head,el)                                                                   \
+    CDL_FOREACH2(head,el,next)
+
+#define CDL_FOREACH2(head,el,next)                                                             \
+    for(el=head;el;el=((el)->next==head ? 0L : (el)->next)) 
+
+#define CDL_FOREACH_SAFE(head,el,tmp1,tmp2)                                                    \
+    CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next)
+
+#define CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next)                                         \
+  for((el)=(head), ((tmp1)=(head)?((head)->prev):NULL);                                        \
+      (el) && ((tmp2)=(el)->next, 1);                                                          \
+      ((el) = (((el)==(tmp1)) ? 0L : (tmp2))))
+
+#define CDL_SEARCH_SCALAR(head,out,field,val)                                                  \
+    CDL_SEARCH_SCALAR2(head,out,field,val,next)
+
+#define CDL_SEARCH_SCALAR2(head,out,field,val,next)                                            \
+do {                                                                                           \
+    CDL_FOREACH2(head,out,next) {                                                              \
+      if ((out)->field == (val)) break;                                                        \
+    }                                                                                          \
+} while(0) 
+
+#define CDL_SEARCH(head,out,elt,cmp)                                                           \
+    CDL_SEARCH2(head,out,elt,cmp,next)
+
+#define CDL_SEARCH2(head,out,elt,cmp,next)                                                     \
+do {                                                                                           \
+    CDL_FOREACH2(head,out,next) {                                                              \
+      if ((cmp(out,elt))==0) break;                                                            \
+    }                                                                                          \
+} while(0) 
+
+#define CDL_REPLACE_ELEM(head, el, add)                                                        \
+do {                                                                                           \
+ assert(head != NULL);                                                                         \
+ assert(el != NULL);                                                                           \
+ assert(add != NULL);                                                                          \
+ if ((el)->next == (el)) {                                                                     \
+  (add)->next = (add);                                                                         \
+  (add)->prev = (add);                                                                         \
+  (head) = (add);                                                                              \
+ } else {                                                                                      \
+  (add)->next = (el)->next;                                                                    \
+  (add)->prev = (el)->prev;                                                                    \
+  (add)->next->prev = (add);                                                                   \
+  (add)->prev->next = (add);                                                                   \
+  if ((head) == (el)) {                                                                        \
+   (head) = (add);                                                                             \
+  }                                                                                            \
+ }                                                                                             \
+} while (0)
+
+#define CDL_PREPEND_ELEM(head, el, add)                                                        \
+do {                                                                                           \
+ assert(head != NULL);                                                                         \
+ assert(el != NULL);                                                                           \
+ assert(add != NULL);                                                                          \
+ (add)->next = (el);                                                                           \
+ (add)->prev = (el)->prev;                                                                     \
+ (el)->prev = (add);                                                                           \
+ (add)->prev->next = (add);                                                                    \
+ if ((head) == (el)) {                                                                         \
+  (head) = (add);                                                                              \
+ }                                                                                             \
+} while (0)                                                                                    \
+
+#endif /* UTLIST_H */
+
diff --git a/gap5/zfio.c b/gap5/zfio.c
deleted file mode 100644
index f134590..0000000
--- a/gap5/zfio.c
+++ /dev/null
@@ -1,128 +0,0 @@
-#include <staden_config.h>
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "os.h"
-#include "zfio.h"
-
-/* ------------------------------------------------------------------------ */
-/* Some wrappers around FILE * vs gzFile *, allowing for either */
-
-/*
- * gzopen() works on both compressed and uncompressed data, but it has
- * a significant performance hit even for uncompressed data (tested as
- * 25s using FILE* to 46s via gzOpen and 66s via gzOpen when gzipped).
- *
- * Hence we use our own wrapper 'zfp' which is a FILE* when uncompressed
- * and gzFile* when compressed. This also means we could hide bzopen in
- * there too if desired.
- */
-
-off_t zftello(zfp *zf) {
-    return zf->fp ? ftello(zf->fp) : -1;
-}
-
-int zfseeko(zfp *zf, off_t offset, int whence) {
-    return zf->fp ? fseeko(zf->fp, offset, whence) : -1;
-}
-
-
-/*
- * A wrapper for either fgets or gzgets depending on what has been
- * opened.
- */
-char *zfgets(char *line, int size, zfp *zf) {
-    if (zf->fp)
-	return fgets(line, size, zf->fp);
-    else
-	return gzgets(zf->gz, line, size);
-}
-
-/*
- * Peeks at and returns the next character without consuming it from the
- * input. (Ie a combination of getc and ungetc).
- */
-int zfpeek(zfp *zf) {
-    int c;
-
-    if (zf->fp) {
-	c = getc(zf->fp);
-	if (c != EOF)
-	    ungetc(c, zf->fp);
-    } else {
-	c = gzgetc(zf->gz);
-	if (c != EOF)
-	    gzungetc(c, zf->gz);
-    }
-
-    return c;
-}
-
-/* A replacement for either feof of gzeof */
-int zfeof(zfp *zf) {
-    return zf->fp ? feof(zf->fp) : gzeof(zf->gz);
-}
-
-/* A replacement for either fopen or gzopen */
-zfp *zfopen(const char *path, const char *mode) {
-    char path2[1024];
-    zfp *zf;
-
-    if (!(zf = (zfp *)malloc(sizeof(*zf))))
-	return NULL;
-    zf->fp = NULL;
-    zf->gz = NULL;
-
-    /* Try normal fopen */
-    if (NULL != (zf->fp = fopen(path, mode))) {
-	unsigned char magic[2];
-	fread(magic, 1, 2, zf->fp);
-	if (!(magic[0] == 0x1f &&
-	      magic[1] == 0x8b)) {
-	    fseeko(zf->fp, 0, SEEK_SET);
-	    return zf;
-	}
-
-	fclose(zf->fp);
-	zf->fp = NULL;
-    }
-
-#ifdef HAVE_POPEN
-    /*
-     * I've no idea why, by gzgets is VERY slow, maybe because it handles
-     * arbitrary seeks.
-     * popen to gzip -cd is 3 times faster though.
-     */
-    if (access(path, R_OK) == 0) {
-	sprintf(path2, "gzip -cd < %.*s", 1000, path);
-	if (NULL != (zf->fp = popen(path2, "r")))
-	    return zf;
-    }
-
-    sprintf(path2, "gzip -cd < %.*s.gz", 1000, path);
-    if (NULL != (zf->fp = popen(path2, "r")))
-	return zf;
-
-    printf("Failed on %s\n", path);
-#else
-    /* Gzopen instead */
-    if (zf->gz = gzopen(path, mode))
-	return zf;
-
-    sprintf(path2, "%.*s.gz", 1020, path);
-    if (zf->gz = gzopen(path2, mode))
-	return zf;
-#endif
-
-    perror(path);
-
-    free(zf);
-    return NULL;
-}
-
-int zfclose(zfp *zf) {
-    int r = (zf->fp) ? fclose(zf->fp) : gzclose(zf->gz);
-    free(zf);
-    return r;
-}
diff --git a/gap5/zfio.h b/gap5/zfio.h
deleted file mode 100644
index 49d2cea..0000000
--- a/gap5/zfio.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _ZFIO_H_
-#define _ZFIO_H_
-
-#include <stdio.h>
-#include <zlib.h>
-
-/*
- * Either a gzFile or a FILE.
- */
-typedef struct {
-    FILE   *fp;
-    gzFile  gz;
-} zfp;
-
-off_t zftello(zfp *zf);
-int zfseeko(zfp *zf, off_t offset, int whence);
-char *zfgets(char *line, int size, zfp *zf);
-zfp *zfopen(const char *path, const char *mode);
-int zfclose(zfp *zf);
-int zfpeek(zfp *zf);
-int zfeof(zfp *zf);
-
-#endif /* _ZFIO_H_ */
diff --git a/get_scf_field/Makefile b/get_scf_field/Makefile
index f552437..0b268fb 100644
--- a/get_scf_field/Makefile
+++ b/get_scf_field/Makefile
@@ -31,3 +31,6 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 get_scf_field.o: $(PWD)/staden_config.h
+get_scf_field.o: $(SRCROOT)/Misc/misc.h
+get_scf_field.o: $(SRCROOT)/Misc/os.h
+get_scf_field.o: $(SRCROOT)/Misc/xalloc.h
diff --git a/global.mk b/global.mk
index ab1abf4..de18e3b 100644
--- a/global.mk
+++ b/global.mk
@@ -462,9 +462,10 @@ depend:
 	  sed -e 's;.*/\([^:]*\):;\1:;'  | \
 	  egrep -v '^[^:]*:[     ]*$$' | \
 	  sed -e 's#$(subst .,\.,$(SRCROOT))#$$(SRCROOT)#g' \
-	      -e "s#`echo $(subst .,\.,$(SRCROOT)) | sed 's#[^/]*/\.\.##'`#\$$(SRCROOT)/#g" \
-	      -e 's#: .*/staden_config.h#: $$(PWD)/staden_config.h#g' | \
-	  egrep -v ': /' > dependencies.tmp2
+	      -e "s#`echo $(subst .,\.,$(SRCROOT)) | sed 's#/[^/]*/\.\./#/#'`#\$$(SRCROOT)/#g" \
+	      -e 's#: .*/staden_config.h#: $$(PWD)/staden_config.h#g' \
+	      -e 's#//#/#g' | \
+	egrep -v ': /' > dependencies.tmp2
 
 	@# Copy the dependencies into the Makefile
 	l=`egrep -n 'DO NOT DELETE' $(VPATH)/Makefile | head -1 | sed 's/:.*//'`; \
diff --git a/haplo/Makefile b/haplo/Makefile
index 603c6bf..2c4ecb9 100644
--- a/haplo/Makefile
+++ b/haplo/Makefile
@@ -47,6 +47,95 @@ DEPEND_OBJ = $(OBJS)
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 haplo_cons.o: $(PWD)/staden_config.h
+haplo_cons.o: $(SRCROOT)/Misc/array.h
+haplo_cons.o: $(SRCROOT)/Misc/bitmap.h
+haplo_cons.o: $(SRCROOT)/Misc/dstring.h
+haplo_cons.o: $(SRCROOT)/Misc/misc.h
+haplo_cons.o: $(SRCROOT)/Misc/os.h
+haplo_cons.o: $(SRCROOT)/Misc/xalloc.h
+haplo_cons.o: $(SRCROOT)/Misc/xerror.h
+haplo_cons.o: $(SRCROOT)/g/freetree.h
+haplo_cons.o: $(SRCROOT)/g/g-defs.h
+haplo_cons.o: $(SRCROOT)/g/g-error.h
+haplo_cons.o: $(SRCROOT)/g/g-filedefs.h
+haplo_cons.o: $(SRCROOT)/g/g-os.h
+haplo_cons.o: $(SRCROOT)/g/g-struct.h
+haplo_cons.o: $(SRCROOT)/gap4/IO1.h
+haplo_cons.o: $(SRCROOT)/gap4/gap-dbstruct.h
+haplo_cons.o: $(SRCROOT)/gap4/gap-if.h
+haplo_cons.o: $(SRCROOT)/gap4/gap_globals.h
+haplo_cons.o: $(SRCROOT)/gap4/io_handle.h
+haplo_cons.o: $(SRCROOT)/gap4/io_utils.h
+haplo_cons.o: $(SRCROOT)/gap4/qual.h
+haplo_cons.o: $(SRCROOT)/gap4/vseqs.h
+haplo_cons.o: $(SRCROOT)/haplo/haplo.h
+haplo_cons.o: $(SRCROOT)/tk_utils/tcl_utils.h
 haplo_snps.o: $(PWD)/staden_config.h
+haplo_snps.o: $(SRCROOT)/Misc/array.h
+haplo_snps.o: $(SRCROOT)/Misc/bitmap.h
+haplo_snps.o: $(SRCROOT)/Misc/dstring.h
+haplo_snps.o: $(SRCROOT)/Misc/misc.h
+haplo_snps.o: $(SRCROOT)/Misc/os.h
+haplo_snps.o: $(SRCROOT)/Misc/xalloc.h
+haplo_snps.o: $(SRCROOT)/Misc/xerror.h
+haplo_snps.o: $(SRCROOT)/g/freetree.h
+haplo_snps.o: $(SRCROOT)/g/g-defs.h
+haplo_snps.o: $(SRCROOT)/g/g-error.h
+haplo_snps.o: $(SRCROOT)/g/g-filedefs.h
+haplo_snps.o: $(SRCROOT)/g/g-os.h
+haplo_snps.o: $(SRCROOT)/g/g-struct.h
+haplo_snps.o: $(SRCROOT)/gap4/IO1.h
+haplo_snps.o: $(SRCROOT)/gap4/gap-dbstruct.h
+haplo_snps.o: $(SRCROOT)/gap4/gap-if.h
+haplo_snps.o: $(SRCROOT)/gap4/gap_globals.h
+haplo_snps.o: $(SRCROOT)/gap4/io_handle.h
+haplo_snps.o: $(SRCROOT)/gap4/io_utils.h
+haplo_snps.o: $(SRCROOT)/gap4/list.h
+haplo_snps.o: $(SRCROOT)/gap4/notes.h
+haplo_snps.o: $(SRCROOT)/gap4/qual.h
+haplo_snps.o: $(SRCROOT)/gap4/template.h
+haplo_snps.o: $(SRCROOT)/haplo/haplo.h
+haplo_snps.o: $(SRCROOT)/tk_utils/tcl_utils.h
 haplo_split.o: $(PWD)/staden_config.h
+haplo_split.o: $(SRCROOT)/Misc/array.h
+haplo_split.o: $(SRCROOT)/Misc/bitmap.h
+haplo_split.o: $(SRCROOT)/Misc/dstring.h
+haplo_split.o: $(SRCROOT)/Misc/misc.h
+haplo_split.o: $(SRCROOT)/Misc/os.h
+haplo_split.o: $(SRCROOT)/Misc/xalloc.h
+haplo_split.o: $(SRCROOT)/Misc/xerror.h
+haplo_split.o: $(SRCROOT)/g/freetree.h
+haplo_split.o: $(SRCROOT)/g/g-defs.h
+haplo_split.o: $(SRCROOT)/g/g-error.h
+haplo_split.o: $(SRCROOT)/g/g-filedefs.h
+haplo_split.o: $(SRCROOT)/g/g-os.h
+haplo_split.o: $(SRCROOT)/g/g-struct.h
+haplo_split.o: $(SRCROOT)/gap4/IO1.h
+haplo_split.o: $(SRCROOT)/gap4/gap-dbstruct.h
+haplo_split.o: $(SRCROOT)/gap4/gap-if.h
+haplo_split.o: $(SRCROOT)/gap4/io_handle.h
+haplo_split.o: $(SRCROOT)/gap4/io_utils.h
+haplo_split.o: $(SRCROOT)/haplo/haplo.h
 haplo_tcl.o: $(PWD)/staden_config.h
+haplo_tcl.o: $(SRCROOT)/Misc/array.h
+haplo_tcl.o: $(SRCROOT)/Misc/bitmap.h
+haplo_tcl.o: $(SRCROOT)/Misc/dstring.h
+haplo_tcl.o: $(SRCROOT)/Misc/misc.h
+haplo_tcl.o: $(SRCROOT)/Misc/os.h
+haplo_tcl.o: $(SRCROOT)/Misc/xalloc.h
+haplo_tcl.o: $(SRCROOT)/Misc/xerror.h
+haplo_tcl.o: $(SRCROOT)/g/freetree.h
+haplo_tcl.o: $(SRCROOT)/g/g-defs.h
+haplo_tcl.o: $(SRCROOT)/g/g-error.h
+haplo_tcl.o: $(SRCROOT)/g/g-filedefs.h
+haplo_tcl.o: $(SRCROOT)/g/g-os.h
+haplo_tcl.o: $(SRCROOT)/g/g-struct.h
+haplo_tcl.o: $(SRCROOT)/gap4/IO1.h
+haplo_tcl.o: $(SRCROOT)/gap4/gap-dbstruct.h
+haplo_tcl.o: $(SRCROOT)/gap4/gap-if.h
+haplo_tcl.o: $(SRCROOT)/gap4/gap_cli_arg.h
+haplo_tcl.o: $(SRCROOT)/gap4/io_handle.h
+haplo_tcl.o: $(SRCROOT)/gap4/io_utils.h
+haplo_tcl.o: $(SRCROOT)/gap4/list_proc.h
+haplo_tcl.o: $(SRCROOT)/haplo/haplo.h
+haplo_tcl.o: $(SRCROOT)/tk_utils/cli_arg.h
diff --git a/hetins/hetins.c b/hetins/hetins.c
index 54d41d5..48c561e 100644
--- a/hetins/hetins.c
+++ b/hetins/hetins.c
@@ -8,6 +8,7 @@
 #include <io_lib/misc.h>
 #include <io_lib/Read.h>
 #include <io_lib/traceType.h>
+#include <io_lib/xalloc.h>
 
 #define FULL_TEST 2
 #define TEST 1
diff --git a/init_exp/Makefile b/init_exp/Makefile
index 3064c51..75a46ca 100644
--- a/init_exp/Makefile
+++ b/init_exp/Makefile
@@ -26,3 +26,5 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 init_exp.o: $(PWD)/staden_config.h
+init_exp.o: $(SRCROOT)/Misc/os.h
+init_exp.o: $(SRCROOT)/Misc/xalloc.h
diff --git a/make_weights/Makefile b/make_weights/Makefile
index e6bb637..4f7e0fd 100644
--- a/make_weights/Makefile
+++ b/make_weights/Makefile
@@ -40,3 +40,7 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it
 
 make_weights.o: $(PWD)/staden_config.h
+make_weights.o: $(SRCROOT)/Misc/misc.h
+make_weights.o: $(SRCROOT)/Misc/os.h
+make_weights.o: $(SRCROOT)/Misc/xalloc.h
+make_weights.o: $(SRCROOT)/seq_utils/dna_utils.h
diff --git a/mutlib/Makefile b/mutlib/Makefile
index afb0514..053f1e6 100644
--- a/mutlib/Makefile
+++ b/mutlib/Makefile
@@ -92,35 +92,373 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it
 
 align.o: $(PWD)/staden_config.h
+align.o: $(SRCROOT)/mutlib/align.hpp
+align.o: $(SRCROOT)/mutlib/matrix.hpp
+align.o: $(SRCROOT)/mutlib/sp_alignment.h
+align.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+basecall.o: $(SRCROOT)/mutlib/basecall.hpp
 caller.o: $(PWD)/staden_config.h
+caller.o: $(SRCROOT)/Misc/misc.h
+caller.o: $(SRCROOT)/Misc/os.h
+caller.o: $(SRCROOT)/Misc/xalloc.h
+caller.o: $(SRCROOT)/mutlib/caller.hpp
+caller.o: $(SRCROOT)/mutlib/matrix.hpp
+caller.o: $(SRCROOT)/mutlib/staden.h
+caller.o: $(SRCROOT)/mutlib/trace.hpp
+caller.o: $(SRCROOT)/seq_utils/dna_utils.h
 caller_base.o: $(PWD)/staden_config.h
+caller_base.o: $(SRCROOT)/Misc/misc.h
+caller_base.o: $(SRCROOT)/Misc/os.h
+caller_base.o: $(SRCROOT)/Misc/xalloc.h
+caller_base.o: $(SRCROOT)/mutlib/caller.hpp
+caller_base.o: $(SRCROOT)/mutlib/caller_base.hpp
+caller_base.o: $(SRCROOT)/mutlib/dnatable.hpp
+caller_base.o: $(SRCROOT)/mutlib/matrix.hpp
+caller_base.o: $(SRCROOT)/mutlib/staden.h
+caller_base.o: $(SRCROOT)/mutlib/trace.hpp
+caller_base.o: $(SRCROOT)/seq_utils/dna_utils.h
 caller_level.o: $(PWD)/staden_config.h
+caller_level.o: $(SRCROOT)/Misc/misc.h
+caller_level.o: $(SRCROOT)/Misc/os.h
+caller_level.o: $(SRCROOT)/Misc/xalloc.h
+caller_level.o: $(SRCROOT)/mutlib/caller.hpp
+caller_level.o: $(SRCROOT)/mutlib/caller_level.hpp
+caller_level.o: $(SRCROOT)/mutlib/dnatable.hpp
+caller_level.o: $(SRCROOT)/mutlib/matrix.hpp
+caller_level.o: $(SRCROOT)/mutlib/staden.h
+caller_level.o: $(SRCROOT)/mutlib/trace.hpp
+caller_level.o: $(SRCROOT)/seq_utils/dna_utils.h
 caller_snr.o: $(PWD)/staden_config.h
+caller_snr.o: $(SRCROOT)/Misc/misc.h
+caller_snr.o: $(SRCROOT)/Misc/os.h
+caller_snr.o: $(SRCROOT)/Misc/xalloc.h
+caller_snr.o: $(SRCROOT)/mutlib/caller.hpp
+caller_snr.o: $(SRCROOT)/mutlib/caller_snr.hpp
+caller_snr.o: $(SRCROOT)/mutlib/matrix.hpp
+caller_snr.o: $(SRCROOT)/mutlib/staden.h
+caller_snr.o: $(SRCROOT)/mutlib/trace.hpp
+caller_snr.o: $(SRCROOT)/seq_utils/dna_utils.h
+dnatable.o: $(SRCROOT)/mutlib/dnatable.hpp
 mutationtag.o: $(PWD)/staden_config.h
+mutationtag.o: $(SRCROOT)/Misc/misc.h
+mutationtag.o: $(SRCROOT)/Misc/os.h
+mutationtag.o: $(SRCROOT)/Misc/xalloc.h
+mutationtag.o: $(SRCROOT)/mutlib/listitem.hpp
+mutationtag.o: $(SRCROOT)/mutlib/mutationtag.hpp
+mutationtag.o: $(SRCROOT)/mutlib/mutlib.h
+mutationtag.o: $(SRCROOT)/mutlib/staden.h
+mutationtag.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutationtag_utils.o: $(PWD)/staden_config.h
+mutationtag_utils.o: $(SRCROOT)/Misc/misc.h
+mutationtag_utils.o: $(SRCROOT)/Misc/os.h
+mutationtag_utils.o: $(SRCROOT)/Misc/xalloc.h
+mutationtag_utils.o: $(SRCROOT)/mutlib/array.hpp
+mutationtag_utils.o: $(SRCROOT)/mutlib/list.hpp
+mutationtag_utils.o: $(SRCROOT)/mutlib/listitem.hpp
+mutationtag_utils.o: $(SRCROOT)/mutlib/mutationtag.hpp
+mutationtag_utils.o: $(SRCROOT)/mutlib/mutationtag_utils.hpp
+mutationtag_utils.o: $(SRCROOT)/mutlib/mutlib.h
+mutationtag_utils.o: $(SRCROOT)/mutlib/staden.h
+mutationtag_utils.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutscan.o: $(PWD)/staden_config.h
+mutscan.o: $(SRCROOT)/Misc/misc.h
+mutscan.o: $(SRCROOT)/Misc/os.h
+mutscan.o: $(SRCROOT)/Misc/xalloc.h
+mutscan.o: $(SRCROOT)/mutlib/align.hpp
+mutscan.o: $(SRCROOT)/mutlib/array.hpp
+mutscan.o: $(SRCROOT)/mutlib/list.hpp
+mutscan.o: $(SRCROOT)/mutlib/listitem.hpp
+mutscan.o: $(SRCROOT)/mutlib/matrix.hpp
+mutscan.o: $(SRCROOT)/mutlib/mutationtag.hpp
+mutscan.o: $(SRCROOT)/mutlib/mutationtag_utils.hpp
+mutscan.o: $(SRCROOT)/mutlib/mutlib.h
+mutscan.o: $(SRCROOT)/mutlib/mutscan.hpp
+mutscan.o: $(SRCROOT)/mutlib/mutscan_analysis.hpp
+mutscan.o: $(SRCROOT)/mutlib/mutscan_parameters.hpp
+mutscan.o: $(SRCROOT)/mutlib/mutscan_preprocess.hpp
+mutscan.o: $(SRCROOT)/mutlib/parameter.hpp
+mutscan.o: $(SRCROOT)/mutlib/sp_alignment.h
+mutscan.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+mutscan.o: $(SRCROOT)/mutlib/staden.h
+mutscan.o: $(SRCROOT)/mutlib/trace.hpp
+mutscan.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutscan_analysis.o: $(PWD)/staden_config.h
+mutscan_analysis.o: $(SRCROOT)/Misc/misc.h
+mutscan_analysis.o: $(SRCROOT)/Misc/os.h
+mutscan_analysis.o: $(SRCROOT)/Misc/xalloc.h
+mutscan_analysis.o: $(SRCROOT)/mutlib/array.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/caller.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/caller_base.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/caller_level.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/dnatable.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/list.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/listitem.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/matrix.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/mutationtag.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/mutlib.h
+mutscan_analysis.o: $(SRCROOT)/mutlib/mutscan_analysis.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/mutscan_preprocess.hpp
+mutscan_analysis.o: $(SRCROOT)/mutlib/staden.h
+mutscan_analysis.o: $(SRCROOT)/mutlib/trace.hpp
+mutscan_analysis.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutscan_helper.o: $(PWD)/staden_config.h
+mutscan_helper.o: $(SRCROOT)/Misc/misc.h
+mutscan_helper.o: $(SRCROOT)/Misc/os.h
+mutscan_helper.o: $(SRCROOT)/Misc/xalloc.h
+mutscan_helper.o: $(SRCROOT)/mutlib/mutlib.h
+mutscan_helper.o: $(SRCROOT)/mutlib/staden.h
+mutscan_helper.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutscan_parameters.o: $(PWD)/staden_config.h
+mutscan_parameters.o: $(SRCROOT)/Misc/misc.h
+mutscan_parameters.o: $(SRCROOT)/Misc/os.h
+mutscan_parameters.o: $(SRCROOT)/Misc/xalloc.h
+mutscan_parameters.o: $(SRCROOT)/mutlib/mutlib.h
+mutscan_parameters.o: $(SRCROOT)/mutlib/mutscan_parameters.hpp
+mutscan_parameters.o: $(SRCROOT)/mutlib/parameter.hpp
+mutscan_parameters.o: $(SRCROOT)/mutlib/staden.h
+mutscan_parameters.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutscan_preprocess.o: $(PWD)/staden_config.h
+mutscan_preprocess.o: $(SRCROOT)/Misc/misc.h
+mutscan_preprocess.o: $(SRCROOT)/Misc/os.h
+mutscan_preprocess.o: $(SRCROOT)/Misc/xalloc.h
+mutscan_preprocess.o: $(SRCROOT)/mutlib/array.hpp
+mutscan_preprocess.o: $(SRCROOT)/mutlib/matrix.hpp
+mutscan_preprocess.o: $(SRCROOT)/mutlib/mutlib.h
+mutscan_preprocess.o: $(SRCROOT)/mutlib/mutscan_preprocess.hpp
+mutscan_preprocess.o: $(SRCROOT)/mutlib/staden.h
+mutscan_preprocess.o: $(SRCROOT)/mutlib/trace.hpp
+mutscan_preprocess.o: $(SRCROOT)/seq_utils/dna_utils.h
 mutscan_validate.o: $(PWD)/staden_config.h
+mutscan_validate.o: $(SRCROOT)/Misc/misc.h
+mutscan_validate.o: $(SRCROOT)/Misc/os.h
+mutscan_validate.o: $(SRCROOT)/Misc/xalloc.h
+mutscan_validate.o: $(SRCROOT)/mutlib/mutlib.h
+mutscan_validate.o: $(SRCROOT)/mutlib/mutscan_parameters.hpp
+mutscan_validate.o: $(SRCROOT)/mutlib/parameter.hpp
+mutscan_validate.o: $(SRCROOT)/mutlib/staden.h
+mutscan_validate.o: $(SRCROOT)/mutlib/validate.hpp
+mutscan_validate.o: $(SRCROOT)/seq_utils/dna_utils.h
 muttag.o: $(PWD)/staden_config.h
+muttag.o: $(SRCROOT)/Misc/misc.h
+muttag.o: $(SRCROOT)/Misc/os.h
+muttag.o: $(SRCROOT)/Misc/xalloc.h
+muttag.o: $(SRCROOT)/mutlib/listitem.hpp
+muttag.o: $(SRCROOT)/mutlib/mutlib.h
+muttag.o: $(SRCROOT)/mutlib/muttag.hpp
+muttag.o: $(SRCROOT)/mutlib/staden.h
+muttag.o: $(SRCROOT)/seq_utils/dna_utils.h
+peakcall.o: $(SRCROOT)/mutlib/listitem.hpp
+peakcall.o: $(SRCROOT)/mutlib/peakcall.hpp
 read_matrix.o: $(PWD)/staden_config.h
+read_matrix.o: $(SRCROOT)/Misc/misc.h
+read_matrix.o: $(SRCROOT)/Misc/os.h
+read_matrix.o: $(SRCROOT)/Misc/xalloc.h
+read_matrix.o: $(SRCROOT)/mutlib/read_matrix.h
 sp_align_lib.o: $(PWD)/staden_config.h
+sp_align_lib.o: $(SRCROOT)/Misc/misc.h
+sp_align_lib.o: $(SRCROOT)/Misc/os.h
+sp_align_lib.o: $(SRCROOT)/Misc/xalloc.h
+sp_align_lib.o: $(SRCROOT)/mutlib/read_matrix.h
+sp_align_lib.o: $(SRCROOT)/mutlib/sp_align_lib.h
+sp_align_lib.o: $(SRCROOT)/mutlib/sp_alignment.h
+sp_align_lib.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+sp_align_lib.o: $(SRCROOT)/mutlib/staden.h
+sp_align_lib.o: $(SRCROOT)/seq_utils/dna_utils.h
 sp_alignment.o: $(PWD)/staden_config.h
+sp_alignment.o: $(SRCROOT)/Misc/misc.h
+sp_alignment.o: $(SRCROOT)/Misc/os.h
+sp_alignment.o: $(SRCROOT)/Misc/xalloc.h
+sp_alignment.o: $(SRCROOT)/mutlib/read_matrix.h
+sp_alignment.o: $(SRCROOT)/mutlib/sp_align_lib.h
+sp_alignment.o: $(SRCROOT)/mutlib/sp_alignment.h
+sp_alignment.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+sp_alignment.o: $(SRCROOT)/mutlib/sp_hash_lib.h
+sp_alignment.o: $(SRCROOT)/mutlib/staden.h
+sp_alignment.o: $(SRCROOT)/seq_utils/dna_utils.h
 sp_hash_lib.o: $(PWD)/staden_config.h
+sp_hash_lib.o: $(SRCROOT)/Misc/misc.h
+sp_hash_lib.o: $(SRCROOT)/Misc/os.h
+sp_hash_lib.o: $(SRCROOT)/Misc/xalloc.h
+sp_hash_lib.o: $(SRCROOT)/mutlib/sp_align_lib.h
+sp_hash_lib.o: $(SRCROOT)/mutlib/sp_alignment.h
+sp_hash_lib.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+sp_hash_lib.o: $(SRCROOT)/mutlib/sp_hash_lib.h
+sp_hash_lib.o: $(SRCROOT)/mutlib/staden.h
+sp_hash_lib.o: $(SRCROOT)/seq_utils/dna_utils.h
 sp_matrix.o: $(PWD)/staden_config.h
+sp_matrix.o: $(SRCROOT)/Misc/misc.h
+sp_matrix.o: $(SRCROOT)/Misc/os.h
+sp_matrix.o: $(SRCROOT)/Misc/xalloc.h
+sp_matrix.o: $(SRCROOT)/mutlib/sp_matrix.h
+stringlist.o: $(SRCROOT)/mutlib/stringlist.hpp
 tagarray.o: $(PWD)/staden_config.h
+tagarray.o: $(SRCROOT)/Misc/misc.h
+tagarray.o: $(SRCROOT)/Misc/os.h
+tagarray.o: $(SRCROOT)/Misc/xalloc.h
+tagarray.o: $(SRCROOT)/mutlib/list.hpp
+tagarray.o: $(SRCROOT)/mutlib/listitem.hpp
+tagarray.o: $(SRCROOT)/mutlib/mutlib.h
+tagarray.o: $(SRCROOT)/mutlib/muttag.hpp
+tagarray.o: $(SRCROOT)/mutlib/staden.h
+tagarray.o: $(SRCROOT)/mutlib/tagarray.hpp
+tagarray.o: $(SRCROOT)/seq_utils/dna_utils.h
 trace.o: $(PWD)/staden_config.h
+trace.o: $(SRCROOT)/Misc/misc.h
+trace.o: $(SRCROOT)/Misc/os.h
+trace.o: $(SRCROOT)/Misc/xalloc.h
+trace.o: $(SRCROOT)/mutlib/array.hpp
+trace.o: $(SRCROOT)/mutlib/staden.h
+trace.o: $(SRCROOT)/mutlib/trace.hpp
+trace.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracealign.o: $(PWD)/staden_config.h
+tracealign.o: $(SRCROOT)/Misc/misc.h
+tracealign.o: $(SRCROOT)/Misc/os.h
+tracealign.o: $(SRCROOT)/Misc/xalloc.h
+tracealign.o: $(SRCROOT)/mutlib/align.hpp
+tracealign.o: $(SRCROOT)/mutlib/array.hpp
+tracealign.o: $(SRCROOT)/mutlib/list.hpp
+tracealign.o: $(SRCROOT)/mutlib/listitem.hpp
+tracealign.o: $(SRCROOT)/mutlib/matrix.hpp
+tracealign.o: $(SRCROOT)/mutlib/mutlib.h
+tracealign.o: $(SRCROOT)/mutlib/muttag.hpp
+tracealign.o: $(SRCROOT)/mutlib/peakcall.hpp
+tracealign.o: $(SRCROOT)/mutlib/sp_alignment.h
+tracealign.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+tracealign.o: $(SRCROOT)/mutlib/staden.h
+tracealign.o: $(SRCROOT)/mutlib/tagarray.hpp
+tracealign.o: $(SRCROOT)/mutlib/trace.hpp
+tracealign.o: $(SRCROOT)/mutlib/tracealign.hpp
+tracealign.o: $(SRCROOT)/mutlib/tracealign_cache.hpp
+tracealign.o: $(SRCROOT)/mutlib/tracealign_preprocess.hpp
+tracealign.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracealign_cache.o: $(PWD)/staden_config.h
+tracealign_cache.o: $(SRCROOT)/Misc/misc.h
+tracealign_cache.o: $(SRCROOT)/Misc/os.h
+tracealign_cache.o: $(SRCROOT)/Misc/xalloc.h
+tracealign_cache.o: $(SRCROOT)/mutlib/array.hpp
+tracealign_cache.o: $(SRCROOT)/mutlib/matrix.hpp
+tracealign_cache.o: $(SRCROOT)/mutlib/staden.h
+tracealign_cache.o: $(SRCROOT)/mutlib/trace.hpp
+tracealign_cache.o: $(SRCROOT)/mutlib/tracealign_cache.hpp
+tracealign_cache.o: $(SRCROOT)/mutlib/tracealign_preprocess.hpp
+tracealign_cache.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracealign_helper.o: $(PWD)/staden_config.h
+tracealign_helper.o: $(SRCROOT)/Misc/misc.h
+tracealign_helper.o: $(SRCROOT)/Misc/os.h
+tracealign_helper.o: $(SRCROOT)/Misc/xalloc.h
+tracealign_helper.o: $(SRCROOT)/mutlib/array.hpp
+tracealign_helper.o: $(SRCROOT)/mutlib/matrix.hpp
+tracealign_helper.o: $(SRCROOT)/mutlib/mutlib.h
+tracealign_helper.o: $(SRCROOT)/mutlib/staden.h
+tracealign_helper.o: $(SRCROOT)/mutlib/trace.hpp
+tracealign_helper.o: $(SRCROOT)/mutlib/tracealign_cache.hpp
+tracealign_helper.o: $(SRCROOT)/mutlib/tracealign_preprocess.hpp
+tracealign_helper.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracealign_interpolate.o: $(PWD)/staden_config.h
+tracealign_interpolate.o: $(SRCROOT)/Misc/misc.h
+tracealign_interpolate.o: $(SRCROOT)/Misc/os.h
+tracealign_interpolate.o: $(SRCROOT)/Misc/xalloc.h
+tracealign_interpolate.o: $(SRCROOT)/mutlib/align.hpp
+tracealign_interpolate.o: $(SRCROOT)/mutlib/array.hpp
+tracealign_interpolate.o: $(SRCROOT)/mutlib/matrix.hpp
+tracealign_interpolate.o: $(SRCROOT)/mutlib/sp_alignment.h
+tracealign_interpolate.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+tracealign_interpolate.o: $(SRCROOT)/mutlib/staden.h
+tracealign_interpolate.o: $(SRCROOT)/mutlib/trace.hpp
+tracealign_interpolate.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracealign_preprocess.o: $(PWD)/staden_config.h
+tracealign_preprocess.o: $(SRCROOT)/Misc/misc.h
+tracealign_preprocess.o: $(SRCROOT)/Misc/os.h
+tracealign_preprocess.o: $(SRCROOT)/Misc/xalloc.h
+tracealign_preprocess.o: $(SRCROOT)/mutlib/array.hpp
+tracealign_preprocess.o: $(SRCROOT)/mutlib/basecall.hpp
+tracealign_preprocess.o: $(SRCROOT)/mutlib/staden.h
+tracealign_preprocess.o: $(SRCROOT)/mutlib/trace.hpp
+tracealign_preprocess.o: $(SRCROOT)/mutlib/tracealign_preprocess.hpp
+tracealign_preprocess.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracealign_validate.o: $(PWD)/staden_config.h
+tracealign_validate.o: $(SRCROOT)/Misc/misc.h
+tracealign_validate.o: $(SRCROOT)/Misc/os.h
+tracealign_validate.o: $(SRCROOT)/Misc/xalloc.h
+tracealign_validate.o: $(SRCROOT)/mutlib/mutlib.h
+tracealign_validate.o: $(SRCROOT)/mutlib/staden.h
+tracealign_validate.o: $(SRCROOT)/mutlib/validate.hpp
+tracealign_validate.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracediff.o: $(PWD)/staden_config.h
+tracediff.o: $(SRCROOT)/Misc/misc.h
+tracediff.o: $(SRCROOT)/Misc/os.h
+tracediff.o: $(SRCROOT)/Misc/xalloc.h
+tracediff.o: $(SRCROOT)/mutlib/align.hpp
+tracediff.o: $(SRCROOT)/mutlib/array.hpp
+tracediff.o: $(SRCROOT)/mutlib/list.hpp
+tracediff.o: $(SRCROOT)/mutlib/listitem.hpp
+tracediff.o: $(SRCROOT)/mutlib/matrix.hpp
+tracediff.o: $(SRCROOT)/mutlib/mutlib.h
+tracediff.o: $(SRCROOT)/mutlib/muttag.hpp
+tracediff.o: $(SRCROOT)/mutlib/parameter.hpp
+tracediff.o: $(SRCROOT)/mutlib/sp_alignment.h
+tracediff.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+tracediff.o: $(SRCROOT)/mutlib/staden.h
+tracediff.o: $(SRCROOT)/mutlib/tagarray.hpp
+tracediff.o: $(SRCROOT)/mutlib/trace.hpp
+tracediff.o: $(SRCROOT)/mutlib/tracealign.hpp
+tracediff.o: $(SRCROOT)/mutlib/tracediff.hpp
+tracediff.o: $(SRCROOT)/mutlib/tracediff_parameters.hpp
+tracediff.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracediff_helper.o: $(PWD)/staden_config.h
+tracediff_helper.o: $(SRCROOT)/Misc/misc.h
+tracediff_helper.o: $(SRCROOT)/Misc/os.h
+tracediff_helper.o: $(SRCROOT)/Misc/xalloc.h
+tracediff_helper.o: $(SRCROOT)/mutlib/align.hpp
+tracediff_helper.o: $(SRCROOT)/mutlib/array.hpp
+tracediff_helper.o: $(SRCROOT)/mutlib/listitem.hpp
+tracediff_helper.o: $(SRCROOT)/mutlib/matrix.hpp
+tracediff_helper.o: $(SRCROOT)/mutlib/mutlib.h
+tracediff_helper.o: $(SRCROOT)/mutlib/muttag.hpp
+tracediff_helper.o: $(SRCROOT)/mutlib/sp_alignment.h
+tracediff_helper.o: $(SRCROOT)/mutlib/sp_alignment_structs.h
+tracediff_helper.o: $(SRCROOT)/mutlib/staden.h
+tracediff_helper.o: $(SRCROOT)/mutlib/trace.hpp
+tracediff_helper.o: $(SRCROOT)/mutlib/tracealign.hpp
+tracediff_helper.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracediff_mutations.o: $(PWD)/staden_config.h
+tracediff_mutations.o: $(SRCROOT)/Misc/misc.h
+tracediff_mutations.o: $(SRCROOT)/Misc/os.h
+tracediff_mutations.o: $(SRCROOT)/Misc/xalloc.h
+tracediff_mutations.o: $(SRCROOT)/mutlib/array.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/list.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/listitem.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/mutlib.h
+tracediff_mutations.o: $(SRCROOT)/mutlib/muttag.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/parameter.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/peakcall.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/staden.h
+tracediff_mutations.o: $(SRCROOT)/mutlib/trace.hpp
+tracediff_mutations.o: $(SRCROOT)/mutlib/tracediff_parameters.hpp
+tracediff_mutations.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracediff_parameters.o: $(PWD)/staden_config.h
+tracediff_parameters.o: $(SRCROOT)/Misc/misc.h
+tracediff_parameters.o: $(SRCROOT)/Misc/os.h
+tracediff_parameters.o: $(SRCROOT)/Misc/xalloc.h
+tracediff_parameters.o: $(SRCROOT)/mutlib/mutlib.h
+tracediff_parameters.o: $(SRCROOT)/mutlib/parameter.hpp
+tracediff_parameters.o: $(SRCROOT)/mutlib/staden.h
+tracediff_parameters.o: $(SRCROOT)/mutlib/tracediff_parameters.hpp
+tracediff_parameters.o: $(SRCROOT)/seq_utils/dna_utils.h
 tracediff_validate.o: $(PWD)/staden_config.h
+tracediff_validate.o: $(SRCROOT)/Misc/misc.h
+tracediff_validate.o: $(SRCROOT)/Misc/os.h
+tracediff_validate.o: $(SRCROOT)/Misc/xalloc.h
+tracediff_validate.o: $(SRCROOT)/mutlib/mutlib.h
+tracediff_validate.o: $(SRCROOT)/mutlib/parameter.hpp
+tracediff_validate.o: $(SRCROOT)/mutlib/staden.h
+tracediff_validate.o: $(SRCROOT)/mutlib/tracediff_parameters.hpp
+tracediff_validate.o: $(SRCROOT)/mutlib/validate.hpp
+tracediff_validate.o: $(SRCROOT)/seq_utils/dna_utils.h
 validate.o: $(PWD)/staden_config.h
+validate.o: $(SRCROOT)/Misc/misc.h
+validate.o: $(SRCROOT)/Misc/os.h
+validate.o: $(SRCROOT)/Misc/xalloc.h
+validate.o: $(SRCROOT)/mutlib/mutlib.h
+validate.o: $(SRCROOT)/mutlib/staden.h
+validate.o: $(SRCROOT)/seq_utils/dna_utils.h
diff --git a/polyA_clip/Makefile b/polyA_clip/Makefile
index 01fd95e..6ec6f48 100644
--- a/polyA_clip/Makefile
+++ b/polyA_clip/Makefile
@@ -39,4 +39,13 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it
 
 polyA_clip.o: $(PWD)/staden_config.h
+polyA_clip.o: $(SRCROOT)/Misc/misc.h
+polyA_clip.o: $(SRCROOT)/Misc/os.h
+polyA_clip.o: $(SRCROOT)/Misc/xalloc.h
+polyA_clip.o: $(SRCROOT)/polyA_clip/seqInfo.h
+polyA_clip.o: $(SRCROOT)/seq_utils/dna_utils.h
 seqInfo.o: $(PWD)/staden_config.h
+seqInfo.o: $(SRCROOT)/Misc/misc.h
+seqInfo.o: $(SRCROOT)/Misc/os.h
+seqInfo.o: $(SRCROOT)/Misc/xalloc.h
+seqInfo.o: $(SRCROOT)/polyA_clip/seqInfo.h
diff --git a/prefinish/Makefile b/prefinish/Makefile
index 65f5ec9..489809b 100644
--- a/prefinish/Makefile
+++ b/prefinish/Makefile
@@ -96,12 +96,352 @@ DEPEND_OBJ = $(OBJS)
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
+dust.o: $(SRCROOT)/seq_utils/dna_utils.h
 finish.o: $(PWD)/staden_config.h
+finish.o: $(SRCROOT)/Misc/array.h
+finish.o: $(SRCROOT)/Misc/bitmap.h
+finish.o: $(SRCROOT)/Misc/dstring.h
+finish.o: $(SRCROOT)/Misc/misc.h
+finish.o: $(SRCROOT)/Misc/os.h
+finish.o: $(SRCROOT)/Misc/reg_exp.h
+finish.o: $(SRCROOT)/Misc/xalloc.h
+finish.o: $(SRCROOT)/Misc/xerror.h
+finish.o: $(SRCROOT)/g/freetree.h
+finish.o: $(SRCROOT)/g/g-defs.h
+finish.o: $(SRCROOT)/g/g-error.h
+finish.o: $(SRCROOT)/g/g-filedefs.h
+finish.o: $(SRCROOT)/g/g-os.h
+finish.o: $(SRCROOT)/g/g-struct.h
+finish.o: $(SRCROOT)/gap4/IO1.h
+finish.o: $(SRCROOT)/gap4/consen.h
+finish.o: $(SRCROOT)/gap4/edStructs.h
+finish.o: $(SRCROOT)/gap4/edUtils.h
+finish.o: $(SRCROOT)/gap4/fort.h
+finish.o: $(SRCROOT)/gap4/fortran.h
+finish.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish.o: $(SRCROOT)/gap4/gap-if.h
+finish.o: $(SRCROOT)/gap4/gap_globals.h
+finish.o: $(SRCROOT)/gap4/hash_lib.h
+finish.o: $(SRCROOT)/gap4/io-reg.h
+finish.o: $(SRCROOT)/gap4/io_handle.h
+finish.o: $(SRCROOT)/gap4/io_utils.h
+finish.o: $(SRCROOT)/gap4/list.h
+finish.o: $(SRCROOT)/gap4/list_proc.h
+finish.o: $(SRCROOT)/gap4/primlib.h
+finish.o: $(SRCROOT)/gap4/qual.h
+finish.o: $(SRCROOT)/gap4/tagDefs.h
+finish.o: $(SRCROOT)/gap4/tagUtils.h
+finish.o: $(SRCROOT)/gap4/template.h
+finish.o: $(SRCROOT)/gap4/tkEdNames.h
+finish.o: $(SRCROOT)/gap4/tkEditor.h
+finish.o: $(SRCROOT)/gap4/tman_display.h
+finish.o: $(SRCROOT)/gap4/undo.h
+finish.o: $(SRCROOT)/gap4/vseqs.h
+finish.o: $(SRCROOT)/prefinish/dust.h
+finish.o: $(SRCROOT)/prefinish/finish.h
+finish.o: $(SRCROOT)/prefinish/finish_filter.h
+finish.o: $(SRCROOT)/prefinish/finish_hash.h
+finish.o: $(SRCROOT)/prefinish/finish_long.h
+finish.o: $(SRCROOT)/prefinish/finish_main.h
+finish.o: $(SRCROOT)/prefinish/finish_pcr.h
+finish.o: $(SRCROOT)/prefinish/finish_utils.h
+finish.o: $(SRCROOT)/prefinish/finish_walk.h
+finish.o: $(SRCROOT)/prefinish/gap_cli_arg.h
+finish.o: $(SRCROOT)/primer3/src/dpal.h
+finish.o: $(SRCROOT)/primer3/src/primer3.h
+finish.o: $(SRCROOT)/seq_utils/align_lib.h
+finish.o: $(SRCROOT)/seq_utils/dna_utils.h
+finish.o: $(SRCROOT)/seq_utils/sequence_formats.h
+finish.o: $(SRCROOT)/tk_utils/cli_arg.h
+finish.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+finish.o: $(SRCROOT)/tk_utils/postscript.h
+finish.o: $(SRCROOT)/tk_utils/sheet.h
+finish.o: $(SRCROOT)/tk_utils/tcl_utils.h
+finish.o: $(SRCROOT)/tk_utils/tkSheet.h
+finish.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+finish.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+finish.o: $(SRCROOT)/tk_utils/tkTrace.h
 finish_filter.o: $(PWD)/staden_config.h
+finish_filter.o: $(SRCROOT)/Misc/array.h
+finish_filter.o: $(SRCROOT)/Misc/bitmap.h
+finish_filter.o: $(SRCROOT)/Misc/os.h
+finish_filter.o: $(SRCROOT)/Misc/xalloc.h
+finish_filter.o: $(SRCROOT)/Misc/xerror.h
+finish_filter.o: $(SRCROOT)/g/freetree.h
+finish_filter.o: $(SRCROOT)/g/g-defs.h
+finish_filter.o: $(SRCROOT)/g/g-error.h
+finish_filter.o: $(SRCROOT)/g/g-filedefs.h
+finish_filter.o: $(SRCROOT)/g/g-os.h
+finish_filter.o: $(SRCROOT)/g/g-struct.h
+finish_filter.o: $(SRCROOT)/gap4/IO1.h
+finish_filter.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_filter.o: $(SRCROOT)/gap4/gap-if.h
+finish_filter.o: $(SRCROOT)/gap4/hash_lib.h
+finish_filter.o: $(SRCROOT)/gap4/io_handle.h
+finish_filter.o: $(SRCROOT)/gap4/io_utils.h
+finish_filter.o: $(SRCROOT)/gap4/list.h
+finish_filter.o: $(SRCROOT)/gap4/primlib.h
+finish_filter.o: $(SRCROOT)/gap4/qual.h
+finish_filter.o: $(SRCROOT)/gap4/template.h
+finish_filter.o: $(SRCROOT)/gap4/vseqs.h
+finish_filter.o: $(SRCROOT)/prefinish/dust.h
+finish_filter.o: $(SRCROOT)/prefinish/finish.h
+finish_filter.o: $(SRCROOT)/prefinish/finish_filter.h
+finish_filter.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_filter.o: $(SRCROOT)/primer3/src/dpal.h
+finish_filter.o: $(SRCROOT)/primer3/src/primer3.h
+finish_filter.o: $(SRCROOT)/seq_utils/align_lib.h
+finish_filter.o: $(SRCROOT)/seq_utils/dna_utils.h
+finish_filter.o: $(SRCROOT)/seq_utils/filter_words.h
 finish_hash.o: $(PWD)/staden_config.h
+finish_hash.o: $(SRCROOT)/Misc/misc.h
+finish_hash.o: $(SRCROOT)/Misc/os.h
+finish_hash.o: $(SRCROOT)/Misc/xalloc.h
+finish_hash.o: $(SRCROOT)/gap4/hash_lib.h
+finish_hash.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_hash.o: $(SRCROOT)/seq_utils/align_lib.h
+finish_hash.o: $(SRCROOT)/seq_utils/dna_utils.h
 finish_long.o: $(PWD)/staden_config.h
+finish_long.o: $(SRCROOT)/Misc/array.h
+finish_long.o: $(SRCROOT)/Misc/bitmap.h
+finish_long.o: $(SRCROOT)/Misc/misc.h
+finish_long.o: $(SRCROOT)/Misc/os.h
+finish_long.o: $(SRCROOT)/Misc/xalloc.h
+finish_long.o: $(SRCROOT)/Misc/xerror.h
+finish_long.o: $(SRCROOT)/g/freetree.h
+finish_long.o: $(SRCROOT)/g/g-defs.h
+finish_long.o: $(SRCROOT)/g/g-error.h
+finish_long.o: $(SRCROOT)/g/g-filedefs.h
+finish_long.o: $(SRCROOT)/g/g-os.h
+finish_long.o: $(SRCROOT)/g/g-struct.h
+finish_long.o: $(SRCROOT)/gap4/IO1.h
+finish_long.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_long.o: $(SRCROOT)/gap4/gap-if.h
+finish_long.o: $(SRCROOT)/gap4/hash_lib.h
+finish_long.o: $(SRCROOT)/gap4/io_handle.h
+finish_long.o: $(SRCROOT)/gap4/io_utils.h
+finish_long.o: $(SRCROOT)/gap4/list.h
+finish_long.o: $(SRCROOT)/gap4/primlib.h
+finish_long.o: $(SRCROOT)/gap4/qual.h
+finish_long.o: $(SRCROOT)/gap4/template.h
+finish_long.o: $(SRCROOT)/gap4/vseqs.h
+finish_long.o: $(SRCROOT)/prefinish/finish.h
+finish_long.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_long.o: $(SRCROOT)/prefinish/finish_long.h
+finish_long.o: $(SRCROOT)/prefinish/finish_utils.h
+finish_long.o: $(SRCROOT)/primer3/src/dpal.h
+finish_long.o: $(SRCROOT)/primer3/src/primer3.h
+finish_long.o: $(SRCROOT)/seq_utils/align_lib.h
 finish_main.o: $(PWD)/staden_config.h
+finish_main.o: $(SRCROOT)/Misc/array.h
+finish_main.o: $(SRCROOT)/Misc/bitmap.h
+finish_main.o: $(SRCROOT)/Misc/dstring.h
+finish_main.o: $(SRCROOT)/Misc/misc.h
+finish_main.o: $(SRCROOT)/Misc/os.h
+finish_main.o: $(SRCROOT)/Misc/xalloc.h
+finish_main.o: $(SRCROOT)/Misc/xerror.h
+finish_main.o: $(SRCROOT)/g/freetree.h
+finish_main.o: $(SRCROOT)/g/g-defs.h
+finish_main.o: $(SRCROOT)/g/g-error.h
+finish_main.o: $(SRCROOT)/g/g-filedefs.h
+finish_main.o: $(SRCROOT)/g/g-os.h
+finish_main.o: $(SRCROOT)/g/g-struct.h
+finish_main.o: $(SRCROOT)/gap4/IO1.h
+finish_main.o: $(SRCROOT)/gap4/edStructs.h
+finish_main.o: $(SRCROOT)/gap4/edUtils.h
+finish_main.o: $(SRCROOT)/gap4/find_fragments.h
+finish_main.o: $(SRCROOT)/gap4/fort.h
+finish_main.o: $(SRCROOT)/gap4/fortran.h
+finish_main.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_main.o: $(SRCROOT)/gap4/gap-if.h
+finish_main.o: $(SRCROOT)/gap4/gap_globals.h
+finish_main.o: $(SRCROOT)/gap4/hash_lib.h
+finish_main.o: $(SRCROOT)/gap4/io-reg.h
+finish_main.o: $(SRCROOT)/gap4/io_handle.h
+finish_main.o: $(SRCROOT)/gap4/io_utils.h
+finish_main.o: $(SRCROOT)/gap4/list.h
+finish_main.o: $(SRCROOT)/gap4/primlib.h
+finish_main.o: $(SRCROOT)/gap4/qual.h
+finish_main.o: $(SRCROOT)/gap4/tagDefs.h
+finish_main.o: $(SRCROOT)/gap4/tagUtils.h
+finish_main.o: $(SRCROOT)/gap4/template.h
+finish_main.o: $(SRCROOT)/gap4/tkEdNames.h
+finish_main.o: $(SRCROOT)/gap4/tkEditor.h
+finish_main.o: $(SRCROOT)/gap4/tman_display.h
+finish_main.o: $(SRCROOT)/gap4/undo.h
+finish_main.o: $(SRCROOT)/gap4/vseqs.h
+finish_main.o: $(SRCROOT)/prefinish/finish.h
+finish_main.o: $(SRCROOT)/prefinish/finish_filter.h
+finish_main.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_main.o: $(SRCROOT)/prefinish/finish_long.h
+finish_main.o: $(SRCROOT)/prefinish/finish_reverse.h
+finish_main.o: $(SRCROOT)/prefinish/finish_utils.h
+finish_main.o: $(SRCROOT)/prefinish/finish_walk.h
+finish_main.o: $(SRCROOT)/primer3/src/dpal.h
+finish_main.o: $(SRCROOT)/primer3/src/primer3.h
+finish_main.o: $(SRCROOT)/seq_utils/align_lib.h
+finish_main.o: $(SRCROOT)/tk_utils/cli_arg.h
+finish_main.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+finish_main.o: $(SRCROOT)/tk_utils/postscript.h
+finish_main.o: $(SRCROOT)/tk_utils/sheet.h
+finish_main.o: $(SRCROOT)/tk_utils/tcl_utils.h
+finish_main.o: $(SRCROOT)/tk_utils/tkSheet.h
+finish_main.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+finish_main.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+finish_main.o: $(SRCROOT)/tk_utils/tkTrace.h
 finish_pcr.o: $(PWD)/staden_config.h
+finish_pcr.o: $(SRCROOT)/Misc/array.h
+finish_pcr.o: $(SRCROOT)/Misc/bitmap.h
+finish_pcr.o: $(SRCROOT)/Misc/dstring.h
+finish_pcr.o: $(SRCROOT)/Misc/misc.h
+finish_pcr.o: $(SRCROOT)/Misc/os.h
+finish_pcr.o: $(SRCROOT)/Misc/xalloc.h
+finish_pcr.o: $(SRCROOT)/Misc/xerror.h
+finish_pcr.o: $(SRCROOT)/g/freetree.h
+finish_pcr.o: $(SRCROOT)/g/g-defs.h
+finish_pcr.o: $(SRCROOT)/g/g-error.h
+finish_pcr.o: $(SRCROOT)/g/g-filedefs.h
+finish_pcr.o: $(SRCROOT)/g/g-os.h
+finish_pcr.o: $(SRCROOT)/g/g-struct.h
+finish_pcr.o: $(SRCROOT)/gap4/IO1.h
+finish_pcr.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_pcr.o: $(SRCROOT)/gap4/gap-if.h
+finish_pcr.o: $(SRCROOT)/gap4/gap_globals.h
+finish_pcr.o: $(SRCROOT)/gap4/hash_lib.h
+finish_pcr.o: $(SRCROOT)/gap4/io_handle.h
+finish_pcr.o: $(SRCROOT)/gap4/io_utils.h
+finish_pcr.o: $(SRCROOT)/gap4/list.h
+finish_pcr.o: $(SRCROOT)/gap4/primlib.h
+finish_pcr.o: $(SRCROOT)/gap4/qual.h
+finish_pcr.o: $(SRCROOT)/gap4/template.h
+finish_pcr.o: $(SRCROOT)/gap4/vseqs.h
+finish_pcr.o: $(SRCROOT)/prefinish/finish.h
+finish_pcr.o: $(SRCROOT)/prefinish/finish_filter.h
+finish_pcr.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_pcr.o: $(SRCROOT)/prefinish/finish_pcr.h
+finish_pcr.o: $(SRCROOT)/prefinish/finish_utils.h
+finish_pcr.o: $(SRCROOT)/prefinish/gap_cli_arg.h
+finish_pcr.o: $(SRCROOT)/primer3/src/dpal.h
+finish_pcr.o: $(SRCROOT)/primer3/src/primer3.h
+finish_pcr.o: $(SRCROOT)/seq_utils/align_lib.h
+finish_pcr.o: $(SRCROOT)/seq_utils/dna_utils.h
+finish_pcr.o: $(SRCROOT)/tk_utils/cli_arg.h
+finish_pcr.o: $(SRCROOT)/tk_utils/tcl_utils.h
+finish_pcr.o: $(SRCROOT)/tk_utils/text_output.h
 finish_reverse.o: $(PWD)/staden_config.h
+finish_reverse.o: $(SRCROOT)/Misc/array.h
+finish_reverse.o: $(SRCROOT)/Misc/bitmap.h
+finish_reverse.o: $(SRCROOT)/Misc/misc.h
+finish_reverse.o: $(SRCROOT)/Misc/os.h
+finish_reverse.o: $(SRCROOT)/Misc/xalloc.h
+finish_reverse.o: $(SRCROOT)/Misc/xerror.h
+finish_reverse.o: $(SRCROOT)/g/freetree.h
+finish_reverse.o: $(SRCROOT)/g/g-defs.h
+finish_reverse.o: $(SRCROOT)/g/g-error.h
+finish_reverse.o: $(SRCROOT)/g/g-filedefs.h
+finish_reverse.o: $(SRCROOT)/g/g-os.h
+finish_reverse.o: $(SRCROOT)/g/g-struct.h
+finish_reverse.o: $(SRCROOT)/gap4/IO1.h
+finish_reverse.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_reverse.o: $(SRCROOT)/gap4/gap-if.h
+finish_reverse.o: $(SRCROOT)/gap4/hash_lib.h
+finish_reverse.o: $(SRCROOT)/gap4/io_handle.h
+finish_reverse.o: $(SRCROOT)/gap4/io_utils.h
+finish_reverse.o: $(SRCROOT)/gap4/list.h
+finish_reverse.o: $(SRCROOT)/gap4/primlib.h
+finish_reverse.o: $(SRCROOT)/gap4/qual.h
+finish_reverse.o: $(SRCROOT)/gap4/template.h
+finish_reverse.o: $(SRCROOT)/gap4/vseqs.h
+finish_reverse.o: $(SRCROOT)/prefinish/finish.h
+finish_reverse.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_reverse.o: $(SRCROOT)/prefinish/finish_reverse.h
+finish_reverse.o: $(SRCROOT)/prefinish/finish_utils.h
+finish_reverse.o: $(SRCROOT)/primer3/src/dpal.h
+finish_reverse.o: $(SRCROOT)/primer3/src/primer3.h
+finish_reverse.o: $(SRCROOT)/seq_utils/align_lib.h
 finish_utils.o: $(PWD)/staden_config.h
+finish_utils.o: $(SRCROOT)/Misc/array.h
+finish_utils.o: $(SRCROOT)/Misc/bitmap.h
+finish_utils.o: $(SRCROOT)/Misc/dstring.h
+finish_utils.o: $(SRCROOT)/Misc/misc.h
+finish_utils.o: $(SRCROOT)/Misc/os.h
+finish_utils.o: $(SRCROOT)/Misc/xalloc.h
+finish_utils.o: $(SRCROOT)/Misc/xerror.h
+finish_utils.o: $(SRCROOT)/g/freetree.h
+finish_utils.o: $(SRCROOT)/g/g-defs.h
+finish_utils.o: $(SRCROOT)/g/g-error.h
+finish_utils.o: $(SRCROOT)/g/g-filedefs.h
+finish_utils.o: $(SRCROOT)/g/g-os.h
+finish_utils.o: $(SRCROOT)/g/g-struct.h
+finish_utils.o: $(SRCROOT)/gap4/IO1.h
+finish_utils.o: $(SRCROOT)/gap4/edStructs.h
+finish_utils.o: $(SRCROOT)/gap4/edUtils.h
+finish_utils.o: $(SRCROOT)/gap4/fort.h
+finish_utils.o: $(SRCROOT)/gap4/fortran.h
+finish_utils.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_utils.o: $(SRCROOT)/gap4/gap-if.h
+finish_utils.o: $(SRCROOT)/gap4/hash_lib.h
+finish_utils.o: $(SRCROOT)/gap4/io-reg.h
+finish_utils.o: $(SRCROOT)/gap4/io_handle.h
+finish_utils.o: $(SRCROOT)/gap4/io_utils.h
+finish_utils.o: $(SRCROOT)/gap4/list.h
+finish_utils.o: $(SRCROOT)/gap4/primlib.h
+finish_utils.o: $(SRCROOT)/gap4/qual.h
+finish_utils.o: $(SRCROOT)/gap4/tagDefs.h
+finish_utils.o: $(SRCROOT)/gap4/tagUtils.h
+finish_utils.o: $(SRCROOT)/gap4/template.h
+finish_utils.o: $(SRCROOT)/gap4/tkEdNames.h
+finish_utils.o: $(SRCROOT)/gap4/tkEditor.h
+finish_utils.o: $(SRCROOT)/gap4/tman_display.h
+finish_utils.o: $(SRCROOT)/gap4/undo.h
+finish_utils.o: $(SRCROOT)/gap4/vseqs.h
+finish_utils.o: $(SRCROOT)/prefinish/finish.h
+finish_utils.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_utils.o: $(SRCROOT)/prefinish/finish_utils.h
+finish_utils.o: $(SRCROOT)/primer3/src/dpal.h
+finish_utils.o: $(SRCROOT)/primer3/src/primer3.h
+finish_utils.o: $(SRCROOT)/seq_utils/align_lib.h
+finish_utils.o: $(SRCROOT)/tk_utils/cli_arg.h
+finish_utils.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+finish_utils.o: $(SRCROOT)/tk_utils/postscript.h
+finish_utils.o: $(SRCROOT)/tk_utils/sheet.h
+finish_utils.o: $(SRCROOT)/tk_utils/tkSheet.h
+finish_utils.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+finish_utils.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+finish_utils.o: $(SRCROOT)/tk_utils/tkTrace.h
 finish_walk.o: $(PWD)/staden_config.h
+finish_walk.o: $(SRCROOT)/Misc/array.h
+finish_walk.o: $(SRCROOT)/Misc/bitmap.h
+finish_walk.o: $(SRCROOT)/Misc/misc.h
+finish_walk.o: $(SRCROOT)/Misc/os.h
+finish_walk.o: $(SRCROOT)/Misc/xalloc.h
+finish_walk.o: $(SRCROOT)/Misc/xerror.h
+finish_walk.o: $(SRCROOT)/g/freetree.h
+finish_walk.o: $(SRCROOT)/g/g-defs.h
+finish_walk.o: $(SRCROOT)/g/g-error.h
+finish_walk.o: $(SRCROOT)/g/g-filedefs.h
+finish_walk.o: $(SRCROOT)/g/g-os.h
+finish_walk.o: $(SRCROOT)/g/g-struct.h
+finish_walk.o: $(SRCROOT)/gap4/IO1.h
+finish_walk.o: $(SRCROOT)/gap4/gap-dbstruct.h
+finish_walk.o: $(SRCROOT)/gap4/gap-if.h
+finish_walk.o: $(SRCROOT)/gap4/gap_globals.h
+finish_walk.o: $(SRCROOT)/gap4/hash_lib.h
+finish_walk.o: $(SRCROOT)/gap4/io_handle.h
+finish_walk.o: $(SRCROOT)/gap4/io_utils.h
+finish_walk.o: $(SRCROOT)/gap4/list.h
+finish_walk.o: $(SRCROOT)/gap4/primlib.h
+finish_walk.o: $(SRCROOT)/gap4/qual.h
+finish_walk.o: $(SRCROOT)/gap4/template.h
+finish_walk.o: $(SRCROOT)/gap4/vseqs.h
+finish_walk.o: $(SRCROOT)/prefinish/finish.h
+finish_walk.o: $(SRCROOT)/prefinish/finish_filter.h
+finish_walk.o: $(SRCROOT)/prefinish/finish_hash.h
+finish_walk.o: $(SRCROOT)/prefinish/finish_utils.h
+finish_walk.o: $(SRCROOT)/prefinish/finish_walk.h
+finish_walk.o: $(SRCROOT)/primer3/src/dpal.h
+finish_walk.o: $(SRCROOT)/primer3/src/primer3.h
+finish_walk.o: $(SRCROOT)/seq_utils/align_lib.h
+finish_walk.o: $(SRCROOT)/seq_utils/dna_utils.h
+finish_walk.o: $(SRCROOT)/seq_utils/search_utils.h
+finish_walk.o: $(SRCROOT)/tk_utils/tcl_utils.h
diff --git a/primer3/src/ntdpal_main.c b/primer3/src/ntdpal_main.c
index 30f22b5..122752a 100644
--- a/primer3/src/ntdpal_main.c
+++ b/primer3/src/ntdpal_main.c
@@ -33,7 +33,7 @@ main(argc, argv)
       "    creating or widening a gap respectively (<gval> and <lval> are\n"
       "    subtracted from the output score).\n"
       "-a causes the scoring matrix to be modified by dpal_set_ambiguity_codes.\n"
-      "-e causes the end postion of the alignment in both sequences to\n"
+      "-e causes the end position of the alignment in both sequences to\n"
       "   be printed.  Do not confuse with the 'e' <mode>\n"
       "-h use a different scoring matrix: G and C matches = 3, A and T = 2\n"
       "-p causes the alignment to be displayed.\n"
diff --git a/primer3/src/primer3_lib.c b/primer3/src/primer3_lib.c
index 157bed3..e345610 100644
--- a/primer3/src/primer3_lib.c
+++ b/primer3/src/primer3_lib.c
@@ -2888,7 +2888,7 @@ const primer_args *pa;
  *  
  * Note: we don't insist that the start codon be ATG, since in some
  * cases the caller will not have the full sequence in 's', nor even
- * know the postion of the start codon relative to s.
+ * know the position of the start codon relative to s.
  */
 static int
 find_stop_codon(const char *s, int start, int direction)
diff --git a/qclip/Makefile b/qclip/Makefile
index 02eead8..6590560 100644
--- a/qclip/Makefile
+++ b/qclip/Makefile
@@ -34,5 +34,18 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 consen.o: $(PWD)/staden_config.h
+consen.o: $(SRCROOT)/Misc/misc.h
+consen.o: $(SRCROOT)/Misc/os.h
+consen.o: $(SRCROOT)/Misc/xalloc.h
+consen.o: $(SRCROOT)/qclip/consen.h
 qclip.o: $(PWD)/staden_config.h
+qclip.o: $(SRCROOT)/Misc/misc.h
+qclip.o: $(SRCROOT)/Misc/os.h
+qclip.o: $(SRCROOT)/Misc/xalloc.h
+qclip.o: $(SRCROOT)/qclip/consen.h
+qclip.o: $(SRCROOT)/qclip/seqInfo.h
 seqInfo.o: $(PWD)/staden_config.h
+seqInfo.o: $(SRCROOT)/Misc/misc.h
+seqInfo.o: $(SRCROOT)/Misc/os.h
+seqInfo.o: $(SRCROOT)/Misc/xalloc.h
+seqInfo.o: $(SRCROOT)/qclip/seqInfo.h
diff --git a/screen_seq/Makefile b/screen_seq/Makefile
index 524030e..a63b421 100644
--- a/screen_seq/Makefile
+++ b/screen_seq/Makefile
@@ -36,3 +36,8 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 screen_seq.o: $(PWD)/staden_config.h
+screen_seq.o: $(SRCROOT)/Misc/getfile.h
+screen_seq.o: $(SRCROOT)/Misc/misc.h
+screen_seq.o: $(SRCROOT)/Misc/os.h
+screen_seq.o: $(SRCROOT)/Misc/xalloc.h
+screen_seq.o: $(SRCROOT)/seq_utils/dna_utils.h
diff --git a/seq_utils/Makefile b/seq_utils/Makefile
index 2aab527..c6a1c69 100644
--- a/seq_utils/Makefile
+++ b/seq_utils/Makefile
@@ -44,7 +44,8 @@ OBJS = \
 
 SU_LIBS = \
 	$(TEXTUTILS_LIB) \
-	$(MISC_LIB)
+	$(MISC_LIB) \
+	$(MATH_LIB)
 
 #
 # Main dependency
@@ -75,16 +76,98 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 align.o: $(PWD)/staden_config.h
+align.o: $(SRCROOT)/Misc/misc.h
+align.o: $(SRCROOT)/Misc/os.h
+align.o: $(SRCROOT)/Misc/xalloc.h
+align.o: $(SRCROOT)/seq_utils/align.h
+align.o: $(SRCROOT)/seq_utils/align_lib_old.h
 align_lib.o: $(PWD)/staden_config.h
+align_lib.o: $(SRCROOT)/Misc/misc.h
+align_lib.o: $(SRCROOT)/Misc/os.h
+align_lib.o: $(SRCROOT)/Misc/xalloc.h
+align_lib.o: $(SRCROOT)/seq_utils/align_lib.h
+align_lib.o: $(SRCROOT)/seq_utils/dna_utils.h
+align_lib.o: $(SRCROOT)/seq_utils/read_matrix.h
 align_lib_old.o: $(PWD)/staden_config.h
+align_lib_old.o: $(SRCROOT)/Misc/misc.h
+align_lib_old.o: $(SRCROOT)/Misc/os.h
+align_lib_old.o: $(SRCROOT)/Misc/xalloc.h
+align_lib_old.o: $(SRCROOT)/seq_utils/align.h
+align_lib_old.o: $(SRCROOT)/seq_utils/align_lib_old.h
 align_ss.o: $(PWD)/staden_config.h
+align_ss.o: $(SRCROOT)/Misc/misc.h
+align_ss.o: $(SRCROOT)/Misc/os.h
+align_ss.o: $(SRCROOT)/Misc/xalloc.h
+align_ss.o: $(SRCROOT)/seq_utils/align.h
+align_ss.o: $(SRCROOT)/seq_utils/align_lib_old.h
 align_ss2.o: $(PWD)/staden_config.h
+align_ss2.o: $(SRCROOT)/Misc/misc.h
+align_ss2.o: $(SRCROOT)/Misc/os.h
+align_ss2.o: $(SRCROOT)/Misc/xalloc.h
+align_ss2.o: $(SRCROOT)/seq_utils/align.h
+align_ss2.o: $(SRCROOT)/seq_utils/align_lib_old.h
 align_sv.o: $(PWD)/staden_config.h
+align_sv.o: $(SRCROOT)/Misc/misc.h
+align_sv.o: $(SRCROOT)/Misc/os.h
+align_sv.o: $(SRCROOT)/Misc/xalloc.h
+align_sv.o: $(SRCROOT)/seq_utils/align.h
+align_sv.o: $(SRCROOT)/seq_utils/align_lib_old.h
+align_sv.o: $(SRCROOT)/seq_utils/uascii.gbl
 base_comp.o: $(PWD)/staden_config.h
+base_comp.o: $(SRCROOT)/Misc/misc.h
+base_comp.o: $(SRCROOT)/Misc/os.h
+base_comp.o: $(SRCROOT)/Misc/xalloc.h
+base_comp.o: $(SRCROOT)/seq_utils/base_comp.h
+base_comp.o: $(SRCROOT)/seq_utils/dna_utils.h
+base_comp.o: $(SRCROOT)/seq_utils/edge.h
 dna_utils.o: $(PWD)/staden_config.h
+dna_utils.o: $(SRCROOT)/Misc/FtoC.h
+dna_utils.o: $(SRCROOT)/Misc/misc.h
+dna_utils.o: $(SRCROOT)/Misc/os.h
+dna_utils.o: $(SRCROOT)/Misc/xalloc.h
+dna_utils.o: $(SRCROOT)/seq_utils/dna_utils.h
 edge.o: $(PWD)/staden_config.h
+edge.o: $(SRCROOT)/Misc/misc.h
+edge.o: $(SRCROOT)/Misc/os.h
+edge.o: $(SRCROOT)/Misc/xalloc.h
+edge.o: $(SRCROOT)/seq_utils/dna_utils.h
+filter_words.o: $(SRCROOT)/seq_utils/dna_utils.h
+filter_words.o: $(SRCROOT)/seq_utils/filter_words.h
 genetic_code.o: $(PWD)/staden_config.h
+genetic_code.o: $(SRCROOT)/Misc/array_arith.h
+genetic_code.o: $(SRCROOT)/Misc/misc.h
+genetic_code.o: $(SRCROOT)/Misc/os.h
+genetic_code.o: $(SRCROOT)/Misc/xalloc.h
+genetic_code.o: $(SRCROOT)/seq_utils/dna_utils.h
+genetic_code.o: $(SRCROOT)/seq_utils/genetic_code.h
+genetic_code.o: $(SRCROOT)/text_utils/text_output.h
 open_reading_frames.o: $(PWD)/staden_config.h
+open_reading_frames.o: $(SRCROOT)/Misc/array_arith.h
+open_reading_frames.o: $(SRCROOT)/Misc/misc.h
+open_reading_frames.o: $(SRCROOT)/Misc/os.h
+open_reading_frames.o: $(SRCROOT)/Misc/xalloc.h
+open_reading_frames.o: $(SRCROOT)/seq_utils/dna_utils.h
+open_reading_frames.o: $(SRCROOT)/seq_utils/genetic_code.h
+open_reading_frames.o: $(SRCROOT)/text_utils/text_output.h
 read_matrix.o: $(PWD)/staden_config.h
+read_matrix.o: $(SRCROOT)/Misc/misc.h
+read_matrix.o: $(SRCROOT)/Misc/os.h
+read_matrix.o: $(SRCROOT)/Misc/xalloc.h
+read_matrix.o: $(SRCROOT)/seq_utils/read_matrix.h
 renz_utils.o: $(PWD)/staden_config.h
+renz_utils.o: $(SRCROOT)/Misc/getfile.h
+renz_utils.o: $(SRCROOT)/Misc/misc.h
+renz_utils.o: $(SRCROOT)/Misc/os.h
+renz_utils.o: $(SRCROOT)/Misc/xalloc.h
+renz_utils.o: $(SRCROOT)/seq_utils/dna_utils.h
+renz_utils.o: $(SRCROOT)/seq_utils/renz_utils.h
+scramble.o: $(SRCROOT)/seq_utils/sequence_formats.h
+search_utils.o: $(SRCROOT)/seq_utils/search_utils.h
 sequence_formats.o: $(PWD)/staden_config.h
+sequence_formats.o: $(SRCROOT)/Misc/array.h
+sequence_formats.o: $(SRCROOT)/Misc/getfile.h
+sequence_formats.o: $(SRCROOT)/Misc/misc.h
+sequence_formats.o: $(SRCROOT)/Misc/os.h
+sequence_formats.o: $(SRCROOT)/Misc/xalloc.h
+sequence_formats.o: $(SRCROOT)/Misc/xerror.h
+sequence_formats.o: $(SRCROOT)/seq_utils/sequence_formats.h
diff --git a/seq_utils/align_lib.c b/seq_utils/align_lib.c
index 1c06076..959401b 100644
--- a/seq_utils/align_lib.c
+++ b/seq_utils/align_lib.c
@@ -1,3 +1,13 @@
+/*
+ * TODO:
+ *
+ * - Rationalise the mix of non-linear scoring functions in
+ *   scale_malign_scores.
+ *
+ * - Add quality values and use in get_malign_counts. Thus bad quality bases
+ *   count for less in consensus vector.
+ */
+
 #include <errno.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -468,11 +478,13 @@ int **create_malign_counts(int length, int depth) {
  */
 void malign_insert_scores(MALIGN *malign, int pos, int size) {
     int i;
+    int st = malign->start;
 
     /* -ve size indicates a deletion. Can it ever occur? */
 
     /* printf("\nConsensus insert at %d + %d\n", pos, size); */
 
+    pos -= st;
     if (pos >= malign->length) {
 	size += pos - malign->length + 1;
 	pos = malign->length-1;
@@ -493,7 +505,7 @@ void malign_insert_scores(MALIGN *malign, int pos, int size) {
     memmove(&malign->scores[pos+size], &malign->scores[pos],
 	    sizeof(malign->scores[0]) * (malign->length - pos));
     for (i = pos; i < pos + size; i++) {
-	malign->scores[i] = (int *)calloc(malign->charset_size, sizeof(int));
+	malign->scores[i] = (int *)calloc(malign->charset_size,sizeof(int));
     }
 
     /* Shuffle along consensus */
@@ -511,6 +523,7 @@ void malign_insert_scores(MALIGN *malign, int pos, int size) {
     }
 
     malign->length += size;
+    malign->end    += size;
 }
 
 /*
@@ -521,6 +534,7 @@ void malign_insert_scores(MALIGN *malign, int pos, int size) {
 void malign_remove_contigl(MALIGN *malign, CONTIGL *previous, CONTIGL *del) {
     int i, j;
     int start, end;
+    int st = malign->start;
     char *seq;
 
     start = del->mseg->offset;
@@ -532,7 +546,7 @@ void malign_remove_contigl(MALIGN *malign, CONTIGL *previous, CONTIGL *del) {
     else
 	malign->contigl = del->next;
 
-    for (j = start, i = 0; j <= end; i++, j++) {
+    for (j = start-st, i = 0; j <= end-st; i++, j++) {
 	int c = malign_lookup[seq[i]];
 	malign->counts[j][c]--;
     }
@@ -544,6 +558,7 @@ void malign_remove_contigl(MALIGN *malign, CONTIGL *previous, CONTIGL *del) {
 void malign_add_contigl(MALIGN *malign, CONTIGL *previous, CONTIGL *add) {
     int i, j;
     int start, end;
+    int st = malign->start;
 
     start = add->mseg->offset;
     end = add->mseg->offset + add->mseg->length-1;
@@ -556,7 +571,7 @@ void malign_add_contigl(MALIGN *malign, CONTIGL *previous, CONTIGL *add) {
 	malign->contigl = add;
     }
 
-    for (j = start, i = 0; i < add->mseg->length; i++, j++) {
+    for (j = start-st, i = 0; i < add->mseg->length; i++, j++) {
 	int c = malign_lookup[add->mseg->seq[i]];
 	malign->counts[j][c]++;
     }
@@ -593,11 +608,12 @@ void malign_recalc_scores(MALIGN *malign, int start, int end) {
 void get_malign_counts (MALIGN *malign, int start, int end) {
     CONTIGL *t;
     int i,j,k,l;
+    int st = malign->start;
 
     /* Zero */
     for (i=start; i<=end; i++) {
 	for (j=0; j<malign->charset_size; j++) {
-	    malign->counts[i][j] = 0;
+	    malign->counts[i-st][j] = 0;
 	}
     }
 
@@ -611,28 +627,36 @@ void get_malign_counts (MALIGN *malign, int start, int end) {
 	    if (k > end)
 		break;
 	    l = malign_lookup[(int)(t->mseg->seq[j])];
-	    malign->counts[k][l]++;
+	    malign->counts[k-st][l]++;
+	}
+    }
+
+    /* Minor inc for any non-N base */
+    for (i=start; i<=end; i++) {
+	for (j=0; j<4; j++) {
+	    malign->counts[i-st][j]++;
 	}
     }
 }
 
 void get_malign_consensus(MALIGN *malign, int start, int end) {
-  int i,j,k;
+  int i,j,k, st;
   char *s;
 
   /* must be run after get_malign_scores */
 
   s = malign->consensus;
   k = malign->charset_size;
+  st = malign->start;
   for(i=start;i<=end;i++) {
       int top = 0;
-      s[i] = '-';
+      s[i-st] = '-';
       for(j = 0; j < k; j++) {
 	  /* Most common base call becomes the consensus */
-	  int sc = malign->counts[i][j];
+	  int sc = malign->counts[i-st][j];
 	  if (top < sc) {
 	      top = sc;
-	      s[i] = malign->charset[j];
+	      s[i-st] = malign->charset[j];
 	  }
       }
   }
@@ -640,10 +664,12 @@ void get_malign_consensus(MALIGN *malign, int start, int end) {
 
 void print_malign_counts(MALIGN *malign) {
   int i,j;
+  int st = malign->start;
+
   for(i=0;i<malign->length;i++) {
-      printf("%04d: ", i);
+      printf("%04d: ", i+st);
       for(j=0;j<malign->charset_size;j++) {
-	  printf(" %+4d ",malign->counts[i][j]);
+	  printf(" %+4d ",malign->counts[i-st][j]);
       }
       printf("\n");
   }
@@ -652,8 +678,10 @@ void print_malign_counts(MALIGN *malign) {
 
 void print_malign_scores(MALIGN *malign) {
   int i,j;
+  int st = malign->start;
+
   for(i=0;i<malign->length;i++) {
-      printf("%04d: ", i);
+      printf("%04d: ", i+st);
       for(j=0;j<malign->charset_size;j++) {
 	  printf(" %+4d ",malign->scores[i][j]);
       }
@@ -662,90 +690,109 @@ void print_malign_scores(MALIGN *malign) {
   printf("\n");
 }
 
+//#define GAPM 130
+//#define GAPM 140
+#define GAPM 180
+//#define GAPM 280
+
 void scale_malign_scores(MALIGN *malign, int start, int end) {
   int i,j;
+  int st = malign->start;
+
   /* in the alignment routine all these values are added:
    * ie score is score + malign->scores[i][j];
    * even when scores[i][j] is a gap penalty.
    * to calculate the score j = seq2[row-1]
    */
 
-  /* An update on Rodger's where the score incorporates positive from match
-   * with negative from mismatches
-   */
-#if 0
-  int k = malign->matrix[0][1];
-  for(i=start;i<=end;i++) {
-      for (l=j=0;j<malign->charset_size;j++) {
-	  l += malign->counts[i][j];
-      }
-      for(j=0;j<malign->charset_size;j++) {
-	  if (malign->counts[i][j]) {
-	      malign->scores[i][j] =
-		  malign->counts[i][j] * malign->matrix[j][j] +
-		  k*(l - malign->counts[i][j]);
-	  } else {
-	      malign->scores[i][j] = k*l;
-	  }
-      }
-  }
-#endif
+#define OFF 32
 
+  // Our cached non-linear transformation
+  static int T1[130] = {0}, T2[130] = {0};
+  int *t2;
+  if (T1[10] == 0) {
+      for (i = 0; i <= 128; i++) {
+	  T1[i] = 128*(sinh(6*(128-i)/128.0-3)/10.02+1)/2;
+	  T2[i] = 28*(4.853-log(i));
 
-  /* Simple unit based scores with 0 = perfect 1 = wrong. Based on ReAligner */
-  /* Scale by 100 to fit in integers */
-#if 1
+	  //T1[i] = T2[i] = (5*128)/(i+5);
+	  //T1[i] = T2[i] = 138*i/(10+i);
 
-//#define OLD_MODE
-#ifdef OLD_MODE
-  for(i=start;i<=end;i++) {
-      int t = 0;
-      double s = 0;
-      int max = 0;
-      for (j = 0; j < malign->charset_size; j++) {
-	  t += malign->counts[i][j];
-	  if (max < malign->counts[i][j])
-	      max = malign->counts[i][j];
+	  // GACCTTTTTCTTTTCGTTTCTATTCTTTTCTTTTCTTTTCGTTTCTATTCT*TTTCTTT*TCTT***TTTTTTTTTGTTCATCTTTCCTGTTTCATG
+	  // works with large window size
+	  //T2[i] = 128/(i+1);  //G(TCstuff)G
       }
-      if (t) {
-	  for(j=0;j<malign->charset_size;j++) {
-	      s = 0.5 * (1 - malign->counts[i][j] / (double)t);
-	      if (malign->counts[i][j] != max)
-		  s += 0.5;
-	      malign->scores[i][j] = s * 100;
-	  }
+  }
+
+  t2 = malign->gap_extend ? T1 : T2;
+  for(i=start;i<=end;i++) {
+      double t = 0;
+
+      t += malign->counts[i-st][0];
+      t += malign->counts[i-st][1];
+      t += malign->counts[i-st][2];
+      t += malign->counts[i-st][3];
+      t += malign->counts[i-st][4];
+      t += malign->counts[i-st][5];
+
+      if (t > 0) {
+	  t = 128/t;
+	  malign->scores[i-st][0] =
+	      T1[(int)(malign->counts[i-st][0]*t)+1] - OFF;
+	  malign->scores[i-st][1] =
+	      T1[(int)(malign->counts[i-st][1]*t)+1] - OFF;
+	  malign->scores[i-st][2] =
+	      T1[(int)(malign->counts[i-st][2]*t)+1] - OFF;
+	  malign->scores[i-st][3] =
+	      T1[(int)(malign->counts[i-st][3]*t)+1] - OFF;
+	  malign->scores[i-st][4] =
+	      t2[(int)(malign->counts[i-st][4]*t)+1] - OFF;
+	  malign->scores[i-st][5] =
+	      T1[(int)(malign->counts[i-st][5]*t)+1] - OFF;
+
 	  /* Penalty for gaps is marginally higher */
-	  malign->scores[i][5] *= 1.01;
+	  malign->scores[i-st][4]+=OFF+1;
+
+	  /* Seq against N in cons is to be deterred */
+	  malign->scores[i-st][5]=GAPM-1;
       } else {
-	  for(j=0;j<malign->charset_size;j++) {
-	      malign->scores[i][j] = 0;
-	  }
+	  malign->scores[i-st][0] = 0;
+	  malign->scores[i-st][1] = 0;
+	  malign->scores[i-st][2] = 0;
+	  malign->scores[i-st][3] = 0;
+	  malign->scores[i-st][4] = GAPM;
+	  malign->scores[i-st][5] = GAPM-1;
       }
   }
-#else
+
+#if 0
+  /* Old linear scores */
   for(i=start;i<=end;i++) {
-      int t = 0, max = 0, s;
+      int t = 0;
 
       for (j = 0; j < malign->charset_size; j++) {
-	  t += malign->counts[i][j];
-	  if (max < malign->counts[i][j])
-	      max = malign->counts[i][j];
+	  t += malign->counts[i-st][j];
       }
       if (t) {
 	  for(j=0;j<malign->charset_size;j++) {
-	      malign->scores[i][j] = 128 - (malign->counts[i][j]<<7)/t;
+	      malign->scores[i-st][j] =
+		  128 - (malign->counts[i-st][j]<<7)/t - OFF;
 	  }
 
 	  /* Penalty for gaps is marginally higher */
-	  malign->scores[i][5]++;
+	  malign->scores[i-st][4]+=OFF+1;
+
+	  /* Seq against N in cons is to be deterred */
+	  malign->scores[i-st][5] = GAPM-1;
       } else {
 	  for(j=0;j<malign->charset_size;j++) {
-	      malign->scores[i][j] = 0;
+	      malign->scores[i-st][j] = 0;
 	  }
+	  malign->scores[i-st][4] = GAPM;
+	  malign->scores[i-st][5] = GAPM-1;
       }
   }
 #endif
-#endif
 }
 
 void print_contig_links (CONTIGL *contigl) {
@@ -757,17 +804,19 @@ void print_contig_links (CONTIGL *contigl) {
   }
 }
 
-int contigl_length (CONTIGL *contigl) {
+void contigl_extents(CONTIGL *contigl, int *start, int *end) {
   CONTIGL *t;
-  int length;
+  int st = INT_MAX, en = INT_MIN;
 
-  length = 0;
   t = contigl;
   while(t) {
-    length = MAX(length,(t->mseg->length + t->mseg->offset));
-    t = t->next;
+      st = MIN(st, t->mseg->offset);
+      en = MAX(en, t->mseg->offset + t->mseg->length-1);
+      t = t->next;
   }
-  return length;
+
+  *start = st;
+  *end   = en;
 }
 
 int contigl_elements (CONTIGL *contigl) {
@@ -823,7 +872,11 @@ MALIGN *contigl_to_malign(CONTIGL *contigl_in, int gap_open, int gap_extend) {
   init_malign_matrix(malign);
   //print_malign_matrix(malign);
 
-  malign->length = contigl_length(contigl);
+  contigl_extents(contigl, &malign->start, &malign->end);
+  malign->length = malign->end - malign->start + 1;
+  // Old method was 0 to end.
+  //malign->start = 0;
+  //malign->length = malign->end+1;
 
   /* get the initial scores from the alignment */
 
@@ -832,7 +885,7 @@ MALIGN *contigl_to_malign(CONTIGL *contigl_in, int gap_open, int gap_extend) {
   malign->orig_counts = malign->counts[0];
   malign->orig_scores = malign->scores[0];
   malign->orig_length = malign->length;
-  get_malign_counts(malign, 0, malign->length-1);
+  get_malign_counts(malign, malign->start, malign->end);
   //print_malign_counts(malign);
 
   /* make a 100% consensus for the alignment */
@@ -842,14 +895,14 @@ MALIGN *contigl_to_malign(CONTIGL *contigl_in, int gap_open, int gap_extend) {
   for (i = 0; i < malign->length; i++) {
       malign->orig_pos[i] = i+1;
   }
-  get_malign_consensus(malign, 0, malign->length-1);
+  get_malign_consensus(malign, malign->start, malign->end);
   //printf("      %s\n",malign->consensus);
 
   /* scale the scores with the gap penalties and the external score matrix */
 
   malign->gap_open = gap_open;
   malign->gap_extend = gap_extend;
-  scale_malign_scores(malign, 0, malign->length-1);
+  scale_malign_scores(malign, malign->start, malign->end);
   //print_malign_scores(malign);
 
   /* FIXME put in error checking for failed mallocs etc */
@@ -6089,8 +6142,6 @@ int fixed_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
  * get away with very small bands in order to realign sequences with the
  * minimal amount of effort.
  */
-//#define GAPM 129
-#define GAPM 140
 int realigner_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
     char *seq1, *seq2;
     int seq1_len, seq2_len, seq_out_len;
@@ -6140,7 +6191,6 @@ int realigner_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
     band_left = params->band_left;
     band_right = params->band_right;
 
-
     /* init tables */
     if(!(F1 = (int *) xcalloc(seq1_len + 2, sizeof(int)))) {
 	verror(ERR_WARN, "affine_align", "xmalloc failed for F1");
@@ -6154,8 +6204,10 @@ int realigner_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
     }
 
     /* do recurrence */
+    E_gap = (edge_mode & EDGE_GAPS_MAXY) ? 1000000000 : 0;
+
     if ( edge_mode & EDGE_GAPS_COUNT ) {
-	for(E_gap = 0, i = 0; i < seq1_len; i++) {
+	for(i = 0; i < seq1_len; i++) {
 	    F1[i] = E_gap;
 	    E_gap += GAPM;
 	}
@@ -6166,13 +6218,13 @@ int realigner_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
 	for(i = 0; i <= seq1_len; i++)
 	    F1[i] = 0;
 	edge_inc = 1;
-	E_gap = GAPM;
+	E_gap += GAPM;
     } else {
 	printf("scream: unknown gaps mode\n");
 	destroy_af_mem ( F1, F2, 0, 0, 0, 0, bit_trace, seq1_out, seq2_out );
 	return -1;
     }
-  
+ 
     /* process each row. i.e. each character of seq2 */
     b_s = big_neg;
     b_e = b_r = b_c = 0;
@@ -6285,15 +6337,20 @@ int realigner_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
 		V_insx = pF2[0] + scores[column-1][gap_match_index];
 		V_insy = pF1[1] + insy_cost;
 
+		//printf("%c %c (insy %d)\t", seq1[column-1], seq2[row-1], insy_cost);
+
 		if (V_diag <= V_insx && V_diag <= V_insy) {
 		    b_s = V_diag;
 		    bit_trace[byte] |= BYTE_DIAGONAL << nibble;
+		    //printf("%d,%d %c %d\n", column,row, '\\', b_s);
 		} else if (V_insx <= V_insy) {
 		    b_s = V_insx;
 		    bit_trace[byte] |= BYTE_ACROSS << nibble;
+		    //printf("%d,%d %c %d\n", column,row, '-', b_s);
 		} else {
 		    b_s = V_insy;
 		    bit_trace[byte] |= BYTE_DOWN << nibble;
+		    //printf("%d,%d %c %d\n", column,row, '|', b_s);
 		}
 
 		*(pF2+1) = b_s;
@@ -6384,20 +6441,24 @@ int realigner_malign(MOVERLAP *moverlap, ALIGN_PARAMS *params) {
 		byte = e / 4;
 		nibble = 2 * (e % 4);
 
-
 		V_diag = pF1[column-1] + scores[column-1][row_index];
 		V_insx = pF2[column-1] + scores[column-1][gap_match_index];
 		V_insy = pF1[column] + insy_cost;
 
+		//printf("%c %c (insy %d)\t", seq1[column-1], seq2[row-1], insy_cost);
+
 		if (V_diag <= V_insx && V_diag <= V_insy) {
 		    b_s = V_diag;
 		    bit_trace[byte] |= BYTE_DIAGONAL << nibble;
+		    //printf("%d,%d %c %d\n", column,row, '\\', b_s);
 		} else if (V_insx <= V_insy) {
 		    b_s = V_insx;
 		    bit_trace[byte] |= BYTE_ACROSS << nibble;
+		    //printf("%d,%d %c %d\n", column,row, '-', b_s);
 		} else {
 		    b_s = V_insy;
 		    bit_trace[byte] |= BYTE_DOWN << nibble;
+		    //printf("%d,%d %c %d\n", column,row, '|', b_s);
 		}
 
 		pF2[column] = b_s;
diff --git a/seq_utils/align_lib.h b/seq_utils/align_lib.h
index 08aa669..8d79f2e 100644
--- a/seq_utils/align_lib.h
+++ b/seq_utils/align_lib.h
@@ -37,8 +37,9 @@ void print_contig_links(CONTIGL *contigl);
 typedef struct Malign {
     char *charset;
     int charset_size;
-    int  length;
-    int  **matrix;
+    int length;
+    int start, end;
+    int **matrix;
     CONTIGL *contigl;
     CONTIGR *region;
     int nregion;
@@ -356,6 +357,12 @@ typedef struct Overlap {
 /* Penalise in Y, but not in X */
 #define EDGE_GAPS_ZEROX   16
 
+/* Force no edge overlap at all for Y. */
+/* Ie      OK:                             DENY:            */
+/* Y-seq  -------*--------               ---------------    */
+/* X-seq     ---------               -----------            */
+#define EDGE_GAPS_MAXY    32
+
 typedef struct Align_params {
     int gap_open;
     int gap_extend;
@@ -457,4 +464,6 @@ void init_W128(int **matrix,
 
 int set_alignment_matrix ( char *fn, char *base_order );
 
+void scale_malign_scores(MALIGN *malign, int start, int end);
+
 #endif
diff --git a/seq_utils/dna_utils.c b/seq_utils/dna_utils.c
index bdb49e1..d67c006 100644
--- a/seq_utils/dna_utils.c
+++ b/seq_utils/dna_utils.c
@@ -15,11 +15,46 @@ int char_set_size = 0, *char_lookup = 0, *char_match = 0;
 
 #define MAX_CHAR_SET_SIZE 24
 #define DNA 1
-static char complementary_base[256];
-
-int dna_lookup[256] = {0};
-int dna_match[256] = {0};
+unsigned char complementary_base[256] = {
+  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
+ 16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
+ 32, '!', '"', '#', '$', '%', '&', '\'','(', ')', '*', '+', ',', '-', '.', '/',
+'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
+'@', 'T', 'V', 'G', 'H', 'E', 'F', 'C', 'D', 'I', 'J', 'M', 'L', 'K', 'N', 'O',
+'P', 'Q', 'Y', 'S', 'A', 'A', 'B', 'W', 'X', 'R', 'Z', '[', '\\',']', '^', '_',
+'`', 't', 'v', 'g', 'h', 'e', 'f', 'c', 'd', 'i', 'j', 'm', 'l', 'k', 'n', 'o',
+'p', 'q', 'y', 's', 'a', 'a', 'b', 'w', 'x', 'r', 'z', '{', '|', '}', '~', 127,
+128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
+};
+
+
+int dna_lookup[256] = { // ACGTU->01233 else 4 (NB: no *->5)
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //00
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //10
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //20
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //30
+    4, 0, 4, 1, 4, 4, 4, 2,   4, 4, 4, 4, 4, 4, 4, 4, //40
+    4, 4, 4, 4, 3, 3, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //50
+    4, 0, 4, 1, 4, 4, 4, 2,   4, 4, 4, 4, 4, 4, 4, 4, //60
+    4, 4, 4, 4, 3, 3, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //70
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //80
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //90
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //a0
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //b0
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //c0
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //d0
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4, //e0
+    4, 4, 4, 4, 4, 4, 4, 4,   4, 4, 4, 4, 4, 4, 4, 4  //f0
+};
 int iubc_lookup[256] = {0};
+int dna_match[256] = {0};
 int hash4_lookup[256] = {0}; /* initialised along with iubc_lookup */
 
 /* 7/1/99 johnt - must initialise globals to force export with WINNT */
@@ -38,59 +73,7 @@ void set_dna_lookup() {
 
     int i;
 
-    for (i=0;i<256;i++) dna_lookup[i] = 4;
     for (i=0;i<256;i++) dna_match[i] = i+256;
-    for (i=0;i<256;i++) complementary_base[i] = i;
-
-    dna_lookup['a'] = 0;
-    dna_lookup['c'] = 1;
-    dna_lookup['g'] = 2;
-    dna_lookup['t'] = 3;
-    dna_lookup['A'] = 0;
-    dna_lookup['C'] = 1;
-    dna_lookup['G'] = 2;
-    dna_lookup['T'] = 3;
-    dna_lookup['U'] = 3;
-    dna_lookup['u'] = 3;
-
-    /* the following does not know if rna or dna so we complement
-       u to a, but a to t */
-
-    complementary_base['a'] = 't';
-    complementary_base['c'] = 'g';
-    complementary_base['g'] = 'c';
-    complementary_base['t'] = 'a';
-    complementary_base['u'] = 'a';
-    complementary_base['A'] = 'T';
-    complementary_base['C'] = 'G';
-    complementary_base['G'] = 'C';
-    complementary_base['T'] = 'A';
-    complementary_base['U'] = 'A';
-
-    complementary_base['n'] = 'n';
-    complementary_base['-'] = '-';
-    complementary_base['b'] = 'v';
-    complementary_base['d'] = 'h';
-    complementary_base['h'] = 'd';
-    complementary_base['k'] = 'm';
-    complementary_base['m'] = 'k';
-    complementary_base['r'] = 'y';
-    complementary_base['s'] = 's';
-    complementary_base['v'] = 'b';
-    complementary_base['w'] = 'w';
-    complementary_base['y'] = 'r';
-
-    complementary_base['B'] = 'V';
-    complementary_base['D'] = 'H';
-    complementary_base['H'] = 'D';
-    complementary_base['K'] = 'M';
-    complementary_base['M'] = 'K';
-    complementary_base['R'] = 'Y';
-    complementary_base['S'] = 'S';
-    complementary_base['V'] = 'B';
-    complementary_base['W'] = 'W';
-    complementary_base['Y'] = 'R';
-
 
     /* dna_match matches the valid characters in dna_lookup 
        such as T = t = U = u, otherwise any character only
diff --git a/seq_utils/dna_utils.h b/seq_utils/dna_utils.h
index 3fc68a5..2ec4faa 100644
--- a/seq_utils/dna_utils.h
+++ b/seq_utils/dna_utils.h
@@ -88,7 +88,7 @@ SEQ_UTILS_EXPORT int dna_lookup[256];
 SEQ_UTILS_EXPORT int dna_match[256];
 SEQ_UTILS_EXPORT int unknown_char;
 SEQ_UTILS_EXPORT int hash4_lookup[256];
-
+SEQ_UTILS_EXPORT unsigned char complementary_base[256];
 
 /* Useful macros used by alignment routines, they require char_match to be set! */
 #define SEQ_MATCH(a,b)    ( ( (char_match[(int)a] < unknown_char) && (char_match[(int)a]) == (char_match[(int)b])) ? 1 : 0 )
diff --git a/spin/Makefile b/spin/Makefile
index cba5667..bb173af 100644
--- a/spin/Makefile
+++ b/spin/Makefile
@@ -103,45 +103,810 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 codon_content.o: $(PWD)/staden_config.h
+codon_content.o: $(SRCROOT)/Misc/array_arith.h
+codon_content.o: $(SRCROOT)/Misc/misc.h
+codon_content.o: $(SRCROOT)/Misc/os.h
+codon_content.o: $(SRCROOT)/Misc/xalloc.h
+codon_content.o: $(SRCROOT)/seq_utils/dna_utils.h
+codon_content.o: $(SRCROOT)/seq_utils/edge.h
+codon_content.o: $(SRCROOT)/seq_utils/genetic_code.h
+codon_content.o: $(SRCROOT)/seq_utils/sequence_formats.h
+codon_content.o: $(SRCROOT)/spin/codon_content.h
 compare_spans.o: $(PWD)/staden_config.h
+compare_spans.o: $(SRCROOT)/Misc/misc.h
+compare_spans.o: $(SRCROOT)/Misc/os.h
+compare_spans.o: $(SRCROOT)/Misc/xalloc.h
+compare_spans.o: $(SRCROOT)/seq_utils/align.h
+compare_spans.o: $(SRCROOT)/seq_utils/align_lib_old.h
+compare_spans.o: $(SRCROOT)/seq_utils/dna_utils.h
+compare_spans.o: $(SRCROOT)/seq_utils/edge.h
+compare_spans.o: $(SRCROOT)/spin/readpam.h
+compare_spans.o: $(SRCROOT)/spin/sip_hash.h
+dinuc_freqs.o: $(SRCROOT)/seq_utils/dna_utils.h
 emboss_input_funcs.o: $(PWD)/staden_config.h
+emboss_input_funcs.o: $(SRCROOT)/Misc/misc.h
+emboss_input_funcs.o: $(SRCROOT)/Misc/os.h
+emboss_input_funcs.o: $(SRCROOT)/Misc/xalloc.h
+emboss_input_funcs.o: $(SRCROOT)/seq_utils/sequence_formats.h
+emboss_input_funcs.o: $(SRCROOT)/spin/emboss_input_funcs.h
+emboss_input_funcs.o: $(SRCROOT)/spin/seq_plot_funcs.h
+emboss_input_funcs.o: $(SRCROOT)/spin/seq_raster.h
+emboss_input_funcs.o: $(SRCROOT)/spin/seq_reg.h
+emboss_input_funcs.o: $(SRCROOT)/spin/seq_results.h
+emboss_input_funcs.o: $(SRCROOT)/spin/sequence_pair_display.h
+emboss_input_funcs.o: $(SRCROOT)/spin/spin_globals.h
+emboss_input_funcs.o: $(SRCROOT)/tk_utils/tcl_utils.h
+emboss_input_funcs.o: $(SRCROOT)/tk_utils/text_output.h
+emboss_input_funcs.o: $(SRCROOT)/tk_utils/tkRaster.h
+init.o: $(SRCROOT)/seq_utils/renz_utils.h
+init.o: $(SRCROOT)/spin/nip_cmds.h
+init.o: $(SRCROOT)/spin/seq_reg.h
+init.o: $(SRCROOT)/spin/sequtils_cmds.h
+init.o: $(SRCROOT)/spin/tkSeqed.h
+init.o: $(SRCROOT)/spin/tkSeqedNames.h
+init.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+init.o: $(SRCROOT)/tk_utils/sheet.h
+init.o: $(SRCROOT)/tk_utils/tkRaster.h
+init.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 nip_base_comp.o: $(PWD)/staden_config.h
+nip_base_comp.o: $(SRCROOT)/Misc/misc.h
+nip_base_comp.o: $(SRCROOT)/Misc/os.h
+nip_base_comp.o: $(SRCROOT)/Misc/xalloc.h
+nip_base_comp.o: $(SRCROOT)/seq_utils/base_comp.h
+nip_base_comp.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_base_comp.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_base_comp.o: $(SRCROOT)/spin/nip_base_comp.h
+nip_base_comp.o: $(SRCROOT)/spin/nip_globals.h
+nip_base_comp.o: $(SRCROOT)/spin/nip_raster.h
+nip_base_comp.o: $(SRCROOT)/spin/nip_results.h
+nip_base_comp.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_base_comp.o: $(SRCROOT)/spin/seq_raster.h
+nip_base_comp.o: $(SRCROOT)/spin/seq_reg.h
+nip_base_comp.o: $(SRCROOT)/spin/seq_results.h
+nip_base_comp.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_base_comp.o: $(SRCROOT)/tk_utils/text_output.h
+nip_base_comp.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_canvas_box.o: $(PWD)/staden_config.h
+nip_canvas_box.o: $(SRCROOT)/Misc/misc.h
+nip_canvas_box.o: $(SRCROOT)/Misc/os.h
+nip_canvas_box.o: $(SRCROOT)/Misc/xalloc.h
+nip_canvas_box.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_canvas_box.o: $(SRCROOT)/spin/nip_results.h
+nip_canvas_box.o: $(SRCROOT)/spin/seq_reg.h
+nip_canvas_box.o: $(SRCROOT)/spin/seq_results.h
+nip_canvas_box.o: $(SRCROOT)/tk_utils/canvas_box.h
+nip_canvas_box.o: $(SRCROOT)/tk_utils/text_output.h
+nip_canvas_box.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_cmds.o: $(PWD)/staden_config.h
+nip_cmds.o: $(SRCROOT)/Misc/misc.h
+nip_cmds.o: $(SRCROOT)/Misc/os.h
+nip_cmds.o: $(SRCROOT)/Misc/xalloc.h
+nip_cmds.o: $(SRCROOT)/seq_utils/base_comp.h
+nip_cmds.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_cmds.o: $(SRCROOT)/seq_utils/edge.h
+nip_cmds.o: $(SRCROOT)/seq_utils/genetic_code.h
+nip_cmds.o: $(SRCROOT)/seq_utils/open_reading_frames.h
+nip_cmds.o: $(SRCROOT)/seq_utils/renz_utils.h
+nip_cmds.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_cmds.o: $(SRCROOT)/spin/codon_content.h
+nip_cmds.o: $(SRCROOT)/spin/dinuc_freqs.h
+nip_cmds.o: $(SRCROOT)/spin/nip_base_comp.h
+nip_cmds.o: $(SRCROOT)/spin/nip_canvas_box.h
+nip_cmds.o: $(SRCROOT)/spin/nip_gene_search.h
+nip_cmds.o: $(SRCROOT)/spin/nip_globals.h
+nip_cmds.o: $(SRCROOT)/spin/nip_raster.h
+nip_cmds.o: $(SRCROOT)/spin/nip_restriction_enzymes.h
+nip_cmds.o: $(SRCROOT)/spin/nip_results.h
+nip_cmds.o: $(SRCROOT)/spin/nip_sendto.h
+nip_cmds.o: $(SRCROOT)/spin/nip_splice_search.h
+nip_cmds.o: $(SRCROOT)/spin/nip_stop_codon.h
+nip_cmds.o: $(SRCROOT)/spin/nip_string_search.h
+nip_cmds.o: $(SRCROOT)/spin/nip_structs.h
+nip_cmds.o: $(SRCROOT)/spin/nip_trna_search.h
+nip_cmds.o: $(SRCROOT)/spin/nip_wtmatrix_search.h
+nip_cmds.o: $(SRCROOT)/spin/seq_raster.h
+nip_cmds.o: $(SRCROOT)/spin/seq_reg.h
+nip_cmds.o: $(SRCROOT)/spin/seq_results.h
+nip_cmds.o: $(SRCROOT)/spin/seqed.h
+nip_cmds.o: $(SRCROOT)/spin/seqed_translate.h
+nip_cmds.o: $(SRCROOT)/spin/seqed_write.h
+nip_cmds.o: $(SRCROOT)/spin/sequtils.h
+nip_cmds.o: $(SRCROOT)/spin/splice_search.h
+nip_cmds.o: $(SRCROOT)/spin/tkSeqed.h
+nip_cmds.o: $(SRCROOT)/spin/tkSeqedNames.h
+nip_cmds.o: $(SRCROOT)/spin/tkSeqedUtils.h
+nip_cmds.o: $(SRCROOT)/spin/trna_search.h
+nip_cmds.o: $(SRCROOT)/tk_utils/canvas_box.h
+nip_cmds.o: $(SRCROOT)/tk_utils/cli_arg.h
+nip_cmds.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+nip_cmds.o: $(SRCROOT)/tk_utils/ruler_tick.h
+nip_cmds.o: $(SRCROOT)/tk_utils/sheet.h
+nip_cmds.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_cmds.o: $(SRCROOT)/tk_utils/text_output.h
+nip_cmds.o: $(SRCROOT)/tk_utils/tkRaster.h
+nip_cmds.o: $(SRCROOT)/tk_utils/tkSheet.h
+nip_cmds.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+nip_cmds.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 nip_gene_search.o: $(PWD)/staden_config.h
+nip_gene_search.o: $(SRCROOT)/Misc/array_arith.h
+nip_gene_search.o: $(SRCROOT)/Misc/misc.h
+nip_gene_search.o: $(SRCROOT)/Misc/os.h
+nip_gene_search.o: $(SRCROOT)/Misc/xalloc.h
+nip_gene_search.o: $(SRCROOT)/seq_utils/renz_utils.h
+nip_gene_search.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_gene_search.o: $(SRCROOT)/spin/codon_content.h
+nip_gene_search.o: $(SRCROOT)/spin/nip_gene_search.h
+nip_gene_search.o: $(SRCROOT)/spin/nip_globals.h
+nip_gene_search.o: $(SRCROOT)/spin/nip_raster.h
+nip_gene_search.o: $(SRCROOT)/spin/nip_results.h
+nip_gene_search.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_gene_search.o: $(SRCROOT)/spin/seq_raster.h
+nip_gene_search.o: $(SRCROOT)/spin/seq_reg.h
+nip_gene_search.o: $(SRCROOT)/spin/seq_results.h
+nip_gene_search.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_gene_search.o: $(SRCROOT)/tk_utils/text_output.h
+nip_gene_search.o: $(SRCROOT)/tk_utils/tkRaster.h
+nip_globals.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_globals.o: $(SRCROOT)/seq_utils/genetic_code.h
+nip_globals.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_globals.o: $(SRCROOT)/spin/nip_globals.h
 nip_restriction_enzymes.o: $(PWD)/staden_config.h
+nip_restriction_enzymes.o: $(SRCROOT)/Misc/misc.h
+nip_restriction_enzymes.o: $(SRCROOT)/Misc/os.h
+nip_restriction_enzymes.o: $(SRCROOT)/Misc/xalloc.h
+nip_restriction_enzymes.o: $(SRCROOT)/seq_utils/renz_utils.h
+nip_restriction_enzymes.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_restriction_enzymes.o: $(SRCROOT)/spin/nip_canvas_box.h
+nip_restriction_enzymes.o: $(SRCROOT)/spin/nip_globals.h
+nip_restriction_enzymes.o: $(SRCROOT)/spin/nip_restriction_enzymes.h
+nip_restriction_enzymes.o: $(SRCROOT)/spin/nip_results.h
+nip_restriction_enzymes.o: $(SRCROOT)/spin/seq_reg.h
+nip_restriction_enzymes.o: $(SRCROOT)/spin/seq_results.h
+nip_restriction_enzymes.o: $(SRCROOT)/tk_utils/canvas_box.h
+nip_restriction_enzymes.o: $(SRCROOT)/tk_utils/restriction_enzyme_map.h
+nip_restriction_enzymes.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_restriction_enzymes.o: $(SRCROOT)/tk_utils/text_output.h
+nip_restriction_enzymes.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_splice_search.o: $(PWD)/staden_config.h
+nip_splice_search.o: $(SRCROOT)/Misc/misc.h
+nip_splice_search.o: $(SRCROOT)/Misc/os.h
+nip_splice_search.o: $(SRCROOT)/Misc/xalloc.h
+nip_splice_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_splice_search.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_splice_search.o: $(SRCROOT)/spin/nip_globals.h
+nip_splice_search.o: $(SRCROOT)/spin/nip_raster.h
+nip_splice_search.o: $(SRCROOT)/spin/nip_results.h
+nip_splice_search.o: $(SRCROOT)/spin/nip_splice_search.h
+nip_splice_search.o: $(SRCROOT)/spin/nip_wtmatrix_search.h
+nip_splice_search.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_splice_search.o: $(SRCROOT)/spin/seq_raster.h
+nip_splice_search.o: $(SRCROOT)/spin/seq_reg.h
+nip_splice_search.o: $(SRCROOT)/spin/seq_results.h
+nip_splice_search.o: $(SRCROOT)/spin/splice_search.h
+nip_splice_search.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+nip_splice_search.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_splice_search.o: $(SRCROOT)/tk_utils/text_output.h
+nip_splice_search.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_stop_codon.o: $(PWD)/staden_config.h
+nip_stop_codon.o: $(SRCROOT)/Misc/misc.h
+nip_stop_codon.o: $(SRCROOT)/Misc/os.h
+nip_stop_codon.o: $(SRCROOT)/Misc/xalloc.h
+nip_stop_codon.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_stop_codon.o: $(SRCROOT)/seq_utils/genetic_code.h
+nip_stop_codon.o: $(SRCROOT)/seq_utils/renz_utils.h
+nip_stop_codon.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_stop_codon.o: $(SRCROOT)/spin/nip_globals.h
+nip_stop_codon.o: $(SRCROOT)/spin/nip_raster.h
+nip_stop_codon.o: $(SRCROOT)/spin/nip_results.h
+nip_stop_codon.o: $(SRCROOT)/spin/nip_stop_codon.h
+nip_stop_codon.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_stop_codon.o: $(SRCROOT)/spin/seq_raster.h
+nip_stop_codon.o: $(SRCROOT)/spin/seq_reg.h
+nip_stop_codon.o: $(SRCROOT)/spin/seq_results.h
+nip_stop_codon.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+nip_stop_codon.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_stop_codon.o: $(SRCROOT)/tk_utils/text_output.h
+nip_stop_codon.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_string_search.o: $(PWD)/staden_config.h
+nip_string_search.o: $(SRCROOT)/Misc/misc.h
+nip_string_search.o: $(SRCROOT)/Misc/os.h
+nip_string_search.o: $(SRCROOT)/Misc/xalloc.h
+nip_string_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_string_search.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_string_search.o: $(SRCROOT)/spin/nip_globals.h
+nip_string_search.o: $(SRCROOT)/spin/nip_raster.h
+nip_string_search.o: $(SRCROOT)/spin/nip_results.h
+nip_string_search.o: $(SRCROOT)/spin/nip_string_search.h
+nip_string_search.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_string_search.o: $(SRCROOT)/spin/seq_raster.h
+nip_string_search.o: $(SRCROOT)/spin/seq_reg.h
+nip_string_search.o: $(SRCROOT)/spin/seq_results.h
+nip_string_search.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+nip_string_search.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_string_search.o: $(SRCROOT)/tk_utils/text_output.h
+nip_string_search.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_trna_search.o: $(PWD)/staden_config.h
+nip_trna_search.o: $(SRCROOT)/Misc/misc.h
+nip_trna_search.o: $(SRCROOT)/Misc/os.h
+nip_trna_search.o: $(SRCROOT)/Misc/xalloc.h
+nip_trna_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_trna_search.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_trna_search.o: $(SRCROOT)/spin/nip_globals.h
+nip_trna_search.o: $(SRCROOT)/spin/nip_raster.h
+nip_trna_search.o: $(SRCROOT)/spin/nip_results.h
+nip_trna_search.o: $(SRCROOT)/spin/nip_trna_search.h
+nip_trna_search.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_trna_search.o: $(SRCROOT)/spin/seq_raster.h
+nip_trna_search.o: $(SRCROOT)/spin/seq_reg.h
+nip_trna_search.o: $(SRCROOT)/spin/seq_results.h
+nip_trna_search.o: $(SRCROOT)/spin/trna_search.h
+nip_trna_search.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+nip_trna_search.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_trna_search.o: $(SRCROOT)/tk_utils/text_output.h
+nip_trna_search.o: $(SRCROOT)/tk_utils/tkRaster.h
 nip_wtmatrix_search.o: $(PWD)/staden_config.h
+nip_wtmatrix_search.o: $(SRCROOT)/Misc/misc.h
+nip_wtmatrix_search.o: $(SRCROOT)/Misc/os.h
+nip_wtmatrix_search.o: $(SRCROOT)/Misc/xalloc.h
+nip_wtmatrix_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+nip_wtmatrix_search.o: $(SRCROOT)/seq_utils/sequence_formats.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/nip_globals.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/nip_raster.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/nip_results.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/nip_wtmatrix_search.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/seq_plot_funcs.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/seq_raster.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/seq_reg.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/seq_results.h
+nip_wtmatrix_search.o: $(SRCROOT)/spin/splice_search.h
+nip_wtmatrix_search.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+nip_wtmatrix_search.o: $(SRCROOT)/tk_utils/tcl_utils.h
+nip_wtmatrix_search.o: $(SRCROOT)/tk_utils/text_output.h
+nip_wtmatrix_search.o: $(SRCROOT)/tk_utils/tkRaster.h
 probs.o: $(PWD)/staden_config.h
+probs.o: $(SRCROOT)/Misc/misc.h
+probs.o: $(SRCROOT)/Misc/os.h
+probs.o: $(SRCROOT)/Misc/xalloc.h
+probs.o: $(SRCROOT)/seq_utils/align.h
+probs.o: $(SRCROOT)/seq_utils/align_lib_old.h
+probs.o: $(SRCROOT)/seq_utils/dna_utils.h
+probs.o: $(SRCROOT)/seq_utils/sequence_formats.h
+probs.o: $(SRCROOT)/spin/probs.h
+probs.o: $(SRCROOT)/spin/readpam.h
+probs.o: $(SRCROOT)/spin/sip_hash.h
 raster_cmds.o: $(PWD)/staden_config.h
+raster_cmds.o: $(SRCROOT)/Misc/misc.h
+raster_cmds.o: $(SRCROOT)/Misc/os.h
+raster_cmds.o: $(SRCROOT)/Misc/xalloc.h
+raster_cmds.o: $(SRCROOT)/seq_utils/sequence_formats.h
+raster_cmds.o: $(SRCROOT)/spin/raster_globals.h
+raster_cmds.o: $(SRCROOT)/spin/raster_structs.h
+raster_cmds.o: $(SRCROOT)/spin/seq_raster.h
+raster_cmds.o: $(SRCROOT)/spin/seq_reg.h
+raster_cmds.o: $(SRCROOT)/spin/seq_results.h
+raster_cmds.o: $(SRCROOT)/tk_utils/canvas_box.h
+raster_cmds.o: $(SRCROOT)/tk_utils/cli_arg.h
+raster_cmds.o: $(SRCROOT)/tk_utils/ruler_tick.h
+raster_cmds.o: $(SRCROOT)/tk_utils/tcl_utils.h
+raster_cmds.o: $(SRCROOT)/tk_utils/text_output.h
+raster_cmds.o: $(SRCROOT)/tk_utils/tkRaster.h
 readpam.o: $(PWD)/staden_config.h
+readpam.o: $(SRCROOT)/Misc/misc.h
+readpam.o: $(SRCROOT)/Misc/os.h
+readpam.o: $(SRCROOT)/Misc/xalloc.h
+readpam.o: $(SRCROOT)/seq_utils/align.h
+readpam.o: $(SRCROOT)/seq_utils/align_lib_old.h
+readpam.o: $(SRCROOT)/seq_utils/dna_utils.h
+readpam.o: $(SRCROOT)/seq_utils/sequence_formats.h
+readpam.o: $(SRCROOT)/spin/readpam.h
 rescan_matches.o: $(PWD)/staden_config.h
+rescan_matches.o: $(SRCROOT)/Misc/array.h
+rescan_matches.o: $(SRCROOT)/Misc/misc.h
+rescan_matches.o: $(SRCROOT)/Misc/os.h
+rescan_matches.o: $(SRCROOT)/Misc/xalloc.h
+rescan_matches.o: $(SRCROOT)/Misc/xerror.h
+rescan_matches.o: $(SRCROOT)/seq_utils/align.h
+rescan_matches.o: $(SRCROOT)/seq_utils/align_lib_old.h
+rescan_matches.o: $(SRCROOT)/seq_utils/dna_utils.h
+rescan_matches.o: $(SRCROOT)/seq_utils/sequence_formats.h
+rescan_matches.o: $(SRCROOT)/spin/readpam.h
+rescan_matches.o: $(SRCROOT)/spin/seq_raster.h
+rescan_matches.o: $(SRCROOT)/spin/seq_reg.h
+rescan_matches.o: $(SRCROOT)/spin/seq_results.h
+rescan_matches.o: $(SRCROOT)/spin/sip_results.h
+rescan_matches.o: $(SRCROOT)/tk_utils/tkRaster.h
 seq_plot_funcs.o: $(PWD)/staden_config.h
+seq_plot_funcs.o: $(SRCROOT)/Misc/misc.h
+seq_plot_funcs.o: $(SRCROOT)/Misc/os.h
+seq_plot_funcs.o: $(SRCROOT)/Misc/xalloc.h
+seq_plot_funcs.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seq_plot_funcs.o: $(SRCROOT)/spin/seq_raster.h
+seq_plot_funcs.o: $(SRCROOT)/spin/seq_reg.h
+seq_plot_funcs.o: $(SRCROOT)/spin/seq_results.h
+seq_plot_funcs.o: $(SRCROOT)/tk_utils/text_output.h
+seq_plot_funcs.o: $(SRCROOT)/tk_utils/tkRaster.h
 seq_raster.o: $(PWD)/staden_config.h
+seq_raster.o: $(SRCROOT)/Misc/misc.h
+seq_raster.o: $(SRCROOT)/Misc/os.h
+seq_raster.o: $(SRCROOT)/Misc/xalloc.h
+seq_raster.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seq_raster.o: $(SRCROOT)/spin/seq_raster.h
+seq_raster.o: $(SRCROOT)/spin/seq_reg.h
+seq_raster.o: $(SRCROOT)/spin/seq_results.h
+seq_raster.o: $(SRCROOT)/spin/spin_globals.h
+seq_raster.o: $(SRCROOT)/tk_utils/tcl_utils.h
+seq_raster.o: $(SRCROOT)/tk_utils/text_output.h
+seq_raster.o: $(SRCROOT)/tk_utils/tkRaster.h
 seq_reg.o: $(PWD)/staden_config.h
+seq_reg.o: $(SRCROOT)/Misc/array.h
+seq_reg.o: $(SRCROOT)/Misc/misc.h
+seq_reg.o: $(SRCROOT)/Misc/os.h
+seq_reg.o: $(SRCROOT)/Misc/xalloc.h
+seq_reg.o: $(SRCROOT)/Misc/xerror.h
+seq_reg.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seq_reg.o: $(SRCROOT)/spin/seq_raster.h
+seq_reg.o: $(SRCROOT)/spin/seq_reg.h
+seq_reg.o: $(SRCROOT)/spin/seq_results.h
+seq_reg.o: $(SRCROOT)/spin/spin_globals.h
+seq_reg.o: $(SRCROOT)/tk_utils/tcl_utils.h
+seq_reg.o: $(SRCROOT)/tk_utils/tkRaster.h
 seq_reg_cmds.o: $(PWD)/staden_config.h
+seq_reg_cmds.o: $(SRCROOT)/Misc/array.h
+seq_reg_cmds.o: $(SRCROOT)/Misc/misc.h
+seq_reg_cmds.o: $(SRCROOT)/Misc/os.h
+seq_reg_cmds.o: $(SRCROOT)/Misc/xalloc.h
+seq_reg_cmds.o: $(SRCROOT)/Misc/xerror.h
+seq_reg_cmds.o: $(SRCROOT)/seq_utils/renz_utils.h
+seq_reg_cmds.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seq_reg_cmds.o: $(SRCROOT)/spin/emboss_input_funcs.h
+seq_reg_cmds.o: $(SRCROOT)/spin/nip_cmds.h
+seq_reg_cmds.o: $(SRCROOT)/spin/raster_cmds.h
+seq_reg_cmds.o: $(SRCROOT)/spin/seq_raster.h
+seq_reg_cmds.o: $(SRCROOT)/spin/seq_reg.h
+seq_reg_cmds.o: $(SRCROOT)/spin/seq_reg_structs.h
+seq_reg_cmds.o: $(SRCROOT)/spin/seq_results.h
+seq_reg_cmds.o: $(SRCROOT)/spin/seq_sendto.h
+seq_reg_cmds.o: $(SRCROOT)/spin/seqed.h
+seq_reg_cmds.o: $(SRCROOT)/spin/sequence_pair_display.h
+seq_reg_cmds.o: $(SRCROOT)/spin/sequtils.h
+seq_reg_cmds.o: $(SRCROOT)/spin/sip_cmds.h
+seq_reg_cmds.o: $(SRCROOT)/spin/spin_globals.h
+seq_reg_cmds.o: $(SRCROOT)/spin/tkSeqed.h
+seq_reg_cmds.o: $(SRCROOT)/spin/tkSeqedNames.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/cli_arg.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/sheet.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/tcl_utils.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/text_output.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/tkRaster.h
+seq_reg_cmds.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 seq_results.o: $(PWD)/staden_config.h
+seq_results.o: $(SRCROOT)/Misc/misc.h
+seq_results.o: $(SRCROOT)/Misc/os.h
+seq_results.o: $(SRCROOT)/Misc/xalloc.h
+seq_results.o: $(SRCROOT)/seq_utils/dna_utils.h
+seq_results.o: $(SRCROOT)/seq_utils/genetic_code.h
+seq_results.o: $(SRCROOT)/seq_utils/scramble.h
+seq_results.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seq_results.o: $(SRCROOT)/spin/codon_content.h
+seq_results.o: $(SRCROOT)/spin/seq_raster.h
+seq_results.o: $(SRCROOT)/spin/seq_reg.h
+seq_results.o: $(SRCROOT)/spin/seq_results.h
+seq_results.o: $(SRCROOT)/tk_utils/tkRaster.h
 seq_sendto.o: $(PWD)/staden_config.h
+seq_sendto.o: $(SRCROOT)/Misc/misc.h
+seq_sendto.o: $(SRCROOT)/Misc/os.h
+seq_sendto.o: $(SRCROOT)/Misc/xalloc.h
+seq_sendto.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seq_sendto.o: $(SRCROOT)/spin/seq_reg.h
+seq_sendto.o: $(SRCROOT)/spin/seq_results.h
+seq_sendto.o: $(SRCROOT)/tk_utils/tcl_utils.h
+seq_sendto.o: $(SRCROOT)/tk_utils/tkRaster.h
 seqed.o: $(PWD)/staden_config.h
+seqed.o: $(SRCROOT)/Misc/misc.h
+seqed.o: $(SRCROOT)/Misc/os.h
+seqed.o: $(SRCROOT)/Misc/xalloc.h
+seqed.o: $(SRCROOT)/seq_utils/renz_utils.h
+seqed.o: $(SRCROOT)/seq_utils/sequence_formats.h
+seqed.o: $(SRCROOT)/spin/seq_raster.h
+seqed.o: $(SRCROOT)/spin/seq_reg.h
+seqed.o: $(SRCROOT)/spin/seq_results.h
+seqed.o: $(SRCROOT)/spin/seqed.h
+seqed.o: $(SRCROOT)/spin/seqed_restriction_enzymes.h
+seqed.o: $(SRCROOT)/spin/spin_globals.h
+seqed.o: $(SRCROOT)/spin/tkSeqed.h
+seqed.o: $(SRCROOT)/spin/tkSeqedNames.h
+seqed.o: $(SRCROOT)/spin/tkSeqedUtils.h
+seqed.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqed.o: $(SRCROOT)/tk_utils/sheet.h
+seqed.o: $(SRCROOT)/tk_utils/tcl_utils.h
+seqed.o: $(SRCROOT)/tk_utils/text_output.h
+seqed.o: $(SRCROOT)/tk_utils/tkRaster.h
+seqed.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+seqedInterface.o: $(SRCROOT)/seq_utils/renz_utils.h
+seqedInterface.o: $(SRCROOT)/spin/seq_reg.h
+seqedInterface.o: $(SRCROOT)/spin/seqedInterface.h
+seqedInterface.o: $(SRCROOT)/spin/tkSeqed.h
+seqedInterface.o: $(SRCROOT)/spin/tkSeqedNames.h
+seqedInterface.o: $(SRCROOT)/spin/tkSeqedUtils.h
+seqedInterface.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqedInterface.o: $(SRCROOT)/tk_utils/sheet.h
+seqedInterface.o: $(SRCROOT)/tk_utils/tkRaster.h
+seqedInterface.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 seqed_restriction_enzymes.o: $(PWD)/staden_config.h
+seqed_restriction_enzymes.o: $(SRCROOT)/Misc/misc.h
+seqed_restriction_enzymes.o: $(SRCROOT)/Misc/os.h
+seqed_restriction_enzymes.o: $(SRCROOT)/Misc/xalloc.h
+seqed_restriction_enzymes.o: $(SRCROOT)/seq_utils/dna_utils.h
+seqed_restriction_enzymes.o: $(SRCROOT)/seq_utils/renz_utils.h
+seqed_restriction_enzymes.o: $(SRCROOT)/spin/seq_reg.h
+seqed_restriction_enzymes.o: $(SRCROOT)/spin/seqed_restriction_enzymes.h
+seqed_restriction_enzymes.o: $(SRCROOT)/spin/tkSeqed.h
+seqed_restriction_enzymes.o: $(SRCROOT)/spin/tkSeqedNames.h
+seqed_restriction_enzymes.o: $(SRCROOT)/spin/tkSeqedUtils.h
+seqed_restriction_enzymes.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqed_restriction_enzymes.o: $(SRCROOT)/tk_utils/sheet.h
+seqed_restriction_enzymes.o: $(SRCROOT)/tk_utils/tkRaster.h
+seqed_restriction_enzymes.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 seqed_search.o: $(PWD)/staden_config.h
+seqed_search.o: $(SRCROOT)/Misc/misc.h
+seqed_search.o: $(SRCROOT)/Misc/os.h
+seqed_search.o: $(SRCROOT)/Misc/xalloc.h
+seqed_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+seqed_search.o: $(SRCROOT)/seq_utils/renz_utils.h
+seqed_search.o: $(SRCROOT)/spin/seq_reg.h
+seqed_search.o: $(SRCROOT)/spin/tkSeqed.h
+seqed_search.o: $(SRCROOT)/spin/tkSeqedNames.h
+seqed_search.o: $(SRCROOT)/spin/tkSeqedUtils.h
+seqed_search.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqed_search.o: $(SRCROOT)/tk_utils/sheet.h
+seqed_search.o: $(SRCROOT)/tk_utils/tcl_utils.h
+seqed_search.o: $(SRCROOT)/tk_utils/text_output.h
+seqed_search.o: $(SRCROOT)/tk_utils/tkRaster.h
+seqed_search.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+seqed_translate.o: $(SRCROOT)/seq_utils/genetic_code.h
+seqed_translate.o: $(SRCROOT)/seq_utils/renz_utils.h
+seqed_translate.o: $(SRCROOT)/spin/seq_reg.h
+seqed_translate.o: $(SRCROOT)/spin/seqed_translate.h
+seqed_translate.o: $(SRCROOT)/spin/tkSeqed.h
+seqed_translate.o: $(SRCROOT)/spin/tkSeqedNames.h
+seqed_translate.o: $(SRCROOT)/spin/tkSeqedUtils.h
+seqed_translate.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqed_translate.o: $(SRCROOT)/tk_utils/sheet.h
+seqed_translate.o: $(SRCROOT)/tk_utils/tkRaster.h
+seqed_translate.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+seqed_write.o: $(SRCROOT)/Misc/xalloc.h
+seqed_write.o: $(SRCROOT)/seq_utils/dna_utils.h
+seqed_write.o: $(SRCROOT)/seq_utils/genetic_code.h
+seqed_write.o: $(SRCROOT)/seq_utils/renz_utils.h
+seqed_write.o: $(SRCROOT)/spin/seq_reg.h
+seqed_write.o: $(SRCROOT)/spin/seqed_restriction_enzymes.h
+seqed_write.o: $(SRCROOT)/spin/seqed_translate.h
+seqed_write.o: $(SRCROOT)/spin/seqed_write.h
+seqed_write.o: $(SRCROOT)/spin/tkSeqed.h
+seqed_write.o: $(SRCROOT)/spin/tkSeqedNames.h
+seqed_write.o: $(SRCROOT)/spin/tkSeqedUtils.h
+seqed_write.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+seqed_write.o: $(SRCROOT)/tk_utils/sheet.h
+seqed_write.o: $(SRCROOT)/tk_utils/tkRaster.h
+seqed_write.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 sequence_pair_display.o: $(PWD)/staden_config.h
+sequence_pair_display.o: $(SRCROOT)/Misc/array.h
+sequence_pair_display.o: $(SRCROOT)/Misc/misc.h
+sequence_pair_display.o: $(SRCROOT)/Misc/os.h
+sequence_pair_display.o: $(SRCROOT)/Misc/xalloc.h
+sequence_pair_display.o: $(SRCROOT)/Misc/xerror.h
+sequence_pair_display.o: $(SRCROOT)/seq_utils/align.h
+sequence_pair_display.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sequence_pair_display.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sequence_pair_display.o: $(SRCROOT)/spin/readpam.h
+sequence_pair_display.o: $(SRCROOT)/spin/seq_raster.h
+sequence_pair_display.o: $(SRCROOT)/spin/seq_reg.h
+sequence_pair_display.o: $(SRCROOT)/spin/seq_results.h
+sequence_pair_display.o: $(SRCROOT)/spin/sequence_pair_display.h
+sequence_pair_display.o: $(SRCROOT)/spin/sip_results.h
+sequence_pair_display.o: $(SRCROOT)/spin/spin_globals.h
+sequence_pair_display.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sequence_pair_display.o: $(SRCROOT)/tk_utils/text_output.h
+sequence_pair_display.o: $(SRCROOT)/tk_utils/tkRaster.h
 sequtils.o: $(PWD)/staden_config.h
+sequtils.o: $(SRCROOT)/Misc/misc.h
+sequtils.o: $(SRCROOT)/Misc/os.h
+sequtils.o: $(SRCROOT)/Misc/xalloc.h
+sequtils.o: $(SRCROOT)/seq_utils/base_comp.h
+sequtils.o: $(SRCROOT)/seq_utils/dna_utils.h
+sequtils.o: $(SRCROOT)/seq_utils/edge.h
+sequtils.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sequtils.o: $(SRCROOT)/spin/seq_reg.h
+sequtils.o: $(SRCROOT)/spin/seq_results.h
+sequtils.o: $(SRCROOT)/tk_utils/text_output.h
+sequtils.o: $(SRCROOT)/tk_utils/tkRaster.h
 sim.o: $(PWD)/staden_config.h
+sim.o: $(SRCROOT)/Misc/array.h
+sim.o: $(SRCROOT)/Misc/misc.h
+sim.o: $(SRCROOT)/Misc/os.h
+sim.o: $(SRCROOT)/Misc/xalloc.h
+sim.o: $(SRCROOT)/Misc/xerror.h
+sim.o: $(SRCROOT)/seq_utils/align.h
+sim.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sim.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sim.o: $(SRCROOT)/spin/seq_raster.h
+sim.o: $(SRCROOT)/spin/seq_reg.h
+sim.o: $(SRCROOT)/spin/seq_results.h
+sim.o: $(SRCROOT)/spin/sip_sim.h
+sim.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_align.o: $(PWD)/staden_config.h
+sip_align.o: $(SRCROOT)/Misc/array.h
+sip_align.o: $(SRCROOT)/Misc/misc.h
+sip_align.o: $(SRCROOT)/Misc/os.h
+sip_align.o: $(SRCROOT)/Misc/xalloc.h
+sip_align.o: $(SRCROOT)/Misc/xerror.h
+sip_align.o: $(SRCROOT)/seq_utils/align.h
+sip_align.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_align.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_align.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_align.o: $(SRCROOT)/spin/readpam.h
+sip_align.o: $(SRCROOT)/spin/seq_plot_funcs.h
+sip_align.o: $(SRCROOT)/spin/seq_raster.h
+sip_align.o: $(SRCROOT)/spin/seq_reg.h
+sip_align.o: $(SRCROOT)/spin/seq_results.h
+sip_align.o: $(SRCROOT)/spin/sequence_pair_display.h
+sip_align.o: $(SRCROOT)/spin/sip_align.h
+sip_align.o: $(SRCROOT)/spin/sip_globals.h
+sip_align.o: $(SRCROOT)/spin/sip_results.h
+sip_align.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_align.o: $(SRCROOT)/tk_utils/text_output.h
+sip_align.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_cmds.o: $(PWD)/staden_config.h
+sip_cmds.o: $(SRCROOT)/Misc/array.h
+sip_cmds.o: $(SRCROOT)/Misc/misc.h
+sip_cmds.o: $(SRCROOT)/Misc/os.h
+sip_cmds.o: $(SRCROOT)/Misc/xalloc.h
+sip_cmds.o: $(SRCROOT)/Misc/xerror.h
+sip_cmds.o: $(SRCROOT)/seq_utils/align.h
+sip_cmds.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_cmds.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_cmds.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_cmds.o: $(SRCROOT)/spin/probs.h
+sip_cmds.o: $(SRCROOT)/spin/readpam.h
+sip_cmds.o: $(SRCROOT)/spin/seq_raster.h
+sip_cmds.o: $(SRCROOT)/spin/seq_reg.h
+sip_cmds.o: $(SRCROOT)/spin/seq_results.h
+sip_cmds.o: $(SRCROOT)/spin/sequtils.h
+sip_cmds.o: $(SRCROOT)/spin/sip_align.h
+sip_cmds.o: $(SRCROOT)/spin/sip_find_identity.h
+sip_cmds.o: $(SRCROOT)/spin/sip_globals.h
+sip_cmds.o: $(SRCROOT)/spin/sip_hash.h
+sip_cmds.o: $(SRCROOT)/spin/sip_quick_scan.h
+sip_cmds.o: $(SRCROOT)/spin/sip_results.h
+sip_cmds.o: $(SRCROOT)/spin/sip_sendto.h
+sip_cmds.o: $(SRCROOT)/spin/sip_sim.h
+sip_cmds.o: $(SRCROOT)/spin/sip_similar_spans.h
+sip_cmds.o: $(SRCROOT)/spin/sip_structs.h
+sip_cmds.o: $(SRCROOT)/tk_utils/cli_arg.h
+sip_cmds.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_cmds.o: $(SRCROOT)/tk_utils/text_output.h
+sip_cmds.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_find_identity.o: $(PWD)/staden_config.h
+sip_find_identity.o: $(SRCROOT)/Misc/array.h
+sip_find_identity.o: $(SRCROOT)/Misc/misc.h
+sip_find_identity.o: $(SRCROOT)/Misc/os.h
+sip_find_identity.o: $(SRCROOT)/Misc/xalloc.h
+sip_find_identity.o: $(SRCROOT)/Misc/xerror.h
+sip_find_identity.o: $(SRCROOT)/seq_utils/align.h
+sip_find_identity.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_find_identity.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_find_identity.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_find_identity.o: $(SRCROOT)/spin/probs.h
+sip_find_identity.o: $(SRCROOT)/spin/readpam.h
+sip_find_identity.o: $(SRCROOT)/spin/seq_plot_funcs.h
+sip_find_identity.o: $(SRCROOT)/spin/seq_raster.h
+sip_find_identity.o: $(SRCROOT)/spin/seq_reg.h
+sip_find_identity.o: $(SRCROOT)/spin/seq_results.h
+sip_find_identity.o: $(SRCROOT)/spin/sequence_pair_display.h
+sip_find_identity.o: $(SRCROOT)/spin/sip_find_identity.h
+sip_find_identity.o: $(SRCROOT)/spin/sip_globals.h
+sip_find_identity.o: $(SRCROOT)/spin/sip_hash.h
+sip_find_identity.o: $(SRCROOT)/spin/sip_results.h
+sip_find_identity.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_find_identity.o: $(SRCROOT)/tk_utils/text_output.h
+sip_find_identity.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_globals.o: $(PWD)/staden_config.h
+sip_globals.o: $(SRCROOT)/Misc/array.h
+sip_globals.o: $(SRCROOT)/Misc/misc.h
+sip_globals.o: $(SRCROOT)/Misc/os.h
+sip_globals.o: $(SRCROOT)/Misc/xalloc.h
+sip_globals.o: $(SRCROOT)/Misc/xerror.h
+sip_globals.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_globals.o: $(SRCROOT)/seq_utils/genetic_code.h
+sip_globals.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_globals.o: $(SRCROOT)/spin/seq_raster.h
+sip_globals.o: $(SRCROOT)/spin/seq_reg.h
+sip_globals.o: $(SRCROOT)/spin/seq_results.h
+sip_globals.o: $(SRCROOT)/spin/sip_results.h
+sip_globals.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_hash.o: $(PWD)/staden_config.h
+sip_hash.o: $(SRCROOT)/Misc/array.h
+sip_hash.o: $(SRCROOT)/Misc/misc.h
+sip_hash.o: $(SRCROOT)/Misc/os.h
+sip_hash.o: $(SRCROOT)/Misc/xalloc.h
+sip_hash.o: $(SRCROOT)/Misc/xerror.h
+sip_hash.o: $(SRCROOT)/seq_utils/align.h
+sip_hash.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_hash.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_hash.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_hash.o: $(SRCROOT)/spin/readpam.h
+sip_hash.o: $(SRCROOT)/spin/seq_raster.h
+sip_hash.o: $(SRCROOT)/spin/seq_reg.h
+sip_hash.o: $(SRCROOT)/spin/seq_results.h
+sip_hash.o: $(SRCROOT)/spin/sip_results.h
+sip_hash.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_quick_scan.o: $(PWD)/staden_config.h
+sip_quick_scan.o: $(SRCROOT)/Misc/array.h
+sip_quick_scan.o: $(SRCROOT)/Misc/misc.h
+sip_quick_scan.o: $(SRCROOT)/Misc/os.h
+sip_quick_scan.o: $(SRCROOT)/Misc/xalloc.h
+sip_quick_scan.o: $(SRCROOT)/Misc/xerror.h
+sip_quick_scan.o: $(SRCROOT)/seq_utils/align.h
+sip_quick_scan.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_quick_scan.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_quick_scan.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_quick_scan.o: $(SRCROOT)/spin/compare_spans.h
+sip_quick_scan.o: $(SRCROOT)/spin/readpam.h
+sip_quick_scan.o: $(SRCROOT)/spin/seq_plot_funcs.h
+sip_quick_scan.o: $(SRCROOT)/spin/seq_raster.h
+sip_quick_scan.o: $(SRCROOT)/spin/seq_reg.h
+sip_quick_scan.o: $(SRCROOT)/spin/seq_results.h
+sip_quick_scan.o: $(SRCROOT)/spin/sequence_pair_display.h
+sip_quick_scan.o: $(SRCROOT)/spin/sip_find_identity.h
+sip_quick_scan.o: $(SRCROOT)/spin/sip_globals.h
+sip_quick_scan.o: $(SRCROOT)/spin/sip_hash.h
+sip_quick_scan.o: $(SRCROOT)/spin/sip_quick_scan.h
+sip_quick_scan.o: $(SRCROOT)/spin/sip_results.h
+sip_quick_scan.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_quick_scan.o: $(SRCROOT)/tk_utils/text_output.h
+sip_quick_scan.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_results.o: $(PWD)/staden_config.h
+sip_results.o: $(SRCROOT)/Misc/array.h
+sip_results.o: $(SRCROOT)/Misc/misc.h
+sip_results.o: $(SRCROOT)/Misc/os.h
+sip_results.o: $(SRCROOT)/Misc/xalloc.h
+sip_results.o: $(SRCROOT)/Misc/xerror.h
+sip_results.o: $(SRCROOT)/seq_utils/align.h
+sip_results.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_results.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_results.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_results.o: $(SRCROOT)/spin/probs.h
+sip_results.o: $(SRCROOT)/spin/readpam.h
+sip_results.o: $(SRCROOT)/spin/seq_raster.h
+sip_results.o: $(SRCROOT)/spin/seq_reg.h
+sip_results.o: $(SRCROOT)/spin/seq_results.h
+sip_results.o: $(SRCROOT)/spin/sip_globals.h
+sip_results.o: $(SRCROOT)/spin/sip_results.h
+sip_results.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_results.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_sim.o: $(PWD)/staden_config.h
+sip_sim.o: $(SRCROOT)/Misc/array.h
+sip_sim.o: $(SRCROOT)/Misc/misc.h
+sip_sim.o: $(SRCROOT)/Misc/os.h
+sip_sim.o: $(SRCROOT)/Misc/xalloc.h
+sip_sim.o: $(SRCROOT)/Misc/xerror.h
+sip_sim.o: $(SRCROOT)/seq_utils/align.h
+sip_sim.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_sim.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_sim.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_sim.o: $(SRCROOT)/spin/readpam.h
+sip_sim.o: $(SRCROOT)/spin/seq_plot_funcs.h
+sip_sim.o: $(SRCROOT)/spin/seq_raster.h
+sip_sim.o: $(SRCROOT)/spin/seq_reg.h
+sip_sim.o: $(SRCROOT)/spin/seq_results.h
+sip_sim.o: $(SRCROOT)/spin/sequence_pair_display.h
+sip_sim.o: $(SRCROOT)/spin/sim.h
+sip_sim.o: $(SRCROOT)/spin/sip_globals.h
+sip_sim.o: $(SRCROOT)/spin/sip_results.h
+sip_sim.o: $(SRCROOT)/spin/sip_sim.h
+sip_sim.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_sim.o: $(SRCROOT)/tk_utils/text_output.h
+sip_sim.o: $(SRCROOT)/tk_utils/tkRaster.h
 sip_similar_spans.o: $(PWD)/staden_config.h
+sip_similar_spans.o: $(SRCROOT)/Misc/array.h
+sip_similar_spans.o: $(SRCROOT)/Misc/misc.h
+sip_similar_spans.o: $(SRCROOT)/Misc/os.h
+sip_similar_spans.o: $(SRCROOT)/Misc/xalloc.h
+sip_similar_spans.o: $(SRCROOT)/Misc/xerror.h
+sip_similar_spans.o: $(SRCROOT)/seq_utils/align.h
+sip_similar_spans.o: $(SRCROOT)/seq_utils/align_lib_old.h
+sip_similar_spans.o: $(SRCROOT)/seq_utils/dna_utils.h
+sip_similar_spans.o: $(SRCROOT)/seq_utils/sequence_formats.h
+sip_similar_spans.o: $(SRCROOT)/spin/compare_spans.h
+sip_similar_spans.o: $(SRCROOT)/spin/readpam.h
+sip_similar_spans.o: $(SRCROOT)/spin/rescan_matches.h
+sip_similar_spans.o: $(SRCROOT)/spin/seq_plot_funcs.h
+sip_similar_spans.o: $(SRCROOT)/spin/seq_raster.h
+sip_similar_spans.o: $(SRCROOT)/spin/seq_reg.h
+sip_similar_spans.o: $(SRCROOT)/spin/seq_results.h
+sip_similar_spans.o: $(SRCROOT)/spin/sequence_pair_display.h
+sip_similar_spans.o: $(SRCROOT)/spin/sip_globals.h
+sip_similar_spans.o: $(SRCROOT)/spin/sip_hash.h
+sip_similar_spans.o: $(SRCROOT)/spin/sip_results.h
+sip_similar_spans.o: $(SRCROOT)/spin/sip_similar_spans.h
+sip_similar_spans.o: $(SRCROOT)/tk_utils/tcl_utils.h
+sip_similar_spans.o: $(SRCROOT)/tk_utils/text_output.h
+sip_similar_spans.o: $(SRCROOT)/tk_utils/tkRaster.h
+spin_globals.o: $(SRCROOT)/spin/spin_globals.h
 splice_search.o: $(PWD)/staden_config.h
+splice_search.o: $(SRCROOT)/Misc/array_arith.h
+splice_search.o: $(SRCROOT)/Misc/getfile.h
+splice_search.o: $(SRCROOT)/Misc/misc.h
+splice_search.o: $(SRCROOT)/Misc/os.h
+splice_search.o: $(SRCROOT)/Misc/xalloc.h
+splice_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+splice_search.o: $(SRCROOT)/spin/splice_search.h
 tkSeqed.o: $(PWD)/staden_config.h
+tkSeqed.o: $(SRCROOT)/Misc/misc.h
+tkSeqed.o: $(SRCROOT)/Misc/os.h
+tkSeqed.o: $(SRCROOT)/Misc/xalloc.h
+tkSeqed.o: $(SRCROOT)/seq_utils/dna_utils.h
+tkSeqed.o: $(SRCROOT)/seq_utils/renz_utils.h
+tkSeqed.o: $(SRCROOT)/spin/seq_reg.h
+tkSeqed.o: $(SRCROOT)/spin/seqedInterface.h
+tkSeqed.o: $(SRCROOT)/spin/seqed_restriction_enzymes.h
+tkSeqed.o: $(SRCROOT)/spin/seqed_search.h
+tkSeqed.o: $(SRCROOT)/spin/tkSeqed.h
+tkSeqed.o: $(SRCROOT)/spin/tkSeqedNames.h
+tkSeqed.o: $(SRCROOT)/spin/tkSeqedUtils.h
+tkSeqed.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkSeqed.o: $(SRCROOT)/tk_utils/sheet.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tkRaster.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkSeqed.o: $(SRCROOT)/tk_utils/tk_defs.h
 tkSeqedNames.o: $(PWD)/staden_config.h
+tkSeqedNames.o: $(SRCROOT)/Misc/misc.h
+tkSeqedNames.o: $(SRCROOT)/Misc/os.h
+tkSeqedNames.o: $(SRCROOT)/Misc/xalloc.h
+tkSeqedNames.o: $(SRCROOT)/spin/tkSeqedNames.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/sheet.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkSeqedNames.o: $(SRCROOT)/tk_utils/tk_defs.h
 tkSeqedUtils.o: $(PWD)/staden_config.h
+tkSeqedUtils.o: $(SRCROOT)/Misc/misc.h
+tkSeqedUtils.o: $(SRCROOT)/Misc/os.h
+tkSeqedUtils.o: $(SRCROOT)/Misc/xalloc.h
+tkSeqedUtils.o: $(SRCROOT)/seq_utils/dna_utils.h
+tkSeqedUtils.o: $(SRCROOT)/seq_utils/genetic_code.h
+tkSeqedUtils.o: $(SRCROOT)/seq_utils/renz_utils.h
+tkSeqedUtils.o: $(SRCROOT)/seq_utils/sequence_formats.h
+tkSeqedUtils.o: $(SRCROOT)/spin/seq_reg.h
+tkSeqedUtils.o: $(SRCROOT)/spin/seq_results.h
+tkSeqedUtils.o: $(SRCROOT)/spin/seqed_restriction_enzymes.h
+tkSeqedUtils.o: $(SRCROOT)/spin/seqed_search.h
+tkSeqedUtils.o: $(SRCROOT)/spin/seqed_translate.h
+tkSeqedUtils.o: $(SRCROOT)/spin/seqed_write.h
+tkSeqedUtils.o: $(SRCROOT)/spin/tkSeqed.h
+tkSeqedUtils.o: $(SRCROOT)/spin/tkSeqedNames.h
+tkSeqedUtils.o: $(SRCROOT)/spin/tkSeqedUtils.h
+tkSeqedUtils.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkSeqedUtils.o: $(SRCROOT)/tk_utils/sheet.h
+tkSeqedUtils.o: $(SRCROOT)/tk_utils/tkRaster.h
+tkSeqedUtils.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkSeqedUtils.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkSeqedUtils.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
 trna_search.o: $(PWD)/staden_config.h
+trna_search.o: $(SRCROOT)/Misc/array_arith.h
+trna_search.o: $(SRCROOT)/Misc/misc.h
+trna_search.o: $(SRCROOT)/Misc/os.h
+trna_search.o: $(SRCROOT)/Misc/xalloc.h
+trna_search.o: $(SRCROOT)/seq_utils/dna_utils.h
+trna_search.o: $(SRCROOT)/seq_utils/edge.h
+trna_search.o: $(SRCROOT)/seq_utils/genetic_code.h
+trna_search.o: $(SRCROOT)/spin/codon_content.h
+trna_search.o: $(SRCROOT)/spin/trna_search.h
diff --git a/staden_config.h.in b/staden_config.h.in
index 0fe81ab..ac0e8c2 100644
--- a/staden_config.h.in
+++ b/staden_config.h.in
@@ -207,6 +207,11 @@
 /* Define to 1 if the X Window System is missing or not being used. */
 #undef X_DISPLAY_MISSING
 
+/* Enable large inode numbers on Mac OS X 10.5.  */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
 /* Number of bits in a file offset, on hosts where this is settable. */
 #undef _FILE_OFFSET_BITS
 
diff --git a/stops/Makefile b/stops/Makefile
index 9f77833..516bffc 100644
--- a/stops/Makefile
+++ b/stops/Makefile
@@ -31,3 +31,4 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 stops.o: $(PWD)/staden_config.h
+stops.o: $(SRCROOT)/Misc/os.h
diff --git a/system.mk.in b/system.mk.in
index 2af36c7..4a9cbd6 100644
--- a/system.mk.in
+++ b/system.mk.in
@@ -73,7 +73,7 @@ CPP		  = @CPP@
 CPPFLAGS	  = @CPPFLAGS@
 LDFLAGS		  = -L$(L) @LDFLAGS@ @CC_SEARCH_FLAGS@
 #CLDFLAGS	  = -L$(L) -Wl,-rpath-link,$(L) $(subst -L,-Wl$(comma)-rpath-link$(comma),$(filter -L%,$(IOLIB_LIB)))
-CLDFLAGS	  = -L$(L) @CC_SEARCH_FLAGS@
+CLDFLAGS	  = -L$(L) @LDFLAGS@ @CC_SEARCH_FLAGS@
 CXXLDFLAGS	  = $(CLDFLAGS)
 F77		  = @F77@
 FFLAGS		  = @FFLAGS@
diff --git a/text_utils/Makefile b/text_utils/Makefile
index 80fceed..49bcc13 100644
--- a/text_utils/Makefile
+++ b/text_utils/Makefile
@@ -45,3 +45,7 @@ install:
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 text_output_stubs.o: $(PWD)/staden_config.h
+text_output_stubs.o: $(SRCROOT)/Misc/misc.h
+text_output_stubs.o: $(SRCROOT)/Misc/os.h
+text_output_stubs.o: $(SRCROOT)/Misc/xalloc.h
+text_output_stubs.o: $(SRCROOT)/text_utils/text_output.h
diff --git a/tk_utils/Makefile b/tk_utils/Makefile
index ad11a73..6e238b3 100644
--- a/tk_utils/Makefile
+++ b/tk_utils/Makefile
@@ -122,25 +122,199 @@ DEPEND_OBJ = $(OBJS)
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 canvas_box.o: $(PWD)/staden_config.h
+canvas_box.o: $(SRCROOT)/Misc/misc.h
+canvas_box.o: $(SRCROOT)/Misc/os.h
+canvas_box.o: $(SRCROOT)/Misc/xalloc.h
+canvas_box.o: $(SRCROOT)/tk_utils/canvas_box.h
+canvas_box.o: $(SRCROOT)/tk_utils/container.h
+canvas_box.o: $(SRCROOT)/tk_utils/element_canvas.h
+canvas_box.o: $(SRCROOT)/tk_utils/ruler_tick.h
+canvas_box.o: $(SRCROOT)/tk_utils/tclCanvGraph.h
+canvas_box.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+canvas_box.o: $(SRCROOT)/tk_utils/tcl_utils.h
 capture.o: $(PWD)/staden_config.h
+capture.o: $(SRCROOT)/Misc/misc.h
+capture.o: $(SRCROOT)/Misc/os.h
+capture.o: $(SRCROOT)/Misc/xalloc.h
+capture.o: $(SRCROOT)/tk_utils/capture.h
+capture.o: $(SRCROOT)/tk_utils/tcl_utils.h
 cli_arg.o: $(PWD)/staden_config.h
+cli_arg.o: $(SRCROOT)/Misc/misc.h
+cli_arg.o: $(SRCROOT)/Misc/os.h
+cli_arg.o: $(SRCROOT)/Misc/xalloc.h
+cli_arg.o: $(SRCROOT)/tk_utils/cli_arg.h
 container.o: $(PWD)/staden_config.h
+container.o: $(SRCROOT)/Misc/misc.h
+container.o: $(SRCROOT)/Misc/os.h
+container.o: $(SRCROOT)/Misc/xalloc.h
+container.o: $(SRCROOT)/tk_utils/canvas_box.h
+container.o: $(SRCROOT)/tk_utils/container.h
+container.o: $(SRCROOT)/tk_utils/container_ruler.h
+container.o: $(SRCROOT)/tk_utils/element_canvas.h
+container.o: $(SRCROOT)/tk_utils/tclCanvGraph.h
+container.o: $(SRCROOT)/tk_utils/tcl_utils.h
+container.o: $(SRCROOT)/tk_utils/text_output.h
 container_ruler.o: $(PWD)/staden_config.h
+container_ruler.o: $(SRCROOT)/Misc/misc.h
+container_ruler.o: $(SRCROOT)/Misc/os.h
+container_ruler.o: $(SRCROOT)/Misc/xalloc.h
+container_ruler.o: $(SRCROOT)/tk_utils/canvas_box.h
+container_ruler.o: $(SRCROOT)/tk_utils/container.h
+container_ruler.o: $(SRCROOT)/tk_utils/tcl_utils.h
+container_ruler.o: $(SRCROOT)/tk_utils/text_output.h
 element_canvas.o: $(PWD)/staden_config.h
+element_canvas.o: $(SRCROOT)/Misc/misc.h
+element_canvas.o: $(SRCROOT)/Misc/os.h
+element_canvas.o: $(SRCROOT)/Misc/xalloc.h
+element_canvas.o: $(SRCROOT)/tk_utils/canvas_box.h
+element_canvas.o: $(SRCROOT)/tk_utils/container.h
+element_canvas.o: $(SRCROOT)/tk_utils/element_canvas.h
+element_canvas.o: $(SRCROOT)/tk_utils/tclCanvGraph.h
+element_canvas.o: $(SRCROOT)/tk_utils/text_output.h
 init.o: $(PWD)/staden_config.h
+init.o: $(SRCROOT)/Misc/misc.h
+init.o: $(SRCROOT)/Misc/os.h
+init.o: $(SRCROOT)/Misc/xalloc.h
+init.o: $(SRCROOT)/tk_utils/tclCanvGraph.h
+init.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+init.o: $(SRCROOT)/tk_utils/tcl_io_lib.h
+init.o: $(SRCROOT)/tk_utils/user_defaults.h
 misc.o: $(PWD)/staden_config.h
+misc.o: $(SRCROOT)/Misc/getfile.h
+misc.o: $(SRCROOT)/Misc/misc.h
+misc.o: $(SRCROOT)/Misc/os.h
+misc.o: $(SRCROOT)/Misc/xalloc.h
+misc.o: $(SRCROOT)/seq_utils/renz_utils.h
+misc.o: $(SRCROOT)/tk_utils/capture.h
+misc.o: $(SRCROOT)/tk_utils/cli_arg.h
+misc.o: $(SRCROOT)/tk_utils/tcl_utils.h
+misc.o: $(SRCROOT)/tk_utils/text_output.h
 postscript.o: $(PWD)/staden_config.h
+postscript.o: $(SRCROOT)/Misc/misc.h
+postscript.o: $(SRCROOT)/Misc/os.h
+postscript.o: $(SRCROOT)/Misc/xalloc.h
+postscript.o: $(SRCROOT)/tk_utils/cli_arg.h
+postscript.o: $(SRCROOT)/tk_utils/postscript.h
+postscript.o: $(SRCROOT)/tk_utils/split.h
 restriction_enzyme_map.o: $(PWD)/staden_config.h
+restriction_enzyme_map.o: $(SRCROOT)/Misc/misc.h
+restriction_enzyme_map.o: $(SRCROOT)/Misc/os.h
+restriction_enzyme_map.o: $(SRCROOT)/Misc/xalloc.h
+restriction_enzyme_map.o: $(SRCROOT)/seq_utils/renz_utils.h
+restriction_enzyme_map.o: $(SRCROOT)/tk_utils/canvas_box.h
+restriction_enzyme_map.o: $(SRCROOT)/tk_utils/tcl_utils.h
+restriction_enzyme_map.o: $(SRCROOT)/tk_utils/text_output.h
 ruler_tick.o: $(PWD)/staden_config.h
+ruler_tick.o: $(SRCROOT)/Misc/misc.h
+ruler_tick.o: $(SRCROOT)/Misc/os.h
+ruler_tick.o: $(SRCROOT)/Misc/xalloc.h
+ruler_tick.o: $(SRCROOT)/tk_utils/canvas_box.h
+ruler_tick.o: $(SRCROOT)/tk_utils/container.h
+ruler_tick.o: $(SRCROOT)/tk_utils/ruler_tick.h
 sheet.o: $(PWD)/staden_config.h
+sheet.o: $(SRCROOT)/Misc/misc.h
+sheet.o: $(SRCROOT)/Misc/os.h
+sheet.o: $(SRCROOT)/Misc/xalloc.h
+sheet.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+sheet.o: $(SRCROOT)/tk_utils/sheet.h
 split.o: $(PWD)/staden_config.h
+split.o: $(SRCROOT)/Misc/misc.h
+split.o: $(SRCROOT)/Misc/os.h
+split.o: $(SRCROOT)/Misc/xalloc.h
+split.o: $(SRCROOT)/tk_utils/split.h
+tclXkeylist.o: $(SRCROOT)/tk_utils/tclExtdInt.h
+tclXutil.o: $(SRCROOT)/tk_utils/tclExtdInt.h
 tcl_debug.o: $(PWD)/staden_config.h
+tcl_debug.o: $(SRCROOT)/Misc/misc.h
+tcl_debug.o: $(SRCROOT)/Misc/os.h
+tcl_debug.o: $(SRCROOT)/Misc/xalloc.h
+tcl_debug.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tcl_io_lib.o: $(SRCROOT)/tk_utils/tcl_io_lib.h
 tcl_utils.o: $(PWD)/staden_config.h
+tcl_utils.o: $(SRCROOT)/Misc/misc.h
+tcl_utils.o: $(SRCROOT)/Misc/os.h
+tcl_utils.o: $(SRCROOT)/Misc/vlen.h
+tcl_utils.o: $(SRCROOT)/Misc/xalloc.h
+tcl_utils.o: $(SRCROOT)/tk_utils/tclXkeylist.h
+tcl_utils.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tcl_utils.o: $(SRCROOT)/tk_utils/text_output.h
 text_output.o: $(PWD)/staden_config.h
+text_output.o: $(SRCROOT)/Misc/FtoC.h
+text_output.o: $(SRCROOT)/Misc/getfile.h
+text_output.o: $(SRCROOT)/Misc/misc.h
+text_output.o: $(SRCROOT)/Misc/os.h
+text_output.o: $(SRCROOT)/Misc/vlen.h
+text_output.o: $(SRCROOT)/Misc/xalloc.h
+text_output.o: $(SRCROOT)/tk_utils/tcl_utils.h
+text_output.o: $(SRCROOT)/tk_utils/text_output.h
 tkRaster.o: $(PWD)/staden_config.h
+tkRaster.o: $(SRCROOT)/Misc/misc.h
+tkRaster.o: $(SRCROOT)/Misc/os.h
+tkRaster.o: $(SRCROOT)/Misc/xalloc.h
+tkRaster.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkRaster.o: $(SRCROOT)/tk_utils/tkRaster.h
+tkRaster.o: $(SRCROOT)/tk_utils/tkRasterBuiltIn.h
+tkRasterBuiltIn.o: $(SRCROOT)/tk_utils/tkRaster.h
+tkRasterBuiltIn.o: $(SRCROOT)/tk_utils/tkRasterBuiltIn.h
 tkSheet.o: $(PWD)/staden_config.h
+tkSheet.o: $(SRCROOT)/Misc/misc.h
+tkSheet.o: $(SRCROOT)/Misc/os.h
+tkSheet.o: $(SRCROOT)/Misc/xalloc.h
+tkSheet.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkSheet.o: $(SRCROOT)/tk_utils/sheet.h
+tkSheet.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkSheet.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkSheet.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkSheet.o: $(SRCROOT)/tk_utils/tkSheet_config.h
+tkSheet.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkSheet.o: $(SRCROOT)/tk_utils/tk_defs.h
+tkSheet_common.o: $(SRCROOT)/Misc/xalloc.h
+tkSheet_common.o: $(SRCROOT)/tk_utils/intrinsic_type.h
+tkSheet_common.o: $(SRCROOT)/tk_utils/sheet.h
+tkSheet_common.o: $(SRCROOT)/tk_utils/tkSheet.h
+tkSheet_common.o: $(SRCROOT)/tk_utils/tkSheet_common.h
+tkSheet_common.o: $(SRCROOT)/tk_utils/tkSheet_struct.h
+tkSheet_common.o: $(SRCROOT)/tk_utils/tk_defs.h
 tkTrace.o: $(PWD)/staden_config.h
+tkTrace.o: $(SRCROOT)/Misc/misc.h
+tkTrace.o: $(SRCROOT)/Misc/os.h
+tkTrace.o: $(SRCROOT)/Misc/xalloc.h
+tkTrace.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkTrace.o: $(SRCROOT)/tk_utils/postscript.h
+tkTrace.o: $(SRCROOT)/tk_utils/split.h
+tkTrace.o: $(SRCROOT)/tk_utils/tcl_utils.h
+tkTrace.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkTrace.o: $(SRCROOT)/tk_utils/tkTraceIO.h
+tkTrace.o: $(SRCROOT)/tk_utils/tk_defs.h
+tkTrace.o: $(SRCROOT)/tk_utils/trace_print.h
 tkTraceComp.o: $(PWD)/staden_config.h
+tkTraceComp.o: $(SRCROOT)/Misc/os.h
+tkTraceComp.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkTraceComp.o: $(SRCROOT)/tk_utils/postscript.h
+tkTraceComp.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkTraceComp.o: $(SRCROOT)/tk_utils/tkTraceIO.h
 tkTraceDisp.o: $(PWD)/staden_config.h
+tkTraceDisp.o: $(SRCROOT)/Misc/misc.h
+tkTraceDisp.o: $(SRCROOT)/Misc/os.h
+tkTraceDisp.o: $(SRCROOT)/Misc/xalloc.h
+tkTraceDisp.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkTraceDisp.o: $(SRCROOT)/tk_utils/postscript.h
+tkTraceDisp.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkTraceDisp.o: $(SRCROOT)/tk_utils/tkTraceIO.h
 tkTraceIO.o: $(PWD)/staden_config.h
+tkTraceIO.o: $(SRCROOT)/Misc/misc.h
+tkTraceIO.o: $(SRCROOT)/Misc/os.h
+tkTraceIO.o: $(SRCROOT)/Misc/xalloc.h
+tkTraceIO.o: $(SRCROOT)/tk_utils/cli_arg.h
+tkTraceIO.o: $(SRCROOT)/tk_utils/postscript.h
+tkTraceIO.o: $(SRCROOT)/tk_utils/tkTrace.h
+tkTraceIO.o: $(SRCROOT)/tk_utils/trace_print.h
 trace_print.o: $(PWD)/staden_config.h
+trace_print.o: $(SRCROOT)/Misc/misc.h
+trace_print.o: $(SRCROOT)/Misc/os.h
+trace_print.o: $(SRCROOT)/Misc/xalloc.h
+trace_print.o: $(SRCROOT)/tk_utils/cli_arg.h
+trace_print.o: $(SRCROOT)/tk_utils/postscript.h
+trace_print.o: $(SRCROOT)/tk_utils/split.h
+trace_print.o: $(SRCROOT)/tk_utils/tkTrace.h
+trace_print.o: $(SRCROOT)/tk_utils/trace_print.h
diff --git a/tk_utils/func_edit.tcl b/tk_utils/func_edit.tcl
new file mode 100644
index 0000000..dbee679
--- /dev/null
+++ b/tk_utils/func_edit.tcl
@@ -0,0 +1,25 @@
+# Allows editing of Tcl functions from within the console
+proc func_edit {func} {
+    if {[catch {info arg $func} err]} {
+	tk_messageBox -message $err
+	return
+    }
+
+    set t "[tmpnam].tcl"
+    set fd [open $t w]
+    puts $fd "proc $func [list [info arg $func]] {[info body $func]}"
+    close $fd
+
+    #exec xterm -e emacs -nw $t
+    exec xemacs $t
+
+    set fd [open $t r]
+    set code [read $fd]
+    close $fd
+    file delete $t
+
+    if {[catch {uplevel #0 $code} err]} {
+	tk_messageBox -message $err
+	return
+    }
+}
\ No newline at end of file
diff --git a/tk_utils/help.tcl b/tk_utils/help.tcl
index 96b1b80..e1c055f 100644
--- a/tk_utils/help.tcl
+++ b/tk_utils/help.tcl
@@ -276,7 +276,11 @@ proc HMlink_callback {win link {future clear}} {
 
     if {[string index $link 0] != "/"} {
 	global help_path
-	set link "$help_path/$link"
+	if {[file exists [regsub {([^#]*)(#.*)?} $link "$help_path/\\1"]]} {
+	    set link "$help_path/$link"
+	} else {
+	    set link "$help_path/../$link"
+	}
     }
 
     if [string match *#* $link] {
diff --git a/tk_utils/init.tcl b/tk_utils/init.tcl
index 78f88a5..035f161 100644
--- a/tk_utils/init.tcl
+++ b/tk_utils/init.tcl
@@ -66,6 +66,7 @@ if {$tcl_platform(os) == "Darwin"} {
     
     # Popup menus
     event add <<menu>>			<3> <Command-Key-3> <Command-Button-1>
+    event add <<ctrl-menu>>		<Control-3> <Control-Command-Key-3> <Control-Command-Button-1>
     
     # Editor bits
     event add <<trace>>	\
@@ -111,6 +112,7 @@ if {$tcl_platform(os) == "Darwin"} {
     
     # Popup menus
     event add <<menu>>			<3>
+    event add <<ctrl-menu>>		<Control-3>
     
     # Editor bits
     event add <<trace>>			<Double-2> <Double-1>
diff --git a/tk_utils/tclIndex b/tk_utils/tclIndex
index ad6d1df..59a3d3c 100644
--- a/tk_utils/tclIndex
+++ b/tk_utils/tclIndex
@@ -552,3 +552,5 @@ set auto_index(xtwinspin) [list source [file join $dir xtwinspin.tcl]]
 set auto_index(xradiobox) [list source [file join $dir xradiobox.tcl]]
 
 set auto_index(console) [list source [file join $dir console.tcl]]
+
+set auto_index(func_edit) [list source [file join $dir func_edit.tcl]]
diff --git a/tk_utils/xcombobox.tcl b/tk_utils/xcombobox.tcl
index 593e7db..fe60e49 100644
--- a/tk_utils/xcombobox.tcl
+++ b/tk_utils/xcombobox.tcl
@@ -33,6 +33,7 @@ widget create Xcombobox -type frame -base entry -components {
     {-values 		values		Values		{}}
     {-command 		command		Command		{}}
     {-postcommand 	postCommand	PostCommand	{}}
+    {-fixed_list        fixedList       FixedList       0}
 }
 
 namespace eval ::Widget::Xcombobox {;
@@ -93,6 +94,17 @@ namespace eval ::Widget::Xcombobox {;
 	    -values {
 		uplevel \#0 [list set $data(-valuesvariable) $val]
 	    }
+	    -fixed_list {
+		if {$data(-state) == "normal"} {
+		    if {$val == 1} {
+			bindtags $data(entry) [list $data(entry) \
+				 [winfo toplevel $data(entry)] all]
+		    } else {
+			bindtags $data(entry) [list $data(entry) Entry \
+				 [winfo toplevel $data(entry)] all]
+		    }
+		}
+	    }
 	}
 	set data($key) $val
     }
@@ -129,15 +141,17 @@ namespace eval ::Widget::Xcombobox {;
 	}
     }
 
-    toplevel $w.list -width $W -height 200 -class ComboList
-    wm geometry $w.list ${W}x200+$x+$y
+    toplevel $w.list -width $W -class ComboList
+    #wm geometry $w.list ${W}x200+$x+$y
+    wm geometry $w.list +$x+$y
     wm transient $w.list $w
     wm overrideredirect $w.list 1
     
     set l [listbox $w.list.l \
 	       -exportselection 0 \
 	       -yscrollcommand "$w.list.ys set" \
-	       -width 10]
+	       -width [$w cget -width]  \
+	       -height 10]
     scrollbar $w.list.ys -command "$l yview" -orient vertical
     if {[uplevel \#0 [list info exists [set ${w}(-valuesvariable)]]]} {
 	set v [uplevel \#0 [list set [set ${w}(-valuesvariable)]]]
@@ -148,8 +162,13 @@ namespace eval ::Widget::Xcombobox {;
     if {"$v" == ""} {
 	$l insert end ""
     }
-    pack $w.list.l -fill both -expand 1 -side left
-    pack $w.list.ys -fill both -side right
+    if {[llength $v] <= 10} {
+	$w.list.l configure -height [llength $v]
+	pack $w.list.l -fill both -expand 0 -side left
+    } else {
+	pack $w.list.l -fill both -expand 0 -side left
+	pack $w.list.ys -fill both -side right
+    }
 
     update idletasks
     grab -global $w.list
diff --git a/tracediff/Makefile b/tracediff/Makefile
index a8cf6f5..52575c5 100644
--- a/tracediff/Makefile
+++ b/tracediff/Makefile
@@ -50,3 +50,8 @@ DEPEND_OBJ = $(OBJSD)
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 main.o: $(PWD)/staden_config.h
+main.o: $(SRCROOT)/Misc/os.h
+main.o: $(SRCROOT)/mutlib/mutlib.h
+main.o: $(SRCROOT)/mutlib/pathutil.h
+main.o: $(SRCROOT)/mutlib/stringlist.hpp
+main.o: $(SRCROOT)/tracediff/staden.h
diff --git a/tracediff/main.cpp b/tracediff/main.cpp
index ed88df6..cd10028 100644
--- a/tracediff/main.cpp
+++ b/tracediff/main.cpp
@@ -1,15 +1,35 @@
 /*
  * Copyright (c) Medical Research Council 2001. All rights reserved.
  *
- * Permission to use, copy, modify and distribute this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * this copyright and notice appears in all copies.
- *
- * This file was written as part of the Staden Package at the MRC Laboratory
- * of Molecular Biology, Hills Road, Cambridge, CB2 2QH, United Kingdom.
- *
- * MRC disclaims all warranties with regard to this software.
- *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *    - Redistributions of source code must retain the above copyright notice, 
+ *      this list of conditions and the following disclaimer.
+ * 
+ *    - Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer
+ *      in the documentation and/or other materials provided with the
+ *      distribution.
+ * 
+ *    - Neither the name of the MEDICAL RESEARCH COUNCIL, THE
+ *      LABORATORY OF MOLECULAR BIOLOGY nor the names of its
+ *      contributors may be used to endorse or promote products
+ *      derived from this software without specific prior written
+ *      permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include <staden_config.h>
diff --git a/vector_clip/Makefile b/vector_clip/Makefile
index 4991f1d..9699358 100644
--- a/vector_clip/Makefile
+++ b/vector_clip/Makefile
@@ -39,3 +39,8 @@ install:
 # DO NOT DELETE
 
 vector_clip.o: $(PWD)/staden_config.h
+vector_clip.o: $(SRCROOT)/Misc/getfile.h
+vector_clip.o: $(SRCROOT)/Misc/misc.h
+vector_clip.o: $(SRCROOT)/Misc/os.h
+vector_clip.o: $(SRCROOT)/Misc/xalloc.h
+vector_clip.o: $(SRCROOT)/seq_utils/dna_utils.h

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/staden.git



More information about the debian-med-commit mailing list