Fix dotplot --strands bug with cut sequences
authorMartin C. Frith
Mon Mar 05 17:43:20 2018 +0900 (2018-03-05)
changeset 926bc08832db1a1
parent 925 e1861f956f60
child 927 fb851b8892a5
Fix dotplot --strands bug with cut sequences
scripts/last-dotplot
test/last-dotplot-test.out
test/last-dotplot-test.sh
     1.1 --- a/scripts/last-dotplot	Mon Mar 05 12:06:48 2018 +0900
     1.2 +++ b/scripts/last-dotplot	Mon Mar 05 17:43:20 2018 +0900
     1.3 @@ -479,7 +479,7 @@
     1.4      if isReverseStrand:
     1.5          beg = -(beg + size)
     1.6      for rangeBeg, rangeEnd, isReverseRange, origin in ranges:
     1.7 -        if rangeEnd > beg:
     1.8 +        if rangeEnd > beg:  # assumes the ranges are sorted
     1.9              return (isReverseStrand != isReverseRange), origin
    1.10  
    1.11  def alignmentPixels(width, height, alignments, bp_per_pix,
    1.12 @@ -698,7 +698,7 @@
    1.13  def rangesPerSeq(sortedRanges, rangePixBegs, rangePixLens, bpPerPix):
    1.14      a = rangesWithOrigins(sortedRanges, rangePixBegs, rangePixLens, bpPerPix)
    1.15      for k, v in itertools.groupby(a, itemgetter(0)):
    1.16 -        yield k, [i[1] for i in v]
    1.17 +        yield k, sorted(i[1] for i in v)
    1.18  
    1.19  def getFont(opts):
    1.20      if opts.fontfile:
     2.1 --- a/test/last-dotplot-test.out	Mon Mar 05 12:06:48 2018 +0900
     2.2 +++ b/test/last-dotplot-test.out	Mon Mar 05 17:43:20 2018 +0900
     2.3 @@ -2,7 +2,6 @@
     2.4  3396982345 3177
     2.5  
     2.6  TEST -v -x600 -c orange -r teal --sort1=2 --border-color=brown 102.maf
     2.7 -last-dotplot: font: /usr/share/fonts/liberation/LiberationSans-Regular.ttf
     2.8  last-dotplot: reading alignments...
     2.9  last-dotplot: cutting...
    2.10  last-dotplot: reading secondary alignments...
    2.11 @@ -93,7 +92,6 @@
    2.12  2981739013 1818
    2.13  
    2.14  TEST -v -y30 --max-gap1=0 --pad=0.08 --border-pixels=2 --sort1=3 102.maf
    2.15 -last-dotplot: font: /usr/share/fonts/liberation/LiberationSans-Regular.ttf
    2.16  last-dotplot: reading alignments...
    2.17  last-dotplot: cutting...
    2.18  last-dotplot: reading secondary alignments...
    2.19 @@ -185,8 +183,97 @@
    2.20  last-dotplot: drawing...
    2.21  3953352818 1272
    2.22  
    2.23 +TEST -v --strands1=1 102.maf
    2.24 +last-dotplot: reading alignments...
    2.25 +last-dotplot: cutting...
    2.26 +last-dotplot: reading secondary alignments...
    2.27 +last-dotplot: cutting...
    2.28 +last-dotplot: sorting...
    2.29 +last-dotplot: chr1	21590603	21590709	+
    2.30 +last-dotplot: chr1	145869990	145870063	+
    2.31 +last-dotplot: chr1	155997846	155997940	+
    2.32 +last-dotplot: chr1	161050878	161050970	+
    2.33 +last-dotplot: chr2	240456604	240456683	-
    2.34 +last-dotplot: chr2	192414435	192414516	-
    2.35 +last-dotplot: chr3	186865624	186865699	-
    2.36 +last-dotplot: chr3	152862866	152862947	-
    2.37 +last-dotplot: chr3	130609381	130609461	-
    2.38 +last-dotplot: chr3	127741348	127741429	-
    2.39 +last-dotplot: chr3	89815452	89815525	-
    2.40 +last-dotplot: chr3	37588349	37588441	-
    2.41 +last-dotplot: chr3	33026597	33026675	-
    2.42 +last-dotplot: chr3	23607529	23607606	-
    2.43 +last-dotplot: chr4	54783677	54783767	-
    2.44 +last-dotplot: chr4	3839035	3839110	-
    2.45 +last-dotplot: chr5	4867398	4867471	+
    2.46 +last-dotplot: chr5	74376550	74376623	+
    2.47 +last-dotplot: chr5	93489515	93489591	+
    2.48 +last-dotplot: chr5	169763588	169763671	+
    2.49 +last-dotplot: chr5	171574427	171574500	+
    2.50 +last-dotplot: chr5	173701172	173701249	+
    2.51 +last-dotplot: chr5	177958514	177958591	+
    2.52 +last-dotplot: chr6	170257674	170257754	-
    2.53 +last-dotplot: chr6	65786074	65786151	-
    2.54 +last-dotplot: chr6	1842804	1842877	-
    2.55 +last-dotplot: chr7	157969496	157969572	-
    2.56 +last-dotplot: chr7	101723218	101723313	-
    2.57 +last-dotplot: chr7	101590352	101590447	-
    2.58 +last-dotplot: chr7	100370569	100370642	-
    2.59 +last-dotplot: chr7	65260279	65260354	-
    2.60 +last-dotplot: chr8	76840831	76840936	+
    2.61 +last-dotplot: chr8	98433234	98433318	+
    2.62 +last-dotplot: chr10	122813007	122813087	+
    2.63 +last-dotplot: chr10	124281367	124281441	+
    2.64 +last-dotplot: chr10	126932842	126932937	+
    2.65 +last-dotplot: chr11	67464119	67464196	+
    2.66 +last-dotplot: chr12	71544959	71545052	-
    2.67 +last-dotplot: chr12	19357508	19357581	-
    2.68 +last-dotplot: chr13	113342188	113342261	+
    2.69 +last-dotplot: chr14	80332102	80332183	+
    2.70 +last-dotplot: chr14	104715645	104715730	+
    2.71 +last-dotplot: chr15	45614722	45614800	+
    2.72 +last-dotplot: chr15	78230458	78230537	+
    2.73 +last-dotplot: chr16	722456	722540	-
    2.74 +last-dotplot: chr17	19079582	19079655	+
    2.75 +last-dotplot: chr17	19172423	19172496	+
    2.76 +last-dotplot: chr17	19205764	19205837	+
    2.77 +last-dotplot: chr17	27793612	27793685	+
    2.78 +last-dotplot: chr17	28925902	28925982	+
    2.79 +last-dotplot: chr17	29190042	29190115	+
    2.80 +last-dotplot: chr17	58670463	58670536	+
    2.81 +last-dotplot: chr18	8561181	8561272	+
    2.82 +last-dotplot: chr18	55335065	55335140	+
    2.83 +last-dotplot: chr19	47072174	47072264	-
    2.84 +last-dotplot: chr19	18430532	18430615	-
    2.85 +last-dotplot: chr19	17615403	17615478	-
    2.86 +last-dotplot: chr19	1395360	1395511	-
    2.87 +last-dotplot: chr19	1393213	1393358	-
    2.88 +last-dotplot: chr19	1390828	1391190	-
    2.89 +last-dotplot: chr19	1387780	1388965	-
    2.90 +last-dotplot: chr19	1383883	1383969	-
    2.91 +last-dotplot: chr20	4034120	4034195	+
    2.92 +last-dotplot: chr20	17684717	17684790	+
    2.93 +last-dotplot: chr21	14291153	14291236	+
    2.94 +last-dotplot: chr21	43027907	43027980	+
    2.95 +last-dotplot: chr22	46458773	46458849	-
    2.96 +last-dotplot: chr22	23657463	23657536	-
    2.97 +last-dotplot: chr22	20726561	20726644	-
    2.98 +last-dotplot: chrX	39928389	39928462	+
    2.99 +last-dotplot: chrX	83302574	83302647	+
   2.100 +last-dotplot: 
   2.101 +last-dotplot: 102	0	699
   2.102 +last-dotplot: 
   2.103 +last-dotplot: choosing bp per pixel...
   2.104 +last-dotplot: choosing bp per pixel...
   2.105 +last-dotplot: bp per pixel = 9
   2.106 +last-dotplot: width:  912
   2.107 +last-dotplot: height: 78
   2.108 +last-dotplot: processing alignments...
   2.109 +last-dotplot: reading annotations...
   2.110 +last-dotplot: drawing...
   2.111 +3966603009 3171
   2.112 +
   2.113  TEST -v --sort2=3 bs100.maf
   2.114 -last-dotplot: font: /usr/share/fonts/liberation/LiberationSans-Regular.ttf
   2.115  last-dotplot: reading alignments...
   2.116  last-dotplot: cutting...
   2.117  last-dotplot: reading secondary alignments...
   2.118 @@ -301,7 +388,6 @@
   2.119  833292477 18662
   2.120  
   2.121  TEST -v -2? --sort2=0 --strands2=1 bs100.maf
   2.122 -last-dotplot: font: /usr/share/fonts/liberation/LiberationSans-Regular.ttf
   2.123  last-dotplot: reading alignments...
   2.124  last-dotplot: cutting...
   2.125  last-dotplot: reading secondary alignments...
     3.1 --- a/test/last-dotplot-test.sh	Mon Mar 05 12:06:48 2018 +0900
     3.2 +++ b/test/last-dotplot-test.sh	Mon Mar 05 17:43:20 2018 +0900
     3.3 @@ -19,7 +19,9 @@
     3.4      plotSum 102.maf
     3.5      plotSum -v -x600 -c orange -r teal --sort1=2 --border-color=brown 102.maf
     3.6      plotSum -v -y30 --max-gap1=0 --pad=0.08 --border-pixels=2 --sort1=3 102.maf
     3.7 +    plotSum -v --strands1=1 102.maf
     3.8      plotSum -v --sort2=3 bs100.maf
     3.9      plotSum -v -2'?' --sort2=0 --strands2=1 bs100.maf
    3.10  } 2>&1 |
    3.11 +grep -v font |
    3.12  diff -u $(basename $0 .sh).out -