changeset 0:acc8d8bfeb9a

Uploaded
author jjohnson
date Wed, 08 Feb 2012 16:59:24 -0500
parents
children 4f6952e0af48
files CREST.pl Gene.pm GeneModel.pm README SCValidator.pm SVExtTools.pm SVUtil.pm StructVar.pm Transcript.pm Tree/DAG_Node.pm Tree/Interval.pm Tree/Interval/Node.pm Tree/Interval/Node/Constants.pm bam2html.pl countDiff.pl crest.xml enum.pm example/germline.bam example/germline.bam.bai example/germline.cover example/germline.sclip.txt example/tumor.bam example/tumor.bam.bai example/tumor.cover example/tumor.cover.somatic.cover example/tumor.predSV.html example/tumor.predSV.txt example/tumor.sclip.txt example/tumor.stat extractSClip.pl germline.bam germline.bam.bai getSomaticPindel.pl getUniqSV.pl ptrfinder removeDupSV.pl tumor.bam tumor.bam.bai tumor.bam.cover tumor.bam.sclip.txt
diffstat 40 files changed, 11807 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CREST.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,1232 @@
+#!/usr/bin/perl -w
+#use lib '/home/jwang2/AssembleTest/Detect/nonSJsrc/dev';
+use strict;
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+use Bio::DB::Sam;
+use Bio::DB::Sam::Constants;
+use Bio::SearchIO;
+use Bio::SeqIO;
+use File::Temp qw/ tempfile tempdir /;
+use File::Spec;
+use File::Path;
+use File::Copy;
+use File::Basename;
+use List::MoreUtils qw/ uniq /;
+use Cwd;
+use SCValidator qw($lowqual_cutoff $min_percent_id $min_percent_hq LEFT_CLIP RIGHT_CLIP);
+use SVUtil qw($use_scratch $work_dir clip_fa_file prepare_reads parse_range get_input_bam 
+	find_smallest_cover get_work_dir is_PCR_dup read_fa_file get_sclip_reads);
+use StructVar;
+require SVExtTools;
+
+use Transcript;
+use Gene;
+use GeneModel;
+
+my $debug = 1;
+$min_percent_id = 90;
+# input/output
+my ( $out_dir, $out_prefix, $range, $bam_d,	$bam_g, $sclip_file);
+my $out_suffix = "predSV.txt";
+my $read_len = 100;
+my $ref_genome ;
+
+my $hetero_factor = 0.4;
+my $triger_p_value = 0.05;
+
+#RNASeq support
+my $RNASeq = 0;
+my $gene_model_file;
+my $gm_format = "REFFLAT";
+my $gm;
+my $max_sclip_reads = 50; # we will consider the position if we have enough sclipped reads
+my $min_one_side_reads = 5;
+my $min_pct_sclip_reads = 5; # we require at least 5% reads have softclipping
+
+# external programs related variable
+# 1. cap3 related variables
+my $cap3 = "cap3";
+my $cap3_options=" -h 70 -y 10 > /dev/null";
+
+# 2 blat related variables, using blat server and blat standalone
+my $blat_client_exe = "gfClient";
+my $blat_client_options = ' -out=psl -nohead -minIdentity=95 -maxIntron=5';  
+my $target_genome = "hg18.2bit";
+my $dir_2bit = "/";
+my $blat_server = "sjblat";
+my $blat_port = 50000;
+my $blat_exe = "blat";
+my $blat_options = " -tileSize=7 -stepSize=1 -out=psl -minScore=15 -noHead -maxIntron=1 ";
+
+$use_scratch = 0;
+my $paired = 1;
+
+my $rescue = 1;
+# other options 
+my ($min_sclip_reads, $max_repetitive_cover, $min_sclip_len );
+my $min_hit_reads;
+my $rmdup;
+my $min_clip_len;
+my ($max_score_diff, $max_num_hits);
+my ($min_dist_diff, $min_hit_len) = (15, 15);
+
+#SV filter related parameters
+my $max_bp_dist = 15;
+my $min_percent_cons_of_read = 0.75;
+my $germline_seq_width = 100;
+my $germline_search_width = 50;
+my $rm_tandem_repeat = 1; #tandem repeat mediated events
+my $tr_max_indel_size = 100;   #tandem repeat mediated indel size
+my $tr_min_size = 2;
+my $tr_max_size = 8; 	  #tandem repeat max_size of single repeat
+my $tr_min_num = 4;		  #tandem repeat minimum number of occurence
+
+# verification pupuse
+my $verify_file;
+my $sensitive;
+my $cluster_size;
+
+# common help options
+my ( $help, $man, $version, $usage );
+my $optionOK = GetOptions(
+	# SV validation related parameters
+	'max_bp_dist=i'		=> \$max_bp_dist,
+	'min_percent_cons_of_read=f'	=> \$min_percent_cons_of_read,
+	'germline_seq_width=i'	=> \$germline_seq_width,
+	'germline_search_width=i'	=> \$germline_search_width,
+	# tandem repeat related parameters
+	'rm_tandem_repeat!'	=> \$rm_tandem_repeat,
+	'tr_max_indel_size=i'	=> \$tr_max_indel_size,
+	'tr_min_size=i'	=> \$tr_min_size,
+	'tr_max_size=i'	=> \$tr_max_size,
+	'tr_min_num=i'	=> \$tr_min_num,
+	'hetero_factor=f'	=> \$hetero_factor,
+	'triger_p_value=f'	=> \$triger_p_value,
+	
+	# input/output 
+	#'s|sample=s'	=> \$sample,
+	'd|input_d=s'	=> \$bam_d,
+	'g|inpug_g=s'	=> \$bam_g,
+	'f|sclipfile=s'	=> \$sclip_file,
+	'p|prefix=s'	=> \$out_prefix,
+	'o|out_dir=s'	=> \$out_dir,
+	'l|read_len=i'	=> \$read_len,
+	'ref_genome=s'	=> \$ref_genome,
+	'v|verify_file=s'	=> \$verify_file,
+	'sensitive'		=> \$sensitive,	
+	'paired!'		=> \$paired,
+	'rescue!'		=> \$rescue,
+	'cluster_size=i'	=> \$cluster_size,
+	# external programs location and options
+	'scratch!'		=> \$use_scratch,
+	'cap3=s'		=> \$cap3,
+	'cap3opt=s'		=> \$cap3_options,
+	'blatclient=s'	=> \$blat_client_exe,
+	'blatclientopt=s'	=> \$blat_client_options,
+	'blat=s'		=> \$blat_exe,
+	't|target_genome=s'	=> \$target_genome,
+	'blatopt=s'		=> \$blat_options,
+	'blatserver=s'	=> \$blat_server,
+	'blatport=i'	=> \$blat_port,
+	'2bitdir=s'		=> \$dir_2bit,
+	#RNAseq support
+	'RNASeq'		=> \$RNASeq,
+	'genemodel=s'		=> \$gene_model_file,
+	'gmformat=s'		=> \$gm_format,
+	#other related parameters
+	'r|range=s'		=> \$range,
+	'max_score_diff=i'		=> \$max_score_diff,
+	'm|min_sclip_reads=i'		=> \$min_sclip_reads,
+	'min_one_side_reads=i'		=> \$min_one_side_reads,
+	'max_rep_cover=i'	=> \$max_repetitive_cover,
+	'min_sclip_len=i'	=> \$min_sclip_len,
+	'min_hit_len=i'		=> \$min_hit_len,
+	'min_dist_diff=i'	=> \$min_dist_diff,
+	'min_hit_reads=i'	=> \$min_hit_reads,
+	'rmdup!'		=> \$rmdup,
+
+	# soft_clipping related parameters (from SVDector package)
+	'min_percent_id=i'	=> \$min_percent_id,
+	'min_percent_hq=i'	=> \$SCValidator::min_percent_hq,
+	'lowqual_cutoff=i'	=> \$lowqual_cutoff,
+
+	# common help parameters
+	'h|help|?'		=> \$help,
+	'man'			=> \$man,
+	'usage'			=> \$usage,
+	'version'		=> \$version,
+);
+
+pod2usage(-verbose=>2) if($man or $usage);
+pod2usage(1) if($help or $version );
+
+my $start_dir = getcwd;
+
+# figure out input file
+if(!$bam_d) {
+	pod2usage(1);
+	croak "You need specify input bam file(s)";
+}
+
+if(!$sclip_file) {
+	pod2usage(1);
+	croak "You need to specify the softclipping file";
+}
+$sclip_file = File::Spec->rel2abs($sclip_file);
+
+if(!$ref_genome) {
+	pod2usage(1);
+	croak "You need to specify the reference genome used by bam file";
+}
+
+croak "The file you sepcified does not exist" unless (
+	-e $sclip_file && -e $bam_d && -e $ref_genome && -e $target_genome);
+my $input_base;
+$bam_d = File::Spec->rel2abs($bam_d);
+$input_base = fileparse($bam_d);
+$bam_g = File::Spec->rel2abs($bam_g) if($bam_g);
+
+#RNASeq support
+if($RNASeq) {
+	croak "You need specify the input gene model file" unless ($gene_model_file);
+	StructVar->add_RNASeq_filter();
+	$min_sclip_reads = 10 unless $min_sclip_reads;
+	$max_repetitive_cover = 5000 unless $max_repetitive_cover;
+	$min_sclip_len = 20 unless $min_clip_len;
+	$max_score_diff = 5 unless $max_score_diff;
+	$max_num_hits = 3 unless $max_num_hits;
+	$min_hit_reads = 5 unless $min_hit_reads;
+	$cluster_size = 5 unless $cluster_size;
+}
+else {
+	$min_sclip_reads = 3 unless $min_sclip_reads;
+	$max_repetitive_cover = 500 unless $max_repetitive_cover;
+	$min_sclip_len = 20 unless $min_clip_len;
+	$max_score_diff = 5 unless $max_score_diff;
+	$max_num_hits = 10 unless $max_num_hits;
+	$min_hit_reads = 1 unless $min_hit_reads;
+	$cluster_size = 1 unless $cluster_size;
+}
+
+if($gene_model_file) {
+	$gm = GeneModel->new if($gene_model_file);
+	$gm->from_file($gene_model_file, $gm_format);
+	StructVar->gene_model($gm);
+}
+
+# set up the external programs and validators
+# Those variable will be global
+my $assembler = Assembler->new( 
+	-PRG => $cap3,
+	-OPTIONS => $cap3_options
+);
+
+my $mapper = Mapper->new(
+	-PRG => join(' ', ($blat_client_exe, $blat_server, $blat_port)),
+	-OPTIONS => $blat_client_options,
+	-BIT2_DIR => $dir_2bit,
+	-MAX_SCORE_DIFF => $max_score_diff,
+	-MAX_NUM_HITS => $max_num_hits,
+);
+
+my $aligner = Aligner->new(
+	-PRG => $blat_exe,
+	-OPTIONS => $blat_options,
+);
+
+StructVar->assembler($assembler);
+StructVar->read_len($read_len);
+StructVar->aligner($aligner);
+StructVar->mapper($mapper);
+StructVar->RNASeq(1) if($RNASeq);
+StructVar->genome($target_genome);
+StructVar->remove_filter("tandem_repeat") unless($rm_tandem_repeat);
+StructVar->tr_max_indel_size($tr_max_indel_size);
+StructVar->tr_min_size($tr_min_size);
+StructVar->tr_max_size($tr_max_size);
+StructVar->tr_min_num($tr_min_num);
+StructVar->max_bp_dist($max_bp_dist) if($max_bp_dist);
+StructVar->germline_seq_width($germline_seq_width) if($germline_seq_width);
+StructVar->germline_search_width($germline_search_width) if($germline_search_width);
+
+
+my $validator = SCValidator->new();
+$validator->remove_validator('strand_validator') if(!$paired);
+
+#setup output and working directory
+$out_dir = getcwd if(!$out_dir);
+mkdir $out_dir if(!-e $out_dir || ! -d $out_dir);
+$work_dir = get_work_dir(-SCRATCH => $use_scratch);
+$work_dir = $out_dir if(!$work_dir);
+$use_scratch = undef if($work_dir eq $out_dir); # don't erase the out_dir
+chdir($work_dir); 
+
+# figure out output prefix
+if(!$out_prefix) {
+	$out_prefix = $input_base;
+}
+
+my $sam_d = Bio::DB::Sam->new( -bam => $bam_d, -fasta => $ref_genome);
+StructVar->sam_d($sam_d);
+my $sam_g;
+if($bam_g) {
+	$sam_g = Bio::DB::Sam->new( -bam => $bam_g);
+	StructVar->sam_g($sam_g);
+}
+
+#my $output_file = File::Spec->catfile($outdir, $out_prefix . $out_suffix);
+my $output_file;
+$output_file = join('.', $out_prefix, $out_suffix);
+$output_file = File::Spec->catfile($out_dir, $output_file);
+
+# the softclip file is sorted, so no need to re-sort it
+open my $SCLIP, "<$sclip_file" or croak "can't open $sclip_file:$OS_ERROR";
+my %sclip;
+my $pre_p;
+while( my $line = <$SCLIP> ) {
+	chomp $line;
+	my ($chr, $pos, $ort, $cover, $C) = split /\t/, $line;
+	if( ! exists($sclip{$chr})) {
+		$sclip{$chr} = [];
+		$pre_p = $pos;
+	}
+	$C = 30 unless $C;
+	if($pos < $pre_p) {
+		print STDERR "The input file is not sorted!";
+		exit(1);
+	}
+	push @{$sclip{$chr}}, [$pos, $ort, $cover, $C];
+}
+close $SCLIP;
+
+my @final_SV;
+my @s_cover = @{find_smallest_cover($min_sclip_reads, $hetero_factor, $triger_p_value)};
+if($range) {
+	@final_SV = detect_range_SVs($sam_d, $range, \%sclip, \@s_cover);
+}
+else {
+	foreach my $chr (keys %sclip) {
+		my @tmpSV = detect_range_SVs($sam_d, $chr, \%sclip, \@s_cover);
+		@final_SV = @tmpSV unless (@final_SV);
+		foreach my $sv (@tmpSV) {
+			push @final_SV, $sv if($sv && ! is_dup_SV(\@final_SV, $sv));
+		}
+	}
+}
+undef %sclip;
+open my $OUT, ">$output_file" or croak "can't open $output_file:$OS_ERROR";
+foreach my $SV (@final_SV) {
+	if($SV->filter) {
+		print $OUT $SV->to_string ;
+		if($RNASeq) {
+			print $OUT "\t", join("\t", @{$SV->get_genes});
+		}
+		print $OUT "\n";
+	}
+}
+chdir $start_dir;
+exit(0);
+
+sub detect_range_SVs {
+	my ($sam_d, $range, $r_sclips, $r_scover) = @_;
+	my ($chr, $start, $end) = parse_range($range);
+	my ($tid) = $sam_d->header->parse_region($chr);
+	my $chr_len = $sam_d->header->target_len->[$tid];
+	my $r_range_sclips = search_sclip($r_sclips, $range);
+	return unless $r_range_sclips;
+	my @scover = @{$r_scover};
+	my @rtn;
+
+	my ($f_tree, $r_tree);
+	if($RNASeq) {
+		my $full_chr = $chr;
+		my ($gm_chr) = $gm->get_all_chr;	
+		$full_chr = "chr" . $chr if($chr !~ m/chr/ && $gm_chr =~ /chr/);
+		($f_tree, $r_tree) = ($gm->sub_model($full_chr, "+"), $gm->sub_model($full_chr, "-"))	if($RNASeq);
+	}
+	my $n = scalar @{$r_range_sclips};
+	push @{$r_range_sclips}, [$r_range_sclips->[$n-1][0] + $cluster_size + 1, '+', 1, 50];
+	push @{$r_range_sclips}, [$r_range_sclips->[$n-1][0] + $cluster_size + 1, '-', 1, 50];
+	$n = $n + 2;
+
+	# try to save the 1 base off problem of soft-clipping 
+	my (@ss1, $p1, $c1);
+	my (@ss2, $p2, $c2);
+	my ($n1, $n2, $cover1, $cover2) = (0, 0, 0, 0);
+	for( my $i = 0; $i < $n; $i++) {
+		my $s = $r_range_sclips->[$i];
+#		print join("\t", @{$s}), "\n" if($debug);
+		my $clip = $s->[1] eq '+' ? RIGHT_CLIP : LEFT_CLIP;
+		next if($s->[0] >= $chr_len );
+		if($clip == RIGHT_CLIP) {
+			$p1 = $c1 = $s->[0] unless $p1;
+			if($s->[0] < $c1) {
+				print STDERR "The soft-clipping file has problem! It's either not sorted or
+					the file has mutliple parts for a chromsome!";
+				last;
+			}
+			if($s->[0] - $c1 < $cluster_size) {
+				$n1 += $s->[2];
+				$cover1 = $s->[3] if($cover1 < $s->[3]);
+				push @ss1, $s; 
+				if($s->[0] < $c1) {
+					$p1 += $s->[0];
+					$c1 = $p1 / scalar @ss1;
+				}
+				next;
+			}
+		}
+		else {
+			$p2 = $c2 = $s->[0] unless $p2;
+			if($s->[0] < $c2) {
+				print STDERR "The soft-clipping file has problem! It's either not sorted or
+					the file has mutliple parts for a chromsome!";
+				last;
+			}
+			if($s->[0] - $p2 < $cluster_size) {
+				$n2 += $s->[2];
+				$cover2 = $s->[3] if($cover2 < $s->[3]);
+				push @ss2, $s; 
+				if($s->[0] < $c2) {
+					$p2 += $s->[0];
+					$c2 = $p2 / scalar @ss2;
+				}
+				next;
+			}
+		}
+				
+		my @cc = $clip == LEFT_CLIP ? @ss2 : @ss1;	
+		my $pos = $clip == LEFT_CLIP ? $ss2[$#ss2]->[0] : $ss1[0]->[0]; 
+		my ($n_s, $cover_s) = $clip == LEFT_CLIP ? ($n2, $cover2) : ($n1, $cover1);
+		my $tmp_range = $clip == LEFT_CLIP ? [$ss2[0]->[0], $ss2[$#ss2]->[0] + $cluster_size] : 
+			[$ss1[0]->[0] - $cluster_size, $ss1[$#ss1]->[0]];
+
+		if($clip == LEFT_CLIP) {
+			@ss2 = (); $p2 = $c2 = $s->[0];
+			$n2 = $s->[2];
+			$cover2 = $s->[3];
+			push @ss2, $s;
+		}
+		else {
+			@ss1 = (); $p1 = $c1 = $s->[0];
+			$n1 = $s->[2];
+			$cover1 = $s->[3];
+			push @ss1, $s;
+		}
+
+	    my @s_reads;
+		if($RNASeq) {
+#			print $n_s, "\n";
+			next if($n_s < $min_sclip_reads && $cover_s > $s_cover[$n_s] ) ;
+			next if($n_s < $max_sclip_reads && $n_s * 100 <= $cover_s * $min_pct_sclip_reads);
+			my @f_genes = $f_tree->intersect($tmp_range);
+			my @r_genes = $r_tree->intersect($tmp_range);
+			next if(scalar @f_genes == 0 && scalar @r_genes == 0);
+		}
+		else {
+			if($n_s < $min_sclip_reads) { #too few covered
+				if($cover_s > $s_cover[$n_s]) {
+					next if(!$sensitive);
+					foreach my $c (@cc) {
+						next if($c->[0] >= $chr_len);
+						push @s_reads, get_sclip_reads(-SAM => $sam_d,
+										   -CHR =>$chr, 
+										   -START => $c->[0], 
+										   -END => $c->[0], 
+										   -CLIP => $clip, 
+										   -MINCLIPLEN => 0,
+										   -VALIDATOR => $validator,
+										   -PAIRED => $paired,
+										   -RMDUP => $rmdup,
+										   -EXTRA => abs($c->[0] - $pos) );
+					}
+				}
+			}
+		}
+		if(! @s_reads) {
+			foreach my $c (@cc) {
+				next if($c->[0] >= $chr_len);
+				push @s_reads, get_sclip_reads(-SAM => $sam_d,
+										   -CHR =>$chr, 
+										   -START => $c->[0], 
+										   -END => $c->[0], 
+										   -CLIP => $clip, 
+										   -MINCLIPLEN => 0,
+										   -VALIDATOR => $validator,
+										   -PAIRED => $paired,
+										   -RMDUP => $rmdup,
+										   -EXTRA => abs($c->[0] - $pos) );
+			}
+		}
+		my $l = 0;
+		foreach my $r (@s_reads) {
+			my $len = length $r->{seq};
+			$l = $len if($l < $len);
+		}
+		next if ($l < $min_sclip_len);
+		print STDERR join("\t", ($chr, $pos, $clip == LEFT_CLIP ? "-" : "+", scalar @s_reads)), "\n";
+		my @SV =  detect_SV(
+			-SAM => $sam_d, 
+			-CHR => $chr, 
+			-POS => $pos, 
+			-ORT => $clip == LEFT_CLIP ? "-" : "+", 
+			-SCLIP => \%sclip,
+			-COVER => $cover_s,
+			-SREADS => \@s_reads);
+		foreach my $sv (@SV) {
+			$sv->{type} = $sv->type;
+			push @rtn, $sv if($sv && ! is_dup_SV(\@rtn, $sv));
+		}
+	}
+
+	if($RNASeq) {
+		push @rtn,	find_del_SVs($sam_d, $chr, $start, $end);
+	}
+	return @rtn;
+}
+
+sub is_dup_SV {
+	my($r_SVs, $sv) = @_;
+	foreach my $s (@{$r_SVs}) {
+		return 1
+		if( $s->first_bp->{pos} == $sv->second_bp->{pos} &&
+			$s->first_bp->{chr} eq $sv->second_bp->{chr} &&
+			$s->second_bp->{pos} == $sv->first_bp->{pos} &&
+			$s->second_bp->{chr} eq $sv->first_bp->{chr} &&
+			$s->{type} == $sv->{type} );
+		return 1
+		if( $s->first_bp->{pos} == $sv->first_bp->{pos} &&
+			$s->first_bp->{chr} eq $sv->first_bp->{chr} &&
+			$s->second_bp->{pos} == $sv->second_bp->{pos} &&
+			$s->second_bp->{chr} eq $sv->second_bp->{chr} &&
+			$s->{type} == $sv->{type} );
+
+	}
+	return;
+}
+
+sub search_sclip {
+	my ($r_sclip, $range) = @_;
+	my ($chr, $start, $end) = parse_range($range);
+	return $r_sclip->{$chr} if(!$start);
+	my $start_i = bin_search($r_sclip->{$chr}, $start);	
+	my $end_i = bin_search($r_sclip->{$chr}, $end);
+	my @tmp = @{$r_sclip->{$chr}};
+	if($start_i <= $end_i) {
+		@tmp = @tmp[$start_i .. $end_i];
+		if($start_i == $end_i) {
+			return undef if($tmp[0]->[0] < $start || $tmp[0]->[0] > $end);
+		}
+		return \@tmp;
+	}
+	else {
+		return undef;
+	}
+}
+
+sub bin_search {
+	my ($a, $p) = @_;
+	my ($s, $e) = (0, scalar(@{$a})-1);
+	my $m = int( ($s + $e)/2);
+	while(1) {
+		return $s if($a->[$s][0] >= $p);	
+		return $e if($a->[$e][0] <= $p);
+		return $m if($a->[$m][0] == $p || ($a->[$m-1][0] < $p && $a->[$m+1][0] > $p));
+		if($a->[$m][0] > $p) {
+			$e = $m;
+		}
+		else {
+			$s = $m;
+		}
+		$m = int( ($s+$e)/2 );
+	}
+}
+
+sub count_coverage {
+	my ($sam, $chr, $pos, $clip) = @_;
+	if($rmdup && !$RNASeq) {
+		my @pairs;
+		my $seg = $sam->segment(-seq_id => $chr, -start => $pos, -end => $pos);
+		my $n = 0;
+		return 0 unless $seg;
+		my $itr = $seg->features(-iterator => 1);
+		while( my $a = $itr->next_seq) {
+			next unless($a->start && $a->end); #why unmapped reads here?
+			my $sclip_len = 0;
+			if($clip) {
+				my @cigar_array = @{$a->cigar_array};
+				#$sclip_len = $1 if($a->cigar_str =~ m/S(\d+)$/ && $clip == RIGHT_CLIP); 
+				$sclip_len = $cigar_array[0]->[1] if($cigar_array[0]->[0] eq 'S' && $clip == RIGHT_CLIP);
+				#$sclip_len = $1 if($a->cigar_str =~ m/^S(\d+)/ && $clip == LEFT_CLIP); 
+				$sclip_len = $cigar_array[$#cigar_array]->[1] if($cigar_array[$#cigar_array]->[0] eq 'S' && $clip == RIGHT_CLIP);
+			}
+			next if(@pairs > 0 && is_PCR_dup($a, \@pairs, $sclip_len));
+			$n++;
+			return $n if( $n > $max_repetitive_cover);
+			push @pairs, [$a->start, $a->end, $a->mate_start ? $a->mate_start : 0, 
+				$a->mate_end ? $a->mate_end : 0, $sclip_len];
+		}
+		return $n;
+	}
+	else{
+		my ($c) = $sam->features(-type => 'coverage', -seq_id=> $chr, 
+			-start => $pos, -end => $pos);
+		return 0 unless $c;
+		my @c_d = $c->coverage;
+		return $c_d[0];
+	}
+}
+
+sub detect_SV {
+	my %param = @_;
+	my @s_reads = @{$param{-SREADS}};
+	my($sam, $chr, $ort, $r_sclip, $coverage) = (	$param{-SAM}, 
+		$param{-CHR},  $param{-ORT},	$param{-SCLIP},	$param{-COVER});
+	my $clip = $ort eq '+' ? RIGHT_CLIP : LEFT_CLIP;
+	return if($coverage > $max_repetitive_cover);
+	my $fa_name = prepare_reads(\@s_reads, $clip);
+	my($contig_file, $sclip_count, $contig_reads) = $assembler->run($fa_name); 
+	return if(!$contig_file or !(-e $contig_file));
+	
+	$contig_file = clip_fa_file($contig_file, $clip);
+	my $contig_seqs = read_fa_file($contig_file);	
+	if(scalar @s_reads == 1) {
+		$contig_file = clip_fa_file($fa_name, $clip);
+		$contig_seqs = read_fa_file($contig_file);
+		my @seq_names = keys %{$contig_seqs};
+		$sclip_count->{$seq_names[0]} = 1;
+	}
+
+	my @SV;
+	my $where = ($clip == LEFT_CLIP ? "right" : "left");
+	my $mapping = $mapper->run( -QUERY => $contig_file );
+	my (%reads, %quals, %s_lens, %pos);
+	foreach my $r (@s_reads) {
+		$reads{$r->{name}} = $r->{full_seq};
+		$quals{$r->{name}} = $r->{full_qual};
+		$s_lens{$r->{name}} = length($r->{seq});
+		$pos{$r->{name}} = $r->{pos};
+	}
+
+	foreach my $s (keys(%{$mapping})) {
+		next if($sclip_count->{$s} < $min_sclip_reads);
+
+		# try to find a better mapping
+		my @tmp_reads;
+		my $selected_read;
+		my @tmp_pos;
+		foreach my $n (@{$contig_reads->{$s}}) {
+			push @tmp_pos, $pos{$n};
+		}
+		@tmp_pos = uniq @tmp_pos;
+		my $real_pos = $clip == LEFT_CLIP ? $tmp_pos[$#tmp_pos] : $tmp_pos[0];
+			
+		my $n_new_SV = 0;
+		my $tmp_bp;
+		foreach my $t (@{$mapping->{$s}}) {
+			my $qort = $t->{qstrand};
+				my $t_pos = $t->{tstart};
+			$t_pos = $t->{tend} if( ($qort eq "+" && $clip == LEFT_CLIP) ||
+				($qort eq '-' && $clip == RIGHT_CLIP));
+			if($t->{tchr} eq $chr && (abs($t_pos - $real_pos) < $min_dist_diff)) { # the soft clipping is incorrect
+				@SV = @SV[0 .. ($#SV - $n_new_SV + 1)] if($n_new_SV > 0);
+				last;		
+			}
+			my $first_bp = {};
+			$first_bp->{sc_reads} =  $sclip_count->{$s};
+			$first_bp->{$where . "_chr"} = $chr;
+			$first_bp->{$where . "_pos"} = $real_pos;
+			$first_bp->{all_pos} = \@tmp_pos;
+			$first_bp->{$where . "_ort"} = "+";
+			$first_bp->{pos}  = $real_pos;
+			$first_bp->{cover} = $coverage;
+			$first_bp->{chr} = $chr;
+			my $new_where = ($where eq "right" ? "left" : "right");
+			
+			$first_bp->{$new_where . "_chr"} = $t->{tchr};
+			$first_bp->{$new_where . "_pos"} = $t_pos;
+			$first_bp->{$new_where . "_ort"} = $qort;
+			$first_bp->{sc_seq} = $contig_seqs->{$s};
+			$first_bp->{reads} = $contig_reads->{$s};
+
+			$tmp_bp = $first_bp unless $tmp_bp;
+			my $second_bp = check_sclip(-SAM => $sam, -TARGET => $t, -CHR => $chr, 
+				-POS => $real_pos, -SCLIP => $r_sclip, -CLIP => $clip);	
+			if(@{$second_bp}) {
+				foreach my $tmp_bp (@{$second_bp}) {
+					push @SV, StructVar->new(-FIRST_BP => $first_bp, -SECOND_BP => $tmp_bp);
+					$n_new_SV++;
+				}
+			}
+		}
+		# save some one side good soft-clipping SV
+		if( $rescue == 1 &&
+			$n_new_SV == 0 && 
+			$sclip_count->{$s} >= $min_one_side_reads && 
+			(scalar(@{$mapping->{$s}}) == 1 || ($mapping->{$s}[0]{perfect} == 1 && $mapping->{$s}->[1]{perfect} == 0)) &&
+			$tmp_bp->{chr} &&
+			length($contig_seqs->{$s}) * 0.95 < $mapping->{$s}[0]{matches}	) {
+
+			my %second_bp = %{$tmp_bp};
+			$second_bp{sc_reads} = 0;
+			$second_bp{sc_seq} = '';
+			($second_bp{chr}, $second_bp{pos}) = $second_bp{pos} == $second_bp{left_pos} ? 
+				($second_bp{right_chr}, $second_bp{right_pos}) : ($second_bp{left_chr}, $second_bp{left_pos});
+			$second_bp{cover} = count_coverage($sam, $second_bp{chr}, $second_bp{pos});
+			$second_bp{reads} = [];
+			push @SV, StructVar->new(-FIRST_BP => $tmp_bp, -SECOND_BP => \%second_bp);			
+		}
+
+	}
+	system("rm $fa_name");	system("rm $fa_name*");
+	return @SV;
+}
+
+sub get_gene_range {
+	my ($chr, $pos, $clip) = @_;
+	my $r = $clip == LEFT_CLIP ? [$pos, $pos+5] : [$pos - 5, $pos];
+	my @genes; 
+	my $tmp = $chr;
+	$tmp  = "chr" . $tmp if($tmp  !~ m/chr/); 
+	my ($f_tree, $r_tree) = ($gm->sub_model($tmp, "+"), $gm->sub_model($tmp, "-"));
+	push @genes, $f_tree->intersect($r);
+	push @genes, $r_tree->intersect($r);
+	my ($s, $e);
+	if(scalar @genes == 0) { #no gene here
+		return [$pos - $read_len, $pos + $read_len];
+	}
+	foreach my $g (@genes)	 {
+		my $start = $g->val->get_start($pos, $read_len);
+		my $end = $g->val->get_end($pos, $read_len);
+		$s = $start if(!$s || $s > $start);
+		$e = $end if(!$e || $e < $end);
+	}
+	return [$s, $e];
+}
+
+sub check_sclip {
+	my %arg = @_;
+	my ($sam, $chr, $pos, $target, $r_sclip, $clip) = 
+		( $arg{-SAM}, $arg{-CHR}, $arg{-POS}, $arg{-TARGET}, $arg{-SCLIP}, $arg{-CLIP} );
+
+	my @bp;
+
+	# identify the searching region for partner soft cliping
+	my $extension;
+	if($RNASeq) {
+		$extension = 50;
+	}
+	else {
+		$extension  = $read_len - ($target->{qend} - $target->{qstart});
+	}
+	my ($tpos, $ort) = ($target->{tend}, $target->{qstrand}); 
+	$tpos = $target->{tstart} if( ($clip == LEFT_CLIP && $ort eq '-')
+		|| ($clip == RIGHT_CLIP && $ort eq '+'));
+	$extension = abs($tpos - $pos) - 1 
+		if($chr eq $target->{tchr} && abs($tpos - $pos) <= $extension); # don't consider itself
+	my $range =$target->{tchr} . ":";
+	if($tpos < $extension) {
+		$range .= '1';
+	}
+	else{
+		$range .= $tpos - $extension;
+	}
+	
+	$range .= "-"; 	$range .= $tpos + $extension;
+	
+	# the orginal genome sequence where we find the soft_clipping
+	my $orig;
+	my $tmp = $chr;
+	#$tmp = 'chr' . $tmp if($tmp !~ m/^chr/);
+	$orig = $target_genome . ":" . $tmp . ":";
+	my $base_pos;
+	if($RNASeq) { #let's do a wild guess!
+		my $r = get_gene_range($tmp, $pos, $clip);
+		return \@bp unless $r;
+		$base_pos = $r->[0];
+		$orig = join("", ($orig, $r->[0], "-", $r->[1]));
+	}
+	else {
+		$base_pos = $pos - $read_len;
+		$orig = join("", ($orig, $pos - $read_len, "-", $pos +  $read_len));
+	}
+
+	return \@bp if(!exists( $r_sclip->{$target->{tchr}})); #mapped to chrY or other minor chrs
+	# the soft clipping happens in highly repetitive region
+	# return \@bp if($coverage > $max_repetitive_cover);
+
+	my $r_pp = search_sclip($r_sclip, $range);
+	return  \@bp if(!$r_pp);
+	
+	my $real_pos;
+	my $found = 0;
+	my @r_reads;
+	my @l_reads;
+	foreach my $s (@{$r_pp}) {
+		#next if($s->[2] < $min_hit_reads); 
+		next if($chr ne $target->{tchr} && (
+			($clip == LEFT_CLIP  &&  $ort ne $s->[1] ) ||
+			($clip == RIGHT_CLIP && $ort eq $s->[1] )) );
+
+		next if($chr eq $target->{tchr} && ($s->[0] < $tpos - $extension 
+			|| $s->[0] > $tpos + $extension));
+		my $tort = $s->[1];
+		next if($s->[3] > $max_repetitive_cover);
+		my $tclip = $tort eq '+' ? RIGHT_CLIP : LEFT_CLIP;
+		my @reads = get_sclip_reads(
+			-SAM => $sam, 
+			-CHR => $target->{tchr}, 
+			-START => $s->[0], 
+			-END => $s->[0], 
+			-CLIP => $tclip,
+			-MINCLIPLEN => $min_hit_len,
+		   	-VALIDATOR => $validator,
+		   	-PAIRED => $paired,
+		   	-RMDUP => $rmdup);
+		next if(!@reads || scalar(@reads) == 0);
+#		push @r_reads, @reads if($tclip == RIGHT_CLIP);
+#		push @l_reads, @reads if($tclip == LEFT_CLIP);
+#	}
+
+#	foreach my $tclip ( (RIGHT_CLIP, LEFT_CLIP)) {
+#		my $s_reads = $tclip == RIGHT_CLIP ? \@r_reads : \@l_reads;
+#		next if(scalar @{$s_reads} == 0);
+		my %count;
+#		my $fa_name = prepare_reads($s_reads, $tclip);
+		my $fa_name = prepare_reads(\@reads, $tclip);
+		
+		my($contig_file, $sclip_count, $contig_reads, $singlet_file) = $assembler->run($fa_name); 
+		my (%reads, %quals, %s_lens, %pos);
+#		foreach my $r (@{$s_reads}) {
+		foreach my $r (@reads) {
+			$reads{$r->{name}} = $r->{full_seq};
+			$quals{$r->{name}} = $r->{full_qual};
+			$s_lens{$r->{name}} = length($r->{seq});
+			$pos{$r->{name}} = $r->{pos};
+		}
+
+		$contig_file = clip_fa_file($contig_file, $tclip);
+		if( -s $singlet_file )  {
+			$singlet_file = clip_fa_file($singlet_file, $tclip);
+			system("cat $singlet_file >> $contig_file");
+			system("rm $singlet_file");
+		}
+		my $seqs = read_fa_file($contig_file);	
+		my $hits = $aligner->run( -TARGET => $orig, -QUERY => $contig_file);
+		foreach my $t (keys %{$hits}) {
+			my $h = $hits->{$t};
+			my $tmp_bp;
+			my @all_pos;
+			my $all_reads_name;
+			if(exists $contig_reads->{$t}) {
+				foreach my $n (@{$contig_reads->{$t}}) {
+					push @all_pos, $pos{$n};
+				}
+				$all_reads_name = $contig_reads->{$t};
+				@all_pos = uniq @all_pos;
+				@all_pos = sort {$a <=> $b} @all_pos;
+
+			}
+			else {
+				push @all_pos, $pos{$t};
+				$all_reads_name = [$t];
+			}
+
+			if(is_good_hit($h, $clip, $tclip)) {
+				my $hit_ort = ($h->strand('query') == 1 ? "+" : "-");
+				my $real_pos = $tclip == RIGHT_CLIP ? $all_pos[0] : $all_pos[$#all_pos];
+				if($tclip == RIGHT_CLIP ) {
+					$tmp_bp = {
+						left_ort	=> '+', 
+						left_pos 	=> $real_pos, 
+						left_chr 	=> $target->{tchr}, 
+						right_ort 	=> $hit_ort,  
+						right_pos 	=> ($hit_ort eq "+" ? $h->start("hit") : $h->end("hit")) + $base_pos,
+						right_chr 	=> $chr, 
+					}
+				}
+				else {
+					$tmp_bp = {
+						left_ort 	=> $hit_ort, 
+						left_chr 	=> $chr, 
+						left_pos 	=> ($hit_ort eq "+" ? $h->end("hit") : $h->start("hit")) + $base_pos,
+						right_ort 	=> "+", 
+						right_chr 	=> $target->{tchr}, 
+						right_pos 	=> $real_pos,
+					}
+				}
+				$tmp_bp->{chr}		= $target->{tchr};
+				$tmp_bp->{pos} 		= $real_pos;
+				$tmp_bp->{all_pos} 	= \@all_pos;
+				$tmp_bp->{sc_seq} 	= $seqs->{$t};
+				$tmp_bp->{cover} 	= count_coverage($sam, $target->{tchr}, $real_pos);
+				$tmp_bp->{sc_reads} = exists $sclip_count->{$t} ? $sclip_count->{$t} : 1;
+				$tmp_bp->{reads} 	= exists $contig_reads->{$t} ? $contig_reads->{$t} : [$t];
+
+				push @bp, $tmp_bp;
+			}
+		}
+		system("rm $fa_name"); system("rm $fa_name*");
+	}
+	return \@bp;
+}
+
+# many more filter can be added here
+sub is_good_hit {
+	my ($hit, $clip, $tclip) = @_;
+
+	return if($hit->length_aln('query') < $min_hit_len);
+	return if($hit->frac_identical * 100 < $min_percent_id );
+	return 1;
+
+	# do we want to do the check?
+	my $ort = ($hit->start('query') < $hit->end('query') ? "+" : "-");
+	my ($dist, $t_dist, $qstart, $qend);
+	$qstart = $ort eq '+' ? $hit->start('query') : $hit->end('query') ;
+	$qend = $ort eq '+' ? $hit->end('query') : $hit->start('query');
+	$t_dist = $qstart;
+	$t_dist = $hit->query_length - $qend if($tclip == LEFT_CLIP);
+
+}
+
+# RNASeq support to identify deletions
+
+sub cigar2hit {
+	my ($s, @cigar_array) = @_;
+	my @pos;
+	my $p = $s; 
+	foreach my $c (@cigar_array){
+		my($op, $len) = @{$c};
+		if($op eq 'N') {
+			push @pos, [$s, $p];
+			$s = $p + $len;
+			$p = $s;
+			next;
+		}
+		$p += $len if($op eq 'M' || $op eq 'D');
+	}
+	push @pos, [$s, $p];
+	return \@pos;
+}
+
+sub	find_del_SVs  {
+	my ($sam, $chr, $start, $end) = @_;
+	my $max_sclip_len = 0;
+	my $range = $chr;
+	if($start && $end) {
+		$range = $chr . ":" . $start . "-" . $end;
+	}
+	my %SV;
+	my $tmp = $chr;
+	$tmp = "chr" . $chr if($chr !~ m/chr/);
+ 
+	my($f_tree, $r_tree) = ($gm->sub_model($tmp, "+"), $gm->sub_model($tmp, "-"));
+
+	$sam->fetch($range, sub {
+		my $a = shift;
+		my $cigar_str = $a->cigar_str;
+#		print $a->qname, "\t", $cigar_str, "\n";
+		return unless $cigar_str =~ m/N/; # the read cross two genes must have N
+#		return unless $a->score >= 97;
+		my $sv = identify_del_SV($f_tree, $a);
+		if($sv){
+			my $tmp1 = $sv->[0] . "+" . $sv->[1];
+			if(!exists($SV{$tmp1})) {
+				$SV{$tmp1} = {};
+				$SV{$tmp1}->{num} = 0;
+				$SV{$tmp1}->{left} = 0;
+				$SV{$tmp1}->{right} = 0;
+			}
+			$SV{$tmp1}->{num}++;
+			$SV{$tmp1}->{left} = $sv->[5] if($SV{$tmp1}->{left} < $sv->[5]);
+			$SV{$tmp1}->{right} = $sv->[6] if($SV{$tmp1}->{right} < $sv->[6]);
+			$SV{$tmp1}->{gene_ort}  = "+";
+			$SV{$tmp1}->{left_gene} = $sv->[3];
+			$SV{$tmp1}->{right_gene} = $sv->[4];
+			push @{$SV{$tmp1}->{reads}}, $a->qname;
+
+		}
+		$sv = identify_del_SV($r_tree, $a);
+		if($sv){
+			my $tmp1 = $sv->[0] . "-" . $sv->[1];
+			if(!exists($SV{$tmp1})) {
+				$SV{$tmp1} = {};
+				$SV{$tmp1}->{num} = 0;
+				$SV{$tmp1}->{left} = 0;
+				$SV{$tmp1}->{right} = 0;
+				$SV{$tmp1}->{reads} = [];
+			}
+			$SV{$tmp1}->{num}++;
+			$SV{$tmp1}->{left} = $sv->[5] if($SV{$tmp1}->{left} < $sv->[5]);
+			$SV{$tmp1}->{right} = $sv->[6] if($SV{$tmp1}->{right} < $sv->[6]);
+			$SV{$tmp1}->{gene_ort}  = "-";
+			$SV{$tmp1}->{left_gene} = $sv->[3];
+			$SV{$tmp1}->{right_gene} = $sv->[4];
+			push @{$SV{$tmp1}->{reads}}, $a->qname;
+		}
+	}
+	);
+
+	my @rtn;
+	foreach my $sv (keys %SV) {
+		my( $pos1, $pos2 ) = $sv =~ m/(\d+)[+|-](\d+)/;
+		print $pos1, "\t", $pos2, "\n";
+		my( $cover1, $cover2) = (count_coverage($sam, $chr, $pos1 - 1), count_coverage($sam, $chr, $pos2));
+		next if($SV{$sv}->{num} < $min_sclip_reads);
+		my $cover = $cover1 < $cover2 ? $cover1 : $cover2;
+		next if($SV{$sv}->{num} * 100 < $cover *  $min_pct_sclip_reads && $SV{$sv} < 50);
+		push @rtn, StructVar->new (
+			-FIRST_BP => {	left_ort => '+',
+							left_pos => $pos1 - 1,
+							left_chr => $chr,
+							right_ort => '+',
+							right_pos => $pos2,
+							right_chr => $chr,
+							chr => $chr,
+							cover => count_coverage($sam, $chr, $pos1 - 1), 
+							pos => $pos1 - 1,
+							sc_reads => $SV{$sv}->{num},
+							left_len => $SV{$sv}->{left},
+							right_len => $SV{$sv}->{right},
+							gene_ort => $SV{$sv}->{gene_ort},
+							left_gene => $SV{$sv}->{left_gene},
+							right_gene => $SV{$sv}->{right_gene},
+							reads => $SV{$sv}->{reads},
+						},
+			-SECOND_BP => {	left_ort => '+',
+							left_pos => $pos1 - 1,
+							left_chr => $chr,
+							right_ort => '+',
+							right_pos => $pos2,
+							right_chr => $chr,
+							chr => $chr,
+							pos => $pos2,
+							cover => count_coverage($sam, $chr, $pos2),
+							sc_reads => $SV{$sv}->{num},
+							reads => [],
+						}
+		);
+	}
+	return @rtn;
+}
+
+sub identify_del_SV {
+	my ($tree, $a) = @_;
+	my @cigar_array = @{$a->cigar_array};
+	return unless($a->start && $a->end);
+	return if(scalar $tree->intersect([$a->start, $a->end]) <= 1);
+
+	my @hits = @{ cigar2hit($a->start, @cigar_array) };
+	my @genes;
+	my $last_gene;
+	my @change;
+	my ($left, $right) = (0, 0);
+	for( my $i = 0; $i < scalar @hits; $i++)  {
+		my $h = $hits[$i];
+		my @g = $tree->intersect($h);
+		my $g_size = scalar @g;
+		if($g_size == 0) {
+#			print STDERR $a->qname, " is mapped outside of gene\n";
+			next;
+		}
+		if( scalar @g == 1) {
+			push @genes, $g[0] unless ($last_gene && $last_gene->val->name eq $g[0]->val->name);
+			if($last_gene && $last_gene->val->name ne $g[0]->val->name) {
+				$right += ($h->[1] - $h->[0] );
+				push @change, $i;	
+			}
+			$left += ($h->[1] - $h->[0] ) if($right == 0); 
+			$last_gene = $g[0];
+			next;
+		}
+#		print STDERR $a->qname, " connect two genes into one?\n";
+		return;
+	}
+	return if(scalar @genes <= 1);
+	if(scalar @genes > 2) {
+#		print STDERR $a->qname, "crossed more than 2 genes!\n";
+		return;
+	}
+	# now we down to 2 genes
+	my ($left_gene, $right_gene) = @genes;	
+	return unless $left_gene->val->overlap([$hits[$change[0]-1]->[0], $hits[$change[0]-1]->[1]]);
+	return unless $right_gene->val->overlap([$hits[$change[0]]->[0], $hits[$change[0]]->[1]]);
+	my $p = $left_gene->val->end;
+	print join("\t", ( $a->score, 
+		$a->cigar_str, $left, $right, $hits[$change[0]-1]->[1], $hits[$change[0]]->[0], 
+		$left_gene->val->name, $right_gene->val->name)), "\n";	
+	return [$hits[$change[0]-1]->[1], $hits[$change[0]]->[0], $a, $left_gene->val, $right_gene->val, $left, $right];	
+}
+
+=head1 NAME
+
+CREST.pl - a Structure Variation detection tools using softclipping for
+whole genome sequencing.
+
+
+=head1 VERSION
+
+This documentation refers to CREST.pl version 0.0.1.
+
+
+=head1 USAGE
+	
+	This program depends on several things that need to be installed and/or
+	specified.  The program uses BioPerl and Bio::DB::Sam module to parse 
+	the files and bam files.  Also it uses Blat software suits to do genome
+	mapping and alignment.  To make the program efficient, it also requires
+	a blat server setup.  And the program uses CAP3 assembler.
+
+	Identify somatic SVs from input:
+	    CREST.pl -f somatic.cover -d tumor.bam -g germline.bam 
+	Identify SVs from a single bam compared wtih reference genome:
+		CREST.pl -f sclip.cover -d sample.bam 
+	Identify SVs from a single bam on chr1 only
+		CREST.pl -f sclip.cover -d sample.bam -r chr1
+
+=head1 REQUIRED ARGUMENTS
+
+	To run the program, several parameter must specified.
+	-d, --input_d:		 The input (diagnositic) bam file
+	-f, --sclipfile:	 The soft clipping information generated by extractSClip.pl
+	--ref_genome:		 The reference genome file in fa format
+	-t, --target_genome: The 2bit genome file used by blat server and blat
+	--blatserver:		 The blat server name or ip address
+	--blatport:			 The blat server port
+
+=head1 OPTIONS
+
+	The options that can be used for the program.
+	-g, --input_g		 The germline (paired) bam file
+	-p, --prefix		 The output prefix, default is the input bam file name
+	-o, --out_dir 		 Output directory, default is the working directory
+	-l, --read_len		 The read length of the sequencing data, defaut 100
+	--sensitive          The program will generate more SVs with higher false positive rate.
+
+	--(no)scratch 		 Use the scratch space, default is off.
+	--(no)paired		 Use paired reads or not, defafult is on, so change to --nopaired for unpaired reads.
+	--cap3				 CAP3 executable position, default cap3
+	--cap3opt			 CAP3 options, single quoted, Default ' > /dev/null'
+	--blatclient 		 gfClient excutable position, default gfClient
+	--blatclientopt		 gfClient options, single quoted, default '-out=psl -nohead'
+	--blat				 blat executable potion, default balt
+	--blatopt			 blat options, single quoted, default '-tileSize=7 -stepSize=1 -out=psl -minScore=15'
+	
+	-r, --range			 The range where SV will be detected, using chr1:100-200 format.
+	--max_score_diff	 The maximum score difference when stopping select hit, default 10.
+	--min_sclip_reads	 Minimum number of soft clipping read to triger the procedure, default 3.
+	--max_rep_cover		 The min number of coverage to be called as repetitive and don't triger
+						 the procedure, default 500.
+	--min_sclip_len		 The min length of soft clipping part at a position to triger the detection,
+						 default 20.
+	--min_hit_len		 Min length of a hit for genome mapping
+	--min_dist_diff		 Min distance between the mapped position and the soft clipping position, default 20.
+	--(no)rmdup			 Remove PCR dumplicate.  Default remove.
+	
+	--min_percent_id	 Min percentage of identity of soft clipping read mapping, default 90
+	--min_percent_hq	 Min percentage of high quality base in soft clipping reads, default 80
+	--lowqual_cutoff	 Low quality cutoff value, default 20.
+
+	-h, --help, -?		 Help information
+	--man				 Man page.
+	--usage				 Usage information.
+	--version			 Software version.
+
+	--(no)rm_tandem_repeat	Remove tandem repeat caused SV events, default is ON. When it's on ptrfinder program
+							need to be on the path.
+	--tr_max_indel_size		Maximum tandem repeat mediated INDEL events, default 100
+	--tr_min_size			Minimum tandem reapet size, default 2
+	--tr_max_size			Maximum tandem repeat size, default 8
+	--tr_min_num			Minimum tandem repeat number, defaut 4
+	--min_percent_cons_of_read Minimum percent of consensus length of read length, default 0.75
+	--max_bp_dist			Maximum distance between two idenfitifed break points, default 15
+	--germline_seq_width	Half window width of genomic sequence around break point for germline SV filtering,
+							default 100
+	--germline_search_width	Half window width for seaching soft-clipped reads around breakpoint for germline SV
+							filtering, default 50.
+
+	--hetero_factor			The factor about the SV's heterogenirity and heterozygosity, default 0.4.
+	--triger_p_value		The p-value that will triger the SV detection when number of soft-clipped reads is small,
+							defaut 0.05.
+
+	--(no)rescue			Use rescue mode, when it's on, the a SV with only 1 side with enough soft-clipped reads
+							is considered as a valid one instead of rejecting it.  Default on.
+	--min_one_side_reads	When rescure mode is on, the minimum number of soft-clipped reads on one side, default 5.
+
+	--RNASeq				RNAseq mode, default off
+	--genemodel				A gene model file, currently only refFlat format (BED) is supported. Requried for RNASeq.
+	--cluster_size			The soft-clipped reads within cluster_size will be considered together, default is 3, RNAseq mode
+							only.
+
+
+=head1 DESCRIPTION
+
+This is a program designed to identify Structure Variations (SVs) using soft
+clipping reads.  With the improvement of next-gen sequencing techniques,
+both the coverage and length of pair-end reads have been increased steady.
+Many SV detection software availalbe uses pair-end information due to the 
+limitted read length.  Now 100bp is pretty common and many reads will cross
+the break points. Some mapping programs ( bwa, etc ) have the ability to
+identify so called soft-clipping reads.  A soft-clipping read is a read that
+different part can be mapped to different genomic posiiton, but the read can
+be uniquely positioned using the mate-pair position and the insert length.
+So this program use those reads to do an assembly-mapping-assembly-alignment
+procedure to identify potential structure variiations.
+
+
+=head1 DIAGNOSTICS
+
+A list of every error and warning message that the application can generate
+(even the ones that will "never happen"), with a full explanation of each
+problem, one or more likely causes, and any suggested remedies. If the
+application generates exit status codes (e.g., under Unix), then list the exit
+status associated with each error.
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+The program is designed to use under a cluster or high performance computing
+environment since it's dealing with over 100G input data.  The program can be 
+used as highly parallellized.  And the program is developped under linux/unix.
+
+
+=head1 DEPENDENCIES
+
+The program depend on several packages:
+1. Bioperl perl module.
+2. Bio::DB::Sam, version 1.5 or later, it requires samtools lib installed.
+3. blat suits, include blat, gfClient, gfServer.
+4. CAP3 assembly program.
+
+
+=head1 BUGS AND LIMITATIONS
+
+There are no known bugs in this module, but the method is limitted to bam file 
+that has soft-clipping cigar string generated.Please report problems to 
+Jianmin Wang  (Jianmin.Wang@stjude.org)
+Patches are welcome.
+
+=head1 AUTHOR
+
+Jianmin Wang (Jianmin.Wang@stjude.org)
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2010 by St. Jude Children's Research Hospital.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version. 
+
+This program is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of 
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Gene.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,130 @@
+package Gene;
+use strict;
+use Transcript;
+use Carp;
+use Data::Dumper;
+
+# a light weight gene structure is used here
+
+my @Gene_slots;
+BEGIN {
+	@Gene_slots = qw(NAME CHR START END STRAND EXONS TRANSCRIPTS TYPE);
+}
+use enum @Gene_slots;
+
+my %attribute = (
+    name         => NAME,
+	chr			 => CHR,
+    start        => START,
+    end          => END,
+	strand		 => STRAND,
+	transcripts  => TRANSCRIPTS,
+	type		 => TYPE,
+);
+
+#using an array instead of a hash for the node
+sub _accessor {
+    my $index = shift;
+    return sub {
+        my $self = shift;
+        return undef unless $self;
+        if (@_) {
+          $self->[$index] = shift;
+        }
+        return $self->[$index];
+    };
+}
+
+while(my($at, $idx) = each %attribute) {
+    no strict 'refs';
+    *$at = _accessor($idx);
+}
+
+sub new {
+    my $class = shift;
+    my $obj = [];
+	$obj->[TRANSCRIPTS] = [];
+    if (@_) {
+		my %arg = @_;
+        $obj->[NAME]        = $arg{-NAME} if($arg{-NAME});
+        $obj->[CHR]         = $arg{-CHR} if($arg{-CHR});
+		$obj->[START]       = $arg{-START} if($arg{-START});
+		$obj->[END]         = $arg{-END} if($arg{-END});
+		$obj->[STRAND]      = $arg{-STRAND} if($arg{-STRAND});
+		$obj->[TRANSCRIPTS] = $arg{-TRANSCRIPTS} if($arg{-TRANSCRIPTS});
+    }
+    return bless $obj, $class;
+}
+
+sub add_transcript {
+	my ($self, $fea) = @_;
+	croak "You must add a Transcript type into a gene" 
+		 unless ($fea->isa('Transcript'));
+	if($self->[STRAND] && $self->[STRAND] ne $fea->strand) {
+		croak "The transcript has different orientation with the gene";
+	}
+	if($self->[CHR] && $self->[CHR] ne $fea->chr) {
+		croak "The transcript is on different chr with the gene";
+	}
+#	if($self->[TYPE] && $fea->type ne $fea->type) {
+#		croak "The type of the transcript are different from the gene";
+#	}
+	$self->[STRAND] = $fea->strand;
+	$self->[CHR] = $fea->chr;
+#	$self->[TYPE] = $fea->type;
+
+	push @{$self->[TRANSCRIPTS]}, $fea;
+
+	$self->[NAME] = $self->[NAME] ? $self->[NAME] . "," . $fea->name : $fea->name;
+
+	
+	#update the start and end of the gene
+	$self->[START] = $fea->start if(!$self->[START] || $self->[START] > $fea->start);
+	$self->[END]   = $fea->end if(!$self->[END] || $self->[END] < $fea->end);
+}
+
+sub get_start {
+	my ($self, $pos, $ext) = @_;
+	my $rtn = $pos;
+	foreach my $t (@{$self->[TRANSCRIPTS]}) {
+		my $tmp = $t->get_start($pos, $ext);
+		$rtn = $tmp if($tmp < $rtn);
+	}
+	return $rtn;
+}
+
+sub get_end {
+	my ($self, $pos, $ext) = @_;
+	my $rtn = $pos;
+	foreach my $t (@{$self->[TRANSCRIPTS]}) {
+		my $tmp = $t->get_end($pos, $ext);
+		$rtn = $tmp if($tmp > $rtn);
+	}
+	return $rtn;
+}
+
+sub overlap {
+	my ($self, $fea) = @_;
+
+	if(ref($fea) eq 'ARRAY') { 
+		foreach my $t ( @{$self->[TRANSCRIPTS]} ) {
+			return 1 if($t->overlap($fea));
+		}
+	}
+	elsif($fea->isa('Transcript')) {
+		return if($fea->strand &&  $self->[STRAND] ne $fea->strand );
+		return if($fea->chr && $self->[CHR] ne $fea->chr) ;
+		#return if($fea->type && $self->[TYPE] ne $fea->type);
+		foreach my $e ( @{$fea->exons}) {
+			foreach my $t ( @{$self->[TRANSCRIPTS]} ) {
+				return 1 if($t->overlap($e));
+			}
+		}
+	}
+	else {
+		croak "Not implemented overlap";
+	}
+	return 0;
+}
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GeneModel.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,259 @@
+package GeneModel;
+use strict;
+use Carp;
+use Data::Dumper;
+use Tree::Interval;
+use Tree::DAG_Node;
+use English;
+use Gene;
+
+sub new {
+    my $class = shift;
+    my $obj = {};
+	$obj->{FMODEL} = {};
+	$obj->{RMODEL} = {};
+    if (@_) {
+		my %arg = @_;
+		$obj->{FMODEL} = $arg{-FMODEL} if($arg{-FMODEL});
+		$obj->{RMODEL} = $arg{-RMODEL} if($arg{-RMODEL});
+    }
+    return bless $obj, $class;
+}
+
+sub get_all_chr {
+	my $self = shift;
+	return keys %{$self->{FMODEL}};
+}
+
+sub add_gene {
+	my ($self, $gene) = @_;
+	if($gene->strand eq '+') {
+		$self->{FMODEL}->{$gene->chr}->insert([$gene->start, $gene->end], $gene);
+	}
+	else {
+		$self->{FMODEL}->{$gene->chr}->insert([$gene->start, $gene->end], $gene);
+	}
+}
+
+sub remove_gene {
+	my $self = shift;
+	my $gene = shift;
+	if($gene->strand eq '+') {
+		$self->{FMODEL}->{$gene->chr}->remove([$gene->start, $gene->end], $gene);
+	}
+	else {
+		$self->{RMODEL}->{$gene->chr}->remove([$gene->start, $gene->end], $gene);
+	}
+}
+
+sub n_genes {
+	my $self = shift;
+	my $n = 0;
+	foreach my $c (keys %{$self->{FMODEL}}) {
+		$n += $self->{FMODEL}->{$c}->size;
+	}
+	foreach my $c (keys %{$self->{RMODEL}}) {
+		$n += $self->{RMODEL}->{$c}->size;
+	}
+	return $n;
+}
+
+sub sub_model {
+	my ($self, $chr, $strand) = @_;
+	if($strand eq '+' ) {
+		return $self->{FMODEL}->{$chr};
+	}
+	else {
+		return $self->{RMODEL}->{$chr};
+	}
+}
+sub look_up_gene {
+	my ($self, $chr, $gene) = @_;
+	if($gene->isa('Gene')) {
+		if($gene->strand eq '+') {
+			return $self->{FMODEL}->{$chr}->lookup([$gene->start, $gene->end]);
+		}
+		else {
+			return $self->{RMODEL}->{$chr}->lookup([$gene->start, $gene->end]);
+		}
+	}
+	elsif(ref($gene) eq 'ARRAY') {
+		return (
+			$self->{FMODEL}->{$chr}->lookup([$gene->start, $gene->end]),
+			$self->{RMODEL}->{$chr}->lookup([$gene->start, $gene->end]) );
+	}
+	else {
+		croak "Not implemented look_up_gene for $gene";
+	}
+}
+
+sub overlap_genes {
+	my ($self, $chr,  $fea, $ort) = @_;
+	my @genes;
+
+	if(ref($fea) eq 'ARRAY') {
+		@genes = $self->_overlap_array($chr, $fea, $ort);
+	}
+	elsif($fea->isa('Transcript')) {
+		foreach my $e (@{$fea->exons}) {
+			push @genes, $self->_overlap_array($chr, $e,  
+				$fea->strand ? $fea->strand : undef);
+		}
+	}
+	else {
+		croak "Not implemented overlap for $fea";
+	}
+	my @rtn;
+	foreach my $g (@genes) {
+		push @rtn, $g if($g->overlap($fea));
+	}
+	return @rtn;
+}
+
+sub _overlap_array {
+	my($self, $chr, $a, $ort) = @_;
+	if($ort) {
+		return $ort == '+' ? $self->{FMODEL}->{$chr}->intersect($a) :
+			$self->{RMODEL}->{$chr}->intersect($a);
+	}
+	else {
+		return ($self->{FMODEL}->{$chr}->intersect($a), $self->{RMODEL}->{$chr}->intersect($a));
+	}
+}
+
+sub model {
+	my ($self, $chr, $strand, $val) = @_;
+	croak "Please specify chr and strand for GeneModel" 
+		unless $chr && $strand;
+	my $model = $strand eq '+' ? $self->{FMODEL} : $self->{RMODEL};
+
+	if($val) {
+		croak "The model for each chrom must be a Tree::Interval" 
+			unless $val->isa('Tree::Interval');
+		$model->{$chr} = $val;
+	}
+	return $model->{$chr};
+}
+
+sub from_file {
+	my ($self, $file, $format) = @_;
+	croak "$format is not implemented yet!" unless uc($format) eq "REFFLAT";
+	print STDERR "Processing gene model file, please wait ... ";
+	my $transcripts = _refFlat2Transcripts($file);
+	my $model = _Transcript2GeneModel($transcripts);
+	foreach my $c (keys %{$model}) {
+		foreach my $s (keys %{$model->{$c}}) {
+			if($s eq '+') {
+				$self->{FMODEL}->{$c} = $model->{$c}{$s};
+			}
+			else {
+				$self->{RMODEL}->{$c} = $model->{$c}{$s};
+			}
+		}
+	}
+	print STDERR "Done.\n";
+}
+
+sub _refFlat2Transcripts {
+	my $file = shift;
+	my %transcripts;
+
+	open my $FILE, "<$file" or croak "Can't open $file: $OS_ERROR";
+	while( my $line = <$FILE> ) {
+		next if($line =~ /^#/); #annotation line
+		my ($name, $refseq_id, $chr, $strand, $txStart, $txEnd, $cdsStart, $cdsEnd, $exonCount, 
+		          $exonStarts, $exonEnds) = split(/\s+/, $line);
+		my $type = $cdsEnd == $cdsStart ? "NR" : "NM";
+		my @starts = split /,/, $exonStarts;
+		my @ends = split /,/, $exonEnds;
+		if(scalar @starts != scalar @ends) {
+			warn "Number of exon starts is not same as exon ends!";
+			next;
+		}
+		$transcripts{$chr} = {} unless (exists $transcripts{$chr});
+		$transcripts{$chr}->{$strand} = [] unless (exists $transcripts{$chr}->{$strand});
+		my @exons;
+		for( my $i = 0; $i < $exonCount; $i++) {
+			push @exons, [$starts[$i], $ends[$i]];
+		}
+
+		my $t = Transcript->new(-START => $starts[0], -END => $ends[$#ends], -CHR => $chr, 
+			-STRAND => $strand eq '+' ? 1 : -1, -NAME => $name, -REFSEQ_ID => $refseq_id,
+			-EXONS => \@exons, -TYPE => $type);
+		push @{$transcripts{$chr}->{$strand}}, $t;
+	}
+	#sort the list of transcripts
+	foreach my $c (keys %transcripts) {
+		foreach my $s (keys %{$transcripts{$c}}) {
+			my @tmp = @{$transcripts{$c}->{$s}};
+			@tmp = sort { $a->start <=> $b->start || $a->end <=> $b->end } @tmp;
+			$transcripts{$c}->{$s} = \@tmp;
+		}
+	}
+	return \%transcripts;
+}
+
+sub _Transcript2GeneModel {
+	my $transcripts = shift;
+	my %genemodel;
+
+	foreach my $c (keys %{$transcripts}) {
+		$genemodel{$c} = {};	
+		foreach my $s (keys %{$transcripts->{$c}}) {
+			my $tree = $genemodel{$c}->{$s} = Tree::Interval->new();
+			foreach my $t (@{$transcripts->{$c}{$s}}) {
+				my @ol = $tree->intersect([$t->start, $t->end]);
+				if(scalar @ol == 0 ) {
+					my $gene = Gene->new();
+					$gene->add_transcript($t);
+					$tree->insert([$t->start, $t->end], $gene);
+					next;
+				}
+				my @real_ol;
+				foreach my $g (@ol) {
+					push @real_ol, $g->val if($g->val->overlap($t));
+				}
+				if(scalar @real_ol == 0) { #gene in gene?
+#					print STDERR "Gene in Gene: ", $t->name, " in ", $ol[0]->val->name, " \n";
+					my $gene = Gene->new();
+					$gene->add_transcript($t);
+					$tree->insert([$t->start, $t->end], $gene);
+					next;
+				}
+				if(scalar @real_ol == 1 ) { # transcript belongs to gene
+					my $g = $real_ol[0];
+#					print STDERR "Same Gene group: ", $t->name, " in ", $real_ol[0]->name, " \n";
+					if($t->start < $g->start || $t->end > $g->end) {
+						$tree->delete([$g->start, $g->end], $g);
+						$g->add_transcript($t);
+						$tree->insert([$g->start, $g->end], $g);
+						next;
+					}
+					$g->add_transcript($t);
+					next;
+				}
+				# a transcript make more genes same
+#				print STDERR "Join Gene group: ", $t->name, " join ", $real_ol[0]->name, "and", $real_ol[1]->name, " \n";
+				my $gene = Gene->new();
+				$gene->add_transcript($t);
+				foreach my $g (@real_ol) {
+					$tree->delete([$g->start, $g->end], $g);
+					foreach my $tp (@{$g->transcripts}) {
+						$gene->add_transcript($tp);
+					}
+				}
+				$tree->insert([$gene->start, $gene->end], $gene);
+			}
+		}
+	}
+	return \%genemodel;
+}
+
+sub _print_tree {
+	return;
+	my $tree = shift;
+	my $t = Tree::DAG_Node->lol_to_tree($tree->root->as_lol);
+	local $, = "\n";
+	print @{$t->draw_ascii_tree}, "\n";
+}
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,254 @@
+This document has the information on how to run CREST for structural
+variation detection.
+
+=============
+Requirements:
+=============
+Before running CREST, you need to make sure that several pieces of software
+and/or modules are installed on the system:
+1. BLAT software suite, especially blat, gfClient, and gfServer. BLAT
+can be obtained from these links:
+    BLAT for academic use: http://www.soe.ucsc.edu/~kent
+    BLAT commercial license: http://www.kentinformatics.com/
+2. CAP3 assembly program, available here:
+    CAP3 for academic use: http://seq.cs.iastate.edu/cap3.html
+    CAP3 commercial license: Contact Robin Kolehmainen at Michigan Tech, 
+    rakolehm@mtu.edu or (906)487-2228.
+3: SAMtools library for accessing SAM/BAM files, available from SourceForge:
+    SAMtools: http://sourceforge.net/projects/samtools/files/
+4. BioPerl and Bio::DB::Sam modules.  They are usually available as
+packages on most Linux distributions, but are also available at this link:
+    BioPerl: http://www.bioperl.org/
+	Bio::DB::Sam: http://search.cpan.org/~lds/Bio-SamTools/lib/Bio/DB/Sam.pm
+Important: you must install SAMtools library before install Bio::DB::Sam.
+5. ptrfinder is needed if you want to remove short tandem repeat mediated
+SVs, the executable is included in the download package, put it on the path.
+
+Note:
+1. You can use your own programs in place of BLAT and CAP3, but you need to
+implement the run method in SVExtTools.pm.
+2. The pipeline uses gfServer to mimic a standard blat server, so you need
+to setup your own gfServer.  Details on setting up the server can be found in
+the BLAT package.  Using a query server can significantly increase the speed of
+the pipeline.
+
+Your BAM files must contain soft-clipping signatures at the breakpoints.  If
+they do not, you will not get any results.  For more information see the
+section "About Soft-Clipping" at the end of this document.
+
+=====================
+Running the pipeline:
+=====================
+
+Make sure that all the required perl modules are in @INC.  One simple way
+is to put all .pm and .pl scripts in the same directory and run them from
+this same directory. Also, the input bam file, must be sorted and indexed
+before running the pipeline.
+
+We are going to use two sample bam files (tumor.bam and germline.bam) to
+illustate how to run the pipeline. The examples assume you want to find SV
+in tumor.bam and you also have the matched germline sample bam file.
+
+Important: indexing all bam files before running the pipeline is required.
+
+1. Get soft-clipping positions.
+
+The program extractSClip.pl will extract all soft-clipping positions first,
+and identify those positions with a cluster of soft-clipped reads.  The
+program requires only the BAM file and the reference genome's FASTA file
+The following is an example to extract all positions:
+
+	extractSClip.pl -i tumor.bam --ref_genome hg18.fa
+
+Two files named tumor.bam.cover and tumor.bam.sclip.txt will be generated
+for use in the next step.
+
+Note: The program can use either paired or single-end sequencing data.  For
+single-end data, use the --nopaired parameter.
+
+For whole genome sequencing project, we highly suggest running the procedure
+in parallel by dividing the genome into pieces.  One natural way is by
+chromosome. The following is an example to extract all positons on chr4.
+
+	extractSClip.pl -i tumor.bam --ref_genome hg18.fa -r 4 
+
+Important: The genome file used in this pipeline must be the same as the one
+used to map reads, so the chromosome names need to agree.  In this example,
+the genome file and bam file all have the chromosome name as 4 instead of
+chr4 you may encounter.
+
+Two files named tumor.bam.4.cover and tumor.bam.4.sclip.txt will be generated
+for use in the next step. So it's very easy to run this step in parallel and
+combine the results together to form a final result.
+
+The output files for this step have names with suffixes of *.cover and
+*.sclip.txt.  The .cover file is a tab-delimited text file, with columns:
+chr, position, strand, number of soft-clipped reads, and coverage at that
+position.  The strand is just left-clipped or right-clipped to help identify
+the SV orientation.  The .sclip.txt file has the detailed information for
+all soft-clipped reads including sequence and quality values. This file is
+also tab-delimited with the following columns: chr, posiiton, strand, read
+name, sequence, and quality.
+
+Example of part of a *.cover file:
+4       125892327       +       1       28
+4       125892458       +       1       27
+4       125893225       +       1       28
+4       125893227       +       5       29
+4       125893365       -       1       26
+4       125893979       -       1       16
+10      66301086        -       1       33
+10      66301858        +       4       14
+10      66301865        -       8       21
+10      66301871        -       1       22
+10      66302136        +       1       51
+
+Example of part of a *.sclip.txt file:
+4       125892327       +       HWUSI-EAS1591_6113C:3:17:12332:19420#0  CC      CC
+4       125892458       +       HWUSI-EAS1591_6113C:4:91:6281:9961#0    GACTAACCACCACGGTACATGTTTTCCTATGTAAAAAACCTGCACATTCTACACATGTATCCCAGAACTTAAAGTAAAACAC B@C@?:CC>CCBCCCCACBCDCCCCCC;<:<9CCCCC@CCCCCBCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCAC
+4       125893225       +       HWI-EAS90_614M9:5:18:17924:10181#0      CCCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAA  #######@@7@:8@><16+6(B>AABCAA3AB@CC6CCCCCCCDCCCCCCBCCDCCCCCCCCCCCCDCCCCCCCCCCCCCC
+
+If you run this step in parallel, you need to combine the outputs by
+concatenating the files.  Tumor and germline files must be concatenated
+separately, for example:
+cat tumor.bam.*.cover > tumor.bam.cover
+cat germline.bam.*.cover > germline.bam.cover
+
+2.Remove germline events (optional) 
+
+Running step 1 on both germline and tumor samples, you will get the
+soft-clipping posiitons in both samples.  This step will remove any position
+in the tumor sample that also appears in germline sample, so germline events
+will be removed.  This step does not use any sequence information and could
+remove true events.  By our observations, true events are rarely removed.
+You can skip this step and the program will do germline clean up at later step
+(see the -g parameter for CREST.pl).
+
+The script for this step is countDiff.pl and it only requires two parameters
+to specity the two output files from previous step.
+
+	countDiff.pl -d tumor.bam.cover -g germline.bam.cover > soft_clip.dist.txt
+
+A file named tumor.bam.cover.somatic.cover will be generated for next step.
+
+The program will generate a file with suffix *.somatic.cover, and it will
+be used for the next step.  The file has the same format as *.cover generated
+in the previous step.
+
+The standard output will show the coverage distribution.  For every read count
+in the range 1-999, it will show the number of breakpoints supported by that
+many soft-clipped reads.
+
+3. Running the SV detection script.
+
+This is the core step in the detection process. The program is CREST.pl.
+
+The program needs quite a few parameters, but you can think about what you
+will need.  Here is a partial list of required and common parameters:
+
+	-f The input soft-clipped coverage file produced in step 1 or 2.
+	-d The disease or tumor bam file
+	-g The germline bam file.  If you want to identify somatic SVs only, you
+	should provide this parameter.  If you also want to identify germline
+	events, you can leave this parameter unspecified. When treat your
+	germline file as disease without specify -g parameter, the program can
+	be used to identify germline events, or SV polymorphism.
+	--ref_genome The reference genome in fa format (used by bam file)
+	-t The reference genome in 2bit format (used by gfClient), this file can
+	be generated by using faToTwoBit program in BLAT program suit.  This
+	file must be the same as the one you used to setup gfServer.
+	--blatserver The name or IP address of blat server, you need to use your
+	own one instead of using the public one at UCSC.
+	--blatport The port number for the blat server.
+	--nopaired Tell the program the reads are not paired.
+
+If all of the required programs are on the path then you won't need to
+specify them again, otherwise you need to specify the paths to the programs
+using the corresponding parameters.  Please use CREST.pl --man to show the 
+man page, which provides a detailed parameter list.
+
+An example of running this step is:
+	CREST.pl -f tumor.bam.cover -d tumor.bam -g germline.bam --ref_genome \
+	hg18.fa -t hg18.2bit
+
+There is also a -r parameter to specify the range to be searched and it's highly
+recommended to run using -r as below:
+	CREST.pl -f tumor.bam.cover -d tumor.bam -g germline.bam --ref_genome \
+	hg18.fa -t /genome/hg18.2bit -r chr1
+So it's very easy to run the program in parallel by spliting the genome into 
+pieces.
+
+The program will generate a *.predSV.txt file.  The filename will be the input
+bam with .predSV.txt appended unless you specify the -p parameter.  Also the 
+STDERR output has the full list of SVs, including rejected ones.  The output 
+file *.predSV.txt has the following tab-delimited columns: left_chr, left_pos, 
+left_strand, # of left soft-clipped reads, right_chr, right_pos, right_strand, 
+# right soft-clipped reads, SV type, coverage at left_pos, coverage at 
+right_pos, assembled length at left_pos, assembled length at right_pos,
+average percent identity at left_pos, percent of non-unique mapping reads at
+left_pos, average percent identity at right_pos, percent of non-unique mapping
+reads at right_pos, start position of consensus mapping to genome,
+starting chromosome of consensus mapping, position of the genomic mapping of
+consensus starting position, end position of consensus mapping to genome,
+ending chromsome of consnesus mapping, position of genomic mapping of
+consensus ending posiiton, and consensus sequences.  For inversion(INV), the 
+last 7 fields will be repeated to reflect the fact two different breakpoints 
+are needed to identify an INV event.
+
+Example of the tumor.predSV.txt file:
+4	125893227	+	5	10	66301858	-	4	CTX	29	14	83	71	0.895173453996983	0.230769230769231	0.735384615384615	0.5	1	4	125893135	176	10	66301773	TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTTCAGTAGCTGTCACCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT
+5	7052198	-	0	10	66301865	+	8	CTX	0	22	0	81	0.761379310344828	0.482758620689655	0	0	1	5	7052278	164	10	66301947	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCAGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTCAAAAAAAAAAAGTGGGAAGAGG
+10	66301858	+	4	4	125893225	-	1	CTX	15	28	71	81	0.735384615384615	0.5	0.889507154213037	0.243243243243243	1	10	66301777	153	4	125893154	TTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA
+
+If there are no or very few results, there may be a lack of soft-clipping.  See
+the section "About Soft-Clipping" at the end of this document.
+
+4. Visulization of the detailed alignment at breakpoint (optional)
+
+The bam2html.pl script builds an html view of the multiple alignment for
+the breakpoint, so you can manually check the soft-clipping and other things.
+
+	bam2html.pl -d diag.bam -g germline.bam -i diag.bam.predSV.txt \
+		--ref_genome /genome/hg18 -o diag.bam.predSV.html
+
+The output file is specified by -o option.
+
+====================
+About Soft-Clipping:
+====================
+
+CREST uses soft-clipping signatures to identify breakpoints.  Soft-clipping is
+indicated by "S" elements in the CIGAR for SAM/BAM records.  Soft-clipping may
+not occur, depending on the mapping algorithm and parameters and sometimes even
+the library preparation.
+
+With bwa sampe:
+---------------
+
+One mapping method that will soft-clip reads is bwa sampe (BWA for paired-end
+reads).  When BWA successfully maps one read in a pair but is not able to map
+the other, it will attempt a more permissive Smith-Waterman alignment of the
+unmapped read in the neighborhood of the mapped mate.  If it is only able to
+align part of the read, then it will soft-clip the portion on the end that it
+could not align.  Often this occurs at the breakpoints of structural
+variations.
+
+In some cases when the insert sizes approach the read length, BWA will not
+perform Smith-Waterman alignment.  Reads from inserts smaller than the read
+length will contain primer and/or adapter and will often not map.  When the
+insert size is close to the read length, this creates a skewed distribution
+of inferred insert sizes which may cause BWA to not attempt Smith-Waterman
+realignment.  This is indicated by the error message "weird pairing".  Often
+in these cases there are also unusually low mapping rates.
+
+One way to fix this problem is to remap unmapped reads bwasw.  To do this,
+extract the unmapped reads as FASTQ files (this may be done with a combination
+of samtools view -f 4 and Picard's SamToFastq).  Realign using bwa bwasw and
+build a BAM file.  Then, re-run CREST on this new BAM file, and you may pick
+up events that would have been missed otherwise.
+
+With other aligners:
+--------------------
+
+Consult the documentation or mailing list(s) for your mapper to determine its
+behavior with regard to soft-clipping.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SCValidator.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,154 @@
+package SCValidator;
+# this is a singleton class
+
+use strict;
+use Exporter 'import';
+our @EXPORT_OK = qw($lowqual_cutoff $min_percent_id $min_percent_hq LEFT_CLIP RIGHT_CLIP);
+use Bio::DB::Sam;
+use constant LEFT_CLIP => 0;
+use constant RIGHT_CLIP => 1;
+
+our $min_percent_hq = 80;
+our $lowqual_cutoff = 20;
+our $min_percent_id = 90;
+
+my $SCValidator;
+my %default_validators = ( 
+	"quality_validator" => \&_quality_validator,
+	"align_validator"	=> \&_align_validator,
+	"strand_validator"	=> \&_strand_validator,
+);
+
+sub new {
+	if( $SCValidator) {
+		return $SCValidator;
+	} else {
+		my $type = shift;
+		my $this = {
+			"validator" => {}	
+		};
+		foreach my $v ( keys(%default_validators)) {
+			$this->{validator}{$v} = $default_validators{$v};
+		}
+		$SCValidator =  bless $this, $type;
+	}
+}
+
+sub add_validator {
+	my $self = shift;
+	my $name = shift;
+	$name = lc $name;
+	if( exists($self->{validator}{$name})) {
+#		print STDERR "Validator: $name is already in the list";
+		return;
+	}
+	if( exists($default_validators{$name})) {
+		$self->{validator}{$name} = $default_validators{$name};
+		return;
+	}
+	my $validator = shift;
+	die "Validator must be coderef" if(ref($validator) ne "CODE");
+	$self->{validator}{$name} = $validator;
+}
+
+sub remove_validator {
+	my ($self, $name) = @_;
+	$name = lc $name;
+	if(exists($self->{validator}{$name})) {
+		delete $self->{validator}{$name};
+	}
+}
+
+sub validate {
+	my $self = shift;
+	my $a = shift;
+	my $clip = shift;
+	die "The method will only validate bam alignment object"
+		if( ref($a) ne "Bio::DB::Bam::Aligment" && 
+			ref($a) ne "Bio::DB::Bam::AlignWrapper" );
+	return undef if($a->unmapped);
+	foreach my $v (keys(%{$self->{"validator"}})) {
+		return undef if(!$self->{"validator"}{$v}->($a, $clip));
+	}
+	return 1;
+}
+
+sub _align_validator {
+	#we only consider high quality part of the alignment
+	my $a = shift;
+	my ($ref, $matches, $query) = $a->padded_alignment;
+	my @qscores = $a->qscore;
+	my $n_matches = 0;
+	my $align_len = 0;
+	my $j = 0;
+	my ($start, $end) = (0, length($ref)-1);
+	my @cigar_array = @{ $a->cigar_array };
+	$start = $cigar_array[0]->[1] if($cigar_array[0]->[0] eq 'S');
+	$end = $end - $cigar_array[$#cigar_array]->[1] if($cigar_array[$#cigar_array]->[0] eq 'S');
+	
+	for( my $i = $start; $i <= $end; $i++) {
+		my $m = substr($matches, $i, 1);
+		if($m ne '|') {
+			if( substr($query, $i, 1) ne '-') {
+		#		$align_len++ if($qscores[$j] >= $lowqual_cutoff);
+				$j++;
+			}
+		#	else {
+		#		$align_len++ if($qscores[$j] >= $lowqual_cutoff && $qscores[$j+1] >= $lowqual_cutoff);
+		#	}
+			next;
+		}
+		if($qscores[$j] >= $lowqual_cutoff) {
+			$n_matches++ if(substr($ref, $i, 1) eq substr($query, $i, 1));
+			$align_len++;
+		}
+		$j++;
+	}
+	return ($align_len - $n_matches > 1) ? undef : 1 if($align_len < 20);
+	return ($n_matches * 100 >= $align_len * $min_percent_id) ? 1 : undef;
+}
+
+sub _quality_validator {
+	my $a = shift;
+	my $clip = shift;
+#	my $cigar_str = $a->cigar_str;
+	my @cigar_array = @{$a->cigar_array};
+	my @qual = $a->qscore;
+	if($clip == LEFT_CLIP) {
+		#my($sclip_len) = $cigar_str =~ m/^S(\d+)/;
+		my $sclip_len = $cigar_array[0]->[1];
+		@qual = @qual[0 .. ($sclip_len - 1)];
+	}
+	elsif ($clip == RIGHT_CLIP) {
+		#my($sclip_len) = $cigar_str =~ m/S(\d+)$/;
+		my $sclip_len = $cigar_array[$#cigar_array]->[1];
+		@qual = @qual[($a->l_qseq - $sclip_len) .. ($a->l_qseq - 1)];
+	}
+	else {
+		print STDERR "Please specify the soft_clipping position:
+			0: LEFT_CLIP or 1: RIGHT_CLIP";
+	}
+
+	my $n_hq = 0;
+	for( my $i = 0; $i <= $#qual; $i++) {
+		$n_hq++ if($qual[$i] >= $lowqual_cutoff);
+	}
+	return ($n_hq * 100 > $#qual * $min_percent_hq) ? 1 : undef;
+}
+
+sub _strand_validator {
+	my $a = shift;
+	my $clip = shift;
+	if($clip == LEFT_CLIP ) {
+		return ($a->paired && ($a->mtid != $a->tid || $a->mate_start < $a->start)) ? undef : 1;
+	}
+	elsif($clip == RIGHT_CLIP) {
+		return ($a->paired && ($a->mtid != $a->tid || $a->mate_start > $a->end)) ? undef : 1;
+	}
+	else {
+		 print STDERR "Please specify the soft_clipping position:
+             0: LEFT_CLIP or 1: RIGHT_CLIP";
+	}
+}
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SVExtTools.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,231 @@
+package SVExtToolsI;
+
+# this package has three major tools that the program is going to use:
+# 1. Assembler, cap3 is used for this purpose
+# 2. Mapper, blat server version is used and highly recommended
+# 3. Aligner, any one will work, but the program need to parse the output 
+sub new {
+	my $class = shift;
+	my %param = @_;
+	my $self = {};
+	$self->{PRG} = undef;
+	$self->{OPTIONS} = undef;
+	foreach my $k (keys %param) {
+		my $k1 = $k;
+		$k1 = substr($k, 1) if($k =~ m/^-/);
+		$self->{$k1} = $param{$k};
+	}
+
+	bless $self, ref($class) || $class;
+	return $self;
+}
+
+sub program {
+	my ($self, $value) = @_;
+	$self->{PRG} = $value if($value);
+	return $self->{PRG};
+}
+
+sub options {
+	my ($self, $value) = @_;
+	$self->{OPTIONS} = $value if($value);
+	return $self->{OPTIONS};
+}
+
+sub run {
+	print STDERR "you need implement your own run method";
+}
+
+package Assembler;
+use strict;
+use Carp;
+use English;
+use base qw(SVExtToolsI);
+
+sub new {
+	my ($class, @args) = @_;
+	my $self = $class->SUPER::new(@args);
+	$self->{PRG} = "cap3" if(!$self->{PRG});
+	$self->{OPTIONS} = "" if(!$self->{OPTIONS});
+	return $self;
+}
+
+# the run function of Assembler returns the contig file and 
+# a hashref with the number of reads in each contig
+
+sub run {
+	my($self, $file) = @_;
+	croak "$self->{PRG} need an input fasta file to do the assembly" if(!$file);
+	if(-s $file == 0) {
+		print STDERR "$file is of size 0";
+		return;
+	}
+	system(join(" ", ($self->{PRG}, $file, $self->{OPTIONS})));
+	my( $r_count, $r_reads ) = _count_reads("$file.cap.ace");
+	return ("$file.cap.contigs", $r_count, $r_reads, "$file.cap.singlets");
+}
+
+sub _count_reads {
+	my $file = shift;
+	my %count;
+	my %reads;
+    open my $ACE, "<$file" or croak "Can't open $file:$OS_ERROR";
+	my $contig_name;
+    while( my $line = <$ACE> ) {
+        if($line =~ m/^CO\s(.*?)\s\d+\s(\d+)/){
+			$contig_name = $1;
+			$count{$contig_name} = $2;
+			$reads{$contig_name} = [];
+		}
+		if($line =~ m/^RD\s(.*?)\s/) {
+			push @{$reads{$contig_name}}, $1;	
+		}
+	}
+	close($ACE);
+	return (\%count, \%reads);
+}
+
+package Mapper;
+use strict;
+use Carp;
+use Data::Dumper;
+use English;
+use Bio::SearchIO;
+use Bio::SeqIO;
+use base qw(SVExtToolsI);
+
+sub new {
+	my ($class, @args) = @_;
+	my $self = $class->SUPER::new(@args);
+	$self->{PRG} = "gfClient sjblat 50000" if(!$self->{PRG});
+	$self->{OPTIONS} = "-out=psl -nohead" if(!$self->{OPTIONS});
+	$self->{MAX_SCORE_DIFF} = 20 if(!$self->{MAX_SCORE_DIFF});
+	$self->{MAX_NUM_HITS} = 10 if(!$self->{MAX_NUM_HITS});
+	return $self;
+}
+
+sub max_score_diff {
+	my $self = shift;
+	my $value = shift;
+	$self->{MAX_SCORE_DIFF} = $value if($value);
+	return $self->{MAX_SCORE_DIFF};
+}
+
+sub max_num_hits {
+	my $self = shift;
+	my $value = shift;
+	$self->{MAX_NUM_HITS} = $value if($value);
+	return $self->{MAX_NUM_HITS};
+}
+
+sub run {
+	my $self = shift;
+	my %param = @_;
+	croak "Missing QUERY parameter for $self->{PRG}" if(!$param{-QUERY});
+	my $output = $param{-OUTPUT} || $param{-QUERY} . ".psl";
+	my $options = $param{-OPTIONS} || $self->{OPTIONS};
+	system(join(" ", ($self->{PRG}, $self->{BIT2_DIR}, $param{-QUERY}, $output, $options)));
+	system("sort -k 10g -k 1nr $output -o $output.sorted");
+	open my $SORTED, "<$output.sorted" or croak "can't open $output.sorted:$OS_ERROR";
+	open my $PSL, ">$output" or croak "can't open $output:$OS_ERROR";
+	my $n = 0;
+	while( my $line = <$SORTED>) {
+		print $PSL $line;
+		$n++;
+		last if($n > 10);
+	}
+	close($PSL);
+	close($SORTED);
+	return $self->select_target($output);
+}
+
+
+sub select_target {
+	my $self = shift;
+	my $file = shift;
+	my %targets;
+	my $parser = Bio::SearchIO->new( -file => $file, -format => 'psl');
+	while( my $result = $parser->next_result ) {
+		my $qname = $result->query_name;
+		$targets{$qname} = [];
+	#	$result->sort_hits(sub {$Bio::Search::Result::ResultI::b -> matches('id') <=> 
+	#	            $Bio::Search::Result::ResultI::a ->matches('id')});
+		my $n_hits = 0;
+		my $max_score = 0;
+#		my $perfect_only;
+		while( my $hit = $result->next_hit ) {
+			while( my $hsp = $hit->next_hsp) {
+				my ($n_matches) = $hsp->matches;
+				last if($max_score - $n_matches > $self->{MAX_SCORE_DIFF});
+				#last if($perfect_only && $hit->query_length != $n_matches);
+				my @blocks;
+				foreach my $bl (@{$hsp->gap_blocks('hit')}) {
+					push @blocks, [$bl->[0], $bl->[0] + $bl->[1]];
+				}
+				push @{$targets{$qname}}, {
+					tchr	=> $hit->name,
+					tstart	=> $hsp->start('hit'),
+					tend	=> $hsp->end('hit'),
+					qstart	=> $hsp->start('query'),
+					qend	=> $hsp->end('query'),
+					qstrand => $hsp->strand('query') == 1 ? '+' : '-',
+					matches	=> $n_matches,
+					blocks	=> \@blocks,
+					perfect => $hit->query_length == $n_matches ? 1 : 0,
+				};
+				#$perfect_only = 1 if($hit->query_length == $n_matches);
+				$max_score = $n_matches if($max_score < $n_matches);
+				$n_hits++;
+			}
+			$hit->rewind;
+			last if($n_hits >= $self->{MAX_NUM_HITS});
+		}
+	}
+	return \%targets;
+}
+
+package Aligner;
+use strict;
+use Carp;
+use English;
+use Bio::SearchIO;
+use Bio::SeqIO;
+use base qw(SVExtToolsI);
+
+sub new {
+	my ($class, @args) = @_;
+	my $self = $class->SUPER::new(@args);
+	$self->{PRG} = "blat" if(!$self->{PRG});
+	$self->{OPTIONS} = "-tileSize=9 -stepSize=1 -out=psl -nohead -minScore=15" 
+		if(!$self->{OPTIONS});
+	return $self;
+}
+
+# return best hit for each query reads
+sub run {
+	my $self = shift;
+	my %param = @_;
+	croak "Missing TARGET parameter for $self->{PRG}" if(!$param{-TARGET});
+	croak "Missing QUERY parameter for $self->{PRG}" if(!$param{-QUERY});
+	my $output = $param{-OUTPUT} || $param{-QUERY} . ".psl";
+	system( join(" ", ($self->{PRG}, $param{-TARGET}, $param{-QUERY}, $output, $self->{OPTIONS})));
+	return $output if($param{-FILE});
+	return _find_best_hit($output);
+}
+
+sub _find_best_hit {
+	my $file = shift;
+	my $parser = Bio::SearchIO->new( -file => $file, -format => 'psl');
+	my %best_hit;
+	while( my $result = $parser->next_result ) {
+		$result->sort_hits(sub {$Bio::Search::Result::ResultI::b -> matches('id') <=> 
+		            $Bio::Search::Result::ResultI::a ->matches('id')});		
+		my $hit = $result->next_hit; # the best hit
+		my $hsp = $hit->next_hsp;
+		$best_hit{$result->query_name} = $hit;
+		$hit->rewind;
+	}
+	return \%best_hit;
+}
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SVUtil.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,318 @@
+package SVUtil;
+
+use strict;
+use Carp;
+use English;
+use Bio::SeqIO;
+use Bio::DB::Sam;
+use File::Spec;
+use File::Path qw(remove_tree);
+use File::Temp qw/ tempfile tempdir /;
+use Cwd;
+use SCValidator qw(LEFT_CLIP RIGHT_CLIP);
+require Exporter;
+our @ISA = ('Exporter');
+our @EXPORT = qw(is_new_pair clip_fa_file prepare_reads parse_range
+	get_input_bam get_work_dir is_PCR_dup read_fa_file find_smallest_cover
+	get_sclip_reads rev_comp);
+our @EXPORT_OK = qw($use_scratch $spacer_seq $spcer_seq_len $work_dir);
+our $use_scratch = 1;
+our  $work_dir;
+
+sub rev_comp {
+    my $str = shift;
+    $str = reverse $str;
+    $str =~ tr/ACTG/TGAC/;
+    return $str;
+}
+# something about binormial distribution
+sub choose {
+    my ($n,$k) = @_;
+    my ($result,$j) = (1,1);
+	    
+    return 0 if $k>$n||$k<0;
+    $k = ($n - $k) if ($n - $k) <$k;
+	    
+    while ($j <= $k ) {
+        $result *= $n--;
+        $result /= $j++;
+    }
+    return $result;
+}
+
+sub dbinorm { #desity funtion 
+	my($n, $k, $p) = @_;
+	return unless($n > 0 && $k >= 0 && $n >= $k && $p >= 0 && $p <=1);
+	my $prob = log(choose($n, $k)) + ($n-$k)*log(1-$p) + $k*log($p);
+	return exp($prob);
+}
+
+sub find_smallest_cover {
+	my ($c, $p, $crit) = @_;
+	my @s_cover;
+	for( my $i = 1; $i < $c; $i++) {
+		my $n = 1;
+		while(1) {
+			my $tmp = 0;
+			for( my $j = 0; $j <= $i && $j < $n; $j++) {
+				$tmp += dbinorm($n, $j, $p);
+			}
+			if( $tmp < $crit) {
+				$s_cover[$i] = $n - 1;
+				last;
+			}
+			$n++;
+		}
+	}
+	return \@s_cover;
+}
+
+
+
+sub read_fa_file {
+	my $file = shift;
+	my $in = Bio::SeqIO->new(-file => $file, -format => 'Fasta');
+	my %seqs;
+	while( my $seq=$in->next_seq()) {
+		$seqs{$seq->display_id} = $seq->seq;
+	}
+	return \%seqs;
+}
+
+# rmdup: remove PCR dumplication related code
+# you can replace it using your own criteria 
+sub is_new_pair {
+    my ($a, $sclip_len, $pairs) = @_;
+    foreach my $p (@{$pairs}) {
+        return undef if($a->start == $p->[0] && $a->end == $p->[1] &&
+            $a->mate_start == $p->[2] && $a->mate_end == $p->[3] && $sclip_len == $p->[4]);
+    }
+    return 1;
+}
+
+#
+#clipping sequnce related code
+#
+# the spacer sequence, you can replace it with your own one
+my $spacer_seq = 'ACGTACGT' . 'CGTA' x 6 . 'ATGCATGC';
+my $spacer_seq_len = length($spacer_seq);
+
+# clip the reads that with spacer_seq at one end
+sub clip_fa_file {
+	my ($file, $ort) = @_;
+	my $out = $file . ".clip.fa";
+	my $in  = Bio::SeqIO->new( -file =>	$file, -format => 'Fasta');
+	open my  $OUT, ">$out" or croak "can't open $file.fa:$OS_ERROR";
+	while( my $seq=$in->next_seq()) {
+		print $OUT ">",  $seq->display_id, "\n";
+		if($ort eq RIGHT_CLIP) {
+			print $OUT  $seq->subseq($spacer_seq_len + 1, $seq->length), "\n";
+		}
+		else {
+			print $OUT  $seq->subseq(1, $seq->length - $spacer_seq_len), "\n";
+		}
+	}
+	close($OUT);
+	return $out;
+}
+
+# prepare the reads into a fasta file
+# due to most assembler can't handle short read well, we add
+# the spacer_seq to the start/end of each sequence arrording to
+# the softclip postion
+sub prepare_reads {
+	my($r_reads, $clip) = @_;
+	my ($fh, $fa_name) = tempfile( DIR => $work_dir, SUFFIX => '.fa');
+	my $qual_name = $fa_name . ".qual";
+	my $spacer_qual = ' 50 ' x $spacer_seq_len;
+
+	open my $qual_fh, ">$qual_name" or croak "can't open $qual_name:$OS_ERROR";
+	foreach my $r (@{$r_reads}) {
+		print $fh ">", $r->{name}, "\n";
+		my $tmp = $r->{seq};
+		$tmp = defined $clip ? 
+			($clip == RIGHT_CLIP ? $spacer_seq . $tmp : $tmp . $spacer_seq) :
+			$tmp;
+		print $fh $tmp, "\n";
+		next unless $r->{qual};
+		print $qual_fh ">", $r->{name}, "\n";
+		$tmp =  join(" ", @{$r->{qual}});
+		$tmp = defined $clip ? 
+			($clip == RIGHT_CLIP ? $spacer_qual . $tmp : $tmp . $spacer_qual) :
+			$tmp;
+		print $qual_fh $tmp, "\n";
+	}
+	close $qual_fh;
+	return $fa_name;
+}
+
+# check PCR duplicate
+sub is_PCR_dup {
+	my ($a, $pairs, $sclip_len) = @_;
+	my ($s, $e, $ms, $me ) = ($a->start, $a->end, $a->mate_start ? $a->mate_start : 0,
+		$a->mate_end ? $a->mate_end : 0);
+    foreach my $p (@{$pairs}) {
+		return 1 if($s == $p->[0] && $e == $p->[1] &&
+			$ms == $p->[2] && $me == $p->[3] && $sclip_len == $p->[4]);
+	}
+	return;
+}
+
+# parse the range of input, format is: chr:start-end
+# start and end is optional
+sub parse_range {
+	my $range = shift;
+	my ($chr, $start, $end);
+	my @field = split /:/, $range;
+	$chr = $field[0];
+#	$chr = substr($chr, 3) if($chr =~ /^chr/);
+	if(@field > 1) {
+		@field = split /-/, $field[1];
+		$start = $field[0];
+		$end = $field[1] if($field[1]);
+		if($start !~ m/^\d+$/ or $end !~ m/^\d+$/) {
+			croak "wrong range format, need to be: chr:start-end";
+		}
+	}
+	return ($chr, $start, $end);
+}
+
+# St. Jude only
+# grab the bam file from the bam dir
+my $raw_bam_dir = "/nfs_exports/genomes/1/PCGP/BucketRaw";
+sub get_input_bam {
+    my $sample = shift;
+	my ($group) = $sample =~ /(.*?)\d+/; 	
+    my $tmp_bam_dir = File::Spec->catdir($raw_bam_dir, $group);
+    opendir(my $dh, $tmp_bam_dir) or croak "can't open directory: $raw_bam_dir: $OS_ERROR";
+    my @files = grep { /^$sample-.*bam$/ } readdir($dh);
+    close $dh;
+    return File::Spec->catfile($raw_bam_dir, $group,  $files[0]);
+}
+
+#scratch related code
+sub get_work_dir {
+    my %options = @_;
+	my $scratch_dir;
+	if($options{-SCRATCH}){
+    	$scratch_dir = (exists $options{-DIR} ? $options{-DIR} :
+        	(-e '/scratch_space' ? '/scratch_space' : undef) );
+	}
+
+    my $dir;
+	if($scratch_dir) {
+		$scratch_dir = File::Spec->rel2abs($scratch_dir);
+	    if($ENV{'JOB_ID'}) {
+    	    $dir = File::Spec->catdir($scratch_dir, $ENV{'JOB_ID'})
+	    }
+		else {
+			$dir = tempdir(DIR => $scratch_dir);
+		}
+	}
+    else {
+			$dir = tempdir();
+    }
+	mkdir($dir) if( ! -e $dir);
+	$work_dir = $dir;
+    return $dir;
+}
+
+
+sub get_sclip_reads {
+	my %args = @_;
+	my ($sam, $chr, $start, $end, $clip, $min_len, $validator, $paired, $rmdup, $full_seq, $extra_base) = 
+		($args{-SAM}, $args{-CHR}, $args{-START}, $args{-END}, $args{-CLIP}, 
+		$args{-MINCLIPLEN}, $args{-VALIDATOR}, $args{-PAIRED}, $args{-RMDUP},
+		$args{-FULLSEQ}, $args{-EXTRA});
+	$extra_base = 0 unless $extra_base;
+	my @rtn;
+	$min_len = 0 unless $min_len;
+	my $max_sclip_len = 0;
+	my $range = $chr;
+	$range = $chr . ":" . $start . "-" . $end if($start && $end);
+	my @pairs;
+	my $strand_validator = $paired ? 1 : 0;
+
+	$sam->fetch($range, sub {
+		my $a = shift;
+		my $cigar_str = $a->cigar_str;
+		my @cigar_array = @{$a->cigar_array};
+		return if($cigar_str !~ m/S/);
+		return unless($a->start && $a->end);	
+		#return if(!$a->proper_pair && $paired);
+		if($paired && !$strand_validator) {
+			$validator->add_validator("strand_validator");
+		}
+
+		if($paired && !$a->proper_pair) {
+			$validator->remove_validator("strand_validator");
+			$strand_validator = 0;
+		}
+        my ($sclip_len, $pos, $seq, $qual);
+		my @tmp = $a->qscore;
+		if($cigar_array[0]->[0] eq 'S' && $clip == LEFT_CLIP ) {
+			$pos = $a->start;
+			return if($pos < $start or $pos > $end); # the softclipping position is not in range
+            $sclip_len = $cigar_array[0]->[1]; 
+			#print $cigar_str, "\t", scalar @pairs, "\n";
+			return unless($validator &&  $validator->validate($a, LEFT_CLIP));
+			$max_sclip_len = $sclip_len if($max_sclip_len < $sclip_len);
+			return if(@pairs > 0 && $rmdup && is_PCR_dup($a, \@pairs, $sclip_len)); #it's a PCR dumplicate
+            $seq = $full_seq ? $a->query->dna :  substr($a->query->dna, 0, $sclip_len + $extra_base);
+			@tmp = $full_seq ? @tmp :  @tmp[0 .. ($sclip_len -1 + $extra_base)];
+
+			push @pairs, [$a->start, $a->end, $a->mate_start ? $a->mate_start : 0, 
+				$a->mate_end ? $a->mate_end : 0, $sclip_len] if($rmdup);
+			my $qscore = $a->qscore;
+				
+			push @rtn, {
+				name => $a->qname,
+				seq => $seq,
+				qual => \@tmp,
+				full_seq => $a->query->dna,
+				full_qual => $qscore,
+				pos => $pos,
+			};
+		}
+		if($cigar_array[$#cigar_array]->[0] eq 'S' &&  $clip == RIGHT_CLIP ) { 
+		  	$pos = $a->end;
+			return if($pos < $start or $pos > $end); # the softclipping position is not in range
+#			print $cigar_str, "\t", scalar @pairs, "\n";
+			return unless $validator->validate($a, RIGHT_CLIP);
+            $sclip_len = $cigar_array[$#cigar_array]->[1]; 
+			$max_sclip_len = $sclip_len if($max_sclip_len < $sclip_len);
+			return if(@pairs > 0 && $rmdup && is_PCR_dup($a, \@pairs, $sclip_len)); #it's a PCR dumplicate
+            $seq = $full_seq ? $a->qseq : substr($a->qseq, $a->l_qseq - $sclip_len - $extra_base );
+			@tmp = $full_seq ? @tmp : @tmp[($a->l_qseq - $sclip_len - $extra_base) .. ($a->l_qseq - 1)];
+			push @pairs, [$a->start, $a->end, $a->mate_start ? $a->mate_start : 0, 
+				$a->mate_end ? $a->mate_end : 0, $sclip_len] if($rmdup);
+			my $qscore = $a->qscore;
+			push @rtn, {
+				name => $a->qname,
+				seq => $seq,
+				qual => \@tmp,
+				full_seq => $a->query->dna,
+				full_qual => $qscore,
+				pos => $pos,
+			};
+        }
+	}
+	);
+	if($max_sclip_len >= $min_len) {
+		return @rtn;
+	}
+	else{
+		undef @rtn; return @rtn;
+	}
+}
+
+my $start_dir;
+BEGIN {
+	$start_dir = getcwd;
+}
+END {
+	chdir($start_dir);
+    remove_tree($work_dir) if($use_scratch && $work_dir && $start_dir ne $work_dir);
+}
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StructVar.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,1240 @@
+package StructVar;
+
+# $Id: StructVar.pm, v 1.00 2010/09/24 jianmin.wang Exp $
+
+use strict;
+use Bio::DB::Sam;
+use Carp;
+use Data::Dumper;
+use English;
+use Bio::SearchIO;
+use GeneModel;
+use Cwd;
+use SVExtTools;
+use List::MoreUtils qw/ uniq /;
+use SVUtil qw( prepare_reads read_fa_file get_sclip_reads rev_comp);
+use SCValidator qw(LEFT_CLIP RIGHT_CLIP);
+
+use constant UNK => 0;
+use constant CTX => 1;
+use constant INV => 2;
+use constant INS => 3;
+use constant DEL => 4;
+use constant ITX => 5;
+
+# type of SVs and thier string
+my %type2str = (
+	0 => 'UNKNOWN',  # unknow type, not single event 
+	1 => 'CTX',		 # cross chromosome translocation
+	2 => 'INV',		 # inversion, requires both breakpoints available
+	3 => 'INS',	     # (tandem) insertion
+	4 => 'DEL',		 # deletion
+	5 => 'ITX',	     # within chromosome translocation
+);
+# class static variables
+my $sam_d;
+my $sam_g;
+my $gm;
+my $assembler;
+my $aligner;
+my $mapper;
+my @filters = (\&_germline_sclip_filter, \&_type_distance_filter, \&_germline_indel_filter);
+my $RNASeq;
+my $read_len;
+my $genome;
+my $tr_max_indel_size;   #tandem repeat mediated indel size
+my $tr_min_size;
+my $tr_max_size; 	  #tandem repeat max_size of single repeat
+my $tr_min_num;		  #tandem repeat minimum number of occurence
+
+my $max_bp_dist = 15;
+my $germline_seq_width = 100;
+my $germline_search_width = 50;
+my $min_percent_cons_of_read = 0.75;
+
+my %default_filters = (
+	'germline_sclip'	=> \&_germline_sclip_filter,
+	'type_distance'		=> \&_type_distance_filter,
+	'germline_indel'	=> \&_germline_indel_filter,
+#	'mapping_artifact'	=> \&_mapping_artifact_filter,
+	'mapping_quality'	=> \&_mapping_quality_filter,
+	'tandem_repeat'		=> \&_tandem_repeat_filter,
+);
+
+sub new {
+	my $class = shift;
+	my %param = @_;
+	my $self = {};
+	$self->{first_bp} = {};
+	$self->{second_bp} = {};
+	$self->{first_bp} = $param{-FIRST_BP} if($param{-FIRST_BP}); 
+	$self->{second_bp} = $param{-SECOND_BP} if($param{-SECOND_BP});
+	$self->{consensus} = $param{-CONSENSUS} ? $param{-CONSENSUS} : "";
+	$self->{type} = "";
+	bless $self, ref($class) || $class;
+	return $self;
+}
+
+sub add_filter {
+	my $self = shift;
+	my $name = shift;
+	my $f = shift;
+	croak "you must specify a filter" if(!$f);
+	croak "the filter must be a subroutine" if(ref($f) ne 'CODE');
+	$default_filters{$name} = $f;
+}
+
+sub add_RNASeq_filter {
+	$default_filters{'RNASeq_strand'} = \&_RNASeq_strand_filter;
+	$default_filters{'RNASeq_INS'}	= \&_RNASeq_INS_filter;
+}
+
+sub remove_filter {
+	my $self = shift;
+	my $name = shift;
+	if($default_filters{$name}){
+		delete $default_filters{$name};
+	}
+	else {
+		print STDERR "Filter $name is not in filter list";
+	}
+} 
+
+sub tr_max_indel_size {   #tandem repeat mediated indel size
+	my $self = shift;
+	my $value = shift;
+	$tr_max_indel_size = $value if($value);
+	return $tr_max_indel_size;
+}
+
+sub min_percent_cons_of_read {
+	my $self= shift;
+	my $value = shift;
+	$min_percent_cons_of_read = $value if($value);
+	return $min_percent_cons_of_read;
+}
+
+sub tr_min_size {
+	my $self = shift;
+	my $value = shift;
+	$tr_min_size = $value if($value);
+	return $tr_min_size;
+}
+sub germline_seq_width {
+	my $self = shift;
+	my $value = shift;
+	$germline_seq_width = $value if($value);
+	return $germline_seq_width;
+}
+
+sub germline_search_width {
+	my $self = shift;
+	my $value = shift;
+	$germline_search_width = $value if($value);
+	return $germline_search_width;
+}
+	
+sub max_bp_dist {
+	my $self = shift;
+	my $value = shift;
+	$max_bp_dist = $value if($value);
+	return $max_bp_dist;
+}
+
+sub tr_max_size { 	  #tandem repeat max_size of single repeat
+	my $self = shift;
+	my $value = shift;
+	$tr_max_size = $value if($value);
+	return $tr_max_size;
+}
+
+sub tr_min_num {	  #tandem repeat minimum number of occurence
+	my $self = shift;
+	my $value = shift;
+	$tr_min_num = $value if($value);
+	return $tr_min_num;
+}
+sub genome {
+	my $self = shift;
+	my $value = shift;
+	$genome = $value if($value);
+	return $genome;
+}
+sub sam_d {
+	my $self = shift;
+	my $value = shift;
+	$sam_d = $value if($value);
+	return $sam_d;
+}
+
+sub sam_g {
+	my $self = shift;
+	my $value = shift;
+	$sam_g = $value if($value);
+	return $sam_g;
+}
+
+sub assembler {
+	my $self = shift;
+	my $value = shift;
+	$assembler = $value if($value);
+	return $assembler;
+}
+
+sub aligner {
+	my $self = shift;
+	my $value = shift;
+	$aligner = $value if($value);
+	return $aligner;
+}
+
+sub RNASeq {
+	my $self = shift;
+	my $value = shift;
+	$RNASeq = 1 if($value);
+	return $RNASeq;
+}
+
+sub mapper {
+	my $self = shift;
+	my $value = shift;
+	$mapper = $value if($value);
+	return $mapper;
+}
+
+sub gene_model {
+	my $self = shift;
+	my $value = shift;
+	$gm = $value if($value);
+	return $gm;
+}
+
+sub read_len {
+	my $self = shift;
+	my $value = shift;
+	$read_len = $value if($value);
+	return $read_len;
+
+}
+sub first_bp {
+	my $self = shift;
+	my %param = @_;
+	if(%param) {
+		$self->{first_bp}{left_chr}  = $param{-LEFT_CHR};
+		$self->{first_bp}{left_pos}  = $param{-LEFT_POS};
+		$self->{first_bp}{left_ort}  = $param{-LEFT_ORT};
+		$self->{first_bp}{right_chr} = $param{-RIGHT_CHR};
+		$self->{first_bp}{right_pos} = $param{-RIGHT_POS};
+		$self->{first_bp}{right_ort} = $param{-RIGHT_ORT};
+		$self->{first_bp}{sc_reads}  = $param{-SC_READS};
+		$self->{first_bp}{pos}       = $param{-POS};
+		$self->{first_bp}{cover}     = $param{-COVER};
+		$self->{first_bp}{sc_seq}	 = $param{-SC_SEQ};
+		$self->{first_bp}{chr}		 = $param{-CHR};
+	}
+	return $self->{first_bp};
+}
+
+sub second_bp {
+	my $self = shift;
+	my %param = @_;
+	if(%param) {
+		$self->{second_bp}{left_chr}  = $param{-LEFT_CHR};
+		$self->{second_bp}{left_pos}  = $param{-LEFT_POS};
+		$self->{second_bp}{left_ort}  = $param{-LEFT_ORT};
+		$self->{second_bp}{right_chr} = $param{-RIGHT_CHR};
+		$self->{second_bp}{right_pos} = $param{-RIGHT_POS};
+		$self->{second_bp}{right_ort} = $param{-RIGHT_ORT};
+		$self->{second_bp}{sc_reads}  = $param{-SC_READS};
+		$self->{second_bp}{pos}       = $param{-POS};
+		$self->{second_bp}{cover}     = $param{-COVER};
+		$self->{second_bp}{sc_seq}	 = $param{-SC_SEQ};
+		$self->{second_bp}{chr}		 = $param{-CHR};
+	}
+	return $self->{second_bp};
+}
+
+sub type {
+	my $self = shift;
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	if($bp1->{left_chr} ne $bp1->{right_chr}) {
+		return CTX if($bp1->{left_ort} eq $bp2->{left_ort} &&
+					  $bp1->{right_ort} eq $bp2->{right_ort});
+
+		return UNK;
+	}
+	if( $bp1->{left_ort} eq $bp1->{right_ort} &&
+		$bp2->{left_ort} eq $bp2->{right_ort} ) { # Insertion or deletion
+		return DEL if( $bp1->{left_pos} <= $bp1->{right_pos} &&
+					   $bp2->{left_pos} <= $bp2->{right_pos});
+		return INS if( $bp1->{left_pos} >= $bp1->{right_pos} &&
+					   $bp2->{left_pos} >= $bp2->{right_pos});
+		return UNK;
+	}
+	if( $bp1->{left_ort} ne $bp1->{right_ort} &&
+		$bp2->{left_ort} ne $bp2->{right_ort} ) {
+		return INV if( ($bp1->{left_ort} eq '+' && $bp2->{left_ort} eq '-')
+					|| ($bp2->{left_ort} eq '+' && $bp1->{left_ort} eq '-'));
+		return ITX if( ($bp1->{left_ort} eq '+' && $bp2->{left_ort} eq '+')  
+					|| ($bp1->{left_ort} eq '-' && $bp2->{left_ort} eq '-') );
+		return UNK;
+	}
+	return UNK;
+}
+
+sub to_string {
+	my $self = shift;
+	my $type = $self->type;
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	my ($left_len, $right_len) = (0, 0);
+	if(exists $bp1->{left_len}) {
+		($left_len, $right_len ) = ($bp1->{left_len}, $bp1->{right_len});
+	}
+	else {
+		$left_len = length($bp1->{sc_seq}) if($bp1->{sc_seq}); 
+		$right_len = length($bp2->{sc_seq}) if($bp2->{sc_seq}); 
+	}
+	if($type == INV && $bp1->{pos} > $bp2->{pos}) {
+		($bp1, $bp2) = ($bp2, $bp1);
+		($left_len, $right_len) = ($right_len, $left_len);
+	}
+	my ($cover1, $cover2) = ($bp1->{cover}, $bp2->{cover});
+
+	my ($chrA, $chrB, $ortA, $ortB) = ($bp1->{left_chr}, $bp1->{right_chr},
+		$bp1->{left_ort}, $bp1->{right_ort});
+	my ($posA, $posB, $countA, $countB) = ($bp1->{pos}, $bp2->{pos}, $bp1->{sc_reads}, $bp2->{sc_reads});
+	if($bp1->{chr} eq $bp1->{right_chr} && $bp1->{pos} == $bp1->{right_pos}) {
+		$posA = $bp2->{pos};
+		$posB = $bp1->{pos};
+		$countA = $bp2->{sc_reads};
+		$countB = $bp1->{sc_reads};
+		($cover1, $cover2) = ($cover2, $cover1);
+		($left_len, $right_len) = ($right_len, $left_len);
+	}
+
+	my $rtn = join("\t", ($chrA, $posA, $ortA, $countA, $chrB, $posB, $ortB, $countB,
+		$type2str{$type}, $cover1, $cover2, $left_len, $right_len, $self->get_statistics(100),
+		$self->{c_start}, $self->{start_chr}, $self->{t_start}, 
+		$self->{c_end}, $self->{end_chr}, $self->{t_end}, $self->{consensus}));
+	if($self->{type} == INV) {
+		$rtn = join("\t", ($rtn, $self->{c_start2}, $self->{start_chr2}, $self->{t_start2},
+			$self->{c_end2}, $self->{end_chr2}, $self->{t_end}, $self->{consensus2}));
+	}
+	return $rtn;
+}
+
+sub set_consensus {
+	my $self = shift;
+	my ($validator, $paired ) = @_;
+	if(!$assembler) {
+		print STDERR "No assembler set, no consensus generated\n";
+		return;
+	}
+	my %all_reads;
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	my $N = 0;
+
+	my @s_reads1 = $self->_get_reads($sam_d, $bp1);
+	my @s_reads2 = $self->_get_reads($sam_d, $bp2);
+	
+	if($self->{type} == INV) {
+		$self->{consensus} = _generate_consensus(\@s_reads1);
+		$self->{consensus2} = _generate_consensus(\@s_reads2);
+	}
+	else {
+		push @s_reads1, @s_reads2;
+		$self->{consensus} = _generate_consensus(\@s_reads1);
+	}
+}
+
+sub _generate_consensus {
+	my $s_reads = shift;
+	my $N = scalar(@{$s_reads});
+	return $s_reads->[0]{seq} if($N == 1);
+	my $fa_name = prepare_reads($s_reads);
+	my ($contig_file, $sclip_count) = $assembler->run($fa_name);
+	if(!$contig_file || -s $contig_file == 0) { 
+		system ("rm $fa_name"); system("rm $fa_name*");
+		return;
+	}
+	my $n = 0;
+	my $contig_name;
+	foreach my $c (keys %{$sclip_count}) {
+		if($sclip_count->{$c} > $n) {
+			$n = $sclip_count->{$c};
+			$contig_name = $c;
+		}
+	}
+	return if($N * 8 > $n * 10);
+	my $contig_seqs = read_fa_file($contig_file);
+	return $contig_seqs->{$contig_name};
+}
+
+sub _get_reads{
+	my $self = shift;
+	my ($sam, $bp) = @_;
+
+	my ($chr, $pos) = ($bp->{chr}, $bp->{pos});
+	my ($start, $end) = ($pos, $pos);
+	if($bp->{all_pos}) {
+		my @tmp = @{$bp->{all_pos}};
+		@tmp = sort {$a <=> $b} @tmp;
+		($start, $end) = ($tmp[0], $tmp[$#tmp]);
+	}
+	my %reads;
+	return if(scalar @{$bp->{reads}} == 0);
+	foreach my $r (@{$bp->{reads}}){
+		$reads{$r} = 1;
+	}
+
+	#my ($sam, $chr, $start, $end, $reads) = 
+	#	($args{-SAM}, $args{-CHR}, $args{-START}, $args{-END}, $args{-READS}) ;
+
+	my @rtn;
+	my $range = $chr;
+	$range = $chr . ":" . $start . "-" . $end;
+	my($s, $e) = ($start, $end);
+	$sam->fetch($range, sub {
+		my $a = shift;
+		return unless (exists $reads{$a->qname});
+		return unless ($a->start && $a->end);
+		return unless (($a->start >= $start && $a->start <= $end) 
+			|| ($a->end >= $start && $a->end <= $end));
+		$s = $a->start if($s > $a->start);
+		$e = $a->end if($e < $a->end);
+		my $qscore = $a->qscore;
+		delete $reads{$a->qname};
+		push @rtn, {
+			name => $a->qname,
+			seq => $a->query->dna,
+			qual => $qscore,
+		};
+	} );
+#	$bp->{range} = [$s, $e];
+	if($self->{type} == INV) {
+		if($start == $bp->{left_pos} || $end == $bp->{left_pos}) {
+			$bp->{left_range} = [$s, $e];
+		}
+		else {
+			$bp->{right_range} = [$s, $e];
+		}
+		return @rtn;
+	}
+	if($chr eq $self->{first_bp}{left_chr} && ($start == $self->{first_bp}{left_pos} || $end == $self->{first_bp}{left_pos})){
+		$self->{first_bp}{left_range} = [$s, $e];
+	}
+	if($chr eq $self->{first_bp}{right_chr} && ($start == $self->{first_bp}{right_pos} || $end == $self->{first_bp}{right_pos})){
+		$self->{first_bp}{right_range} = [$s, $e];
+	}
+
+	return @rtn;	
+}
+
+my $start_dir;
+BEGIN {
+	$start_dir = getcwd;
+}
+
+sub _cat_genes {
+	my ($ort, @genes) = @_;
+	my $rtn;
+	my @names;
+	foreach my $g (@genes) {
+		push @names, $g->val->name;
+	}
+	@names = uniq @names;
+	$rtn = join(";", @names);
+	$rtn = $rtn . "($ort)" if($rtn);
+	return $rtn;
+}
+
+sub get_genes {
+	my $self = shift;
+	return ['NA', 'NA', 'NA'] unless $gm;
+
+	my ($gene1, $gene2);
+	my $dist;
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	my ($ort1, $ort2) = ($bp1->{left_ort}, $bp1->{right_ort});
+	my ($chr1, $chr2) = ($bp1->{left_chr}, $bp1->{right_chr});
+	my ($pos1, $pos2) = ($bp1->{pos}, $bp2->{pos});
+	($pos1, $pos2) = ($pos2, $pos1) if($bp1->{right_pos} == $pos1);
+	my $range1 = $ort1 eq "+" ? [$pos1 - 5, $pos1] : [$pos1, $pos1 + 5];
+	my $range2 = $ort2 eq "+" ? [$pos2, $pos2 + 5] : [$pos2 - 5, $pos2];
+
+	my ($tmp1, $tmp2) = ($chr1 =~ m/chr/ ? $chr1 : "chr" . $chr1, 
+		$chr2 =~ m/chr/ ? $chr2 : "chr" . $chr2);
+	my ($r_tree1, $f_tree1) = ($gm->sub_model($tmp1, "-"), 	$gm->sub_model($tmp1, "+"));
+	my ($r_tree2, $f_tree2) = ($gm->sub_model($tmp2, "-"), 	$gm->sub_model($tmp2, "+"));
+
+	my ($g_ort1, $g_ort2);
+	my @genes;
+	@genes = $r_tree1->intersect($range1) if($r_tree1);
+	$gene1 = _cat_genes("-", @genes) if(scalar @genes > 0 );
+	undef @genes;
+	@genes = $f_tree1->intersect($range1) if($f_tree1);
+	if(scalar @genes > 0) {
+		my $tmp = _cat_genes("+", @genes);
+		if($gene1) {
+			$gene1 .= ";" .  $tmp;
+		}
+		else {
+			$gene1 = $tmp;
+		}
+	}
+	undef @genes;
+	@genes = $r_tree2->intersect($range2) if($r_tree2);
+	$gene2 = _cat_genes("-", @genes) if(scalar @genes > 0 );
+	undef @genes;
+	@genes = $f_tree2->intersect($range2) if($f_tree2);;
+	if(scalar @genes > 0) {
+		my $tmp = _cat_genes("+", @genes);
+		if($gene2) {
+			$gene2 .= ";" .  $tmp;
+		}
+		else {
+			$gene2 = $tmp;
+		}
+	}
+
+	$gene1 = 'NA' unless $gene1;
+	$gene2 = 'NA' unless $gene2;
+	my $type = $self->{type};
+	if( $type == INS  or $type == DEL ) {
+		($pos1, $pos2) = ($pos2, $pos1)  if($pos1 > $pos2);
+		@genes =  $r_tree1->intersect([$pos1 - 5, $pos2 + 5]);
+		if(scalar @genes >= 2) {
+			$dist = scalar(@genes) - 2;
+			$dist .= "(-)";
+		}
+		@genes =  $f_tree1->intersect([$pos1 - 5, $pos2 + 5]);
+		if(scalar @genes >= 2) {
+			if($dist) {
+				$dist .= ":" . (scalar (@genes) - 2);
+			}
+			else {
+				$dist = scalar (@genes) - 2;
+			}
+			$dist .= "(+)";
+		}
+	}
+	$dist = 'NA' unless $dist;
+	return [$gene1, $gene2, $dist];
+}
+
+sub to_full_string {
+	my $self = shift;
+	my $type = $self->{type};
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	return join("\t", ( $bp1->{left_chr}, $bp1->{left_pos}, $bp1->{left_ort},
+		$bp1->{right_chr}, $bp1->{right_pos}, $bp1->{right_ort}, $bp1->{sc_reads},
+		$bp2->{left_chr}, $bp2->{left_pos}, $bp2->{left_ort},
+		$bp2->{right_chr}, $bp2->{right_pos}, $bp2->{right_ort}, $bp2->{sc_reads},
+		$type2str{$type}));
+}
+
+sub filter {
+	my $self = shift;
+	print STDERR "SV filter starting....\n";
+	$self->{type} = $self->type;
+	$self->set_consensus;
+
+	if(!$self->{consensus}  || length $self->{consensus} < $read_len * $min_percent_cons_of_read) {
+		$self->{error} = "No Consensus or consensus too short";
+		print STDERR "FAILED\n";
+		return;
+	}
+	if($self->{type} == INV && (!$self->{consensus2} || length $self->{consensus2} < $read_len * $min_percent_cons_of_read)) {
+		$self->{error} = "No Consensus or consensus too short";
+		print STDERR "FAILED\n";
+		return;
+	}
+
+	foreach my $f (values(%default_filters) ){
+		if(! $f->($self)){
+			print STDERR "FAILED\n";
+			return;
+		}
+	}
+	print STDERR "PASSED\n";
+	return 1;
+}
+
+sub _mapping_quality_filter {
+	my $self = shift;
+	if($self->{type} == INV) {
+		my $tmp1 = $self->_mapping_quality($self->{first_bp}, $self->{consensus}, 1);
+		my $tmp2 = $self->_mapping_quality($self->{second_bp}, $self->{consensus2}, 2);
+		return $tmp1 && $tmp2;
+	}
+	return $self->_mapping_quality($self->{first_bp}, $self->{consensus}, 1);
+}
+
+sub _mapping_quality {
+	my $self = shift;
+	my $bp = shift;
+	my $con = shift;
+	my $which = shift;
+	$which = "" unless $which == 2;
+	my $l = length($con);
+	print STDERR "Mapping quality filter ... ";
+
+	open my $QUERY, ">query.fa" or croak "can't open query.fa : $OS_ERROR";
+	print $QUERY ">query\n", $con, "\n";
+	close $QUERY;
+
+	my ($range1, $range2) = $self->_find_bp_ref_range($bp, $con);
+	my ($s1, $e1, $t_s1, $t_e1) = $self->_map_consensus($range1);
+	return unless $e1;
+	my ($chr, $s, $e) = split /[:|-]/, $range2;
+	my $offset = 0;
+	if($s < $t_e1 && $e > $t_s1) { #overlap
+		my $tmp = substr $con, 0, $s;
+		if($s1 < $l - $e1) {
+			$offset = $e1;
+			$tmp = substr $con, $e1 + 1;
+		}
+		open my $QUERY, ">query.fa" or croak "can't open query.fa : $OS_ERROR";
+		print $QUERY ">query\n", $tmp, "\n";
+		close $QUERY;
+	}
+	my ($s2, $e2, $t_s2, $t_e2) = $self->_map_consensus($range2);
+	return unless $e2;
+	$s2 += $offset;
+	$e2 += $offset;
+	if($s1 < $s2) {
+		if($e1 < $s2) {
+			$self->{"insert" . $which} = substr($con, $e1, $s2 - $e1);
+		}
+		$self->{"c_start" . $which} = $s1;
+		$self->{"t_start" . $which} = $t_s1;
+		$self->{"start_chr" . $which} = $bp->{left_chr};
+		$self->{"c_end" . $which} = $e2;
+		$self->{"t_end" . $which} = $t_e2;
+		$self->{"end_chr". $which} = $bp->{right_chr};
+		$s1 = 1; 
+		($e1, $s2)  = ($s2, $e1);
+		$e2 = $l;
+	}
+	else {
+		if($e2 < $s1) {
+			$self->{"insert" . $which} = substr($con, $e2, $s1 - $e2);
+		}
+		$self->{"c_start" . $which} = $s2;
+		$self->{"t_start" . $which} = $t_s2;
+		$self->{"start_chr" . $which} = $bp->{right_chr};
+		$self->{"c_end" . $which} = $e1;
+		$self->{"t_end" . $which} = $t_e1;
+		$self->{"end_chr" . $which } = $bp->{left_chr};
+		$s2 = 1;
+		($e2, $s1) = ($s1, $e2);
+		$e1 = $l;	
+	}
+	
+	my $n = 1;
+	foreach my $r( ($range1, $range2) ) {
+		my $r_a = $r eq $range1 ? $range2 : $range1;
+		my($chr, $s, $e) = split /[:|-]/, $r;
+		my($chr_a, $s_a, $e_a) = split /[:|-]/, $r_a;
+		my($s_c, $e_c) = $n == 1 ? ($s1, $e1) : ($s2, $e2);
+		$n++;
+		open my $QUERY, ">query.fa" or croak "can't open query.fa : $OS_ERROR";
+		print $QUERY ">query\n", substr($self->{consensus}, $s_c, $e_c - $s_c + 1), "\n";
+		close $QUERY;
+		my $hit = $aligner->run(-TARGET => $genome . ":" . $r, -QUERY => "query.fa");
+		my $h = $hit->{query};
+		return unless $h;	
+		my $hsp = $h->next_hsp;
+		my @matches = $hsp->matches;
+		$hit = $mapper->run(-QUERY => "query.fa");	
+		foreach $h (@{$hit->{query}}) {
+			next if($h->{tchr} eq $chr && $h->{tstart} >= $s - $l && $h->{tend} <= $e + $l); # the same one
+			return if($h->{matches} >= $matches[0]); #find a better or as good as match
+			return if($h->{tchr} eq $chr_a && $h->{matches} - $matches[0] >= -5 && $self->{type} == CTX);
+		}
+	}
+	print STDERR "PASSED\n";
+	return 1;
+}
+
+sub _map_consensus {
+	my $self = shift;
+	my $range = shift;
+	my ($s_c, $e_c, $s_t, $e_t);
+
+	my $hits = $aligner->run(-TARGET => $genome . ":" . $range, -QUERY => "query.fa");
+	my ($chr, $s, $e) = split /[:|-]/, $range;
+	my $h = $hits->{query};
+	return unless $h; # can't find a good enough match
+	my $hsp = $h->next_hsp;
+	my @matches = $hsp->matches;
+	($s_c, $e_c, $s_t, $e_t) = ($hsp->start('query'), $hsp->end('query'),
+		$hsp->start('hit'), $hsp->end('hit'));
+	return if( ($e_c - $s_c + 1) * 0.97 > $matches[0]); # the alignment is not good
+	($s_t, $e_t) = $hsp->strand == 1 ?  ($s_t + $s, $e_t + $s) : ($e_t + $s, $s_t + $s);
+	return ($s_c, $e_c, $s_t, $e_t);
+}
+
+sub _find_bp_ref_range {
+	my $self = shift;
+	my $bp = shift;
+	my $con = shift;
+
+	my $l = int(length($con)/2);
+	my $ext = $l * 2;
+	$ext = 100000 if($RNASeq);
+	if($self->{type} == DEL && abs($bp->{left_pos} - $bp->{right_pos}) < $l ){
+		$l = abs($bp->{left_pos} - $bp->{right_pos}) - 1;
+	}
+
+	my($range1, $range2);
+	my ($chr, $p) = ($bp->{left_chr}, $bp->{left_pos});
+	my 	$ort = $bp->{left_ort}; 
+	my ($s, $e);
+	if($bp->{left_range} ) {
+		$s = $bp->{left_range}->[0] - $l;
+		$e = $bp->{left_range}->[1] + $l;
+	}	
+	else {
+		$s = $e = $p;
+		$s = $ort eq "+" ? $p - $ext : $p - $l;
+		$e = $ort eq "+" ? $p + $l : $p + $ext;
+	}
+	$s = 1 if($s < 1);
+	$e = $bp->{left_pos} + $l if($self->{type} == DEL);
+	$range1 = $chr . ":" . $s . "-" . $e;
+
+	($chr, $p) = ($bp->{right_chr}, $bp->{right_pos});
+	$ort = $bp->{left_ort}; 
+	if($bp->{right_range} ) {
+		$s = $bp->{right_range}->[0] - $l;
+		$e = $bp->{right_range}->[1] + $l;
+	}	
+	else {
+		$s = $e = $p;
+		$s = $ort eq "-" ? $p - $ext : $p - $l;
+		$e = $ort eq "-" ? $p + $l : $p + $ext;
+	}
+	$s = $bp->{right_pos} - $l if($self->{type} == DEL);
+	$s = 1 if($s < 1);
+	$range2 = $chr . ":" . $s . "-" . $e;
+
+	return ($range1, $range2);
+}
+
+sub _find_ref_range {
+	my $self = shift;
+	my $l = int(length($self->{consensus})/2);
+	my ($range1, $range2);
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+
+	my ($chr, $p) = ($bp1->{chr}, $bp1->{pos});
+	my ($s, $e);
+	my $ext = $l*2 ;
+	$ext = 100000 if($RNASeq);
+	if($self->{type} == DEL && abs($bp1->{pos} - $bp2->{pos}) < $l ){
+		$l = abs($bp1->{pos} - $bp2->{pos}) - 1;
+	}
+	
+	my $ort = $bp1->{pos} == $bp1->{left_pos} ? 
+		($bp1->{left_ort} eq "+" ? "-" : "+") : $bp1->{right_ort};
+	if($bp1->{range}) {
+		$s = $bp1->{range}->[0] - $l;
+		$s = 1 if($s < 1);
+		$e = $bp1->{range}->[1] +  $l;
+	}
+	else {
+		$s = $e = $p;
+		$s = $ort eq "+" ? $p - $l  : $p - $ext;
+		$e = $ort eq "+" ? $p + $ext : $p + $l;
+	}
+	$s = 1 if($s < 1);
+	$e = $bp1->{pos} + $l if($self->{type} == DEL);
+	
+	$range1 = $chr . ":" . $s . "-" . $e;
+
+	($chr, $p) = ($bp2->{chr}, $bp2->{pos});
+	$ort = $bp2->{pos} == $bp2->{left_pos} ? 
+		($bp2->{left_ort} eq '+' ? '-' : '+') : $bp2->{right_ort};
+	if($self->{type} == INV) {
+		$ort = $bp1->{pos} == $bp1->{left_pos} ?
+			$bp1->{right_ort} : ($bp1->{left_ort} eq '+' ? '-' : '+');
+	}
+
+	if($bp2->{range} && $self->{type} != INV) {
+		$s = $bp2->{range}->[0] - $l;
+		$e = $bp2->{range}->[1] +  $l;
+	}
+	else {
+		$s = $e = $p;
+		$s = $ort eq "+" ? $p - $l : $p - $ext;
+		$e = $ort eq "+" ? $p + $ext : $p + $l;
+	}
+	$s = $bp2->{pos} - $l if($self->{type} == DEL); 
+	$s = 1 if($s < 1);
+
+	$range2 = $chr . ":" . $s . "-" . $e;
+	return($range1, $range2);
+}
+
+my $GAP = -5;
+my $MATCH = 2;
+my $MISMATCH = -5;
+sub _refine_bp {
+	my $self = shift;
+	my $h = shift;
+	my $ref_seq = shift;
+	my $con = $self->{consensus};
+	my $hsp = $h->next_hsp;
+	my ($i, $j) = ($hsp->start("hit"), $hsp->start("query"));
+	if($hsp->strand == -1) {
+		$con = rev_comp($con);
+		$j = length($con) - $hsp->end("query");
+	}
+
+	my ($score, $g, $max_score, $s) = (0, 0, 0);
+	my ($current_s_r, $current_s_c) = ($i, $j);
+	my ($s_r, $s_c, $e_r, $e_c);
+	my $p;
+	my ($n_matches, $n_max_matches) = (0, 0);
+	my @bl_r = @{$hsp->gap_blocks('hit')};
+	my @bl_c = @{$hsp->gap_blocks('query')};
+	for( my $n = 0; $n < scalar @bl_r; $n++) {
+		my $m = $bl_r[$n]->[1];
+		if($p) { #gaps
+			if (!$RNASeq || $bl_r[$n]->[0] - $p < 25) {
+				$score += $GAP * ($bl_r[$n]->[0] - $p);
+				$score = 0 if($score < 0 )
+			}
+			$i += $m;
+			$j += $bl_c[$n]->[1];
+		}
+
+		while($m) { #matches / mismatches
+			($current_s_r, $current_s_c, $n_matches) = ($i, $j, 0) 
+				if($score == 0); #reset
+
+			if(substr($ref_seq, $i, 1) eq substr($con, $j, 1)) {
+				$score += $MATCH;
+				$n_matches++;
+			}
+			else {
+				$score += $MISMATCH;
+			}
+			if($score > $max_score) {
+				$n_max_matches = $n_matches;
+				$max_score = $score;
+				($s_r, $s_c) = ($current_s_r, $current_s_c);
+				($e_r, $e_c) = ($i, $j);
+			}
+			$n_matches = $score = 0 if($score < 0 );
+			$m--; $i++;	$j++;
+		}
+		$p = $bl_r[$n]->[0] + $bl_r[$n]->[1];
+	}
+	return($n_max_matches, $s_r, $e_r, $s_c, $e_c);
+}
+
+sub _mapping_artifact_filter {
+	my $self = shift;
+	if($self->{type} == INV) {
+		return ($self->_mapping_artifact($self->{consensus})
+			|| $self->_mapping_artifact($self->{consensus2}) );
+	}
+	return $self->_mapping_artifact($self->{consensus});
+}
+
+sub _mapping_artifact {
+	my $self = shift;
+	my $con = shift;
+	my $l = length $con;
+	print STDERR "Mapping artifact filter ... ";
+	$self->{error} = "Mapping Artifact";
+	$l = $l - 5;
+	my $options = " minIdentity=97  -out=psl -nohead";
+	$options = $options . " -maxIntron=5 " unless $RNASeq;
+	my $exp = $l;
+	if($self->{type} == DEL && $RNASeq)	{
+		$exp = $self->{second_bp}{pos} - $self->{first_bp}{pos};
+		$options = $options . " -maxIntron=" . ($exp + 100) if($exp > 75000);
+	}
+
+	open my $QUERY, ">query.fa" or croak "can't open query.fa : $OS_ERROR";
+	print $QUERY ">query\n", $con, "\n";
+	close $QUERY;
+	my $tmp_mapping = $mapper->run(-QUERY => "query.fa", -OPTIONS => $options);
+	system("rm query.fa"); system("rm query.fa*");
+
+	$l = $l + 5;
+	if($RNASeq) {
+		#can't find a decent mapping for DEL event
+		return if($self->{type} == DEL && !$tmp_mapping->{query});
+		foreach my $h(@{$tmp_mapping->{query}}) {
+			#next if($h->{tend} - $h->{tstart} < $exp - 10);
+			return if ($self->{type} != DEL && $h->{qend} - $h->{qstart} > $l - 10);
+			my $chr = $h->{tchr};
+			$chr = "chr" . $chr unless $chr =~ m/^chr/;
+			my ($r_tree, $f_tree)  =  ($gm->sub_model($chr, "-"),  $gm->sub_model($chr, "+"));
+			return unless ($f_tree && $r_tree);
+			my @f_genes = $f_tree->intersect([$h->{tstart}, $h->{tend}]);
+			my @r_genes = $r_tree->intersect([$h->{tstart}, $h->{tend}]);
+			return if(scalar @f_genes <= 1 && scalar @r_genes <= 1);
+			my @f_tmp_genes;
+			my @r_tmp_genes;
+			
+			foreach my $g (@f_genes) {
+				foreach my $block (@{$h->{blocks}}) {
+					if($g->val->overlap($block)){
+						push @f_tmp_genes, $g;
+						last;
+					}
+				}
+			}
+			foreach my $g (@r_genes) {
+				foreach my $block  (@{$h->{blocks}}) {
+					if($g->val->overlap($block)){
+						push @r_tmp_genes, $g;
+						last;
+					}
+				}
+			}
+			return if(scalar @f_tmp_genes < 1 && scalar @r_tmp_genes < 1);
+		}
+	}
+	else {
+		foreach my $h (@{$tmp_mapping->{query}}){
+			return if($h->{tend} - $h->{tstart} < $l + 10 && $h->{qend} - $h->{qstart} > $l - 5);
+		}
+	}
+	$self->{error} = undef;
+	return 1;
+}
+
+sub _germline_sclip_filter {
+	my $self = shift;
+	print STDERR "Germline sclip filter\n";
+	return 1 if(!$sam_g);
+	$self->{error} = "Germline Event";
+	my $rtn = _compare_seq($self->{first_bp}) &&
+		_compare_seq($self->{second_bp});
+	$self->{error} = undef if($rtn);
+	return $rtn;
+		
+}
+
+sub _compare_seq {
+	my $bp = shift;
+	my $seq;
+	if($bp->{pos} == $bp->{left_pos}) {
+		my $seg = $sam_d->segment($bp->{right_chr}, $bp->{right_pos} -
+			$germline_seq_width, $bp->{right_pos} + $germline_seq_width);
+		$seq = $seg->dna;
+	}
+	else {
+		my $seg = $sam_d->segment($bp->{left_chr}, $bp->{left_pos} - $germline_seq_width,
+			$bp->{left_pos} + $germline_seq_width);
+		$seq = $seg->dna;
+	}
+	my $sclip_seq  = _get_sclip_seqs($sam_g, $bp->{chr}, $bp->{pos} - $germline_search_width, 
+		$bp->{pos} + $germline_search_width);
+
+
+	open my $TARGET, ">target.fa" or croak "can't open target.fa : $OS_ERROR";
+	print $TARGET ">target\n", $seq, "\n";
+	close $TARGET;
+
+	if(keys(%{$sclip_seq})) {
+		open my $QUERY, ">query.fa" or croak "can't open query.fa : $OS_ERROR";
+		foreach my $s (keys(%{$sclip_seq})) {
+			print $QUERY ">", $s, "\n", $sclip_seq->{$s}, "\n";
+		}
+		close($QUERY);
+		my $hits = $aligner->run(-TARGET => "target.fa", -QUERY => 'query.fa');
+		return if(keys(%{$hits}));
+	}
+	return 1;
+}
+
+sub _type_distance_filter {
+	my $self = shift;
+	my $type = $self->{type};
+	$self->{error} = "Type Distance";
+	print STDERR "Type distance filter\n";
+	if($type == UNK) {  #those events are not sure, always ignore them 
+		print STDERR $self->to_full_string, "\n";
+		return;
+	}
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	return 1 if($bp2->{sc_reads} == 0);
+	my ($d1, $d2);
+	if($type == INS || $type == DEL) {
+		($d1, $d2) = ($bp1->{left_pos} - $bp2->{left_pos}, 
+			$bp1->{right_pos} - $bp2->{right_pos});
+	}
+	if( $type == INV ){
+		($d1, $d2) = ($bp1->{left_pos} - $bp2->{left_pos}, 
+			$bp2->{right_pos} - $bp1->{right_pos});
+	}
+	if( $type == ITX ) {
+		($d1, $d2) = ($bp1->{left_pos} - $bp2->{right_pos},
+			$bp2->{left_pos} - $bp1->{right_pos});
+	}
+	if($type == CTX ) {
+		if($bp1->{left_ort} eq $bp1->{right_ort} || 
+			$bp1->{sc_reads} == 0 || $bp2->{sc_reads} == 0) {
+			($d1, $d2) = ($bp1->{left_pos} - $bp2->{left_pos}, $bp1->{right_pos} - $bp2->{right_pos}) ;
+		}
+		else {
+			($d1, $d2) = ($bp1->{left_pos} - $bp2->{right_pos},	$bp2->{left_pos} - $bp1->{right_pos});
+		}
+	}
+	print STDERR $self->to_full_string, "\t", $d1, "\t", $d2, "\n";
+	if($d1 <= 1 && $d2 <= 1 || abs($d1 - $d2) <= 5) {
+		$self->{error} = undef;
+		return 1;
+	}
+	if(abs($d1) > $max_bp_dist || abs($d2) > $max_bp_dist){
+		print STDERR "Distance fail\n";
+		return;
+	}
+	$self->{error} = undef;
+	return 1; # the distance is small enough
+}
+
+sub _germline_indel_filter {
+	my $self = shift;
+	my $type = $self->{type};
+	print STDERR "Germline INDEL FILTER test\n";
+	return if(abs($self->{first_bp}{pos} - $self->{second_bp}{pos}) < 40);
+	return 1 if(!$sam_g);
+	return 1 if( $type != INS && $type != DEL);
+	return 1 if( abs($self->{first_bp}{pos} - $self->{second_bp}{pos}) > 50 );
+	$self->{error} = "Germline INDEL";
+	my ($start, $end ) = ($self->{first_bp}{left_pos}, $self->{first_bp}{right_pos});
+	my $indel_len = abs($end - $start);
+	($start, $end) = ($end, $start) if($start > $end);
+
+	my $itr = $sam_g->features(-iterator => 1, -seq_id => $self->{first_bp}{chr},
+		-start => $start, -end => $end);
+	while( my $a = $itr->next_seq ) {
+		next if($type == DEL && $a->cigar_str !~ m/D/);
+		next if($type == INS && $a->cigar_str !~ m/I/);
+		my $cigar_array = $a->cigar_array;
+		my $pos = $a->pos;
+		foreach my $ca (@{$cigar_array}) {
+			if($ca->[0] eq 'M') {
+				$pos += $ca->[1];
+				next;
+			}
+			if($ca->[0] eq 'I' && $type == INS ){
+				return  if(abs($ca->[1] - $indel_len) <= 20 && abs($pos - $start) <= 20); 
+				next;
+			}
+			if($ca->[0] eq 'D' && $type == DEL) {
+				return  if(abs($ca->[1] - $indel_len) <= 20 && abs($pos - $start) <= 20);
+				$pos += $ca->[1];
+				next;
+			}
+		}
+	}
+	$self->{error} = undef;
+	return 1;
+}
+
+sub _tandem_repeat_filter {
+	my $self = shift;
+	my $con = $self->{consensus};
+	print STDERR "low compexity filter\n";
+	open my $QUERY, ">query.fa" or croak "can't open query.fa : $OS_ERROR";
+	print $QUERY ">query\n", $self->{consensus}, "\n";
+	close $QUERY;
+	
+	system("ptrfinder -seq query.fa -repsize $tr_min_size,$tr_max_size -minrep $tr_min_num > query.fa.rep");
+	if(-e "query.fa.rep") {
+		open my $REP, "<query.fa.rep" or croak "can't open query.fa.rep:$OS_ERROR";
+		while( my $line = <$REP>) {
+			chomp $line;
+			my($pattern, $len, $times, $s, $e) = 
+				$line =~ m/PATTERN\s(\w+)\sLENGTH\s(\d+)\sTIMES\s(\d+)\sSTART\s(\d+)\sSTOP\s(\d+)\sID/;
+			if($self->{type} == DEL || $self->{type} == INS){
+				if(abs($self->{first_bp}{left_pos} - $self->{first_bp}{right_pos}) < $tr_max_indel_size) {
+					print STDERR "Tandem repeat mediated INDEL!\n";
+					close $REP;
+					return;
+				}
+			}
+			else{
+				if(($s < 5 || length($self->{consensus}) - $e < 5) && $len * $times > 30 ) {
+					print STDERR "Tandem repeat mediated events!\n";
+					close $REP;
+					return;
+				}
+			}
+		}
+	}
+	return 1;
+}
+
+sub _get_sclip_seqs {
+	my ($sam, $chr, $start, $end) = @_;
+    my %rtn;
+    my $range = $chr . ":" . $start . "-" . $end;
+
+    $sam->fetch($range, sub {
+        my $a = shift;
+        my $cigar_str = $a->cigar_str;
+        return if($cigar_str !~ /S/);
+        my ($sclip_len, $pos, $seq, $qual);
+		my @cigar_array = @{$a->cigar_array};
+        if($cigar_array[0]->[0] eq 'S' ) {
+            $sclip_len = $cigar_array[0]->[1]; $pos = $a->start;
+            return if($pos < $start or $pos > $end); # the softclipping position is not in range
+ 			$seq = substr($a->query->dna, 0, $sclip_len );
+			$rtn{$a->qname} = $seq if($sclip_len >= 10);
+		}
+		#if($cigar_str =~ m/S(\d+)$/) {
+		if($cigar_array[$#cigar_array]->[0] eq 'S') {
+			$sclip_len = $cigar_array[$#cigar_array]->[1]; 
+			$pos = $a->end;
+            return if($pos < $start or $pos > $end); # the softclipping position is not in range
+			$seq = substr($a->qseq, $a->l_qseq - $sclip_len );
+			$rtn{$a->qname} = $seq if($sclip_len >= 10);
+		}
+	}
+	);
+	return \%rtn;
+}
+
+sub _RNASeq_strand_filter {
+	my $self = shift;
+	my $type = $self->type;
+	print STDERR "RNASeq strand filter\n";
+	return 1 unless $gm;
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	my ($ort1, $ort2) = ($bp1->{left_ort}, $bp1->{right_ort});
+	my ($chr1, $chr2) = ($bp1->{left_chr}, $bp1->{right_chr});
+	my ($pos1, $pos2) = ($bp1->{pos}, $bp2->{pos});
+	($pos1, $pos2) = ($pos2, $pos1) if($bp1->{right_pos} == $pos1);
+	my ($tmp1, $tmp2) = ($chr1 =~ m/chr/ ? $chr1 : "chr" . $chr1, 
+		$chr2 =~ m/chr/ ? $chr2 : "chr" . $chr2);
+	$tmp1 = "chrM" if($tmp1 eq "chrMT");
+	$tmp2 = "chrM" if($tmp2 eq "chrMT");
+	my ($r_tree1, $f_tree1) = ($gm->sub_model($tmp1, "-"), 	$gm->sub_model($tmp1, "+"));
+	my ($r_tree2, $f_tree2) = ($gm->sub_model($tmp2, "-"), 	$gm->sub_model($tmp2, "+"));
+	my ($g_ort1, $g_ort2);
+	return 1 unless($r_tree1 && $r_tree2 && $f_tree1 && $f_tree2);
+	$g_ort1 = "-" if(scalar($r_tree1->intersect([$pos1 - 5, $pos1])) > 0);
+	$g_ort1 = "+" if(scalar($f_tree1->intersect([$pos1 - 5, $pos1])) > 0);
+	$g_ort2 = "-" if(scalar($r_tree2->intersect([$pos2, $pos2 + 5])) > 0);
+	$g_ort2 = "+" if(scalar($f_tree2->intersect([$pos2, $pos2 + 5])) > 0);
+	return 1 unless($g_ort1 && $g_ort2);
+	return 1 if($g_ort1 eq $ort1 && $g_ort2 eq $ort2);
+	return 1 if($g_ort1 ne $ort1 && $g_ort2 ne $ort2);
+	return;
+}
+
+# INS filter check to make sure that the INS part overlap with any gene
+# if the INS part only in intron will return as a false positive
+sub _RNASeq_INS_filter {
+	my $self = shift;
+	my $type = $self->{type};
+	return 1 if($type != INS);
+	print STDERR "RNAseq INS filter\n";
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	my ($pos1, $pos2) = ($bp1->{pos}, $bp2->{pos});
+	($pos1, $pos2) = ($pos2, $pos1) if($pos2 < $pos1);
+	my $chr = $bp1->{chr};
+	$chr = "chr" . $chr unless $chr =~ m/chr/;
+	my ($r_tree, $f_tree) = ($gm->sub_model($chr, "-"), 	$gm->sub_model($chr, "+"));
+	foreach my $tree( ($r_tree, $f_tree) ) {
+		my @tmp;
+		@tmp = $f_tree->intersect([$pos1, $pos2]);
+		foreach my $g (@tmp) {
+			return 1 if($g->val->overlap([$pos1, $pos2]));	
+		}
+	}
+	return;
+}
+
+sub _RNASeq_DEL_filter {
+	my $self = shift;
+	my $type = $self->type;
+	return 1 if($type != DEL);
+	print STDERR "RNAseq DEL filter\n";
+
+	my ($gene1, $gene2, $dist) = @{$self->get_genes};
+	return if($gene1 eq $gene2);
+	my ($d_plus, $d_minus) = (0, 0);
+	$d_plus = $1 if($dist =~ m/(\d+)\(\+\)/);
+	$d_minus = $1 if($dist =~ m/(\d+)\(\-\)/);
+	return if($d_plus == 0 && $d_minus == 0);
+	my ($bp1, $bp2) = ($self->{first_bp}, $self->{second_bp});
+	return if($bp1->{cover} == 0 || $bp2->{cover} == 0);
+	my($left_len, $right_len);
+	if(exists $bp1->{left_len}) {
+		($left_len, $right_len ) = ($bp1->{left_len}, $bp1->{right_len});
+	}
+	else {
+		$left_len = length($bp1->{sc_seq}) if($bp1->{sc_seq}); 
+		$right_len = length($bp2->{sc_seq}) if($bp2->{sc_seq}); 
+	}
+	return if($left_len < 30 || $right_len < 30);
+	return if($bp1->{sc_reads} < 10 || $bp2->{sc_reads} < 10);
+	return unless $bp1->{left_gene}->overlap([$bp1->{pos} - $left_len, $bp1->{pos}]);
+	return unless $bp1->{right_gene}->overlap([$bp2->{pos} + $right_len, $bp2->{pos}]);
+	return 1;
+}
+
+sub get_statistics {
+	my $self = shift;
+	my $half_width = shift;
+	my $sam = $self->sam_d;
+	my @rtn;
+
+	foreach my $bp ( ($self->{first_bp}, $self->{second_bp})) {
+		my ($chr, $pos ) = ($bp->{chr}, $bp->{pos});
+		my $range = $chr . ":" . ($pos - $half_width) . "-" . ($pos + $half_width);
+		my ($n_seq, $n_rep, $total_pid) = (0, 0, 0);
+
+		$sam->fetch($range, sub {
+			my $a = shift;
+			return unless ($a->start && $a->end);
+			return unless ($a->start >= $pos - $half_width && $a->end <= $pos + $half_width);
+			$n_seq++;
+			$total_pid += _cal_pid($a);
+			if($a->has_tag("XT")) {
+			   $n_rep++ if($a->aux_get("XT") ne "U");
+		    }
+		}
+		);
+		if($n_seq == 0) {
+			push @rtn, (0, 0);
+		}
+		else {
+			push @rtn, ($total_pid/$n_seq, $n_rep/$n_seq);
+		}
+	}
+	return @rtn;
+}
+
+sub _cal_pid {
+	my $a = shift;
+	my ($ref, $matches, $query) = $a->padded_alignment;
+	my ($n_match, $n) = (0, 0);
+	for( my $i = 0; $i < length($matches); $i++) {
+		my $c = substr $matches, $i, 1;
+		$n_match++ if($c eq "|");
+		$n++;
+	}
+	return 0 if($n == 0);
+	return $n_match/$n;
+}
+
+
+1;
+__END__;
+
+=pod
+
+=head1 NAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Transcript.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,126 @@
+package Transcript;
+use strict;
+use Carp;
+use Data::Dumper;
+
+# we are going to use a light weight Transcript model here 
+my @Transcript_slots;
+BEGIN {
+	@Transcript_slots = qw(NAME REFSEQ_ID CHR START END STRAND CDS_START CDS_END EXONS TYPE);
+}
+use enum @Transcript_slots;
+
+my %attribute = (
+    name         => NAME,
+    refseq_id    => REFSEQ_ID,
+	chr			 => CHR,
+    start        => START,
+    end          => END,
+	strand		 => STRAND,
+    cds_start    => CDS_START,
+	cds_end      => CDS_END,
+	exons        => EXONS,
+	type		 => TYPE,
+);
+
+#using an array instead of a hash for the node
+sub _accessor {
+    my $index = shift;
+    return sub {
+        my $self = shift;
+        return undef unless $self;
+        if (@_) {
+          $self->[$index] = shift;
+        }
+        return $self->[$index];
+    };
+}
+
+while(my($at, $idx) = each %attribute) {
+    no strict 'refs';
+    *$at = _accessor($idx);
+}
+
+sub new {
+    my $class = shift;
+    my $obj = [];
+
+    if (@_) {
+		my %arg = @_;
+        $obj->[NAME]      = $arg{-NAME}      if($arg{-NAME});
+		$obj->[REFSEQ_ID] = $arg{-REFSEQ_ID} if($arg{-REFSEQ_ID});
+		$obj->[CHR]       = $arg{-CHR}       if($arg{-CHR});
+		$obj->[START]     = $arg{-START}     if($arg{-START});
+		$obj->[END]       = $arg{-END}       if($arg{-END});
+		$obj->[STRAND]    = $arg{-STRAND}    if($arg{-STRAND});
+		$obj->[CDS_START] = $arg{-CDS_START} if($arg{-CDS_START});
+		$obj->[CDS_END]   = $arg{-CDS_END}   if($arg{-CDS_END});
+		$obj->[EXONS]     = $arg{-EXONS}     if($arg{-EXONS});
+		$obj->[TYPE]      = $arg{-TYPE}      if($arg{-TYPE});
+    }
+    return bless $obj, $class;
+}
+
+sub get_start {
+	my ($self, $pos, $ext) = @_;
+	my @tmp;
+	foreach my $e( @{$self->[EXONS]} ) {
+		if($e->[1] < $pos) {
+			push @tmp, $e;
+			next;
+		}
+		last;
+	}
+	my $len = 0;
+	while(scalar @tmp > 0) {
+		my $e = pop @tmp;
+		if($e->[1] >= $pos) {
+			my $l = $pos - $e->[0];
+			if($l + $len < $ext) {
+				$len = $l;
+				next;
+			}
+			return $pos - $ext;
+		}
+		if($e->[1] - $e->[0] + 1 + $len < $ext) {
+			$len += ($e->[1] - $e->[0] + 1);
+			next;
+		}
+		return ($e->[1] - $ext + $len);
+	}
+	return $self->start;
+}
+
+sub get_end {
+	my ($self, $pos, $ext) = @_;
+	my @tmp = @{$self->[EXONS]};
+	my $len = 0;
+	while(scalar @tmp > 0) {
+		my $e = shift @tmp;
+		next if($e->[1] < $pos);
+		if($e->[0] <= $pos ) {
+			return $pos + $ext if($e->[1] - $pos >= $ext);
+			$len = $e->[1] - $pos;
+			next;
+		}
+		if($e->[1] - $e->[0] + 1 + $len < $ext) {
+			$len += ($e->[1] - $e->[0] + 1);
+			next;
+		}
+		return ($e->[0] + $ext - $len);
+	}
+	return $self->end;
+}
+
+sub overlap {
+	my $self = shift;
+	my $range = shift;
+	croak "Range must be a ref of array" unless(ref($range) eq 'ARRAY');
+
+	foreach my $e ( @{$self->[EXONS]} ) {
+		return 1 if($e->[0] <= $range->[1] && $e->[1] >= $range->[0]);
+	}
+	return;
+}
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tree/DAG_Node.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,2942 @@
+require 5;
+package Tree::DAG_Node;
+use Carp ();
+use strict;
+use vars qw(@ISA $Debug $VERSION);
+
+$Debug = 0;
+$VERSION = '1.06';
+
+=head1 NAME
+
+Tree::DAG_Node - (super)class for representing nodes in a tree
+
+=head1 SYNOPSIS
+
+Using as a base class:
+
+  package Game::Tree::Node; # or whatever you're doing
+  use Tree::DAG_Node;
+  @ISA = qw(Tree::DAG_Node);
+  ...your own methods overriding/extending
+    the methods in Tree::DAG_Node...
+
+Using as a class of its own:
+
+  use Tree::DAG_Node;
+  my $root = Tree::DAG_Node->new();
+  $root->name("I'm the tops");
+  my $new_daughter = $root->new_daughter;
+  $new_daughter->name("More");
+  ...
+
+=head1 DESCRIPTION
+
+This class encapsulates/makes/manipulates objects that represent nodes
+in a tree structure. The tree structure is not an object itself, but
+is emergent from the linkages you create between nodes.  This class
+provides the methods for making linkages that can be used to build up
+a tree, while preventing you from ever making any kinds of linkages
+which are not allowed in a tree (such as having a node be its own
+mother or ancestor, or having a node have two mothers).
+
+This is what I mean by a "tree structure", a bit redundantly stated:
+
+* A tree is a special case of an acyclic directed graph.
+
+* A tree is a network of nodes where there's exactly one root
+node (i.e., 'the top'), and the only primary relationship between nodes
+is the mother-daugher relationship.
+
+* No node can be its own mother, or its mother's mother, etc.
+
+* Each node in the tree has exactly one "parent" (node in the "up"
+direction) -- except the root, which is parentless.
+
+* Each node can have any number (0 to any finite number) of daughter
+nodes.  A given node's daughter nodes constitute an I<ordered> list.
+(However, you are free to consider this ordering irrelevant.
+Some applications do need daughters to be ordered, so I chose to
+consider this the general case.)
+
+* A node can appear in only one tree, and only once in that tree.
+Notably (notable because it doesn't follow from the two above points),
+a node cannot appear twice in its mother's daughter list.
+
+* In other words, there's an idea of up (toward the root) versus
+down (away from the root), and left (i.e., toward the start (index 0)
+of a given node's daughter list) versus right (toward the end of a
+given node's daughter list).
+
+Trees as described above have various applications, among them:
+representing syntactic constituency, in formal linguistics;
+representing contingencies in a game tree; representing abstract
+syntax in the parsing of any computer language -- whether in
+expression trees for programming languages, or constituency in the
+parse of a markup language document.  (Some of these might not use the
+fact that daughters are ordered.)
+
+(Note: B-Trees are a very special case of the above kinds of trees,
+and are best treated with their own class.  Check CPAN for modules
+encapsulating B-Trees; or if you actually want a database, and for
+some reason ended up looking here, go look at L<AnyDBM_File>.)
+
+Many base classes are not usable except as such -- but Tree::DAG_Node
+can be used as a normal class.  You can go ahead and say:
+
+  use Tree::DAG_Node;
+  my $root = Tree::DAG_Node->new();
+  $root->name("I'm the tops");
+  $new_daughter = Tree::DAG_Node->new();
+  $new_daughter->name("More");
+  $root->add_daughter($new_daughter);
+
+and so on, constructing and linking objects from Tree::DAG_Node and
+making useful tree structures out of them.
+
+=head1 A NOTE TO THE READER
+
+This class is big and provides lots of methods.  If your problem is
+simple (say, just representing a simple parse tree), this class might
+seem like using an atomic sledgehammer to swat a fly.  But the
+complexity of this module's bells and whistles shouldn't detract from
+the efficiency of using this class for a simple purpose.  In fact, I'd
+be very surprised if any one user ever had use for more that even a
+third of the methods in this class.  And remember: an atomic
+sledgehammer B<will> kill that fly.
+
+=head1 OBJECT CONTENTS
+
+Implementationally, each node in a tree is an object, in the sense of
+being an arbitrarily complex data structure that belongs to a class
+(presumably Tree::DAG_Node, or ones derived from it) that provides
+methods.
+
+The attributes of a node-object are:
+
+=over
+
+=item mother -- this node's mother.  undef if this is a root.
+
+=item daughters -- the (possibly empty) list of daughters of this node.
+
+=item name -- the name for this node.
+
+Need not be unique, or even printable.  This is printed in some of the
+various dumper methods, but it's up to you if you don't put anything
+meaningful or printable here.
+
+=item attributes -- whatever the user wants to use it for.
+
+Presumably a hashref to whatever other attributes the user wants to
+store without risk of colliding with the object's real attributes.
+(Example usage: attributes to an SGML tag -- you definitely wouldn't
+want the existence of a "mother=foo" pair in such a tag to collide with
+a node object's 'mother' attribute.)
+
+Aside from (by default) initializing it to {}, and having the access
+method called "attributes" (described a ways below), I don't do
+anything with the "attributes" in this module.  I basically intended
+this so that users who don't want/need to bother deriving a class
+from Tree::DAG_Node, could still attach whatever data they wanted in a
+node.
+
+=back
+
+"mother" and "daughters" are attributes that relate to linkage -- they
+are never written to directly, but are changed as appropriate by the
+"linkage methods", discussed below.
+
+The other two (and whatever others you may add in derived classes) are
+simply accessed thru the same-named methods, discussed further below.
+
+=head2 ABOUT THE DOCUMENTED INTERFACE
+
+Stick to the documented interface (and comments in the source --
+especially ones saying "undocumented!" and/or "disfavored!" -- do not
+count as documentation!), and don't rely on any behavior that's not in
+the documented interface.
+
+Specifically, unless the documentation for a particular method says
+"this method returns thus-and-such a value", then you should not rely on
+it returning anything meaningful.
+
+A I<passing> acquintance with at least the broader details of the source
+code for this class is assumed for anyone using this class as a base
+class -- especially if you're overriding existing methods, and
+B<definitely> if you're overriding linkage methods.
+
+=head1 MAIN CONSTRUCTOR, AND INITIALIZER
+
+=over
+
+=item the constructor CLASS->new() or CLASS->new({...options...})
+
+This creates a new node object, calls $object->_init({...options...})
+to provide it sane defaults (like: undef name, undef mother, no
+daughters, 'attributes' setting of a new empty hashref), and returns
+the object created.  (If you just said "CLASS->new()" or "CLASS->new",
+then it pretends you called "CLASS->new({})".)
+
+Currently no options for putting in {...options...} are part
+of the documented interface, but the options is here in case
+you want to add such behavior in a derived class.
+
+Read on if you plan on using Tree::DAG_New as a base class.
+(Otherwise feel free to skip to the description of _init.)
+
+There are, in my mind, two ways to do object construction:
+
+Way 1: create an object, knowing that it'll have certain uninteresting
+sane default values, and then call methods to change those values to
+what you want.  Example:
+
+    $node = Tree::DAG_Node->new;
+    $node->name('Supahnode!');
+    $root->add_daughter($node);
+    $node->add_daughters(@some_others)
+
+Way 2: be able to specify some/most/all the object's attributes in
+the call to the constructor.  Something like:
+
+    $node = Tree::DAG_Node->new({
+      name => 'Supahnode!',
+      mother => $root,
+      daughters => \@some_others
+    });
+
+After some deliberation, I've decided that the second way is a Bad
+Thing.  First off, it is B<not> markedly more concise than the first
+way.  Second off, it often requires subtly different syntax (e.g.,
+\@some_others vs @some_others).  It just complicates things for the
+programmer and the user, without making either appreciably happier.
+
+(This is not to say that options in general for a constructor are bad
+-- C<random_network>, discussed far below, necessarily takes options.
+But note that those are not options for the default values of
+attributes.)
+
+Anyway, if you use Tree::DAG_Node as a superclass, and you add
+attributes that need to be initialized, what you need to do is provide
+an _init method that calls $this->SUPER::_init($options) to use its
+superclass's _init method, and then initializes the new attributes:
+
+  sub _init {
+    my($this, $options) = @_[0,1];
+    $this->SUPER::_init($options); # call my superclass's _init to
+      # init all the attributes I'm inheriting
+    
+    # Now init /my/ new attributes:
+    $this->{'amigos'} = []; # for example
+  }
+
+...or, as I prefer when I'm being a neat freak:
+
+  sub _init {
+    my($this, $options) = @_[0,1];
+    $this->SUPER::_init($options);
+    
+    $this->_init_amigos($options);
+  }
+  
+  sub _init_amigos {
+    my $this = $_[0];
+    # Or my($this,$options) = @_[0,1]; if I'm using $options
+    $this->{'amigos'} = [];
+  }
+
+
+In other words, I like to have each attribute initialized thru a
+method named _init_[attribute], which should expect the object as
+$_[0] and the the options hashref (or {} if none was given) as $_[1].
+If you insist on having your _init recognize options for setting
+attributes, you might as well have them dealt with by the appropriate
+_init_[attribute] method, like this:
+
+  sub _init {
+    my($this, $options) = @_[0,1];
+    $this->SUPER::_init($options);
+    
+    $this->_init_amigos($options);
+  }
+  
+  sub _init_amigos {
+    my($this,$options) = @_[0,1]; # I need options this time
+    $this->{'amigos'} = [];
+    $this->amigos(@{$options->{'amigos'}}) if $options->{'amigos'};
+  }
+
+All this bookkeeping looks silly with just one new attribute in a
+class derived straight from Tree::DAG_Node, but if there's lots of new
+attributes running around, and if you're deriving from a class derived
+from a class derived from Tree::DAG_Node, then tidy
+stratification/modularization like this can keep you sane.
+
+=item the constructor $obj->new() or $obj->new({...options...})
+
+Just another way to get at the C<new> method. This B<does not copy>
+$obj, but merely constructs a new object of the same class as it.
+Saves you the bother of going $class = ref $obj; $obj2 = $class->new;
+
+=cut
+
+sub new { # constructor
+  # Presumably you won't EVER need to override this -- _init is what
+  # you'd override in order to set an object's default attribute values.
+  my $class = shift;
+  $class = ref($class) if ref($class); # tchristic style.  why not?
+
+  my $o = ref($_[0]) eq 'HASH' ? $_[0] : {}; # o for options hashref
+  my $it = bless( {}, $class );
+  print "Constructing $it in class $class\n" if $Debug;
+  $it->_init( $o );
+  return $it;
+}
+
+###########################################################################
+
+=item the method $node->_init({...options...})
+
+Initialize the object's attribute values.  See the discussion above.
+Presumably this should be called only by the guts of the C<new>
+constructor -- never by the end user.
+
+Currently there are no documented options for putting in
+{...options...}, but (in case you want to disregard the above rant)
+the option exists for you to use {...options...} for something useful
+in a derived class.
+
+Please see the source for more information.
+
+=item see also (below) the constructors "new_daughter" and "new_daughter_left"
+
+=back
+
+=cut
+
+sub _init { # method
+  my $this = shift;
+  my $o = ref($_[0]) eq 'HASH' ? $_[0] : {};
+
+  # Sane initialization.
+  $this->_init_mother($o);
+  $this->_init_daughters($o);
+  $this->_init_name($o);
+  $this->_init_attributes($o);
+
+  return;
+}
+
+sub _init_mother { # to be called by an _init
+  my($this, $o) = @_[0,1];
+
+  $this->{'mother'} = undef;
+
+  # Undocumented and disfavored.  Consider this just an example.
+  ( $o->{'mother'} )->add_daughter($this)
+    if defined($o->{'mother'}) && ref($o->{'mother'});
+  # DO NOT use this option (as implemented) with new_daughter or
+  #  new_daughter_left!!!!!
+  # BAD THINGS MAY HAPPEN!!!
+}
+
+sub _init_daughters { # to be called by an _init
+  my($this, $o) = @_[0,1];
+
+  $this->{'daughters'} = [];
+
+  # Undocumented and disfavored.  Consider this just an example.
+  $this->set_daughters( @{$o->{'daughters'}} )
+    if ref($o->{'daughters'}) && (@{$o->{'daughters'}});
+  # DO NOT use this option (as implemented) with new_daughter or
+  #  new_daughter_left!!!!!
+  # BAD THINGS MAY HAPPEN!!!
+}
+
+sub _init_name { # to be called by an _init
+  my($this, $o) = @_[0,1];
+
+  $this->{'name'} = undef;
+
+  # Undocumented and disfavored.  Consider this just an example.
+  $this->name( $o->{'name'} ) if exists $o->{'name'};
+}
+
+sub _init_attributes { # to be called by an _init
+  my($this, $o) = @_[0,1];
+
+  $this->{'attributes'} = {};
+
+  # Undocumented and disfavored.  Consider this just an example.
+  $this->attributes( $o->{'attributes'} ) if exists $o->{'attributes'};
+}
+
+###########################################################################
+###########################################################################
+
+=head1 LINKAGE-RELATED METHODS
+
+=over
+
+=item $node->daughters
+
+This returns the (possibly empty) list of daughters for $node.
+
+=cut
+
+sub daughters { # read-only attrib-method: returns a list.
+  my $this = shift;
+
+  if(@_) { # undoc'd and disfavored to use as a write-method
+    Carp::croak "Don't set daughters with doughters anymore\n";
+    Carp::carp "my parameter must be a listref" unless ref($_[0]);
+    $this->{'daughters'} = $_[0];
+    $this->_update_daughter_links;
+  }
+  #return $this->{'daughters'};
+  return @{$this->{'daughters'} || []};
+}
+
+###########################################################################
+
+=item $node->mother
+
+This returns what node is $node's mother.  This is undef if $node has
+no mother -- i.e., if it is a root.
+
+=cut
+
+sub mother { # read-only attrib-method: returns an object (the mother node)
+  my $this = shift;
+  Carp::croak "I'm a read-only method!" if @_;
+  return $this->{'mother'};
+}
+
+###########################################################################
+###########################################################################
+
+=item $mother->add_daughters( LIST )
+
+This method adds the node objects in LIST to the (right) end of
+$mother's C<daughter> list.  Making a node N1 the daughter of another
+node N2 also means that N1's C<mother> attribute is "automatically" set
+to N2; it also means that N1 stops being anything else's daughter as
+it becomes N2's daughter.
+
+If you try to make a node its own mother, a fatal error results.  If
+you try to take one of a a node N1's ancestors and make it also a
+daughter of N1, a fatal error results.  A fatal error results if
+anything in LIST isn't a node object.
+
+If you try to make N1 a daughter of N2, but it's B<already> a daughter
+of N2, then this is a no-operation -- it won't move such nodes to the
+end of the list or anything; it just skips doing anything with them.
+
+=item $node->add_daughter( LIST )
+
+An exact synonym for $node->add_daughters(LIST)
+
+=cut
+
+sub add_daughters { # write-only method
+  my($mother, @daughters) = @_;
+  return unless @daughters; # no-op
+  return
+    $mother->_add_daughters_wrapper(
+      sub { push @{$_[0]}, $_[1]; },
+      @daughters
+    );
+}
+
+sub add_daughter { # alias
+  my($it,@them) = @_;  $it->add_daughters(@them);
+}
+
+=item $mother->add_daughters_left( LIST )
+
+This method is just like C<add_daughters>, except that it adds the
+node objects in LIST to the (left) beginning of $mother's daughter
+list, instead of the (right) end of it.
+
+=item $node->add_daughter_left( LIST )
+
+An exact synonym for $node->add_daughters_left( LIST )
+
+=cut
+
+sub add_daughters_left { # write-only method
+  my($mother, @daughters) = @_;
+  return unless @daughters;
+  return
+    $mother->_add_daughters_wrapper(
+      sub { unshift @{$_[0]}, $_[1]; },
+      @daughters
+    );
+}
+
+sub add_daughter_left { # alias
+  my($it,@them) = @_;  $it->add_daughters_left(@them);
+}
+
+=item Note:
+
+The above link-making methods perform basically an C<unshift> or
+C<push> on the mother node's daughter list.  To get the full range of
+list-handling functionality, copy the daughter list, and change it,
+and then call C<set_daughters> on the result:
+
+          @them = $mother->daughters;
+          @removed = splice(@them, 0,2, @new_nodes);
+          $mother->set_daughters(@them);
+
+Or consider a structure like:
+
+          $mother->set_daughters(
+                                 grep($_->name =~ /NP/ ,
+                                      $mother->daughters
+                                     )
+                                );
+
+=cut
+
+
+###
+##  Used by the adding methods
+#    (except maybe new_daughter, and new_daughter_left)
+
+sub _add_daughters_wrapper {
+  my($mother, $callback, @daughters) = @_;
+  return unless @daughters;
+
+  my %ancestors;
+  @ancestors{ $mother->ancestors } = undef;
+  # This could be made more efficient by not bothering to compile
+  # the ancestor list for $mother if all the nodes to add are
+  # daughterless.
+  # But then you have to CHECK if they're daughterless.
+  # If $mother is [big number] generations down, then it's worth checking.
+
+  foreach my $daughter (@daughters) { # which may be ()
+    Carp::croak "daughter must be a node object!" unless UNIVERSAL::can($daughter, 'is_node');
+
+    printf "Mother  : %s (%s)\n", $mother, ref $mother if $Debug;
+    printf "Daughter: %s (%s)\n", $daughter, ref $daughter if $Debug;
+    printf "Adding %s to %s\n",
+      ($daughter->name() || $daughter),
+      ($mother->name()   || $mother)     if $Debug > 1;
+
+    Carp::croak "mother can't be its own daughter!" if $mother eq $daughter;
+
+    $daughter->cyclicity_fault(
+      "$daughter (" . ($daughter->name || 'no_name') .
+      ") is an ancestor of $mother (" . ($mother->name || 'no_name') .
+      "), so can't became its daughter."
+    ) if exists $ancestors{$daughter};
+
+    my $old_mother = $daughter->{'mother'};
+
+    next if defined($old_mother) && ref($old_mother) && $old_mother eq $mother;
+      # noop if $daughter is already $mother's daughter
+
+    $old_mother->remove_daughters($daughter)
+      if defined($old_mother) && ref($old_mother);
+
+    &{$callback}($mother->{'daughters'}, $daughter);
+  }
+  $mother->_update_daughter_links; # need only do this at the end
+
+  return;
+}
+
+###########################################################################
+###########################################################################
+
+sub _update_daughter_links {
+  # Eliminate any duplicates in my daughters list, and update
+  #  all my daughters' links to myself.
+  my $this = shift;
+
+  my $them = $this->{'daughters'};
+
+  # Eliminate duplicate daughters.
+  my %seen = ();
+  @$them = grep { ref($_) && not($seen{$_}++) } @$them;
+   # not that there should ever be duplicate daughters anyhoo.
+
+  foreach my $one (@$them) { # linkage bookkeeping
+    Carp::croak "daughter <$one> isn't an object!" unless ref $one;
+    $one->{'mother'} = $this;
+  }
+  return;
+}
+
+###########################################################################
+
+# Currently unused.
+
+sub _update_links { # update all descendant links for ancestorship below
+  # this point
+  # note: it's "descendant", not "descendent"
+  # see <http://www.lenzo.com/~sburke/stuff/english_ant_and_ent.html>
+  my $this = shift;
+  # $this->no_cyclicity;
+  $this->walk_down({
+    'callback' => sub {
+      my $this = $_[0];
+      $this->_update_daughter_links;
+      return 1;
+    },
+  });
+}
+
+###########################################################################
+###########################################################################
+
+=item the constructor $daughter = $mother->new_daughter, or
+
+=item the constructor $daughter = $mother->new_daughter({...options...})
+
+This B<constructs> a B<new> node (of the same class as $mother), and
+adds it to the (right) end of the daughter list of $mother. This is
+essentially the same as going
+
+      $daughter = $mother->new;
+      $mother->add_daughter($daughter);
+
+but is rather more efficient because (since $daughter is guaranteed new
+and isn't linked to/from anything), it doesn't have to check that
+$daughter isn't an ancestor of $mother, isn't already daughter to a
+mother it needs to be unlinked from, isn't already in $mother's 
+daughter list, etc.
+
+As you'd expect for a constructor, it returns the node-object created.
+
+=cut
+
+# Note that if you radically change 'mother'/'daughters' bookkeeping,
+# you may have to change this routine, since it's one of the places
+# that directly writes to 'daughters' and 'mother'.
+
+sub new_daughter {
+  my($mother, @options) = @_;
+  my $daughter = $mother->new(@options);
+
+  push @{$mother->{'daughters'}}, $daughter;
+  $daughter->{'mother'} = $mother;
+
+  return $daughter;
+}
+
+=item the constructor $mother->new_daughter_left, or
+
+=item $mother->new_daughter_left({...options...})
+
+This is just like $mother->new_daughter, but adds the new daughter
+to the left (start) of $mother's daughter list.
+
+=cut
+
+# Note that if you radically change 'mother'/'daughters' bookkeeping,
+# you may have to change this routine, since it's one of the places
+# that directly writes to 'daughters' and 'mother'.
+
+sub new_daughter_left {
+  my($mother, @options) = @_;
+  my $daughter = $mother->new(@options);
+
+  unshift @{$mother->{'daughters'}}, $daughter;
+  $daughter->{'mother'} = $mother;
+
+  return $daughter;
+}
+
+###########################################################################
+
+=item $mother->remove_daughters( LIST )
+
+This removes the nodes listed in LIST from $mother's daughter list.
+This is a no-operation if LIST is empty.  If there are things in LIST
+that aren't a current daughter of $mother, they are ignored.
+
+Not to be confused with $mother->clear_daughters.
+
+=cut
+
+sub remove_daughters { # write-only method
+  my($mother, @daughters) = @_;
+  Carp::croak "mother must be an object!" unless ref $mother;
+  return unless @daughters;
+
+  my %to_delete;
+  @daughters = grep {ref($_)
+		       and defined($_->{'mother'})
+		       and $mother eq $_->{'mother'}
+                    } @daughters;
+  return unless @daughters;
+  @to_delete{ @daughters } = undef;
+
+  # This could be done better and more efficiently, I guess.
+  foreach my $daughter (@daughters) {
+    $daughter->{'mother'} = undef;
+  }
+  my $them = $mother->{'daughters'};
+  @$them = grep { !exists($to_delete{$_}) } @$them;
+
+  # $mother->_update_daughter_links; # unnecessary
+  return;
+}
+
+=item $node->remove_daughter( LIST )
+
+An exact synonym for $node->remove_daughters( LIST )
+
+=cut
+
+sub remove_daughter { # alias
+  my($it,@them) = @_;  $it->remove_daughters(@them);
+}
+
+=item $node->unlink_from_mother
+
+This removes node from the daughter list of its mother.  If it has no
+mother, this is a no-operation.
+
+Returns the mother unlinked from (if any).
+
+=cut
+
+sub unlink_from_mother {
+  my $node = $_[0];
+  my $mother = $node->{'mother'};
+  $mother->remove_daughters($node) if defined($mother) && ref($mother);
+  return $mother;
+}
+
+###########################################################################
+
+=item $mother->clear_daughters
+
+This unlinks all $mother's daughters.
+Returns the the list of what used to be $mother's daughters.
+
+Not to be confused with $mother->remove_daughters( LIST ).
+
+=cut
+
+sub clear_daughters { # write-only method
+  my($mother) = $_[0];
+  my @daughters = @{$mother->{'daughters'}};
+
+  @{$mother->{'daughters'}} = ();
+  foreach my $one (@daughters) {
+    next unless UNIVERSAL::can($one, 'is_node'); # sanity check
+    $one->{'mother'} = undef;
+  }
+  # Another, simpler, way to do it:
+  #  $mother->remove_daughters($mother->daughters);
+
+  return @daughters; # NEW
+}
+#--------------------------------------------------------------------------
+
+=item $mother->set_daughters( LIST )
+
+This unlinks all $mother's daughters, and replaces them with the
+daughters in LIST.
+
+Currently implemented as just $mother->clear_daughters followed by
+$mother->add_daughters( LIST ).
+
+=cut
+
+sub set_daughters { # write-only method
+  my($mother, @them) = @_;
+  $mother->clear_daughters;
+  $mother->add_daughters(@them) if @them;
+  # yup, it's that simple
+}
+
+#--------------------------------------------------------------------------
+
+=item $node->replace_with( LIST )
+
+This replaces $node in its mother's daughter list, by unlinking $node
+and replacing it with the items in LIST.  This returns a list consisting
+of $node followed by LIST, i.e., the nodes that replaced it.
+
+LIST can include $node itself (presumably at most once).  LIST can
+also be empty-list.  However, if any items in LIST are sisters to
+$node, they are ignored, and are not in the copy of LIST passed as the
+return value.
+
+As you might expect for any linking operation, the items in LIST
+cannot be $node's mother, or any ancestor to it; and items in LIST are,
+of course, unlinked from their mothers (if they have any) as they're
+linked to $node's mother.
+
+(In the special (and bizarre) case where $node is root, this simply calls
+$this->unlink_from_mother on all the items in LIST, making them roots of
+their own trees.)
+
+Note that the daughter-list of $node is not necessarily affected; nor
+are the daughter-lists of the items in LIST.  I mention this in case you
+think replace_with switches one node for another, with respect to its
+mother list B<and> its daughter list, leaving the rest of the tree
+unchanged. If that's what you want, replacing $Old with $New, then you
+want:
+
+  $New->set_daughters($Old->clear_daughters);
+  $Old->replace_with($New);
+
+(I can't say $node's and LIST-items' daughter lists are B<never>
+affected my replace_with -- they can be affected in this case:
+
+  $N1 = ($node->daughters)[0]; # first daughter of $node
+  $N2 = ($N1->daughters)[0];   # first daughter of $N1;
+  $N3 = Tree::DAG_Node->random_network; # or whatever
+  $node->replace_with($N1, $N2, $N3);
+
+As a side affect of attaching $N1 and $N2 to $node's mother, they're
+unlinked from their parents ($node, and $N1, replectively).
+But N3's daughter list is unaffected.
+
+In other words, this method does what it has to, as you'd expect it
+to.
+
+=cut
+
+sub replace_with { # write-only method
+  my($this, @replacements) = @_;
+  
+  if(not( defined($this->{'mother'}) && ref($this->{'mother'}) )) { # if root
+    foreach my $replacement (@replacements) {
+      $replacement->{'mother'}->remove_daughters($replacement)
+        if $replacement->{'mother'};
+    }
+      # make 'em roots
+  } else { # I have a mother
+    my $mother = $this->{'mother'};
+
+    #@replacements = grep(($_ eq $this  ||  $_->{'mother'} ne $mother),
+    #                     @replacements);
+    @replacements = grep { $_ eq $this
+                           || not(defined($_->{'mother'}) &&
+                                  ref($_->{'mother'}) &&
+                                  $_->{'mother'} eq $mother
+                                 )
+                         }
+                         @replacements;
+    # Eliminate sisters (but not self)
+    # i.e., I want myself or things NOT with the same mother as myself.
+
+    $mother->set_daughters(   # old switcheroo
+                           map($_ eq $this ? (@replacements) : $_ ,
+                               @{$mother->{'daughters'}}
+                              )
+                          );
+    # and set_daughters does all the checking and possible
+    # unlinking
+  }
+  return($this, @replacements);
+}
+
+=item $node->replace_with_daughters
+
+This replaces $node in its mother's daughter list, by unlinking $node
+and replacing it with its daughters.  In other words, $node becomes
+motherless and daughterless as its daughters move up and take its place.
+This returns a list consisting of $node followed by the nodes that were
+its daughters.
+
+In the special (and bizarre) case where $node is root, this simply
+unlinks its daughters from it, making them roots of their own trees.
+
+Effectively the same as $node->replace_with($node->daughters), but more
+efficient, since less checking has to be done.  (And I also think
+$node->replace_with_daughters is a more common operation in
+tree-wrangling than $node->replace_with(LIST), so deserves a named
+method of its own, but that's just me.)
+
+=cut
+
+# Note that if you radically change 'mother'/'daughters' bookkeeping,
+# you may have to change this routine, since it's one of the places
+# that directly writes to 'daughters' and 'mother'.
+
+sub replace_with_daughters { # write-only method
+  my($this) = $_[0]; # takes no params other than the self
+  my $mother = $this->{'mother'};
+  return($this, $this->clear_daughters)
+    unless defined($mother) && ref($mother);
+
+  my @daughters = $this->clear_daughters;
+  my $sib_r = $mother->{'daughters'};
+  @$sib_r = map($_ eq $this ? (@daughters) : $_,
+                @$sib_r   # old switcheroo
+            );
+  foreach my $daughter (@daughters) {
+    $daughter->{'mother'} = $mother;
+  }
+  return($this, @daughters);
+}
+
+#--------------------------------------------------------------------------
+
+=item $node->add_left_sisters( LIST )
+
+This adds the elements in LIST (in that order) as immediate left sisters of
+$node.  In other words, given that B's mother's daughter-list is (A,B,C,D),
+calling B->add_left_sisters(X,Y) makes B's mother's daughter-list
+(A,X,Y,B,C,D).
+
+If LIST is empty, this is a no-op, and returns empty-list.
+
+This is basically implemented as a call to $node->replace_with(LIST,
+$node), and so all replace_with's limitations and caveats apply.
+
+The return value of $node->add_left_sisters( LIST ) is the elements of
+LIST that got added, as returned by replace_with -- minus the copies
+of $node you'd get from a straight call to $node->replace_with(LIST,
+$node).
+
+=cut
+
+sub add_left_sisters { # write-only method
+  my($this, @new) = @_;
+  return() unless @new;
+  
+  @new = $this->replace_with(@new, $this);
+  shift @new; pop @new; # kill the copies of $this
+  return @new;
+}
+
+=item $node->add_left_sister( LIST )
+
+An exact synonym for $node->add_left_sisters(LIST)
+
+=cut
+
+sub add_left_sister { # alias
+  my($it,@them) = @_;  $it->add_left_sisters(@them);
+}
+
+=item $node->add_right_sisters( LIST )
+
+Just like add_left_sisters (which see), except that the the elements
+in LIST (in that order) as immediate B<right> sisters of $node;
+
+In other words, given that B's mother's daughter-list is (A,B,C,D),
+calling B->add_right_sisters(X,Y) makes B's mother's daughter-list
+(A,B,X,Y,C,D).
+
+=cut
+
+sub add_right_sisters { # write-only method
+  my($this, @new) = @_;
+  return() unless @new;
+  @new = $this->replace_with($this, @new);
+  shift @new; shift @new; # kill the copies of $this
+  return @new;
+}
+
+=item $node->add_right_sister( LIST )
+
+An exact synonym for $node->add_right_sisters(LIST)
+
+=cut
+
+sub add_right_sister { # alias
+  my($it,@them) = @_;  $it->add_right_sisters(@them);
+}
+
+###########################################################################
+
+=back
+
+=cut
+
+###########################################################################
+###########################################################################
+
+=head1 OTHER ATTRIBUTE METHODS
+
+=over
+
+=item $node->name or $node->name(SCALAR)
+
+In the first form, returns the value of the node object's "name"
+attribute.  In the second form, sets it to the value of SCALAR.
+
+=cut
+
+sub name { # read/write attribute-method.  returns/expects a scalar
+  my $this = shift;
+  $this->{'name'} = $_[0] if @_;
+  return $this->{'name'};
+}
+
+
+###########################################################################
+
+=item $node->attributes or $node->attributes(SCALAR)
+
+In the first form, returns the value of the node object's "attributes"
+attribute.  In the second form, sets it to the value of SCALAR.  I
+intend this to be used to store a reference to a (presumably
+anonymous) hash the user can use to store whatever attributes he
+doesn't want to have to store as object attributes.  In this case, you
+needn't ever set the value of this.  (_init has already initialized it
+to {}.)  Instead you can just do...
+
+  $node->attributes->{'foo'} = 'bar';
+
+...to write foo => bar.
+
+=cut
+
+sub attributes { # read/write attribute-method
+  # expects a ref, presumably a hashref
+  my $this = shift;
+  if(@_) {
+    Carp::carp "my parameter must be a reference" unless ref($_[0]);
+    $this->{'attributes'} = $_[0];
+  }
+  return $this->{'attributes'};
+}
+
+=item $node->attribute or $node->attribute(SCALAR)
+
+An exact synonym for $node->attributes or $node->attributes(SCALAR)
+
+=cut
+
+sub attribute { # alias
+  my($it,@them) = @_;  $it->attributes(@them);
+}
+
+###########################################################################
+# Secret Stuff.
+
+sub no_cyclicity { # croak iff I'm in a CYCLIC class. 
+  my($it) = $_[0];
+  # If, God forbid, I use this to make a cyclic class, then I'd
+  # expand the functionality of this routine to actually look for
+  # cyclicity.  Or something like that.  Maybe.
+
+  $it->cyclicity_fault("You can't do that in a cyclic class!")
+    if $it->cyclicity_allowed;
+  return;
+}
+
+sub cyclicity_fault {
+  my($it, $bitch) = @_[0,1];
+  Carp::croak "Cyclicity fault: $bitch"; # never return
+}
+
+sub cyclicity_allowed {
+  return 0;
+}
+
+###########################################################################
+# More secret stuff.  Currently unused.
+
+sub inaugurate_root { # no-op
+  my($it, $tree) = @_[0,1];
+  # flag this node as being the root of the tree $tree.
+  return;
+}
+
+sub decommission_root { # no-op
+  # flag this node as no longer being the root of the tree $tree.
+  return;
+}
+
+###########################################################################
+###########################################################################
+
+=back
+
+=head1 OTHER METHODS TO DO WITH RELATIONSHIPS
+
+=over
+
+=item $node->is_node
+
+This always returns true.  More pertinently, $object->can('is_node')
+is true (regardless of what C<is_node> would do if called) for objects
+belonging to this class or for any class derived from it.
+
+=cut
+
+sub is_node { return 1; } # always true.
+# NEVER override this with anything that returns false in the belief
+#  that this'd signal "not a node class".  The existence of this method
+#  is what I test for, with the various "can()" uses in this class.
+
+###########################################################################
+
+=item $node->ancestors
+
+Returns the list of this node's ancestors, starting with its mother,
+then grandmother, and ending at the root.  It does this by simply
+following the 'mother' attributes up as far as it can.  So if $item IS
+the root, this returns an empty list.
+
+Consider that scalar($node->ancestors) returns the ply of this node
+within the tree -- 2 for a granddaughter of the root, etc., and 0 for
+root itself.
+
+=cut
+
+sub ancestors {
+  my $this = shift;
+  my $mama = $this->{'mother'}; # initial condition
+  return () unless ref($mama); # I must be root!
+
+  # $this->no_cyclicity; # avoid infinite loops
+
+  # Could be defined recursively, as:
+  # if(ref($mama = $this->{'mother'})){
+  #   return($mama, $mama->ancestors);
+  # } else {
+  #   return ();
+  # }
+  # But I didn't think of that until I coded the stuff below, which is
+  # faster.
+
+  my @ancestors = ( $mama ); # start off with my mama
+  while(defined( $mama = $mama->{'mother'} ) && ref($mama)) {
+    # Walk up the tree
+    push(@ancestors, $mama);
+    # This turns into an infinite loop if someone gets stupid
+    #  and makes this tree cyclic!  Don't do it!
+  }
+  return @ancestors;
+}
+
+###########################################################################
+
+=item $node->root
+
+Returns the root of whatever tree $node is a member of.  If $node is
+the root, then the result is $node itself.
+
+=cut
+
+sub root {
+  my $it = $_[0];
+  my @ancestors = ($it, $it->ancestors);
+  return $ancestors[-1];
+}
+
+###########################################################################
+
+=item $node->is_daughter_of($node2)
+
+Returns true iff $node is a daughter of $node2.
+Currently implemented as just a test of ($it->mother eq $node2).
+
+=cut
+
+sub is_daughter_of {
+  my($it,$mama) = @_[0,1];
+  return $it->{'mother'} eq $mama;
+}
+
+###########################################################################
+
+=item $node->self_and_descendants
+
+Returns a list consisting of itself (as element 0) and all the
+descendants of $node.  Returns just itself if $node is a
+terminal_node.
+
+(Note that it's spelled "descendants", not "descendents".)
+
+=cut
+
+sub self_and_descendants {
+  # read-only method:  return a list of myself and any/all descendants
+  my $node = shift;
+  my @List = ();
+  # $node->no_cyclicity;
+  $node->walk_down({ 'callback' => sub { push @List, $_[0]; return 1;}});
+  Carp::croak "Spork Error 919: \@List has no contents!?!?" unless @List;
+    # impossible
+  return @List;
+}
+
+###########################################################################
+
+=item $node->descendants
+
+Returns a list consisting of all the descendants of $node.  Returns
+empty-list if $node is a terminal_node.
+
+(Note that it's spelled "descendants", not "descendents".)
+
+=cut
+
+sub descendants {
+  # read-only method:  return a list of my descendants
+  my $node = shift;
+  my @list = $node->self_and_descendants;
+  shift @list; # lose myself.
+  return @list;
+}
+
+###########################################################################
+
+=item $node->leaves_under
+
+Returns a list (going left-to-right) of all the leaf nodes under
+$node.  ("Leaf nodes" are also called "terminal nodes" -- i.e., nodes
+that have no daughters.)  Returns $node in the degenerate case of
+$node being a leaf itself.
+
+=cut
+
+sub leaves_under {
+  # read-only method:  return a list of all leaves under myself.
+  # Returns myself in the degenerate case of being a leaf myself.
+  my $node = shift;
+  my @List = ();
+  # $node->no_cyclicity;
+  $node->walk_down({ 'callback' =>
+    sub {
+      my $node = $_[0];
+      my @daughters = @{$node->{'daughters'}};
+      push(@List, $node) unless @daughters;
+      return 1;
+    }
+  });
+  Carp::croak "Spork Error 861: \@List has no contents!?!?" unless @List;
+    # impossible
+  return @List;
+}
+
+###########################################################################
+
+=item $node->depth_under
+
+Returns an integer representing the number of branches between this
+$node and the most distant leaf under it.  (In other words, this
+returns the ply of subtree starting of $node.  Consider
+scalar($it->ancestors) if you want the ply of a node within the whole
+tree.)
+
+=cut
+
+sub depth_under {
+  my $node = shift;
+  my $max_depth = 0;
+  $node->walk_down({
+    '_depth' => 0,
+    'callback' => sub {
+      my $depth = $_[1]->{'_depth'};
+      $max_depth = $depth if $depth > $max_depth;
+      return 1;
+    },
+  });
+  return $max_depth;
+}
+
+###########################################################################
+
+=item $node->generation
+
+Returns a list of all nodes (going left-to-right) that are in $node's
+generation -- i.e., that are the some number of nodes down from
+the root.  $root->generation is just $root.
+
+Of course, $node is always in its own generation.
+
+=item $node->generation_under(NODE2)
+
+Like $node->generation, but returns only the nodes in $node's generation
+that are also descendants of NODE2 -- in other words,
+
+    @us = $node->generation_under( $node->mother->mother );
+
+is all $node's first cousins (to borrow yet more kinship terminology) --
+assuming $node does indeed have a grandmother.  Actually "cousins" isn't
+quite an apt word, because C<@us> ends up including $node's siblings and
+$node.
+
+Actually, C<generation_under> is just an alias to C<generation>, but I
+figure that this:
+
+   @us = $node->generation_under($way_upline);
+
+is a bit more readable than this:
+
+   @us = $node->generation($way_upline);
+
+But it's up to you.
+
+$node->generation_under($node) returns just $node.
+
+If you call $node->generation_under($node) but NODE2 is not $node or an
+ancestor of $node, it behaves as if you called just $node->generation().
+
+=cut
+
+sub generation {
+  my($node, $limit) = @_[0,1]; 
+  # $node->no_cyclicity;
+  return $node
+    if $node eq $limit || not(
+			      defined($node->{'mother'}) &&
+			      ref($node->{'mother'})
+			     ); # bailout
+
+  return map(@{$_->{'daughters'}}, $node->{'mother'}->generation($limit));
+    # recurse!
+    # Yup, my generation is just all the daughters of my mom's generation.
+}
+
+sub generation_under {
+  my($node, @rest) = @_; 
+  return $node->generation(@rest);
+}
+
+###########################################################################
+
+=item $node->self_and_sisters
+
+Returns a list of all nodes (going left-to-right) that have the same
+mother as $node -- including $node itself. This is just like
+$node->mother->daughters, except that that fails where $node is root,
+whereas $root->self_and_siblings, as a special case, returns $root.
+
+(Contrary to how you may interpret how this method is named, "self" is
+not (necessarily) the first element of what's returned.)
+
+=cut
+
+sub self_and_sisters {
+  my $node = $_[0];
+  my $mother = $node->{'mother'};
+  return $node unless defined($mother) && ref($mother);  # special case
+  return @{$node->{'mother'}->{'daughters'}};
+}
+
+###########################################################################
+
+=item $node->sisters
+
+Returns a list of all nodes (going left-to-right) that have the same
+mother as $node -- B<not including> $node itself.  If $node is root,
+this returns empty-list.
+
+=cut
+
+sub sisters {
+  my $node = $_[0];
+  my $mother = $node->{'mother'};
+  return() unless $mother;  # special case
+  return grep($_ ne $node,
+              @{$node->{'mother'}->{'daughters'}}
+             );
+}
+
+###########################################################################
+
+=item $node->left_sister
+
+Returns the node that's the immediate left sister of $node.  If $node
+is the leftmost (or only) daughter of its mother (or has no mother),
+then this returns undef.
+
+(See also $node->add_left_sisters(LIST).)
+
+=cut
+
+sub left_sister {
+  my $it = $_[0];
+  my $mother = $it->{'mother'};
+  return undef unless $mother;
+  my @sisters = @{$mother->{'daughters'}};
+  
+  return undef if @sisters  == 1; # I'm an only daughter
+
+  my $left = undef;
+  foreach my $one (@sisters) {
+    return $left if $one eq $it;
+    $left = $one;
+  }
+  die "SPORK ERROR 9757: I'm not in my mother's daughter list!?!?";
+}
+
+
+=item $node->left_sisters
+
+Returns a list of nodes that're sisters to the left of $node.  If
+$node is the leftmost (or only) daughter of its mother (or has no
+mother), then this returns an empty list.
+
+(See also $node->add_left_sisters(LIST).)
+
+=cut
+
+sub left_sisters {
+  my $it = $_[0];
+  my $mother = $it->{'mother'};
+  return() unless $mother;
+  my @sisters = @{$mother->{'daughters'}};
+  return() if @sisters  == 1; # I'm an only daughter
+
+  my @out = ();
+  foreach my $one (@sisters) {
+    return @out if $one eq $it;
+    push @out, $one;
+  }
+  die "SPORK ERROR 9767: I'm not in my mother's daughter list!?!?";
+}
+
+=item $node->right_sister
+
+Returns the node that's the immediate right sister of $node.  If $node
+is the rightmost (or only) daughter of its mother (or has no mother),
+then this returns undef.
+
+(See also $node->add_right_sisters(LIST).)
+
+=cut
+
+sub right_sister {
+  my $it = $_[0];
+  my $mother = $it->{'mother'};
+  return undef unless $mother;
+  my @sisters = @{$mother->{'daughters'}};
+  return undef if @sisters  == 1; # I'm an only daughter
+
+  my $seen = 0;
+  foreach my $one (@sisters) {
+    return $one if $seen;
+    $seen = 1 if $one eq $it;
+  }
+  die "SPORK ERROR 9777: I'm not in my mother's daughter list!?!?"
+    unless $seen;
+  return undef;
+}
+
+=item $node->right_sisters
+
+Returns a list of nodes that're sisters to the right of $node. If
+$node is the rightmost (or only) daughter of its mother (or has no
+mother), then this returns an empty list.
+
+(See also $node->add_right_sisters(LIST).)
+
+=cut
+
+sub right_sisters {
+  my $it = $_[0];
+  my $mother = $it->{'mother'};
+  return() unless $mother;
+  my @sisters = @{$mother->{'daughters'}};
+  return() if @sisters  == 1; # I'm an only daughter
+
+  my @out;
+  my $seen = 0;
+  foreach my $one (@sisters) {
+    push @out, $one if $seen;
+    $seen = 1 if $one eq $it;
+  }
+  die "SPORK ERROR 9787: I'm not in my mother's daughter list!?!?"
+    unless $seen;
+  return @out;
+}
+
+###########################################################################
+
+=item $node->my_daughter_index
+
+Returns what index this daughter is, in its mother's C<daughter> list.
+In other words, if $node is ($node->mother->daughters)[3], then
+$node->my_daughter_index returns 3.
+
+As a special case, returns 0 if $node has no mother.
+
+=cut
+
+sub my_daughter_index {
+  # returns what number is my index in my mother's daughter list
+  # special case: 0 for root.
+  my $node = $_[0];
+  my $ord = -1;
+  my $mother = $node->{'mother'};
+
+  return 0 unless $mother;
+  my @sisters = @{$mother->{'daughters'}};
+
+  die "SPORK ERROR 6512:  My mother has no kids!!!" unless @sisters;
+
+ Find_Self:
+  for(my $i = 0; $i < @sisters; $i++) {
+    if($sisters[$i] eq $node) {
+      $ord = $i;
+      last Find_Self;
+    }
+  }
+  die "SPORK ERROR 2837: I'm not a daughter of my mother?!?!" if $ord == -1;
+  return $ord;
+}
+
+###########################################################################
+
+=item $node->address or $anynode->address(ADDRESS)
+
+With the first syntax, returns the address of $node within its tree,
+based on its position within the tree.  An address is formed by noting
+the path between the root and $node, and concatenating the
+daughter-indices of the nodes this passes thru (starting with 0 for
+the root, and ending with $node).
+
+For example, if to get from node ROOT to node $node, you pass thru
+ROOT, A, B, and $node, then the address is determined as:
+
+* ROOT's my_daughter_index is 0.
+
+* A's my_daughter_index is, suppose, 2. (A is index 2 in ROOT's
+daughter list.)
+
+* B's my_daughter_index is, suppose, 0. (B is index 0 in A's
+daughter list.)
+
+* $node's my_daughter_index is, suppose, 4. ($node is index 4 in
+B's daughter list.)
+
+The address of the above-described $node is, therefore, "0:2:0:4".
+
+(As a somewhat special case, the address of the root is always "0";
+and since addresses start from the root, all addresses start with a
+"0".)
+
+The second syntax, where you provide an address, starts from the root
+of the tree $anynode belongs to, and returns the node corresponding to
+that address.  Returns undef if no node corresponds to that address.
+Note that this routine may be somewhat liberal in its interpretation
+of what can constitute an address; i.e., it accepts "0.2.0.4", besides
+"0:2:0:4".
+
+Also note that the address of a node in a tree is meaningful only in
+that tree as currently structured.
+
+(Consider how ($address1 cmp $address2) may be magically meaningful
+to you, if you mant to figure out what nodes are to the right of what
+other nodes.)
+
+=cut
+
+sub address {
+  my($it, $address) = @_[0,1];
+  if(defined($address) && length($address)) { # given the address, return the node.
+    # invalid addresses return undef
+    my $root = $it->root;
+    my @parts = map {$_ + 0}
+                    $address =~ m/(\d+)/g; # generous!
+    Carp::croak "Address \"$address\" is an ill-formed address" unless @parts;
+    Carp::croak "Address \"$address\" must start with '0'" unless shift(@parts) == 0;
+
+    my $current_node = $root;
+    while(@parts) { # no-op for root
+      my $ord = shift @parts;
+      my @daughters = @{$current_node->{'daughters'}};
+
+      if($#daughters < $ord) { # illegal address
+        print "* $address has an out-of-range index ($ord)!" if $Debug;
+        return undef;
+      }
+      $current_node = $daughters[$ord];
+      unless(ref($current_node)) {
+        print "* $address points to or thru a non-node!" if $Debug;
+        return undef;
+      }
+    }
+    return $current_node;
+
+  } else { # given the node, return the address
+    my @parts = ();
+    my $current_node = $it;
+    my $mother;
+
+    while(defined( $mother = $current_node->{'mother'} ) && ref($mother)) {
+      unshift @parts, $current_node->my_daughter_index;
+      $current_node = $mother;
+    }
+    return join(':', 0, @parts);
+  }
+}
+
+###########################################################################
+
+=item $node->common(LIST)
+
+Returns the lowest node in the tree that is ancestor-or-self to the
+nodes $node and LIST.
+
+If the nodes are far enough apart in the tree, the answer is just the
+root.
+
+If the nodes aren't all in the same tree, the answer is undef.
+
+As a degenerate case, if LIST is empty, returns $node.
+
+=cut
+
+sub common { # Return the lowest node common to all these nodes...
+  # Called as $it->common($other) or $it->common(@others)
+  my @ones = @_; # all nodes I was given
+  my($first, @others) = @_;
+
+  return $first unless @others; # degenerate case
+
+  my %ones;
+  @ones{ @ones } = undef;
+
+  foreach my $node (@others) {
+    Carp::croak "TILT: node \"$node\" is not a node"
+      unless UNIVERSAL::can($node, 'is_node');
+    my %first_lineage;
+    @first_lineage{$first, $first->ancestors} = undef;
+    my $higher = undef; # the common of $first and $node
+    my @my_lineage = $node->ancestors;
+
+   Find_Common:
+    while(@my_lineage) {
+      if(exists $first_lineage{$my_lineage[0]}) {
+        $higher = $my_lineage[0];
+        last Find_Common;
+      }
+      shift @my_lineage;
+    }
+    return undef unless $higher;
+    $first = $higher;
+  } 
+  return $first;
+}
+
+
+###########################################################################
+
+=item $node->common_ancestor(LIST)
+
+Returns the lowest node that is ancestor to all the nodes given (in
+nodes $node and LIST).  In other words, it answers the question: "What
+node in the tree, as low as possible, is ancestor to the nodes given
+($node and LIST)?"
+
+If the nodes are far enough apart, the answer is just the root --
+except if any of the nodes are the root itself, in which case the
+answer is undef (since the root has no ancestor).
+
+If the nodes aren't all in the same tree, the answer is undef.
+
+As a degenerate case, if LIST is empty, returns $node's mother;
+that'll be undef if $node is root.
+
+=cut
+
+sub common_ancestor {
+  my @ones = @_; # all nodes I was given
+  my($first, @others) = @_;
+
+  return $first->{'mother'} unless @others;
+    # which may be undef if $first is the root!
+
+  my %ones;
+  @ones{ @ones } = undef; # my arguments
+
+  my $common = $first->common(@others);
+  if(exists($ones{$common})) { # if the common is one of my nodes...
+    return $common->{'mother'};
+    # and this might be undef, if $common is root!
+  } else {
+    return $common;
+    # which might be null if that's all common came up with
+  }
+}
+
+###########################################################################
+###########################################################################
+
+=back
+
+=head1 YET MORE METHODS
+
+=over
+
+=item $node->walk_down({ callback => \&foo, callbackback => \&foo, ... })
+
+Performs a depth-first traversal of the structure at and under $node.
+What it does at each node depends on the value of the options hashref,
+which you must provide.  There are three options, "callback" and
+"callbackback" (at least one of which must be defined, as a sub
+reference), and "_depth".  This is what C<walk_down> does, in
+pseudocode form:
+
+* Start at the $node given.
+
+* If there's a C<callback>, call it with $node as the first argument,
+and the options hashref as the second argument (which contains the
+potentially useful C<_depth>, remember).  This function must return
+true or false -- if false, it will block the next step:
+
+* If $node has any daughter nodes, increment C<_depth>, and call
+$daughter->walk_down(options_hashref) for each daughter (in order, of
+course), where options_hashref is the same hashref it was called with.
+When this returns, decrements C<_depth>.
+
+* If there's a C<callbackback>, call just it as with C<callback> (but
+tossing out the return value).  Note that C<callback> returning false
+blocks traversal below $node, but doesn't block calling callbackback
+for $node.  (Incidentally, in the unlikely case that $node has stopped
+being a node object, C<callbackback> won't get called.)
+
+* Return.
+
+$node->walk_down is the way to recursively do things to a tree (if you
+start at the root) or part of a tree; if what you're doing is best done
+via pre-pre order traversal, use C<callback>; if what you're doing is
+best done with post-order traversal, use C<callbackback>.
+C<walk_down> is even the basis for plenty of the methods in this
+class.  See the source code for examples both simple and horrific.
+
+Note that if you don't specify C<_depth>, it effectively defaults to
+0.  You should set it to scalar($node->ancestors) if you want
+C<_depth> to reflect the true depth-in-the-tree for the nodes called,
+instead of just the depth below $node.  (If $node is the root, there's
+difference, of course.)
+
+And B<by the way>, it's a bad idea to modify the tree from the callback.
+Unpredictable things may happen.  I instead suggest having your callback
+add to a stack of things that need changing, and then, once C<walk_down>
+is all finished, changing those nodes from that stack.
+
+Note that the existence of C<walk_down> doesn't mean you can't write
+you own special-use traversers.
+
+=cut
+
+sub walk_down {
+  my($this, $o) = @_[0,1];
+
+  # All the can()s are in case an object changes class while I'm
+  # looking at it.
+
+  Carp::croak "I need options!" unless ref($o);
+  Carp::croak "I need a callback or a callbackback" unless
+    ( ref($o->{'callback'}) || ref($o->{'callbackback'}) );
+
+  # $this->no_cyclicity;
+  my $callback = ref($o->{'callback'}) ? $o->{'callback'} : undef;
+  my $callbackback = ref($o->{'callbackback'}) ? $o->{'callbackback'} : undef;
+  my $callback_status = 1;
+
+  print "Callback: $callback   Callbackback: $callbackback\n" if $Debug;
+
+  printf "* Entering %s\n", ($this->name || $this) if $Debug;
+  $callback_status = &{ $callback }( $this, $o ) if $callback;
+
+  if($callback_status) {
+    # Keep recursing unless callback returned false... and if there's
+    # anything to recurse into, of course.
+    my @daughters = UNIVERSAL::can($this, 'is_node') ? @{$this->{'daughters'}} : ();
+    if(@daughters) {
+      $o->{'_depth'} += 1;
+      #print "Depth " , $o->{'_depth'}, "\n";
+      foreach my $one (@daughters) {
+        $one->walk_down($o) if UNIVERSAL::can($one, 'is_node');
+        # and if it can do "is_node", it should provide a walk_down!
+      }
+      $o->{'_depth'} -= 1;
+    }
+  } else {
+    printf "* Recursing below %s pruned\n", ($this->name || $this) if $Debug;
+  }
+
+  # Note that $callback_status doesn't block callbackback from being called
+  if($callbackback){
+    if(UNIVERSAL::can($this, 'is_node')) { # if it's still a node!
+      print "* Calling callbackback\n" if $Debug;
+      scalar( &{ $callbackback }( $this, $o ) );
+      # scalar to give it the same context as callback
+    } else {
+      print "* Can't call callbackback -- $this isn't a node anymore\n"
+        if $Debug;
+    }
+  }
+  if($Debug) {
+    if(UNIVERSAL::can($this, 'is_node')) { # if it's still a node!
+      printf "* Leaving %s\n", ($this->name || $this)
+    } else {
+      print "* Leaving [no longer a node]\n";
+    }
+  }
+  return;
+}
+
+###########################################################################
+
+=item @lines = $node->dump_names({ ...options... });
+
+Dumps, as an indented list, the names of the nodes starting at $node,
+and continuing under it.  Options are:
+
+* _depth -- A nonnegative number.  Indicating the depth to consider
+$node as being at (and so the generation under that is that plus one,
+etc.).  Defaults to 0.  You may choose to use set _depth =>
+scalar($node->ancestors).
+
+* tick -- a string to preface each entry with, between the
+indenting-spacing and the node's name.  Defaults to empty-string.  You
+may prefer "*" or "-> " or someting.
+
+* indent -- the string used to indent with.  Defaults to "  " (two
+spaces).  Another sane value might be ". " (period, space).  Setting it
+to empty-string suppresses indenting.
+
+The dump is not printed, but is returned as a list, where each
+item is a line, with a "\n" at the end.
+
+=cut
+
+sub dump_names {
+  my($it, $o) = @_[0,1];
+  $o = {} unless ref $o;
+  my @out = ();
+  $o->{'_depth'} ||= 0;
+  $o->{'indent'} ||= '  ';
+  $o->{'tick'} ||= '';
+
+  $o->{'callback'} = sub {
+      my($this, $o) = @_[0,1];
+      push(@out,
+        join('',
+             $o->{'indent'} x $o->{'_depth'},
+             $o->{'tick'},
+             &Tree::DAG_Node::_dump_quote($this->name || $this),
+             "\n"
+        )
+      );      
+      return 1;
+    }
+  ;
+  $it->walk_down($o);
+  return @out;
+}
+
+###########################################################################
+###########################################################################
+
+=item the constructor CLASS->random_network({...options...})
+
+=item the method $node->random_network({...options...})
+
+In the first case, constructs a randomly arranged network under a new
+node, and returns the root node of that tree.  In the latter case,
+constructs the network under $node.
+
+Currently, this is implemented a bit half-heartedly, and
+half-wittedly.  I basically needed to make up random-looking networks
+to stress-test the various tree-dumper methods, and so wrote this.  If
+you actually want to rely on this for any application more
+serious than that, I suggest examining the source code and seeing if
+this does really what you need (say, in reliability of randomness);
+and feel totally free to suggest changes to me (especially in the form
+of "I rewrote C<random_network>, here's the code...")
+
+It takes four options:
+
+* max_node_count -- maximum number of nodes this tree will be allowed
+to have (counting the root).  Defaults to 25.
+
+* min_depth -- minimum depth for the tree.  Defaults to 2.  Leaves can
+be generated only after this depth is reached, so the tree will be at
+least this deep -- unless max_node_count is hit first.
+
+* max_depth -- maximum depth for the tree.  Defaults to 3 plus
+min_depth.  The tree will not be deeper than this.
+
+* max_children -- maximum number of children any mother in the tree
+can have.  Defaults to 4.
+
+=cut
+
+sub random_network { # constructor or method.
+  my $class = $_[0];
+  my $o = ref($_[1]) ? $_[1] : {};
+  my $am_cons = 0;
+  my $root;
+
+  if(ref($class)){ # I'm a method.
+    $root = $_[0]; # build under the given node, from same class.
+    $class = ref $class;
+    $am_cons = 0;
+  } else { # I'm a constructor
+    $root = $class->new; # build under a new node, with class named.
+    $root->name("Root");
+    $am_cons = 1;
+  }
+
+  my $min_depth = $o->{'min_depth'} || 2;
+  my $max_depth = $o->{'max_depth'} || ($min_depth + 3);
+  my $max_children = $o->{'max_children'} || 4;
+  my $max_node_count = $o->{'max_node_count'} || 25;
+
+  Carp::croak "max_children has to be positive" if int($max_children) < 1;
+
+  my @mothers = ( $root );
+  my @children = ( );
+  my $node_count = 1; # the root
+
+ Gen:
+  foreach my $depth (1 .. $max_depth) {
+    last if $node_count > $max_node_count;
+   Mother:
+    foreach my $mother (@mothers) {
+      last Gen if $node_count > $max_node_count;
+      my $children_number;    
+      if($depth <= $min_depth) {
+        until( $children_number = int(rand(1 + $max_children)) ) {}
+      } else {
+        $children_number = int(rand($max_children));
+      }
+     Beget:
+      foreach (1 .. $children_number) {
+        last Gen if $node_count > $max_node_count;
+        my $node = $mother->new_daughter;
+        $node->name("Node$node_count");
+        ++$node_count;
+        push(@children, $node);
+      }
+    }
+    @mothers = @children;
+    @children = ();
+    last unless @mothers;
+  }
+
+  return $root;
+}
+
+=item the constructor CLASS->lol_to_tree($lol);
+
+Converts something like bracket-notation for "Chomsky trees" (or
+rather, the closest you can come with Perl
+list-of-lists(-of-lists(-of-lists))) into a tree structure.  Returns
+the root of the tree converted.
+
+The conversion rules are that:  1) if the last (possibly the only) item
+in a given list is a scalar, then that is used as the "name" attribute
+for the node based on this list.  2) All other items in the list
+represent daughter nodes of the current node -- recursively so, if
+they are list references; otherwise, (non-terminal) scalars are
+considered to denote nodes with that name.  So ['Foo', 'Bar', 'N'] is
+an alternate way to represent [['Foo'], ['Bar'], 'N'].
+
+An example will illustrate:
+
+  use Tree::DAG_Node;
+  $lol =
+    [
+      [
+        [ [ 'Det:The' ],
+          [ [ 'dog' ], 'N'], 'NP'],
+        [ '/with rabies\\', 'PP'],
+        'NP'
+      ],
+      [ 'died', 'VP'],
+      'S'
+    ];
+   $tree = Tree::DAG_Node->lol_to_tree($lol);
+   $diagram = $tree->draw_ascii_tree;
+   print map "$_\n", @$diagram;
+
+...returns this tree:
+
+                   |                   
+                  <S>                  
+                   |                   
+                /------------------\   
+                |                  |   
+              <NP>                <VP> 
+                |                  |   
+        /---------------\        <died>
+        |               |              
+      <NP>            <PP>             
+        |               |              
+     /-------\   </with rabies\>       
+     |       |                         
+ <Det:The>  <N>                        
+             |                         
+           <dog>                       
+
+By the way (and this rather follows from the above rules), when
+denoting a LoL tree consisting of just one node, this:
+
+  $tree = Tree::DAG_Node->lol_to_tree( 'Lonely' );
+
+is okay, although it'd probably occur to you to denote it only as:
+
+  $tree = Tree::DAG_Node->lol_to_tree( ['Lonely'] );
+
+which is of course fine, too.
+
+=cut
+
+sub lol_to_tree {
+  my($class, $lol, $seen_r) = @_[0,1,2];
+  $seen_r = {} unless ref($seen_r) eq 'HASH';
+  return if ref($lol) && $seen_r->{$lol}++; # catch circularity
+
+  $class = ref($class) || $class;
+  my $node = $class->new();
+
+  unless(ref($lol) eq 'ARRAY') {  # It's a terminal node.
+    $node->name($lol) if defined $lol;
+    return $node;
+  }
+  return $node unless @$lol;  # It's a terminal node, oddly represented
+
+  #  It's a non-terminal node.
+
+  my @options = @$lol; 
+  unless(ref($options[-1]) eq 'ARRAY') {
+    # This is what separates this method from simple_lol_to_tree
+    $node->name(pop(@options));
+  }
+
+  foreach my $d (@options) {  # Scan daughters (whether scalars or listrefs)
+    $node->add_daughter( $class->lol_to_tree($d, $seen_r) );  # recurse!
+  }
+
+  return $node;
+}
+
+#--------------------------------------------------------------------------
+
+=item $node->tree_to_lol_notation({...options...})
+
+Dumps a tree (starting at $node) as the sort of LoL-like bracket
+notation you see in the above example code.  Returns just one big
+block of text.  The only option is "multiline" -- if true, it dumps
+the text as the sort of indented structure as seen above; if false
+(and it defaults to false), dumps it all on one line (with no
+indenting, of course).
+
+For example, starting with the tree from the above example,
+this:
+
+  print $tree->tree_to_lol_notation, "\n";
+
+prints the following (which I've broken over two lines for sake of
+printablitity of documentation):
+
+  [[[['Det:The'], [['dog'], 'N'], 'NP'], [["/with rabies\x5c"],
+  'PP'], 'NP'], [['died'], 'VP'], 'S'], 
+
+Doing this:
+
+  print $tree->tree_to_lol_notation({ multiline => 1 });
+
+prints the same content, just spread over many lines, and prettily
+indented.
+
+=cut
+
+#--------------------------------------------------------------------------
+
+sub tree_to_lol_notation {
+  my $root = $_[0];
+  my($it, $o) = @_[0,1];
+  $o = {} unless ref $o;
+  my @out = ();
+  $o->{'_depth'} ||= 0;
+  $o->{'multiline'} = 0 unless exists($o->{'multiline'});
+
+  my $line_end;
+  if($o->{'multiline'}) {
+    $o->{'indent'} ||= '  ';
+    $line_end = "\n";
+  } else {
+    $o->{'indent'} ||= '';
+    $line_end = '';
+  }
+
+  $o->{'callback'} = sub {
+      my($this, $o) = @_[0,1];
+      push(@out,
+             $o->{'indent'} x $o->{'_depth'},
+             "[$line_end",
+      );      
+      return 1;
+    }
+  ;
+  $o->{'callbackback'} = sub {
+      my($this, $o) = @_[0,1];
+      my $name = $this->name;
+      if(!defined($name)) {
+        $name = 'undef';
+      } else {
+        $name = &Tree::DAG_Node::_dump_quote($name);
+      }
+      push(@out,
+             $o->{'indent'} x ($o->{'_depth'} + 1),
+             "$name$line_end",
+             $o->{'indent'} x $o->{'_depth'},
+             "], $line_end",
+      );
+      return 1;
+    }
+  ;
+  $it->walk_down($o);
+  return join('', @out);
+}
+
+#--------------------------------------------------------------------------
+
+=item $node->tree_to_lol
+
+Returns that tree (starting at $node) represented as a LoL, like what
+$lol, above, holds.  (This is as opposed to C<tree_to_lol_notation>,
+which returns the viewable code like what gets evaluated and stored in
+$lol, above.)
+
+Lord only knows what you use this for -- maybe for feeding to
+Data::Dumper, in case C<tree_to_lol_notation> doesn't do just what you
+want?
+
+=cut
+
+sub tree_to_lol {
+  # I haven't /rigorously/ tested this.
+  my($it, $o) = @_[0,1]; # $o is currently unused anyway
+  $o = {} unless ref $o;
+
+  my $out = [];
+  my @lol_stack = ($out);
+  $o->{'callback'} = sub {
+      my($this, $o) = @_[0,1];
+      my $new = [];
+      push @{$lol_stack[-1]}, $new;
+      push(@lol_stack, $new);
+      return 1;
+    }
+  ;
+  $o->{'callbackback'} = sub {
+      my($this, $o) = @_[0,1];
+      push @{$lol_stack[-1]}, $this->name;
+      pop @lol_stack;
+      return 1;
+    }
+  ;
+  $it->walk_down($o);
+  die "totally bizarre error 12416" unless ref($out->[0]);
+  $out = $out->[0]; # the real root
+  return $out;
+}
+
+###########################################################################
+
+=item the constructor CLASS->simple_lol_to_tree($simple_lol);
+
+This is like lol_to_tree, except that rule 1 doesn't apply -- i.e.,
+all scalars (or really, anything not a listref) in the LoL-structure
+end up as named terminal nodes, and only terminal nodes get names
+(and, of course, that name comes from that scalar value).  This method
+is useful for making things like expression trees, or at least
+starting them off.  Consider that this:
+
+    $tree = Tree::DAG_Node->simple_lol_to_tree(
+      [ 'foo', ['bar', ['baz'], 'quux'], 'zaz', 'pati' ]
+    );
+
+converts from something like a Lispish or Iconish tree, if you pretend
+the brackets are parentheses.
+
+Note that there is a (possibly surprising) degenerate case of what I'm
+calling a "simple-LoL", and it's like this:
+
+  $tree = Tree::DAG_Node->simple_lol_to_tree('Lonely');
+
+This is the (only) way you can specify a tree consisting of only a
+single node, which here gets the name 'Lonely'.
+
+=cut
+
+sub simple_lol_to_tree {
+  my($class, $lol, $seen_r) = @_[0,1,2];
+  $class = ref($class) || $class;
+  $seen_r = {} unless ref($seen_r) eq 'HASH';
+  return if ref($lol) && $seen_r->{$lol}++; # catch circularity
+
+  my $node = $class->new();
+
+  unless(ref($lol) eq 'ARRAY') {  # It's a terminal node.
+    $node->name($lol) if defined $lol;
+    return $node;
+  }
+
+  #  It's a non-terminal node.
+  foreach my $d (@$lol) { # scan daughters (whether scalars or listrefs)
+    $node->add_daughter( $class->simple_lol_to_tree($d, $seen_r) );  # recurse!
+  }
+
+  return $node;
+}
+
+#--------------------------------------------------------------------------
+
+=item $node->tree_to_simple_lol
+
+Returns that tree (starting at $node) represented as a simple-LoL --
+i.e., one where non-terminal nodes are represented as listrefs, and
+terminal nodes are gotten from the contents of those nodes' "name'
+attributes.
+
+Note that in the case of $node being terminal, what you get back is
+the same as $node->name.
+
+Compare to tree_to_simple_lol_notation.
+
+=cut
+
+sub tree_to_simple_lol {
+  # I haven't /rigorously/ tested this.
+  my $root = $_[0];
+
+  return $root->name unless scalar($root->daughters);
+   # special case we have to nip in the bud
+
+  my($it, $o) = @_[0,1]; # $o is currently unused anyway
+  $o = {} unless ref $o;
+
+  my $out = [];
+  my @lol_stack = ($out);
+  $o->{'callback'} = sub {
+      my($this, $o) = @_[0,1];
+      my $new;
+      $new = scalar($this->daughters) ? [] : $this->name;
+        # Terminal nodes are scalars, the rest are listrefs we'll fill in
+        # as we recurse the tree below here.
+      push @{$lol_stack[-1]}, $new;
+      push(@lol_stack, $new);
+      return 1;
+    }
+  ;
+  $o->{'callbackback'} = sub { pop @lol_stack; return 1; };
+  $it->walk_down($o);
+  die "totally bizarre error 12416" unless ref($out->[0]);
+  $out = $out->[0]; # the real root
+  return $out;
+}
+
+#--------------------------------------------------------------------------
+
+=item $node->tree_to_simple_lol_notation({...options...})
+
+A simple-LoL version of tree_to_lol_notation (which see); takes the
+same options.
+
+=cut
+
+sub tree_to_simple_lol_notation {
+  my($it, $o) = @_[0,1];
+  $o = {} unless ref $o;
+  my @out = ();
+  $o->{'_depth'} ||= 0;
+  $o->{'multiline'} = 0 unless exists($o->{'multiline'});
+
+  my $line_end;
+  if($o->{'multiline'}) {
+    $o->{'indent'} ||= '  ';
+    $line_end = "\n";
+  } else {
+    $o->{'indent'} ||= '';
+    $line_end = '';
+  }
+
+  $o->{'callback'} = sub {
+      my($this, $o) = @_[0,1];
+      if(scalar($this->daughters)) {   # Nonterminal
+        push(@out,
+               $o->{'indent'} x $o->{'_depth'},
+               "[$line_end",
+        );
+      } else {   # Terminal
+        my $name = $this->name;
+        push @out,
+          $o->{'indent'} x $o->{'_depth'},
+          defined($name) ? &Tree::DAG_Node::_dump_quote($name) : 'undef',
+          ",$line_end";
+      }
+      return 1;
+    }
+  ;
+  $o->{'callbackback'} = sub {
+      my($this, $o) = @_[0,1];
+      push(@out,
+             $o->{'indent'} x $o->{'_depth'},
+             "], $line_end",
+      ) if scalar($this->daughters);
+      return 1;
+    }
+  ;
+
+  $it->walk_down($o);
+  return join('', @out);
+}
+
+###########################################################################
+#  $list_r = $root_node->draw_ascii_tree({ h_compact => 1});
+#  print map("$_\n", @$list_r);
+
+=item $list_r = $node->draw_ascii_tree({ ... options ... })
+
+Draws a nice ASCII-art representation of the tree structure
+at-and-under $node, with $node at the top.  Returns a reference to the
+list of lines (with no "\n"s or anything at the end of them) that make
+up the picture.
+
+Example usage:
+
+  print map("$_\n", @{$tree->draw_ascii_tree});
+
+draw_ascii_tree takes parameters you set in the options hashref:
+
+* "no_name" -- if true, C<draw_ascii_tree> doesn't print the name of
+the node; simply prints a "*".  Defaults to 0 (i.e., print the node
+name.)
+
+* "h_spacing" -- number 0 or greater.  Sets the number of spaces
+inserted horizontally between nodes (and groups of nodes) in a tree.
+Defaults to 1.
+
+* "h_compact" -- number 0 or 1.  Sets the extent to which
+C<draw_ascii_tree> tries to save horizontal space.  Defaults to 1.  If
+I think of a better scrunching algorithm, there'll be a "2" setting
+for this.
+
+* "v_compact" -- number 0, 1, or 2.  Sets the degree to which
+C<draw_ascii_tree> tries to save vertical space.  Defaults to 1.
+
+This occasionally returns trees that are a bit cock-eyed in parts; if
+anyone can suggest a better drawing algorithm, I'd be appreciative.
+
+=cut
+
+sub draw_ascii_tree {
+  # Make a "box" for this node and its possible daughters, recursively.
+
+  # The guts of this routine are horrific AND recursive!
+
+  # Feel free to send me better code.  I worked on this until it
+  #  gave me a headache and it worked passably, and then I stopped.
+
+  my $it = $_[0];
+  my $o = ref($_[1]) ? $_[1] : {};
+  my(@box, @daughter_boxes, $width, @daughters);
+  @daughters = @{$it->{'daughters'}};
+
+  # $it->no_cyclicity;
+
+  $o->{'no_name'}   = 0 unless exists $o->{'no_name'};
+  $o->{'h_spacing'} = 1 unless exists $o->{'h_spacing'};
+  $o->{'h_compact'} = 1 unless exists $o->{'h_compact'};
+  $o->{'v_compact'} = 1 unless exists $o->{'v_compact'};
+
+  my $printable_name;
+  if($o->{'no_name'}) {
+    $printable_name = '*';
+  } else {
+    $printable_name = $it->name || $it;
+    $printable_name =~ tr<\cm\cj\t >< >s;
+    $printable_name = "<$printable_name>";
+  }
+
+  if(!scalar(@daughters)) { # I am a leaf!
+    # Now add the top parts, and return.
+    @box = ("|", $printable_name);
+  } else {
+    @daughter_boxes = map { &draw_ascii_tree($_, $o) } @daughters;
+
+    my $max_height = 0;
+    foreach my $box (@daughter_boxes) {
+      my $h = @$box;
+      $max_height = $h if $h > $max_height;
+    }
+
+    @box = ('') x $max_height; # establish the list
+
+    foreach my $one (@daughter_boxes) {
+      my $length = length($one->[0]);
+      my $height = @$one;
+
+      #now make all the same height.
+      my $deficit = $max_height - $height;
+      if($deficit > 0) {
+        push @$one, ( scalar( ' ' x $length ) ) x $deficit;
+        $height = scalar(@$one);
+      }
+
+
+      # Now tack 'em onto @box
+      ##########################################################
+      # This used to be a sub of its own.  Ho-hum.
+
+      my($b1, $b2) = (\@box, $one);
+      my($h1, $h2) = (scalar(@$b1), scalar(@$b2));
+
+      my(@diffs, $to_chop);
+      if($o->{'h_compact'}) { # Try for h-scrunching.
+        my @diffs;
+        my $min_diff = length($b1->[0]); # just for starters
+        foreach my $line (0 .. ($h1 - 1)) {
+          my $size_l = 0; # length of terminal whitespace
+          my $size_r = 0; # length of initial whitespace
+          $size_l = length($1) if $b1->[$line] =~ /( +)$/s;
+          $size_r = length($1) if $b2->[$line] =~ /^( +)/s;
+          my $sum = $size_l + $size_r;
+      
+          $min_diff = $sum if $sum < $min_diff;
+          push @diffs, [$sum, $size_l, $size_r];
+        }
+        $to_chop = $min_diff - $o->{'h_spacing'};
+        $to_chop = 0 if $to_chop < 0;
+      }
+
+      if(not(  $o->{'h_compact'} and $to_chop  )) {
+        # No H-scrunching needed/possible
+        foreach my $line (0 .. ($h1 - 1)) {
+          $b1->[ $line ] .= $b2->[ $line ] . (' ' x $o->{'h_spacing'});
+        }
+      } else {
+        # H-scrunching is called for.
+        foreach my $line (0 .. ($h1 - 1)) {
+          my $r = $b2->[$line]; # will be the new line
+          my $remaining = $to_chop;
+          if($remaining) {
+            my($l_chop, $r_chop) = @{$diffs[$line]}[1,2];
+      
+            if($l_chop) {
+              if($l_chop > $remaining) {
+                $l_chop = $remaining;
+                $remaining = 0;
+              } elsif($l_chop == $remaining) {
+                $remaining = 0;
+              } else { # remaining > l_chop
+                $remaining -= $l_chop;
+              }
+            }
+            if($r_chop) {
+              if($r_chop > $remaining) { 
+                $r_chop = $remaining;
+                $remaining = 0;
+              } elsif($r_chop == $remaining) {
+                $remaining = 0;
+              } else { # remaining > r_chop
+                $remaining -= $r_chop; # should never happen!
+              }
+            }
+
+            substr($b1->[$line], -$l_chop) = '' if $l_chop;
+            substr($r, 0, $r_chop) = '' if $r_chop;
+          } # else no-op
+          $b1->[ $line ] .= $r . (' ' x $o->{'h_spacing'});
+        }
+         # End of H-scrunching ickyness
+      }
+       # End of ye big tack-on
+
+    }
+     # End of the foreach daughter_box loop
+
+    # remove any fencepost h_spacing
+    if($o->{'h_spacing'}) {
+      foreach my $line (@box) {
+        substr($line, -$o->{'h_spacing'}) = '' if length($line);
+      }
+    }
+
+    # end of catenation
+    die "SPORK ERROR 958203: Freak!!!!!" unless @box;
+
+    # Now tweak the pipes
+    my $new_pipes = $box[0];
+    my $pipe_count = $new_pipes =~ tr<|><+>;
+    if($pipe_count < 2) {
+      $new_pipes = "|";
+    } else {
+      my($init_space, $end_space);
+
+      # Thanks to Gilles Lamiral for pointing out the need to set to '',
+      #  to avoid -w warnings about undeffiness.
+
+      if( $new_pipes =~ s<^( +)><>s ) {
+        $init_space = $1;
+      } else {
+        $init_space = '';
+      }
+
+      if( $new_pipes =~ s<( +)$><>s ) {
+        $end_space  = $1
+      } else {
+        $end_space = '';
+      }
+
+      $new_pipes =~ tr< ><->;
+      substr($new_pipes,0,1) = "/";
+      substr($new_pipes,-1,1) = "\\";
+
+      $new_pipes = $init_space . $new_pipes . $end_space;
+      # substr($new_pipes, int((length($new_pipes)), 1)) / 2) = "^"; # feh
+    }
+
+    # Now tack on the formatting for this node.
+    if($o->{'v_compact'} == 2) {
+      if(@daughters == 1) {
+        unshift @box, "|", $printable_name;
+      } else {
+        unshift @box, "|", $printable_name, $new_pipes;
+      }
+    } elsif ($o->{'v_compact'} == 1 and @daughters == 1) {
+      unshift @box, "|", $printable_name;
+    } else { # general case
+      unshift @box, "|", $printable_name, $new_pipes;
+    }
+  }
+
+  # Flush the edges:
+  my $max_width = 0;
+  foreach my $line (@box) {
+    my $w = length($line);
+    $max_width = $w if $w > $max_width;
+  }
+  foreach my $one (@box) {
+    my $space_to_add = $max_width - length($one);
+    next unless $space_to_add;
+    my $add_left = int($space_to_add / 2);
+    my $add_right = $space_to_add - $add_left;
+    $one = (' ' x $add_left) . $one . (' ' x $add_right);
+  }
+
+  return \@box; # must not return a null list!
+}
+
+###########################################################################
+
+=item $node->copy_tree or $node->copy_tree({...options...})
+
+This returns the root of a copy of the tree that $node is a member of.
+If you pass no options, copy_tree pretends you've passed {}.
+
+This method is currently implemented as just a call to
+$this->root->copy_at_and_under({...options...}), but magic may be
+added in the future.
+
+Options you specify are passed down to calls to $node->copy.
+
+=cut
+
+sub copy_tree {
+  my($this, $o) = @_[0,1];
+  my $root = $this->root;
+  $o = {} unless ref $o;
+  
+  my $new_root = $root->copy_at_and_under($o);
+  
+  return $new_root;
+}
+
+=item $node->copy_at_and_under or $node->copy_at_and_under({...options...})
+
+This returns a copy of the subtree consisting of $node and everything
+under it.
+
+If you pass no options, copy_at_and_under pretends you've passed {}.
+
+This works by recursively building up the new tree from the leaves,
+duplicating nodes using $orig_node->copy($options_ref) and then
+linking them up into a new tree of the same shape.
+
+Options you specify are passed down to calls to $node->copy.
+
+=cut
+
+sub copy_at_and_under {
+  my($from, $o) = @_[0,1];
+  $o = {} unless ref $o;
+  my @daughters = map($_->copy_at_and_under($o), @{$from->{'daughters'}});
+  my $to = $from->copy($o);
+  $to->set_daughters(@daughters) if @daughters;
+  return $to;
+}
+
+=item the constructor $node->copy or $node->copy({...options...})
+
+Returns a copy of $node, B<minus> its daughter or mother attributes
+(which are set back to default values).
+
+If you pass no options, C<copy> pretends you've passed {}.
+
+Magic happens with the 'attributes' attribute: if it's a hashref (and
+it usually is), the new node doesn't end up with the same hashref, but
+with ref to a hash with the content duplicated from the original's
+hashref.  If 'attributes' is not a hashref, but instead an object that
+belongs to a class that provides a method called "copy", then that
+method is called, and the result saved in the clone's 'attribute'
+attribute.  Both of these kinds of magic are disabled if the options
+you pass to C<copy> (maybe via C<copy_tree>, or C<copy_at_and_under>)
+includes (C<no_attribute_copy> => 1).
+
+The options hashref you pass to C<copy> (derictly or indirectly) gets
+changed slightly after you call C<copy> -- it gets an entry called
+"from_to" added to it.  Chances are you would never know nor care, but
+this is reserved for possible future use.  See the source if you are
+wildly curious.
+
+Note that if you are using $node->copy (whether directly or via
+$node->copy_tree or $node->copy_at_or_under), and it's not properly
+copying object attributes containing references, you probably
+shouldn't fight it or try to fix it -- simply override copy_tree with:
+
+  sub copy_tree {
+    use Storable qw(dclone); 
+    my $this = $_[0];
+    return dclone($this->root);
+     # d for "deep"
+  }
+
+or
+
+  sub copy_tree {
+    use Data::Dumper;
+    my $this = $_[0];
+    $Data::Dumper::Purity = 1;
+    return eval(Dumper($this->root));
+  }
+
+Both of these avoid you having to reinvent the wheel.
+
+How to override copy_at_or_under with something that uses Storable
+or Data::Dumper is left as an exercise to the reader.
+
+Consider that if in a derived class, you add attributes with really
+bizarre contents (like a unique-for-all-time-ID), you may need to
+override C<copy>.  Consider:
+
+  sub copy {
+    my($it, @etc) = @_;
+    $it->SUPER::copy(@etc);
+    $it->{'UID'} = &get_new_UID;
+  }
+
+...or the like.  See the source of Tree::DAG_Node::copy for
+inspiration.
+
+=cut
+
+sub copy {
+  my($from,$o) = @_[0,1];
+  $o = {} unless ref $o;
+
+  # Straight dupe, and bless into same class:
+  my $to = bless { %$from }, ref($from);
+  
+  # Null out linkages.
+  $to->_init_mother;
+  $to->_init_daughters;
+
+  # dupe the 'attributes' attribute:
+  unless($o->{'no_attribute_copy'}) {
+    my $attrib_copy = ref($to->{'attributes'});
+    if($attrib_copy) {
+      if($attrib_copy eq 'HASH') {
+        $to->{'attributes'} = { %{$to->{'attributes'}} };
+        # dupe the hashref
+      } elsif ($attrib_copy = UNIVERSAL::can($to->{'attributes'}, 'copy') ) {
+        # $attrib_copy now points to the copier method
+        $to->{'attributes'} = &{$attrib_copy}($from);
+      } # otherwise I don't know how to copy it; leave as is
+    }
+  }
+  $o->{'from_to'}->{$from} = $to; # SECRET VOODOO
+    # ...autovivifies an anon hashref for 'from_to' if need be
+    # This is here in case I later want/need a table corresponding
+    # old nodes to new.
+  return $to;
+}
+
+
+###########################################################################
+
+=item $node->delete_tree
+
+Destroys the entire tree that $node is a member of (starting at the
+root), by nulling out each node-object's attributes (including, most
+importantly, its linkage attributes -- hopefully this is more than
+sufficient to eliminate all circularity in the data structure), and
+then moving it into the class DEADNODE.
+
+Use this when you're finished with the tree in question, and want to
+free up its memory.  (If you don't do this, it'll get freed up anyway
+when your program ends.)
+
+If you try calling any methods on any of the node objects in the tree
+you've destroyed, you'll get an error like:
+
+  Can't locate object method "leaves_under"
+    via package "DEADNODE".
+
+So if you see that, that's what you've done wrong.  (Actually, the
+class DEADNODE does provide one method: a no-op method "delete_tree".
+So if you want to delete a tree, but think you may have deleted it
+already, it's safe to call $node->delete_tree on it (again).)
+
+The C<delete_tree> method is needed because Perl's garbage collector
+would never (as currently implemented) see that it was time to
+de-allocate the memory the tree uses -- until either you call
+$node->delete_tree, or until the program stops (at "global
+destruction" time, when B<everything> is unallocated).
+
+Incidentally, there are better ways to do garbage-collecting on a
+tree, ways which don't require the user to explicitly call a method
+like C<delete_tree> -- they involve dummy classes, as explained at
+C<http://mox.perl.com/misc/circle-destroy.pod>
+
+However, introducing a dummy class concept into Tree::DAG_Node would
+be rather a distraction.  If you want to do this with your derived
+classes, via a DESTROY in a dummy class (or in a tree-metainformation
+class, maybe), then feel free to.
+
+The only case where I can imagine C<delete_tree> failing to totally
+void the tree, is if you use the hashref in the "attributes" attribute
+to store (presumably among other things) references to other nodes'
+"attributes" hashrefs -- which 1) is maybe a bit odd, and 2) is your
+problem, because it's your hash structure that's circular, not the
+tree's.  Anyway, consider:
+
+      # null out all my "attributes" hashes
+      $anywhere->root->walk_down({
+        'callback' => sub {
+          $hr = $_[0]->attributes; %$hr = (); return 1;
+        }
+      });
+      # And then:
+      $anywhere->delete_tree;
+
+(I suppose C<delete_tree> is a "destructor", or as close as you can
+meaningfully come for a circularity-rich data structure in Perl.)
+
+=cut
+
+sub delete_tree {
+  my $it = $_[0];
+  $it->root->walk_down({ # has to be callbackback, not callback
+    'callbackback' => sub {
+       %{$_[0]} = ();
+       bless($_[0], 'DEADNODE'); # cause become dead!  cause become dead!
+       return 1;
+     }
+  });
+  return;
+  # Why DEADNODE?  Because of the nice error message:
+  #  "Can't locate object method "leaves_under" via package "DEADNODE"."
+  # Moreover, DEADNODE doesn't provide is_node, so fails my can() tests.
+}
+
+sub DEADNODE::delete_tree { return; }
+  # in case you kill it AGAIN!!!!!  AND AGAIN AND AGAIN!!!!!! OO-HAHAHAHA!
+
+###########################################################################
+# stolen from MIDI.pm
+
+sub _dump_quote {
+  my @stuff = @_;
+  return
+    join(", ",
+    map
+     { # the cleaner-upper function
+       if(!length($_)) { # empty string
+         "''";
+       } elsif( m/^-?\d+(?:\.\d+)?$/s ) { # a number
+         $_;
+       } elsif( # text with junk in it
+          s<([^\x20\x21\x23\x27-\x3F\x41-\x5B\x5D-\x7E])>
+           <'\\x'.(unpack("H2",$1))>eg
+         ) {
+         "\"$_\"";
+       } else { # text with no junk in it
+         s<'><\\'>g;
+         "\'$_\'";
+       }
+     }
+     @stuff
+    );
+}
+
+###########################################################################
+
+=back
+
+=head2 When and How to Destroy
+
+It should be clear to you that if you've built a big parse tree or
+something, and then you're finished with it, you should call
+$some_node->delete_tree on it if you want the memory back.
+
+But consider this case:  you've got this tree:
+
+      A
+    / | \
+   B  C  D
+   |     | \
+   E     X  Y
+
+Let's say you decide you don't want D or any of its descendants in the
+tree, so you call D->unlink_from_mother.  This does NOT automagically
+destroy the tree D-X-Y.  Instead it merely splits the tree into two:
+
+     A                        D
+    / \                      / \
+   B   C                    X   Y
+   | 
+   E 
+
+To destroy D and its little tree, you have to explicitly call
+delete_tree on it.
+
+Note, however, that if you call C->unlink_from_mother, and if you don't
+have a link to C anywhere, then it B<does> magically go away.  This is
+because nothing links to C -- whereas with the D-X-Y tree, D links to
+X and Y, and X and Y each link back to D. Note that calling
+C->delete_tree is harmless -- after all, a tree of only one node is
+still a tree.
+
+So, this is a surefire way of getting rid of all $node's children and
+freeing up the memory associated with them and their descendants:
+
+  foreach my $it ($node->clear_daughters) { $it->delete_tree }
+
+Just be sure not to do this:
+
+  foreach my $it ($node->daughters) { $it->delete_tree }
+  $node->clear_daughters;
+
+That's bad; the first call to $_->delete_tree will climb to the root
+of $node's tree, and nuke the whole tree, not just the bits under $node.
+You might as well have just called $node->delete_tree.
+(Moreavor, once $node is dead, you can't call clear_daughters on it,
+so you'll get an error there.)
+
+=head1 BUG REPORTS
+
+If you find a bug in this library, report it to me as soon as possible,
+at the address listed in the MAINTAINER section, below.  Please try to
+be as specific as possible about how you got the bug to occur.
+
+=head1 HELP!
+
+If you develop a given routine for dealing with trees in some way, and
+use it a lot, then if you think it'd be of use to anyone else, do email
+me about it; it might be helpful to others to include that routine, or
+something based on it, in a later version of this module.
+
+It's occurred to me that you might like to (and might yourself develop
+routines to) draw trees in something other than ASCII art.  If you do so
+-- say, for PostScript output, or for output interpretable by some
+external plotting program --  I'd be most interested in the results.
+
+=head1 RAMBLINGS
+
+This module uses "strict", but I never wrote it with -w warnings in
+mind -- so if you use -w, do not be surprised if you see complaints
+from the guts of DAG_Node.  As long as there is no way to turn off -w
+for a given module (instead of having to do it in every single
+subroutine with a "local $^W"), I'm not going to change this. However,
+I do, at points, get bursts of ambition, and I try to fix code in
+DAG_Node that generates warnings, I<as I come across them> -- which is
+only occasionally.  Feel free to email me any patches for any such
+fixes you come up with, tho.
+
+Currently I don't assume (or enforce) anything about the class
+membership of nodes being manipulated, other than by testing whether
+each one provides a method C<is_node>, a la:
+
+  die "Not a node!!!" unless UNIVERSAL::can($node, "is_node");
+
+So, as far as I'm concerned, a given tree's nodes are free to belong to
+different classes, just so long as they provide/inherit C<is_node>, the
+few methods that this class relies on to navigate the tree, and have the
+same internal object structure, or a superset of it. Presumably this
+would be the case for any object belonging to a class derived from
+C<Tree::DAG_Node>, or belonging to C<Tree::DAG_Node> itself.
+
+When routines in this class access a node's "mother" attribute, or its
+"daughters" attribute, they (generally) do so directly (via 
+$node->{'mother'}, etc.), for sake of efficiency.  But classes derived
+from this class should probably do this instead thru a method (via
+$node->mother, etc.), for sake of portability, abstraction, and general
+goodness.
+
+However, no routines in this class (aside from, necessarily, C<_init>,
+C<_init_name>, and C<name>) access the "name" attribute directly;
+routines (like the various tree draw/dump methods) get the "name" value
+thru a call to $obj->name().  So if you want the object's name to not be
+a real attribute, but instead have it derived dynamically from some feature
+of the object (say, based on some of its other attributes, or based on
+its address), you can to override the C<name> method, without causing
+problems.  (Be sure to consider the case of $obj->name as a write
+method, as it's used in C<lol_to_tree> and C<random_network>.)
+
+=head1 SEE ALSO
+
+L<HTML::Element>
+
+Wirth, Niklaus.  1976.  I<Algorithms + Data Structures = Programs>
+Prentice-Hall, Englewood Cliffs, NJ.
+
+Knuth, Donald Ervin.  1997.  I<Art of Computer Programming, Volume 1,
+Third Edition: Fundamental Algorithms>.  Addison-Wesley,  Reading, MA.
+
+Wirth's classic, currently and lamentably out of print, has a good
+section on trees.  I find it clearer than Knuth's (if not quite as
+encyclopedic), probably because Wirth's example code is in a
+block-structured high-level language (basically Pascal), instead
+of in assembler (MIX).
+
+Until some kind publisher brings out a new printing of Wirth's book,
+try poking around used bookstores (or C<www.abebooks.com>) for a copy.
+I think it was also republished in the 1980s under the title
+I<Algorithms and Data Structures>, and in a German edition called
+I<Algorithmen und Datenstrukturen>.  (That is, I'm sure books by Knuth
+were published under those titles, but I'm I<assuming> that they're just
+later printings/editions of I<Algorithms + Data Structures =
+Programs>.)
+
+=head1 MAINTAINER
+
+David Hand, C<< <cogent@cpan.org> >>
+
+=head1 AUTHOR
+
+Sean M. Burke, C<< <sburke@cpan.org> >>
+
+=head1 COPYRIGHT, LICENSE, AND DISCLAIMER
+
+Copyright 1998-2001, 2004, 2007 by Sean M. Burke and David Hand.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+This program is distributed in the hope that it will be useful, but
+without any warranty; without even the implied warranty of
+merchantability or fitness for a particular purpose.
+
+=cut
+
+1;
+
+__END__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tree/Interval.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,741 @@
+package Tree::Interval;
+
+use strict;
+use Carp;
+
+use Tree::Interval::Node qw[set_color color_of parent_of left_of right_of];
+use Tree::Interval::Node::Constants;
+use Tree::DAG_Node;
+use vars qw( $VERSION @EXPORT_OK );
+$VERSION = 0.1;
+
+require Exporter;
+*import    = \&Exporter::import;
+@EXPORT_OK = qw[LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV];
+
+use enum qw{ LUEQUAL  LUGTEQ  LULTEQ LUGREAT LULESS LUNEXT LUPREV };
+
+# object slots
+use enum qw{ ROOT CMP SIZE };
+
+sub new {
+    my ($class, $cmp) = @_;
+    my $obj = [];
+    $obj->[SIZE] = 0;
+    if($cmp) {
+        ref $cmp eq 'CODE'
+          or croak('Invalid arg: codref expected');
+        $obj->[CMP] = $cmp;
+    }
+	else {
+		# default compare
+		$obj->[CMP] = sub { $_[0]->[0] <=> $_[1]->[0] || $_[0]->[1] <=> $_[1]->[1]};
+	}
+    return bless $obj => $class;
+}
+
+
+sub DESTROY { $_[0]->[ROOT]->DESTROY if $_[0]->[ROOT] }
+
+sub root { $_[0]->[ROOT] }
+sub size { $_[0]->[SIZE] }
+
+sub left_most {
+    my $self = shift;
+    return undef unless $self->[ROOT];
+    return $self->[ROOT]->left_most;
+}
+
+sub right_most {
+    my $self = shift;
+    return undef unless $self->[ROOT];
+    return $self->[ROOT]->right_most;
+}
+
+# return all the intervals intersect with the interval
+sub intersect {
+	my $self = shift;
+	my $interval = shift;
+	return my @tmp  unless $self->[ROOT];
+	return $self->[ROOT]->intersect($interval);
+}
+
+sub lookup {
+    my $self = shift;
+    my $key  = shift;
+    defined $key
+      or croak("Can't use undefined value as key");
+    my $mode = shift || LUEQUAL;
+    my $cmp = $self->[CMP];
+
+    my $y;
+    my $x = $self->[ROOT]
+      or return;
+    my $next_child;
+    while($x) {
+        $y = $x;
+        if($cmp ? $cmp->($key, $x->[_KEY]) == 0
+                : $key eq $x->[_KEY]) {
+            # found it!
+            if($mode == LUGREAT || $mode == LUNEXT) {
+                $x = $x->successor;
+            }
+            elsif($mode == LULESS || $mode == LUPREV) {
+                $x = $x->predecessor;
+            }
+            return wantarray
+              ? ($x->[_VAL], $x)
+              : $x->[_VAL];
+        }
+        if($cmp ? $cmp->($key, $x->[_KEY]) < 0
+                : $key lt $x->[_KEY]) {
+            $next_child = _LEFT;
+        }
+        else {
+            $next_child = _RIGHT;
+        }
+        $x = $x->[$next_child];
+    }
+    # Didn't find it :(
+    if($mode == LUGTEQ || $mode == LUGREAT) {
+        if($next_child == _LEFT) {
+            return wantarray ? ($y->[_VAL], $y) : $y->[_VAL];
+        }
+        else {
+            my $next = $y->successor
+              or return;
+            return wantarray ? ($next->[_VAL], $next) : $next->[_VAL];
+        }
+    }
+    elsif($mode == LULTEQ || $mode == LULESS) {
+        if($next_child == _RIGHT) {
+            return wantarray ? ($y->[_VAL], $y) : $y->[_VAL];
+        }
+        else {
+            my $next = $y->predecessor
+              or return;
+            return wantarray ? ($next->[_VAL], $next) : $next->[_VAL];
+        }
+    }
+    return;
+}
+
+sub insert {
+    my $self = shift;
+    my $key_or_node = shift;
+    defined $key_or_node
+      or croak("Can't use undefined value as key or node");
+    my $val = shift;
+
+    my $cmp = $self->[CMP];
+    my $z = (ref $key_or_node eq 'Tree::Interval::Node')
+              ? $key_or_node
+              : Tree::Interval::Node->new($key_or_node => $val);
+
+    my $y;
+    my $x = $self->[ROOT];
+    while($x) {
+        $y = $x;
+        # Handle case of inserting node with duplicate key.
+        if($cmp ? $cmp->($z->[_KEY], $x->[_KEY]) == 0
+                : $z->[_KEY] eq $x->[_KEY])
+        {
+			warn "The same key (range) is already in the tree
+				it will be replaced!";
+            my $old_val = $x->[_VAL];
+            $x->[_VAL] = $z->[_VAL];
+            return $old_val;
+        }
+
+        if($cmp ? $cmp->($z->[_KEY], $x->[_KEY]) < 0
+                : $z->[_KEY] lt $x->[_KEY])
+        {
+            $x = $x->[_LEFT];
+        }
+        else {
+            $x = $x->[_RIGHT];
+        }
+    }
+    # insert new node
+    $z->[_PARENT] = $y;
+    if(not defined $y) {
+        $self->[ROOT] = $z;
+    }
+    else {
+        if($cmp ? $cmp->($z->[_KEY], $y->[_KEY]) < 0
+                : $z->[_KEY] lt $y->[_KEY])
+        {
+            $y->[_LEFT] = $z;
+        }
+        else {
+            $y->[_RIGHT] = $z;
+        }
+    }
+	_update_max($z);
+    $self->_fix_after_insertion($z);
+    $self->[SIZE]++;
+}
+
+sub _fix_after_insertion {
+    my $self = shift;
+    my $x = shift or croak('Missing arg: node');
+
+    $x->[_COLOR] = RED;
+    while($x != $self->[ROOT] && $x->[_PARENT][_COLOR] == RED) {
+        my ($child, $rotate1, $rotate2);
+        if(($x->[_PARENT] || 0) == ($x->[_PARENT][_PARENT][_LEFT] || 0)) {
+            ($child, $rotate1, $rotate2) = (_RIGHT, '_left_rotate', '_right_rotate');
+        }
+        else {
+            ($child, $rotate1, $rotate2) = (_LEFT, '_right_rotate', '_left_rotate');
+        }
+        my $y = $x->[_PARENT][_PARENT][$child];
+
+        if($y && $y->[_COLOR] == RED) {
+            $x->[_PARENT][_COLOR] = BLACK;
+            $y->[_COLOR] = BLACK;
+            $x->[_PARENT][_PARENT][_COLOR] = RED;
+            $x = $x->[_PARENT][_PARENT];
+        }
+        else {
+            if($x == ($x->[_PARENT][$child] || 0)) {
+                $x = $x->[_PARENT];
+                $self->$rotate1($x);
+            }
+            $x->[_PARENT][_COLOR] = BLACK;
+            $x->[_PARENT][_PARENT][_COLOR] = RED;
+            $self->$rotate2($x->[_PARENT][_PARENT]);
+        }
+    }
+    $self->[ROOT][_COLOR] = BLACK;
+}
+
+sub delete {
+    my ($self, $key_or_node) = @_;
+    defined $key_or_node
+      or croak("Can't use undefined value as key or node");
+
+    my $z = (ref $key_or_node eq 'Tree::Interval::Node')
+              ? $key_or_node
+              : ($self->lookup($key_or_node))[1];
+    return unless $z;
+
+    my $y;
+    if($z->[_LEFT] && $z->[_RIGHT]) {
+        # (Notes kindly provided by Christopher Gurnee)
+        # When deleting a node 'z' which has two children from a binary search tree, the
+        # typical algorithm is to delete the successor node 'y' instead (which is
+        # guaranteed to have at most one child), and then to overwrite the key/values of
+        # node 'z' (which is still in the tree) with the key/values (which we don't want
+        # to lose) from the now-deleted successor node 'y'.
+
+        # Since we need to return the deleted item, it's not good enough to overwrite the
+        # key/values of node 'z' with those of node 'y'. Instead we swap them so we can
+        # return the deleted values.
+
+        $y = $z->predecessor;
+        ($z->[_KEY], $y->[_KEY]) = ($y->[_KEY], $z->[_KEY]);
+        ($z->[_VAL], $y->[_VAL]) = ($y->[_VAL], $z->[_VAL]);
+        ($z->[_INTERVAL], $y->[_INTERVAL]) = ($y->[_INTERVAL], $z->[_INTERVAL]);
+    }
+    else {
+        $y = $z;
+    }
+	
+    # splice out $y
+    my $x = $y->[_LEFT] || $y->[_RIGHT];
+    if(defined $x) {
+        $x->[_PARENT] = $y->[_PARENT];
+        if(! defined $y->[_PARENT]) {
+            $self->[ROOT] = $x;
+        }
+        elsif($y == $y->[_PARENT][_LEFT]) {
+            $y->[_PARENT][_LEFT] = $x;
+        }
+        else {
+            $y->[_PARENT][_RIGHT] = $x;
+        }
+        # Null out links so they are OK to use by _fix_after_deletion
+        delete @{$y}[_PARENT, _LEFT, _RIGHT];
+		_update_max($x);
+        # Fix replacement
+        if($y->[_COLOR] == BLACK) {
+            $self->_fix_after_deletion($x);
+        }
+    }
+    elsif(! defined $y->[_PARENT]) {
+        # return if we are the only node
+        delete $self->[ROOT];
+    }
+    else {
+        # No children. Use self as phantom replacement and unlink
+        if($y->[_COLOR] == BLACK) {
+            $self->_fix_after_deletion($y);
+        }
+        if(defined $y->[_PARENT]) {
+            no warnings 'uninitialized';
+            if($y == $y->[_PARENT][_LEFT]) {
+                delete $y->[_PARENT][_LEFT];
+            }
+            elsif($y == $y->[_PARENT][_RIGHT]) {
+                delete $y->[_PARENT][_RIGHT];
+            }
+			my $tmp = $y->[_PARENT];
+            delete $y->[_PARENT];
+			_update_max($tmp);
+        }
+    }
+    $self->[SIZE]--;
+    return $y;
+}
+
+sub _fix_after_deletion {
+    my $self = shift;
+    my $x = shift or croak('Missing arg: node');
+
+    while($x != $self->[ROOT] && color_of($x) == BLACK) {
+        my ($child1, $child2, $rotate1, $rotate2);
+        no warnings 'uninitialized';
+        if($x == left_of(parent_of($x))) {
+            ($child1,    $child2,   $rotate1,       $rotate2) =
+            (\&right_of, \&left_of, '_left_rotate', '_right_rotate');
+        }
+        else {
+            ($child1,   $child2,    $rotate1,        $rotate2) =
+            (\&left_of, \&right_of, '_right_rotate', '_left_rotate');
+        }
+        use warnings;
+
+        my $w = $child1->(parent_of($x));
+        if(color_of($w) == RED) {
+            set_color($w, BLACK);
+            set_color(parent_of($x), RED);
+            $self->$rotate1(parent_of($x));
+            $w = right_of(parent_of($x));
+        }
+        if(color_of($child2->($w)) == BLACK &&
+           color_of($child1->($w)) == BLACK) {
+            set_color($w, RED);
+            $x = parent_of($x);
+        }
+        else {
+            if(color_of($child1->($w)) == BLACK) {
+                set_color($child2->($w), BLACK);
+                set_color($w, RED);
+                $self->$rotate2($w);
+                $w = $child1->(parent_of($x));
+            }
+            set_color($w, color_of(parent_of($x)));
+            set_color(parent_of($x), BLACK);
+            set_color($child1->($w), BLACK);
+            $self->$rotate1(parent_of($x));
+            $x = $self->[ROOT];
+        }
+    }
+    set_color($x, BLACK);
+}
+
+
+sub _max3 {
+	my ($a, $b, $c) = @_;
+	my $min = ($a || $b || $c) - 1;
+	$a = $a || $min;
+	$b = $b || $min;
+	$c = $c || $min;
+	return $a if($a >= $b && $a >= $c);
+	return $b if($b >= $a && $b >= $c);
+	return $c if($c >= $a && $c >= $b);
+}
+
+sub _max {
+	my $x = shift;
+	my $tmp = _max3($x->[_INTERVAL][1], 
+		$x->[_LEFT] ? $x->[_LEFT][_MAX] : undef, 
+		$x->[_RIGHT] ? $x->[_RIGHT][_MAX] : undef);
+	$x->[_MAX] = $tmp;
+	return $tmp;
+}
+
+sub _update_max {
+	my $x = shift;
+	#update the max field for each parent node
+	_max($x);
+	my $k = $x->[_PARENT];
+	while($k) {
+		my $tmp = $k->[_MAX];
+		_max($k);
+		last if($tmp == $k->[_MAX]); # no need to update further
+		$k = $k->[_PARENT];
+	}
+}
+
+sub _left_rotate {
+    my $self = shift;
+    my $x = shift or croak('Missing arg: node');
+
+    my $y = $x->[_RIGHT]
+      or return;
+    $x->[_RIGHT] = $y->[_LEFT];
+    if($y->[_LEFT]) {
+        $y->[_LEFT]->[_PARENT] = $x;
+    }
+    $y->[_PARENT] = $x->[_PARENT];
+    if(not defined $x->[_PARENT]) {
+        $self->[ROOT] = $y;
+    }
+    else {
+        $x == $x->[_PARENT]->[_LEFT]
+          ? $x->[_PARENT]->[_LEFT]  = $y
+          : $x->[_PARENT]->[_RIGHT] = $y;
+    }
+    $y->[_LEFT]   = $x;
+    $x->[_PARENT] = $y;
+	#update max
+	_max($x); _max($y);
+}
+
+sub _right_rotate {
+    my $self = shift;
+    my $y = shift or croak('Missing arg: node');
+
+    my $x = $y->[_LEFT]
+      or return;
+    $y->[_LEFT] = $x->[_RIGHT];
+    if($x->[_RIGHT]) {
+        $x->[_RIGHT]->[_PARENT] = $y
+    }
+    $x->[_PARENT] = $y->[_PARENT];
+    if(not defined $y->[_PARENT]) {
+        $self->[ROOT] = $x;
+    }
+    else {
+        $y == $y->[_PARENT]->[_RIGHT]
+          ? $y->[_PARENT]->[_RIGHT] = $x
+          : $y->[_PARENT]->[_LEFT]  = $x;
+    }
+    $x->[_RIGHT] = $y;
+    $y->[_PARENT] = $x;
+	_max($y); _max($x);
+}
+
+1; 
+
+# Magic true value required at end of module
+__END__
+
+=head1 NAME
+
+Tree::RB - Perl implementation of the Red/Black tree, a type of balanced binary search tree. 
+
+
+=head1 VERSION
+
+This document describes Tree::RB version 0.1
+
+
+=head1 SYNOPSIS
+
+    use Tree::RB;
+
+    my $tree = Tree::RB->new;
+    $tree->put('France'  => 'Paris');
+    $tree->put('England' => 'London');
+    $tree->put('Hungary' => 'Budapest');
+    $tree->put('Ireland' => 'Dublin');
+    $tree->put('Egypt'   => 'Cairo');
+    $tree->put('Germany' => 'Berlin');
+
+    $tree->put('Alaska' => 'Anchorage'); # D'oh!
+    $tree->delete('Alaska');
+
+    print $tree->get('Ireland'); # 'Dublin'
+
+    print $tree->min->key; # 'Egypt' 
+    print $tree->max->key; # 'Ireland' 
+    print $tree->size; # 6
+
+    # print items, ordered by key
+    my $it = $tree->iter;
+
+    while(my $node = $it->next) {
+        sprintf "key = %s, value = %s\n", $node->key, $node->val;
+    }
+
+    # print items in reverse order
+    $it = $tree->rev_iter;
+
+    while(my $node = $it->next) {
+        sprintf "key = %s, value = %s\n", $node->key, $node->val;
+    }
+
+    # Hash interface
+    tie my %capital, 'Tree::RB';
+
+    # or do this to store items in descending order 
+    tie my %capital, 'Tree::RB', sub { $_[1] cmp $_[0] };
+
+    $capital{'France'}  = 'Paris';
+    $capital{'England'} = 'London';
+    $capital{'Hungary'} = 'Budapest';
+    $capital{'Ireland'} = 'Dublin';
+    $capital{'Egypt'}   = 'Cairo';
+    $capital{'Germany'} = 'Berlin';
+
+    # print items in order
+    while(my ($key, $val) = each %capital) {
+        printf "key = $key, value = $val\n";
+    }
+
+=head1 DESCRIPTION
+
+This is a Perl implementation of the Red/Black tree, a type of balanced binary search tree. 
+
+A tied hash interface is also provided to allow ordered hashes to be used.
+
+See the Wikipedia article at L<http://en.wikipedia.org/wiki/Red-black_tree> for more on Red/Black trees.
+
+
+=head1 INTERFACE
+
+=head2 new([CODEREF])
+
+Creates and returns a new tree. If a reference to a subroutine is passed to
+new(), the subroutine will be used to override the tree's default lexical
+ordering and provide a user a defined ordering. 
+
+This subroutine should be just like a comparator subroutine used with L<sort>, 
+except that it doesn't do the $a, $b trick.
+
+For example, to get a case insensitive ordering
+
+    my $tree = Tree::RB->new(sub { lc $_[0] cmp lc $_[1]});
+    $tree->put('Wall'  => 'Larry');
+    $tree->put('Smith' => 'Agent');
+    $tree->put('mouse' => 'micky');
+    $tree->put('duck'  => 'donald');
+
+    my $it = $tree->iter;
+
+    while(my $node = $it->next) {
+        sprintf "key = %s, value = %s\n", $node->key, $node->val;
+    }
+
+=head2 resort(CODEREF)
+
+Changes the ordering of nodes within the tree. The new ordering is
+specified by a comparator subroutine which must be passed to resort().
+
+See L</new> for further information about the comparator.
+
+=head2 size()
+
+Returns the number of nodes in the tree.
+
+=head2 root()
+
+Returns the root node of the tree. This will either be undef
+if no nodes have been added to the tree, or a L<Tree::RB::Node> object.
+See the L<Tree::RB::Node> manual page for details on the Node object.
+
+=head2 min()
+
+Returns the node with the minimal key.
+
+=head2 max()
+
+Returns the node with the maximal key.
+
+=head2 lookup(KEY, [MODE])
+
+When called in scalar context, lookup(KEY) returns the value
+associated with KEY.
+
+When called in list context, lookup(KEY) returns a list whose first
+element is the value associated with KEY, and whose second element
+is the node containing the key/value.
+
+An optional MODE parameter can be passed to lookup() to influence
+which key is returned.
+
+The values of MODE are constants that are exported on demand by
+Tree::RB
+
+    use Tree::RB qw[LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV];
+
+=over
+
+=item LUEQUAL
+
+Returns node exactly matching the key.
+
+=item LUGTEQ
+
+Returns the node exactly matching the specified key, 
+if this is not found then the next node that is greater than the specified key is returned.
+
+=item LULTEQ
+
+Returns the node exactly matching the specified key, 
+if this is not found then the next node that is less than the specified key is returned.
+
+=item LUGREAT
+
+Returns the node that is just greater than the specified key - not equal to. 
+This mode is similar to LUNEXT except that the specified key need not exist in the tree.
+
+=item LULESS
+
+Returns the node that is just less than the specified key - not equal to. 
+This mode is similar to LUPREV except that the specified key need not exist in the tree.
+
+=item LUNEXT
+
+Looks for the key specified, if not found returns C<undef>. 
+If the node is found returns the next node that is greater than 
+the one found (or C<undef> if there is no next node). 
+
+This can be used to step through the tree in order.
+
+=item LUPREV
+
+Looks for the key specified, if not found returns C<undef>. 
+If the node is found returns the previous node that is less than 
+the one found (or C<undef> if there is no previous node). 
+
+This can be used to step through the tree in reverse order.
+
+=back
+
+=head2 get(KEY)
+
+get() is an alias for lookup().
+
+=head2 iter([KEY])
+
+Returns an iterator object that can be used to traverse the tree in order.
+
+The iterator object supports a 'next' method that returns the next node in the
+tree or undef if all of the nodes have been visited.
+
+See the synopsis for an example.
+
+If a key is supplied, the iterator returned will traverse the tree in order starting from
+the node with key greater than or equal to the specified key.
+
+    $it = $tree->iter('France');
+    my $node = $it->next;
+    print $node->key; # -> 'France'
+
+=head2 rev_iter([KEY])
+
+Returns an iterator object that can be used to traverse the tree in reverse order.
+
+If a key is supplied, the iterator returned will traverse the tree in order starting from
+the node with key less than or equal to the specified key.
+
+    $it = $tree->rev_iter('France');
+    my $node = $it->next;
+    print $node->key; # -> 'England'
+
+=head2 hseek(KEY, [{-reverse => 1|0}])
+
+For tied hashes, determines the next entry to be returned by each.
+
+    tie my %capital, 'Tree::RB';
+
+    $capital{'France'}  = 'Paris';
+    $capital{'England'} = 'London';
+    $capital{'Hungary'} = 'Budapest';
+    $capital{'Ireland'} = 'Dublin';
+    $capital{'Egypt'}   = 'Cairo';
+    $capital{'Germany'} = 'Berlin';
+    tied(%capital)->hseek('Germany');
+
+    ($key, $val) = each %capital;
+    print "$key, $val"; # -> Germany, Berlin 
+
+The direction of iteration can be reversed by passing a hashref with key '-reverse' and value 1
+to hseek after or instead of KEY, e.g. to iterate over the hash in reverse order:
+
+    tied(%capital)->hseek({-reverse => 1});
+    $key = each %capital;
+    print $key; # -> Ireland 
+
+The following calls are equivalent
+
+    tied(%capital)->hseek('Germany', {-reverse => 1});
+    tied(%capital)->hseek({-key => 'Germany', -reverse => 1});
+
+=head2 put(KEY, VALUE)
+
+Adds a new node to the tree. 
+
+The first argument is the key of the node, the second is its value. 
+
+If a node with that key already exists, its value is replaced with 
+the given value and the old value is returned. Otherwise, undef is returned.
+
+=head2 delete(KEY)
+
+If the tree has a node with the specified key, that node is
+deleted from the tree and returned, otherwise C<undef> is returned.
+
+
+=head1 DEPENDENCIES
+
+L<enum>
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+Please report any bugs or feature requests to
+C<bug-tree-rb@rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org>.
+
+
+=head1 AUTHOR
+
+Arun Prasad  C<< <arunbear@cpan.org> >>
+
+Some documentation has been borrowed from Benjamin Holzman's L<Tree::RedBlack>
+and Damian Ivereigh's libredblack (L<http://libredblack.sourceforge.net/>).
+
+=head1 ACKNOWLEDGEMENTS
+
+Thanks for bug reports go to Anton Petrusevich, Wes Thompson and Christopher Gurnee.
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2007, Arun Prasad C<< <arunbear@cpan.org> >>. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+
+
+=head1 DISCLAIMER OF WARRANTY
+
+BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
+YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR, OR CORRECTION.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
+THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tree/Interval/Node.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,208 @@
+package Tree::Interval::Node;
+
+use strict;
+use Carp;
+use Tree::Interval::Node::Constants;
+use vars qw( $VERSION @EXPORT_OK );
+
+require Exporter;
+*import    = \&Exporter::import;
+@EXPORT_OK = qw[set_color color_of parent_of left_of right_of];
+
+$VERSION = '0.1';
+
+# key and interval is the same thing
+my %attribute = (
+    key    => _KEY,
+    val    => _VAL,
+    color  => _COLOR,
+    parent => _PARENT,
+    left   => _LEFT,
+    right  => _RIGHT,
+	max    => _MAX,
+	interval => _INTERVAL,
+);
+
+#using an array instead of a hash for the node
+sub _accessor {
+    my $index = shift;
+    return sub {
+        my $self = shift;
+		return undef unless $self;
+        if (@_) {
+          $self->[$index] = shift;
+        }
+        return $self->[$index];
+    };
+}
+
+while(my($at, $idx) = each %attribute) {
+    no strict 'refs';
+    *$at = _accessor($idx);
+}
+
+sub new {
+    my $class = shift;
+    my $obj = [];
+
+    if (@_) {
+        $obj->[_KEY] = $obj->[_INTERVAL] = shift;
+        $obj->[_VAL] = shift;
+    }
+    return bless $obj, $class;
+}
+
+sub left_most {
+    my $self = shift;
+    while ($self->[_LEFT]) {
+        $self = $self->[_LEFT];
+    }
+    return $self;
+}
+
+sub right_most {
+    my $self = shift;
+    while ($self->[_RIGHT]) {
+        $self = $self->[_RIGHT];
+    }
+    return $self;
+}
+
+#find left_most leaf
+sub leaf {
+    my $self = shift;
+    while (my $any_child = $self->[_LEFT] || $self->[_RIGHT]) {
+        $self = $any_child;
+    }
+    return $self;
+}
+
+sub successor {
+    my $self = shift;
+    if ($self->[_RIGHT]) {
+        return $self->[_RIGHT]->left_most;
+    }
+    my $parent = $self->[_PARENT];
+    while ($parent && $parent->[_RIGHT] && $self == $parent->[_RIGHT]) {
+        $self = $parent;
+        $parent = $parent->[_PARENT];
+    }
+    return $parent;
+}
+
+sub predecessor {
+    my $self = shift;
+    if ($self->[_LEFT]) {
+        return $self->[_LEFT]->right_most;
+    }
+    my $parent = $self->[_PARENT];
+    while ($parent && $parent->[_LEFT] && $self == $parent->[_LEFT]) {
+        $self = $parent;
+        $parent = $parent->[_PARENT];
+    }
+    return $parent;
+}
+
+sub as_lol {
+    my $self = shift;
+    my $node = shift || $self;
+    my $aref;
+    push @$aref,
+         $node->[_LEFT]
+           ? $self->as_lol($node->[_LEFT])
+           : '*';
+    push @$aref,
+         $node->[_RIGHT]
+           ? $self->as_lol($node->[_RIGHT])
+           : '*';
+    my $color = ($node->[_COLOR] == RED ? 'R' : 'B');
+    no warnings 'uninitialized';
+    push @$aref, "$color:[$node->[_KEY][0],$node->[_KEY][1]]:$node->[_MAX]";
+    return $aref;
+}
+
+sub strip {
+    my $self = shift;
+    my $callback = shift;
+
+    my $x = $self;
+    while($x) {
+        my $leaf = $x->leaf;
+        $x = $leaf->[_PARENT];
+
+        # detach $leaf from the (sub)tree
+        no warnings "uninitialized";
+        if($leaf == $x->[_LEFT]) {
+            undef $x->[_LEFT];
+        }
+        else {
+            undef $x->[_RIGHT];
+        }
+        undef $leaf->[_PARENT];
+        if($callback) {
+            $callback->($leaf);
+        }
+
+        if(!$x->[_LEFT] && !$x->[_RIGHT]) {
+            $x = $x->[_PARENT];
+        }
+    }
+}
+
+sub DESTROY { $_[0]->strip; }
+
+# Null aware accessors to assist with rebalancings during insertion and deletion
+#
+# A weird case of Java to the rescue!
+# These are inspired by http://www.javaresearch.org/source/jdk142/java/util/TreeMap.java.html
+# which was found via http://en.wikipedia.org/wiki/Red-black_tree#Implementations
+
+# do wen need it? as we have accessors already
+sub set_color {
+    my ($node, $color) = @_;
+    if($node) {
+        $node->[_COLOR] = $color; 
+    }
+}
+
+sub color_of {
+    $_[0] ? $_[0]->[_COLOR] : BLACK;
+}
+
+sub parent_of {
+    $_[0] ? $_[0]->[_PARENT] : undef;
+}
+
+sub left_of {
+    $_[0] ? $_[0]->[_LEFT] : undef;
+}
+
+sub right_of {
+    $_[0] ? $_[0]->[_RIGHT] : undef;
+}
+
+sub _overlap {
+	my ($a, $b) = @_;
+	return 1 if($a->[0] <= $b->[1] && $a->[1] >= $b->[0]);
+	return undef;
+}	
+
+sub intersect {
+	my $x = shift;
+	my $interval = shift;
+	return if(!$x);
+#	print $x->val->name, "\t", $x->key->[0], "\t", $x->key->[1], "\n";
+	my @rtn;
+	if(_overlap($x->interval, $interval)) {
+		push @rtn, $x;
+	}
+#	my $y = $x->parent;
+	if($x->left && $x->left->max >= $interval->[0] ) { # && (!$y || _overlap($interval, [$y->interval->[0], $x->left->max]))) {
+		push @rtn, $x->left->intersect($interval);
+	}
+	push @rtn, $x->right->intersect($interval) if($x->right && _overlap($interval, [$x->interval->[0], $x->right->max]));
+	return @rtn;
+}
+
+1;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tree/Interval/Node/Constants.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,32 @@
+package Tree::Interval::Node::Constants;
+
+use strict;
+use Carp;
+use vars qw( $VERSION @EXPORT );
+
+$VERSION = '0.1';
+
+require Exporter;
+*import = \&Exporter::import;
+
+my @Node_slots;
+my @Node_colors;
+
+BEGIN { 
+    @Node_slots  = qw(PARENT LEFT RIGHT COLOR KEY VAL MAX INTERVAL); 
+    @Node_colors = qw(RED BLACK);
+}
+
+@EXPORT = (@Node_colors, map {"_$_"} @Node_slots);
+
+use enum @Node_colors;
+use enum @Node_slots;
+
+# enum doesn't allow symbols to start with "_", but we want them 
+foreach my $s (@Node_slots) {
+    no strict 'refs';
+    *{"_$s"} = \&$s;
+    delete $Tree::RB::Node::Constants::{$s};
+} 
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bam2html.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,528 @@
+#!/usr/bin/perl -w
+use strict;
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+use Bio::Assembly::IO;
+use Bio::DB::Sam;
+use Bio::DB::Sam::Constants;
+use File::Spec;
+use File::Path;
+use File::Copy;
+use File::Basename;
+
+use constant HTML_COLOR => {
+	'MATCH'		=> '#000000', #black
+	'MISMATCH'	=> '#800000', #brown
+	'LOWQUAL'	=> '#C0C0C0', #grey
+	'INDEL'		=> '#FF8040', #Orange
+	'SCLIP'		=> '#6960EC', #Slate Blue2
+};
+my $lowqual_cutoff = 20;
+
+my ($bam_d, $bam_g,  $file);
+my $ref_genome;
+my $range;
+
+my ( $help, $man, $version, $usage );
+my $output;
+my $RNASeq;
+my $optionOK = GetOptions(
+	'd=s'			=> \$bam_d,
+	'g=s'			=> \$bam_g,
+	'f|i|file|input=s'	=> \$file,
+	'r|ref_genome=s'	=> \$ref_genome,
+	'range=s'		=> \$range,
+	'RNASeq'		=> \$RNASeq,
+	'o|output=s'	=> \$output,
+	'h|help|?'      => \$help,
+	'man'           => \$man,
+	'usage'         => \$usage,
+	'v|version'     => \$version,
+);
+
+pod2usage(-verbose=>2) if($man or $usage);
+pod2usage(1) if($help or $version );
+croak "you must specify at least one bam file" unless ($bam_d || $bam_g);
+warn "Missing reference genome, the view is not correct" unless($ref_genome);
+croak "You need either provide an input file or a range" unless ($file || $range);
+
+my @bams;
+push @bams, Bio::DB::Sam->new( -bam => $bam_d, -fasta => $ref_genome) if($bam_d);
+push @bams, Bio::DB::Sam->new( -bam => $bam_g, -fasta => $ref_genome) if($bam_g);
+open STDOUT, ">$output" if $output;
+
+if($range) {
+	print STDOUT bam2html($range, @bams);
+	close STDOUT if $output;
+	exit(0);
+}
+
+open my $FILE, "<$file" or croak "can't open $file:$OS_ERROR";
+while( my $line = <$FILE>) {
+	chomp $line;
+	my @fields = split /\t/, $line;
+	print "<h3 style=\"color:blue;text-align:center\">$line</h3>\n";
+	if(scalar(@fields) == 3) { # deal with file: chr	start	end format
+		my ($chr, $s, $e) = @fields;
+		print STDOUT bam2html("$chr:$s-$e", @bams);
+		next;
+	}
+	# deal with CREST output file
+#	if($fields[0] =~ /^chr/) {
+#		$fields[0] = substr($fields[0], 3);
+#		$fields[2] = substr($fields[2], 3);
+#	}
+	my ($chr, $s, $e) = ($fields[0], $fields[1], $fields[1]);
+	print STDOUT bam2html("$chr:$s-$e", @bams);
+	($chr, $s, $e) = ($fields[4], $fields[5], $fields[5]);
+	print STDOUT bam2html("$chr:$s-$e", @bams);
+}
+close STDOUT if($output);
+exit(0);
+#print bam2html("12:11676858-11676858", $bam1, $bam2);
+
+
+sub get_input_bam {
+    my ($raw_bam_dir, $sample, $group) = @_;
+
+    $raw_bam_dir = File::Spec->catdir($raw_bam_dir, $group);
+    opendir(my $dh, $raw_bam_dir) or croak "can't open directory: $raw_bam_dir: $OS_ERROR";
+    my @files = grep { /^$sample-.*bam$/ } readdir($dh);
+	close $dh;
+	return $files[0];
+}
+
+
+# this function returns a <pre> </pre> block for the specific contig in the ace file
+sub bam2html {
+	my ($range, @bams) = @_;
+	my ($chr, $start, $end) = $range =~ m/^(.*?):(\d+)-(\d+)/;
+	if(!$chr or !$start or !$end) {
+		croak "The range format is not correct, use chr:start-end";
+	}
+	my ($r_start, $r_end) = ($start, $end);
+	my $name_len = length($range);
+	for my $bam (@bams) {
+		my $segment = $bam->segment(-seq_id => $chr, -start => $start, -end => $end);
+		my @alignments = $segment->features;
+	#	return "There are too many reads in this region, this is must be a highly repetitive region, abort!"
+	#		if(scalar(@alignments) > 500);
+		for my $a(@alignments) {
+			my $l = length($a->query->name);
+			$name_len = $l if($name_len < $l);
+		}
+	}
+	if($start == $end) { # we want to check a specific point
+		if($RNASeq) { # for RNASeq we just extend a little bit instead of dynamic do it
+			$r_start = $start - 100;
+			$r_end = $end + 100;
+		}
+		else {	
+			for my $bam (@bams) {
+				my $segment = $bam->segment(-seq_id => $chr, -start => $start - 1, -end => $end + 1);
+				my @alignments = $segment->features;
+				for my $a (@alignments) {
+					next if($a->start > $end || $a->end < $start);
+					$r_start = $a->start if $a->start < $r_start;
+					$r_end = $a->end if $a->end > $r_end;
+				}
+			}
+		}
+		$range = "$chr:$r_start-$r_end";
+	}
+	my $rtn_str = "<pre>\n";
+	my($ref, $pos2padded) = get_padded_ref($range, @bams);
+	$rtn_str .= print_bam_ruler($r_start, $r_end, $pos2padded, $name_len) . "\n";
+	my $line = print_ref($ref, $range, $name_len);
+	my $line_len = length($line);
+	$rtn_str .= $line . "\n" . ' ' x $line_len . "\n";
+	$ref =~ s/\*//g; #remove * from ref sequence
+	for my $bam (@bams) {
+		my $segment = $bam->segment(-seq_id => $chr, -start => $start, -end => $end);
+		my @alignments = $segment->features;
+		for my $a (@alignments) {
+			#next if($a->cigar_str !~ m/S/);
+			if($a->strand == 1) {
+				my $tmp_str = print_bam_seq($a, $r_start, $r_end, $ref, $pos2padded, $name_len);
+				$rtn_str .= $tmp_str . "\n" if($tmp_str); 
+			}
+		}
+		for my $a (@alignments) {
+			#next if($a->cigar_str !~ m/S/);
+			if($a->strand == -1) {
+				my $tmp_str = print_bam_seq($a, $r_start, $r_end, $ref, $pos2padded, $name_len);
+				$rtn_str .= $tmp_str . "\n" if($tmp_str);
+			}
+		}
+		$rtn_str .= '_' x $line_len . "\n";
+	}
+	$rtn_str .= "\n</pre>";
+	return $rtn_str;
+}
+
+# only print the unpadded position, which is meaningful
+sub print_bam_ruler {
+	my($start, $end, $pos2padded, $name_len) = @_;
+	my ($string, $mark);
+	$string = $mark = " "x($name_len + 2);
+	
+	#print | at 20 and . at 10 
+	for( my $i = $start; $i <= $end; $i++) {
+		$mark .= $i % 10 == 0 ? ($i % 20 == 0 ? "|" : ".") : " ";
+		last if($i == $end);
+		$mark .= ' ' x ($pos2padded->[$i - $start + 2] - $pos2padded->[$i - $start + 1] - 1);
+	}
+	# print numbers above | for padded consensus
+	my $padded_i = 0;
+	for( my $i = 1; $i <= $end - $start + 1; $i++ ) {
+		my $j = $i + $start - 1;
+		my $overhead = $pos2padded->[$i] - $padded_i;
+		if($overhead > 0 ) {
+			$string .= ' ' x $overhead;
+			$padded_i += $overhead;
+		}
+		if( $j % 20 == 0) {
+			my $l = length($j);
+			my $half_l = int(($l+1)/2);
+			$string = substr($string, 0, length($string) - $half_l );
+			$string .= $j;
+			$padded_i += ($l - $half_l);
+		}
+	}
+	return join("\n", ($string, $mark));
+}
+
+sub print_ref {
+	my( $ref, $chr, $name_len) = @_;
+	return $chr . " " x ($name_len + 2 - length($chr)) . $ref;
+}
+
+sub get_padded_ref {
+	my ($range, @bams) = @_;
+	my $ref_str; #padded ref genome
+	my @pos2padded;
+	my($chr, $start, $end) = $range =~ m/(.*?):(\d+)-(\d+)/;
+	
+	@pos2padded = 0 .. ($end - $start + 1);
+	push @pos2padded, 100 + $end - $start;
+	
+	foreach my $bam (@bams) {
+		my ($d, $cum_pad) = (0, 0);
+		my $padded_fun = sub {
+			my ($seqid, $pos, $p) = @_;
+			return if($pos < $start || $pos > $end);
+			$d++; 
+			$pos2padded[$d] += $cum_pad;
+			my $max_ins = 0;
+			for my $pileup (@$p) {
+				$max_ins = $pileup->indel if($max_ins < $pileup->indel);
+			}
+			if($max_ins > $pos2padded[$d+1] + $cum_pad - $pos2padded[$d] - 1) {
+				$cum_pad += $max_ins - ($pos2padded[$d+1] + $cum_pad-  $pos2padded[$d] - 1);
+			}
+		};
+		$bam->pileup($range, $padded_fun);
+		if($d <= $end - $start + 1) {
+			for(my $i = $d + 1; $i <= $end-$start+1; $i++) {
+				$pos2padded[$i] += $cum_pad;
+			}
+		}
+	}
+	my $refseq = $bams[0]->segment($chr, $start, $end)->dna;
+	my @str = split //, "*" x $pos2padded[$end - $start + 1];
+	for my $i ( 1 .. ($end - $start + 1)) {
+		$str[$pos2padded[$i]] = substr($refseq, $i-1, 1);
+	}
+	shift @str; #remove the 0th base
+	return (join( '', @str), \@pos2padded );
+}
+
+sub print_bam_seq { # it's complicated
+	my ($align, $start, $end, $ref, $pos2padded, $name_len) = @_;
+	my $rtn = $align->query->name;
+	$rtn .= ' ' x ($name_len - length($rtn));
+	$rtn .= $align->strand == -1 ? '- ' : '+ ';
+	my $p_s = $align->start;	
+	my $p_e = $align->end;
+	my $seq = $align->query->dna;
+	my @qual = $align->qscore;
+	my $repeat = 0;
+	if($align->has_tag("XT")) {
+		$repeat = 1 if($align->aux_get("XT") ne "U");
+	}
+
+	my $r_cigar = $align->cigar_array;
+	my ($s, $e) = ($align->query->start, $align->query->end);
+	
+	# reads partial in the region
+	my $leading = "";
+	if($p_s < $start) {
+		($r_cigar, $p_s, $s) = find_new_start($r_cigar, $p_s, $s, $start);
+	}
+
+	my $tailing = "";
+	if($p_e > $end) {
+		($r_cigar, $p_e, $e) = find_new_end($r_cigar, $p_e, $e, $end);
+	}
+	return if($s >= $e);	
+	my @cigar = @{$r_cigar};
+
+	# deal with leading softclip
+    my	$op = shift @cigar;
+	my $l =  $pos2padded->[$p_s - $start + 1] - $pos2padded->[1];
+	if($op->[0] eq 'S') {
+		my $ss = $op->[1] - $l;
+		if($ss < 0) {
+			$ss = -$ss;
+			$leading .= ' ' x $ss;
+			$ss = 0;
+		}
+		$leading .= '<font color="' . HTML_COLOR->{'SCLIP'} . '">';
+		for( my $i = $ss; $i < $op->[1]; $i++) {
+			my $c = substr($seq, $i, 1);
+			$c = lc $c if($qual[$i] < $lowqual_cutoff);
+			$leading .= $c;
+		}
+		$leading .= '</font>' ;
+	}
+	else {
+		$leading .= ' ' x $l;	
+		unshift @cigar, $op;
+	}
+
+	#dealing with tailing softclip
+	$op = pop @cigar;
+	$l = $pos2padded->[$end - $start + 1] - $pos2padded->[$p_e - $start + 1];
+	if($op->[0] eq 'S') {
+		my $ee = $op->[1] - $l;
+		$ee = 0 if($ee < 0 );
+		$tailing = '<font color="' . HTML_COLOR->{'SCLIP'} . '">';
+		for( my $i = 0; $i < $op->[1] - $ee; $i++){
+			my $c = substr($seq, $i + $e, 1);
+			$c = lc $c if($qual[$i + $e] < $lowqual_cutoff);
+			$tailing .= $c;
+		}
+		$tailing .= '</font>';
+	}
+	else{
+		push @cigar, $op;
+	}
+
+	# generate the alignment part, only M, I, D and N
+	my $mid = '';
+	my $mode;
+	foreach $op (@cigar) {
+		my $l = $op->[1];
+		if($op->[0] eq 'M') {
+			my $line = '';
+			while($l > 0 ){
+				$l--;
+				my $c = substr($seq, $s - 1, 1); #seq is 0 based
+				my $newmode = "MISMATCH";
+				my $cc = substr($ref, $p_s - $start, 1); 
+				#last unless ($c && $cc);
+				$newmode = "MATCH" if($cc eq $c);
+				if($qual[$s-1] < $lowqual_cutoff) {
+					$c = lc $c;
+					$newmode = 'LOWQUAL' if($newmode eq 'MATCH');
+				}
+				if(!$mode) {
+					$line .= '<font color="' . HTML_COLOR->{$newmode} . '">';
+				}
+				elsif($mode ne $newmode) {
+					$line .= '</font>' . '<font color="' . HTML_COLOR->{$newmode} . '">';
+				}
+				$mode = $newmode;
+				$line .= $c;
+				$s++; $p_s++;
+				# dealing with padded * in reference genome
+				if($p_s < $p_e && $s < $e && $l > 0) { 
+					my $tmp = $pos2padded->[$p_s - $start + 1]-$pos2padded->[$p_s-1 - $start + 1];
+					if( $tmp > 1) {	
+						$line .= '</font>';
+						$line .= '<font color="' . HTML_COLOR->{'INDEL'} . '">';
+						$line .= '*' x ($tmp - 1);
+						$mode = 'INDEL';
+					}
+				}
+			}
+			$mid .= $line;
+		}
+		if($op->[0] eq 'D' || $op->[0] eq 'I' || $op->[0] eq 'N') {
+			my $newmode = 'INDEL';
+			my $tmp; #extra padded * after indel
+			$mid .= '</font>' if($mode && $mode ne $newmode);
+			$mid .= '<font color="' . HTML_COLOR->{'INDEL'} . '">';
+
+			if($op->[0] eq 'D' || $op->[0] eq 'N') {
+				$mid .= ($op->[0] eq 'D' ? '*' : '=') x $l;
+				$p_s += $l;
+				$tmp = $pos2padded->[$p_s - $start + 1]-$pos2padded->[$p_s - $l - $start ] - $l if($p_s < $p_e);
+			}
+			else{
+				$tmp = $pos2padded->[$p_s - $start + 1] - $pos2padded->[$p_s - 1 - $start + 1] - $l if($p_s < $p_e);
+				while($l > 0 ) {
+					my $c = substr($seq, $s - 1, 1);
+					$c = lc $c if($qual[$s - 1] < $lowqual_cutoff);
+					$mid .= $c;
+					$l--; $s++;
+				}
+			}
+			$mode = $newmode;
+			if($p_s < $p_e && $tmp > 1) {	
+				$mid .= '*' x ($tmp - 1);
+			}
+		}
+	}
+	$mid .= '</font>';
+	$rtn .= $leading . $mid . $tailing;		
+	$rtn = '<b><i>' . $rtn . '</i></b>' if($repeat);
+	return $rtn;
+}
+
+sub find_new_start {
+	my ($r_cigar, $p_s, $s, $start) = @_;
+	my @cigar = @{$r_cigar};
+ 
+	while(1) {
+		my $op = shift @cigar;
+		next if( $op->[0] eq 'S' || $op->[0] eq 'H');
+		if( $op->[0] eq 'I') { 
+			$s += $op->[1];	next;
+		}
+		if( $p_s + $op->[1] < $start ) { 
+			$p_s += $op->[1];	
+			$s += $op->[1] if $op->[0] eq 'M'; 
+		}
+		else {
+			$s += ($start - $p_s) if $op->[0] eq 'M'; 
+			unshift @cigar, [$op->[0], $op->[1] - ($start - $p_s)];
+			$p_s = $start;
+			return (\@cigar, $p_s, $s);
+		}
+	}
+}
+
+sub find_new_end {
+	my ($r_cigar, $p_e, $e, $end) = @_;
+	my @cigar = @{$r_cigar};
+
+	while(1) {
+		my $op = pop @cigar;
+		next if( $op->[0] eq 'S' || $op->[0] eq 'H');
+		if( $op->[0] eq 'I') { 
+			$e -= $op->[1];	next;
+		}
+		if( $p_e - $op->[1] > $end ) { 
+			$p_e -= $op->[1];	
+			$e -= $op->[1] if $op->[0] eq 'M'; 
+		}
+		else {
+			$e -= ($p_e - $end) if $op->[0] eq 'M';
+			push @cigar, [$op->[0], $op->[1] - ($p_e - $end)];
+			$p_e = $end;
+			return (\@cigar, $p_e, $e);
+		}
+	}
+}
+
+=head1 NAME
+
+bam2html.pl - a bam file viewer that just simple display part of the alignment as HTML file.
+
+
+=head1 VERSION
+
+This documentation refers to bam2html.pl version 0.0.1.
+
+
+=head1 USAGE
+	
+	Display part of a bam file:
+	    bam2html.pl -r hg18.fa -d diag.bam --range 1:123566-123766 -o diag.html
+	Display part of two bam files, one diagnositc, one germlie for comparison.
+	    bam2html.pl -r hg18.fa -d diag.bam -g germline.bam --range 1:123566-123766 -o diag.html
+	Display part of two bam files, one diagnositc, one germlie for comparison from
+	a list of positions in a file, each line should be tab sepearted as: chr, start, and end.
+	    bam2html.pl -r hg18.fa -d diag.bam -g germline.bam -o diag.html -f position.txt
+	Display part of two bam files, one diagnositc, one germlie for comparison from a file
+	generated by CREST.pl.
+	    bam2html.pl -r hg18.fa -d diag.bam -g germline.bam -o predSV.html -f predSV.txt
+
+=head1 REQUIRED ARGUMENTS
+
+	To run the program, several parameter must specified.
+	-d:					The input (diagnositic) bam file
+	-g:					The input (germ line) bam file
+	-r, --ref_genome: 	The reference genome file in fa format
+
+=head1 OPTIONS
+
+	The	options that can be used for the program.
+	-o: 		The output file, default to STDOUT if missing.
+	--range:	The range where SV will be detected, using chr1:100-200 format.
+	-f, -i:		The input file from either CREST.pl or tab seperated chr, start, end.
+
+	-h, --help	 Help information
+	--man		 Man page.
+	--usage		 Usage information.
+	--version	 Software version.
+
+
+=head1 DESCRIPTION
+
+ This is a bam file viewer that just simple display part of the alignment as 
+ HTML file. The program is developed to view Structure Varitions around break 
+ point. So manual review will a breeze.  Any way this program can be used
+ otherway, but don't put a too big range to display as the view will not
+ be pretty as each read will occupy a line.
+
+
+=head1 DIAGNOSTICS
+
+If the program does not respond for minutes, please be a little bit patient as
+sometimes generating the html file could take longer time.
+If you provide a range as "chr1:50-100" and nothing was output, please make sure
+the reference genomes for mapping and display are exact the same and the chrom
+name is chr1 not 1.
+
+
+=head1 DEPENDENCIES
+
+The program depend on several packages:
+1. Bioperl perl module.
+2. Bio::DB::Sam, version 1.5 or later, it requires samtools lib installed.
+
+
+=head1 BUGS AND LIMITATIONS
+
+There are no known bugs in this module, but the method is limitted to bam file 
+that has soft-clipping cigar string generated.Please report problems to 
+Jianmin Wang  (Jianmin.Wang@stjude.org)
+Patches are welcome.
+
+=head1 AUTHOR
+
+Jianmin Wang (Jianmin.Wang@stjude.org)
+
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2010 by St. Jude Children's Research Hospital.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version. 
+
+This program is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of 
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/countDiff.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,74 @@
+#!/nfs_exports/apps/64-bit/gnu-apps/perl5.8.9/bin/perl -w
+use strict;
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+use Bio::DB::Sam;
+use Bio::DB::Sam::Constants;
+use Bio::SearchIO;
+use Bio::SeqIO;
+use File::Temp qw/ tempfile tempdir /;
+use File::Spec;
+use File::Path;
+use File::Copy;
+use File::Basename;
+use Cwd;
+
+# bam related variables
+# input/output
+my($file_d, $file_g);
+
+my ( $help, $man, $version, $usage );
+my $optionOK = GetOptions(
+	'd|diagnostic=s'	=> \$file_d,
+	'g|germline=s'		=> \$file_g,
+	'h|help|?'			=> \$help,
+	'man'				=> \$man,
+	'usage'				=> \$usage,
+	'v|version'			=> \$version,
+);
+
+pod2usage(-verbose=>2) if($man or $usage);
+pod2usage(1) if($help or $version );
+
+my $start_dir = getcwd;
+
+# figure out input file
+if(!$file_d or !$file_g ) {
+	croak "you need specify diagnostic and germline input file";
+}
+my ( @cover_D, @cover_diff);
+for( my $i = 1; $i < 1000; $i++) {
+	$cover_D[$i] = 0;
+	$cover_diff[$i] = 0;
+}
+my($prefix, $path, $suffix) = fileparse($file_d);
+my $diff_file = $prefix . ".somatic.cover";
+$diff_file = File::Spec->catfile($path, $diff_file);
+open my $SOMATIC, ">$diff_file" or croak "can't open $diff_file:$OS_ERROR";
+open my $IN_D, "<$file_d" or croak "can't open $file_d:$OS_ERROR";
+open my $IN_G, "<$file_g" or croak "can't open $file_g:$OS_ERROR";
+my %g_sclip;
+while( my $line = <$IN_G> ) {
+	chomp $line;
+	my ($chr, $pos, $ort, $cover) = split /\t/, $line;
+	$g_sclip{$chr} = {} if(!exists($g_sclip{$chr}));
+	$g_sclip{$chr}->{$pos} = $ort;
+}
+close($IN_G);
+while( my $line = <$IN_D> ) {
+	chomp $line;
+	my ($chr, $pos, $ort, $cover) = split /\t/, $line;
+	$cover_D[$cover]++;
+	next if(exists ($g_sclip{$chr}->{$pos}) && $g_sclip{$chr}->{$pos} eq $ort);
+	$cover_diff[$cover]++;
+	print $SOMATIC $line, "\n";
+}
+close($IN_D);
+close $SOMATIC;
+for( my $i = 1; $i < 1000; $i++) {
+	print join("\t", $i, $cover_D[$i], $cover_diff[$i]), "\n";
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crest.xml	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,536 @@
+<tool id="crest" name="CREST" version="1.0">
+ <description>Clipping reveals structural variations</description>
+ <requirements>
+  <requirement type="package">bioperl</requirement>
+  <requirement type="binary">gfServer</requirement>
+  <requirement type="binary">gfClient</requirement>
+  <requirement type="binary">cap</requirement>
+ </requirements>
+ <command> mkdir $crest_log.extra_files_path; cat $shscript > $crest_log.extra_files_path/crest.sh; /bin/bash $shscript &#38;> $crest_log</command>
+ <inputs>
+  <param name="tumor_bam" type="data" format="bam" label="Tumor Sample" 
+         help="BAM files must contain soft-clipping signatures at the breakpoints.  If they do not, you will not get any results."/>
+  <param name="germline_bam" type="data" format="bam" optional="true" label="Germline Sample" help=""/>
+  <conditional name="refGenomeSource">
+      <param name="genomeSource" type="select" label="&lt;HR&gt;Will you select a reference genome from your history or use a built-in index" help="">
+        <option value="indexed">Use a built-in index</option>
+        <option value="history">Use one from the history</option>
+      </param>
+      <when value="indexed">
+        <param name="genome_fasta" type="select" label="Select a Reference Dataset" help="if your genome of interest is not listed - contact Galaxy team">
+          <options from_file="crest.loc">
+            <column name="dbkey" index="0"/>
+            <column name="name" index="1"/>
+            <column name="value" index="2"/>
+            <filter type="data_meta" ref="tumor_bam" key="dbkey" column="0" />
+            <validator type="no_options" message="No indexes are available" />
+          </options>
+        </param>
+        <param name="genome_2bit" type="select" optional="true" label="The 2bit index" help="">
+          <options from_file="crest.loc">
+            <column name="dbkey" index="0"/>
+            <column name="name" index="1"/>
+            <column name="value" index="3"/>
+            <filter type="data_meta" ref="tumor_bam" key="dbkey" column="0" />
+          </options>
+        </param>
+      </when>
+      <when value="history">
+        <param name="genome_fasta" type="data" format="fasta" label="Genome Reference Sequence" help="Should match your input Tumor Sample BAM fie database">
+          <validator type="unspecified_build" message="Must assign a build"/>
+        </param>
+        <param name="genome_2bit" type="data" format="twobit" label="Genome Reference 2bit index (Choose same as Genome Reference Sequence)" help="">
+          <validator type="unspecified_build" message="Must assign a build"/>
+        </param>
+      </when>  <!-- history -->
+  </conditional>  <!-- refGenomeSource -->
+  <!-- Input Datasets -->
+  <conditional name="rnaseq">
+   <param name="mode" type="boolean" checked="false" truevalue="yes" falsevalue="no" label="&lt;HR&gt;RNAseq mode" 
+         help="Requires a gene model file"/>
+   <when value="no">
+   </when>
+   <when value="yes">
+    <param name="gene_model" type="data" format="bed" label="Gene model file" help="currently only refFlat format (BED) is supported"/>
+    <param name="cluster_size" type="integer" value="" optional="true" label="Cluster Size" 
+           help="The soft-clipped reads within cluster_size will be considered together, default is 3">
+      <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+   </when>
+  </conditional>
+  <!-- options -->
+  <param name="paired" type="boolean" checked="true" truevalue="" falsevalue="--nopaired" label="&lt;HR&gt;Paired Reads?"/>
+  <param name="read_len" type="integer" value="" optional="true" label="Read length of the sequencing data" 
+           help="The read length of the sequencing data, defaut 100">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+  </param>
+  <param name="sensitive" type="boolean" checked="false" truevalue="--sensitive" falsevalue="" label="&lt;HR&gt;Sensitive" 
+         help="The program will generate more SVs with higher false positive rate."/>
+  <param name="range" type="text" value="" optional="true" label="Limit Genome range where SV will be detected," 
+         help="The range where SV will be detected, using chr1:100-200 format">
+            <validator type="regex" message="format: chr1:100-200">^\w+(:\d+-\d+)?$</validator>
+  </param>
+  <conditional name="hit">
+   <param name="mode" type="select" label="&lt;HR&gt;Adjust Hit Detection">
+    <option value="no">Use defaults</option>
+    <option value="yes">Adjust Settings</option>
+   </param>
+   <when value="yes">
+    <param name="max_score_diff" type="integer" value="" optional="true" label="maximum score difference" 
+           help="The maximum score difference when stopping select hit, default 10.">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="min_sclip_reads" type="integer" value="" optional="true" label="Minimum number of soft clipping reads" 
+           help="Minimum number of soft clipping read to triger the procedure, default 3 (10 for RNASeq)">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="max_rep_cover" type="integer" value="" optional="true" label="Repetitive coverage threshold" 
+           help="The min number of coverage to be called as repetitive and don't triger the procedure, default 500 (5000 for RNASeq)">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="min_sclip_len" type="integer" value="" optional="true" label="Soft clipping detection" 
+           help="The min length of soft clipping part at a position to triger the detection, default 20.">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="min_hit_len" type="integer" value="" optional="true" label="Minimum length of a hit for genome mapping" 
+           help="">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="min_hit_reads" type="integer" value="" optional="true" label="Minimum read hits" 
+           help="Minimum number of reads in a hit. default 3 (10 for  RNASeq)">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="min_dist_diff" type="integer" value="" optional="true" label="Min distance between the mapped position and the soft clipping position" 
+           help="Min distance between the mapped position and the soft clipping position, default 20.">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+   </when>
+   <when value="no"/>
+  </conditional>
+  
+  <conditional name="softclip">
+   <param name="mode" type="select" label="&lt;HR&gt;Adjust Soft Clipping">
+    <option value="no">Use defaults</option>
+    <option value="yes">Adjust Settings</option>
+   </param>
+   <when value="yes">
+    <param name="min_percent_id" type="integer" value="" optional="true" label="Identity threshold for soft clipping read mapping" 
+           help="Min percentage of identity of soft clipping read mapping, default 90">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="min_percent_hq" type="integer" value="" optional="true" label="High quality bases threshold for soft clipping" 
+           help="Min percentage of high quality base in soft clipping reads, default 80">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="lowqual_cutoff" type="integer" value="" optional="true" label="Low quality cutoff" 
+           help="Low quality cutoff value, default 20.">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+   </when>
+   <when value="no"/>
+  </conditional>
+
+  <conditional name="sv_filter">
+   <param name="mode" type="select" label="&lt;HR&gt;Adjust Structural Variant Filtering">
+    <option value="no">Use defaults</option>
+    <option value="yes">Adjust Settings</option>
+   </param>
+   <when value="yes">
+    <param name="min_percent_cons_of_read" type="float" value="" optional="true" label="Relative consensus length threshold" 
+           help="Minimum percent of consensus length of read length, default 0.75">
+            <validator type="in_range" message="Must be greater than 0" min="0" max="1"/>
+    </param>
+    <param name="max_bp_dist" type="integer" value="" optional="true" label="Maximum distance between break points" 
+           help="Maximum distance in base pairs between two idenfitifed break points, default 15">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="germline_seq_width" type="integer" value="" optional="true" label="Germline SV filtering window" 
+           help="Half window width of genomic sequence around break point for germline SV filtering, default 100">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="germline_search_width" type="integer" value="" optional="true" label="Soft Clip Germline SV filtering window" 
+           help="Half window width for seaching soft-clipped reads around breakpoint for germline SV iltering, default 50">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+   </when>
+   <when value="no"/>
+  </conditional>
+
+  <conditional name="rescue">
+   <param name="mode" type="select" label="&lt;HR&gt;Rescue mode"
+          help="a SV with only 1 side with enough soft-clipped reads is considered as a valid one, default is ON.">
+    <option value="no">Rescue mode Off</option>
+    <option value="default" selected="true">Rescue On with default Setting</option>
+    <option value="yes">Adjust Rescue Settings</option>
+   </param>
+   <when value="yes">
+    <param name="min_one_side_reads" type="integer" value="" optional="true" label="Minimum number of soft-clipped reads on one side" 
+         help="the minimum number of soft-clipped reads on one side, default 5">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+   </when>
+   <when value="no"/>
+   <when value="default"/>
+  </conditional>
+
+  <conditional name="tandem_repeat">
+   <param name="mode" type="select" label="&lt;HR&gt;Tandem Repeats"
+          help="Remove tandem repeat caused SV events, default is ON.">
+    <option value="default" selected="true">Remove Tandem Repeats using default Setting</option>
+    <option value="yes">Remove Tandem Repeats with Adjusted Settings</option>
+    <option value="no">Keep Tandem Repeats</option>
+   </param>
+   <when value="yes">
+    <param name="tr_max_indel_size" type="integer" value="" optional="true" label="Maximum INDEL events" 
+         help="Maximum tandem repeat mediated INDEL events, default 100">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="tr_min_size" type="integer" value="" optional="true" label="Minimum tandem reapet size" 
+         help="Minimum tandem reapet size, default 2">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="tr_max_size" type="integer" value="" optional="true" label="Maximum tandem reapet size" 
+         help="Maximum tandem reapet size, default 8">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="tr_min_num" type="integer" value="" optional="true" label="Minimum tandem reapet number" 
+         help="Minimum tandem repeat number, defaut 4">
+            <validator type="in_range" message="Must be greater than 0" min="1"/>
+    </param>
+    <param name="hetero_factor" type="float" value="" optional="true" label="heterogenirity and heterozygosity factor" 
+           help="The factor about the SV's heterogenirity and heterozygosity, default 0.4">
+            <validator type="in_range" message="Must be greater than 0" min="0" max="1"/>
+    </param>
+    <param name="triger_p_value" type="float" value="" optional="true" label="heterogenirity and heterozygosity factor" 
+           help="The p-value that will triger the SV detection when number of soft-clipped reads is small, default 0.05">
+            <validator type="in_range" message="Must be greater than 0" min="0" max="1"/>
+    </param>
+   </when>
+   <when value="default"/>
+   <when value="no"/>
+  </conditional>
+ </inputs>
+ <outputs>
+  <data format="txt" name="crest_log" label="${tool.name} on ${on_string}: crest.log" />
+  <data format="tabular" name="tumor_cover" label="${tool.name} on ${on_string}: tumor.cover" from_work_dir="tumor.bam.cover"/>
+  <data format="tabular" name="tumor_sclip" label="${tool.name} on ${on_string}: tumor.sclip.txt" from_work_dir="tumor.bam.sclip.txt"/>
+  <data format="tabular" name="germline_cover" label="${tool.name} on ${on_string}: germline.cover" from_work_dir="germline.bam.cover">
+    <filter>germline_bam != None</filter>
+  </data>
+  <data format="tabular" name="germline_sclip" label="${tool.name} on ${on_string}: germline.sclip.txt" from_work_dir="germline.bam.sclip.txt">
+    <filter>germline_bam != None</filter>
+  </data>
+  <data format="tabular" name="predSV" label="${tool.name} on ${on_string}: tumor.predSV.txt" from_work_dir="tumor.bam.predSV.txt"/>
+  <data format="html" name="predSV_html" label="${tool.name} on ${on_string}: tumor.bam.predSV.html" />
+ </outputs>
+ <configfiles>
+  <configfile name="shscript"> #slurp
+#!/bin/bash
+## define some things for cheetah proccessing and to avoid problems with xml parsing of this tool_config
+#set $amp = chr(38)
+#set $ds = chr(36)
+#set $gt = chr(62)
+#set $lt = chr(60)
+#set $echo_cmd = 'echo'
+## Find the CREST.pl in the galaxy tool path
+#import Cheetah.FileUtils
+#set $toolpath = '/'.join([$__root_dir__,'tools','crest'])
+#set $crest = $Cheetah.FileUtils.findFiles($toolpath,['CREST.pl'],[],['example','Tree'])[0]
+#set $extractSClip = $Cheetah.FileUtils.findFiles($toolpath,['extractSClip.pl'],[],['example','Tree'])[0]
+#set $countDiff = $Cheetah.FileUtils.findFiles($toolpath,['countDiff.pl'],[],['example','Tree'])[0]
+#set $bam2html = $Cheetah.FileUtils.findFiles($toolpath,['bam2html.pl'],[],['example','Tree'])[0]
+## 
+## Need ptrfinder on path
+export PATH=${ds}PATH:$toolpath
+#raw
+## Set temp directory
+export TMPDIR=`pwd`/tmp
+mkdir -p $TMPDIR
+#end raw
+## check for the genome reference 2bit 
+if  [ ! -f $refGenomeSource.genome_2bit ]; then exit 1; fi
+## get the dbkey and use that in link name
+#set $dbkey = $tumor_bam.metadata.dbkey
+#set $ref_fa = '.'.join([$dbkey,'fa'])
+#set $ref_2bit = '.'.join([$dbkey,'2bit'])
+ref_fa=$ref_fa
+ref_2bit=$ref_2bit
+ln -s $refGenomeSource.genome_fasta $ref_fa
+ln -s $refGenomeSource.genome_2bit $ref_2bit
+target_genome=`pwd`/$ref_2bit
+## Problem - gfServer doesn't reserve the port until it's done reading genome, so another might try to open the same port
+#raw
+## start a local gfServer with the selected genome reference
+## find an open port on which to start a blat server via gfServer 
+for (( bp = 50000 + $$ % 1000; bp &lt; 60000; bp += 7 ))
+do
+   if ! netstat -an | grep $bp > /dev/null; then blatport=$bp; break; fi
+done
+## exit if can't open a port
+echo "Starting gfServer on port " $blatport
+#end raw
+( gfServer -canStop -log=gfServer.log start localhost ${ds}blatport ${ds}target_genome 2${gt} /dev/null ) ${amp}
+#raw
+(
+## symbolic link the tumor input bam annd bai files in our working directory
+#end raw
+ln -s $tumor_bam tumor.bam
+ln -s $tumor_bam.metadata.bam_index tumor.bam.bai
+## String value of an Optional DataToolParameter input is 'None' when not set
+#if $germline_bam.__str__ != 'None':
+#raw
+## symbolic link the germline input bam annd bai files in our working directory
+#end raw
+ln -s $germline_bam germline.bam
+ln -s $germline_bam.metadata.bam_index germline.bam.bai
+#end if
+#raw
+## Get soft-clipping positions.
+#end raw
+$echo_cmd perl -I $toolpath $extractSClip -i tumor.bam --ref_genome $ref_fa
+perl -I $toolpath $extractSClip -i tumor.bam --ref_genome $ref_fa
+##
+## If there is a germline input
+#if $germline_bam.__str__ != 'None':
+$echo_cmd perl -I $toolpath $extractSClip -i tumor.bam --ref_genome $ref_fa
+perl -I $toolpath $extractSClip -i tumor.bam --ref_genome $ref_fa
+#raw
+## Remove germline events (optional)
+#end raw
+$echo_cmd perl -I $toolpath  $countDiff -d tumor.bam.cover -g germline.bam.cover to  soft_clip.dist.txt
+perl -I $toolpath  $countDiff -d tumor.bam.cover -g germline.bam.cover $gt soft_clip.dist.txt
+#end if
+)
+## Running the SV detection script.
+## Determine the CREST options
+#set $crest_args = ["-f tumor.bam.cover -d tumor.bam"]
+##
+#if $germline_bam.__str__ != 'None':
+#set $crest_args = $crest_args + ["-g germline.bam"]
+#end if
+#set $crest_args = $crest_args + ["--ref_genome",$ref_fa]
+##
+#if $rnaseq.mode
+ #set $crest_args = $crest_args + ["--RNASeq","--genemodel",$rnaseq.gene_model.__str__]
+ #if $rnaseq.cluster_size.__str__ != '':
+  #set $crest_args = $crest_args + ["--cluster_size",$rnaseq.cluster_size.__str__]
+ #end if
+#end if
+##
+#if $paired.__str__ != '':
+ #set $crest_args = $crest_args + [$paired.__str__]
+#end if
+#if $sensitive.__str__ != '':
+ #set $crest_args = $crest_args + [$sensitive.__str__]
+#end if
+#if $range.__str__ != '':
+ #set $crest_args = $crest_args + ["-r",$range.__str__]
+#end if
+#if $read_len.__str__ != '':
+ #set $crest_args = $crest_args + ["-l",$read_len.__str__]
+#end if
+##
+#if $hit.mode.__str__ == 'yes':
+ #if $hit.max_score_diff.__str__ != '':
+  #set $crest_args = $crest_args + ["--max_score_diff", $hit.max_score_diff.__str__]
+ #end if
+ #if $hit.min_sclip_reads.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_sclip_reads",$hit.min_sclip_reads.__str__]
+ #end if
+ #if $hit.max_rep_cover.__str__ != '':
+  #set $crest_args = $crest_args + ["--max_rep_cover",$hit.max_rep_cover.__str__]
+ #end if
+ #if $hit.min_sclip_len.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_sclip_len",$hit.min_sclip_len.__str__]
+ #end if
+ #if $hit.min_hit_len.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_hit_len",$hit.min_hit_len.__str__]
+ #end if
+ #if $hit.min_hit_reads.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_hit_reads",$hit.min_hit_reads.__str__]
+ #end if
+ #if $hit.min_dist_diff.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_dist_diff",$hit.min_dist_diff.__str__]
+ #end if
+#end if
+##
+#if $softclip.mode.__str__ == 'yes':
+ #if $softclip.min_percent_id.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_percent_id",$softclip.min_percent_id.__str__]
+ #end if
+ #if $softclip.min_percent_hq.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_percent_hq",$softclip.min_percent_hq.__str__]
+ #end if
+ #if $softclip.lowqual_cutoff.__str__ != '':
+  #set $crest_args = $crest_args + ["--lowqual_cutoff",$softclip.lowqual_cutoff.__str__]
+ #end if
+#end if
+##
+#if $sv_filter.mode.__str__ == 'yes':
+ #if $sv_filter.min_percent_cons_of_read.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_percent_cons_of_read",$sv_filter.min_percent_cons_of_read.__str__]
+ #end if
+ #if $sv_filter.max_bp_dist.__str__ != '':
+  #set $crest_args = $crest_args + ["--max_bp_dist",$sv_filter.max_bp_dist.__str__]
+ #end if
+ #if $sv_filter.germline_seq_width.__str__ != '':
+  #set $crest_args = $crest_args + ["--germline_seq_width",$sv_filter.germline_seq_width.__str__]
+ #end if
+ #if $sv_filter.germline_search_width.__str__ != '':
+  #set $crest_args = $crest_args + ["--germline_search_width",$sv_filter.germline_search_width.__str__]
+ #end if
+#end if
+##
+#if $rescue.mode.__str__ == 'yes':
+ #if $rescue.min_one_side_reads.__str__ != '':
+  #set $crest_args = $crest_args + ["--min_one_side_reads",$rescue.min_one_side_reads.__str__]
+ #end if
+#elif $rescue.mode.__str__ == 'no':
+  #set $crest_args = $crest_args + ["--norescue"]
+#end if
+##
+#if $tandem_repeat.mode.__str__ == 'yes':
+ #if $tandem_repeat.tr_max_indel_size.__str__ != '':
+  #set $crest_args = $crest_args + ["--tr_max_indel_size",$tandem_repeat.tr_max_indel_size.__str__]
+ #end if
+ #if $tandem_repeat.tr_min_size.__str__ != '':
+  #set $crest_args = $crest_args + ["--tr_min_size",$tandem_repeat.tr_min_size.__str__]
+ #end if
+ #if $tandem_repeat.tr_max_size.__str__ != '':
+  #set $crest_args = $crest_args + ["--tr_max_size",$tandem_repeat.tr_max_size.__str__]
+ #end if
+ #if $tandem_repeat.tr_min_num.__str__ != '':
+  #set $crest_args = $crest_args + ["--tr_min_num",$tandem_repeat.tr_min_num.__str__]
+ #end if
+ #if $tandem_repeat.hetero_factor.__str__ != '':
+  #set $crest_args = $crest_args + ["--hetero_factor",$tandem_repeat.hetero_factor.__str__]
+ #end if
+ #if $tandem_repeat.triger_p_value.__str__ != '':
+  #set $crest_args = $crest_args + ["--triger_p_value",$tandem_repeat.triger_p_value.__str__]
+ #end if
+#elif $tandem_repeat.mode.__str__ == 'no':
+  #set $crest_args = $crest_args + ["--norm_tandem_repeat"]
+#end if
+#raw
+## check if gfServer is ready
+echo "Waiting for gfServer"
+for (( tries = 0; tries &lt; 30; tries += 1 ))
+do
+  if ! netstat -an | grep $blatport > /dev/null &#38;&#38; ps -f | grep gfServer | grep $blatport > /dev/null; then sleep 60; else break; fi
+done
+#end raw
+#raw
+## Run CREST 
+#end raw
+(
+## perl -I ~/src/crest ../CREST.pl -f tumor.bam.cover -d tumor.bam -g germline.bam --ref_genome hg18.fa --2bitdir=/home/msi/jj/src/crest/example --target_genome=hg18.2bit --blatserver localhost --blatport 50000
+$echo_cmd perl -I $toolpath $crest #echo ' '.join($crest_args)# --target_genome ${ds}target_genome --blatserver localhost --blatport ${ds}blatport 
+perl -I $toolpath $crest #echo ' '.join($crest_args)# --target_genome ${ds}target_genome --blatserver localhost --blatport ${ds}blatport
+#raw
+## Visulization of the detailed alignment at breakpoint (optional)
+## The bam2html.pl script builds an html view of the multiple alignment for the breakpoint, so you can manually check the soft-clipping and other things.
+#end raw
+## bam2html.pl -r hg18.fa -d tumor.bam -g germline.bam -o predSV.html -f predSV.txt
+if [ -e tumor.bam.predSV.txt ]
+then
+#if $germline_bam.__str__ != 'None':
+perl -I $toolpath $bam2html -d tumor.bam -g germline.bam -f tumor.bam.predSV.txt --ref_genome $ref_fa -o $predSV_html
+#else
+perl -I $toolpath $bam2html -d tumor.bam -f tumor.bam.predSV.txt --ref_genome $ref_fa -o $predSV_html
+#end if
+fi
+)
+#raw
+## shut down the blat server
+echo "shutting down gfServer on port " $blatport
+gfServer stop localhost $blatport
+#end raw
+  </configfile>
+ </configfiles>
+ <tests>
+ </tests>
+ <help>
+**CREST**
+
+CREST_ is an algorithm for detecting genomic structural variations at base-pair resolution using next-generation sequencing data.  '
+
+CREST uses pieces of DNA called soft clips to find structural variations.  Soft clips are the DNA segments produced during sequencing that fail to properly align to the reference genome as the sample genome is reassembled.  CREST uses the soft clips to precisely identify sites of chromosomal rearrangement or where pieces of DNA are inserted or deleted.
+
+Please cite the following article:
+
+Wang J, Mullighan CG, Easton J, Roberts S, Heatley SL, Ma J, Rusch MC, Chen K, Harris CC, Ding L, Holmfeldt L, Payne-Turner D, Fan X, Wei L, Zhao D, Obenauer JC, Naeve C, Mardis ER, Wilson RK, Downing JR and Zhang J. CREST maps somatic structural variation in cancer genomes with base-pair resolution (2011). Nature_Methods_.
+
+.. _Nature_Methods: http://www.nature.com/nmeth/journal/v8/n8/pdf/nmeth.1628.pdf
+.. _CREST: http://www.stjuderesearch.org/site/lab/zhang
+
+
+----
+
+**Input formats**
+
+BAM files that must contain soft-clipping signatures at the breakpoints.  If
+they do not, you will not get any results.  
+
+CREST uses soft-clipping signatures to identify breakpoints.  Soft-clipping is
+indicated by "S" elements in the CIGAR for SAM/BAM records.  Soft-clipping may
+not occur, depending on the mapping algorithm and parameters and sometimes even
+the library preparation.
+
+With bwa sampe:
+
+One mapping method that will soft-clip reads is bwa sampe (BWA for paired-end
+reads).  When BWA successfully maps one read in a pair but is not able to map
+the other, it will attempt a more permissive Smith-Waterman alignment of the
+unmapped read in the neighborhood of the mapped mate.  If it is only able to
+align part of the read, then it will soft-clip the portion on the end that it
+could not align.  Often this occurs at the breakpoints of structural
+variations.
+
+In some cases when the insert sizes approach the read length, BWA will not
+perform Smith-Waterman alignment.  Reads from inserts smaller than the read
+length will contain primer and/or adapter and will often not map.  When the
+insert size is close to the read length, this creates a skewed distribution
+of inferred insert sizes which may cause BWA to not attempt Smith-Waterman
+realignment.  This is indicated by the error message "weird pairing".  Often
+in these cases there are also unusually low mapping rates.
+
+One way to fix this problem is to remap unmapped reads bwasw.  To do this,
+extract the unmapped reads as FASTQ files (this may be done with a combination
+of samtools view -f 4 and Picard's SamToFastq).  Realign using bwa bwasw and
+build a BAM file.  Then, re-run CREST on this new BAM file, and you may pick
+up events that would have been missed otherwise.
+
+
+
+
+------
+
+**Outputs**
+
+The output
+file *.predSV.txt has the following tab-delimited columns: left_chr, left_pos,
+left_strand, # of left soft-clipped reads, right_chr, right_pos, right_strand,
+# right soft-clipped reads, SV type, coverage at left_pos, coverage at
+right_pos, assembled length at left_pos, assembled length at right_pos,
+average percent identity at left_pos, percent of non-unique mapping reads at
+left_pos, average percent identity at right_pos, percent of non-unique mapping
+reads at right_pos, start position of consensus mapping to genome,
+starting chromosome of consensus mapping, position of the genomic mapping of
+consensus starting position, end position of consensus mapping to genome,
+ending chromsome of consnesus mapping, position of genomic mapping of
+consensus ending posiiton, and consensus sequences.  For inversion(INV), the
+last 7 fields will be repeated to reflect the fact two different breakpoints
+are needed to identify an INV event.
+
+Example of the tumor.predSV.txt file:
+
+4       125893227       +       5       10      66301858        -       4       CTX     29      14      83      71      0.895173453996983       0.230769230769231       0.735384615384615       0.5     1       4       125893135       176     10      66301773        TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTTCAGTAGCTGTCACCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT
+5       7052198 -       0       10      66301865        +       8       CTX     0       22      0       81      0.761379310344828       0.482758620689655       0       0       1       5       7052278 164     10      66301947        AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCAGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTCAAAAAAAAAAAGTGGGAAGAGG
+10      66301858        +       4       4       125893225       -       1       CTX     15      28      71      81      0.735384615384615       0.5     0.889507154213037       0.243243243243243       1       10      66301777        153     4       125893154       TTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA
+
+If there are no or very few results, there may be a lack of soft-clipping. 
+
+
+
+ </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/enum.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,387 @@
+package enum;
+use strict;
+no strict 'refs';  # Let's just make this very clear right off
+
+use Carp;
+use vars qw($VERSION);
+$VERSION = do { my @r = (q$Revision: 1.16 $ =~ /\d+/g); sprintf '%d.%03d'.'%02d' x ($#r-1), @r};
+
+my $Ident = '[^\W_0-9]\w*';
+
+sub ENUM    () { 1 }
+sub BITMASK () { 2 }
+
+sub import {
+    my $class   = shift;
+    @_ or return;       # Ignore 'use enum;'
+    my $pkg     = caller() . '::';
+    my $prefix  = '';   # default no prefix 
+    my $index   = 0;    # default start index
+    my $mode    = ENUM; # default to enum
+
+    ## Pragmas should be as fast as they can be, so we inline some
+    ## pieces.
+    foreach (@_) {
+        ## Plain tag is most common case
+        if (/^$Ident$/o) {
+            my $n = $index;
+
+            if ($mode == ENUM) {
+                $index++;
+            }
+            elsif ($mode == BITMASK) {
+                $index ||= 1;
+                $index *= 2;
+                if ( $index & ($index - 1) ) {
+                    croak (
+                        "$index is not a valid single bitmask "
+                        . " (Maybe you overflowed your system's max int value?)"
+                    );
+                }
+            }
+            else {
+                confess qq(Can't Happen: mode $mode invalid);
+            }
+
+            *{"$pkg$prefix$_"} = sub () { $n };
+        }
+
+        ## Index change
+        elsif (/^($Ident)=(-?)(.+)$/o) {
+            my $name= $1;
+            my $neg = $2;
+            $index  = $3;
+
+            ## Convert non-decimal numerics to decimal
+            if ($index =~ /^0x[\da-f]+$/i) {    ## Hex
+                $index = hex $index;
+            }
+            elsif ($index =~ /^0\d/) {          ## Octal
+                $index = oct $index;
+            }
+            elsif ($index !~ /[^\d_]/) {        ## 123_456 notation
+                $index =~ s/_//g;
+            }
+
+            ## Force numeric context, but only in numeric context
+            if ($index =~ /\D/) {
+                $index  = "$neg$index";
+            }
+            else {
+                $index  = "$neg$index";
+                $index  += 0;
+            }
+
+            my $n   = $index;
+
+            if ($mode == BITMASK) {
+                ($index & ($index - 1))
+                    and croak "$index is not a valid single bitmask";
+                $index *= 2;
+            }
+            elsif ($mode == ENUM) {
+                $index++;
+            }
+            else {
+                confess qq(Can't Happen: mode $mode invalid);
+            }
+
+            *{"$pkg$prefix$name"} = sub () { $n };
+        }
+
+        ## Prefix/option change
+        elsif (/^([A-Z]*):($Ident)?(=?)(-?)(.*)/) {
+            ## Option change
+            if ($1) {
+                if      ($1 eq 'ENUM')      { $mode = ENUM;     $index = 0 }
+                elsif   ($1 eq 'BITMASK')   { $mode = BITMASK;  $index = 1 }
+                else    { croak qq(Invalid enum option '$1') }
+            }
+
+            my $neg = $4;
+
+            ## Index change too?
+            if ($3) {
+                if (length $5) {
+                    $index = $5;
+
+                    ## Convert non-decimal numerics to decimal
+                    if ($index =~ /^0x[\da-f]+$/i) {    ## Hex
+                        $index = hex $index;
+                    }
+                    elsif ($index =~ /^0\d/) {          ## Oct
+                        $index = oct $index;
+                    }
+                    elsif ($index !~ /[^\d_]/) {        ## 123_456 notation
+                        $index =~ s/_//g;
+                    }
+
+                    ## Force numeric context, but only in numeric context
+                    if ($index =~ /\D/) {
+                        $index  = "$neg$index";
+                    }
+                    else {
+                        $index  = "$neg$index";
+                        $index  += 0;
+                    }
+
+                    ## Bitmask mode must check index changes
+                    if ($mode == BITMASK) {
+                        ($index & ($index - 1))
+                            and croak "$index is not a valid single bitmask";
+                    }
+                }
+                else {
+                    croak qq(No index value defined after "=");
+                }
+            }
+
+            ## Incase it's a null prefix
+            $prefix = defined $2 ? $2 : '';
+        }
+
+        ## A..Z case magic lists
+        elsif (/^($Ident)\.\.($Ident)$/o) {
+            ## Almost never used, so check last
+            foreach my $name ("$1" .. "$2") {
+                my $n = $index;
+
+                if ($mode == BITMASK) {
+                    ($index & ($index - 1))
+                        and croak "$index is not a valid single bitmask";
+                    $index *= 2;
+                }
+                elsif ($mode == ENUM) {
+                    $index++;
+                }
+                else {
+                    confess qq(Can't Happen: mode $mode invalid);
+                }
+
+                *{"$pkg$prefix$name"} = sub () { $n };
+            }
+        }
+
+        else {
+            croak qq(Can't define "$_" as enum type (name contains invalid characters));
+        }
+    }
+}
+
+1;
+
+__END__
+
+
+=head1 NAME
+
+enum - C style enumerated types and bitmask flags in Perl
+
+=head1 SYNOPSIS
+
+  use enum qw(Sun Mon Tue Wed Thu Fri Sat);
+  # Sun == 0, Mon == 1, etc
+
+  use enum qw(Forty=40 FortyOne Five=5 Six Seven);
+  # Yes, you can change the start indexs at any time as in C
+
+  use enum qw(:Prefix_ One Two Three);
+  ## Creates Prefix_One, Prefix_Two, Prefix_Three
+
+  use enum qw(:Letters_ A..Z);
+  ## Creates Letters_A, Letters_B, Letters_C, ...
+
+  use enum qw(
+      :Months_=0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
+      :Days_=0   Sun Mon Tue Wed Thu Fri Sat
+      :Letters_=20 A..Z
+  );
+  ## Prefixes can be changed mid list and can have index changes too
+
+  use enum qw(BITMASK:LOCK_ SH EX NB UN);
+  ## Creates bitmask constants for LOCK_SH == 1, LOCK_EX == 2,
+  ## LOCK_NB == 4, and LOCK_UN == 8.
+  ## NOTE: This example is only valid on FreeBSD-2.2.5 however, so don't
+  ## actually do this.  Import from Fnctl instead.
+
+=head1 DESCRIPTION
+
+Defines a set of symbolic constants with ordered numeric values ala B<C> B<enum> types.
+
+Now capable of creating creating ordered bitmask constants as well.  See the B<BITMASKS>
+section for details.
+
+What are they good for?  Typical uses would be for giving mnemonic names to indexes of
+arrays.  Such arrays might be a list of months, days, or a return value index from
+a function such as localtime():
+
+  use enum qw(
+      :Months_=0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
+      :Days_=0   Sun Mon Tue Wed Thu Fri Sat
+      :LC_=0     Sec Min Hour MDay Mon Year WDay YDay Isdst
+  );
+
+  if ((localtime)[LC_Mon] == Months_Jan) {
+      print "It's January!\n";
+  }
+  if ((localtime)[LC_WDay] == Days_Fri) {
+      print "It's Friday!\n";
+  }
+
+This not only reads easier, but can also be typo-checked at compile time when
+run under B<use strict>.  That is, if you misspell B<Days_Fri> as B<Days_Fry>,
+you'll generate a compile error.
+
+=head1 BITMASKS, bitwise operations, and bitmask option values
+
+The B<BITMASK> option allows the easy creation of bitmask constants such as
+functions like flock() and sysopen() use.  These are also very useful for your
+own code as they allow you to efficiently store many true/false options within
+a single integer.
+
+    use enum qw(BITMASK: MY_ FOO BAR CAT DOG);
+
+    my $foo = 0;
+    $foo |= MY_FOO;
+    $foo |= MY_DOG;
+    
+    if ($foo & MY_DOG) {
+        print "foo has the MY_DOG option set\n";
+    }
+    if ($foo & (MY_BAR | MY_DOG)) {
+        print "foo has either the MY_BAR or MY_DOG option set\n"
+    }
+
+    $foo ^= MY_DOG;  ## Turn MY_DOG option off (set its bit to false)
+
+When using bitmasks, remember that you must use the bitwise operators, B<|>, B<&>, B<^>,
+and B<~>.  If you try to do an operation like C<$foo += MY_DOG;> and the B<MY_DOG> bit
+has already been set, you'll end up setting other bits you probably didn't want to set.
+You'll find the documentation for these operators in the B<perlop> manpage.
+
+You can set a starting index for bitmasks just as you can for normal B<enum> values,
+but if the given index isn't a power of 2 it won't resolve to a single bit and therefor
+will generate a compile error.  Because of this, whenever you set the B<BITFIELD:>
+directive, the index is automatically set to 1.  If you wish to go back to normal B<enum>
+mode, use the B<ENUM:> directive.  Similarly to the B<BITFIELD> directive, the B<ENUM:>
+directive resets the index to 0.  Here's an example:
+
+  use enum qw(
+      BITMASK:BITS_ FOO BAR CAT DOG
+      ENUM: FALSE TRUE
+      ENUM: NO YES
+      BITMASK: ONE TWO FOUR EIGHT SIX_TEEN
+  );
+
+In this case, B<BITS_FOO, BITS_BAR, BITS_CAT, and BITS_DOG> equal 1, 2, 4 and
+8 respectively.  B<FALSE and TRUE> equal 0 and 1.  B<NO and YES> also equal
+0 and 1.  And B<ONE, TWO, FOUR, EIGHT, and SIX_TEEN> equal, you guessed it, 1,
+2, 4, 8, and 16.
+
+=head1 BUGS
+
+Enum names can not be the same as method, function, or constant names.  This
+is probably a Good Thing[tm].
+
+No way (that I know of) to cause compile time errors when one of these enum names get
+redefined.  IMHO, there is absolutely no time when redefining a sub is a Good Thing[tm],
+and should be taken out of the language, or at least have a pragma that can cause it
+to be a compile time error.
+
+Enumerated types are package scoped just like constants, not block scoped as some
+other pragma modules are.
+
+It supports A..Z nonsense.  Can anyone give me a Real World[tm] reason why anyone would
+ever use this feature...?
+
+=head1 HISTORY
+
+  $Log: enum.pm,v $
+  Revision 1.16  1999/05/27 16:00:35  byron
+
+
+  Fixed bug that caused bitwise operators to treat enum types as strings
+  instead of numbers.
+
+  Revision 1.15  1999/05/27 15:51:27  byron
+
+
+  Add support for negative values.
+
+  Added stricter hex value checks.
+
+  Revision 1.14  1999/05/13 15:58:18  byron
+
+
+  Fixed bug in hex index code that broke on 0xA.
+
+  Revision 1.13  1999/05/13 10:52:30  byron
+
+
+  Fixed auto-index bugs in new non-decimal numeric support.
+
+  Revision 1.12  1999/05/13 10:00:45  byron
+
+
+  Added support for non-decimal numeric representations ala 0x123, 0644, and
+  123_456.
+
+  First version committed to CVS.
+
+
+  Revision 1.11  1998/07/18 17:53:05  byron
+    -Added BITMASK and ENUM directives.
+    -Revamped documentation.
+
+  Revision 1.10  1998/06/12 20:12:50  byron
+    -Removed test code
+    -Released to CPAN
+
+  Revision 1.9  1998/06/12 00:21:00  byron
+    -Fixed -w warning when a null tag is used
+
+  Revision 1.8  1998/06/11 23:04:53  byron
+    -Fixed documentation bugs
+    -Moved A..Z case to last as it's not going to be used
+     as much as the other cases.
+
+  Revision 1.7  1998/06/10 12:25:04  byron
+    -Changed interface to match original design by Tom Phoenix
+     as implemented in an early version of enum.pm by Benjamin Holzman.
+    -Changed tag syntax to not require the 'PREFIX' string of Tom's
+     interface.
+    -Allow multiple prefix tags to be used at any point.
+    -Allowed index value changes from tags.
+
+  Revision 1.6  1998/06/10 03:37:57  byron
+    -Fixed superfulous -w warning
+
+  Revision 1.4  1998/06/10 01:07:03  byron
+    -Changed behaver to closer resemble C enum types
+    -Changed docs to match new behaver
+
+=head1 AUTHOR
+
+Zenin <zenin@archive.rhps.org>
+
+aka Byron Brummer <byron@omix.com>.
+
+Based off of the B<constant> module by Tom Phoenix.
+
+Original implementation of an interface of Tom Phoenix's
+design by Benjamin Holzman, for which we borrow the basic
+parse algorithm layout.
+
+=head1 COPYRIGHT
+
+Copyright 1998 (c) Byron Brummer.
+Copyright 1998 (c) OMIX, Inc.
+
+Permission to use, modify, and redistribute this module granted under
+the same terms as B<Perl>.
+
+=head1 SEE ALSO
+
+constant(3), perl(1).
+
+=cut
Binary file example/germline.bam has changed
Binary file example/germline.bam.bai has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/germline.cover	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,2 @@
+4	125892484	+	1	17
+4	125894262	+	2	11
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/germline.sclip.txt	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,3 @@
+4	125892484	+	HWUSI-EAS729_614T6:6:61:16691:2909#0	A	C
+4	125894262	+	HWUSI-EAS1543_614TM:1:62:2828:15248#0	AA	CC
+4	125894262	+	HWUSI-EAS729_614T6:3:68:9882:5425#0	AAAGAGTT	CCCCCCCC
Binary file example/tumor.bam has changed
Binary file example/tumor.bam.bai has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/tumor.cover	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,11 @@
+4	125892327	+	1	30
+4	125892458	+	1	27
+4	125893225	+	1	28
+4	125893227	+	5	29
+4	125893365	-	1	26
+4	125893979	-	1	16
+10	66301086	-	2	33
+10	66301858	+	4	15
+10	66301865	-	9	22
+10	66301871	-	1	24
+10	66302136	+	1	51
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/tumor.cover.somatic.cover	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,11 @@
+4	125892327	+	1	30
+4	125892458	+	1	27
+4	125893225	+	1	28
+4	125893227	+	5	29
+4	125893365	-	1	26
+4	125893979	-	1	16
+10	66301086	-	2	33
+10	66301858	+	4	15
+10	66301865	-	9	22
+10	66301871	-	1	24
+10	66302136	+	1	51
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/tumor.predSV.html	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,379 @@
+<h3 style="color:blue;text-align:center">4	125893227	+	5	10	66301858	-	4	CTX	29	14	83	71	0.895173453996983	0.230769230769231	0.735384615384615	0.5	1	4	125893135	176	10	66301773	TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTTCAGTAGCTGTCACCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT</h3>
+<pre>
+                                                125893140           125893160           125893180           125893200            125893220           125893240            125893260           125893280           125893300           125893320  
+                                          .         |         .         |         .         |         .         |         .          |         .         |         .          |         .         |         .         |         .         |      
+4:125893129-125893326                    CTAAAATTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT*CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC*TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGCATCAAAATTTTAAAATATCCCTT
+                                                                                                                                                                                                                                                 
+HWI-EAS90_614M9:6:67:12631:17754#0     + <font color="#000000">CTAAAATTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACT</font>
+HWUSI-EAS1591_6113C:4:21:6779:18838#0  + <font color="#000000">CTAAAATTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACT</font>
+HWI-EAS90_614M9:1:32:10389:16117#0     +             <font color="#C0C0C0">atttt</font><font color="#000000">GAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">C</font><font color="#C0C0C0">agtagctgtcactgtaggcaaaaat</font>
+HWUSI-EAS1591_6113C:2:27:1355:21017#0  +             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGC</font><font color="#C0C0C0">aa</font><font color="#800000">c</font><font color="#C0C0C0">aat</font>
+HWUSI-EAS1591_6113C:1:93:16865:6051#0  +                   <font color="#000000">AAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCAT</font>
+HWI-EAS90_614M9:3:78:1961:11755#0      +                           <font color="#000000">ATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAA</font><font color="#C0C0C0">a</font><font color="#000000">AA</font><font color="#C0C0C0">t</font><font color="#000000">GCCCA</font><font color="#C0C0C0">t</font><font color="#000000">TATTC</font><font color="#FF8040">*</font><font color="#000000">TGC</font>
+HWI-EAS231_614TA:5:6:17800:6620#0      +                                  <font color="#000000">TTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATAT</font>
+<b><i>HWI-EAS90_614M9:3:95:10317:10581#0     +                                          <font color="#000000">ATATATCATATTCTAAATTATGAAAAGAGAATATGA</font><font color="#FF8040">*</font><font color="#000000">T</font><font color="#C0C0C0">ctctttt</font><font color="#FF8040">c</font><font color="#C0C0C0">cag</font><font color="#FF8040">*</font><font color="#C0C0C0">agc</font><font color="#800000">c</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">c</font><font color="#800000">c</font><font color="#C0C0C0">c</font><font color="#800000">c</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">a</font><font color="#800000">a</font><font color="#C0C0C0">gc</font><font color="#800000">c</font><font color="#C0C0C0">aaaa</font><font color="#800000">a</font><font color="#C0C0C0">gccc</font><font color="#800000">c</font><font color="#C0C0C0">ttattc</font><font color="#FF8040">t</font><font color="#C0C0C0">t</font><font color="#800000">c</font><font color="#C0C0C0">ctaa</font><font color="#800000">t</font><font color="#C0C0C0">tatcta</font><font color="#6960EC">gggga</font></i></b>
+<b><i>HWI-EAS292_102081428:2:115:1681:2531#0 +                                                        <font color="#C0C0C0">aaattatgaaaagagaatatgattctctttt</font><font color="#FF8040">*</font><font color="#800000">t</font><font color="#C0C0C0">ag</font><font color="#800000">g</font><font color="#C0C0C0">agctgt</font><font color="#800000">t</font><font color="#C0C0C0">ac</font><font color="#6960EC">tgtagggaaaaatgcccattattctgctaaatatctaagtgaggggtgcttctatt</font></i></b>
+HWI-EAS90_614M9:1:67:1331:13704#0      +                                                                       <font color="#000000">AATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATA</font>
+HWI-EAS231_614TA:2:73:4389:2239#0      +                                                                           <font color="#000000">TGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAG</font>
+HWI-EAS231_614TA:7:88:14296:6002#0     +                                                                           <font color="#000000">TGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAG</font>
+HWI-EAS231_614TA:1:26:7960:13504#0     +                                                                              <font color="#000000">TTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">T</font>
+HWI-EAS90_614M9:7:18:13917:3050#0      +                                                                                <font color="#000000">CTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCA</font>
+HWI-EAS292_102081428:1:66:16549:20224#0+                                                                                 <font color="#000000">TCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">T</font><font color="#C0C0C0">g</font><font color="#000000">CTAAATATCTAAGTGATGCTTGCTACTATTAACTG</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">t</font><font color="#000000">GTAT</font><font color="#C0C0C0">a</font><font color="#000000">TACTAGC</font><font color="#800000">G</font><font color="#000000">TCAA</font>
+HWI-EAS90_614M9:5:77:4642:6832#0       +                                                                                  <font color="#000000">CTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATT</font><font color="#C0C0C0">a</font><font color="#000000">ACTGAATGTATATACTAGC</font><font color="#800000">g</font><font color="#C0C0C0">tcaaa</font>
+HWI-EAS90_614M9:8:34:7077:4638#0       +                                                                                  <font color="#000000">CTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAA</font>
+HWI-EAS231_614TA:2:33:16646:21114#0    +                                                                                                    <font color="#000000">CTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAA</font><font color="#C0C0C0">ttttaaaatatccctt</font>
+<b><i>HWUSI-EAS1591_6113C:4:9:4513:12290#0   -       <font color="#000000">TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCAC</font><font color="#6960EC">CTCCTGG</font></i></b>
+HWI-EAS231_614TA:7:49:16816:4213#0     -        <font color="#000000">TATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCA</font>
+HWI-EAS231_614TA:1:118:16290:13237#0   -             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAAT</font>
+HWI-EAS231_614TA:6:113:8101:10568#0    -              <font color="#000000">TTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATG</font>
+HWI-EAS90_614M9:6:48:8352:11907#0      -                       <font color="#000000">ATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATT</font>
+<b><i>HWUSI-EAS1591_6113C:4:39:14328:11130#0 -                         <font color="#000000">ATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCAC</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTG</font></i></b>
+<b><i>HWI-EAS90_614M9:1:85:18838:8742#0      -                                  <font color="#000000">TTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCAC</font><font color="#6960EC">CTCCtgggttcaggTGATTCTCCTGCCTCTACCT</font></i></b>
+<b><i>HWI-EAS90_614M9:4:32:9763:4986#0       -                                  <font color="#000000">TTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTC</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCT</font></i></b>
+HWI-EAS231_614TA:4:103:18855:9257#0    -                                        <font color="#000000">ATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGT</font>
+HWI-EAS292_102081428:2:23:3944:1922#0  -                                        <font color="#C0C0C0">a</font><font color="#000000">TA</font><font color="#C0C0C0">ta</font><font color="#800000">G</font><font color="#000000">ATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGT</font>
+<b><i>HWUSI-EAS1591_6113C:2:117:3095:2051#0  -                                                                                <font color="#000000">CTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAG</font><font color="#C0C0C0">tagctgt</font><font color="#000000">C</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAAT</font></i></b>
+HWI-EAS90_614M9:5:28:11006:5910#0      -                                                                                 <font color="#000000">TCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAA</font>
+<b><i>HWI-EAS90_614M9:5:1:12903:5535#0       -                                                                                   <font color="#000000">TTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTA</font><font color="#C0C0C0">g</font><font color="#000000">CTGTCAC</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT</font></i></b>
+HWI-EAS90_614M9:2:56:9827:2778#0       -                                                                                                 <font color="#C0C0C0">tcactgta</font><font color="#000000">GGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWI-EAS90_614M9:4:47:5786:19724#0      -                                                                                                 <font color="#C0C0C0">tcact</font><font color="#000000">GTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWI-EAS90_614M9:6:67:11670:7706#0      -                                                                                                 <font color="#000000">TCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWUSI-EAS1591_6113C:1:117:14883:9756#0 -                                                                                                 <font color="#000000">TCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWI-EAS90_614M9:6:37:7790:16256#0      -                                                                                                  <font color="#000000">CACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCCC</font>
+HWUSI-EAS1591_6113C:4:38:15097:15951#0 -                                                                                                   <font color="#000000">ACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCCCT</font>
+_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+HWUSI-EAS729_614T6:8:86:3208:16885#0   +       <font color="#000000">TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGC</font>
+HWUSI-EAS729_614T6:3:97:10823:18653#0  +         <font color="#000000">ATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAA</font>
+HWUSI-EAS729_614T6:4:113:3054:5730#0   +          <font color="#000000">TGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAG</font><font color="#C0C0C0">gcaa</font><font color="#800000">g</font>
+HWUSI-EAS729_614T6:2:63:5049:3137#0    +            <font color="#000000">AATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAA</font>
+HWUSI-EAS729_614T6:5:95:4777:9034#0    +            <font color="#000000">AATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAA</font>
+HWUSI-EAS729_614T6:8:79:9632:17904#0   +            <font color="#000000">AATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAA</font>
+HWUSI-EAS1543_614TM:8:50:14524:11101#0 +             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAAT</font>
+HWUSI-EAS729_614T6:3:79:10477:10666#0  +                <font color="#000000">TTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCC</font>
+HWUSI-EAS729_614T6:4:80:3846:17138#0   +                <font color="#000000">TTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCC</font>
+HWUSI-EAS729_614T6:4:83:3398:15440#0   +                <font color="#000000">TTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCC</font>
+HWUSI-EAS729_614T6:5:37:19001:5491#0   +                 <font color="#000000">TGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCC</font>
+HWUSI-EAS729_614T6:8:113:1681:2586#0   +                            <font color="#000000">TCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCT</font>
+HWUSI-EAS729_614T6:8:3:18130:10917#0   +                               <font color="#000000">TATTTTGAAATATATATCATAT</font><font color="#C0C0C0">t</font><font color="#000000">CTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAA</font>
+HWUSI-EAS729_614T6:7:32:3784:11386#0   +                                    <font color="#000000">TGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCT</font>
+HWUSI-EAS729_614T6:7:117:8731:4955#0   +                                          <font color="#000000">ATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGA</font>
+HWUSI-EAS729_614T6:8:51:17611:11416#0  +                                           <font color="#000000">TATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGAT</font>
+HWUSI-EAS1543_614TM:1:102:4785:3367#0  +                                                  <font color="#000000">TATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCT</font>
+HWUSI-EAS1543_614TM:6:60:2952:14857#0  +                                                  <font color="#000000">TATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCT</font>
+HWUSI-EAS729_614T6:5:55:11097:17856#0  +                                                             <font color="#000000">ATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTG</font>
+HWUSI-EAS729_614T6:2:8:16102:20401#0   +                                                                <font color="#000000">AAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAAT</font>
+HWUSI-EAS1543_614TM:1:75:3691:5075#0   +                                                                            <font color="#000000">GATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font>
+HWUSI-EAS729_614T6:8:52:15200:10784#0  +                                                                                                  <font color="#000000">CACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGCATCAAA</font><font color="#C0C0C0">att</font><font color="#800000">n</font><font color="#C0C0C0">t</font><font color="#000000">AAAATATCCC</font>
+HWUSI-EAS1543_614TM:7:17:14845:19479#0 -             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATAT</font><font color="#800000">A</font><font color="#000000">ATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAAT</font>
+HWUSI-EAS729_614T6:3:13:15991:15051#0  -                          <font color="#000000">TATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TG</font>
+HWUSI-EAS729_614T6:7:65:3141:2489#0    -                          <font color="#000000">TATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TG</font>
+HWUSI-EAS729_614T6:8:54:5081:15134#0   -                          <font color="#000000">TATCATATTTT</font><font color="#800000">c</font><font color="#000000">AAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TG</font>
+HWUSI-EAS1543_614TM:4:38:16709:14763#0 -                             <font color="#000000">CATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTA</font>
+HWUSI-EAS1543_614TM:8:50:14524:11101#0 -                                                  <font color="#000000">TATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCT</font>
+HWUSI-EAS729_614T6:1:56:9586:15810#0   -                                                       <font color="#000000">TAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATAT</font><font color="#800000">a</font><font color="#000000">TAAGTGATGCTTGCTACTAT</font>
+HWUSI-EAS729_614T6:1:37:11212:13638#0  -                                                       <font color="#000000">TAAATTATGAA</font><font color="#800000">t</font><font color="#000000">AGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTAT</font>
+HWUSI-EAS729_614T6:1:29:1825:18616#0   -                                                         <font color="#000000">AATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTA</font>
+HWUSI-EAS729_614T6:5:48:14044:12231#0  -                                                         <font color="#000000">AATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTA</font>
+HWUSI-EAS729_614T6:4:115:6035:15619#0  -                                                          <font color="#000000">ATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAA</font>
+HWUSI-EAS729_614T6:5:72:1269:20227#0   -                                                                  <font color="#C0C0C0">aagagaatatgattctct</font><font color="#000000">T</font><font color="#C0C0C0">t</font><font color="#000000">T</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGT</font>
+HWUSI-EAS729_614T6:7:32:3784:11386#0   -                                                                  <font color="#000000">AAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGT</font>
+HWUSI-EAS1543_614TM:1:102:4785:3367#0  -                                                                                         <font color="#000000">AGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTA</font>
+HWUSI-EAS1543_614TM:6:60:2952:14857#0  -                                                                                         <font color="#C0C0C0">agtag</font><font color="#000000">CTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTG</font><font color="#C0C0C0">ctact</font><font color="#000000">ATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTA</font>
+_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+
+</pre><pre>
+                                                        66301780            66301800            66301820            66301840            66301860            66301880            66301900            66301920             66301940           
+                                                 .         |         .         |         .         |         .         |         .         |         .         |         .         |         .         |          .         |          .    
+10:66301762-66301954                     GTAAAAACACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC*AAAAAAAAAAAGTGGGA*AGAGGATATGTA
+                                                                                                                                                                                                                                            
+HWI-EAS231_614TA:7:82:16847:8457#0     +        <font color="#000000">CACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">gagaatcacttgaacccagg</font><font color="#800000">g</font><font color="#C0C0C0">ggtggaggttggag</font>
+HWI-EAS231_614TA:3:12:6209:13521#0     +          <font color="#000000">CAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtg</font>
+HWI-EAS90_614M9:8:23:6627:13184#0      +                                                                           <font color="#000000">GAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAA</font><font color="#C0C0C0">aa</font>
+HWI-EAS90_614M9:6:39:4439:17404#0      +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">agtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWI-EAS292_102081428:4:40:3376:13334#0 -           <font color="#000000">AAAAA</font><font color="#C0C0C0">t</font><font color="#000000">TA</font><font color="#C0C0C0">gc</font><font color="#000000">CAGGCATGG</font><font color="#C0C0C0">t</font><font color="#000000">GGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGA</font>
+HWI-EAS90_614M9:4:10:8095:5678#0       -           <font color="#000000">AAAAA</font><font color="#C0C0C0">ttag</font><font color="#000000">C</font><font color="#C0C0C0">ca</font><font color="#000000">G</font><font color="#C0C0C0">gcat</font><font color="#000000">GGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGA</font>
+HWI-EAS90_614M9:6:117:3466:13678#0     -                   <font color="#C0C0C0">gccagg</font><font color="#800000">gg</font><font color="#C0C0C0">tggtggtgggc</font><font color="#800000">g</font><font color="#C0C0C0">cctgtaatcccagctactcg</font><font color="#000000">GGAGGTAGAGGC</font><font color="#C0C0C0">a</font><font color="#000000">GGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGAT</font>
+HWI-EAS231_614TA:6:38:5961:6062#0      -                      <font color="#C0C0C0">aggc</font><font color="#800000">g</font><font color="#C0C0C0">tggtggtgggcacctgtaatcccagctactc</font><font color="#000000">GGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCAT</font>
+<b><i>HWI-EAS231_614TA:1:37:3390:19595#0     -       <font color="#6960EC">acacaaaaattagccaggc</font><font color="#C0C0C0">a</font><font color="#000000">TGGTGGTGGGC</font><font color="#C0C0C0">a</font><font color="#000000">CCTGTAATCCCAGCT</font><font color="#C0C0C0">a</font><font color="#000000">CT</font><font color="#C0C0C0">c</font><font color="#000000">GGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">AGAGGCAGGAGAATCACTTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACT</font></i></b>
+<b><i>HWI-EAS90_614M9:1:98:9476:6999#0       -                               <font color="#C0C0C0">gg</font><font color="#000000">TGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCA</font><font color="#800000">g</font><font color="#000000">TTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACTGAAAAGAGAATCATATTCTCTTTT</font></i></b>
+HWI-EAS231_614TA:8:4:10123:13264#0     -                                          <font color="#C0C0C0">g</font><font color="#000000">TA</font><font color="#C0C0C0">at</font><font color="#000000">CCCAGCT</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#C0C0C0">t</font><font color="#000000">CGGGAGGTAG</font><font color="#C0C0C0">aggca</font><font color="#000000">GGAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGG</font>
+HWUSI-EAS1591_6113C:2:96:6055:2122#0   -                                                      <font color="#C0C0C0">actcg</font><font color="#000000">GGAGGTAGAGGCAGGAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CTTGAACCCAGGAGGTGGA</font><font color="#800000">a</font><font color="#000000">GTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAA</font>
+<b><i>HWI-EAS90_614M9:7:110:15112:12998#0    -                                                               <font color="#000000">GTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAAT</font></i></b>
+<b><i>HWI-EAS90_614M9:5:12:2797:13435#0      -                                                                     <font color="#000000">GCAGGAGAATCACTTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA</font></i></b>
+HWI-EAS231_614TA:7:82:16847:8457#0     -                                                                                              <font color="#C0C0C0">ggtggaggttggagtgagccaagatcatgccact</font><font color="#800000">t</font><font color="#C0C0C0">cactc</font><font color="#000000">TAGCCTGGGCAACAGAGGAAGACTCCACCT</font><font color="#C0C0C0">c</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTA</font>
+____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+HWUSI-EAS1543_614TM:3:9:10897:10640#0  + <font color="#000000">GTAAAAACACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGA</font><font color="#C0C0C0">accc</font><font color="#800000">c</font><font color="#C0C0C0">ggaggtggag</font>
+HWUSI-EAS1543_614TM:5:85:1510:15876#0  + <font color="#000000">GTAAAAACACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">AGAGGCAGG</font><font color="#800000">g</font><font color="#C0C0C0">gaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">c</font><font color="#C0C0C0">g</font>
+HWUSI-EAS1543_614TM:6:36:6112:14330#0  +         <font color="#000000">ACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font>
+HWUSI-EAS1543_614TM:5:9:12006:6856#0   +           <font color="#000000">AAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAG</font><font color="#C0C0C0">aatcacttgaaccc</font><font color="#800000">c</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">ga</font>
+<b><i>HWUSI-EAS729_614T6:4:52:7979:7186#0    +                   <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">atcac</font><font color="#FF8040">t</font><font color="#C0C0C0">tt</font><font color="#800000">a</font><font color="#C0C0C0">aaccca</font><font color="#FF8040">*</font><font color="#C0C0C0">gagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">caag</font><font color="#6960EC">gt</font></i></b>
+<b><i>HWUSI-EAS729_614T6:7:102:2873:18725#0  +                   <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">gagaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">gagc</font><font color="#800000">g</font><font color="#C0C0C0">aaga</font><font color="#6960EC">a</font></i></b>
+<b><i>HWUSI-EAS729_614T6:8:57:13075:5535#0   +                   <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaa</font><font color="#800000">a</font><font color="#C0C0C0">cc</font><font color="#800000">c</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tggag</font><font color="#800000">g</font><font color="#C0C0C0">gagccaaga</font><font color="#6960EC">a</font></i></b>
+HWUSI-EAS1543_614TM:5:116:13350:19305#0+                    <font color="#000000">CCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAG</font><font color="#C0C0C0">gtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">gtgagccaagatc</font>
+HWUSI-EAS729_614T6:2:14:10861:9808#0   +                      <font color="#000000">AGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAACCC</font><font color="#C0C0C0">aggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcat</font>
+HWUSI-EAS1543_614TM:6:116:11405:10100#0+                         <font color="#000000">CATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">tcacttgaacccaggaggtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">gagccaagatca</font><font color="#800000">a</font><font color="#C0C0C0">gcc</font>
+HWUSI-EAS1543_614TM:8:103:11766:8746#0 +                               <font color="#000000">GGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGG</font><font color="#800000">g</font><font color="#000000">TGG</font><font color="#C0C0C0">a</font><font color="#000000">GTGAGCCAAGATCATGCCACTGCA</font>
+HWUSI-EAS1543_614TM:2:81:13732:11884#0 +                                <font color="#000000">GTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCAC</font><font color="#C0C0C0">t</font><font color="#000000">TGAACCC</font><font color="#C0C0C0">aggaggtggaggttggagtgagccaagatcatgccac</font><font color="#800000">c</font><font color="#C0C0C0">gcac</font>
+HWUSI-EAS729_614T6:6:27:13980:13345#0  +                                        <font color="#000000">CTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCC</font><font color="#C0C0C0">aggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggaggttggagtgagccaagatcatgccactgc</font><font color="#800000">c</font><font color="#C0C0C0">ctctagcc</font><font color="#800000">c</font>
+HWUSI-EAS729_614T6:7:80:16372:13691#0  +                                        <font color="#000000">CTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAA</font><font color="#C0C0C0">c</font><font color="#000000">CCAGG</font><font color="#C0C0C0">aggtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcatgccactgcactctagcct</font>
+HWUSI-EAS1543_614TM:4:24:17238:9026#0  +                                                        <font color="#000000">TCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">GGAGG</font><font color="#C0C0C0">t</font><font color="#000000">TGGAG</font><font color="#C0C0C0">t</font><font color="#000000">G</font><font color="#C0C0C0">a</font><font color="#000000">GCCAAGATCATGCCACTGCACTCTAGCC</font><font color="#C0C0C0">t</font><font color="#000000">GGGC</font><font color="#C0C0C0">a</font><font color="#000000">ACAGAGG</font><font color="#C0C0C0">a</font><font color="#000000">AGA</font>
+HWUSI-EAS729_614T6:4:85:2284:10568#0   +                                                                          <font color="#800000">T</font><font color="#000000">GAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACT</font><font color="#C0C0C0">ccacctc</font><font color="#FF8040">*</font><font color="#C0C0C0">a</font><font color="#800000">c</font><font color="#C0C0C0">aa</font><font color="#800000">c</font><font color="#C0C0C0">aaaa</font>
+HWUSI-EAS729_614T6:8:88:7531:4372#0    +                                                                                   <font color="#000000">TGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font><font color="#C0C0C0">aaaaagtgggaa</font>
+HWUSI-EAS1543_614TM:6:91:4071:17532#0  +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGAC</font><font color="#C0C0C0">t</font><font color="#000000">CCACC</font><font color="#C0C0C0">t</font><font color="#000000">C</font><font color="#FF8040">*</font><font color="#000000">A</font><font color="#C0C0C0">a</font><font color="#000000">AAAA</font><font color="#C0C0C0">aaaaag</font><font color="#800000">c</font><font color="#C0C0C0">ggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS1543_614TM:7:25:16711:4592#0  +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">ag</font><font color="#800000">a</font><font color="#000000">GGGA</font><font color="#FF8040">*</font><font color="#000000">AG</font><font color="#C0C0C0">aggat</font>
+HWUSI-EAS729_614T6:3:34:6821:21373#0   +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAG</font><font color="#C0C0C0">a</font><font color="#000000">GGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font><font color="#C0C0C0">a</font><font color="#800000">g</font><font color="#C0C0C0">aaagtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS729_614T6:6:117:5396:15508#0  +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAA</font><font color="#C0C0C0">aaaaaagtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS1543_614TM:8:35:4484:12519#0  -        <font color="#000000">CACAAA</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">tt</font><font color="#000000">AGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAG</font>
+HWUSI-EAS1543_614TM:4:40:15892:1713#0  -                      <font color="#800000">g</font><font color="#C0C0C0">ggc</font><font color="#800000">g</font><font color="#C0C0C0">tg</font><font color="#800000">tg</font><font color="#C0C0C0">ggtgggcacctgtaatcccagctactc</font><font color="#000000">GGGAGGTAGAGGCAGGAGAATCACTTGA</font><font color="#C0C0C0">a</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCAT</font>
+HWUSI-EAS1543_614TM:5:90:12703:4722#0  -                          <font color="#C0C0C0">a</font><font color="#000000">TGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCA</font>
+HWUSI-EAS1543_614TM:3:102:1564:19915#0 -                                                          <font color="#C0C0C0">gggaggtagaggc</font><font color="#800000">g</font><font color="#C0C0C0">gga</font><font color="#000000">GAATCACT</font><font color="#C0C0C0">tgaa</font><font color="#000000">C</font><font color="#C0C0C0">c</font><font color="#000000">C</font><font color="#C0C0C0">a</font><font color="#000000">GGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACT</font>
+HWUSI-EAS1543_614TM:5:5:18169:18490#0  -                                                              <font color="#000000">GGTAGAGGC</font><font color="#C0C0C0">a</font><font color="#000000">GGAG</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGA</font><font color="#800000">t</font><font color="#000000">GAAGACTCCAC</font>
+HWUSI-EAS729_614T6:4:44:11568:10646#0  -                                                              <font color="#000000">GGTAGAGGCAGGAGAA</font><font color="#C0C0C0">tc</font><font color="#000000">ACT</font><font color="#C0C0C0">tgaa</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCAC</font>
+HWUSI-EAS729_614T6:8:38:2365:13463#0   -                                                              <font color="#C0C0C0">ggtagaggcaggagaatcacttgaa</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCAC</font>
+HWUSI-EAS1543_614TM:8:59:4470:6454#0   -                                                               <font color="#000000">GTAGAGG</font><font color="#C0C0C0">c</font><font color="#000000">AGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACC</font>
+HWUSI-EAS729_614T6:1:58:5165:11774#0   -                                                                 <font color="#C0C0C0">agagg</font><font color="#000000">CA</font><font color="#C0C0C0">g</font><font color="#000000">GAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CT</font><font color="#C0C0C0">tg</font><font color="#000000">A</font><font color="#C0C0C0">a</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font>
+HWUSI-EAS729_614T6:6:64:8262:4344#0    -                                                                 <font color="#000000">AGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font>
+HWUSI-EAS1543_614TM:3:9:10897:10640#0  -                                                                       <font color="#000000">AGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:5:85:1510:15876#0  -                                                                       <font color="#C0C0C0">aggagaatcacttgaaccc</font><font color="#800000">g</font><font color="#C0C0C0">ggaggtggag</font><font color="#000000">GT</font><font color="#C0C0C0">t</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:7:109:3095:2034#0  -                                                                       <font color="#C0C0C0">aggagaatcacttga</font><font color="#800000">g</font><font color="#C0C0C0">ccc</font><font color="#800000">g</font><font color="#C0C0C0">ggaggtggagg</font><font color="#000000">TTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:4:24:17238:9026#0  -                                                                              <font color="#C0C0C0">tcact</font><font color="#000000">TGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGT</font>
+HWUSI-EAS1543_614TM:6:36:6112:14330#0  -                                                                                <font color="#C0C0C0">acttgaacccaggaggtgga</font><font color="#000000">GGTTGGAGTGAGCCAAGATCAT</font><font color="#C0C0C0">g</font><font color="#000000">CCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGG</font>
+HWUSI-EAS1543_614TM:4:67:1427:8600#0   -                                                                                  <font color="#C0C0C0">ttga</font><font color="#800000">c</font><font color="#C0C0C0">cccagg</font><font color="#800000">g</font><font color="#C0C0C0">ggtg</font><font color="#000000">GAGGT</font><font color="#C0C0C0">t</font><font color="#000000">GGAGTGAGCC</font><font color="#C0C0C0">aa</font><font color="#000000">G</font><font color="#C0C0C0">at</font><font color="#000000">C</font><font color="#C0C0C0">atgccac</font><font color="#000000">TGC</font><font color="#800000">c</font><font color="#000000">CTCTAGCCTGGG</font><font color="#C0C0C0">c</font><font color="#000000">AACAGAGG</font><font color="#C0C0C0">a</font><font color="#000000">AG</font><font color="#C0C0C0">a</font><font color="#000000">CTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS1543_614TM:6:77:17645:6273#0  -                                                                                  <font color="#C0C0C0">ttgaacccaggaggtggagg</font><font color="#000000">TTGGAG</font><font color="#C0C0C0">t</font><font color="#000000">GAGC</font><font color="#C0C0C0">c</font><font color="#000000">AA</font><font color="#C0C0C0">g</font><font color="#000000">ATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS1543_614TM:7:100:16004:10107#0-                                                                                  <font color="#000000">TTGAACCC</font><font color="#C0C0C0">a</font><font color="#000000">GG</font><font color="#C0C0C0">a</font><font color="#000000">GGTGG</font><font color="#C0C0C0">a</font><font color="#000000">GGTTGGA</font><font color="#C0C0C0">g</font><font color="#000000">TGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAG</font><font color="#C0C0C0">a</font><font color="#000000">CTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS729_614T6:2:93:11989:6538#0   -                                                                                   <font color="#C0C0C0">tga</font><font color="#800000">g</font><font color="#C0C0C0">cccaggaggtgga</font><font color="#000000">GGTTGGAGTGAGC</font><font color="#C0C0C0">c</font><font color="#000000">AAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGAA</font>
+HWUSI-EAS1543_614TM:2:81:13732:11884#0 -                                                                                         <font color="#C0C0C0">caggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">ggttgg</font><font color="#800000">g</font><font color="#C0C0C0">gtgagccaagatcatgccactgcactctagc</font><font color="#000000">C</font><font color="#C0C0C0">t</font><font color="#000000">GGGCAA</font><font color="#C0C0C0">ca</font><font color="#000000">GAGGAA</font><font color="#C0C0C0">gactccacct</font><font color="#000000">C</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGAT</font>
+HWUSI-EAS729_614T6:3:11:5262:1432#0    -                                                                                         <font color="#C0C0C0">caggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcatgcc</font><font color="#800000">c</font><font color="#C0C0C0">ctgcactctagc</font><font color="#000000">CTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGAT</font>
+____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+
+</pre><h3 style="color:blue;text-align:center">5	7052198	-	0	10	66301865	+	8	CTX	0	22	0	81	0.761379310344828	0.482758620689655	0	0	1	5	7052278	164	10	66301947	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCAGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTCAAAAAAAAAAAGTGGGAAGAGG</h3>
+<pre>
+                    
+                    
+5:7052198-7052198  T
+                    
+____________________
+____________________
+
+</pre><pre>
+                                                 66301780            66301800            66301820            66301840            66301860            66301880            66301900            66301920             66301940             66301960
+                                          .         |         .         |         .         |         .         |         .         |         .         |         .         |         .         |          .         |          .         |   
+10:66301769-66301962                     CACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC*AAAAAAAAAAAGTGGGA*AGAGGATATGTATGAGCAG*A
+                                                                                                                                                                                                                                              
+HWI-EAS231_614TA:7:82:16847:8457#0     + <font color="#000000">CACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">gagaatcacttgaacccagg</font><font color="#800000">g</font><font color="#C0C0C0">ggtggaggttggag</font>
+HWI-EAS231_614TA:3:12:6209:13521#0     +   <font color="#000000">CAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtg</font>
+HWI-EAS90_614M9:8:23:6627:13184#0      +                                                                    <font color="#000000">GAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAA</font><font color="#C0C0C0">aa</font>
+HWI-EAS90_614M9:6:39:4439:17404#0      +                                                                                  <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">agtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWI-EAS231_614TA:2:4:4943:8854#0       +                                                                                            <font color="#000000">AGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGA</font><font color="#C0C0C0">t</font><font color="#000000">ATG</font><font color="#C0C0C0">t</font><font color="#000000">ATGAGC</font>
+HWI-EAS231_614TA:4:78:6983:13721#0     +                                                                                            <font color="#000000">AGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTATGAGC</font>
+HWUSI-EAS1591_6113C:2:82:8140:13005#0  +                                                                                               <font color="#000000">TTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTATGAGCAGA</font>
+<b><i>HWI-EAS231_614TA:4:36:3528:11249#0     +                                                                                     <font color="#6960EC">TTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACA</font><font color="#6960EC">GAGGAAGACTCCACCTCAAAAAAAAAAGtGggAAGAGGAtatgt</font></i></b>
+<b><i>HWI-EAS231_614TA:5:52:9612:8954#0      +                                                                                <font color="#6960EC">CGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCC</font><font color="#6960EC">TGGGCAACAGAGGAAGACTCCACCTCAAAAAAAAAAAGTGGGAAGAGG</font></i></b>
+<b><i>HWI-EAS90_614M9:1:118:15320:11068#0    +                <font color="#6960EC">AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCATG</font></i></b>
+<b><i>HWI-EAS90_614M9:3:104:3717:11676#0     +                                                                           <font color="#6960EC">GAGTCCGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCA</font><font color="#C0C0C0">t</font><font color="#000000">GCCAC</font><font color="#C0C0C0">tgcactc</font><font color="#800000">c</font><font color="#C0C0C0">agcctgggcaacagaggaagactccacctc</font><font color="#FF8040">*</font><font color="#800000">c</font><font color="#C0C0C0">aaaaaaaaaa</font><font color="#800000">aa</font><font color="#C0C0C0">ggga</font></i></b>
+<b><i>HWI-EAS90_614M9:4:115:17151:16115#0    +                                                    <font color="#6960EC">AGTCCGGAGTTCTCAACGATGGTGAGTCCGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTC</font></i></b>
+<b><i>HWI-EAS90_614M9:5:27:7334:16234#0      +                          <font color="#6960EC">CTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACT</font></i></b>
+<b><i>HWI-EAS90_614M9:7:21:19162:4940#0      +                                                                                             <font color="#6960EC">TTCA</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAA</font><font color="#C0C0C0">gt</font><font color="#000000">GG</font><font color="#C0C0C0">ga</font><font color="#FF8040">*</font><font color="#000000">AG</font><font color="#C0C0C0">aggata</font><font color="#000000">TG</font><font color="#C0C0C0">tatgagca</font></i></b>
+<b><i>HWUSI-EAS1591_6113C:1:24:6705:7145#0   +                <font color="#6960EC">AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGCGAGTCCGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGC</font><font color="#C0C0C0">c</font><font color="#000000">AAGATCATG</font></i></b>
+<b><i>HWUSI-EAS1591_6113C:2:55:7685:7454#0   +                                                                            <font color="#6960EC">AGTCCGTAGTTTGTTCCTTCA</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#6960EC">AAAAAAAAAAAGtGGGaA</font></i></b>
+HWI-EAS292_102081428:4:40:3376:13334#0 -    <font color="#000000">AAAAA</font><font color="#C0C0C0">t</font><font color="#000000">TA</font><font color="#C0C0C0">gc</font><font color="#000000">CAGGCATGG</font><font color="#C0C0C0">t</font><font color="#000000">GGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGA</font>
+HWI-EAS90_614M9:4:10:8095:5678#0       -    <font color="#000000">AAAAA</font><font color="#C0C0C0">ttag</font><font color="#000000">C</font><font color="#C0C0C0">ca</font><font color="#000000">G</font><font color="#C0C0C0">gcat</font><font color="#000000">GGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGA</font>
+HWI-EAS90_614M9:6:117:3466:13678#0     -            <font color="#C0C0C0">gccagg</font><font color="#800000">gg</font><font color="#C0C0C0">tggtggtgggc</font><font color="#800000">g</font><font color="#C0C0C0">cctgtaatcccagctactcg</font><font color="#000000">GGAGGTAGAGGC</font><font color="#C0C0C0">a</font><font color="#000000">GGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGAT</font>
+HWI-EAS231_614TA:6:38:5961:6062#0      -               <font color="#C0C0C0">aggc</font><font color="#800000">g</font><font color="#C0C0C0">tggtggtgggcacctgtaatcccagctactc</font><font color="#000000">GGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCAT</font>
+HWI-EAS231_614TA:8:4:10123:13264#0     -                                   <font color="#C0C0C0">g</font><font color="#000000">TA</font><font color="#C0C0C0">at</font><font color="#000000">CCCAGCT</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#C0C0C0">t</font><font color="#000000">CGGGAGGTAG</font><font color="#C0C0C0">aggca</font><font color="#000000">GGAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGG</font>
+HWUSI-EAS1591_6113C:2:96:6055:2122#0   -                                               <font color="#C0C0C0">actcg</font><font color="#000000">GGAGGTAGAGGCAGGAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CTTGAACCCAGGAGGTGGA</font><font color="#800000">a</font><font color="#000000">GTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAA</font>
+HWI-EAS231_614TA:7:82:16847:8457#0     -                                                                                       <font color="#C0C0C0">ggtggaggttggagtgagccaagatcatgccact</font><font color="#800000">t</font><font color="#C0C0C0">cactc</font><font color="#000000">TAGCCTGGGCAACAGAGGAAGACTCCACCT</font><font color="#C0C0C0">c</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTA</font>
+HWI-EAS231_614TA:3:12:6209:13521#0     -                                                                                           <font color="#C0C0C0">gaggttggagtgagc</font><font color="#000000">CAAGA</font><font color="#C0C0C0">t</font><font color="#000000">C</font><font color="#C0C0C0">a</font><font color="#000000">TGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTATGAG</font>
+______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+HWUSI-EAS1543_614TM:6:36:6112:14330#0  +  <font color="#000000">ACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font>
+HWUSI-EAS1543_614TM:5:9:12006:6856#0   +    <font color="#000000">AAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAG</font><font color="#C0C0C0">aatcacttgaaccc</font><font color="#800000">c</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">ga</font>
+<b><i>HWUSI-EAS729_614T6:4:52:7979:7186#0    +            <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">atcac</font><font color="#FF8040">t</font><font color="#C0C0C0">tt</font><font color="#800000">a</font><font color="#C0C0C0">aaccca</font><font color="#FF8040">*</font><font color="#C0C0C0">gagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">caag</font><font color="#6960EC">gt</font></i></b>
+<b><i>HWUSI-EAS729_614T6:7:102:2873:18725#0  +            <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">gagaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">gagc</font><font color="#800000">g</font><font color="#C0C0C0">aaga</font><font color="#6960EC">a</font></i></b>
+<b><i>HWUSI-EAS729_614T6:8:57:13075:5535#0   +            <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaa</font><font color="#800000">a</font><font color="#C0C0C0">cc</font><font color="#800000">c</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tggag</font><font color="#800000">g</font><font color="#C0C0C0">gagccaaga</font><font color="#6960EC">a</font></i></b>
+HWUSI-EAS1543_614TM:5:116:13350:19305#0+             <font color="#000000">CCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAG</font><font color="#C0C0C0">gtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">gtgagccaagatc</font>
+HWUSI-EAS729_614T6:2:14:10861:9808#0   +               <font color="#000000">AGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAACCC</font><font color="#C0C0C0">aggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcat</font>
+HWUSI-EAS1543_614TM:6:116:11405:10100#0+                  <font color="#000000">CATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">tcacttgaacccaggaggtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">gagccaagatca</font><font color="#800000">a</font><font color="#C0C0C0">gcc</font>
+HWUSI-EAS1543_614TM:8:103:11766:8746#0 +                        <font color="#000000">GGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGG</font><font color="#800000">g</font><font color="#000000">TGG</font><font color="#C0C0C0">a</font><font color="#000000">GTGAGCCAAGATCATGCCACTGCA</font>
+HWUSI-EAS1543_614TM:2:81:13732:11884#0 +                         <font color="#000000">GTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCAC</font><font color="#C0C0C0">t</font><font color="#000000">TGAACCC</font><font color="#C0C0C0">aggaggtggaggttggagtgagccaagatcatgccac</font><font color="#800000">c</font><font color="#C0C0C0">gcac</font>
+HWUSI-EAS729_614T6:6:27:13980:13345#0  +                                 <font color="#000000">CTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCC</font><font color="#C0C0C0">aggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggaggttggagtgagccaagatcatgccactgc</font><font color="#800000">c</font><font color="#C0C0C0">ctctagcc</font><font color="#800000">c</font>
+HWUSI-EAS729_614T6:7:80:16372:13691#0  +                                 <font color="#000000">CTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAA</font><font color="#C0C0C0">c</font><font color="#000000">CCAGG</font><font color="#C0C0C0">aggtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcatgccactgcactctagcct</font>
+HWUSI-EAS1543_614TM:4:24:17238:9026#0  +                                                 <font color="#000000">TCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">GGAGG</font><font color="#C0C0C0">t</font><font color="#000000">TGGAG</font><font color="#C0C0C0">t</font><font color="#000000">G</font><font color="#C0C0C0">a</font><font color="#000000">GCCAAGATCATGCCACTGCACTCTAGCC</font><font color="#C0C0C0">t</font><font color="#000000">GGGC</font><font color="#C0C0C0">a</font><font color="#000000">ACAGAGG</font><font color="#C0C0C0">a</font><font color="#000000">AGA</font>
+HWUSI-EAS729_614T6:4:85:2284:10568#0   +                                                                   <font color="#800000">T</font><font color="#000000">GAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACT</font><font color="#C0C0C0">ccacctc</font><font color="#FF8040">*</font><font color="#C0C0C0">a</font><font color="#800000">c</font><font color="#C0C0C0">aa</font><font color="#800000">c</font><font color="#C0C0C0">aaaa</font>
+HWUSI-EAS729_614T6:8:88:7531:4372#0    +                                                                            <font color="#000000">TGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font><font color="#C0C0C0">aaaaagtgggaa</font>
+HWUSI-EAS1543_614TM:6:91:4071:17532#0  +                                                                                  <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGAC</font><font color="#C0C0C0">t</font><font color="#000000">CCACC</font><font color="#C0C0C0">t</font><font color="#000000">C</font><font color="#FF8040">*</font><font color="#000000">A</font><font color="#C0C0C0">a</font><font color="#000000">AAAA</font><font color="#C0C0C0">aaaaag</font><font color="#800000">c</font><font color="#C0C0C0">ggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS1543_614TM:7:25:16711:4592#0  +                                                                                  <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">ag</font><font color="#800000">a</font><font color="#000000">GGGA</font><font color="#FF8040">*</font><font color="#000000">AG</font><font color="#C0C0C0">aggat</font>
+HWUSI-EAS729_614T6:3:34:6821:21373#0   +                                                                                  <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAG</font><font color="#C0C0C0">a</font><font color="#000000">GGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font><font color="#C0C0C0">a</font><font color="#800000">g</font><font color="#C0C0C0">aaagtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS729_614T6:6:117:5396:15508#0  +                                                                                  <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAA</font><font color="#C0C0C0">aaaaaagtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS1543_614TM:4:21:14965:3057#0  +                                                                                              <font color="#000000">GTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">A</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">ag</font><font color="#800000">a</font><font color="#C0C0C0">ggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggatatg</font><font color="#800000">a</font><font color="#C0C0C0">atg</font><font color="#800000">g</font><font color="#C0C0C0">gca</font>
+HWUSI-EAS729_614T6:4:1:12928:15062#0   +                                                                                              <font color="#000000">GTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAA</font><font color="#C0C0C0">g</font><font color="#000000">TGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTATGAGCAG</font>
+HWUSI-EAS1543_614TM:8:35:4484:12519#0  - <font color="#000000">CACAAA</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">tt</font><font color="#000000">AGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAG</font>
+HWUSI-EAS1543_614TM:4:40:15892:1713#0  -               <font color="#800000">g</font><font color="#C0C0C0">ggc</font><font color="#800000">g</font><font color="#C0C0C0">tg</font><font color="#800000">tg</font><font color="#C0C0C0">ggtgggcacctgtaatcccagctactc</font><font color="#000000">GGGAGGTAGAGGCAGGAGAATCACTTGA</font><font color="#C0C0C0">a</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCAT</font>
+HWUSI-EAS1543_614TM:5:90:12703:4722#0  -                   <font color="#C0C0C0">a</font><font color="#000000">TGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCA</font>
+HWUSI-EAS1543_614TM:3:102:1564:19915#0 -                                                   <font color="#C0C0C0">gggaggtagaggc</font><font color="#800000">g</font><font color="#C0C0C0">gga</font><font color="#000000">GAATCACT</font><font color="#C0C0C0">tgaa</font><font color="#000000">C</font><font color="#C0C0C0">c</font><font color="#000000">C</font><font color="#C0C0C0">a</font><font color="#000000">GGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACT</font>
+HWUSI-EAS1543_614TM:5:5:18169:18490#0  -                                                       <font color="#000000">GGTAGAGGC</font><font color="#C0C0C0">a</font><font color="#000000">GGAG</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGA</font><font color="#800000">t</font><font color="#000000">GAAGACTCCAC</font>
+HWUSI-EAS729_614T6:4:44:11568:10646#0  -                                                       <font color="#000000">GGTAGAGGCAGGAGAA</font><font color="#C0C0C0">tc</font><font color="#000000">ACT</font><font color="#C0C0C0">tgaa</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCAC</font>
+HWUSI-EAS729_614T6:8:38:2365:13463#0   -                                                       <font color="#C0C0C0">ggtagaggcaggagaatcacttgaa</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCAC</font>
+HWUSI-EAS1543_614TM:8:59:4470:6454#0   -                                                        <font color="#000000">GTAGAGG</font><font color="#C0C0C0">c</font><font color="#000000">AGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACC</font>
+HWUSI-EAS729_614T6:1:58:5165:11774#0   -                                                          <font color="#C0C0C0">agagg</font><font color="#000000">CA</font><font color="#C0C0C0">g</font><font color="#000000">GAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CT</font><font color="#C0C0C0">tg</font><font color="#000000">A</font><font color="#C0C0C0">a</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font>
+HWUSI-EAS729_614T6:6:64:8262:4344#0    -                                                          <font color="#000000">AGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font>
+HWUSI-EAS1543_614TM:3:9:10897:10640#0  -                                                                <font color="#000000">AGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:5:85:1510:15876#0  -                                                                <font color="#C0C0C0">aggagaatcacttgaaccc</font><font color="#800000">g</font><font color="#C0C0C0">ggaggtggag</font><font color="#000000">GT</font><font color="#C0C0C0">t</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:7:109:3095:2034#0  -                                                                <font color="#C0C0C0">aggagaatcacttga</font><font color="#800000">g</font><font color="#C0C0C0">ccc</font><font color="#800000">g</font><font color="#C0C0C0">ggaggtggagg</font><font color="#000000">TTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:4:24:17238:9026#0  -                                                                       <font color="#C0C0C0">tcact</font><font color="#000000">TGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGT</font>
+HWUSI-EAS1543_614TM:6:36:6112:14330#0  -                                                                         <font color="#C0C0C0">acttgaacccaggaggtgga</font><font color="#000000">GGTTGGAGTGAGCCAAGATCAT</font><font color="#C0C0C0">g</font><font color="#000000">CCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGG</font>
+HWUSI-EAS1543_614TM:4:67:1427:8600#0   -                                                                           <font color="#C0C0C0">ttga</font><font color="#800000">c</font><font color="#C0C0C0">cccagg</font><font color="#800000">g</font><font color="#C0C0C0">ggtg</font><font color="#000000">GAGGT</font><font color="#C0C0C0">t</font><font color="#000000">GGAGTGAGCC</font><font color="#C0C0C0">aa</font><font color="#000000">G</font><font color="#C0C0C0">at</font><font color="#000000">C</font><font color="#C0C0C0">atgccac</font><font color="#000000">TGC</font><font color="#800000">c</font><font color="#000000">CTCTAGCCTGGG</font><font color="#C0C0C0">c</font><font color="#000000">AACAGAGG</font><font color="#C0C0C0">a</font><font color="#000000">AG</font><font color="#C0C0C0">a</font><font color="#000000">CTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS1543_614TM:6:77:17645:6273#0  -                                                                           <font color="#C0C0C0">ttgaacccaggaggtggagg</font><font color="#000000">TTGGAG</font><font color="#C0C0C0">t</font><font color="#000000">GAGC</font><font color="#C0C0C0">c</font><font color="#000000">AA</font><font color="#C0C0C0">g</font><font color="#000000">ATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS1543_614TM:7:100:16004:10107#0-                                                                           <font color="#000000">TTGAACCC</font><font color="#C0C0C0">a</font><font color="#000000">GG</font><font color="#C0C0C0">a</font><font color="#000000">GGTGG</font><font color="#C0C0C0">a</font><font color="#000000">GGTTGGA</font><font color="#C0C0C0">g</font><font color="#000000">TGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAG</font><font color="#C0C0C0">a</font><font color="#000000">CTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS729_614T6:2:93:11989:6538#0   -                                                                            <font color="#C0C0C0">tga</font><font color="#800000">g</font><font color="#C0C0C0">cccaggaggtgga</font><font color="#000000">GGTTGGAGTGAGC</font><font color="#C0C0C0">c</font><font color="#000000">AAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGAA</font>
+HWUSI-EAS1543_614TM:2:81:13732:11884#0 -                                                                                  <font color="#C0C0C0">caggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">ggttgg</font><font color="#800000">g</font><font color="#C0C0C0">gtgagccaagatcatgccactgcactctagc</font><font color="#000000">C</font><font color="#C0C0C0">t</font><font color="#000000">GGGCAA</font><font color="#C0C0C0">ca</font><font color="#000000">GAGGAA</font><font color="#C0C0C0">gactccacct</font><font color="#000000">C</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGAT</font>
+HWUSI-EAS729_614T6:3:11:5262:1432#0    -                                                                                  <font color="#C0C0C0">caggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcatgcc</font><font color="#800000">c</font><font color="#C0C0C0">ctgcactctagc</font><font color="#000000">CTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGAT</font>
+______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+
+</pre><h3 style="color:blue;text-align:center">10	66301858	+	4	4	125893225	-	1	CTX	15	28	71	81	0.735384615384615	0.5	0.889507154213037	0.243243243243243	1	10	66301777	153	4	125893154	TTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA</h3>
+<pre>
+                                                        66301780            66301800            66301820            66301840            66301860            66301880            66301900            66301920             66301940           
+                                                 .         |         .         |         .         |         .         |         .         |         .         |         .         |         .         |          .         |          .    
+10:66301762-66301954                     GTAAAAACACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC*AAAAAAAAAAAGTGGGA*AGAGGATATGTA
+                                                                                                                                                                                                                                            
+HWI-EAS231_614TA:7:82:16847:8457#0     +        <font color="#000000">CACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">gagaatcacttgaacccagg</font><font color="#800000">g</font><font color="#C0C0C0">ggtggaggttggag</font>
+HWI-EAS231_614TA:3:12:6209:13521#0     +          <font color="#000000">CAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtg</font>
+HWI-EAS90_614M9:8:23:6627:13184#0      +                                                                           <font color="#000000">GAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAA</font><font color="#C0C0C0">aa</font>
+HWI-EAS90_614M9:6:39:4439:17404#0      +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">agtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWI-EAS292_102081428:4:40:3376:13334#0 -           <font color="#000000">AAAAA</font><font color="#C0C0C0">t</font><font color="#000000">TA</font><font color="#C0C0C0">gc</font><font color="#000000">CAGGCATGG</font><font color="#C0C0C0">t</font><font color="#000000">GGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGA</font>
+HWI-EAS90_614M9:4:10:8095:5678#0       -           <font color="#000000">AAAAA</font><font color="#C0C0C0">ttag</font><font color="#000000">C</font><font color="#C0C0C0">ca</font><font color="#000000">G</font><font color="#C0C0C0">gcat</font><font color="#000000">GGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGA</font>
+HWI-EAS90_614M9:6:117:3466:13678#0     -                   <font color="#C0C0C0">gccagg</font><font color="#800000">gg</font><font color="#C0C0C0">tggtggtgggc</font><font color="#800000">g</font><font color="#C0C0C0">cctgtaatcccagctactcg</font><font color="#000000">GGAGGTAGAGGC</font><font color="#C0C0C0">a</font><font color="#000000">GGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGAT</font>
+HWI-EAS231_614TA:6:38:5961:6062#0      -                      <font color="#C0C0C0">aggc</font><font color="#800000">g</font><font color="#C0C0C0">tggtggtgggcacctgtaatcccagctactc</font><font color="#000000">GGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCAT</font>
+<b><i>HWI-EAS231_614TA:1:37:3390:19595#0     -       <font color="#6960EC">acacaaaaattagccaggc</font><font color="#C0C0C0">a</font><font color="#000000">TGGTGGTGGGC</font><font color="#C0C0C0">a</font><font color="#000000">CCTGTAATCCCAGCT</font><font color="#C0C0C0">a</font><font color="#000000">CT</font><font color="#C0C0C0">c</font><font color="#000000">GGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">AGAGGCAGGAGAATCACTTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACT</font></i></b>
+<b><i>HWI-EAS90_614M9:1:98:9476:6999#0       -                               <font color="#C0C0C0">gg</font><font color="#000000">TGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCA</font><font color="#800000">g</font><font color="#000000">TTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACTGAAAAGAGAATCATATTCTCTTTT</font></i></b>
+HWI-EAS231_614TA:8:4:10123:13264#0     -                                          <font color="#C0C0C0">g</font><font color="#000000">TA</font><font color="#C0C0C0">at</font><font color="#000000">CCCAGCT</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#C0C0C0">t</font><font color="#000000">CGGGAGGTAG</font><font color="#C0C0C0">aggca</font><font color="#000000">GGAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGG</font>
+HWUSI-EAS1591_6113C:2:96:6055:2122#0   -                                                      <font color="#C0C0C0">actcg</font><font color="#000000">GGAGGTAGAGGCAGGAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CTTGAACCCAGGAGGTGGA</font><font color="#800000">a</font><font color="#000000">GTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAA</font>
+<b><i>HWI-EAS90_614M9:7:110:15112:12998#0    -                                                               <font color="#000000">GTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAAT</font></i></b>
+<b><i>HWI-EAS90_614M9:5:12:2797:13435#0      -                                                                     <font color="#000000">GCAGGAGAATCACTTGAACCCAGGAGGTG</font><font color="#6960EC">ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA</font></i></b>
+HWI-EAS231_614TA:7:82:16847:8457#0     -                                                                                              <font color="#C0C0C0">ggtggaggttggagtgagccaagatcatgccact</font><font color="#800000">t</font><font color="#C0C0C0">cactc</font><font color="#000000">TAGCCTGGGCAACAGAGGAAGACTCCACCT</font><font color="#C0C0C0">c</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGATATGTA</font>
+____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+HWUSI-EAS1543_614TM:3:9:10897:10640#0  + <font color="#000000">GTAAAAACACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGA</font><font color="#C0C0C0">accc</font><font color="#800000">c</font><font color="#C0C0C0">ggaggtggag</font>
+HWUSI-EAS1543_614TM:5:85:1510:15876#0  + <font color="#000000">GTAAAAACACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">AGAGGCAGG</font><font color="#800000">g</font><font color="#C0C0C0">gaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">c</font><font color="#C0C0C0">g</font>
+HWUSI-EAS1543_614TM:6:36:6112:14330#0  +         <font color="#000000">ACAAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font>
+HWUSI-EAS1543_614TM:5:9:12006:6856#0   +           <font color="#000000">AAAAATTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAG</font><font color="#C0C0C0">aatcacttgaaccc</font><font color="#800000">c</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">ga</font>
+<b><i>HWUSI-EAS729_614T6:4:52:7979:7186#0    +                   <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">atcac</font><font color="#FF8040">t</font><font color="#C0C0C0">tt</font><font color="#800000">a</font><font color="#C0C0C0">aaccca</font><font color="#FF8040">*</font><font color="#C0C0C0">gagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">caag</font><font color="#6960EC">gt</font></i></b>
+<b><i>HWUSI-EAS729_614T6:7:102:2873:18725#0  +                   <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAG</font><font color="#C0C0C0">gagaatcacttgaacccaggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">gagc</font><font color="#800000">g</font><font color="#C0C0C0">aaga</font><font color="#6960EC">a</font></i></b>
+<b><i>HWUSI-EAS729_614T6:8:57:13075:5535#0   +                   <font color="#000000">GCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGG</font><font color="#C0C0C0">agaatcacttgaa</font><font color="#800000">a</font><font color="#C0C0C0">cc</font><font color="#800000">c</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tggag</font><font color="#800000">g</font><font color="#C0C0C0">gagccaaga</font><font color="#6960EC">a</font></i></b>
+HWUSI-EAS1543_614TM:5:116:13350:19305#0+                    <font color="#000000">CCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAG</font><font color="#C0C0C0">gtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">gtgagccaagatc</font>
+HWUSI-EAS729_614T6:2:14:10861:9808#0   +                      <font color="#000000">AGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAACCC</font><font color="#C0C0C0">aggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcat</font>
+HWUSI-EAS1543_614TM:6:116:11405:10100#0+                         <font color="#000000">CATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">tcacttgaacccaggaggtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tgg</font><font color="#800000">g</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">gagccaagatca</font><font color="#800000">a</font><font color="#C0C0C0">gcc</font>
+HWUSI-EAS1543_614TM:8:103:11766:8746#0 +                               <font color="#000000">GGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGG</font><font color="#800000">g</font><font color="#000000">TGG</font><font color="#C0C0C0">a</font><font color="#000000">GTGAGCCAAGATCATGCCACTGCA</font>
+HWUSI-EAS1543_614TM:2:81:13732:11884#0 +                                <font color="#000000">GTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCAC</font><font color="#C0C0C0">t</font><font color="#000000">TGAACCC</font><font color="#C0C0C0">aggaggtggaggttggagtgagccaagatcatgccac</font><font color="#800000">c</font><font color="#C0C0C0">gcac</font>
+HWUSI-EAS729_614T6:6:27:13980:13345#0  +                                        <font color="#000000">CTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCC</font><font color="#C0C0C0">aggagg</font><font color="#800000">g</font><font color="#C0C0C0">ggaggttggagtgagccaagatcatgccactgc</font><font color="#800000">c</font><font color="#C0C0C0">ctctagcc</font><font color="#800000">c</font>
+HWUSI-EAS729_614T6:7:80:16372:13691#0  +                                        <font color="#000000">CTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAA</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAA</font><font color="#C0C0C0">c</font><font color="#000000">CCAGG</font><font color="#C0C0C0">aggtggagg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcatgccactgcactctagcct</font>
+HWUSI-EAS1543_614TM:4:24:17238:9026#0  +                                                        <font color="#000000">TCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGG</font><font color="#C0C0C0">t</font><font color="#000000">GGAGG</font><font color="#C0C0C0">t</font><font color="#000000">TGGAG</font><font color="#C0C0C0">t</font><font color="#000000">G</font><font color="#C0C0C0">a</font><font color="#000000">GCCAAGATCATGCCACTGCACTCTAGCC</font><font color="#C0C0C0">t</font><font color="#000000">GGGC</font><font color="#C0C0C0">a</font><font color="#000000">ACAGAGG</font><font color="#C0C0C0">a</font><font color="#000000">AGA</font>
+HWUSI-EAS729_614T6:4:85:2284:10568#0   +                                                                          <font color="#800000">T</font><font color="#000000">GAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACT</font><font color="#C0C0C0">ccacctc</font><font color="#FF8040">*</font><font color="#C0C0C0">a</font><font color="#800000">c</font><font color="#C0C0C0">aa</font><font color="#800000">c</font><font color="#C0C0C0">aaaa</font>
+HWUSI-EAS729_614T6:8:88:7531:4372#0    +                                                                                   <font color="#000000">TGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font><font color="#C0C0C0">aaaaagtgggaa</font>
+HWUSI-EAS1543_614TM:6:91:4071:17532#0  +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGAC</font><font color="#C0C0C0">t</font><font color="#000000">CCACC</font><font color="#C0C0C0">t</font><font color="#000000">C</font><font color="#FF8040">*</font><font color="#000000">A</font><font color="#C0C0C0">a</font><font color="#000000">AAAA</font><font color="#C0C0C0">aaaaag</font><font color="#800000">c</font><font color="#C0C0C0">ggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS1543_614TM:7:25:16711:4592#0  +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAA</font><font color="#C0C0C0">ag</font><font color="#800000">a</font><font color="#000000">GGGA</font><font color="#FF8040">*</font><font color="#000000">AG</font><font color="#C0C0C0">aggat</font>
+HWUSI-EAS729_614T6:3:34:6821:21373#0   +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAG</font><font color="#C0C0C0">a</font><font color="#000000">GGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font><font color="#C0C0C0">a</font><font color="#800000">g</font><font color="#C0C0C0">aaagtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS729_614T6:6:117:5396:15508#0  +                                                                                         <font color="#000000">CAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAA</font><font color="#C0C0C0">aaaaaagtggga</font><font color="#FF8040">*</font><font color="#C0C0C0">agaggat</font>
+HWUSI-EAS1543_614TM:8:35:4484:12519#0  -        <font color="#000000">CACAAA</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">tt</font><font color="#000000">AGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAG</font>
+HWUSI-EAS1543_614TM:4:40:15892:1713#0  -                      <font color="#800000">g</font><font color="#C0C0C0">ggc</font><font color="#800000">g</font><font color="#C0C0C0">tg</font><font color="#800000">tg</font><font color="#C0C0C0">ggtgggcacctgtaatcccagctactc</font><font color="#000000">GGGAGGTAGAGGCAGGAGAATCACTTGA</font><font color="#C0C0C0">a</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCAT</font>
+HWUSI-EAS1543_614TM:5:90:12703:4722#0  -                          <font color="#C0C0C0">a</font><font color="#000000">TGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCA</font>
+HWUSI-EAS1543_614TM:3:102:1564:19915#0 -                                                          <font color="#C0C0C0">gggaggtagaggc</font><font color="#800000">g</font><font color="#C0C0C0">gga</font><font color="#000000">GAATCACT</font><font color="#C0C0C0">tgaa</font><font color="#000000">C</font><font color="#C0C0C0">c</font><font color="#000000">C</font><font color="#C0C0C0">a</font><font color="#000000">GGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACT</font>
+HWUSI-EAS1543_614TM:5:5:18169:18490#0  -                                                              <font color="#000000">GGTAGAGGC</font><font color="#C0C0C0">a</font><font color="#000000">GGAG</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">t</font><font color="#000000">CACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGA</font><font color="#800000">t</font><font color="#000000">GAAGACTCCAC</font>
+HWUSI-EAS729_614T6:4:44:11568:10646#0  -                                                              <font color="#000000">GGTAGAGGCAGGAGAA</font><font color="#C0C0C0">tc</font><font color="#000000">ACT</font><font color="#C0C0C0">tgaa</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCAC</font>
+HWUSI-EAS729_614T6:8:38:2365:13463#0   -                                                              <font color="#C0C0C0">ggtagaggcaggagaatcacttgaa</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCAC</font>
+HWUSI-EAS1543_614TM:8:59:4470:6454#0   -                                                               <font color="#000000">GTAGAGG</font><font color="#C0C0C0">c</font><font color="#000000">AGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACC</font>
+HWUSI-EAS729_614T6:1:58:5165:11774#0   -                                                                 <font color="#C0C0C0">agagg</font><font color="#000000">CA</font><font color="#C0C0C0">g</font><font color="#000000">GAGAATC</font><font color="#C0C0C0">a</font><font color="#000000">CT</font><font color="#C0C0C0">tg</font><font color="#000000">A</font><font color="#C0C0C0">a</font><font color="#000000">CCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font>
+HWUSI-EAS729_614T6:6:64:8262:4344#0    -                                                                 <font color="#000000">AGAGGCAGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font>
+HWUSI-EAS1543_614TM:3:9:10897:10640#0  -                                                                       <font color="#000000">AGGAGAATCACTTGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:5:85:1510:15876#0  -                                                                       <font color="#C0C0C0">aggagaatcacttgaaccc</font><font color="#800000">g</font><font color="#C0C0C0">ggaggtggag</font><font color="#000000">GT</font><font color="#C0C0C0">t</font><font color="#000000">GGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:7:109:3095:2034#0  -                                                                       <font color="#C0C0C0">aggagaatcacttga</font><font color="#800000">g</font><font color="#C0C0C0">ccc</font><font color="#800000">g</font><font color="#C0C0C0">ggaggtggagg</font><font color="#000000">TTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAA</font>
+HWUSI-EAS1543_614TM:4:24:17238:9026#0  -                                                                              <font color="#C0C0C0">tcact</font><font color="#000000">TGAACCCAGGAGGTGGAGGTTGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGT</font>
+HWUSI-EAS1543_614TM:6:36:6112:14330#0  -                                                                                <font color="#C0C0C0">acttgaacccaggaggtgga</font><font color="#000000">GGTTGGAGTGAGCCAAGATCAT</font><font color="#C0C0C0">g</font><font color="#000000">CCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGG</font>
+HWUSI-EAS1543_614TM:4:67:1427:8600#0   -                                                                                  <font color="#C0C0C0">ttga</font><font color="#800000">c</font><font color="#C0C0C0">cccagg</font><font color="#800000">g</font><font color="#C0C0C0">ggtg</font><font color="#000000">GAGGT</font><font color="#C0C0C0">t</font><font color="#000000">GGAGTGAGCC</font><font color="#C0C0C0">aa</font><font color="#000000">G</font><font color="#C0C0C0">at</font><font color="#000000">C</font><font color="#C0C0C0">atgccac</font><font color="#000000">TGC</font><font color="#800000">c</font><font color="#000000">CTCTAGCCTGGG</font><font color="#C0C0C0">c</font><font color="#000000">AACAGAGG</font><font color="#C0C0C0">a</font><font color="#000000">AG</font><font color="#C0C0C0">a</font><font color="#000000">CTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS1543_614TM:6:77:17645:6273#0  -                                                                                  <font color="#C0C0C0">ttgaacccaggaggtggagg</font><font color="#000000">TTGGAG</font><font color="#C0C0C0">t</font><font color="#000000">GAGC</font><font color="#C0C0C0">c</font><font color="#000000">AA</font><font color="#C0C0C0">g</font><font color="#000000">ATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS1543_614TM:7:100:16004:10107#0-                                                                                  <font color="#000000">TTGAACCC</font><font color="#C0C0C0">a</font><font color="#000000">GG</font><font color="#C0C0C0">a</font><font color="#000000">GGTGG</font><font color="#C0C0C0">a</font><font color="#000000">GGTTGGA</font><font color="#C0C0C0">g</font><font color="#000000">TGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAG</font><font color="#C0C0C0">a</font><font color="#000000">CTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font>
+HWUSI-EAS729_614T6:2:93:11989:6538#0   -                                                                                   <font color="#C0C0C0">tga</font><font color="#800000">g</font><font color="#C0C0C0">cccaggaggtgga</font><font color="#000000">GGTTGGAGTGAGC</font><font color="#C0C0C0">c</font><font color="#000000">AAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGAA</font>
+HWUSI-EAS1543_614TM:2:81:13732:11884#0 -                                                                                         <font color="#C0C0C0">caggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">ggttgg</font><font color="#800000">g</font><font color="#C0C0C0">gtgagccaagatcatgccactgcactctagc</font><font color="#000000">C</font><font color="#C0C0C0">t</font><font color="#000000">GGGCAA</font><font color="#C0C0C0">ca</font><font color="#000000">GAGGAA</font><font color="#C0C0C0">gactccacct</font><font color="#000000">C</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGAT</font>
+HWUSI-EAS729_614T6:3:11:5262:1432#0    -                                                                                         <font color="#C0C0C0">caggagg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">gg</font><font color="#800000">g</font><font color="#C0C0C0">tggagtgagccaagatcatgcc</font><font color="#800000">c</font><font color="#C0C0C0">ctgcactctagc</font><font color="#000000">CTGGGCAACAGAGGAAGACTCCACCTC</font><font color="#FF8040">*</font><font color="#000000">AAAAAAAAAAAGTGGGA</font><font color="#FF8040">*</font><font color="#000000">AGAGGAT</font>
+____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+
+</pre><pre>
+                                                125893140           125893160           125893180           125893200            125893220           125893240            125893260           125893280           125893300           125893320
+                                          .         |         .         |         .         |         .         |         .          |         .         |         .          |         .         |         .         |         .         |    
+4:125893129-125893324                    CTAAAATTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT*CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC*TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGCATCAAAATTTTAAAATATCCC
+                                                                                                                                                                                                                                               
+HWI-EAS90_614M9:6:67:12631:17754#0     + <font color="#000000">CTAAAATTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACT</font>
+HWUSI-EAS1591_6113C:4:21:6779:18838#0  + <font color="#000000">CTAAAATTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACT</font>
+HWI-EAS90_614M9:1:32:10389:16117#0     +             <font color="#C0C0C0">atttt</font><font color="#000000">GAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">C</font><font color="#C0C0C0">agtagctgtcactgtaggcaaaaat</font>
+HWUSI-EAS1591_6113C:2:27:1355:21017#0  +             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGC</font><font color="#C0C0C0">aa</font><font color="#800000">c</font><font color="#C0C0C0">aat</font>
+HWUSI-EAS1591_6113C:1:93:16865:6051#0  +                   <font color="#000000">AAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCAT</font>
+HWI-EAS90_614M9:3:78:1961:11755#0      +                           <font color="#000000">ATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAA</font><font color="#C0C0C0">a</font><font color="#000000">AA</font><font color="#C0C0C0">t</font><font color="#000000">GCCCA</font><font color="#C0C0C0">t</font><font color="#000000">TATTC</font><font color="#FF8040">*</font><font color="#000000">TGC</font>
+HWI-EAS231_614TA:5:6:17800:6620#0      +                                  <font color="#000000">TTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATAT</font>
+<b><i>HWI-EAS90_614M9:3:95:10317:10581#0     +                                          <font color="#000000">ATATATCATATTCTAAATTATGAAAAGAGAATATGA</font><font color="#FF8040">*</font><font color="#000000">T</font><font color="#C0C0C0">ctctttt</font><font color="#FF8040">c</font><font color="#C0C0C0">cag</font><font color="#FF8040">*</font><font color="#C0C0C0">agc</font><font color="#800000">c</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">c</font><font color="#800000">c</font><font color="#C0C0C0">c</font><font color="#800000">c</font><font color="#C0C0C0">g</font><font color="#800000">g</font><font color="#C0C0C0">a</font><font color="#800000">a</font><font color="#C0C0C0">gc</font><font color="#800000">c</font><font color="#C0C0C0">aaaa</font><font color="#800000">a</font><font color="#C0C0C0">gccc</font><font color="#800000">c</font><font color="#C0C0C0">ttattc</font><font color="#FF8040">t</font><font color="#C0C0C0">t</font><font color="#800000">c</font><font color="#C0C0C0">ctaa</font><font color="#800000">t</font><font color="#C0C0C0">tatcta</font><font color="#6960EC">gggga</font></i></b>
+<b><i>HWI-EAS292_102081428:2:115:1681:2531#0 +                                                        <font color="#C0C0C0">aaattatgaaaagagaatatgattctctttt</font><font color="#FF8040">*</font><font color="#800000">t</font><font color="#C0C0C0">ag</font><font color="#800000">g</font><font color="#C0C0C0">agctgt</font><font color="#800000">t</font><font color="#C0C0C0">ac</font><font color="#6960EC">tgtagggaaaaatgcccattattctgctaaatatctaagtgaggggtgcttctatt</font></i></b>
+HWI-EAS90_614M9:1:67:1331:13704#0      +                                                                       <font color="#000000">AATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATA</font>
+HWI-EAS231_614TA:2:73:4389:2239#0      +                                                                           <font color="#000000">TGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAG</font>
+HWI-EAS231_614TA:7:88:14296:6002#0     +                                                                           <font color="#000000">TGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAG</font>
+HWI-EAS231_614TA:1:26:7960:13504#0     +                                                                              <font color="#000000">TTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">T</font>
+HWI-EAS90_614M9:7:18:13917:3050#0      +                                                                                <font color="#000000">CTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCA</font>
+HWI-EAS292_102081428:1:66:16549:20224#0+                                                                                 <font color="#000000">TCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">T</font><font color="#C0C0C0">g</font><font color="#000000">CTAAATATCTAAGTGATGCTTGCTACTATTAACTG</font><font color="#C0C0C0">a</font><font color="#000000">A</font><font color="#C0C0C0">t</font><font color="#000000">GTAT</font><font color="#C0C0C0">a</font><font color="#000000">TACTAGC</font><font color="#800000">G</font><font color="#000000">TCAA</font>
+HWI-EAS90_614M9:5:77:4642:6832#0       +                                                                                  <font color="#000000">CTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATT</font><font color="#C0C0C0">a</font><font color="#000000">ACTGAATGTATATACTAGC</font><font color="#800000">g</font><font color="#C0C0C0">tcaaa</font>
+HWI-EAS90_614M9:8:34:7077:4638#0       +                                                                                  <font color="#000000">CTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAA</font>
+<b><i>HWUSI-EAS1591_6113C:4:9:4513:12290#0   -       <font color="#000000">TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCAC</font><font color="#6960EC">CTCCTGG</font></i></b>
+HWI-EAS231_614TA:7:49:16816:4213#0     -        <font color="#000000">TATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCA</font>
+HWI-EAS231_614TA:1:118:16290:13237#0   -             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAAT</font>
+HWI-EAS231_614TA:6:113:8101:10568#0    -              <font color="#000000">TTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATG</font>
+HWI-EAS90_614M9:6:48:8352:11907#0      -                       <font color="#000000">ATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATT</font>
+<b><i>HWUSI-EAS1591_6113C:4:39:14328:11130#0 -                         <font color="#000000">ATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCAC</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTG</font></i></b>
+<b><i>HWI-EAS90_614M9:1:85:18838:8742#0      -                                  <font color="#000000">TTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCAC</font><font color="#6960EC">CTCCtgggttcaggTGATTCTCCTGCCTCTACCT</font></i></b>
+<b><i>HWI-EAS90_614M9:4:32:9763:4986#0       -                                  <font color="#000000">TTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTC</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCT</font></i></b>
+HWI-EAS231_614TA:4:103:18855:9257#0    -                                        <font color="#000000">ATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGT</font>
+HWI-EAS292_102081428:2:23:3944:1922#0  -                                        <font color="#C0C0C0">a</font><font color="#000000">TA</font><font color="#C0C0C0">ta</font><font color="#800000">G</font><font color="#000000">ATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGT</font>
+<b><i>HWI-EAS90_614M9:5:18:17924:10181#0     -                                                                               <font color="#C0C0C0">tctctttt</font><font color="#FF8040">*</font><font color="#C0C0C0">cagtagctgtc</font><font color="#6960EC">ccctcctGGGTTCAAGtGaTtCTCCTGCCtCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAA</font></i></b>
+<b><i>HWUSI-EAS1591_6113C:2:117:3095:2051#0  -                                                                                <font color="#000000">CTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAG</font><font color="#C0C0C0">tagctgt</font><font color="#000000">C</font><font color="#C0C0C0">a</font><font color="#000000">C</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAAT</font></i></b>
+HWI-EAS90_614M9:5:28:11006:5910#0      -                                                                                 <font color="#000000">TCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAA</font>
+<b><i>HWI-EAS90_614M9:5:1:12903:5535#0       -                                                                                   <font color="#000000">TTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTA</font><font color="#C0C0C0">g</font><font color="#000000">CTGTCAC</font><font color="#6960EC">CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT</font></i></b>
+HWI-EAS90_614M9:2:56:9827:2778#0       -                                                                                                 <font color="#C0C0C0">tcactgta</font><font color="#000000">GGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWI-EAS90_614M9:4:47:5786:19724#0      -                                                                                                 <font color="#C0C0C0">tcact</font><font color="#000000">GTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWI-EAS90_614M9:6:67:11670:7706#0      -                                                                                                 <font color="#000000">TCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWUSI-EAS1591_6113C:1:117:14883:9756#0 -                                                                                                 <font color="#000000">TCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCC</font>
+HWI-EAS90_614M9:6:37:7790:16256#0      -                                                                                                  <font color="#000000">CACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTAAAATATCCC</font>
+_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+HWUSI-EAS729_614T6:8:86:3208:16885#0   +       <font color="#000000">TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGC</font>
+HWUSI-EAS729_614T6:3:97:10823:18653#0  +         <font color="#000000">ATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAA</font>
+HWUSI-EAS729_614T6:4:113:3054:5730#0   +          <font color="#000000">TGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAG</font><font color="#C0C0C0">gcaa</font><font color="#800000">g</font>
+HWUSI-EAS729_614T6:2:63:5049:3137#0    +            <font color="#000000">AATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAA</font>
+HWUSI-EAS729_614T6:5:95:4777:9034#0    +            <font color="#000000">AATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAA</font>
+HWUSI-EAS729_614T6:8:79:9632:17904#0   +            <font color="#000000">AATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAA</font>
+HWUSI-EAS1543_614TM:8:50:14524:11101#0 +             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAAT</font>
+HWUSI-EAS729_614T6:3:79:10477:10666#0  +                <font color="#000000">TTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCC</font>
+HWUSI-EAS729_614T6:4:80:3846:17138#0   +                <font color="#000000">TTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCC</font>
+HWUSI-EAS729_614T6:4:83:3398:15440#0   +                <font color="#000000">TTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCC</font>
+HWUSI-EAS729_614T6:5:37:19001:5491#0   +                 <font color="#000000">TGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCC</font>
+HWUSI-EAS729_614T6:8:113:1681:2586#0   +                            <font color="#000000">TCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCT</font>
+HWUSI-EAS729_614T6:8:3:18130:10917#0   +                               <font color="#000000">TATTTTGAAATATATATCATAT</font><font color="#C0C0C0">t</font><font color="#000000">CTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAA</font>
+HWUSI-EAS729_614T6:7:32:3784:11386#0   +                                    <font color="#000000">TGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCT</font>
+HWUSI-EAS729_614T6:7:117:8731:4955#0   +                                          <font color="#000000">ATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGA</font>
+HWUSI-EAS729_614T6:8:51:17611:11416#0  +                                           <font color="#000000">TATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGAT</font>
+HWUSI-EAS1543_614TM:1:102:4785:3367#0  +                                                  <font color="#000000">TATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCT</font>
+HWUSI-EAS1543_614TM:6:60:2952:14857#0  +                                                  <font color="#000000">TATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCT</font>
+HWUSI-EAS729_614T6:5:55:11097:17856#0  +                                                             <font color="#000000">ATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTG</font>
+HWUSI-EAS729_614T6:2:8:16102:20401#0   +                                                                <font color="#000000">AAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAAT</font>
+HWUSI-EAS1543_614TM:1:75:3691:5075#0   +                                                                            <font color="#000000">GATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font>
+HWUSI-EAS729_614T6:8:52:15200:10784#0  +                                                                                                  <font color="#000000">CACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGCATCAAA</font><font color="#C0C0C0">att</font><font color="#800000">n</font><font color="#C0C0C0">t</font><font color="#000000">AAAATATCCC</font>
+HWUSI-EAS1543_614TM:7:17:14845:19479#0 -             <font color="#000000">ATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATAT</font><font color="#800000">A</font><font color="#000000">ATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAAT</font>
+HWUSI-EAS729_614T6:3:13:15991:15051#0  -                          <font color="#000000">TATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TG</font>
+HWUSI-EAS729_614T6:7:65:3141:2489#0    -                          <font color="#000000">TATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TG</font>
+HWUSI-EAS729_614T6:8:54:5081:15134#0   -                          <font color="#000000">TATCATATTTT</font><font color="#800000">c</font><font color="#000000">AAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TG</font>
+HWUSI-EAS1543_614TM:4:38:16709:14763#0 -                             <font color="#000000">CATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTA</font>
+HWUSI-EAS1543_614TM:8:50:14524:11101#0 -                                                  <font color="#000000">TATTCTAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCT</font>
+HWUSI-EAS729_614T6:1:56:9586:15810#0   -                                                       <font color="#000000">TAAATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATAT</font><font color="#800000">a</font><font color="#000000">TAAGTGATGCTTGCTACTAT</font>
+HWUSI-EAS729_614T6:1:37:11212:13638#0  -                                                       <font color="#000000">TAAATTATGAA</font><font color="#800000">t</font><font color="#000000">AGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTAT</font>
+HWUSI-EAS729_614T6:1:29:1825:18616#0   -                                                         <font color="#000000">AATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTA</font>
+HWUSI-EAS729_614T6:5:48:14044:12231#0  -                                                         <font color="#000000">AATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTA</font>
+HWUSI-EAS729_614T6:4:115:6035:15619#0  -                                                          <font color="#000000">ATTATGAAAAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAA</font>
+HWUSI-EAS729_614T6:5:72:1269:20227#0   -                                                                  <font color="#C0C0C0">aagagaatatgattctct</font><font color="#000000">T</font><font color="#C0C0C0">t</font><font color="#000000">T</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGT</font>
+HWUSI-EAS729_614T6:7:32:3784:11386#0   -                                                                  <font color="#000000">AAGAGAATATGATTCTCTTTT</font><font color="#FF8040">*</font><font color="#000000">CAGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGT</font>
+HWUSI-EAS1543_614TM:1:102:4785:3367#0  -                                                                                         <font color="#000000">AGTAGCTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTGCTACTATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTA</font>
+HWUSI-EAS1543_614TM:6:60:2952:14857#0  -                                                                                         <font color="#C0C0C0">agtag</font><font color="#000000">CTGTCACTGTAGGCAAAAATGCCCATTATTC</font><font color="#FF8040">*</font><font color="#000000">TGCTAAATATCTAAGTGATGCTTG</font><font color="#C0C0C0">ctact</font><font color="#000000">ATTAACTGAATGTATATACTAGC</font><font color="#800000">G</font><font color="#000000">TCAAAATTTTA</font>
+_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
+
+</pre>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/tumor.predSV.txt	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,3 @@
+4	125893227	+	5	10	66301858	-	4	CTX	29	14	83	71	0.895173453996983	0.230769230769231	0.735384615384615	0.5	1	4	125893135	176	10	66301773	TTATGAATTTTGAAATATATATCATATTTTGAAATATATATCATATTCTAAATTATGAAAAGAGAATATGATTCTCTTTTCAGTAGCTGTCACCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT
+5	7052198	-	0	10	66301865	+	8	CTX	0	22	0	81	0.761379310344828	0.482758620689655	0	0	1	5	7052278	164	10	66301947	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCAGGAGTGAGCCAAGATCATGCCACTGCACTCTAGCCTGGGCAACAGAGGAAGACTCCACCTCAAAAAAAAAAAGTGGGAAGAGG
+10	66301858	+	4	4	125893225	-	1	CTX	15	28	71	81	0.735384615384615	0.5	0.889507154213037	0.243243243243243	1	10	66301777	153	4	125893154	TTAGCCAGGCATGGTGGTGGGCACCTGTAATCCCAGCTACTCGGGAGGTAGAGGCAGGAGAATCACTTGAACCCAGGAGGTGACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/tumor.sclip.txt	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,27 @@
+4	125892327	+	HWUSI-EAS1591_6113C:3:17:12332:19420#0	CC	CC
+4	125892458	+	HWUSI-EAS1591_6113C:4:91:6281:9961#0	GACTAACCACCACGGTACATGTTTTCCTATGTAAAAAACCTGCACATTCTACACATGTATCCCAGAACTTAAAGTAAAACAC	B@C@?:CC>CCBCCCCACBCDCCCCCC;<:<9CCCCC@CCCCCBCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCAC
+4	125893225	+	HWI-EAS90_614M9:5:18:17924:10181#0	CCCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAA	#######@@7@:8@><16+6(B>AABCAA3AB@CC6CCCCCCCDCCCCCCBCCDCCCCCCCCCCCCDCCCCCCCCCCCCCC
+4	125893227	+	HWI-EAS90_614M9:4:32:9763:4986#0	CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCT	CCCC@CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+4	125893227	+	HWI-EAS90_614M9:5:1:12903:5535#0	CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT	B;@@>DABBB>DBAAAB@BABDDDDCCBCDACCBCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCC
+4	125893227	+	HWUSI-EAS1591_6113C:2:117:3095:2051#0	CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAAT	65977A::??BB>?BA8???=BDCCCCBCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDCCCCCCCCCCCCCCC
+4	125893227	+	HWUSI-EAS1591_6113C:4:39:14328:11130#0	CTCCTGGGTTCAAGTGATTCTCCTG	CCCCCCCCCCCCCCCCCCCCCCCCC
+4	125893227	+	HWUSI-EAS1591_6113C:4:9:4513:12290#0	CTCCTGG	CCCCCCC
+4	125893365	-	HWI-EAS292_102081428:1:66:17910:13190#0	TAACTACTT	GFGFDGGGG
+4	125893979	-	HWUSI-EAS1591_6113C:1:81:16173:11673#0	ATAAAATATTTATATTTTATATATTTGTATTCAAT	CCCCCCCCCCCCCCCCCCCCCCCCCCCDCCCCCCC
+10	66301086	-	HWI-EAS231_614TA:6:108:5679:13132#0	AAACATGGTTCAAATAAATTATTTATAAAGAAG	CCCCCCCCCCCCCCCCCBBCCCCCCCCCCCCCC
+10	66301086	-	HWI-EAS292_102081428:1:76:17776:13382#0	AAACATGGTTCAAATAAATTATTTATAAAGAAG	GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
+10	66301858	+	HWI-EAS231_614TA:1:37:3390:19595#0	ACAGCTACT	CCCCCCCCC
+10	66301858	+	HWI-EAS90_614M9:1:98:9476:6999#0	ACAGCTACTGAAAAGAGAATCATATTCTCTTTT	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301858	+	HWI-EAS90_614M9:5:12:2797:13435#0	ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA	CCCCCCDCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301858	+	HWI-EAS90_614M9:7:110:15112:12998#0	ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAAT	CCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301865	-	HWI-EAS231_614TA:4:36:3528:11249#0	TTTGTTCCTTCA	CCCCCCCCCCCC
+10	66301865	-	HWI-EAS231_614TA:5:52:9612:8954#0	CGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCC
+10	66301865	-	HWI-EAS90_614M9:1:118:15320:11068#0	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCDCCCCCCCCCCCCCCCC@CCBCCCDDCCDBCDBCCDBCBCDDD
+10	66301865	-	HWI-EAS90_614M9:3:104:3717:11676#0	GAGTCCGTAGTTTGTTCCTTCA	BBBBBB@9B@878;69?B9AB>
+10	66301865	-	HWI-EAS90_614M9:4:115:17151:16115#0	AGTCCGGAGTTCTCAACGATGGTGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301865	-	HWI-EAS90_614M9:5:27:7334:16234#0	CTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCDCCCCCCCCCCCCCBCCBCCCDCCCCCCBCCCCCCCCC@CC>CAC@CCBABCADDDBDBBBBBB
+10	66301865	-	HWI-EAS90_614M9:7:21:19162:4940#0	TTCA	CCCC
+10	66301865	-	HWUSI-EAS1591_6113C:1:24:6705:7145#0	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGCGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCCDCCCCCCCCCCCCCCCCDCCCDCCCCCCACCCCCCDCCDC98A@C<C?CB9@BA@@BBCBBD@B
+10	66301865	-	HWUSI-EAS1591_6113C:2:55:7685:7454#0	AGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCCCCCC
+10	66301871	-	HWI-EAS90_614M9:3:114:11684:16725#0	ATCAAGAAAATTAATAAACCCTAGCCCATAT	BBBBBBBBB==BBBBBBBBBBBBBBBBBBBB
+10	66302136	+	HWI-EAS231_614TA:4:119:4524:15992#0	TAAATTCCGGACACAGTACTACTATGTTGAAGAGGAGTTG	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/tumor.stat	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,999 @@
+1	7	7
+2	1	1
+3	0	0
+4	1	1
+5	1	1
+6	0	0
+7	0	0
+8	0	0
+9	1	1
+10	0	0
+11	0	0
+12	0	0
+13	0	0
+14	0	0
+15	0	0
+16	0	0
+17	0	0
+18	0	0
+19	0	0
+20	0	0
+21	0	0
+22	0	0
+23	0	0
+24	0	0
+25	0	0
+26	0	0
+27	0	0
+28	0	0
+29	0	0
+30	0	0
+31	0	0
+32	0	0
+33	0	0
+34	0	0
+35	0	0
+36	0	0
+37	0	0
+38	0	0
+39	0	0
+40	0	0
+41	0	0
+42	0	0
+43	0	0
+44	0	0
+45	0	0
+46	0	0
+47	0	0
+48	0	0
+49	0	0
+50	0	0
+51	0	0
+52	0	0
+53	0	0
+54	0	0
+55	0	0
+56	0	0
+57	0	0
+58	0	0
+59	0	0
+60	0	0
+61	0	0
+62	0	0
+63	0	0
+64	0	0
+65	0	0
+66	0	0
+67	0	0
+68	0	0
+69	0	0
+70	0	0
+71	0	0
+72	0	0
+73	0	0
+74	0	0
+75	0	0
+76	0	0
+77	0	0
+78	0	0
+79	0	0
+80	0	0
+81	0	0
+82	0	0
+83	0	0
+84	0	0
+85	0	0
+86	0	0
+87	0	0
+88	0	0
+89	0	0
+90	0	0
+91	0	0
+92	0	0
+93	0	0
+94	0	0
+95	0	0
+96	0	0
+97	0	0
+98	0	0
+99	0	0
+100	0	0
+101	0	0
+102	0	0
+103	0	0
+104	0	0
+105	0	0
+106	0	0
+107	0	0
+108	0	0
+109	0	0
+110	0	0
+111	0	0
+112	0	0
+113	0	0
+114	0	0
+115	0	0
+116	0	0
+117	0	0
+118	0	0
+119	0	0
+120	0	0
+121	0	0
+122	0	0
+123	0	0
+124	0	0
+125	0	0
+126	0	0
+127	0	0
+128	0	0
+129	0	0
+130	0	0
+131	0	0
+132	0	0
+133	0	0
+134	0	0
+135	0	0
+136	0	0
+137	0	0
+138	0	0
+139	0	0
+140	0	0
+141	0	0
+142	0	0
+143	0	0
+144	0	0
+145	0	0
+146	0	0
+147	0	0
+148	0	0
+149	0	0
+150	0	0
+151	0	0
+152	0	0
+153	0	0
+154	0	0
+155	0	0
+156	0	0
+157	0	0
+158	0	0
+159	0	0
+160	0	0
+161	0	0
+162	0	0
+163	0	0
+164	0	0
+165	0	0
+166	0	0
+167	0	0
+168	0	0
+169	0	0
+170	0	0
+171	0	0
+172	0	0
+173	0	0
+174	0	0
+175	0	0
+176	0	0
+177	0	0
+178	0	0
+179	0	0
+180	0	0
+181	0	0
+182	0	0
+183	0	0
+184	0	0
+185	0	0
+186	0	0
+187	0	0
+188	0	0
+189	0	0
+190	0	0
+191	0	0
+192	0	0
+193	0	0
+194	0	0
+195	0	0
+196	0	0
+197	0	0
+198	0	0
+199	0	0
+200	0	0
+201	0	0
+202	0	0
+203	0	0
+204	0	0
+205	0	0
+206	0	0
+207	0	0
+208	0	0
+209	0	0
+210	0	0
+211	0	0
+212	0	0
+213	0	0
+214	0	0
+215	0	0
+216	0	0
+217	0	0
+218	0	0
+219	0	0
+220	0	0
+221	0	0
+222	0	0
+223	0	0
+224	0	0
+225	0	0
+226	0	0
+227	0	0
+228	0	0
+229	0	0
+230	0	0
+231	0	0
+232	0	0
+233	0	0
+234	0	0
+235	0	0
+236	0	0
+237	0	0
+238	0	0
+239	0	0
+240	0	0
+241	0	0
+242	0	0
+243	0	0
+244	0	0
+245	0	0
+246	0	0
+247	0	0
+248	0	0
+249	0	0
+250	0	0
+251	0	0
+252	0	0
+253	0	0
+254	0	0
+255	0	0
+256	0	0
+257	0	0
+258	0	0
+259	0	0
+260	0	0
+261	0	0
+262	0	0
+263	0	0
+264	0	0
+265	0	0
+266	0	0
+267	0	0
+268	0	0
+269	0	0
+270	0	0
+271	0	0
+272	0	0
+273	0	0
+274	0	0
+275	0	0
+276	0	0
+277	0	0
+278	0	0
+279	0	0
+280	0	0
+281	0	0
+282	0	0
+283	0	0
+284	0	0
+285	0	0
+286	0	0
+287	0	0
+288	0	0
+289	0	0
+290	0	0
+291	0	0
+292	0	0
+293	0	0
+294	0	0
+295	0	0
+296	0	0
+297	0	0
+298	0	0
+299	0	0
+300	0	0
+301	0	0
+302	0	0
+303	0	0
+304	0	0
+305	0	0
+306	0	0
+307	0	0
+308	0	0
+309	0	0
+310	0	0
+311	0	0
+312	0	0
+313	0	0
+314	0	0
+315	0	0
+316	0	0
+317	0	0
+318	0	0
+319	0	0
+320	0	0
+321	0	0
+322	0	0
+323	0	0
+324	0	0
+325	0	0
+326	0	0
+327	0	0
+328	0	0
+329	0	0
+330	0	0
+331	0	0
+332	0	0
+333	0	0
+334	0	0
+335	0	0
+336	0	0
+337	0	0
+338	0	0
+339	0	0
+340	0	0
+341	0	0
+342	0	0
+343	0	0
+344	0	0
+345	0	0
+346	0	0
+347	0	0
+348	0	0
+349	0	0
+350	0	0
+351	0	0
+352	0	0
+353	0	0
+354	0	0
+355	0	0
+356	0	0
+357	0	0
+358	0	0
+359	0	0
+360	0	0
+361	0	0
+362	0	0
+363	0	0
+364	0	0
+365	0	0
+366	0	0
+367	0	0
+368	0	0
+369	0	0
+370	0	0
+371	0	0
+372	0	0
+373	0	0
+374	0	0
+375	0	0
+376	0	0
+377	0	0
+378	0	0
+379	0	0
+380	0	0
+381	0	0
+382	0	0
+383	0	0
+384	0	0
+385	0	0
+386	0	0
+387	0	0
+388	0	0
+389	0	0
+390	0	0
+391	0	0
+392	0	0
+393	0	0
+394	0	0
+395	0	0
+396	0	0
+397	0	0
+398	0	0
+399	0	0
+400	0	0
+401	0	0
+402	0	0
+403	0	0
+404	0	0
+405	0	0
+406	0	0
+407	0	0
+408	0	0
+409	0	0
+410	0	0
+411	0	0
+412	0	0
+413	0	0
+414	0	0
+415	0	0
+416	0	0
+417	0	0
+418	0	0
+419	0	0
+420	0	0
+421	0	0
+422	0	0
+423	0	0
+424	0	0
+425	0	0
+426	0	0
+427	0	0
+428	0	0
+429	0	0
+430	0	0
+431	0	0
+432	0	0
+433	0	0
+434	0	0
+435	0	0
+436	0	0
+437	0	0
+438	0	0
+439	0	0
+440	0	0
+441	0	0
+442	0	0
+443	0	0
+444	0	0
+445	0	0
+446	0	0
+447	0	0
+448	0	0
+449	0	0
+450	0	0
+451	0	0
+452	0	0
+453	0	0
+454	0	0
+455	0	0
+456	0	0
+457	0	0
+458	0	0
+459	0	0
+460	0	0
+461	0	0
+462	0	0
+463	0	0
+464	0	0
+465	0	0
+466	0	0
+467	0	0
+468	0	0
+469	0	0
+470	0	0
+471	0	0
+472	0	0
+473	0	0
+474	0	0
+475	0	0
+476	0	0
+477	0	0
+478	0	0
+479	0	0
+480	0	0
+481	0	0
+482	0	0
+483	0	0
+484	0	0
+485	0	0
+486	0	0
+487	0	0
+488	0	0
+489	0	0
+490	0	0
+491	0	0
+492	0	0
+493	0	0
+494	0	0
+495	0	0
+496	0	0
+497	0	0
+498	0	0
+499	0	0
+500	0	0
+501	0	0
+502	0	0
+503	0	0
+504	0	0
+505	0	0
+506	0	0
+507	0	0
+508	0	0
+509	0	0
+510	0	0
+511	0	0
+512	0	0
+513	0	0
+514	0	0
+515	0	0
+516	0	0
+517	0	0
+518	0	0
+519	0	0
+520	0	0
+521	0	0
+522	0	0
+523	0	0
+524	0	0
+525	0	0
+526	0	0
+527	0	0
+528	0	0
+529	0	0
+530	0	0
+531	0	0
+532	0	0
+533	0	0
+534	0	0
+535	0	0
+536	0	0
+537	0	0
+538	0	0
+539	0	0
+540	0	0
+541	0	0
+542	0	0
+543	0	0
+544	0	0
+545	0	0
+546	0	0
+547	0	0
+548	0	0
+549	0	0
+550	0	0
+551	0	0
+552	0	0
+553	0	0
+554	0	0
+555	0	0
+556	0	0
+557	0	0
+558	0	0
+559	0	0
+560	0	0
+561	0	0
+562	0	0
+563	0	0
+564	0	0
+565	0	0
+566	0	0
+567	0	0
+568	0	0
+569	0	0
+570	0	0
+571	0	0
+572	0	0
+573	0	0
+574	0	0
+575	0	0
+576	0	0
+577	0	0
+578	0	0
+579	0	0
+580	0	0
+581	0	0
+582	0	0
+583	0	0
+584	0	0
+585	0	0
+586	0	0
+587	0	0
+588	0	0
+589	0	0
+590	0	0
+591	0	0
+592	0	0
+593	0	0
+594	0	0
+595	0	0
+596	0	0
+597	0	0
+598	0	0
+599	0	0
+600	0	0
+601	0	0
+602	0	0
+603	0	0
+604	0	0
+605	0	0
+606	0	0
+607	0	0
+608	0	0
+609	0	0
+610	0	0
+611	0	0
+612	0	0
+613	0	0
+614	0	0
+615	0	0
+616	0	0
+617	0	0
+618	0	0
+619	0	0
+620	0	0
+621	0	0
+622	0	0
+623	0	0
+624	0	0
+625	0	0
+626	0	0
+627	0	0
+628	0	0
+629	0	0
+630	0	0
+631	0	0
+632	0	0
+633	0	0
+634	0	0
+635	0	0
+636	0	0
+637	0	0
+638	0	0
+639	0	0
+640	0	0
+641	0	0
+642	0	0
+643	0	0
+644	0	0
+645	0	0
+646	0	0
+647	0	0
+648	0	0
+649	0	0
+650	0	0
+651	0	0
+652	0	0
+653	0	0
+654	0	0
+655	0	0
+656	0	0
+657	0	0
+658	0	0
+659	0	0
+660	0	0
+661	0	0
+662	0	0
+663	0	0
+664	0	0
+665	0	0
+666	0	0
+667	0	0
+668	0	0
+669	0	0
+670	0	0
+671	0	0
+672	0	0
+673	0	0
+674	0	0
+675	0	0
+676	0	0
+677	0	0
+678	0	0
+679	0	0
+680	0	0
+681	0	0
+682	0	0
+683	0	0
+684	0	0
+685	0	0
+686	0	0
+687	0	0
+688	0	0
+689	0	0
+690	0	0
+691	0	0
+692	0	0
+693	0	0
+694	0	0
+695	0	0
+696	0	0
+697	0	0
+698	0	0
+699	0	0
+700	0	0
+701	0	0
+702	0	0
+703	0	0
+704	0	0
+705	0	0
+706	0	0
+707	0	0
+708	0	0
+709	0	0
+710	0	0
+711	0	0
+712	0	0
+713	0	0
+714	0	0
+715	0	0
+716	0	0
+717	0	0
+718	0	0
+719	0	0
+720	0	0
+721	0	0
+722	0	0
+723	0	0
+724	0	0
+725	0	0
+726	0	0
+727	0	0
+728	0	0
+729	0	0
+730	0	0
+731	0	0
+732	0	0
+733	0	0
+734	0	0
+735	0	0
+736	0	0
+737	0	0
+738	0	0
+739	0	0
+740	0	0
+741	0	0
+742	0	0
+743	0	0
+744	0	0
+745	0	0
+746	0	0
+747	0	0
+748	0	0
+749	0	0
+750	0	0
+751	0	0
+752	0	0
+753	0	0
+754	0	0
+755	0	0
+756	0	0
+757	0	0
+758	0	0
+759	0	0
+760	0	0
+761	0	0
+762	0	0
+763	0	0
+764	0	0
+765	0	0
+766	0	0
+767	0	0
+768	0	0
+769	0	0
+770	0	0
+771	0	0
+772	0	0
+773	0	0
+774	0	0
+775	0	0
+776	0	0
+777	0	0
+778	0	0
+779	0	0
+780	0	0
+781	0	0
+782	0	0
+783	0	0
+784	0	0
+785	0	0
+786	0	0
+787	0	0
+788	0	0
+789	0	0
+790	0	0
+791	0	0
+792	0	0
+793	0	0
+794	0	0
+795	0	0
+796	0	0
+797	0	0
+798	0	0
+799	0	0
+800	0	0
+801	0	0
+802	0	0
+803	0	0
+804	0	0
+805	0	0
+806	0	0
+807	0	0
+808	0	0
+809	0	0
+810	0	0
+811	0	0
+812	0	0
+813	0	0
+814	0	0
+815	0	0
+816	0	0
+817	0	0
+818	0	0
+819	0	0
+820	0	0
+821	0	0
+822	0	0
+823	0	0
+824	0	0
+825	0	0
+826	0	0
+827	0	0
+828	0	0
+829	0	0
+830	0	0
+831	0	0
+832	0	0
+833	0	0
+834	0	0
+835	0	0
+836	0	0
+837	0	0
+838	0	0
+839	0	0
+840	0	0
+841	0	0
+842	0	0
+843	0	0
+844	0	0
+845	0	0
+846	0	0
+847	0	0
+848	0	0
+849	0	0
+850	0	0
+851	0	0
+852	0	0
+853	0	0
+854	0	0
+855	0	0
+856	0	0
+857	0	0
+858	0	0
+859	0	0
+860	0	0
+861	0	0
+862	0	0
+863	0	0
+864	0	0
+865	0	0
+866	0	0
+867	0	0
+868	0	0
+869	0	0
+870	0	0
+871	0	0
+872	0	0
+873	0	0
+874	0	0
+875	0	0
+876	0	0
+877	0	0
+878	0	0
+879	0	0
+880	0	0
+881	0	0
+882	0	0
+883	0	0
+884	0	0
+885	0	0
+886	0	0
+887	0	0
+888	0	0
+889	0	0
+890	0	0
+891	0	0
+892	0	0
+893	0	0
+894	0	0
+895	0	0
+896	0	0
+897	0	0
+898	0	0
+899	0	0
+900	0	0
+901	0	0
+902	0	0
+903	0	0
+904	0	0
+905	0	0
+906	0	0
+907	0	0
+908	0	0
+909	0	0
+910	0	0
+911	0	0
+912	0	0
+913	0	0
+914	0	0
+915	0	0
+916	0	0
+917	0	0
+918	0	0
+919	0	0
+920	0	0
+921	0	0
+922	0	0
+923	0	0
+924	0	0
+925	0	0
+926	0	0
+927	0	0
+928	0	0
+929	0	0
+930	0	0
+931	0	0
+932	0	0
+933	0	0
+934	0	0
+935	0	0
+936	0	0
+937	0	0
+938	0	0
+939	0	0
+940	0	0
+941	0	0
+942	0	0
+943	0	0
+944	0	0
+945	0	0
+946	0	0
+947	0	0
+948	0	0
+949	0	0
+950	0	0
+951	0	0
+952	0	0
+953	0	0
+954	0	0
+955	0	0
+956	0	0
+957	0	0
+958	0	0
+959	0	0
+960	0	0
+961	0	0
+962	0	0
+963	0	0
+964	0	0
+965	0	0
+966	0	0
+967	0	0
+968	0	0
+969	0	0
+970	0	0
+971	0	0
+972	0	0
+973	0	0
+974	0	0
+975	0	0
+976	0	0
+977	0	0
+978	0	0
+979	0	0
+980	0	0
+981	0	0
+982	0	0
+983	0	0
+984	0	0
+985	0	0
+986	0	0
+987	0	0
+988	0	0
+989	0	0
+990	0	0
+991	0	0
+992	0	0
+993	0	0
+994	0	0
+995	0	0
+996	0	0
+997	0	0
+998	0	0
+999	0	0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extractSClip.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,390 @@
+#!/usr/bin/perl -w
+use strict;
+#use lib '/home/jwang2/AssembleTest/Detect/nonSJsrc/dev';
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+use Bio::DB::Sam;
+use File::Temp qw/ tempfile tempdir /;
+use File::Spec;
+use File::Basename;
+use Cwd;
+use List::MoreUtils qw/ uniq /;
+#custom packages
+use SCValidator qw($lowqual_cutoff $min_percent_id $min_percent_hq LEFT_CLIP RIGHT_CLIP);
+use SVUtil qw($use_scratch $work_dir get_input_bam get_work_dir parse_range is_PCR_dup);
+
+use constant FQ_BASE_NUMBER => 33;
+
+my $rmdup = 0;
+my $print_read = 1;
+$use_scratch = 0;
+$min_percent_id = 90;
+my ($work_dir, $out_dir);
+my $ref_genome;
+# input/output
+my ($out_prefix, $range, $input_bam );
+my $out_suffix = "sclip.txt";
+my $paired = 1;
+my ( $help, $man, $version, $usage );
+my $optionOK = GetOptions(
+	'i|in|input=s'	=> \$input_bam,	
+	'o|out_dir=s'	=> \$out_dir,
+	'ref_genome=s'  => \$ref_genome,
+	'p=s'			=> \$out_prefix,
+	'scratch!'		=> \$use_scratch,
+	'paired!'		=> \$paired,
+	'rmdup!'		=> \$rmdup,
+	'lq_cutoff=i'	=> \$lowqual_cutoff,
+	'min_pct_id=i'	=> \$min_percent_id,
+	'min_pct_hq=i'	=> \$min_percent_hq,
+	'print_read!'	=> \$print_read,
+	'r|range=s'		=> \$range,
+	'h|help|?'		=> \$help,
+	'man'			=> \$man,
+	'usage'			=> \$usage,
+	'v|version'		=> \$version,
+);
+
+pod2usage(-verbose=>2) if($man or $usage);
+pod2usage(1) if($help or $version );
+
+my $start_dir = getcwd;
+if($input_bam) {
+	croak "The bam file you specified does not exist!\n" unless(-e $input_bam);
+	$input_bam = File::Spec->rel2abs($input_bam);
+}
+else{
+	croak "You must specify the input bam file or sample name";
+}
+croak "You must provide the reference genome in fasta format!" if(!$ref_genome);
+croak "The reference genome file you speicified does not exist!\n"
+	unless(-e $ref_genome);
+
+my $input_base = fileparse($input_bam);
+
+#setup output dir and workind directory
+$out_dir = getcwd if(!$out_dir);
+mkdir $out_dir if(!-e $out_dir || ! -d $out_dir);
+$work_dir = get_work_dir() if($use_scratch);
+$work_dir = $out_dir if(!$work_dir);
+$use_scratch = undef if($work_dir eq $out_dir);
+chdir($work_dir); 
+
+# figure out output prefix
+$out_prefix = $input_base if(!$out_prefix);
+
+my $sam = Bio::DB::Sam->new( -bam => $input_bam, -fasta => $ref_genome);
+
+my $output_file;
+my $validator = SCValidator->new();
+if(!$paired) {
+	$validator->remove_validator("strand_validator");
+}
+if($range) {
+	my ($chr, $start, $end) = parse_range($range);
+	my $tmp = $chr;
+	$tmp = $tmp . ".$start" if($start);
+	$tmp = $tmp . ".$end" if($end);
+	$output_file = join('.', $out_prefix, $tmp, $out_suffix);
+	$output_file = File::Spec->catfile($out_dir, $output_file);
+
+	my($pcover, $ncover) = extract_range_sclip(
+		-SAM => $sam, 
+		-RANGE => $range, 
+		-WORK_DIR => $work_dir, 
+		-OUTPUT => $output_file,  
+		-VALIDATOR => $validator);
+	$output_file = join('.', $out_prefix, $tmp, "cover");
+	$output_file = File::Spec->catfile($out_dir, $output_file);
+	warn "$output_file file exists and it will be replaced!" if(-e $output_file);
+	$rmdup = 0;
+	#$start = 0 unless $start;
+    #my ($tid) = $sam->header->parse_region($chr);
+    #my $chr_len = $sam->header->target_len->[$tid];
+	#$end = $chr_len unless $end;
+	
+	#my ($coverage) = $sam->features(-type => 'coverage', -seq_id => $chr,
+	#	-start => $start, -end => $end);
+	#my @cc = $coverage->coverage;
+
+	$rmdup = 0;
+	my($fh, $fname) = tempfile( DIR => $work_dir);
+	foreach my $p (keys(%{$pcover})) {
+		my $c = ($rmdup ? scalar(@{$pcover->{$p}}) : $pcover->{$p});
+		print $fh join("\t", $chr, $p, "+", $c, count_coverage($sam, $chr, $p)), "\n";
+	}
+	foreach my $p (keys(%{$ncover})) {
+		my $c = ($rmdup ? scalar(@{$ncover->{$p}}) : $ncover->{$p});
+		print $fh join("\t", $chr, $p, "-", $c , count_coverage($sam, $chr, $p)), "\n";
+	}
+	system("sort -k 2 -n $fname -o $output_file");
+	system("rm $fname");
+}
+else{
+	$output_file = join('.', $out_prefix, $out_suffix);
+	$output_file = File::Spec->catfile($out_dir, $output_file);
+    my $header = $sam->header;
+    my $target_names = $header->target_name;
+    $output_file = join('.', $out_prefix, "cover");
+	my $read_file = join('.', $out_prefix, "sclip.txt");
+    $output_file = File::Spec->catfile($out_dir, $output_file);
+    $read_file = File::Spec->catfile($out_dir, $read_file);
+
+	if(-e $output_file) {
+		warn "$output_file file exists and it will be replaced!";
+		system("rm $output_file");
+	}
+	my @t_names = uniq @{$target_names};
+    foreach my $chr (@t_names){
+		my($fh, $fname) = tempfile( DIR => $work_dir);
+        my($pcover, $ncover) = extract_range_sclip(
+			-SAM => $sam,
+			-RANGE =>$chr, 
+			-WORK_DIR => $work_dir, 
+			-OUTPUT => $read_file, 
+			-VALIDATOR => $validator);
+		foreach my $p (keys(%{$pcover})) {
+			my $c = ($rmdup ? scalar(@{$pcover->{$p}}) : $pcover->{$p});
+			print $fh join("\t", $chr, $p, "+", $c, count_coverage($sam, $chr, $p) ), "\n";
+		}
+		foreach my $p (keys(%{$ncover})) {
+			my $c = ($rmdup ? scalar(@{$ncover->{$p}}) : $ncover->{$p});
+			print $fh join("\t", $chr, $p, "-", $c, count_coverage($sam, $chr, $p)), "\n";
+		}
+		system("sort -k 2 -n $fname -o $fname.sorted");
+		system("cat $fname.sorted >> $output_file");
+		system("rm $fname");
+		system("rm $fname.sorted");
+    }
+}
+chdir $start_dir;
+exit(0);
+
+sub count_coverage {
+	my ($sam, $chr, $pos, $clip) = @_;
+	if($rmdup) {
+		my @pairs;
+		my $seg = $sam->segment(-seq_id => $chr, -start => $pos, -end => $pos);
+		my $n = 0;
+		my $itr = $seg->features(-iterator => 1);
+		while( my $a = $itr->next_seq) {
+			my $sclip_len = 0;
+			if($clip) {
+				my @cigar_array = @{$a->cigar_array};
+				$sclip_len = $cigar_array[0]->[1] if($cigar_array[0]->[0] eq 'S' && $clip == RIGHT_CLIP);
+				$sclip_len = $cigar_array[$#cigar_array]->[1] if($cigar_array[$#cigar_array]->[0] eq 'S' && $clip == RIGHT_CLIP);
+			}
+			next if(@pairs > 0 && is_PCR_dup($a, \@pairs, $sclip_len));
+			$n++;
+			#return $n if( $n > $max_repetitive_cover);
+			if($a->mpos) {
+				push @pairs, [$a->start, $a->end, $a->mate_start, $a->mate_end, $sclip_len];
+			}
+			else {
+				push @pairs, [$a->start, $a->end, 0, 0, $sclip_len];
+			}
+
+		}
+		return $n;
+	}
+	else{
+		my ($c) = $sam->features(-type => 'coverage', -seq_id=> $chr, 
+			-start => $pos, -end => $pos);
+		my @c_d = $c->coverage;
+		return $c_d[0];
+	}
+}
+
+sub extract_range_sclip {
+	my %arg = @_;
+	my $sam = $arg{-SAM} || croak "missing -SAM";
+	my $range = $arg{-RANGE} || croak "missing -RANGE";
+	my $output_file = $arg{-OUTPUT} || croak "missing -OUTPUT";
+	my $validator = $arg{-VALIDATOR} || croak "missing -VALIDATOR";
+
+	my($fh, $fname) = tempfile( DIR => $work_dir);
+	my (%plus_cover, %neg_cover);
+	$sam->fetch($range, 
+		sub {
+			my $a = shift;
+			my $cigar_str = $a->cigar_str;
+#			print STDERR $a->qname, "\t", $cigar_str, "\n";
+			my @cigar_array = @{$a->cigar_array};
+			return if($a->cigar_str !~ m/S/);
+			if($paired && !$a->proper_pair) { #paired but mate is not mapped 
+				$validator->remove_validator("strand_validator");
+			}
+			#return if(!$a->proper_pair && $paired);
+			#return if($paired && !$a->mpos); 
+			my ($sclip_len, $ort, $pos, $seq, $qual_str, $qual);
+			$qual_str = join( "",  (map { chr $_ + FQ_BASE_NUMBER } $a->qscore));
+			if($cigar_array[0]->[0] eq 'S' && $validator->validate($a, LEFT_CLIP) ) {
+				$sclip_len = $cigar_array[0]->[1]; $ort = "-"; $pos = $a->start;
+				$seq = substr($a->query->dna, 0, $sclip_len );
+				$qual = substr($qual_str, 0, $sclip_len);
+				
+				my $print = 1;
+				if($rmdup) {
+					if(exists $neg_cover{$pos}) {
+						$print = 0 if(is_PCR_dup($a, $neg_cover{$pos}, $sclip_len));
+					}
+					else {
+						$neg_cover{$pos} = [];
+					}
+					if($print == 1) {
+						if($a->mpos) {
+							push @{$neg_cover{$pos}}, [$a->start, $a->end, $a->mate_start, $a->mate_end, $sclip_len];
+						}
+						else {
+							push @{$neg_cover{$pos}}, [$a->start, $a->end, 0, 0, $sclip_len];
+						}
+					}
+				}
+				else {
+					if(exists $neg_cover{$pos}) {
+						$neg_cover{$pos}++;
+					}
+					else{
+						$neg_cover{$pos} = 1;
+					}
+				}
+				print $fh join("\t", $a->seq_id, $pos, $ort, $a->qname, $seq, $qual), "\n"
+					if($print_read && $print == 1);
+			}
+
+			if($cigar_array[$#cigar_array]->[0] eq 'S' &&  $validator->validate($a, RIGHT_CLIP)) {
+				$sclip_len = $cigar_array[$#cigar_array]->[1]; $ort = '+'; $pos = $a->end;
+				my $l = length($a->query->dna);
+				$seq = substr($a->query->dna, $l - $sclip_len);
+				$qual = substr($qual_str, $l - $sclip_len);
+
+				my $print = 1;
+				if($rmdup) {
+					if(exists $plus_cover{$pos}) {
+						$print = 0 if(is_PCR_dup($a, $plus_cover{$pos}, $sclip_len));
+					}
+					else {
+						$plus_cover{$pos} = [];
+					}
+					if($print ==1 ) {
+						if($a->mpos) {
+							push @{$plus_cover{$pos}}, [$a->start, $a->end, $a->mate_start, $a->mate_end, $sclip_len];
+						}
+						else {
+							push @{$plus_cover{$pos}}, [$a->start, 0, 0, $a->mate_end, $sclip_len];
+						}
+					}
+				}
+				else {
+					if(exists $plus_cover{$pos}) {
+						$plus_cover{$pos}++;
+					}
+					else{
+						$plus_cover{$pos} = 1;
+					}
+				}
+				$print = is_PCR_dup($a, $plus_cover{$pos}, $sclip_len) if($rmdup);
+				print $fh join("\t", $a->seq_id, $pos, $ort, $a->qname, $seq, $qual), "\n"
+					if($print_read && $print);
+			}
+			if($paired && !$a->proper_pair) { #paired but mate is not mapped, add back
+				$validator->add_validator("strand_validator"); 
+			}
+		}
+	);
+	if($print_read) {
+		system("sort -k 2 -n $fname -o $fname.sorted");
+		system("cat $fname.sorted >> $output_file");
+		system("rm $fname");
+		system("rm $fname.sorted");
+	}
+	return(\%plus_cover, \%neg_cover);
+}
+
+
+=head1 NAME
+
+extractSClip.pl - extract positions with soft clipped read in bam file.
+
+
+=head1 VERSION
+
+This documentation refers to extractSClip.pl version 0.0.1.
+
+
+=head1 USAGE
+
+	# extract all positions with soft clipped reads in whole genome:
+	./extractSClip.pl -i sample.bam -g hg18.fa 
+	# extract chr1 positions with soft clipped reads
+	./extractSClip.pl -i sample.bam -g hg18.fa -r chr1
+
+
+=head1 REQUIRED ARGUMENTS
+
+	-i: Input bam file.
+	--ref_genome: The genome file in fa file, must be the same used to map reads.
+	
+
+=head1 OPTIONS
+
+	-r: The range of positions need to be extracted. Format: chr1 or chr1:500-5000.
+	-o: The output directory, default is current directory.
+	--scratch: use scracth space, default off.
+	--rmdup: remove PCR dumplicate reads, default on, use --normdup to turn it off.
+	--lq_cutoff: low quality cutoff value, default 20. 
+	--min_pct_id: minimum percent identify for the aligned high qual part,default 90.
+	--min_pct_hq: minimum percent high quality for soft clipped part, default 80.
+	--print_read: individual soft-clipped read will be printed, default off.
+	-h, --help: The help page.
+	--man: Print the man page.
+	--usage: Print usage information.
+	-v, --version: print version information.
+
+
+=head1 DESCRIPTION
+
+This is a program to extract all soft-clipped positions such that for each position
+a list of requirements need to be satisfied. More specifically, the orientaion of 
+pair-end read should be satisfied, the minimum percent identify of aligned part 
+need to be satisfied, and the minimum percent of hiqh quality soft-clipped part 
+should be satisfied.
+
+
+=head1 DEPENDENCIES
+
+The program depend on several packages:
+1. Bioperl perl module.
+2. Bio::DB::Sam, version 1.5 or later, it requires samtools lib installed.
+
+=head1 BUGS AND LIMITATIONS
+
+There are no known bugs in this module, but the method is limitted to bam file 
+that has soft-clipping cigar string generated.Please report problems to 
+Jianmin Wang  (Jianmin.Wang@stjude.org)
+Patches are welcome.
+
+=head1 AUTHOR
+
+Jianmin Wang (Jianmin.Wang@stjude.org)
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2010 by St. Jude Children's Research Hospital.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version. 
+
+This program is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of 
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
Binary file germline.bam has changed
Binary file germline.bam.bai has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/getSomaticPindel.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,142 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+
+my ( $help, $man, $version, $usage );
+my ($infile, $outfile);
+my $optionOK = GetOptions(
+	'h|help|?'		=> \$help,
+	'man'			=> \$man,
+	'usage'			=> \$usage,
+	'v|version'		=> \$version,
+	'i|input=s'		=> \$infile,
+	'o|output=s'	=> \$outfile,
+);
+
+pod2usage(2) if($man);
+pod2usage( -verbose => 99, -sections => "USAGE|REQUIRED ARGUMENTS|OPTIONS" ) 
+	if($help or $usage or !$infile or !$outfile);
+pod2usage( -verbose => 99, -sections => "VERSION") if($version);
+
+open my $IN "<$infile" or croak "can't open $infile:$OS_ERROR";
+while(my $line = <$IN>) {
+
+}
+=head1 NAME
+
+<application name> - <One-line description of application's purpose>
+
+
+=head1 VERSION
+
+The initial template usually just has:
+
+This documentation refers to <application name> version 0.0.1.
+
+
+=head1 USAGE
+
+    # Brief working invocation example(s) here showing the most common usage(s)
+
+	# This section will be as far as many users ever read,
+	# so make it as educational and exemplary as possible.
+=head1 REQUIRED ARGUMENTS
+
+A complete list of every argument that must appear on the command line.
+when the application  is invoked, explaining what each of them does, any
+restrictions on where each one may appear (i.e., flags that must appear
+before or after filenames), and how the various arguments and options
+may interact (e.g., mutual exclusions, required combinations, etc.)
+
+If all of the application's arguments are optional, this section
+may be omitted entirely.
+
+=head1 OPTIONS
+
+A complete list of every available option with which the application
+can be invoked, explaining what each does, and listing any restrictions,
+or interactions.
+
+If the application has no options, this section may be omitted entirely.
+
+
+=head1 DESCRIPTION
+
+A full description of the application and its features.
+May include numerous subsections (i.e., =head2, =head3, etc.).
+
+
+=head1 DIAGNOSTICS
+
+A list of every error and warning message that the application can generate
+(even the ones that will "never happen"), with a full explanation of each
+problem, one or more likely causes, and any suggested remedies. If the
+application generates exit status codes (e.g., under Unix), then list the exit
+status associated with each error.
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+A full explanation of any configuration system(s) used by the application,
+including the names and locations of any configuration files, and the
+meaning of any environment variables or properties that can be set. These
+descriptions must also include details of any configuration language used.
+
+
+=head1 DEPENDENCIES
+
+A list of all the other modules that this module relies upon, including any
+restrictions on versions, and an indication of whether these required modules are
+part of the standard Perl distribution, part of the module's distribution,
+or must be installed separately.
+
+
+=head1 INCOMPATIBILITIES
+
+A list of any modules that this module cannot be used in conjunction with.
+This may be due to name conflicts in the interface, or competition for
+system or program resources, or due to internal limitations of Perl
+(for example, many modules that use source code filters are mutually
+incompatible).
+
+
+=head1 BUGS AND LIMITATIONS
+
+A list of known problems with the module, together with some indication of
+whether they are likely to be fixed in an upcoming release.
+
+Also a list of restrictions on the features the module does provide:
+data types that cannot be handled, performance issues and the circumstances
+in which they may arise, practical limitations on the size of data sets,
+special cases that are not (yet) handled, etc.
+
+The initial template usually just has:
+
+There are no known bugs in this module.
+Please report problems to <Maintainer name(s)>  (<contact address>)
+Patches are welcome.
+
+=head1 AUTHOR
+
+<Author name(s)> (<contact address>)
+
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) <year> <copyright holder> (<contact address>). All rights reserved.
+
+followed by whatever licence you wish to release it under.
+For Perl code that is often just:
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/getUniqSV.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,222 @@
+#!/nfs_exports/apps/64-bit/gnu-apps/perl5.8.9/bin/perl -w
+
+use strict;
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+use DBI;
+use DBD::mysql;
+
+my $db = 'hg18';
+my $port = 3306;
+my $host = '10.4.19.125';
+my $USER = "sjXuser";
+
+my ( $help, $man, $version, $usage );
+my ($in, $normal, $out);
+my $optionOK = GetOptions(
+	'd|i|in|input=s'	=> \$in,
+	'g|normal=s'	    => \$normal,
+	'o|out|output=s'	=> \$out,
+	'h|help|?'		=> \$help,
+	'man'			=> \$man,
+	'usage'			=> \$usage,
+	'v|version'		=> \$version,
+);
+
+pod2usage(2) if($man);
+pod2usage( -verbose => 99, -sections => "USAGE|REQUIRED ARGUMENTS|OPTIONS" ) 
+	if($help or $usage);
+pod2usage( -verbose => 99, -sections => "VERSION") if($version);
+
+croak "Missing input file" if(!$in);
+open STDOUT, ">$out" if($out);
+open my $IN, "<$in" or croak "can't open $in: $OS_ERROR";
+open my $NORMAL, "<$normal" or croak "can't open $normal: $OS_ERROR" if($normal);
+
+my $dbh = DBI->connect("dbi:mysql:$db:$host:$port", $USER) or
+	die "Can't connect to MySQL database: $DBI::errstr\n";
+
+my @SV;
+my @normal_SV;
+if($normal) {
+	while(my $line = <$NORMAL>) {
+		chomp $line;
+		my ($chrA, $posA, $ortA, $countA, $chrB, $posB, $ortB, $countB, $type) = split /\t/, $line;
+		next if( search_sv(\@normal_SV, $chrA, $posA, $chrB, $posB, $type));
+		push @normal_SV, [$chrA, $posA, $chrB, $posB, $type];
+	}
+}
+while( my $line = <$IN> ) {
+	chomp $line;
+	my ($chrA, $posA, $ortA, $countA, $chrB, $posB, $ortB, $countB, $type) = split /\t/, $line;
+	next if( search_sv(\@normal_SV, $chrA, $posA, $chrB, $posB, $type)); # the SV exists in normal sample
+	push @normal_SV, [$chrA, $posA, $chrB, $posB, $type];
+	print STDOUT $line;
+	if($type eq 'DEL') {
+		my $tmp = get_gene_info($chrA, $posA, $posB);
+		print STDOUT "\t", $tmp if($tmp);
+	}
+	else {
+		print STDOUT "\t", get_gene_info($chrA, $posA, $posA);
+		print STDOUT "\t", get_gene_info($chrB, $posB, $posB);
+	}
+	print STDOUT "\n";
+}
+close $IN;
+close STDOUT if($out);
+$dbh->disconnect;
+exit(0);
+
+sub search_sv {
+	my ($r_SV, $chrA, $posA, $chrB, $posB, $type) = @_;
+
+	foreach my $sv (@{$r_SV}) {
+		return 1 if( $sv->[0] eq $chrA && abs($sv->[1] - $posA) < 20 &&
+			$sv->[2] eq $chrB && abs($sv->[3] - $posB) < 20 && $sv->[4] eq $type);
+		return 1 if( $sv->[0] eq $chrB && abs($sv->[1] - $posB) < 20 &&
+			$sv->[2] eq $chrA && abs($sv->[3] - $posA) < 20 && $sv->[4] eq $type);
+		return 1 if( $sv->[0] eq $chrA && abs($sv->[1] - $posA) < 100 &&
+			$sv->[2] eq $chrB && abs($sv->[3] - $posB) < 100 && $sv->[4] eq $type && $type eq 'CTX');
+		return 1 if( $sv->[0] eq $chrB && abs($sv->[1]- $posB) < 100 &&
+			$sv->[2] eq $chrA && abs($sv->[3] - $posA)  < 100  && $sv->[4] eq $type && $type eq 'CTX');
+	}
+	return;
+}
+
+sub get_gene_info {
+   my ($chr, $st, $ed) = @_;
+   $chr = 'chr' . $chr if($chr !~ m/chr/);
+	my $rtn="";
+   my $sth = $dbh->prepare("select distinct geneName 
+                           from refFlat
+                           where (chrom = '$chr' AND $ed >= txStart AND $st <= txEnd)
+                           order by txStart"
+                          );
+   $sth->execute();
+   my $tbl_ref = $sth->fetchall_arrayref();
+   foreach my $r (@{$tbl_ref}) {
+   		if($rtn eq '') { 
+			$rtn = $r->[0];
+		} 
+		else {
+			$rtn = $rtn . ", " .  $r->[0];
+		}
+	}
+	return $rtn;
+}
+=head1 NAME
+
+<application name> - <One-line description of application's purpose>
+
+
+=head1 VERSION
+
+The initial template usually just has:
+
+This documentation refers to <application name> version 0.0.1.
+
+
+=head1 USAGE
+
+    # Brief working invocation example(s) here showing the most common usage(s)
+
+	# This section will be as far as many users ever read,
+	# so make it as educational and exemplary as possible.
+=head1 REQUIRED ARGUMENTS
+
+A complete list of every argument that must appear on the command line.
+when the application  is invoked, explaining what each of them does, any
+restrictions on where each one may appear (i.e., flags that must appear
+before or after filenames), and how the various arguments and options
+may interact (e.g., mutual exclusions, required combinations, etc.)
+
+If all of the application's arguments are optional, this section
+may be omitted entirely.
+
+=head1 OPTIONS
+
+A complete list of every available option with which the application
+can be invoked, explaining what each does, and listing any restrictions,
+or interactions.
+
+If the application has no options, this section may be omitted entirely.
+
+
+=head1 DESCRIPTION
+
+A full description of the application and its features.
+May include numerous subsections (i.e., =head2, =head3, etc.).
+
+
+=head1 DIAGNOSTICS
+
+A list of every error and warning message that the application can generate
+(even the ones that will "never happen"), with a full explanation of each
+problem, one or more likely causes, and any suggested remedies. If the
+application generates exit status codes (e.g., under Unix), then list the exit
+status associated with each error.
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+A full explanation of any configuration system(s) used by the application,
+including the names and locations of any configuration files, and the
+meaning of any environment variables or properties that can be set. These
+descriptions must also include details of any configuration language used.
+
+
+=head1 DEPENDENCIES
+
+A list of all the other modules that this module relies upon, including any
+restrictions on versions, and an indication of whether these required modules are
+part of the standard Perl distribution, part of the module's distribution,
+or must be installed separately.
+
+
+=head1 INCOMPATIBILITIES
+
+A list of any modules that this module cannot be used in conjunction with.
+This may be due to name conflicts in the interface, or competition for
+system or program resources, or due to internal limitations of Perl
+(for example, many modules that use source code filters are mutually
+incompatible).
+
+
+=head1 BUGS AND LIMITATIONS
+
+A list of known problems with the module, together with some indication of
+whether they are likely to be fixed in an upcoming release.
+
+Also a list of restrictions on the features the module does provide:
+data types that cannot be handled, performance issues and the circumstances
+in which they may arise, practical limitations on the size of data sets,
+special cases that are not (yet) handled, etc.
+
+The initial template usually just has:
+
+There are no known bugs in this module.
+Please report problems to <Maintainer name(s)>  (<contact address>)
+Patches are welcome.
+
+=head1 AUTHOR
+
+<Author name(s)> (<contact address>)
+
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) <year> <copyright holder> (<contact address>). All rights reserved.
+
+followed by whatever licence you wish to release it under.
+For Perl code that is often just:
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
Binary file ptrfinder has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/removeDupSV.pl	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,188 @@
+#!/nfs_exports/apps/64-bit/gnu-apps/perl5.8.9/bin/perl -w
+
+use strict;
+use Carp;
+use Getopt::Long;
+use English;
+use Pod::Usage;
+use Data::Dumper;
+use DBI;
+use DBD::mysql;
+
+my ( $help, $man, $version, $usage );
+my ($in, $out);
+my $min_inv = 10000;
+my $min_total_sclip = 6;
+my $add_inv_back;
+my $width = 20;
+my $optionOK = GetOptions(
+	'i|in|input=s'	=> \$in,
+	'o|out|output=s'	=> \$out,
+	'min_inv_size=i'	=> \$min_inv,
+	'min_total_sclip=i'	=> \$min_total_sclip,
+	'add_inv_back!'	=> \$add_inv_back,
+	'width=i'		=> \$width,
+	'h|help|?'		=> \$help,
+	'man'			=> \$man,
+	'usage'			=> \$usage,
+	'v|version'		=> \$version,
+);
+
+pod2usage(2) if($man);
+pod2usage( -verbose => 99, -sections => "USAGE|REQUIRED ARGUMENTS|OPTIONS" ) 
+	if($help or $usage);
+pod2usage( -verbose => 99, -sections => "VERSION") if($version);
+
+croak "Missing input file" if(!$in);
+open STDOUT, ">$out" if($out);
+open my $IN, "<$in" or croak "can't open $in: $OS_ERROR";
+
+my @SV;
+my @discard_SV;
+while(my $line = <$IN>) {
+	chomp $line;
+	my ($chrA, $posA, $ortA, $countA, $chrB, $posB, $ortB, $countB, $type) = split /\t/, $line;
+	next if( search_sv(\@SV, $chrA, $posA, $chrB, $posB, $type));
+	if(($type eq 'ITX' || $type eq 'INV') && (abs($posB - $posA) < $min_inv && ($countA + $countB) < $min_total_sclip)) {
+		print STDERR "$line is removed due to possible circulization\n";
+		push @discard_SV, $line;
+		next;
+	}
+	push @SV, [$chrA, $posA, $chrB, $posB, $type, $line];
+}
+
+close $IN;
+
+foreach my $sv (@SV) {
+	print STDOUT $sv->[5];
+#	if($sv->[4] eq 'DEL') {
+#		my $tmp = get_gene_info($sv->[0], $sv->[1], $sv->[3]);
+#		print STDOUT "\t", $tmp if($tmp);
+#	}
+#	else {
+#		print STDOUT "\t", get_gene_info($sv->[0], $sv->[1], $sv->[1]);
+#		print STDOUT "\t", get_gene_info($sv->[2], $sv->[3], $sv->[3]);
+#	}
+	print STDOUT "\n";
+}
+
+if($add_inv_back) {
+	foreach my $sv (@discard_SV) {
+		my ($chrA, $posA, $ortA, $countA, $chrB, $posB, $ortB, $countB, $type) = split /\t/, $sv;
+		next if(search_nearby_sv(\@SV, $chrA, $posA, $posB));
+		print STDOUT $sv;
+		print "\n";
+	}
+}
+close STDOUT if($out);
+exit(0);
+
+sub search_nearby_sv {
+	my($r_SV, $chrA, $posA, $posB) = @_;
+	foreach my $sv (@{$r_SV}) {
+		return 1 if($sv->[0] eq $chrA && abs($sv->[1] - $posA) < 10000);
+		return 1 if($sv->[2] eq $chrA && abs($sv->[3] - $posA) < 10000);
+		return 1 if($sv->[0] eq $chrA && abs($sv->[1] - $posB) < 10000);
+		return 1 if($sv->[2] eq $chrA && abs($sv->[3] - $posB) < 10000);
+	}
+	return;
+}
+
+sub search_sv {
+	my ($r_SV, $chrA, $posA, $chrB, $posB, $type) = @_;
+	
+	for(my $i = 0; $i < scalar @{$r_SV}; $i++) {
+		my $sv = $r_SV->[$i];
+		if($type eq "INV" && $r_SV->[$i][4] eq "ITX" ) {
+			if(( $sv->[0] eq $chrA && abs($sv->[1] - $posA) < 20 &&
+	            $sv->[2] eq $chrB && abs($sv->[3] - $posB) < 20 )||
+				( $sv->[0] eq $chrB && abs($sv->[1] - $posB) < 20 &&
+	            $sv->[2] eq $chrA && abs($sv->[3] - $posA) < 20)) {
+				delete $r_SV->[$i];
+				return;
+			}
+		}
+		else {	
+			return 1 if( $sv->[0] eq $chrA && abs($sv->[1] - $posA) < $width &&
+				$sv->[2] eq $chrB && abs($sv->[3] - $posB) < $width && $sv->[4] eq $type);
+			return 1 if( $sv->[0] eq $chrB && abs($sv->[1] - $posB) < $width &&
+				$sv->[2] eq $chrA && abs($sv->[3] - $posA) < $width && $sv->[4] eq $type);
+			return 1 if( $sv->[0] eq $chrA && abs($sv->[1] - $posA) < $width &&
+				$sv->[2] eq $chrB && abs($sv->[3] - $posB) < $width && $sv->[4] eq $type && $type eq 'CTX');
+			return 1 if( $sv->[0] eq $chrB && abs($sv->[1]- $posB) < $width &&
+				$sv->[2] eq $chrA && abs($sv->[3] - $posA)  < $width  && $sv->[4] eq $type && $type eq 'CTX');
+		}
+	}
+	return;
+}
+
+=head1 NAME
+
+removeDupSV.pl - a program to remove duplicated SVs for CREST.pl
+
+
+=head1 VERSION
+
+This documentation refers to removeDupSV.pl version 0.0.1.
+
+
+=head1 USAGE
+	The program need an input file generated by CREST.pl	
+		removeDupSV.pl -i tumor.predSV.txt -o tumor.predSV.txt.nodup
+
+=head1 REQUIRED ARGUMENTS
+
+	To run the program, several parameter must specified.
+	-i	The input file generated by CREST.pl
+	-o	The output file
+
+=head1 OPTIONS
+
+	The options that can be used for the program.
+	--min_inv_size		For ITX/INV, the minimum event size, default 10000
+	--min_total_sclip	For ITX/INV with size smaller than min_inv_size, the min
+						number of soft-clipped reads needed to keep it, default 6
+	--(no)add_inv_back	Add ITX/INV back if there is another event nearby, 
+						default OFF.
+	--width				The max breakpoint distance such that it's considered as 
+						same breakpoint, default 20
+	-h, --help, -?		 Help information
+	--man				 Man page.
+	--usage				 Usage information.
+	--version			 Software version.
+
+
+=head1 DESCRIPTION
+
+This is a simple program to remove duplicated SVs, also it remove small INV/ITX 
+events since most of those are due to library preparation.
+
+
+=head1 BUGS AND LIMITATIONS
+
+There are no known bugs in this module, but the method is limitted to bam file 
+that has soft-clipping cigar string generated.Please report problems to 
+Jianmin Wang  (Jianmin.Wang@stjude.org)
+Patches are welcome.
+
+=head1 AUTHOR
+
+Jianmin Wang (Jianmin.Wang@stjude.org)
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2010 by St. Jude Children's Research Hospital.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version. 
+
+This program is distributed in the hope that it will be useful, 
+but WITHOUT ANY WARRANTY; without even the implied warranty of 
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
Binary file tumor.bam has changed
Binary file tumor.bam.bai has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tumor.bam.cover	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,11 @@
+4	125892327	+	1	30
+4	125892458	+	1	27
+4	125893225	+	1	28
+4	125893227	+	5	29
+4	125893365	-	1	26
+4	125893979	-	1	16
+10	66301086	-	2	33
+10	66301858	+	4	15
+10	66301865	-	9	22
+10	66301871	-	1	24
+10	66302136	+	1	51
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tumor.bam.sclip.txt	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,27 @@
+4	125892327	+	HWUSI-EAS1591_6113C:3:17:12332:19420#0	CC	CC
+4	125892458	+	HWUSI-EAS1591_6113C:4:91:6281:9961#0	GACTAACCACCACGGTACATGTTTTCCTATGTAAAAAACCTGCACATTCTACACATGTATCCCAGAACTTAAAGTAAAACAC	B@C@?:CC>CCBCCCCACBCDCCCCCC;<:<9CCCCC@CCCCCBCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCAC
+4	125893225	+	HWI-EAS90_614M9:5:18:17924:10181#0	CCCTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAA	#######@@7@:8@><16+6(B>AABCAA3AB@CC6CCCCCCCDCCCCCCBCCDCCCCCCCCCCCCDCCCCCCCCCCCCCC
+4	125893227	+	HWI-EAS90_614M9:4:32:9763:4986#0	CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCT	CCCC@CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+4	125893227	+	HWI-EAS90_614M9:5:1:12903:5535#0	CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAATTTT	B;@@>DABBB>DBAAAB@BABDDDDCCBCDACCBCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCC
+4	125893227	+	HWUSI-EAS1591_6113C:2:117:3095:2051#0	CTCCTGGGTTCAAGTGATTCTCCTGCCTCTACCTCCCGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCTGGCTAAT	65977A::??BB>?BA8???=BDCCCCBCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDCCCCCCCCCCCCCCC
+4	125893227	+	HWUSI-EAS1591_6113C:4:39:14328:11130#0	CTCCTGGGTTCAAGTGATTCTCCTG	CCCCCCCCCCCCCCCCCCCCCCCCC
+4	125893227	+	HWUSI-EAS1591_6113C:4:9:4513:12290#0	CTCCTGG	CCCCCCC
+4	125893365	-	HWI-EAS292_102081428:1:66:17910:13190#0	TAACTACTT	GFGFDGGGG
+4	125893979	-	HWUSI-EAS1591_6113C:1:81:16173:11673#0	ATAAAATATTTATATTTTATATATTTGTATTCAAT	CCCCCCCCCCCCCCCCCCCCCCCCCCCDCCCCCCC
+10	66301086	-	HWI-EAS231_614TA:6:108:5679:13132#0	AAACATGGTTCAAATAAATTATTTATAAAGAAG	CCCCCCCCCCCCCCCCCBBCCCCCCCCCCCCCC
+10	66301086	-	HWI-EAS292_102081428:1:76:17776:13382#0	AAACATGGTTCAAATAAATTATTTATAAAGAAG	GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
+10	66301858	+	HWI-EAS231_614TA:1:37:3390:19595#0	ACAGCTACT	CCCCCCCCC
+10	66301858	+	HWI-EAS90_614M9:1:98:9476:6999#0	ACAGCTACTGAAAAGAGAATCATATTCTCTTTT	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301858	+	HWI-EAS90_614M9:5:12:2797:13435#0	ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAATATGATA	CCCCCCDCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301858	+	HWI-EAS90_614M9:7:110:15112:12998#0	ACAGCTACTGAAAAGAGAATCATATTCTCTTTTCATAATTTAGAATATGATATATATTTCAAAAT	CCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301865	-	HWI-EAS231_614TA:4:36:3528:11249#0	TTTGTTCCTTCA	CCCCCCCCCCCC
+10	66301865	-	HWI-EAS231_614TA:5:52:9612:8954#0	CGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCC
+10	66301865	-	HWI-EAS90_614M9:1:118:15320:11068#0	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCDCCCCCCCCCCCCCCCC@CCBCCCDDCCDBCDBCCDBCBCDDD
+10	66301865	-	HWI-EAS90_614M9:3:104:3717:11676#0	GAGTCCGTAGTTTGTTCCTTCA	BBBBBB@9B@878;69?B9AB>
+10	66301865	-	HWI-EAS90_614M9:4:115:17151:16115#0	AGTCCGGAGTTCTCAACGATGGTGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+10	66301865	-	HWI-EAS90_614M9:5:27:7334:16234#0	CTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGTGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCDCCCCCCCCCCCCCBCCBCCCDCCCCCCBCCCCCCCCC@CC>CAC@CCBABCADDDBDBBBBBB
+10	66301865	-	HWI-EAS90_614M9:7:21:19162:4940#0	TTCA	CCCC
+10	66301865	-	HWUSI-EAS1591_6113C:1:24:6705:7145#0	AGCCATGGACCTTGTGGTGGGTTCTTAACAATGGTGAGTCCGGAGTTCTTAACGATGGCGAGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCCDCCCCCCCCCCCCCCCCDCCCDCCCCCCACCCCCCDCCDC98A@C<C?CB9@BA@@BBCBBD@B
+10	66301865	-	HWUSI-EAS1591_6113C:2:55:7685:7454#0	AGTCCGTAGTTTGTTCCTTCA	CCCCCCCCCCCCCCCCCCCCC
+10	66301871	-	HWI-EAS90_614M9:3:114:11684:16725#0	ATCAAGAAAATTAATAAACCCTAGCCCATAT	BBBBBBBBB==BBBBBBBBBBBBBBBBBBBB
+10	66302136	+	HWI-EAS231_614TA:4:119:4524:15992#0	TAAATTCCGGACACAGTACTACTATGTTGAAGAGGAGTTG	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC