@@ -41,7 +41,6 @@ namespace Drawing {
41
41
struct TextItemIns {
42
42
sk_sp<SkTextBlob> text;
43
43
float x, y;
44
- // float box_x, box_y;
45
44
float box_y, box_w;
46
45
};
47
46
@@ -63,6 +62,9 @@ namespace Drawing {
63
62
float yOffsetAll = refSpace;
64
63
65
64
for (auto &cl: collections) {
65
+ if (cl.skipDrawingCoverage ) {
66
+ continue ;
67
+ }
66
68
cl.skipDrawingCoverage = true ;
67
69
68
70
if (cl.bamIdx != last_bamIdx) {
@@ -78,17 +80,11 @@ namespace Drawing {
78
80
Segs::findMismatches (opts, cl);
79
81
}
80
82
81
- // double tot, mean, n;
82
83
const std::vector<int > &covArr_r = cl.covArr ;
83
84
std::vector<float > c;
84
85
c.resize (cl.covArr .size ());
85
86
c[0 ] = (float ) cl.covArr [0 ];
86
87
int cMaxi = (c[0 ] > 10 ) ? (int ) c[0 ] : 10 ;
87
- // tot = (float) c[0];
88
- // n = 0;
89
- // if (tot > 0) {
90
- // n += 1;
91
- // }
92
88
float cMax;
93
89
bool processThis = draw_mismatch_info && !cl.collection_processed ;
94
90
for (size_t i = 1 ; i < c.size (); ++i) { // cum sum
@@ -97,8 +93,6 @@ namespace Drawing {
97
93
cMaxi = (int ) c[i];
98
94
}
99
95
if (c[i] > 0 ) {
100
- // tot += c[i];
101
- // n += 1;
102
96
// normalise mismatched bases to nearest whole percentage (avoids extra memory allocation)
103
97
if (processThis) { //
104
98
if (mmVector[i].A || mmVector[i].T || mmVector[i].C || mmVector[i].G ) {
@@ -116,12 +110,6 @@ namespace Drawing {
116
110
}
117
111
cl.collection_processed = true ;
118
112
cl.maxCoverage = cMaxi;
119
- // if (n > 0) {
120
- // mean = tot / n;
121
- // mean = ((float) ((int) (mean * 10))) / 10;
122
- // } else {
123
- // mean = 0;
124
- // }
125
113
126
114
if (opts.log2_cov ) {
127
115
for (size_t i = 0 ; i < c.size (); ++i) {
@@ -311,14 +299,6 @@ namespace Drawing {
311
299
path.lineTo (xOffset + 6 * monitorScale, covY + yOffsetAll);
312
300
canvas->drawPath (path, theme.lcJoins );
313
301
314
- // char *ap = indelChars;
315
- // ap += std::sprintf(indelChars, "%s", "avg. ");
316
- // std::sprintf(ap, "%.1f", mean);
317
-
318
- // if (covY > fonts.overlayHeight * 3) { // dont overlap text
319
- // blob = SkTextBlob::MakeFromString(indelChars, fonts.overlay);
320
- // canvas->drawTextBlob(blob, xOffset + 8 * monitorScale, covY_f + yOffsetAll + (fonts.overlayHeight * 2), theme.tcDel);
321
- // }
322
302
last_bamIdx = cl.bamIdx ;
323
303
324
304
// Draw data labels when alignments are not shown
@@ -795,55 +775,58 @@ namespace Drawing {
795
775
}
796
776
}
797
777
798
- void drawDeletionLine (const Segs::Align &a, SkCanvas *canvas, SkPath &path, const Themes::IniOptions &opts,
799
- const Themes::Fonts &fonts,
800
- int regionBegin, int Y, int regionLen, int starti, int lastEndi,
801
- float regionPixels, float xScaling, float yScaling, float xOffset, float yOffset,
802
- float textDrop, std::vector<TextItem> &text, bool indelTextFits) {
803
-
778
+ void drawDeletionLine (SkCanvas *canvas, SkPath &path, const Themes::IniOptions &opts,
779
+ const Themes::Fonts &fonts,
780
+ int regionBegin, int Y, int regionLen, int starti, int lastEndi,
781
+ float regionPixels, float xScaling, float yScaling, float xOffset, float yOffset,
782
+ std::vector<TextItem> &text, bool indelTextFits) {
804
783
int isize = starti - lastEndi;
805
784
int lastEnd = lastEndi - regionBegin;
806
- starti -= regionBegin;
807
-
808
- int size = starti - lastEnd;
785
+ int startRelative = starti - regionBegin;
786
+ int size = startRelative - lastEnd;
809
787
if (size <= 0 ) {
810
788
return ;
811
789
}
812
- float delBegin = ( float ) lastEnd * xScaling;
813
- float delEnd = delBegin + (( float ) size * xScaling);
814
- float yh = (( float ) Y + ( float ) polygonHeight * ( float ) 0.5 ) * yScaling + yOffset;
790
+ float delBegin = lastEnd * xScaling;
791
+ float delEnd = delBegin + (size * xScaling);
792
+ float yh = (Y + polygonHeight * 0.5 ) * yScaling + yOffset;
815
793
816
794
if (isize >= opts.indel_length ) {
817
- if (regionLen < 500000 && indelTextFits) { // line and text
795
+ if (regionLen < 500000 && indelTextFits) {
818
796
std::sprintf (indelChars, " %d" , isize);
819
- size_t sl = strlen (indelChars);
820
- float textW = fonts.textWidths [sl - 1 ];
821
- float textBegin = (((float ) lastEnd + (float ) size / 2 ) * xScaling) - (textW / 2 );
822
- float textEnd = textBegin + textW;
797
+ size_t textLength = strlen (indelChars);
798
+ float textWidth = fonts.textWidths [textLength - 1 ];
799
+ float textCenter = ((lastEnd + size / 2 .0f ) * xScaling);
800
+ float textBegin = textCenter - (textWidth / 2 .0f );
801
+ float textEnd = textBegin + textWidth;
802
+
803
+ // Adjust if text would be off-screen
823
804
if (textBegin < 0 ) {
824
805
textBegin = 0 ;
825
- textEnd = textW ;
806
+ textEnd = textWidth ;
826
807
} else if (textEnd > regionPixels) {
827
- textBegin = regionPixels - textW ;
808
+ textBegin = regionPixels - textWidth ;
828
809
textEnd = regionPixels;
829
810
}
830
- text.emplace_back () = {SkTextBlob::MakeFromString (indelChars, fonts.overlay ),
831
- textBegin + xOffset,
832
- ((float ) Y + polygonHeight) * yScaling - textDrop + yOffset};
833
-
811
+ float textYPosition = yh + (fonts.overlayHeight / 2 );
812
+ text.emplace_back () = {
813
+ SkTextBlob::MakeFromString (indelChars, fonts.overlay ),
814
+ textBegin + xOffset,
815
+ textYPosition
816
+ };
834
817
if (textBegin > delBegin) {
835
818
drawHLine (canvas, path, opts.theme .lcJoins , delBegin + xOffset, yh, textBegin + xOffset);
836
819
drawHLine (canvas, path, opts.theme .lcJoins , textEnd + xOffset, yh, delEnd + xOffset);
837
820
}
838
- } else { // dot only
821
+ } else { // Draw dot or line without text
839
822
delEnd = std::min (regionPixels, delEnd);
840
823
if (delEnd - delBegin < 2 ) {
841
824
canvas->drawPoint (delBegin + xOffset, yh, opts.theme .lcBright );
842
825
} else {
843
826
drawHLine (canvas, path, opts.theme .lcJoins , delBegin + xOffset, yh, delEnd + xOffset);
844
827
}
845
828
}
846
- } else if ((float ) size / (float ) regionLen > 0.0005 ) { // (regionLen < 50000 || size > 100) { // line only
829
+ } else if ((float )size / (float )regionLen > 0.0005 ) { // Draw small deletions but only if they're visible enough
847
830
delEnd = std::min (regionPixels, delEnd);
848
831
drawHLine (canvas, path, opts.theme .lcJoins , delBegin + xOffset, yh, delEnd + xOffset);
849
832
}
@@ -1059,10 +1042,8 @@ namespace Drawing {
1059
1042
continue ; // insertion
1060
1043
}
1061
1044
if (lastEnd <= regionEnd && regionBegin <= starti) {
1062
- drawDeletionLine (a, canvas, path, opts, fonts,
1063
- regionBegin, Y, regionLen, starti, lastEnd,
1064
- regionPixels, xScaling, yScaling, xOffset, yOffset,
1065
- textDrop, text_del, indelTextFits);
1045
+ drawDeletionLine (canvas, path, opts, fonts, regionBegin, Y, regionLen, starti, lastEnd,
1046
+ regionPixels, xScaling, yScaling, xOffset, yOffset, text_del, indelTextFits);
1066
1047
}
1067
1048
}
1068
1049
@@ -1162,13 +1143,11 @@ namespace Drawing {
1162
1143
std::sprintf (indelChars, " %d" , ins.length );
1163
1144
size_t sl = strlen (indelChars);
1164
1145
textW = fonts.textWidths [sl - 1 ];
1165
- if (ins.length > (uint32_t ) opts.indel_length ) {
1146
+ if (ins.length >= (uint32_t ) opts.indel_length ) {
1166
1147
if (regionLen < 500000 && indelTextFits) { // line and text
1167
- // float yScaledOffset = (Y * yScaling) + yOffset;
1168
1148
text_ins.emplace_back () = {SkTextBlob::MakeFromString (indelChars, fonts.overlay ),
1169
1149
(float )(p - (textW * 0.5 ) + xOffset - monitorScale),
1170
1150
yScaledOffset + polygonHeight - textDrop,
1171
- // ((Y + polygonHeight) * yScaling) + yOffset - textDrop,
1172
1151
yScaledOffset,
1173
1152
std::fmax ((float )textW + monitorScale + monitorScale, ins_block_w)};
1174
1153
@@ -1345,7 +1324,7 @@ namespace Drawing {
1345
1324
double mmPosOffset = monitorScale; // draw position of boxes
1346
1325
if (scale_bar) {
1347
1326
mmPosOffset = gap + h + gap + monitorScale + (gap*0.25 );
1348
- yp = gap + h + gap + h + monitorScale ;
1327
+ yp = gap + h + gap + monitorScale + h + (gap* 0.25 ) ;
1349
1328
} else {
1350
1329
mmPosOffset = monitorScale + monitorScale;
1351
1330
yp = h + monitorScale + monitorScale;
@@ -2236,7 +2215,7 @@ namespace Drawing {
2236
2215
canvas->save ();
2237
2216
clip.setXYWH (plot_gap + (regionIdx * colWidth), 1 , scaleWidth, fonts.overlayHeight * 2 + plot_gap);
2238
2217
canvas->clipRect (clip, SkClipOp::kIntersect );
2239
- canvas->drawRect (clip, opts.theme .bgPaint );
2218
+ // canvas->drawRect(clip, opts.theme.bgPaint);
2240
2219
2241
2220
int position = (region.start / (int )nice_tick) * (int )nice_tick;
2242
2221
int num_divisions = nice_range / nice_tick;
0 commit comments