Mercurial > repos > cpt > cpt_easyfig
comparison Easyfig.py @ 1:afce956686a1 draft
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author | cpt |
---|---|
date | Mon, 05 Jun 2023 02:41:13 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:2139c39b727e | 1:afce956686a1 |
---|---|
1 #!/usr/bin/env python | |
2 # easyFig.py Written by: Mitchell Sullivan mjsull@gmail.com | |
3 # Supervisor: Dr. Scott Beatson and Dr. Nico Petty University of Queensland | |
4 # Version 2.2.3 08.11.2016 | |
5 # License: GPLv3 | |
6 | |
7 import os | |
8 import subprocess | |
9 from math import ceil, hypot | |
10 import threading | |
11 import time | |
12 import struct | |
13 import base64 | |
14 import string | |
15 from ftplib import FTP | |
16 import tarfile | |
17 import platform | |
18 import shutil | |
19 import webbrowser | |
20 import operator | |
21 import sys | |
22 | |
23 | |
24 def colorstr(rgb): | |
25 return "#%x%x%x" % (int(rgb[0] / 16), int(rgb[1] / 16), int(rgb[2] / 16)) | |
26 | |
27 | |
28 def binar(s): | |
29 transdict = { | |
30 "0": "0000", | |
31 "1": "0001", | |
32 "2": "0010", | |
33 "3": "0011", | |
34 "4": "0100", | |
35 "5": "0101", | |
36 "6": "0110", | |
37 "7": "0111", | |
38 "8": "1000", | |
39 "9": "1001", | |
40 "a": "1010", | |
41 "b": "1011", | |
42 "c": "1100", | |
43 "d": "1101", | |
44 "e": "1110", | |
45 "f": "1111", | |
46 } | |
47 outstring = "" | |
48 for i in s: | |
49 outstring += transdict[i] | |
50 return outstring | |
51 | |
52 | |
53 class scalableVectorGraphics: | |
54 def __init__(self, height, width): | |
55 self.height = height | |
56 self.width = width | |
57 self.out = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
58 <svg | |
59 xmlns:dc="http://purl.org/dc/elements/1.1/" | |
60 xmlns:cc="http://creativecommons.org/ns#" | |
61 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
62 xmlns:svg="http://www.w3.org/2000/svg" | |
63 xmlns="http://www.w3.org/2000/svg" | |
64 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |
65 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |
66 height="%d" | |
67 width="%d" | |
68 id="svg2" | |
69 version="1.1" | |
70 inkscape:version="0.48.4 r9939" | |
71 sodipodi:docname="easyfig"> | |
72 <metadata | |
73 id="metadata122"> | |
74 <rdf:RDF> | |
75 <cc:Work | |
76 rdf:about=""> | |
77 <dc:format>image/svg+xml</dc:format> | |
78 <dc:type | |
79 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |
80 <dc:title>Easyfig</dc:title> | |
81 </cc:Work> | |
82 </rdf:RDF> | |
83 </metadata> | |
84 <defs | |
85 id="defs120" /> | |
86 <sodipodi:namedview | |
87 pagecolor="#ffffff" | |
88 bordercolor="#666666" | |
89 borderopacity="1" | |
90 objecttolerance="10" | |
91 gridtolerance="10" | |
92 guidetolerance="10" | |
93 inkscape:pageopacity="0" | |
94 inkscape:pageshadow="2" | |
95 inkscape:window-width="640" | |
96 inkscape:window-height="480" | |
97 id="namedview118" | |
98 showgrid="false" | |
99 inkscape:zoom="0.0584" | |
100 inkscape:cx="2500" | |
101 inkscape:cy="75.5" | |
102 inkscape:window-x="55" | |
103 inkscape:window-y="34" | |
104 inkscape:window-maximized="0" | |
105 inkscape:current-layer="svg2" /> | |
106 <title | |
107 id="title4">Easyfig</title> | |
108 <g | |
109 style="fill-opacity:1.0; stroke:black; stroke-width:1;" | |
110 id="g6">""" % ( | |
111 self.height, | |
112 self.width, | |
113 ) | |
114 | |
115 def drawLine(self, x1, y1, x2, y2, th=1, cl=(0, 0, 0)): | |
116 self.out += ( | |
117 ' <line x1="%d" y1="%d" x2="%d" y2="%d"\n stroke-width="%d" stroke="%s" />\n' | |
118 % (x1, y1, x2, y2, th, colorstr(cl)) | |
119 ) | |
120 | |
121 def writesvg(self, filename): | |
122 outfile = open(filename, "w") | |
123 outfile.write(self.out + " </g>\n</svg>") | |
124 outfile.close() | |
125 | |
126 def drawRightArrow(self, x, y, wid, ht, fc, oc=(0, 0, 0), lt=1): | |
127 if lt > ht / 2: | |
128 lt = ht / 2 | |
129 x1 = x + wid | |
130 y1 = y + ht / 2 | |
131 x2 = x + wid - ht / 2 | |
132 ht -= 1 | |
133 if wid > ht / 2: | |
134 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
135 colorstr(fc), | |
136 colorstr(oc), | |
137 lt, | |
138 ) | |
139 self.out += ( | |
140 ' points="%d,%d %d,%d %d,%d %d,%d %d,%d %d,%d %d,%d" />\n' | |
141 % ( | |
142 x, | |
143 y + ht / 4, | |
144 x2, | |
145 y + ht / 4, | |
146 x2, | |
147 y, | |
148 x1, | |
149 y1, | |
150 x2, | |
151 y + ht, | |
152 x2, | |
153 y + 3 * ht / 4, | |
154 x, | |
155 y + 3 * ht / 4, | |
156 ) | |
157 ) | |
158 else: | |
159 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
160 colorstr(fc), | |
161 colorstr(oc), | |
162 lt, | |
163 ) | |
164 self.out += ' points="%d,%d %d,%d %d,%d" />\n' % ( | |
165 x, | |
166 y, | |
167 x, | |
168 y + ht, | |
169 x + wid, | |
170 y1, | |
171 ) | |
172 | |
173 def drawLeftArrow(self, x, y, wid, ht, fc, oc=(0, 0, 0), lt=1): | |
174 if lt > ht / 2: | |
175 lt = ht / 2 | |
176 x1 = x + wid | |
177 y1 = y + ht / 2 | |
178 x2 = x + ht / 2 | |
179 ht -= 1 | |
180 if wid > ht / 2: | |
181 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
182 colorstr(fc), | |
183 colorstr(oc), | |
184 lt, | |
185 ) | |
186 self.out += ( | |
187 ' points="%d,%d %d,%d %d,%d %d,%d %d,%d %d,%d %d,%d" />\n' | |
188 % ( | |
189 x1, | |
190 y + ht / 4, | |
191 x2, | |
192 y + ht / 4, | |
193 x2, | |
194 y, | |
195 x, | |
196 y1, | |
197 x2, | |
198 y + ht, | |
199 x2, | |
200 y + 3 * ht / 4, | |
201 x1, | |
202 y + 3 * ht / 4, | |
203 ) | |
204 ) | |
205 else: | |
206 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
207 colorstr(fc), | |
208 colorstr(oc), | |
209 lt, | |
210 ) | |
211 self.out += ' points="%d,%d %d,%d %d,%d" />\n' % ( | |
212 x, | |
213 y1, | |
214 x1, | |
215 y + ht, | |
216 x1, | |
217 y, | |
218 ) | |
219 | |
220 def drawBlastHit(self, x1, y1, x2, y2, x3, y3, x4, y4, fill=(0, 0, 255), lt=0): | |
221 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
222 colorstr(fill), | |
223 colorstr(fill), | |
224 lt, | |
225 ) | |
226 self.out += ' points="%d,%d %d,%d %d,%d %d,%d" />\n' % ( | |
227 x1, | |
228 y1, | |
229 x2, | |
230 y2, | |
231 x3, | |
232 y3, | |
233 x4, | |
234 y4, | |
235 ) | |
236 | |
237 def drawGradient(self, x1, y1, wid, hei, minc, maxc): | |
238 self.out += ' <defs>\n <linearGradient id="MyGradient" x1="0%" y1="0%" x2="0%" y2="100%">\n' | |
239 self.out += ' <stop offset="0%%" stop-color="%s" />\n' % colorstr(maxc) | |
240 self.out += ' <stop offset="100%%" stop-color="%s" />\n' % colorstr(minc) | |
241 self.out += " </linearGradient>\n </defs>\n" | |
242 self.out += ' <rect fill="url(#MyGradient)" stroke-width="0"\n' | |
243 self.out += ' x="%d" y="%d" width="%d" height="%d"/>\n' % ( | |
244 x1, | |
245 y1, | |
246 wid, | |
247 hei, | |
248 ) | |
249 | |
250 def drawGradient2(self, x1, y1, wid, hei, minc, maxc): | |
251 self.out += ' <defs>\n <linearGradient id="MyGradient2" x1="0%" y1="0%" x2="0%" y2="100%">\n' | |
252 self.out += ' <stop offset="0%%" stop-color="%s" />\n' % colorstr(maxc) | |
253 self.out += ' <stop offset="100%%" stop-color="%s" />\n' % colorstr(minc) | |
254 self.out += " </linearGradient>\n</defs>\n" | |
255 self.out += ' <rect fill="url(#MyGradient2)" stroke-width="0"\n' | |
256 self.out += ' x="%d" y="%d" width="%d" height="%d" />\n' % ( | |
257 x1, | |
258 y1, | |
259 wid, | |
260 hei, | |
261 ) | |
262 | |
263 def drawOutRect(self, x1, y1, wid, hei, fill, lt=1): | |
264 self.out += ' <rect fill="%s" stroke-width="%d"\n' % (colorstr(fill), lt) | |
265 self.out += ' x="%d" y="%d" width="%d" height="%d" />\n' % ( | |
266 x1, | |
267 y1, | |
268 wid, | |
269 hei, | |
270 ) | |
271 | |
272 def drawRightFrame(self, x, y, wid, ht, lt, frame, fill): | |
273 if lt > ht / 2: | |
274 lt = ht / 2 | |
275 if frame == 1: | |
276 y1 = y + ht / 2 | |
277 y2 = y + ht * 3 / 8 | |
278 y3 = y + ht * 1 / 4 | |
279 elif frame == 2: | |
280 y1 = y + ht * 3 / 8 | |
281 y2 = y + ht * 1 / 4 | |
282 y3 = y + ht * 1 / 8 | |
283 elif frame == 0: | |
284 y1 = y + ht * 1 / 4 | |
285 y2 = y + ht * 1 / 8 | |
286 y3 = y + 1 | |
287 x1 = x | |
288 x2 = x + wid - ht / 8 | |
289 x3 = x + wid | |
290 if wid > ht / 8: | |
291 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
292 colorstr(fill), | |
293 colorstr((0, 0, 0)), | |
294 lt, | |
295 ) | |
296 self.out += ' points="%d,%d %d,%d %d,%d %d,%d %d,%d" />\n' % ( | |
297 x1, | |
298 y1, | |
299 x2, | |
300 y1, | |
301 x3, | |
302 y2, | |
303 x2, | |
304 y3, | |
305 x1, | |
306 y3, | |
307 ) | |
308 else: | |
309 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
310 colorstr(fill), | |
311 colorstr((0, 0, 0)), | |
312 lt, | |
313 ) | |
314 self.out += ' points="%d,%d %d,%d %d,%d" />\n' % ( | |
315 x1, | |
316 y1, | |
317 x3, | |
318 y2, | |
319 x1, | |
320 y3, | |
321 ) | |
322 | |
323 def drawRightFrameRect(self, x, y, wid, ht, lt, frame, fill): | |
324 if lt > ht / 2: | |
325 lt = ht / 2 | |
326 if frame == 1: | |
327 y1 = y + ht / 4 | |
328 elif frame == 2: | |
329 y1 = y + ht / 8 | |
330 elif frame == 0: | |
331 y1 = y + 1 | |
332 hei = ht / 4 | |
333 x1 = x | |
334 self.out += ' <rect fill="%s" stroke-width="%d"\n' % (colorstr(fill), lt) | |
335 self.out += ' x="%d" y="%d" width="%d" height="%d" />\n' % ( | |
336 x1, | |
337 y1, | |
338 wid, | |
339 hei, | |
340 ) | |
341 | |
342 def drawLeftFrame(self, x, y, wid, ht, lt, frame, fill): | |
343 if lt > ht / 2: | |
344 lt = ht / 2 | |
345 if frame == 1: | |
346 y1 = y + ht | |
347 y2 = y + ht * 7 / 8 | |
348 y3 = y + ht * 3 / 4 | |
349 elif frame == 2: | |
350 y1 = y + ht * 7 / 8 | |
351 y2 = y + ht * 3 / 4 | |
352 y3 = y + ht * 5 / 8 | |
353 elif frame == 0: | |
354 y1 = y + ht * 3 / 4 | |
355 y2 = y + ht * 5 / 8 | |
356 y3 = y + ht / 2 | |
357 x1 = x + wid | |
358 x2 = x + ht / 8 | |
359 x3 = x | |
360 if wid > ht / 8: | |
361 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
362 colorstr(fill), | |
363 colorstr((0, 0, 0)), | |
364 lt, | |
365 ) | |
366 self.out += ' points="%d,%d %d,%d %d,%d %d,%d %d,%d" />\n' % ( | |
367 x1, | |
368 y1, | |
369 x2, | |
370 y1, | |
371 x3, | |
372 y2, | |
373 x2, | |
374 y3, | |
375 x1, | |
376 y3, | |
377 ) | |
378 else: | |
379 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
380 colorstr(fill), | |
381 colorstr((0, 0, 0)), | |
382 lt, | |
383 ) | |
384 self.out += ' points="%d,%d %d,%d %d,%d" />\n' % ( | |
385 x1, | |
386 y1, | |
387 x3, | |
388 y2, | |
389 x1, | |
390 y3, | |
391 ) | |
392 | |
393 def drawLeftFrameRect(self, x, y, wid, ht, lt, frame, fill): | |
394 if lt > ht / 2: | |
395 lt = ht / 2 | |
396 if frame == 1: | |
397 y1 = y + ht * 3 / 4 | |
398 elif frame == 2: | |
399 y1 = y + ht * 5 / 8 | |
400 elif frame == 0: | |
401 y1 = y + ht / 2 | |
402 hei = ht / 4 | |
403 x1 = x | |
404 self.out += ' <rect fill="%s" stroke-width="%d"\n' % (colorstr(fill), lt) | |
405 self.out += ' x="%d" y="%d" width="%d" height="%d" />\n' % ( | |
406 x1, | |
407 y1, | |
408 wid, | |
409 hei, | |
410 ) | |
411 | |
412 def drawPointer(self, x, y, ht, lt, fill): | |
413 x1 = x - int(round(0.577350269 * ht / 2)) | |
414 x2 = x + int(round(0.577350269 * ht / 2)) | |
415 y1 = y + ht / 2 | |
416 y2 = y + 1 | |
417 self.out += ' <polygon fill="%s" stroke="%s" stroke-width="%d"\n' % ( | |
418 colorstr(fill), | |
419 colorstr((0, 0, 0)), | |
420 lt, | |
421 ) | |
422 self.out += ' points="%d,%d %d,%d %d,%d" />\n' % ( | |
423 x1, | |
424 y2, | |
425 x2, | |
426 y2, | |
427 x, | |
428 y1, | |
429 ) | |
430 | |
431 def drawDash(self, x1, y1, x2, y2, exont): | |
432 self.out += ' <line x1="%d" y1="%d" x2="%d" y2="%d"\n' % (x1, y1, x2, y2) | |
433 self.out += ' style="stroke-dasharray: 5, 3, 9, 3"\n' | |
434 self.out += ' stroke="#000" stroke-width="%d" />\n' % exont | |
435 | |
436 def writeString( | |
437 self, thestring, x, y, size, ital=False, bold=False, rotate=0, justify="left" | |
438 ): | |
439 if rotate != 0: | |
440 x, y = y, x | |
441 self.out += " <text\n" | |
442 self.out += ( | |
443 ' style="font-size:%dpx;font-style:normal;font-weight:normal\ | |
444 ;line-height:125%%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"\n' | |
445 % size | |
446 ) | |
447 if justify == "right": | |
448 self.out += ' text-anchor="end"\n' | |
449 if rotate == 1: | |
450 self.out += ' x="-%d"\n' % x | |
451 else: | |
452 self.out += ' x="%d"\n' % x | |
453 if rotate == -1: | |
454 self.out += ' y="-%d"\n' % y | |
455 else: | |
456 self.out += ' y="%d"\n' % y | |
457 self.out += ' sodipodi:linespacing="125%"' | |
458 if rotate == -1: | |
459 self.out += '\n transform="matrix(0,1,-1,0,0,0)"' | |
460 if rotate == 1: | |
461 self.out += '\n transform="matrix(0,-1,1,0,0,0)"' | |
462 self.out += '><tspan\n sodipodi:role="line"\n' | |
463 if rotate == 1: | |
464 self.out += ' x="-%d"\n' % x | |
465 else: | |
466 self.out += ' x="%d"\n' % x | |
467 if rotate == -1: | |
468 self.out += ' y="-%d"' % y | |
469 else: | |
470 self.out += ' y="%d"' % y | |
471 if ital and bold: | |
472 self.out += '\nstyle="font-style:italic;font-weight:bold"' | |
473 elif ital: | |
474 self.out += '\nstyle="font-style:italic"' | |
475 elif bold: | |
476 self.out += '\nstyle="font-style:normal;font-weight:bold"' | |
477 self.out += ">" + thestring + "</tspan></text>\n" | |
478 | |
479 | |
480 # class of blast hit data | |
481 class BlastHit: | |
482 def __init__( | |
483 self, | |
484 query, | |
485 ref, | |
486 ident, | |
487 length, | |
488 mismatch, | |
489 gaps, | |
490 qStart, | |
491 qEnd, | |
492 rStart, | |
493 rEnd, | |
494 eValue, | |
495 bitscore, | |
496 ): | |
497 self.query = query | |
498 self.ref = ref | |
499 self.ident = float(ident) | |
500 self.length = int(length) | |
501 self.mismatch = int(mismatch) | |
502 self.gaps = int(gaps) | |
503 self.qStart = int(qStart) | |
504 self.qEnd = int(qEnd) | |
505 self.rStart = int(rStart) | |
506 self.rEnd = int(rEnd) | |
507 self.eValue = float(eValue) | |
508 self.bitscore = float(bitscore) | |
509 | |
510 | |
511 # class for feature data | |
512 class feature: | |
513 def __init__(self, start, stop, type, strand, colour, name): | |
514 self.start = start | |
515 self.stop = stop | |
516 self.type = type | |
517 self.strand = strand | |
518 self.colour = colour | |
519 self.name = name | |
520 | |
521 def length(self): | |
522 if type(self.start) == int: | |
523 return self.stop - self.start | |
524 else: | |
525 return self.stop[-1] - self.start[0] | |
526 | |
527 | |
528 # method for converting base pair position into pixel position | |
529 def convertPos(length, maxlength, width, pos, aln): | |
530 if aln == "centre": | |
531 return int(((((maxlength - length) * 1.0 / 2) + pos) * 1.0 / maxlength) * width) | |
532 elif aln == "left": | |
533 return int(((pos * 1.0 / maxlength) * width)) | |
534 elif aln == "right": | |
535 return int(((((maxlength - length) * 1.0) + pos) * 1.0 / maxlength) * width) | |
536 elif aln == "best blast": | |
537 return int((((pos + shifter) * 1.0 / maxlength) * width)) | |
538 | |
539 | |
540 # method for converting base pair position into pixel position if the genome has been reversed | |
541 def convertPosR(length, maxlength, width, pos, aln): | |
542 if aln == "centre": | |
543 return int( | |
544 width | |
545 - (((((maxlength - length) * 1.0 / 2) + pos) * 1.0 / maxlength) * width) | |
546 ) | |
547 elif aln == "left": | |
548 return int( | |
549 width - (((((maxlength - length) * 1.0) + pos) * 1.0 / maxlength) * width) | |
550 ) | |
551 elif aln == "right": | |
552 return int(width - ((pos * 1.0 / maxlength) * width)) | |
553 elif aln == "best blast": | |
554 return int( | |
555 width | |
556 - ( | |
557 ((((maxlength - length) * 1.0) + pos - shifter) * 1.0 / maxlength) | |
558 * width | |
559 ) | |
560 ) | |
561 | |
562 | |
563 """ Functions and classes for the bmp module. | |
564 This section of the code uses a modified version of Paul McGuire's | |
565 (http://www.geocities.com/ptmcg/) (RIP geocities/under constuction gifs) | |
566 bmp.py - module for constructing simple BMP graphics files | |
567 It is freely avaiable under the following license | |
568 | |
569 | |
570 license for all code contained: | |
571 | |
572 Permission is hereby granted, free of charge, to any person obtaining | |
573 a copy of this software and associated documentation files (the | |
574 "Software"), to deal in the Software without restriction, including | |
575 without limitation the rights to use, copy, modify, merge, publish, | |
576 distribute, sublicense, and/or sell copies of the Software, and to | |
577 permit persons to whom the Software is furnished to do so, subject to | |
578 the following conditions: | |
579 | |
580 The above copyright notice and this permission notice shall be | |
581 included in all copies or substantial portions of the Software. | |
582 | |
583 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
584 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
585 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
586 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
587 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
588 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
589 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
590 | |
591 """ | |
592 | |
593 | |
594 def shortToString(i): | |
595 hi = (i & 0xFF00) >> 8 | |
596 lo = i & 0x00FF | |
597 return chr(lo) + chr(hi) | |
598 | |
599 | |
600 def longToString(i): | |
601 hi = (int(i) & 0x7FFF0000) >> 16 | |
602 lo = int(i) & 0x0000FFFF | |
603 return shortToString(lo) + shortToString(hi) | |
604 | |
605 | |
606 # class | |
607 class Color(object): | |
608 """class for specifying s while drawing BitMap elements""" | |
609 | |
610 __slots__ = ["red", "grn", "blu"] | |
611 __shade = 32 | |
612 | |
613 def __init__(self, r=0, g=0, b=0): | |
614 self.red = r | |
615 self.grn = g | |
616 self.blu = b | |
617 | |
618 def __setattr__(self, name, value): | |
619 if hasattr(self, name): | |
620 raise AttributeError("Color is immutable") | |
621 else: | |
622 object.__setattr__(self, name, value) | |
623 | |
624 def __str__(self): | |
625 return "R:%d G:%d B:%d" % (self.red, self.grn, self.blu) | |
626 | |
627 def __hash__(self): | |
628 return (int(self.blu)) + (int(self.grn) << 8) + (int(self.red) << 16) | |
629 | |
630 def __eq__(self, other): | |
631 return (self is other) or (self.toLong == other.toLong) | |
632 | |
633 def lighten(self): | |
634 return Color( | |
635 min(self.red + Color.__shade, 255), | |
636 min(self.grn + Color.__shade, 255), | |
637 min(self.blu + Color.__shade, 255), | |
638 ) | |
639 | |
640 def darken(self): | |
641 return Color( | |
642 max(self.red - Color.__shade, 0), | |
643 max(self.grn - Color.__shade, 0), | |
644 max(self.blu - Color.__shade, 0), | |
645 ) | |
646 | |
647 def toLong(self): | |
648 return self.__hash__() | |
649 | |
650 def fromLong(l): | |
651 b = l & 0xFF | |
652 l = l >> 8 | |
653 g = l & 0xFF | |
654 l = l >> 8 | |
655 r = l & 0xFF | |
656 return Color(r, g, b) | |
657 | |
658 fromLong = staticmethod(fromLong) | |
659 | |
660 | |
661 # define class constants for common s | |
662 Color.BLACK = Color(0, 0, 0) | |
663 Color.RED = Color(255, 0, 0) | |
664 Color.GREEN = Color(0, 255, 0) | |
665 Color.BLUE = Color(0, 0, 255) | |
666 Color.CYAN = Color(0, 255, 255) | |
667 Color.MAGENTA = Color(255, 0, 255) | |
668 Color.YELLOW = Color(255, 255, 0) | |
669 Color.WHITE = Color(255, 255, 255) | |
670 Color.DKRED = Color(128, 0, 0) | |
671 Color.DKGREEN = Color(0, 128, 0) | |
672 Color.DKBLUE = Color(0, 0, 128) | |
673 Color.TEAL = Color(0, 128, 128) | |
674 Color.PURPLE = Color(128, 0, 128) | |
675 Color.BROWN = Color(128, 128, 0) | |
676 Color.GRAY = Color(128, 128, 128) | |
677 | |
678 | |
679 class BitMap(object): | |
680 """class for drawing and saving simple Windows bitmap files""" | |
681 | |
682 LINE_SOLID = 0 | |
683 LINE_DASHED = 1 | |
684 LINE_DOTTED = 2 | |
685 LINE_DOT_DASH = 3 | |
686 _DASH_LEN = 12.0 | |
687 _DOT_LEN = 6.0 | |
688 _DOT_DASH_LEN = _DOT_LEN + _DASH_LEN | |
689 | |
690 def __init__(self, width, height, bkgd=Color.WHITE, frgd=Color.BLACK): | |
691 self.wd = int(ceil(width)) | |
692 self.ht = int(ceil(height)) | |
693 self.bg = 0 | |
694 self.fg = 1 | |
695 self.palette = [] | |
696 self.palette.append(bkgd.toLong()) | |
697 self.palette.append(frgd.toLong()) | |
698 self.setDefaultPenColor() | |
699 | |
700 tmparray = [self.bg] * self.wd | |
701 self.bitarray = [tmparray[:] for i in range(self.ht)] | |
702 self.currentPen = 1 | |
703 self.fontName = "%s-%d-%s" % ("none", 0, "none") | |
704 self.defsize = 64 | |
705 self.amatrixwid = 41 | |
706 self.amatrixhei = 48 | |
707 self.amatrixori = 16 | |
708 self.amatrix = "3ff8000001ffffc00003fffff80003fffffe0003ffffff8003ffffffe003\ | |
709 fffffff801ff801ffc01ff0001fe00ff00007f80ff00003fc07f80000fe0\ | |
710 3fc00007f01fc00003f80fe00001fc00000000fe000000007f000000007f\ | |
711 800000003fc0000000ffe000000ffff00003fffff8001ffffffc003fffff\ | |
712 fe007fffff7f00fffff83f807fff001fc07ff8000fe07fe00007f03fc000\ | |
713 03f81fe00001fc1fe00000fe0fe000007f07f000003f83f800001fc1fc00\ | |
714 001fe0fe00000ff07f00000ff83fc0000ffc0ff0001ffe07fc001fff01ff\ | |
715 807fffc0ffffffcffe3fffffc7ff0fffffc3ff83ffff80ffc07fff007fe0\ | |
716 07f8000fe" | |
717 self.bmatrixwid = 40 | |
718 self.bmatrixhei = 64 | |
719 self.bmatrixori = 0 | |
720 self.bmatrix = "7f000000007f000000007f000000007f000000007f000000007f00000000\ | |
721 7f000000007f000000007f000000007f000000007f000000007f00000000\ | |
722 7f000000007f000000007f000000007f000000007f007fc0007f03fff800\ | |
723 7f07fffe007f1fffff007f3fffff807f7fffffc07f7fffffe07fff00fff0\ | |
724 7ffc003ff07ff8000ff87ff00007f87fe00003fc7fe00003fc7fc00001fe\ | |
725 7fc00001fe7f800000fe7f800000fe7f800000fe7f000000ff7f0000007f\ | |
726 7f0000007f7f0000007fff0000007fff0000007fff0000007fff0000007f\ | |
727 ff0000007fff0000007fff0000007fff800000feff800000feff800000fe\ | |
728 ff800000feffc00001feffc00001fcffe00003fcffe00007f8fff00007f8\ | |
729 fff8000ff8fffe003ff0ffff80ffe0feffffffe0fe7fffffc0fe3fffff80\ | |
730 fe1ffffe00fe0ffffc000003fff00000003f0000" | |
731 self.cmatrixwid = 37 | |
732 self.cmatrixhei = 48 | |
733 self.cmatrixori = 16 | |
734 self.cmatrix = "1ff0000007fff00000ffffe0001fffff8001ffffff001ffffff801ffffff\ | |
735 e00ffc01ff80ff8007fc0ff8001ff07f80007f87f80001fe3fc0000ff1fc\ | |
736 00003f9fe00001fcfe00000fe7f00000003f80000001f80000001fc00000\ | |
737 00fe00000007f00000003f80000001fc0000000fe00000007f00000003f8\ | |
738 0000001fc0000000fe00000007f00000001fc0000000fe000007f7f00000\ | |
739 3fbfc00003f8fe00001fc7f80000fe3fc0000ff0ff0000ff07fc000ff81f\ | |
740 f000ff807fe01ffc03ffffffc00ffffffc003fffffc000fffffc0001ffff\ | |
741 c00003fff8000001fc000" | |
742 self.dmatrixwid = 40 | |
743 self.dmatrixhei = 64 | |
744 self.dmatrixori = 0 | |
745 self.dmatrix = "7f000000007f000000007f000000007f000000007f000000007f00000000\ | |
746 7f000000007f000000007f000000007f000000007f000000007f00000000\ | |
747 7f000000007f000000007f000000007f0003ff007f001fffc07f003ffff0\ | |
748 7f00fffffc7f01fffffe7f03ffffff7f07ffffffff0fff00ffff0ffc003f\ | |
749 ff1ff0000fff1fe00007ff3fe00003ff3fc00003ff7f800001ff7f800001\ | |
750 ff7f000000ff7f000000ff7f000000ffff000000fffe0000007ffe000000\ | |
751 7ffe0000007ffe0000007ffe0000007ffe0000007ffe0000007ffe000000\ | |
752 7ffe0000007ffe0000007f7f000000ff7f000000ff7f000000ff7f000000\ | |
753 ff7f800001ff3f800001ff3fc00003ff3fe00003ff1ff00007ff1ff8000f\ | |
754 ff0ffc003fff07ff00ffff07ffffff7f03fffffe7f01fffffc7f00fffff8\ | |
755 7f003ffff07f000fffc0000000fc0000" | |
756 self.ematrixwid = 39 | |
757 self.ematrixhei = 48 | |
758 self.ematrixori = 16 | |
759 self.ematrix = "1ff0000001fffe00000fffff00003fffff0001ffffff0007ffffff001fff\ | |
760 ffff003ff007ff00ff8003ff03fe0003fe07f80001fe0fe00003fc3f8000\ | |
761 03fc7f000003f9fc000007f3f800000fe7f000000fcfc000001fff800000\ | |
762 3fff0000007fffffffffffffffffffffffffffffffffffffffffffffffff\ | |
763 ffffffffffff800000007f00000000fe00000001fc00000001f800000003\ | |
764 f800000007f000001fcfe000003f8fe00000ff1fc00001fc3fc00007f83f\ | |
765 c0001fe07fc0003fc07fe001ff007ff00ffe00fffffff800ffffffe000ff\ | |
766 ffff80007ffffe00007ffff000003fff80000007f8000" | |
767 self.fmatrixwid = 20 | |
768 self.fmatrixhei = 62 | |
769 self.fmatrixori = 0 | |
770 self.fmatrix = "7f003ff007ff00fff01fff01fff01fe003fc003f8003f8003f8003f8003f\ | |
771 8003f8003f8003f8003f80ffffffffffffffffffffffffffffff03f8003f\ | |
772 8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f\ | |
773 8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f\ | |
774 8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f\ | |
775 8003f80" | |
776 self.gmatrixwid = 39 | |
777 self.gmatrixhei = 65 | |
778 self.gmatrixori = 16 | |
779 self.gmatrix = "1ff0000000fff80fe007fffc1fc03ffffc3f80fffffc7f03fffffcfe0fff\ | |
780 fffdfc1ff807fff87fc003fff1ff0003ffe3fc0003ffcff00003ff9fe000\ | |
781 03ff3f800007feff000007fdfc00000ffbf800001ff7f000003fefc00000\ | |
782 3fff8000007fff000000fffe000001fffc000003fff8000007fff000000f\ | |
783 ffe000001fffc000003fff8000007fff000000fffe000001fefe000007fd\ | |
784 fc00000ffbf800001ff7f800007fe7f00000ffcff00001ff9fe00007ff1f\ | |
785 e0001ffe3fe0007ffc3fe001fff83ff00feff07fffffdfe07fffff3fc07f\ | |
786 fffc7f807ffff0ff003fff81fe001ffe03f80007c007f00000000fe00000\ | |
787 003fc00000007f9fc00000ff3f800001fc7f800007f87f00000ff0ff0000\ | |
788 3fc1ff0000ff81ff0007fe01ff803ff803fffffff003ffffffc003fffffe\ | |
789 0001fffff80000ffff8000001ff8000" | |
790 self.hmatrixwid = 35 | |
791 self.hmatrixhei = 62 | |
792 self.hmatrixori = 0 | |
793 self.hmatrix = "3f80000007f0000000fe0000001fc0000003f80000007f0000000fe00000\ | |
794 01fc0000003f80000007f0000000fe0000001fc0000003f80000007f0000\ | |
795 000fe0000001fc0000003f803fe007f03fffc0fe0ffffc1fc7ffffe3f9ff\ | |
796 fffe7f7fffffcfffe01ffdfff000ffbffc000ff7ff0000ffffc0001ffff0\ | |
797 0001fffe00003fff800007fff00000fffe00001fff800003fff000007ffe\ | |
798 00000fffc00001fff800003fff000007ffe00000fffc00001fff800003ff\ | |
799 f000007ffe00000fffc00001fff800003fff000007ffe00000fffc00001f\ | |
800 ff800003fff000007ffe00000fffc00001fff800003fff000007ffe00000\ | |
801 fffc00001fff800003fff000007ffe00000fffc00001fff800003fff0000\ | |
802 07f" | |
803 self.imatrixwid = 7 | |
804 self.imatrixhei = 63 | |
805 self.imatrixori = 0 | |
806 self.imatrix = "1fffffffffffffffc0000000000000007fffffffffffffffffffffffffff\ | |
807 fffffffffffffffffffffffffffffffffffffffffffffffffff" | |
808 self.jmatrixwid = 14 | |
809 self.jmatrixhei = 80 | |
810 self.jmatrixori = 0 | |
811 self.jmatrix = "1fc07f01fc07f01fc07f01fc07f01fc00000000000000000000000000000\ | |
812 7f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01\ | |
813 fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07\ | |
814 f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01fc07f01f\ | |
815 c07f01fc0ff03fc1fffffbffefff3ff8ffc3f00" | |
816 self.kmatrixwid = 38 | |
817 self.kmatrixhei = 62 | |
818 self.kmatrixori = 0 | |
819 self.kmatrix = "fe00000003f80000000fe00000003f80000000fe00000003f80000000fe0\ | |
820 0000003f80000000fe00000003f80000000fe00000003f80000000fe0000\ | |
821 0003f80000000fe00000003f80000000fe00000003f80001ff8fe0000ff8\ | |
822 3f80007fc0fe0003fe03f8001ff00fe000ff803f8007fc00fe003fe003f8\ | |
823 01ff000fe00ff8003f807fc000fe03fe0003f81ff0000fe0ff80003f87fc\ | |
824 0000fe3fe00003f9ffc0000fe7ff80003fbffe0000fffffc0003fffff000\ | |
825 0fffbfe0003ffc7fc000ffe0ff0003ff03fe000ff807fc003fc01ff000fe\ | |
826 003fe003f8007f800fe001ff003f8003fe00fe0007f803f8001ff00fe000\ | |
827 3fe03f8000ff80fe0001ff03f80003fc0fe0000ff83f80001ff0fe00003f\ | |
828 c3f80000ff8fe00001fe3f800007fcfe00000ffbf800001ff" | |
829 self.lmatrixwid = 7 | |
830 self.lmatrixhei = 62 | |
831 self.lmatrixori = 0 | |
832 self.lmatrix = "3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
833 fffffffffffffffffffffffffffffffffffffffffffffffff" | |
834 self.mmatrixwid = 59 | |
835 self.mmatrixhei = 46 | |
836 self.mmatrixori = 16 | |
837 self.mmatrix = "3fe0001ff007f03fff001fffc0fe0ffff807fffe1fc7ffff83ffffe3f9ff\ | |
838 fff8fffffe7f7fffffbfffffcfffc07ffff01ffdffe003fff800ffbff800\ | |
839 3ffe000ffffe0003ff8000ffff80007fe0001ffff00007fc0001fffc0000\ | |
840 ff00003fff80001fe00007ffe00003f80000fffc00007f00001fff80000f\ | |
841 e00003fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe\ | |
842 00003fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe0\ | |
843 0003fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe00\ | |
844 003fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe000\ | |
845 03fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe0000\ | |
846 3fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe00003\ | |
847 fff00001fc00007ffe00003f80000fffc00007f00001fff80000fe00003f\ | |
848 ff00001fc00007f" | |
849 self.nmatrixwid = 35 | |
850 self.nmatrixhei = 46 | |
851 self.nmatrixori = 16 | |
852 self.nmatrix = "1fe007f01fff80fe0ffffc1fc3ffffc3f8fffffc7f3fffffcfefe01ffdff\ | |
853 f001ffbffc000ff7ff0001ffffc0001ffff00001fffe00003fff800007ff\ | |
854 f00000fffe00001fff800003fff000007ffe00000fffc00001fff800003f\ | |
855 ff000007ffe00000fffc00001fff800003fff000007ffe00000fffc00001\ | |
856 fff800003fff000007ffe00000fffc00001fff800003fff000007ffe0000\ | |
857 0fffc00001fff800003fff000007ffe00000fffc00001fff800003fff000\ | |
858 007ffe00000fffc00001fff800003fff000007f" | |
859 self.omatrixwid = 40 | |
860 self.omatrixhei = 48 | |
861 self.omatrixori = 16 | |
862 self.omatrix = "1ff8000000ffff000003ffffc0000ffffff0001ffffff8003ffffffc007f\ | |
863 fffffe00fff00fff00ffc003ff01ff0000ff81fe00007f83fc00003fc3fc\ | |
864 00003fc3f800001fc7f800001fe7f000000fe7f000000fe7f000000fefe0\ | |
865 00000fffe0000007ffe0000007ffe0000007ffe0000007ffe0000007ffe0\ | |
866 000007ffe0000007ffe0000007ffe0000007ffe0000007fff000000ff7f0\ | |
867 00000fe7f000000fe7f000000fe7f800001fe3f800001fc3fc00003fc3fc\ | |
868 00003fc1fe00007f81ff0000ff80ffc003ff007ff00ffe007ffffffe003f\ | |
869 fffffc001ffffff8000fffffe00003ffffc00000ffff0000000ff0000" | |
870 self.pmatrixwid = 40 | |
871 self.pmatrixhei = 64 | |
872 self.pmatrixori = 16 | |
873 self.pmatrix = "7fc000fe03fff800fe0ffffe00fe1fffff00fe3fffff80fe7fffffc0feff\ | |
874 ffffe0ffff00fff0fffc003ff0fff8000ff8fff00007f8ffe00003fcffe0\ | |
875 0003fcffc00001fcffc00001feff800000feff800000feff800000feff00\ | |
876 0000ffff0000007fff0000007fff0000007fff0000007fff0000007fff00\ | |
877 00007f7f0000007f7f0000007f7f0000007f7f0000007f7f800000ff7f80\ | |
878 0000fe7f800000fe7f800000fe7fc00001fe7fc00001fc7fe00003fc7fe0\ | |
879 0007fc7ff0000ff87ff8001ff87ffc003ff07fff80fff07fffffffe07f7f\ | |
880 ffffc07f3fffff807f1fffff007f07fffc007f01fff0007f003f80007f00\ | |
881 0000007f000000007f000000007f000000007f000000007f000000007f00\ | |
882 0000007f000000007f000000007f000000007f000000007f000000007f00\ | |
883 0000007f000000007f000000007f00000000" | |
884 self.qmatrixwid = 40 | |
885 self.qmatrixhei = 64 | |
886 self.qmatrixori = 16 | |
887 self.qmatrix = "1fe0000000fffc07f003ffff07f00fffff87f01fffffe7f03ffffff7f07f\ | |
888 fffff7f07ff007fff0ffc003fff1ff0000fff1fe00007ff3fe00003ff3fc\ | |
889 00003ff3f800001ff7f800001ff7f000000ff7f000000ff7f000000ff7f0\ | |
890 00000fffe0000007ffe0000007ffe0000007ffe0000007ffe0000007ffe0\ | |
891 000007ffe0000007ffe0000007ffe0000007ffe0000007fff000000ff7f0\ | |
892 00000ff7f000000ff7f000000ff7f800001ff7f800001ff3fc00003ff3fe\ | |
893 00003ff1ff00007ff1ff8000fff0ffc003fff0fff00ffff07ffffff7f03f\ | |
894 fffff7f01fffffe7f00fffff87f003ffff07f000fffc07f0001fc007f000\ | |
895 000007f000000007f000000007f000000007f000000007f000000007f000\ | |
896 000007f000000007f000000007f000000007f000000007f000000007f000\ | |
897 000007f000000007f000000007f000000007f" | |
898 self.rmatrixwid = 22 | |
899 self.rmatrixhei = 46 | |
900 self.rmatrixori = 16 | |
901 self.rmatrix = "3bf80fffe07fff87fffe3ffff9ffffe7ffffbfe0fffc03ffc00ffe003ff0\ | |
902 00ff8003fe000ff0003fc000ff0003f8000fe0003f8000fe0003f8000fe0\ | |
903 003f8000fe0003f8000fe0003f8000fe0003f8000fe0003f8000fe0003f8\ | |
904 000fe0003f8000fe0003f8000fe0003f8000fe0003f8000fe0003f8000fe\ | |
905 0003f8000" | |
906 self.smatrixwid = 36 | |
907 self.smatrixhei = 48 | |
908 self.smatrixori = 16 | |
909 self.smatrix = "7fe000003fffc0001fffff0003fffffc007fffffe00fffffff01fffffff0\ | |
910 1ff803ff83fe0007f83f80007f87f80003fc7f00001fc7f00001fc7f0000\ | |
911 1fc7f00000007f00000007f80000003fc0000003ff8000003fff000001ff\ | |
912 ff00000fffff00007fffff0001fffffc0007fffff0001fffff80001ffffc\ | |
913 00001fffc000001ffe0000003fe0000001ff0000000ff00000007ffe0000\ | |
914 07ffe000007fff000007f7f000007f7f80000fe7f80001fe7fe0007fe3ff\ | |
915 801ffc3fffffff81fffffff80fffffff007fffffc001fffff80007fffc00\ | |
916 0007fc000" | |
917 self.tmatrixwid = 20 | |
918 self.tmatrixhei = 59 | |
919 self.tmatrixori = 5 | |
920 self.tmatrix = "3f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f80f\ | |
921 fffffffffffffffffffffffffffff03f8003f8003f8003f8003f8003f800\ | |
922 3f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f800\ | |
923 3f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f8003f800\ | |
924 3f8003f8003f8003f8003fc003fff03fff01fff00fff007ff001fe" | |
925 self.umatrixwid = 35 | |
926 self.umatrixhei = 47 | |
927 self.umatrixori = 17 | |
928 self.umatrix = "1fc00001fff800003fff000007ffe00000fffc00001fff800003fff00000\ | |
929 7ffe00000fffc00001fff800003fff000007ffe00000fffc00001fff8000\ | |
930 03fff000007ffe00000fffc00001fff800003fff000007ffe00000fffc00\ | |
931 001fff800003fff000007ffe00000fffc00001fff800003fff000007ffe0\ | |
932 0000fffc00001fff800003fff000007ffe00001fffc00003fff800007fff\ | |
933 00001fffe00003fffe0000ffffe0003ffbfc000fff7fe003ffeffe03fdfc\ | |
934 ffffff3f8fffffc7f0fffff0fe0ffffc1fc07ffe000001fe0000" | |
935 self.vmatrixwid = 40 | |
936 self.vmatrixhei = 45 | |
937 self.vmatrixori = 17 | |
938 self.vmatrix = "ff000000ffff000000ff7f800001fe7f800001fe7f800001fe3fc00003fc\ | |
939 3fc00003fc3fc00003f81fe00007f81fe00007f81fe00007f00ff0000ff0\ | |
940 0ff0000ff007f0000fe007f8001fe007f8001fc003f8001fc003fc003fc0\ | |
941 03fc003f8001fc003f8001fe007f8001fe007f0000fe007f0000ff00fe00\ | |
942 00ff00fe00007f00fe00007f01fc00007f81fc00003f83f800003f83f800\ | |
943 003fc3f800001fc7f000001fc7f000000fe7f000000fefe000000fefe000\ | |
944 0007ffc0000007ffc0000007ffc0000003ff80000003ff80000003ff8000\ | |
945 0001ff00000001ff00000001fe0000" | |
946 self.wmatrixwid = 60 | |
947 self.wmatrixhei = 45 | |
948 self.wmatrixori = 17 | |
949 self.wmatrix = "ff00003fc0000ff7f00007fe0000ff7f80007fe0001fe7f80007fe0001fe\ | |
950 7f80007fe0001fe3f8000fff0001fc3fc000fff0003fc3fc000fff0003fc\ | |
951 1fc000fff0003f81fc001fff8003f81fe001fff8007f81fe001fbf8007f8\ | |
952 0fe001fbf8007f00fe003f9fc007f00ff003f9fc00ff007f003f1fc00fe0\ | |
953 07f003f1fc00fe007f007f0fe00fe007f807f0fe01fe003f807e0fe01fc0\ | |
954 03f807e07f01fc003fc0fe07f01fc001fc0fe07f03f8001fc0fc07f03f80\ | |
955 01fc0fc03f83f8001fe1fc03f83f8000fe1fc03f87f0000fe1f803f87f00\ | |
956 00fe1f801fc7f00007f3f801fc7e00007f3f801fcfe00007f3f001fcfe00\ | |
957 007f3f000fefe00003fff000fefc00003fff000fffc00003ffe000fffc00\ | |
958 001ffe0007ff800001ffe0007ff800001ffe0007ff800001ffc0007ff800\ | |
959 000ffc0003ff000000ffc0003ff000000ffc0003ff0000007f80003fe000\ | |
960 0007f80001fe000" | |
961 self.xmatrixwid = 39 | |
962 self.xmatrixhei = 45 | |
963 self.xmatrixori = 17 | |
964 self.xmatrix = "3fe00000ff3fc00003fc3fc0000ff03fc0001fc07f80007f807f8001fe00\ | |
965 7f8003f800ff000ff000ff003fc000ff007f0001fe01fe0001fe07f80001\ | |
966 fe0fe00003fc3fc00003fcff000003fdfc000007fff0000007ffe0000007\ | |
967 ff8000000ffe0000000ffc0000000ff00000001fe00000007fe0000000ff\ | |
968 e0000003ffc000000fffc000003fffc000007f7f800001fe7f800007f87f\ | |
969 80000fe0ff00003fc0ff0000ff00ff0001fc01fe0007f801fe001fe001fe\ | |
970 003f8003fc00ff0003fc03fc0007fc0ff00007f81fe00007f87f80000ff9\ | |
971 fe00000ff7fc00000ff" | |
972 self.ymatrixwid = 39 | |
973 self.ymatrixhei = 64 | |
974 self.ymatrixori = 17 | |
975 self.ymatrix = "fe000001fffe000007f9fc00000ff3f800001fc7f800007f8ff00000ff0f\ | |
976 e00001fc1fe00007f83fc0000ff03f80001fc07f80007f80ff0000ff00fe\ | |
977 0001fc01fe0007f803fc000fe003f8001fc007f8007f800ff000fe000fe0\ | |
978 01fc001fe007f8003fc00fe0003f803fc0007f807f8000ff00fe0000fe03\ | |
979 fc0001fc07f00003fc0fe00003f83fc00007f07f00000ff0fe00000fe3fc\ | |
980 00001fc7f000003fcfe000003fbfc000007f7f000000fffe000000fff800\ | |
981 0001fff0000003ffe0000003ff80000007ff0000000ffe0000000ff80000\ | |
982 001ff00000003fe00000003f80000000ff00000001fe00000003f8000000\ | |
983 0ff00000001fc00000007f80000000ff00000001fc00000007f80000001f\ | |
984 f00000007fc000003fff8000007ffe000000fff8000001ffe0000003ff80\ | |
985 000007fe00000003e0000000" | |
986 self.zmatrixwid = 36 | |
987 self.zmatrixhei = 45 | |
988 self.zmatrixori = 17 | |
989 self.zmatrix = "7fffffffe7fffffffe7fffffffe7fffffffe7fffffffe7fffffffe000000\ | |
990 3fc0000007f8000000ff8000001ff0000001fe0000003fc0000007f80000\ | |
991 00ff8000001ff0000003fe0000003fc0000007f8000000ff8000001ff000\ | |
992 0003fe0000003fc0000007f8000000ff8000001ff0000003fe0000003fc0\ | |
993 000007f8000000ff8000001ff0000003fe0000003fc0000007fc000000ff\ | |
994 8000001ff0000003fe0000003fc0000007fc000000ff8000000fffffffff\ | |
995 fffffffffffffffffffffffffffffffffffffffffffff" | |
996 self.Amatrixwid = 55 | |
997 self.Amatrixhei = 62 | |
998 self.Amatrixori = 0 | |
999 self.Amatrix = "ffe00000000001ffc00000000003ffc0000000000fff80000000001fff00\ | |
1000 000000003fff0000000000fffe0000000001fffc0000000003fffc000000\ | |
1001 000ff7f8000000001feff0000000007fcff000000000ff1fe000000001fe\ | |
1002 3fc000000007f83fc00000000ff07f800000001fe0ff800000007f80ff00\ | |
1003 000000ff01fe00000001fe03fe00000007f803fc0000000ff007f8000000\ | |
1004 1fe00ff80000007f800ff0000000ff001fe0000003fe003fe0000007f800\ | |
1005 3fc000000ff0007f8000003fc000ff8000007f8000ff000000ff0001fe00\ | |
1006 0003fc0003fe000007f80003fc00000ff00007fc00003fc0000ff800007f\ | |
1007 80000ff00000ff00001ff00003ffffffffe00007ffffffffc0001fffffff\ | |
1008 ffc0003fffffffff80007fffffffff0001ffffffffff0003fffffffffe00\ | |
1009 07f8000003fc001ff0000007fc003fc000000ff8007f8000000ff001ff00\ | |
1010 00001ff003fc0000003fe007f80000003fc01ff00000007fc03fc0000000\ | |
1011 ff80ff80000000ff81ff00000001ff03fc00000003fe0ff800000003fe1f\ | |
1012 e000000007fc3fc00000000ff8ff800000000ff9fe000000001ff7fc0000\ | |
1013 00001ff" | |
1014 self.Bmatrixwid = 46 | |
1015 self.Bmatrixhei = 62 | |
1016 self.Bmatrixori = 0 | |
1017 self.Bmatrix = "fffffffc0003ffffffff000fffffffff003ffffffffe00fffffffffc03ff\ | |
1018 fffffff80ffffffffff03fc00001ffe0ff000001ff83fc000003ff0ff000\ | |
1019 0007fc3fc000000ff0ff0000003fe3fc0000007f8ff0000001fe3fc00000\ | |
1020 07f8ff0000001fe3fc0000007f8ff0000001fe3fc0000007f0ff0000001f\ | |
1021 c3fc000000ff0ff0000003f83fc000001fe0ff000000ff83fc000007fc0f\ | |
1022 f00000ffe03fffffffff00fffffffff003ffffffff800fffffffff803fff\ | |
1023 ffffff80ffffffffff03ffffffffff0ff000001ffc3fc000001ff8ff0000\ | |
1024 001ff3fc0000003feff0000000ffbfc0000001feff00000007fbfc000000\ | |
1025 0ffff00000003fffc0000000ffff00000003fffc0000000ffff00000003f\ | |
1026 bfc0000000feff00000007fbfc0000001feff00000007fbfc0000003fcff\ | |
1027 0000001ff3fc000000ff8ff000000ffe3ffffffffff0ffffffffff83ffff\ | |
1028 fffffc0fffffffffe03fffffffff00fffffffff003fffffffc000" | |
1029 self.Cmatrixwid = 53 | |
1030 self.Cmatrixhei = 65 | |
1031 self.Cmatrixori = -1 | |
1032 self.Cmatrix = "3ff8000000001ffffc00000007fffffc000000fffffff000001fffffffe0\ | |
1033 0001ffffffff80001ffffffffe0001fff000fff8001ffc0001ffc001ffc0\ | |
1034 0003ff001ff800000ffc00ff8000003fe00ff8000000ff807f80000003fc\ | |
1035 07fc0000001fe03fc00000007f83fc00000003fc1fe00000001fe1fe0000\ | |
1036 00007f8ff000000003fc7f800000000007f800000000003fc00000000001\ | |
1037 fe00000000000ff000000000007f800000000003f800000000003fc00000\ | |
1038 000001fe00000000000ff000000000007f800000000003fc00000000001f\ | |
1039 e00000000000ff000000000007f800000000003fc00000000001fe000000\ | |
1040 00000ff000000000007f800000000001fe00000000000ff000000000ff7f\ | |
1041 8000000007fbfc000000003fdfe000000003fc7f800000001fe3fc000000\ | |
1042 00ff1ff000000007f87f800000007fc3fe00000003fc0ff00000003fe07f\ | |
1043 c0000001ff01ff0000001ff00ffc000000ff803ff000000ff801ffc00000\ | |
1044 ffc007ff00000ffc001ffe0001ffc0007ffe007ffc0001ffffffffe00007\ | |
1045 fffffffc00001fffffffc000003ffffffc0000007fffff800000007fffe0\ | |
1046 000000003ff00000" | |
1047 self.Dmatrixwid = 49 | |
1048 self.Dmatrixhei = 62 | |
1049 self.Dmatrixori = 0 | |
1050 self.Dmatrix = "3ffffffe00001ffffffff0000ffffffffe0007ffffffffc003fffffffff0\ | |
1051 01fffffffffe00ffffffffff807f800007ffe03fc000007ff01fe000000f\ | |
1052 fc0ff0000003ff07f8000000ff83fc0000003fe1fe0000000ff0ff000000\ | |
1053 07fc7f80000001fe3fc0000000ff9fe00000003fcff00000001fe7f80000\ | |
1054 0007fbfc00000003fdfe00000001feff00000000ff7f800000007fbfc000\ | |
1055 00001fffe00000000ffff000000007fff800000003fffc00000001fffe00\ | |
1056 000000ffff000000007fff800000003fffc00000001fffe00000000ffff0\ | |
1057 00000007fff800000003fffc00000001fffe00000000ffff00000000ff7f\ | |
1058 800000007fbfc00000003fdfe00000001feff00000000ff7f80000000ff3\ | |
1059 fc00000007f9fe00000007fcff00000003fc7f80000003fe3fc0000001fe\ | |
1060 1fe0000001ff0ff0000001ff07f8000001ff83fc000001ff81fe000003ff\ | |
1061 80ff00000fffc07fffffffffc03fffffffff801fffffffff800fffffffff\ | |
1062 8007ffffffff0003fffffffe0001fffffff00000" | |
1063 self.Ematrixwid = 44 | |
1064 self.Ematrixhei = 62 | |
1065 self.Ematrixori = 0 | |
1066 self.Ematrix = "ffffffffffeffffffffffeffffffffffeffffffffffeffffffffffefffff\ | |
1067 fffffeffffffffffeff000000000ff000000000ff000000000ff00000000\ | |
1068 0ff000000000ff000000000ff000000000ff000000000ff000000000ff00\ | |
1069 0000000ff000000000ff000000000ff000000000ff000000000ff0000000\ | |
1070 00ff000000000ff000000000ff000000000ff000000000ff000000000fff\ | |
1071 fffffffcffffffffffcffffffffffcffffffffffcffffffffffcffffffff\ | |
1072 ffcffffffffffcff000000000ff000000000ff000000000ff000000000ff\ | |
1073 000000000ff000000000ff000000000ff000000000ff000000000ff00000\ | |
1074 0000ff000000000ff000000000ff000000000ff000000000ff000000000f\ | |
1075 f000000000ff000000000ff000000000ff000000000ff000000000ff0000\ | |
1076 00000fffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1077 ffffffffffffffffffffff" | |
1078 self.Fmatrixwid = 42 | |
1079 self.Fmatrixhei = 62 | |
1080 self.Fmatrixori = 0 | |
1081 self.Fmatrix = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1082 fffffffffffffffc00000000ff000000003fc00000000ff000000003fc00\ | |
1083 000000ff000000003fc00000000ff000000003fc00000000ff000000003f\ | |
1084 c00000000ff000000003fc00000000ff000000003fc00000000ff0000000\ | |
1085 03fc00000000ff000000003fc00000000ff000000003fffffffff0ffffff\ | |
1086 fffc3fffffffff0fffffffffc3fffffffff0fffffffffc3fffffffff0ff0\ | |
1087 00000003fc00000000ff000000003fc00000000ff000000003fc00000000\ | |
1088 ff000000003fc00000000ff000000003fc00000000ff000000003fc00000\ | |
1089 000ff000000003fc00000000ff000000003fc00000000ff000000003fc00\ | |
1090 000000ff000000003fc00000000ff000000003fc00000000ff000000003f\ | |
1091 c00000000ff000000003fc00000000ff000000003fc00000000" | |
1092 self.Gmatrixwid = 56 | |
1093 self.Gmatrixhei = 65 | |
1094 self.Gmatrixori = -1 | |
1095 self.Gmatrix = "ffe0000000001fffff000000007fffffc0000001fffffff0000007ffffff\ | |
1096 fc00000ffffffffe00003fffffffff00007fff000fff8000fff80003ffc0\ | |
1097 00ffe00000ffe001ff8000003ff003ff0000001ff007fe0000000ff807fc\ | |
1098 0000000ff80ff800000007fc0ff800000003fc1ff000000003fc1fe00000\ | |
1099 0003fc1fe000000001fe3fc000000001fe3fc000000000003fc000000000\ | |
1100 007f8000000000007f8000000000007f8000000000007f8000000000007f\ | |
1101 000000000000ff000000000000ff000000000000ff000000000000ff0000\ | |
1102 03ffffffff000003ffffffff000003ffffffff000003ffffffff000003ff\ | |
1103 ffffff000003ffffffff000003ffffffff00000000007f7f80000000007f\ | |
1104 7f80000000007f7f80000000007f7f80000000007f7fc0000000007f3fc0\ | |
1105 000000007f3fc000000000ff3fe000000000ff1fe000000000ff1ff00000\ | |
1106 0001ff1ff000000001ff0ff800000003ff0ffc00000007ff07fc00000007\ | |
1107 ff03fe0000000fff03ff0000001fff01ffc000007fff00ffe00000ffff00\ | |
1108 7ffc0003ff7f003fff001ffe3f001ffffffffc3f000ffffffff83f0007ff\ | |
1109 ffffe03f0001ffffff801f00007fffff001f00000ffff80000000000ff00\ | |
1110 0000" | |
1111 self.Hmatrixwid = 48 | |
1112 self.Hmatrixhei = 62 | |
1113 self.Hmatrixori = 0 | |
1114 self.Hmatrix = "ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1115 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1116 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1117 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1118 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1119 ff00000000ffff00000000ffffffffffffffffffffffffffffffffffffff\ | |
1120 ffffffffffffffffffffffffffffffffffffffffffffffffff00000000ff\ | |
1121 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1122 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1123 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1124 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1125 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1126 ff00000000ffff00000000ff" | |
1127 self.Imatrixwid = 8 | |
1128 self.Imatrixhei = 62 | |
1129 self.Imatrixori = 0 | |
1130 self.Imatrix = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1131 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1132 ffff" | |
1133 self.Jmatrixwid = 35 | |
1134 self.Jmatrixhei = 64 | |
1135 self.Jmatrixori = 0 | |
1136 self.Jmatrix = "1fe0000003fc0000007f8000000ff0000001fe0000003fc0000007f80000\ | |
1137 00ff0000001fe0000003fc0000007f8000000ff0000001fe0000003fc000\ | |
1138 0007f8000000ff0000001fe0000003fc0000007f8000000ff0000001fe00\ | |
1139 00003fc0000007f8000000ff0000001fe0000003fc0000007f8000000ff0\ | |
1140 000001fe0000003fc0000007f8000000ff0000001fe0000003fc0000007f\ | |
1141 8000000ff0000001fe0000003fc0000007f8000000ff0000001fe0000003\ | |
1142 fffc00007fff80000ffff00001fffe00003fffc00007fff80000ffff0000\ | |
1143 1fffe00003fffc0000ffffc0001fe7f80003fcff8000ff9ff8003fe1ff80\ | |
1144 0ffc3ffc07ff03ffffffe03ffffff803fffffe003fffff0001ffffc0000f\ | |
1145 ffe000003fc000" | |
1146 self.Kmatrixwid = 49 | |
1147 self.Kmatrixhei = 62 | |
1148 self.Kmatrixori = 0 | |
1149 self.Kmatrix = "3fc0000000ffffe0000000ffeff0000000ffe7f8000000ffe3fc000000ff\ | |
1150 e1fe000000ffe0ff000000ffe07f800000ffe03fc00000ffe01fe00000ff\ | |
1151 e00ff000007fe007f800007fe003fc00007fe001fe00007fe000ff00007f\ | |
1152 e0007f80007fe0003fc0007fe0001fe0007fe0000ff0007fe00007f8007f\ | |
1153 e00003fc007fe00001fe007fe00000ff007fe000007f807fe000003fc07f\ | |
1154 e000001fe07fe000000ff07ff8000007f87ffc000003fc7fff000001fe7f\ | |
1155 ffc00000ff7fffe000007fffcff800003fffc3fe00001fffc1ff00000fff\ | |
1156 c07fc00007ffc01ff00003ffc00ffc0001ffc003fe0000ffc000ff80007f\ | |
1157 c0007fe0003fc0001ff0001fe00007fc000ff00001ff0007f80000ff8003\ | |
1158 fc00003fe001fe00000ff800ff000007fe007f800001ff003fc000007fc0\ | |
1159 1fe000003ff00ff000000ff807f8000003fe03fc000001ff81fe0000007f\ | |
1160 c0ff0000001ff07f8000000ffc3fc0000003fe1fe0000000ff8ff0000000\ | |
1161 3fe7f80000001ffbfc00000007fdfe00000001ff" | |
1162 self.Lmatrixwid = 39 | |
1163 self.Lmatrixhei = 62 | |
1164 self.Lmatrixori = 0 | |
1165 self.Lmatrix = "3fc00000007f80000000ff00000001fe00000003fc00000007f80000000f\ | |
1166 f00000001fe00000003fc00000007f80000000ff00000001fe00000003fc\ | |
1167 00000007f80000000ff00000001fe00000003fc00000007f80000000ff00\ | |
1168 000001fe00000003fc00000007f80000000ff00000001fe00000003fc000\ | |
1169 00007f80000000ff00000001fe00000003fc00000007f80000000ff00000\ | |
1170 001fe00000003fc00000007f80000000ff00000001fe00000003fc000000\ | |
1171 07f80000000ff00000001fe00000003fc00000007f80000000ff00000001\ | |
1172 fe00000003fc00000007f80000000ff00000001fe00000003fc00000007f\ | |
1173 80000000ff00000001fe00000003fc00000007f80000000ff00000001fff\ | |
1174 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1175 fffff" | |
1176 self.Mmatrixwid = 57 | |
1177 self.Mmatrixhei = 62 | |
1178 self.Mmatrixori = 0 | |
1179 self.Mmatrix = "3ff800000000fffffc000000007ffffe000000003fffff800000003fffff\ | |
1180 c00000001fffffe00000000ffffff80000000ffffffc00000007fffffe00\ | |
1181 000003ffffff80000003ffffffc0000001ffffffe0000000fffffbf80000\ | |
1182 00fefffdfc0000007f7ffefe0000003fbfff3f8000003f9fff9fc000001f\ | |
1183 cfffcfe000000fe7ffe3f800000fe3fff1fc000007f1fff8fe000003f8ff\ | |
1184 fc3f800003f87ffe1fc00001fc3fff0fe00000fe1fff83f80000fe0fffc1\ | |
1185 fc00007f07ffe0fe00003f83fff03f80003f81fff81fc0001fc0fffc0fe0\ | |
1186 000fe07ffe03f8000fe03fff01fc0007f01fff807e0003f80fffc03f8003\ | |
1187 f807ffe01fc001fc03fff007e000fe01fff803f800fe00fffc01fc007f00\ | |
1188 7ffe007e003f803fff003f803f801fff801fc01fc00fffc007e00fe007ff\ | |
1189 e003f80fe003fff001fc07f001fff8007e03f800fffc003f83f8007ffe00\ | |
1190 1fc1fc003fff0007e0fe001fff8003f8fe000fffc001fc7f0007ffe0007e\ | |
1191 3f8003fff0003fbf8001fff8001fdfc000fffc0007ffe0007ffe0003ffe0\ | |
1192 003fff0001fff0001fff80007ff8000fffc0003ff80007ffe0001ffc0003\ | |
1193 fff00007fe0001fff80003fe0000fffc0001ff00007f" | |
1194 self.Nmatrixwid = 48 | |
1195 self.Nmatrixhei = 62 | |
1196 self.Nmatrixori = 0 | |
1197 self.Nmatrix = "ff000000007fff800000007fffc00000007fffc00000007fffe00000007f\ | |
1198 fff00000007ffff00000007ffff80000007ffffc0000007ffffc0000007f\ | |
1199 fffe0000007fffff0000007fffff0000007ffeff8000007ffe7f8000007f\ | |
1200 fe7fc000007ffe3fe000007ffe1fe000007ffe1ff000007ffe0ff800007f\ | |
1201 fe07f800007ffe07fc00007ffe03fe00007ffe01fe00007ffe01ff00007f\ | |
1202 fe00ff80007ffe007f80007ffe007fc0007ffe003fe0007ffe003fe0007f\ | |
1203 fe001ff0007ffe000ff8007ffe000ff8007ffe0007fc007ffe0003fe007f\ | |
1204 fe0003fe007ffe0001ff007ffe0000ff007ffe0000ff807ffe00007fc07f\ | |
1205 fe00003fc07ffe00003fe07ffe00001ff07ffe00000ff07ffe00000ff87f\ | |
1206 fe000007fc7ffe000003fc7ffe000003fe7ffe000001ff7ffe000001ff7f\ | |
1207 fe000000fffffe0000007ffffe0000007ffffe0000003ffffe0000001fff\ | |
1208 fe0000001ffffe0000000ffffe00000007fffe00000007fffe00000003ff\ | |
1209 fe00000001fffe00000001ff" | |
1210 self.Omatrixwid = 60 | |
1211 self.Omatrixhei = 65 | |
1212 self.Omatrixori = -1 | |
1213 self.Omatrix = "fff00000000000fffff0000000007fffffe00000000fffffff80000003ff\ | |
1214 fffffc000000fffffffff000001fffffffff800003fff000fffc00007ff8\ | |
1215 0001ffe0000ffe000007ff0001ffc000003ff8003ff0000000ffc003fe00\ | |
1216 000007fc007fc00000003fe00ff800000001ff00ff800000001ff01ff000\ | |
1217 000000ff81fe0000000007f83fe0000000007f83fe0000000007fc3fc000\ | |
1218 0000003fc3fc0000000003fc7f80000000001fe7f80000000001fe7f8000\ | |
1219 0000001fe7f80000000001fe7f00000000000feff00000000000ffff0000\ | |
1220 0000000ffff00000000000ffff00000000000ffff00000000000ffff0000\ | |
1221 0000000ffff00000000000ffff00000000000ffff00000000000ffff0000\ | |
1222 0000000ffff00000000000ff7f00000000000fe7f80000000001fe7f8000\ | |
1223 0000001fe7f80000000001fe7f80000000001fe3fc0000000003fc3fc000\ | |
1224 0000003fc3fe0000000007fc1fe0000000007f81ff000000000ff80ff000\ | |
1225 000000ff00ff800000001ff00ffc00000003ff007fc00000003fe003ff00\ | |
1226 00000ffc003ff8000001ff8001ffc000003ff8000fff00000fff00007ffc\ | |
1227 0003ffe00003fff801fffc00001fffffffff800000fffffffff0000003ff\ | |
1228 fffffc0000000fffffff000000003fffffc0000000007fffe00000000000\ | |
1229 3fe000000" | |
1230 self.Pmatrixwid = 44 | |
1231 self.Pmatrixhei = 62 | |
1232 self.Pmatrixori = 0 | |
1233 self.Pmatrix = "fffffffe000ffffffffc00fffffffff00fffffffffc0fffffffffe0fffff\ | |
1234 fffff0ffffffffff8ff000007ff8ff000001ffcff0000007fcff0000003f\ | |
1235 eff0000003feff0000001feff0000001feff0000000ffff0000000ffff00\ | |
1236 00000ffff0000000ffff0000000ffff0000000ffff0000000ffff0000000\ | |
1237 ffff0000001ffff0000001feff0000003feff0000007feff000000ffcff0\ | |
1238 00001ffcff000007ff8ffffffffff8ffffffffff0fffffffffe0ffffffff\ | |
1239 fc0fffffffff00ffffffffc00fffffffe000ff000000000ff000000000ff\ | |
1240 000000000ff000000000ff000000000ff000000000ff000000000ff00000\ | |
1241 0000ff000000000ff000000000ff000000000ff000000000ff000000000f\ | |
1242 f000000000ff000000000ff000000000ff000000000ff000000000ff0000\ | |
1243 00000ff000000000ff000000000ff000000000ff000000000ff000000000\ | |
1244 ff000000000ff000000000" | |
1245 self.Qmatrixwid = 60 | |
1246 self.Qmatrixhei = 68 | |
1247 self.Qmatrixori = -1 | |
1248 self.Qmatrix = "fff00000000000fffff0000000007fffffe00000000fffffff00000003ff\ | |
1249 fffffc000000fffffffff000001fffffffff800003fff000fffc00007ff8\ | |
1250 0001ffe0000ffe000007ff0001ffc000003ff8003ff0000000ffc003fe00\ | |
1251 000007fc007fc00000003fe00ff800000001ff00ff800000001ff01ff000\ | |
1252 000000ff81fe0000000007f83fe0000000007fc3fe0000000007fc3fc000\ | |
1253 0000003fc3fc0000000003fc7f80000000001fe7f80000000001fe7f8000\ | |
1254 0000001fe7f80000000001fe7f00000000000feff00000000000ffff0000\ | |
1255 0000000ffff00000000000ffff00000000000ffff00000000000ffff0000\ | |
1256 0000000ffff00000000000ffff00000000000ffff00000000000ffff0000\ | |
1257 0000000ffff00000000000ff7f00000000000fe7f80000000001fe7f8000\ | |
1258 0000001fe7f80000000001fe7f80000000001fe3fc0000000003fc3fc000\ | |
1259 0000003fc3fe0000000007fc1fe0000006007f81ff000000f00ff80ff000\ | |
1260 001f80ff00ff800001fc1ff00ffc00003ff3ff007fc00001ffbfe003fe00\ | |
1261 000ffffc003ff800007fffc001ffc00001fff8000fff00000fff00007ff8\ | |
1262 0003ffe00003fff801ffff00001ffffffffff80000ffffffffffe00003ff\ | |
1263 ffffffff00000fffffff9ff800003fffffe07fc000007ffff003fe000000\ | |
1264 3fe0001fc0000000000000f8000000000000070000000000000010" | |
1265 self.Rmatrixwid = 50 | |
1266 self.Rmatrixhei = 62 | |
1267 self.Rmatrixori = 0 | |
1268 self.Rmatrix = "ffffffffc0003fffffffff000ffffffffff003fffffffffe00ffffffffff\ | |
1269 e03ffffffffff80fffffffffff03fc000001ffe0ff0000001ff83fc00000\ | |
1270 03ff0ff00000007fc3fc0000000ff0ff00000003fe3fc00000007f8ff000\ | |
1271 00001fe3fc00000007f8ff00000001fe3fc00000007f8ff00000001fe3fc\ | |
1272 00000007f8ff00000001fc3fc00000007f0ff00000003fc3fc0000000ff0\ | |
1273 ff00000007f83fc0000003fc0ff0000001ff03fc000003ff80ffffffffff\ | |
1274 c03fffffffffc00fffffffffe003fffffffff800ffffffffff803fffffff\ | |
1275 fff00ffffffffffe03fc000001ffc0ff0000001ff03fc0000003fe0ff000\ | |
1276 00007f83fc0000000fe0ff00000003fc3fc00000007f0ff00000001fc3fc\ | |
1277 00000007f0ff00000001fc3fc00000007f0ff00000001fc3fc00000007f0\ | |
1278 ff00000001fc3fc00000007f0ff00000001fc3fc00000007f0ff00000001\ | |
1279 fc3fc00000007f0ff00000001fc3fc00000007f8ff00000001fe3fc00000\ | |
1280 007f8ff00000000ff3fc00000003feff00000000ffffc00000003ff" | |
1281 self.Smatrixwid = 49 | |
1282 self.Smatrixhei = 65 | |
1283 self.Smatrixori = -1 | |
1284 self.Smatrix = "7ff800000003ffffc0000007fffff800000fffffff00000fffffffc0001f\ | |
1285 fffffff8001ffffffffe001fff000fff000ffc0000ffc00ffc00003ff007\ | |
1286 fc000007f807fc000001fe03fc000000ff01fe0000003f81fe0000001fc0\ | |
1287 ff0000000ff07f80000003f83fc0000001fc1fe0000000fe0ff000000000\ | |
1288 07fc0000000003fe0000000000ff80000000007fe0000000003ffc000000\ | |
1289 000fff8000000007fff800000001ffffc00000007ffffe0000001ffffff0\ | |
1290 000003ffffff8000007ffffff800000fffffff0000007fffffc0000003ff\ | |
1291 fff80000003ffffe00000001ffff800000000fffc000000001fff0000000\ | |
1292 003ff80000000007fe0000000001ff00000000007fbf800000003fffc000\ | |
1293 00000fffe000000007fff000000003fff800000001fefe00000000ff7f00\ | |
1294 0000007fbfc00000007f9fe00000003fc7f80000003fe3fe0000001fe0ff\ | |
1295 8000001ff07fe000003ff01ffc00007ff007ffe001fff801fffffffff800\ | |
1296 7ffffffff8001ffffffff00003fffffff000007fffffe000000fffff8000\ | |
1297 00003ff80000" | |
1298 self.Tmatrixwid = 48 | |
1299 self.Tmatrixhei = 62 | |
1300 self.Tmatrixori = 0 | |
1301 self.Tmatrix = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1302 ffffffffffffffffffffffff00000ff0000000000ff0000000000ff00000\ | |
1303 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1304 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1305 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1306 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1307 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1308 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1309 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1310 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1311 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1312 00000ff0000000000ff0000000000ff0000000000ff0000000000ff00000\ | |
1313 00000ff0000000000ff00000" | |
1314 self.Umatrixwid = 48 | |
1315 self.Umatrixhei = 64 | |
1316 self.Umatrixori = 0 | |
1317 self.Umatrix = "ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1318 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1319 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1320 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1321 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1322 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1323 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1324 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1325 ff00000000ffff00000000ffff00000000ffff00000000ffff00000000ff\ | |
1326 ff00000000ffff00000000ffff00000000ff7f80000001fe7f80000001fe\ | |
1327 7fc0000003fe7fc0000003fc3fe0000007fc3ff000000ff81ff800003ff8\ | |
1328 0ffe0000fff007ffc007ffe007ffffffffc003ffffffff8000ffffffff00\ | |
1329 007ffffffc00000ffffff0000003ffffc00000001ff80000" | |
1330 self.Vmatrixwid = 52 | |
1331 self.Vmatrixhei = 62 | |
1332 self.Vmatrixori = 0 | |
1333 self.Vmatrix = "ff800000000ff7f800000000fe7fc00000001fe7fc00000001fe3fc00000\ | |
1334 001fc3fe00000003fc1fe00000003fc1fe00000003f81ff00000007f80ff\ | |
1335 00000007f80ff00000007f00ff8000000ff007f8000000ff007f8000000f\ | |
1336 e007fc000001fe003fc000001fe003fc000001fc003fe000003fc001fe00\ | |
1337 0003fc001fe000003f8000ff000007f8000ff000007f8000ff000007f000\ | |
1338 07f80000ff00007f80000ff00007fc0000fe00003fc0001fe00003fc0001\ | |
1339 fe00003fe0001fc00001fe0003fc00001fe0003fc00000ff0003f800000f\ | |
1340 f0007f800000ff0007f8000007f8007f0000007f800ff0000007f800ff00\ | |
1341 00003fc00fe0000003fc01fe0000003fc01fe0000001fe01fc0000001fe0\ | |
1342 3fc0000001fe03fc0000000ff03f80000000ff07f800000007f07f800000\ | |
1343 007f87f000000007f87f000000003fcff000000003fcfe000000003fcfe0\ | |
1344 00000001fffe000000001fffc000000001fffc000000000fff8000000000\ | |
1345 fff80000000007ff80000000007ff00000000007ff00000000003ff00000\ | |
1346 000003fe00000000003fe00000" | |
1347 self.Wmatrixwid = 77 | |
1348 self.Wmatrixhei = 62 | |
1349 self.Wmatrixori = 0 | |
1350 self.Wmatrix = "3fe000000ff8000003ffff0000007fc000001ff7f8000003fe000000ff3f\ | |
1351 e000003ff800000ff9ff000001ffc000007fcff800000ffe000003fe3fc0\ | |
1352 0000fff000001fe1ff000007ffc00001ff0ff800003ffe00000ff87fc000\ | |
1353 01fff000007fc1fe00001fffc00003fc0ff80000fffe00003fe07fc00007\ | |
1354 f7f00001ff01fe00003fbf80000ff80ff00003f9fe00007f807f80001fc7\ | |
1355 f00003fc03fe0000fe3f80003fe00ff0000ff1fe0001fe007f80007f0ff0\ | |
1356 000ff003fc0003f83f80007f801ff0001fc1fc0007fc007f8001fe0ff000\ | |
1357 3fc003fc000fe03f8001fe001fe0007f01fc000ff000ff8003f80ff0007f\ | |
1358 8003fc003f807f8007f8001fe001fc01fc003fc000ff000fe00fe001fe00\ | |
1359 07f800ff007f800ff0001fe007f001fc00ff0000ff003f800fe007f80007\ | |
1360 f801fc007f003fc0003fc01fe003fc01fe0000ff00fe000fe00fe00007f8\ | |
1361 07f0007f00ff00003fc03f8003fc07f80001fe03f8001fe03fc00007f81f\ | |
1362 c0007f01fc00003fc0fe0003f81fe00001fe0ff0001fe0ff00000ff07f00\ | |
1363 007f07f800003f83f80003f83f800001fe1fc0001fe1fc00000ff1fe0000\ | |
1364 ff1fe000007f8fe00003f8ff000001fc7f00001fc7f000000ff3f80000ff\ | |
1365 3f8000007fbf800003fbfc000001fdfc00001fdfe000000fefe00000fffe\ | |
1366 0000007fff000007fff0000003fff000001fff8000000fff800000fffc00\ | |
1367 00007ffc000007ffc0000003ffe000001ffe0000001ffe000000fff00000\ | |
1368 007ff0000007ff80000003ff8000003ff80000001ffc000000ffc0000000\ | |
1369 ffc0000007fe00000003fe0000003ff00000001ff0000001ff0000" | |
1370 self.Xmatrixwid = 53 | |
1371 self.Xmatrixhei = 62 | |
1372 self.Xmatrixori = 0 | |
1373 self.Xmatrix = "1ff80000000ffc7fe00000007fc1ff00000007fc07fc0000007fe03ff000\ | |
1374 0003fe00ff8000003fe003fe000003ff001ff800001ff0007fc00001ff00\ | |
1375 01ff00000ff8000ffc0000ff80003fe0000ff80000ff80007fc00007fe00\ | |
1376 07fc00001ff0007fc000007fc003fc000003ff003fe000000ff803fe0000\ | |
1377 003fe01fe0000001ff81ff00000007fc1ff00000001ff0ff000000007fcf\ | |
1378 f800000003feff800000000ffff8000000003fff8000000001fffc000000\ | |
1379 0007ffc0000000001ffc0000000000ffe00000000003fe00000000003ff8\ | |
1380 0000000003ffe0000000001fff8000000001fffc000000001ffff0000000\ | |
1381 01ff7fc00000000ffbfe00000000ff8ff80000000ff83fe00000007fc1ff\ | |
1382 00000007fc07fc0000007fc01ff0000003fe00ff8000003fe003fe000003\ | |
1383 fe000ff800001ff0007fe00001ff0001ff00001ff00007fc0001ff80003f\ | |
1384 f0000ff80000ff8000ff800003fe000ffc00001ff8007fc000007fc007fc\ | |
1385 000001ff007fe000000ffc03fe0000003fe03fe0000001ff83ff00000007\ | |
1386 fe1ff00000001ff1ff00000000ffdff800000003ff" | |
1387 self.Ymatrixwid = 55 | |
1388 self.Ymatrixhei = 62 | |
1389 self.Ymatrixori = 0 | |
1390 self.Ymatrix = "3ff000000000ffbff000000003fe3fe00000000ffc7fe00000001ff07fe0\ | |
1391 0000007fc07fc0000000ff80ffc0000003fe00ff8000000ffc00ff800000\ | |
1392 1ff001ff8000007fc001ff000000ff8003ff000003fe0003fe000007fc00\ | |
1393 03fe00001ff00007fe00007fc00007fc0000ff800007fc0003fe00000ff8\ | |
1394 0007f800000ff8001ff000000ff8007fc000001ff000ff8000001ff003fe\ | |
1395 0000003fe007f80000003fe01ff00000003fe07fc00000007fc0ff000000\ | |
1396 007fc3fe000000007fc7f800000000ff9ff000000000ffbfc000000000ff\ | |
1397 ff0000000001fffe0000000001fff80000000003fff00000000003ffc000\ | |
1398 00000003ff000000000007fe000000000007f800000000000ff000000000\ | |
1399 001fe000000000003fc000000000007f800000000000ff000000000001fe\ | |
1400 000000000003fc000000000007f800000000000ff000000000001fe00000\ | |
1401 0000003fc000000000007f800000000000ff000000000001fe0000000000\ | |
1402 03fc000000000007f800000000000ff000000000001fe000000000003fc0\ | |
1403 00000000007f800000000000ff000000000001fe000000000003fc000000\ | |
1404 000007f800000" | |
1405 self.Zmatrixwid = 48 | |
1406 self.Zmatrixhei = 62 | |
1407 self.Zmatrixori = 0 | |
1408 self.Zmatrix = "1ffffffffffe1ffffffffffe1ffffffffffe1ffffffffffe1ffffffffffe\ | |
1409 1ffffffffffe1ffffffffffe0000000007fe000000000ffc000000001ff8\ | |
1410 000000001ff8000000003ff0000000007fe000000000ffc000000000ffc0\ | |
1411 00000001ff8000000003ff0000000007fe0000000007fc000000000ffc00\ | |
1412 0000001ff8000000003ff0000000007fe0000000007fe000000000ffc000\ | |
1413 000001ff8000000003ff0000000003ff0000000007fe000000000ffc0000\ | |
1414 00001ff8000000001ff8000000003ff0000000007fe000000000ffc00000\ | |
1415 0000ff8000000001ff8000000003ff0000000007fe000000000ffc000000\ | |
1416 000ffc000000001ff8000000003ff0000000007fe0000000007fe0000000\ | |
1417 00ffc000000001ff8000000003ff0000000003ff0000000007fe00000000\ | |
1418 0ffc000000001ff8000000001ff0000000003ff0000000007fe000000000\ | |
1419 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1420 ffffffffffffffffffffffff" | |
1421 self.onematrixwid = 21 | |
1422 self.onematrixhei = 60 | |
1423 self.onematrixori = 2 | |
1424 self.onematrix = "f80007c0007e0003f0001f8001fc000fe000ff000ff800ffc03ffe1fffff\ | |
1425 fffffffffffffffffffffffff8003fc001fe000ff0007f8003fc001fe000\ | |
1426 ff0007f8003fc001fc000fe0007f0003f8001fc000fe0007f0003f8001fc\ | |
1427 000fe0007f0003f8001fc000fe0007f0003f8001fc000fe0007f0003f800\ | |
1428 1fc000fe0007f0003f8001fc000fe0007f0003f8001fc000fe0007f0003f\ | |
1429 8001fc000fe" | |
1430 self.twomatrixwid = 40 | |
1431 self.twomatrixhei = 60 | |
1432 self.twomatrixori = 2 | |
1433 self.twomatrix = "1ffc000000ffff800003ffffe0000ffffff8001ffffffc003ffffffe007f\ | |
1434 ffffff007ff007ff80ffc000ffc1ff00007fc1fe00003fe1fe00001fe3fc\ | |
1435 00000fe3f800000fe3f800000ff3f8000007f7f8000007f7f0000007f7f0\ | |
1436 000007f7f0000007f7f0000007f00000000ff00000000fe00000001fe000\ | |
1437 00001fe00000003fc00000007fc0000000ff80000003ff00000007ff0000\ | |
1438 001ffe0000007ffc000000fff8000003ffe000000fffc000003fff000000\ | |
1439 7ffe000001fff8000003ffe000000fff8000001ffe0000003ff80000007f\ | |
1440 e00000007fc0000000ff80000001fe00000001fc00000003fc00000003f8\ | |
1441 00000007f000000007f000000007f000000007f00000000fffffffffffff\ | |
1442 fffffffffffffffffffffffffffffffffffffffffffffffffffffffff" | |
1443 self.threematrixwid = 40 | |
1444 self.threematrixhei = 62 | |
1445 self.threematrixori = 2 | |
1446 self.threematrix = "1ff8000001ffff800007ffffe0000ffffff0003ffffff8007ffffffc007f\ | |
1447 fffffe00ffe007ff01ff8001ff01fe0000ff81fc00007f83fc00003f83f8\ | |
1448 00003fc3f800001fc3f800001fc7f000001fc7f000001fc7f000001fc7f0\ | |
1449 00001fc00000001fc00000003f800000003f800000007f80000000ff0000\ | |
1450 0001ff0000001ffe00000ffffc00000ffff000000fffe000000ffff80000\ | |
1451 0ffffc00000fffff00000003ff80000000ffc00000003fc00000001fe000\ | |
1452 00001fe00000000fe00000000ff000000007f000000007f000000007ffe0\ | |
1453 000007ffe0000007ffe0000007ffe0000007f7f0000007f7f000000fe7f0\ | |
1454 00000fe7f800001fe3f800001fe3fc00003fc3fe00007fc1ff8001ff81ff\ | |
1455 e007ff80ffffffff007ffffffe003ffffffc001ffffff00007ffffe00001\ | |
1456 ffff0000001ff0000" | |
1457 self.fourmatrixwid = 41 | |
1458 self.fourmatrixhei = 60 | |
1459 self.fourmatrixori = 2 | |
1460 self.fourmatrix = "1f000000001f800000001fc00000001fe00000000ff00000000ff8000000\ | |
1461 0ffc00000007fe00000007ff00000007ff80000007ffc0000003ffe00000\ | |
1462 03fff0000003fff8000003fdfc000001fcfe000001fc7f000001fe3f8000\ | |
1463 00fe1fc00000fe0fe00000ff07f00000ff03f800007f01fc00007f00fe00\ | |
1464 007f807f00003f803f80003f801fc0003fc00fe0003fc007f0001fc003f8\ | |
1465 001fc001fc001fe000fe000fe0007f000fe0003f800ff0001fc00ff0000f\ | |
1466 e007f00007f007f00003f803f80001fc01ffffffffffffffffffffffffff\ | |
1467 fffffffffffffffffffffffffffffffffffffffffffffc000001fc000000\ | |
1468 00fe000000007f000000003f800000001fc00000000fe000000007f00000\ | |
1469 0003f800000001fc00000000fe000000007f000000003f800000001fc000\ | |
1470 00000fe00" | |
1471 self.fivematrixwid = 40 | |
1472 self.fivematrixhei = 62 | |
1473 self.fivematrixori = 2 | |
1474 self.fivematrix = "3fffffff803fffffff803fffffff803fffffff807fffffff807fffffff80\ | |
1475 7fffffff807f000000007f000000007f000000007e00000000fe00000000\ | |
1476 fe00000000fe00000000fe00000000fe00000000fe00000000fc00000000\ | |
1477 fc00000001fc00000001fc07f80001fc3fff0001fcffffe001fffffff001\ | |
1478 fffffff801fffffffe01fffffffe03ffe00fff03ff8003ff83fe0000ff83\ | |
1479 fc00007fc3f800003fc00000001fe00000001fe00000000fe00000000fe0\ | |
1480 0000000ff000000007f000000007f000000007f000000007f000000007f0\ | |
1481 00000007f000000007f000000007ffe0000007efe000000fe7f000000fe7\ | |
1482 f000001fe7f800001fc3f800003fc3fc00007f83fe0000ff81ff8001ff00\ | |
1483 ffe00ffe00fffffffe007ffffffc003ffffff8000fffffe00007ffffc000\ | |
1484 00fffe0000001ff0000" | |
1485 self.sixmatrixwid = 39 | |
1486 self.sixmatrixhei = 62 | |
1487 self.sixmatrixori = 2 | |
1488 self.sixmatrix = "1ff0000001fffc00000ffffe00007ffffe0001fffffe0007fffffe001fff\ | |
1489 fffe007ff00ffc01ff8007fc03fc0007f80ff00007f81fe00007f07f8000\ | |
1490 0fe0fe00000fe1fc00001fc7f00000000fe00000001fc00000007f800000\ | |
1491 00fe00000001fc00000003f800000007f003f8000fe07ffe003fc3ffff00\ | |
1492 7f8fffff80ff3fffff81feffffff83ffffffff87fff807ff8fffc001ff1f\ | |
1493 fe0001ff3ff80001fe7ff00001feffc00003fdff000003fbfe000007f7fc\ | |
1494 00000ffff000000fffe000001fdfc000003fbf8000007f7f000000fefe00\ | |
1495 0001fdfc000003fbf8000007f3f800001fc7f000003f8ff000007f0fe000\ | |
1496 01fe1fe00007f81fe0000ff03fe0007fc07fe001ff807ff00ffe007fffff\ | |
1497 f8007fffffe0007fffff80007ffffe00007ffff000001fff80000003f800\ | |
1498 0" | |
1499 self.sevenmatrixwid = 40 | |
1500 self.sevenmatrixhei = 60 | |
1501 self.sevenmatrixori = 2 | |
1502 self.sevenmatrix = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1503 ffffffffff00000000fe00000000fe00000001fc00000003f800000003f8\ | |
1504 00000007f00000000fe00000000fc00000001fc00000003f800000003f80\ | |
1505 0000007f00000000fe00000000fe00000001fc00000001fc00000003f800\ | |
1506 000003f000000007f00000000fe00000000fe00000001fc00000001fc000\ | |
1507 00003f800000003f800000007f000000007f00000000ff00000000fe0000\ | |
1508 0001fe00000001fc00000001fc00000003f800000003f800000007f80000\ | |
1509 0007f000000007f00000000ff00000000fe00000000fe00000001fe00000\ | |
1510 001fe00000001fc00000003fc00000003fc00000003f800000003f800000\ | |
1511 007f800000007f800000007f800000007f00000000ff00000000ff000000" | |
1512 self.eightmatrixwid = 40 | |
1513 self.eightmatrixhei = 62 | |
1514 self.eightmatrixori = 2 | |
1515 self.eightmatrix = "ff80000007fff000003ffffe00007fffff0000ffffff8001ffffffc003ff\ | |
1516 ffffe007ff007ff007fc001ff00ff8000ff80ff00007f80fe00003f81fe0\ | |
1517 0003fc1fc00001fc1fc00001fc1fc00001fc1fc00001fc1fc00001fc1fc0\ | |
1518 0001fc1fe00003fc0fe00003f80ff00007f807f8000ff007fe003ff003ff\ | |
1519 80ffe001ffffffc0007fffff00003ffffe00007ffffe0001ffffff8003ff\ | |
1520 ffffc007ff00fff00ff8001ff01ff0000ff83fc00003fc3f800001fc7f80\ | |
1521 0001fe7f000000fe7f000000fefe0000007ffe0000007ffe0000007ffe00\ | |
1522 00007ffe0000007ffe0000007ffe0000007ffe0000007f7f000000fe7f00\ | |
1523 0000fe7f800001fe7f800001fe3fc00003fc3fe0000ffc1ff8001ff80ffe\ | |
1524 00fff007ffffffe007ffffffe001ffffff8000ffffff00003ffffc00000f\ | |
1525 fff0000000ff0000" | |
1526 self.ninematrixwid = 39 | |
1527 self.ninematrixhei = 62 | |
1528 self.ninematrixori = 2 | |
1529 self.ninematrix = "ffc000000ffff000007ffff80001fffff80007fffff8003ffffff8007fff\ | |
1530 fff801ff803ff807fe001ff80ff0000ff03fc0000ff07f00001fe1fe0000\ | |
1531 1fe3f800001fc7f000003f8fe000007f3f8000007f7f000000fefe000001\ | |
1532 fdfc000003fbf8000007f7f000000fefe000001fffc000003fdfc00000ff\ | |
1533 bf800001ff7f800007feff00000ffcff00003ff9ff0000fff1ff0007ffe3\ | |
1534 ff803fffc3ffffffff83fffffeff03fffff9fe03ffffe3fc01ffff07f800\ | |
1535 fffc0fe0003f801fc00000003f800000007f00000000fe00000003fc0000\ | |
1536 0007f00000000fe00000001fc7f000007f8fe00000fe0fe00003fc1fc000\ | |
1537 07f03fc0001fe07fc0007fc07f8001ff00ffc007fc00ffc03ff800ffffff\ | |
1538 e001ffffff8001fffffe0001fffff80000ffffc000007ffe0000001fc000\ | |
1539 0" | |
1540 self.tenmatrixwid = 39 | |
1541 self.tenmatrixhei = 62 | |
1542 self.tenmatrixori = 2 | |
1543 self.tenmatrix = "7fc0000007fff000003ffff80000fffff80003fffff8000ffffff8003fff\ | |
1544 fff800ffe03ff801ff001ff007f8001ff00ff0001fe03fc0001fe07f0000\ | |
1545 1fc1fe00003fc3f800003f87f000007f0fe00000fe3f800000fe7f000001\ | |
1546 fcfe000003f9fc000007f3f800000fe7e000000fdfc000001fff8000003f\ | |
1547 ff0000007ffe000000fffc000001fff8000003fff0000007ffe000000fff\ | |
1548 c000001fff8000003fff0000007ffe000000fffc000001fff8000003fff0\ | |
1549 000007ffe000000fefc000001fdfc000007f3f800000fe7f000001fcfe00\ | |
1550 0003f9fc000007f3f800000fe3f800003f87f000007f0ff00000fe0fe000\ | |
1551 03f81fc00007f03fc0001fc03fc0007f807fc001ff007fc007fc007fe03f\ | |
1552 f0007fffffc000ffffff00007ffffc00007ffff000003fff8000000ff800\ | |
1553 0" | |
1554 self._matrixwid = 51 | |
1555 self._matrixhei = 4 | |
1556 self._matrixori = 73 | |
1557 self._matrix = "fffffffffffffffffffffffffffffffffffffffffffffffffff" | |
1558 self.minusmatrixwid = 20 | |
1559 self.minusmatrixhei = 6 | |
1560 self.minusmatrixori = 36 | |
1561 self.minusmatrix = "ffffffffffffffffffffffffffffff" | |
1562 self.plusmatrixwid = 42 | |
1563 self.plusmatrixhei = 42 | |
1564 self.plusmatrixori = 21 | |
1565 self.plusmatrix = "3f000000000fc000000003f000000000fc000000003f000000000fc00000\ | |
1566 0003f000000000fc000000003f000000000fc000000003f000000000fc00\ | |
1567 0000003f000000000fc000000003f000000000fc000000003f000000000f\ | |
1568 c0000fffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1569 ffffffff00003f000000000fc000000003f000000000fc000000003f0000\ | |
1570 00000fc000000003f000000000fc000000003f000000000fc000000003f0\ | |
1571 00000000fc000000003f000000000fc000000003f000000000fc00000000\ | |
1572 3f000000000fc0000" | |
1573 self.equalmatrixwid = 41 | |
1574 self.equalmatrixhei = 21 | |
1575 self.equalmatrixori = 32 | |
1576 self.equalmatrix = "1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1577 ff8000000000000000000000000000000000000000000000000000000000\ | |
1578 00000000000000000000000000000000003fffffffffffffffffffffffff\ | |
1579 ffffffffffffffffffffffffffffffffffff" | |
1580 self.exclmatrixwid = 7 | |
1581 self.exclmatrixhei = 62 | |
1582 self.exclmatrixori = 0 | |
1583 self.exclmatrix = "3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbe\ | |
1584 7cf9f3e7cf9f3e3870e1c3870000000007fffffffffffffff" | |
1585 self.atmatrixwid = 78 | |
1586 self.atmatrixhei = 75 | |
1587 self.atmatrixori = -1 | |
1588 self.atmatrix = "3ffc000000000000001fffff80000000000003ffffffc000000000003fff\ | |
1589 ffffc00000000007ffffffffc0000000003fffffffffc000000003ffffff\ | |
1590 ffff800000003fffc000ffff80000001fff000007fff0000000fff000000\ | |
1591 3ffe000000fff00000003ffc000007ff000000003ff800003ff000000000\ | |
1592 7ff00001ff80000000007fe0000ffc0000000000ffc0007fc00000000001\ | |
1593 ff8001fe000000000003fe000ff0000000000007fc007fc000000000000f\ | |
1594 f801fe000003f800003fe00ff00000fff800007f807f80000ffff03f80ff\ | |
1595 01fc00007ffff1fc03fc0ff00007ffffc7f007f83f80003ff03fbfc01fe1\ | |
1596 fe0001ff003ffe003f87f0000ff0007ff800fe1fc0007f8000ffe003fcfe\ | |
1597 0001fc0003ff0007f3f8000fe00007fc001fcfc0007f80001ff0007f7f00\ | |
1598 01fc00007fc001fdfc000fe00001fe0007f7f0003f800007f8001fdf8001\ | |
1599 fe00001fe0007f7e0007f000007f0001fff8001fc00003fc0007ffe0007f\ | |
1600 00000ff0001fbf8003f800003f8000fefe000fe00000fe0003fbf8003f80\ | |
1601 0007f8000fefe000fe00001fc0007f3f8003f800007f0001fcfe000fe000\ | |
1602 03fc000ff3f8003f80000fe0003f8fe000fe00007f8001fe1fc003fc0001\ | |
1603 fe0007f07f0007f0000ff0003fc1fc001fe0007fc001fe07f8007f8003ff\ | |
1604 000ff00fe000ff001ffe007fc03fc003fe00fff807fe00ff0007fe0feff8\ | |
1605 7ff001fe000fffff3fffff8007f8001ffff8fffffc000ff0003fffc1ffff\ | |
1606 c0003fe0007ffc03fffc00007fc0003f8003ff800001ff80000000000000\ | |
1607 0003ff000000000000000007fe00000000000000000ffc00000000000000\ | |
1608 001ffc00000000000000003ff800000000000000007ff800000000000000\ | |
1609 00fff80000000000000001fffc000003c000000001ffff0001ff80000000\ | |
1610 03fffffffffe0000000003fffffffff80000000003fffffffff000000000\ | |
1611 03ffffffff800000000001fffffff0000000000000fffffc000000000000\ | |
1612 001ffc00000000" | |
1613 self.hashmatrixwid = 45 | |
1614 self.hashmatrixhei = 60 | |
1615 self.hashmatrixori = 3 | |
1616 self.hashmatrix = "7e003f000007f003f800003f801fc00001f800fe00000fc007e000007e00\ | |
1617 3f000007f003f800003f801fc00001fc00fe00000fc007e000007e003f00\ | |
1618 0003f001f800003f801fc00001fc00fe00000fc007e000007e003f001fff\ | |
1619 fffffff8ffffffffffc7fffffffffe3ffffffffff1ffffffffff8fffffff\ | |
1620 fffc003f801fc00001fc00fe00000fe007f000007e003f000003f001f800\ | |
1621 001f800fc00001fc00fe00000fe007f000007f003f800003f001f800001f\ | |
1622 800fc00000fc007e00000fe007f000007f003f800003f001fc007fffffff\ | |
1623 ffe3ffffffffff1ffffffffff8ffffffffffc7fffffffffe3ffffffffff0\ | |
1624 00fc007e00000fe003f000007f003f800003f801fc00001f800fe00000fc\ | |
1625 007e000007e003f000007f003f800003f801fc00001f800fe00000fc007e\ | |
1626 000007e003f000007f003f800003f801fc00001f800fe00000fc007e0000\ | |
1627 07e003f0000" | |
1628 self.dollarmatrixwid = 41 | |
1629 self.dollarmatrixhei = 77 | |
1630 self.dollarmatrixori = -4 | |
1631 self.dollarmatrix = "7c000000003e000000001f000000000f8000000007c00000000ffc000000\ | |
1632 7fffc00000fffff80001ffffff0003ffffffc003fffffff003ffcf8ffc01\ | |
1633 ff07c1fe01fe03e07f80fe01f01fc0fe00f80ff07f007c03f83f003e01fc\ | |
1634 3f801f007f1fc00f803f8fe007c01fc7f003e00fe3f801f00001fc00f800\ | |
1635 00fe007c00007f803e00001fc01f00000ff00f800007fc07c00001ff83e0\ | |
1636 00007ff1f000003ffff800000ffffe000003fffff00000ffffff00001fff\ | |
1637 ffe00003fffff800003fffff000003ffffc00000fffff000007c7ff80000\ | |
1638 3e0ffe00001f01ff00000f807fc00007c01fe00003e007f00001f001f800\ | |
1639 00f800fffc007c007ffe003e003fff001f001fff800f800fffc007c007ff\ | |
1640 f003e003f3f801f001f9fc00f801fcff007c00fe3f803e00fe1fe01f00ff\ | |
1641 0ff80f80ff03ff07c1ff80ffe3e3ff803fffffff800fffffff8003ffffff\ | |
1642 80007fffff00000ffffe0000007ff000000007c000000003e000000001f0\ | |
1643 00000000f8000000007c000000003e000000001f000000000f8000000007\ | |
1644 c0000" | |
1645 self.percentmatrixwid = 71 | |
1646 self.percentmatrixhei = 61 | |
1647 self.percentmatrixori = 2 | |
1648 self.percentmatrix = "1f00000000000000007e0000003fc0000001f8000003fff0000003e00000\ | |
1649 0ffff800000fc000007ffff800001f000001fffff800007e000007fffff8\ | |
1650 0000f800000ff81ff80003f000003fc00ff00007c00000ff000ff0001f80\ | |
1651 0001fc000fe0003e000003f0000fc000fc00000fe0001fc003f000001f80\ | |
1652 001f8007e000003f00003f001f8000007e00007e003e000000fc0000fc00\ | |
1653 fc000001f80001f801f0000003f80007f007e0000003f0000fc00f800000\ | |
1654 07f0003f803f0000000ff000ff00fc0000000ff003fc01f80000000ff81f\ | |
1655 f007e00000001fffffe00fc00000001fffff803f000000001ffffe007c00\ | |
1656 0000000ffff001f80000000007ff8003e00000000001fc000fc000000000\ | |
1657 0000001f00000000000000007e0000000000000001f80007f00000000003\ | |
1658 f0007ffc000000000fc003fffe000000001f800ffffe000000007e003fff\ | |
1659 fe00000000f800fffffe00000003f003fe03fe00000007c007f803fc0000\ | |
1660 001f801fc001fc0000007e003f8003f8000000fc007e0003f0000003f001\ | |
1661 f80003f0000007e003f00007e000001f8007e0000fc000003f000fc0001f\ | |
1662 800000fc001f80003f000001f0003f00007e000007e0003f0001f800000f\ | |
1663 80007f0007f000003f0000fe000fe00000fc0000ff007f800001f80001ff\ | |
1664 01ff000007e00001fffffc00000fc00001fffff000003f000001ffffc000\ | |
1665 007e000001ffff000001f8000000fff8000007f00000003f800" | |
1666 self.hatmatrixwid = 32 | |
1667 self.hatmatrixhei = 32 | |
1668 self.hatmatrixori = 2 | |
1669 self.hatmatrix = "7e000000ff000000ff000001ff000001ff800001ff800003ffc00003ffc0\ | |
1670 0007e7c00007e7e00007c7e0000fc3f0000fc3f0001f81f0001f81f8001f\ | |
1671 01f8003f00fc003f00fc007e007c007e007e007c007e00fc003f00fc003f\ | |
1672 01f8001f81f8001f81f0001f83f0000fc3f0000fc7e00007e7e00007efc0\ | |
1673 0003efc00003f" | |
1674 self.ampmatrixwid = 50 | |
1675 self.ampmatrixhei = 62 | |
1676 self.ampmatrixori = 2 | |
1677 self.ampmatrix = "3fc0000000007ffe000000007fffc00000003ffffc0000001fffff800000\ | |
1678 0fffffe0000007fc07fc000001fe00ff800000fe001fe000003f8003f800\ | |
1679 001fc0007f000007f0001fc00001fc0007f000007f0001fc00001fc0007f\ | |
1680 000007f0001fc00000fe000fe000003f8003f800000ff001fe000001fe00\ | |
1681 ff0000007f80ffc000000ff07fe0000001fe3ff00000007ffff80000000f\ | |
1682 fff800000001fffc000000007ffc000000001ffe000000001fff00000000\ | |
1683 0fffe00000000ffffc00000007feff80000003ff1ff003f801ff07fe00fe\ | |
1684 00ff80ff803f807fc01ff00fe03fe003fe07f00ff0007fc1fc07f8000ff8\ | |
1685 7f01fc0003ff3fc07f00007fcfe03f80000ffff80fe00001fffc03f80000\ | |
1686 3fff00fe000007ff803f800001ffe00fe000003ff003f8000007fc00ff00\ | |
1687 0001ff801fc00000fff007f800007ffe01ff00003fffc03fe0001ffff00f\ | |
1688 fc001ffbfe01ffe03ffc7fc07ffffffe0ff80fffffff03ff01ffffff807f\ | |
1689 c03fffff800ff803ffffc001ff003fff8000000000ff0000000" | |
1690 self.strixmatrixwid = 25 | |
1691 self.strixmatrixhei = 24 | |
1692 self.strixmatrixori = 0 | |
1693 self.strixmatrix = "3e00001f00000f800007c00003e00001f00100f804e07c0efe3e3fffffff\ | |
1694 fffffffffffff0ffff8007fc0003fe0003ff8001ffc001fbf001f8fc01f8\ | |
1695 3f01fc1fc0fc07e01c01c00600c0" | |
1696 self.opencparmatrixwid = 18 | |
1697 self.opencparmatrixhei = 80 | |
1698 self.opencparmatrixori = 0 | |
1699 self.opencparmatrix = "3c001f000f8007e001f000f8003e001f000fc003f001f8007e001f000fc0\ | |
1700 03e001f8007e003f800fc003f001fc007e001f8007e003f800fc003f000f\ | |
1701 c007f001fc007f001f8007e001f800fe003f800fe003f800fe003f800fe0\ | |
1702 03f800fe003f800fe003f8007e001f8007e001fc007f001fc003f000fc00\ | |
1703 3f000fe003f8007e001f8007f000fc003f000fc001f8007e000f8003f000\ | |
1704 fc001f8007e000f8003f0007c000f8003e0007c001f0003e0007c001f" | |
1705 self.closecparmatrixwid = 18 | |
1706 self.closecparmatrixhei = 80 | |
1707 self.closecparmatrixori = 0 | |
1708 self.closecparmatrix = "f0003e0007c001f8003e0007c001f0007e000fc003f0007e001f8003e000\ | |
1709 fc003f0007e001f8007f000fc003f000fe001f8007e001f8007f000fc003\ | |
1710 f000fc003f800fe003f8007e001f8007e001fc007f001fc007f001fc007f\ | |
1711 001fc007f001fc007f001fc007f001f8007e001f800fe003f800fe003f00\ | |
1712 0fc003f001fc007f001f8007e003f800fc003f000fc007e001f8007c003f\ | |
1713 000fc007e001f8007c003f000f8007c001f000f8003e001f000f8003e000" | |
1714 self.opensparmatrixwid = 16 | |
1715 self.opensparmatrixhei = 80 | |
1716 self.opensparmatrixori = 0 | |
1717 self.opensparmatrix = "fffffffffffffffffffffffffe00fe00fe00fe00fe00fe00fe00fe00fe00\ | |
1718 fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00\ | |
1719 fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00\ | |
1720 fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00\ | |
1721 fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00fe00ffff\ | |
1722 ffffffffffffffffffff" | |
1723 self.closesparmatrixwid = 16 | |
1724 self.closesparmatrixhei = 80 | |
1725 self.closesparmatrixori = 0 | |
1726 self.closesparmatrix = "ffffffffffffffffffffffff007f007f007f007f007f007f007f007f007f\ | |
1727 007f007f007f007f007f007f007f007f007f007f007f007f007f007f007f\ | |
1728 007f007f007f007f007f007f007f007f007f007f007f007f007f007f007f\ | |
1729 007f007f007f007f007f007f007f007f007f007f007f007f007f007f007f\ | |
1730 007f007f007f007f007f007f007f007f007f007f007f007f007f007fffff\ | |
1731 ffffffffffffffffffff" | |
1732 self.backslashmatrixwid = 25 | |
1733 self.backslashmatrixhei = 63 | |
1734 self.backslashmatrixori = 0 | |
1735 self.backslashmatrix = "7c00001e00000f800007c00001e00000f800007c00003e00000f000007c0\ | |
1736 0003e00000f000007c00003e00000f000007c00003e00000f000007c0000\ | |
1737 3e00000f000007c00003e00000f000007c00003e00000f000007c00003e0\ | |
1738 0000f000007c00003e00001f000007800003e00001f000007800003e0000\ | |
1739 1f000007800003e00001f000007800003e00001f000007800003e00001f0\ | |
1740 00007800003e00001f000007800003e00001f000007800003e00001f0000\ | |
1741 0f800003c00001f00000f800003c00001f" | |
1742 self.semicolmatrixwid = 9 | |
1743 self.semicolmatrixhei = 57 | |
1744 self.semicolmatrixori = 17 | |
1745 self.semicolmatrix = "1ffffffffffffffffffff000000000000000000000000000000000000000\ | |
1746 0000000000000000000001ffffffffffffffffffff0783c1e0f078383c1e\ | |
1747 1e7e3e1c0" | |
1748 self.postmatrixwid = 8 | |
1749 self.postmatrixhei = 21 | |
1750 self.postmatrixori = 2 | |
1751 self.postmatrix = "ffffffffffffffffffffffff7e7e7e7e7e3c3c3c3c" | |
1752 self.commamatrixwid = 9 | |
1753 self.commamatrixhei = 21 | |
1754 self.commamatrixori = 53 | |
1755 self.commamatrix = "1ffffffffffffffffffff0783c1e0f078383c1e1e7e3e1c0" | |
1756 self.fullstopmatrixwid = 9 | |
1757 self.fullstopmatrixhei = 9 | |
1758 self.fullstopmatrixori = 53 | |
1759 self.fullstopmatrix = "1ffffffffffffffffffff" | |
1760 self.forslashmatrixwid = 25 | |
1761 self.forslashmatrixhei = 63 | |
1762 self.forslashmatrixori = 0 | |
1763 self.forslashmatrix = "7c00003c00003e00001f00000f00000f800007c00003e00001e00001f000\ | |
1764 00f800007800007c00003e00001e00001f00000f800007800007c00003e0\ | |
1765 0001e00001f00000f800007800007c00003e00001e00001f00000f800007\ | |
1766 800007c00003e00001f00000f00000f800007c00003c00003e00001f0000\ | |
1767 0f00000f800007c00003c00003e00001f00000f00000f800007c00003c00\ | |
1768 003e00001f00000f00000f800007c00003c00003e00001f00000f8000078\ | |
1769 00007c00003e00001e00001f00000" | |
1770 self.lesthanmatrixwid = 41 | |
1771 self.lesthanmatrixhei = 41 | |
1772 self.lesthanmatrixori = 22 | |
1773 self.lesthanmatrix = "10000000003800000000fc00000001fe00000007ff0000000fff8000001f\ | |
1774 ffc000007fff800000ffff000001fffc000007fff800000fffe000001fff\ | |
1775 c000007fff000000fffe000003fffc000007fff000000fffe0000007ff80\ | |
1776 000003ff00000001fe00000000ffe00000007ffc0000003fffc0000003ff\ | |
1777 f80000007fff0000000ffff0000000fffe0000001fffe0000003fffc0000\ | |
1778 003fff80000007fff8000000ffff0000000ffff0000001fffc0000001ffe\ | |
1779 00000003ff000000007f8000000007c000000000e0000000001" | |
1780 self.greatthanmatrixwid = 42 | |
1781 self.greatthanmatrixhei = 41 | |
1782 self.greatthanmatrixori = 22 | |
1783 self.greatthanmatrix = "30000000000f0000000003f000000000ff800000003ff80000000fffc000\ | |
1784 0003fffc0000003fffc0000001fffe0000001fffe0000000fffe0000000f\ | |
1785 fff0000000ffff00000007fff00000007fff80000003fff80000003fffc0\ | |
1786 000003fffc0000001fff00000001ffc00000000ff00000001ffc0000001f\ | |
1787 ff0000003fff8000003fff8000003fff8000007fff0000007fff000000ff\ | |
1788 ff000000fffe000001fffe000001fffe000003fffc000003fffc000003ff\ | |
1789 f8000000fff80000003ff80000000ff000000003f000000000f000000000\ | |
1790 20000000000" | |
1791 self.questionmatrixwid = 36 | |
1792 self.questionmatrixhei = 63 | |
1793 self.questionmatrixori = -1 | |
1794 self.questionmatrix = "7fe000003fffe0000fffff8003fffffc007fffffe00fffffff00fffffff8\ | |
1795 1ff801ffc3fe0007fc3fc0003fe3f80001fe7f80000fe7f00000ff7f0000\ | |
1796 07f7e000007ffe000007ffe000007ffe000007ffe000007ffe000007f000\ | |
1797 0000fe0000000fe0000001fe0000003fc0000003fc0000007f8000000ff0\ | |
1798 000001ff0000003fe0000007fc000000ff8000001ff0000003fc0000007f\ | |
1799 8000000ff0000000ff0000001fe0000001fc0000003fc0000003f8000000\ | |
1800 3f80000003f80000003f80000003f80000003f80000003f8000000000000\ | |
1801 000000000000000000000000000000000000000000000000000000000000\ | |
1802 0000003f80000003f80000003f80000003f80000003f80000003f8000000\ | |
1803 3f80000003f80000003f8000" | |
1804 self.colonmatrixwid = 9 | |
1805 self.colonmatrixhei = 45 | |
1806 self.colonmatrixori = 17 | |
1807 self.colonmatrix = "1ffffffffffffffffffff000000000000000000000000000000000000000\ | |
1808 0000000000000000000001ffffffffffffffffffff" | |
1809 self.quotematrixwid = 22 | |
1810 self.quotematrixhei = 21 | |
1811 self.quotematrixori = 2 | |
1812 self.quotematrix = "3fc0ffff03fffc0ffff03fffc0ffff03fffc0ffff03fffc0ffff03fffc0f\ | |
1813 ffffffdf807e7e01f9f807e7e01f9f807e3c00f0f003c3c00f0f003c" | |
1814 self.opensquigmatrixwid = 19 | |
1815 self.opensquigmatrixhei = 80 | |
1816 self.opensquigmatrixori = 0 | |
1817 self.opensquigmatrix = "7e007fc01ff807ff00ffe03ffc07f800fe003f8007f000fe001fc003f800\ | |
1818 7f000fe001fc003f8007f000fe001fc003f8007f000fe001fc003f8007f0\ | |
1819 00fe001fc003f8007f000fe001fc007f000fe003fc00ff007fc01ff803fc\ | |
1820 007f000fe001fe003fe001fe001fe001fc001fc003f8003f0007e000fe00\ | |
1821 1fc003f8007f000fe001fc003f8007f000fe001fc003f8007f000fe001fc\ | |
1822 003f8007f000fe001fc003f8007f000fe001fc001fc003fc007ff807ff00\ | |
1823 ffe00ffc00ff8003f" | |
1824 self.closesquigmatrixwid = 20 | |
1825 self.closesquigmatrixhei = 80 | |
1826 self.closesquigmatrixori = 0 | |
1827 self.closesquigmatrix = "fe000ffc00ffe00fff00fff00fff8007f8003f8001fc001fc001fc001fc0\ | |
1828 01fc001fc001fc001fc001fc001fc001fc001fc001fc001fc001fc001fc0\ | |
1829 01fc001fc001fc001fc001fc001fc001fc000fc000fe000fe0007f0007f8\ | |
1830 003fe001ff000ff0007f0007f000ff001ff003fe007f8007f000fe000fe0\ | |
1831 00fc001fc001fc001fc001fc001fc001fc001fc001fc001fc001fc001fc0\ | |
1832 01fc001fc001fc001fc001fc001fc001fc001fc001fc001fc001fc001fc0\ | |
1833 03f8007f80fff80fff00fff00ffe00ff800fe000" | |
1834 self.barmatrixwid = 5 | |
1835 self.barmatrixhei = 80 | |
1836 self.barmatrixori = 0 | |
1837 self.barmatrix = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1838 ffffffffffffffffffffffffffffffffffffffff" | |
1839 self.miscmatrixwid = 46 | |
1840 self.miscmatrixhei = 80 | |
1841 self.miscmatrixori = 0 | |
1842 self.miscmatrix = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1843 ffffffffff8000000007fe000000001ff8000000007fe000000001ff8000\ | |
1844 000007fe000000001ff8000000007fe000000001ff8000000007fe000000\ | |
1845 001ff8000000007fe000000001ff8000000007fe000000001ff800000000\ | |
1846 7fe000000001ff8000000007fe000000001ff8000000007fe000000001ff\ | |
1847 8000000007fe000000001ff8000000007fe000000001ff8000000007fe00\ | |
1848 0000001ff8000000007fe000000001ff8000000007fe000000001ff80000\ | |
1849 00007fe000000001ff8000000007fe000000001ff8000000007fe0000000\ | |
1850 01ff8000000007fe000000001ff8000000007fe000000001ff8000000007\ | |
1851 fe000000001ff8000000007fe000000001ff8000000007fe000000001ff8\ | |
1852 000000007fe000000001ff8000000007fe000000001ff8000000007fe000\ | |
1853 000001ff8000000007fe000000001ff8000000007fe000000001ff800000\ | |
1854 0007fe000000001ff8000000007fe000000001ff8000000007fe00000000\ | |
1855 1ff8000000007fe000000001ff8000000007fe000000001ff8000000007f\ | |
1856 e000000001ffffffffffffffffffffffffffffffffffffffffffffffffff\ | |
1857 ffffffffffffffffffff" | |
1858 | |
1859 def writea(self, x, y, size, ital, bold, sans, rotate): | |
1860 xpos = x | |
1861 sizeratio = size * 1.0 / self.defsize | |
1862 sizeint = (size - 1) / self.defsize + 1 | |
1863 if bold: | |
1864 sizeint = sizeint + 2 + int(sizeratio) | |
1865 charstring = binar(self.amatrix) | |
1866 charstring = ( | |
1867 self.amatrixwid * self.amatrixhei - len(charstring) | |
1868 ) * "0" + charstring | |
1869 if len(charstring) > self.amatrixwid * self.amatrixhei: | |
1870 charstring = charstring[0 - self.amatrixwid * self.amatrixhei :] | |
1871 for i in range(0, len(charstring), self.amatrixwid): | |
1872 for j in range(i, i + self.amatrixwid): | |
1873 if charstring[j] == "1": | |
1874 for k in range(sizeint): | |
1875 for l in range(sizeint): | |
1876 if ital and rotate == -1: | |
1877 x = ( | |
1878 xpos | |
1879 + ( | |
1880 int( | |
1881 ( | |
1882 ( | |
1883 self.amatrixori | |
1884 - self.amatrixwid | |
1885 + j / self.amatrixwid | |
1886 ) | |
1887 ) | |
1888 * sizeratio | |
1889 ) | |
1890 - l | |
1891 ) | |
1892 / 3 | |
1893 ) | |
1894 elif ital: | |
1895 x = ( | |
1896 xpos | |
1897 + ( | |
1898 int( | |
1899 ( | |
1900 self.defsize | |
1901 - ( | |
1902 self.amatrixori | |
1903 + j / self.amatrixwid | |
1904 ) | |
1905 ) | |
1906 * sizeratio | |
1907 ) | |
1908 - l | |
1909 ) | |
1910 / 3 | |
1911 ) | |
1912 if rotate == 1: | |
1913 self.plotPoint( | |
1914 y | |
1915 + int( | |
1916 (self.amatrixori + j / self.amatrixwid) | |
1917 * sizeratio | |
1918 ) | |
1919 - l | |
1920 - self.defsize, | |
1921 x + int((j % self.amatrixwid) * sizeratio) - k, | |
1922 ) | |
1923 elif rotate == -1: | |
1924 self.plotPoint( | |
1925 y | |
1926 + int( | |
1927 ( | |
1928 self.defsize | |
1929 - (self.amatrixori + j / self.amatrixwid) | |
1930 ) | |
1931 * sizeratio | |
1932 ) | |
1933 - l, | |
1934 2 * x | |
1935 - (x + int((j % self.amatrixwid) * sizeratio) - k), | |
1936 ) | |
1937 else: | |
1938 self.plotPoint( | |
1939 x + int((j % self.amatrixwid) * sizeratio) - k, | |
1940 y | |
1941 + int( | |
1942 ( | |
1943 self.defsize | |
1944 - (self.amatrixori + j / self.amatrixwid) | |
1945 ) | |
1946 * sizeratio | |
1947 ) | |
1948 - l, | |
1949 ) | |
1950 | |
1951 def writeb(self, x, y, size, ital, bold, sans, rotate): | |
1952 xpos = x | |
1953 sizeratio = size * 1.0 / self.defsize | |
1954 sizeint = (size - 1) / self.defsize + 1 | |
1955 if bold: | |
1956 sizeint = sizeint + 2 + int(sizeratio) | |
1957 charstring = binar(self.bmatrix) | |
1958 charstring = ( | |
1959 self.bmatrixwid * self.bmatrixhei - len(charstring) | |
1960 ) * "0" + charstring | |
1961 if len(charstring) > self.bmatrixwid * self.bmatrixhei: | |
1962 charstring = charstring[0 - self.bmatrixwid * self.bmatrixhei :] | |
1963 for i in range(0, len(charstring), self.bmatrixwid): | |
1964 for j in range(i, i + self.bmatrixwid): | |
1965 if charstring[j] == "1": | |
1966 for k in range(sizeint): | |
1967 for l in range(sizeint): | |
1968 if ital and rotate == -1: | |
1969 x = ( | |
1970 xpos | |
1971 + ( | |
1972 int( | |
1973 ( | |
1974 ( | |
1975 self.bmatrixori | |
1976 - self.bmatrixwid | |
1977 + j / self.bmatrixwid | |
1978 ) | |
1979 ) | |
1980 * sizeratio | |
1981 ) | |
1982 - l | |
1983 ) | |
1984 / 3 | |
1985 ) | |
1986 elif ital: | |
1987 x = ( | |
1988 xpos | |
1989 + ( | |
1990 int( | |
1991 ( | |
1992 self.defsize | |
1993 - ( | |
1994 self.bmatrixori | |
1995 + j / self.bmatrixwid | |
1996 ) | |
1997 ) | |
1998 * sizeratio | |
1999 ) | |
2000 - l | |
2001 ) | |
2002 / 3 | |
2003 ) | |
2004 if rotate == 1: | |
2005 self.plotPoint( | |
2006 y | |
2007 + int( | |
2008 (self.bmatrixori + j / self.bmatrixwid) | |
2009 * sizeratio | |
2010 ) | |
2011 - l | |
2012 - self.defsize, | |
2013 x + int((j % self.bmatrixwid) * sizeratio) - k, | |
2014 ) | |
2015 elif rotate == -1: | |
2016 self.plotPoint( | |
2017 y | |
2018 + int( | |
2019 ( | |
2020 self.defsize | |
2021 - (self.bmatrixori + j / self.bmatrixwid) | |
2022 ) | |
2023 * sizeratio | |
2024 ) | |
2025 - l, | |
2026 2 * x | |
2027 - (x + int((j % self.bmatrixwid) * sizeratio) - k), | |
2028 ) | |
2029 else: | |
2030 self.plotPoint( | |
2031 x + int((j % self.bmatrixwid) * sizeratio) - k, | |
2032 y | |
2033 + int( | |
2034 ( | |
2035 self.defsize | |
2036 - (self.bmatrixori + j / self.bmatrixwid) | |
2037 ) | |
2038 * sizeratio | |
2039 ) | |
2040 - l, | |
2041 ) | |
2042 | |
2043 def writec(self, x, y, size, ital, bold, sans, rotate): | |
2044 xpos = x | |
2045 sizeratio = size * 1.0 / self.defsize | |
2046 sizeint = (size - 1) / self.defsize + 1 | |
2047 if bold: | |
2048 sizeint = sizeint + 2 + int(sizeratio) | |
2049 charstring = binar(self.cmatrix) | |
2050 charstring = ( | |
2051 self.cmatrixwid * self.cmatrixhei - len(charstring) | |
2052 ) * "0" + charstring | |
2053 if len(charstring) > self.cmatrixwid * self.cmatrixhei: | |
2054 charstring = charstring[0 - self.cmatrixwid * self.cmatrixhei :] | |
2055 for i in range(0, len(charstring), self.cmatrixwid): | |
2056 for j in range(i, i + self.cmatrixwid): | |
2057 if charstring[j] == "1": | |
2058 for k in range(sizeint): | |
2059 for l in range(sizeint): | |
2060 if ital and rotate == -1: | |
2061 x = ( | |
2062 xpos | |
2063 + ( | |
2064 int( | |
2065 ( | |
2066 ( | |
2067 self.cmatrixori | |
2068 - self.cmatrixwid | |
2069 + j / self.cmatrixwid | |
2070 ) | |
2071 ) | |
2072 * sizeratio | |
2073 ) | |
2074 - l | |
2075 ) | |
2076 / 3 | |
2077 ) | |
2078 elif ital: | |
2079 x = ( | |
2080 xpos | |
2081 + ( | |
2082 int( | |
2083 ( | |
2084 self.defsize | |
2085 - ( | |
2086 self.cmatrixori | |
2087 + j / self.cmatrixwid | |
2088 ) | |
2089 ) | |
2090 * sizeratio | |
2091 ) | |
2092 - l | |
2093 ) | |
2094 / 3 | |
2095 ) | |
2096 if rotate == 1: | |
2097 self.plotPoint( | |
2098 y | |
2099 + int( | |
2100 (self.cmatrixori + j / self.cmatrixwid) | |
2101 * sizeratio | |
2102 ) | |
2103 - l | |
2104 - self.defsize, | |
2105 x + int((j % self.cmatrixwid) * sizeratio) - k, | |
2106 ) | |
2107 elif rotate == -1: | |
2108 self.plotPoint( | |
2109 y | |
2110 + int( | |
2111 ( | |
2112 self.defsize | |
2113 - (self.cmatrixori + j / self.cmatrixwid) | |
2114 ) | |
2115 * sizeratio | |
2116 ) | |
2117 - l, | |
2118 2 * x | |
2119 - (x + int((j % self.cmatrixwid) * sizeratio) - k), | |
2120 ) | |
2121 else: | |
2122 self.plotPoint( | |
2123 x + int((j % self.cmatrixwid) * sizeratio) - k, | |
2124 y | |
2125 + int( | |
2126 ( | |
2127 self.defsize | |
2128 - (self.cmatrixori + j / self.cmatrixwid) | |
2129 ) | |
2130 * sizeratio | |
2131 ) | |
2132 - l, | |
2133 ) | |
2134 | |
2135 def writed(self, x, y, size, ital, bold, sans, rotate): | |
2136 xpos = x | |
2137 sizeratio = size * 1.0 / self.defsize | |
2138 sizeint = (size - 1) / self.defsize + 1 | |
2139 if bold: | |
2140 sizeint = sizeint + 2 + int(sizeratio) | |
2141 charstring = binar(self.dmatrix) | |
2142 charstring = ( | |
2143 self.dmatrixwid * self.dmatrixhei - len(charstring) | |
2144 ) * "0" + charstring | |
2145 if len(charstring) > self.dmatrixwid * self.dmatrixhei: | |
2146 charstring = charstring[0 - self.dmatrixwid * self.dmatrixhei :] | |
2147 for i in range(0, len(charstring), self.dmatrixwid): | |
2148 for j in range(i, i + self.dmatrixwid): | |
2149 if charstring[j] == "1": | |
2150 for k in range(sizeint): | |
2151 for l in range(sizeint): | |
2152 if ital and rotate == -1: | |
2153 x = ( | |
2154 xpos | |
2155 + ( | |
2156 int( | |
2157 ( | |
2158 ( | |
2159 self.dmatrixori | |
2160 - self.dmatrixwid | |
2161 + j / self.dmatrixwid | |
2162 ) | |
2163 ) | |
2164 * sizeratio | |
2165 ) | |
2166 - l | |
2167 ) | |
2168 / 3 | |
2169 ) | |
2170 elif ital: | |
2171 x = ( | |
2172 xpos | |
2173 + ( | |
2174 int( | |
2175 ( | |
2176 self.defsize | |
2177 - ( | |
2178 self.dmatrixori | |
2179 + j / self.dmatrixwid | |
2180 ) | |
2181 ) | |
2182 * sizeratio | |
2183 ) | |
2184 - l | |
2185 ) | |
2186 / 3 | |
2187 ) | |
2188 if rotate == 1: | |
2189 self.plotPoint( | |
2190 y | |
2191 + int( | |
2192 (self.dmatrixori + j / self.dmatrixwid) | |
2193 * sizeratio | |
2194 ) | |
2195 - l | |
2196 - self.defsize, | |
2197 x + int((j % self.dmatrixwid) * sizeratio) - k, | |
2198 ) | |
2199 elif rotate == -1: | |
2200 self.plotPoint( | |
2201 y | |
2202 + int( | |
2203 ( | |
2204 self.defsize | |
2205 - (self.dmatrixori + j / self.dmatrixwid) | |
2206 ) | |
2207 * sizeratio | |
2208 ) | |
2209 - l, | |
2210 2 * x | |
2211 - (x + int((j % self.dmatrixwid) * sizeratio) - k), | |
2212 ) | |
2213 else: | |
2214 self.plotPoint( | |
2215 x + int((j % self.dmatrixwid) * sizeratio) - k, | |
2216 y | |
2217 + int( | |
2218 ( | |
2219 self.defsize | |
2220 - (self.dmatrixori + j / self.dmatrixwid) | |
2221 ) | |
2222 * sizeratio | |
2223 ) | |
2224 - l, | |
2225 ) | |
2226 | |
2227 def writee(self, x, y, size, ital, bold, sans, rotate): | |
2228 xpos = x | |
2229 sizeratio = size * 1.0 / self.defsize | |
2230 sizeint = (size - 1) / self.defsize + 1 | |
2231 if bold: | |
2232 sizeint = sizeint + 2 + int(sizeratio) | |
2233 charstring = binar(self.ematrix) | |
2234 charstring = ( | |
2235 self.ematrixwid * self.ematrixhei - len(charstring) | |
2236 ) * "0" + charstring | |
2237 if len(charstring) > self.ematrixwid * self.ematrixhei: | |
2238 charstring = charstring[0 - self.ematrixwid * self.ematrixhei :] | |
2239 for i in range(0, len(charstring), self.ematrixwid): | |
2240 for j in range(i, i + self.ematrixwid): | |
2241 if charstring[j] == "1": | |
2242 for k in range(sizeint): | |
2243 for l in range(sizeint): | |
2244 if ital and rotate == -1: | |
2245 x = ( | |
2246 xpos | |
2247 + ( | |
2248 int( | |
2249 ( | |
2250 ( | |
2251 self.ematrixori | |
2252 - self.ematrixwid | |
2253 + j / self.ematrixwid | |
2254 ) | |
2255 ) | |
2256 * sizeratio | |
2257 ) | |
2258 - l | |
2259 ) | |
2260 / 3 | |
2261 ) | |
2262 elif ital: | |
2263 x = ( | |
2264 xpos | |
2265 + ( | |
2266 int( | |
2267 ( | |
2268 self.defsize | |
2269 - ( | |
2270 self.ematrixori | |
2271 + j / self.ematrixwid | |
2272 ) | |
2273 ) | |
2274 * sizeratio | |
2275 ) | |
2276 - l | |
2277 ) | |
2278 / 3 | |
2279 ) | |
2280 if rotate == 1: | |
2281 self.plotPoint( | |
2282 y | |
2283 + int( | |
2284 (self.ematrixori + j / self.ematrixwid) | |
2285 * sizeratio | |
2286 ) | |
2287 - l | |
2288 - self.defsize, | |
2289 x + int((j % self.ematrixwid) * sizeratio) - k, | |
2290 ) | |
2291 elif rotate == -1: | |
2292 self.plotPoint( | |
2293 y | |
2294 + int( | |
2295 ( | |
2296 self.defsize | |
2297 - (self.ematrixori + j / self.ematrixwid) | |
2298 ) | |
2299 * sizeratio | |
2300 ) | |
2301 - l, | |
2302 2 * x | |
2303 - (x + int((j % self.ematrixwid) * sizeratio) - k), | |
2304 ) | |
2305 else: | |
2306 self.plotPoint( | |
2307 x + int((j % self.ematrixwid) * sizeratio) - k, | |
2308 y | |
2309 + int( | |
2310 ( | |
2311 self.defsize | |
2312 - (self.ematrixori + j / self.ematrixwid) | |
2313 ) | |
2314 * sizeratio | |
2315 ) | |
2316 - l, | |
2317 ) | |
2318 | |
2319 def writef(self, x, y, size, ital, bold, sans, rotate): | |
2320 xpos = x | |
2321 sizeratio = size * 1.0 / self.defsize | |
2322 sizeint = (size - 1) / self.defsize + 1 | |
2323 if bold: | |
2324 sizeint = sizeint + 2 + int(sizeratio) | |
2325 charstring = binar(self.fmatrix) | |
2326 charstring = ( | |
2327 self.fmatrixwid * self.fmatrixhei - len(charstring) | |
2328 ) * "0" + charstring | |
2329 if len(charstring) > self.fmatrixwid * self.fmatrixhei: | |
2330 charstring = charstring[0 - self.fmatrixwid * self.fmatrixhei :] | |
2331 for i in range(0, len(charstring), self.fmatrixwid): | |
2332 for j in range(i, i + self.fmatrixwid): | |
2333 if charstring[j] == "1": | |
2334 for k in range(sizeint): | |
2335 for l in range(sizeint): | |
2336 if ital and rotate == -1: | |
2337 x = ( | |
2338 xpos | |
2339 + ( | |
2340 int( | |
2341 ( | |
2342 ( | |
2343 self.fmatrixori | |
2344 - self.fmatrixwid | |
2345 + j / self.fmatrixwid | |
2346 ) | |
2347 ) | |
2348 * sizeratio | |
2349 ) | |
2350 - l | |
2351 ) | |
2352 / 3 | |
2353 ) | |
2354 elif ital: | |
2355 x = ( | |
2356 xpos | |
2357 + ( | |
2358 int( | |
2359 ( | |
2360 self.defsize | |
2361 - ( | |
2362 self.fmatrixori | |
2363 + j / self.fmatrixwid | |
2364 ) | |
2365 ) | |
2366 * sizeratio | |
2367 ) | |
2368 - l | |
2369 ) | |
2370 / 3 | |
2371 ) | |
2372 if rotate == 1: | |
2373 self.plotPoint( | |
2374 y | |
2375 + int( | |
2376 (self.fmatrixori + j / self.fmatrixwid) | |
2377 * sizeratio | |
2378 ) | |
2379 - l | |
2380 - self.defsize, | |
2381 x + int((j % self.fmatrixwid) * sizeratio) - k, | |
2382 ) | |
2383 elif rotate == -1: | |
2384 self.plotPoint( | |
2385 y | |
2386 + int( | |
2387 ( | |
2388 self.defsize | |
2389 - (self.fmatrixori + j / self.fmatrixwid) | |
2390 ) | |
2391 * sizeratio | |
2392 ) | |
2393 - l, | |
2394 2 * x | |
2395 - (x + int((j % self.fmatrixwid) * sizeratio) - k), | |
2396 ) | |
2397 else: | |
2398 self.plotPoint( | |
2399 x + int((j % self.fmatrixwid) * sizeratio) - k, | |
2400 y | |
2401 + int( | |
2402 ( | |
2403 self.defsize | |
2404 - (self.fmatrixori + j / self.fmatrixwid) | |
2405 ) | |
2406 * sizeratio | |
2407 ) | |
2408 - l, | |
2409 ) | |
2410 | |
2411 def writeg(self, x, y, size, ital, bold, sans, rotate): | |
2412 xpos = x | |
2413 sizeratio = size * 1.0 / self.defsize | |
2414 sizeint = (size - 1) / self.defsize + 1 | |
2415 if bold: | |
2416 sizeint = sizeint + 2 + int(sizeratio) | |
2417 charstring = binar(self.gmatrix) | |
2418 charstring = ( | |
2419 self.gmatrixwid * self.gmatrixhei - len(charstring) | |
2420 ) * "0" + charstring | |
2421 if len(charstring) > self.gmatrixwid * self.gmatrixhei: | |
2422 charstring = charstring[0 - self.gmatrixwid * self.gmatrixhei :] | |
2423 for i in range(0, len(charstring), self.gmatrixwid): | |
2424 for j in range(i, i + self.gmatrixwid): | |
2425 if charstring[j] == "1": | |
2426 for k in range(sizeint): | |
2427 for l in range(sizeint): | |
2428 if ital and rotate == -1: | |
2429 x = ( | |
2430 xpos | |
2431 + ( | |
2432 int( | |
2433 ( | |
2434 ( | |
2435 self.gmatrixori | |
2436 - self.gmatrixwid | |
2437 + j / self.gmatrixwid | |
2438 ) | |
2439 ) | |
2440 * sizeratio | |
2441 ) | |
2442 - l | |
2443 ) | |
2444 / 3 | |
2445 ) | |
2446 elif ital: | |
2447 x = ( | |
2448 xpos | |
2449 + ( | |
2450 int( | |
2451 ( | |
2452 self.defsize | |
2453 - ( | |
2454 self.gmatrixori | |
2455 + j / self.gmatrixwid | |
2456 ) | |
2457 ) | |
2458 * sizeratio | |
2459 ) | |
2460 - l | |
2461 ) | |
2462 / 3 | |
2463 ) | |
2464 if rotate == 1: | |
2465 self.plotPoint( | |
2466 y | |
2467 + int( | |
2468 (self.gmatrixori + j / self.gmatrixwid) | |
2469 * sizeratio | |
2470 ) | |
2471 - l | |
2472 - self.defsize, | |
2473 x + int((j % self.gmatrixwid) * sizeratio) - k, | |
2474 ) | |
2475 elif rotate == -1: | |
2476 self.plotPoint( | |
2477 y | |
2478 + int( | |
2479 ( | |
2480 self.defsize | |
2481 - (self.gmatrixori + j / self.gmatrixwid) | |
2482 ) | |
2483 * sizeratio | |
2484 ) | |
2485 - l, | |
2486 2 * x | |
2487 - (x + int((j % self.gmatrixwid) * sizeratio) - k), | |
2488 ) | |
2489 else: | |
2490 self.plotPoint( | |
2491 x + int((j % self.gmatrixwid) * sizeratio) - k, | |
2492 y | |
2493 + int( | |
2494 ( | |
2495 self.defsize | |
2496 - (self.gmatrixori + j / self.gmatrixwid) | |
2497 ) | |
2498 * sizeratio | |
2499 ) | |
2500 - l, | |
2501 ) | |
2502 | |
2503 def writeh(self, x, y, size, ital, bold, sans, rotate): | |
2504 xpos = x | |
2505 sizeratio = size * 1.0 / self.defsize | |
2506 sizeint = (size - 1) / self.defsize + 1 | |
2507 if bold: | |
2508 sizeint = sizeint + 2 + int(sizeratio) | |
2509 charstring = binar(self.hmatrix) | |
2510 charstring = ( | |
2511 self.hmatrixwid * self.hmatrixhei - len(charstring) | |
2512 ) * "0" + charstring | |
2513 if len(charstring) > self.hmatrixwid * self.hmatrixhei: | |
2514 charstring = charstring[0 - self.hmatrixwid * self.hmatrixhei :] | |
2515 for i in range(0, len(charstring), self.hmatrixwid): | |
2516 for j in range(i, i + self.hmatrixwid): | |
2517 if charstring[j] == "1": | |
2518 for k in range(sizeint): | |
2519 for l in range(sizeint): | |
2520 if ital and rotate == -1: | |
2521 x = ( | |
2522 xpos | |
2523 + ( | |
2524 int( | |
2525 ( | |
2526 ( | |
2527 self.hmatrixori | |
2528 - self.hmatrixwid | |
2529 + j / self.hmatrixwid | |
2530 ) | |
2531 ) | |
2532 * sizeratio | |
2533 ) | |
2534 - l | |
2535 ) | |
2536 / 3 | |
2537 ) | |
2538 elif ital: | |
2539 x = ( | |
2540 xpos | |
2541 + ( | |
2542 int( | |
2543 ( | |
2544 self.defsize | |
2545 - ( | |
2546 self.hmatrixori | |
2547 + j / self.hmatrixwid | |
2548 ) | |
2549 ) | |
2550 * sizeratio | |
2551 ) | |
2552 - l | |
2553 ) | |
2554 / 3 | |
2555 ) | |
2556 if rotate == 1: | |
2557 self.plotPoint( | |
2558 y | |
2559 + int( | |
2560 (self.hmatrixori + j / self.hmatrixwid) | |
2561 * sizeratio | |
2562 ) | |
2563 - l | |
2564 - self.defsize, | |
2565 x + int((j % self.hmatrixwid) * sizeratio) - k, | |
2566 ) | |
2567 elif rotate == -1: | |
2568 self.plotPoint( | |
2569 y | |
2570 + int( | |
2571 ( | |
2572 self.defsize | |
2573 - (self.hmatrixori + j / self.hmatrixwid) | |
2574 ) | |
2575 * sizeratio | |
2576 ) | |
2577 - l, | |
2578 2 * x | |
2579 - (x + int((j % self.hmatrixwid) * sizeratio) - k), | |
2580 ) | |
2581 else: | |
2582 self.plotPoint( | |
2583 x + int((j % self.hmatrixwid) * sizeratio) - k, | |
2584 y | |
2585 + int( | |
2586 ( | |
2587 self.defsize | |
2588 - (self.hmatrixori + j / self.hmatrixwid) | |
2589 ) | |
2590 * sizeratio | |
2591 ) | |
2592 - l, | |
2593 ) | |
2594 | |
2595 def writei(self, x, y, size, ital, bold, sans, rotate): | |
2596 xpos = x | |
2597 sizeratio = size * 1.0 / self.defsize | |
2598 sizeint = (size - 1) / self.defsize + 1 | |
2599 if bold: | |
2600 sizeint = sizeint + 2 + int(sizeratio) | |
2601 charstring = binar(self.imatrix) | |
2602 charstring = ( | |
2603 self.imatrixwid * self.imatrixhei - len(charstring) | |
2604 ) * "0" + charstring | |
2605 if len(charstring) > self.imatrixwid * self.imatrixhei: | |
2606 charstring = charstring[0 - self.imatrixwid * self.imatrixhei :] | |
2607 for i in range(0, len(charstring), self.imatrixwid): | |
2608 for j in range(i, i + self.imatrixwid): | |
2609 if charstring[j] == "1": | |
2610 for k in range(sizeint): | |
2611 for l in range(sizeint): | |
2612 if ital and rotate == -1: | |
2613 x = ( | |
2614 xpos | |
2615 + ( | |
2616 int( | |
2617 ( | |
2618 ( | |
2619 self.imatrixori | |
2620 - self.imatrixwid | |
2621 + j / self.imatrixwid | |
2622 ) | |
2623 ) | |
2624 * sizeratio | |
2625 ) | |
2626 - l | |
2627 ) | |
2628 / 3 | |
2629 ) | |
2630 elif ital: | |
2631 x = ( | |
2632 xpos | |
2633 + ( | |
2634 int( | |
2635 ( | |
2636 self.defsize | |
2637 - ( | |
2638 self.imatrixori | |
2639 + j / self.imatrixwid | |
2640 ) | |
2641 ) | |
2642 * sizeratio | |
2643 ) | |
2644 - l | |
2645 ) | |
2646 / 3 | |
2647 ) | |
2648 if rotate == 1: | |
2649 self.plotPoint( | |
2650 y | |
2651 + int( | |
2652 (self.imatrixori + j / self.imatrixwid) | |
2653 * sizeratio | |
2654 ) | |
2655 - l | |
2656 - self.defsize, | |
2657 x + int((j % self.imatrixwid) * sizeratio) - k, | |
2658 ) | |
2659 elif rotate == -1: | |
2660 self.plotPoint( | |
2661 y | |
2662 + int( | |
2663 ( | |
2664 self.defsize | |
2665 - (self.imatrixori + j / self.imatrixwid) | |
2666 ) | |
2667 * sizeratio | |
2668 ) | |
2669 - l, | |
2670 2 * x | |
2671 - (x + int((j % self.imatrixwid) * sizeratio) - k), | |
2672 ) | |
2673 else: | |
2674 self.plotPoint( | |
2675 x + int((j % self.imatrixwid) * sizeratio) - k, | |
2676 y | |
2677 + int( | |
2678 ( | |
2679 self.defsize | |
2680 - (self.imatrixori + j / self.imatrixwid) | |
2681 ) | |
2682 * sizeratio | |
2683 ) | |
2684 - l, | |
2685 ) | |
2686 | |
2687 def writej(self, x, y, size, ital, bold, sans, rotate): | |
2688 xpos = x | |
2689 sizeratio = size * 1.0 / self.defsize | |
2690 sizeint = (size - 1) / self.defsize + 1 | |
2691 if bold: | |
2692 sizeint = sizeint + 2 + int(sizeratio) | |
2693 charstring = binar(self.jmatrix) | |
2694 charstring = ( | |
2695 self.jmatrixwid * self.jmatrixhei - len(charstring) | |
2696 ) * "0" + charstring | |
2697 if len(charstring) > self.jmatrixwid * self.jmatrixhei: | |
2698 charstring = charstring[0 - self.jmatrixwid * self.jmatrixhei :] | |
2699 for i in range(0, len(charstring), self.jmatrixwid): | |
2700 for j in range(i, i + self.jmatrixwid): | |
2701 if charstring[j] == "1": | |
2702 for k in range(sizeint): | |
2703 for l in range(sizeint): | |
2704 if ital and rotate == -1: | |
2705 x = ( | |
2706 xpos | |
2707 + ( | |
2708 int( | |
2709 ( | |
2710 ( | |
2711 self.jmatrixori | |
2712 - self.jmatrixwid | |
2713 + j / self.jmatrixwid | |
2714 ) | |
2715 ) | |
2716 * sizeratio | |
2717 ) | |
2718 - l | |
2719 ) | |
2720 / 3 | |
2721 ) | |
2722 elif ital: | |
2723 x = ( | |
2724 xpos | |
2725 + ( | |
2726 int( | |
2727 ( | |
2728 self.defsize | |
2729 - ( | |
2730 self.jmatrixori | |
2731 + j / self.jmatrixwid | |
2732 ) | |
2733 ) | |
2734 * sizeratio | |
2735 ) | |
2736 - l | |
2737 ) | |
2738 / 3 | |
2739 ) | |
2740 if rotate == 1: | |
2741 self.plotPoint( | |
2742 y | |
2743 + int( | |
2744 (self.jmatrixori + j / self.jmatrixwid) | |
2745 * sizeratio | |
2746 ) | |
2747 - l | |
2748 - self.defsize, | |
2749 x + int((j % self.jmatrixwid) * sizeratio) - k, | |
2750 ) | |
2751 elif rotate == -1: | |
2752 self.plotPoint( | |
2753 y | |
2754 + int( | |
2755 ( | |
2756 self.defsize | |
2757 - (self.jmatrixori + j / self.jmatrixwid) | |
2758 ) | |
2759 * sizeratio | |
2760 ) | |
2761 - l, | |
2762 2 * x | |
2763 - (x + int((j % self.jmatrixwid) * sizeratio) - k), | |
2764 ) | |
2765 else: | |
2766 self.plotPoint( | |
2767 x + int((j % self.jmatrixwid) * sizeratio) - k, | |
2768 y | |
2769 + int( | |
2770 ( | |
2771 self.defsize | |
2772 - (self.jmatrixori + j / self.jmatrixwid) | |
2773 ) | |
2774 * sizeratio | |
2775 ) | |
2776 - l, | |
2777 ) | |
2778 | |
2779 def writek(self, x, y, size, ital, bold, sans, rotate): | |
2780 xpos = x | |
2781 sizeratio = size * 1.0 / self.defsize | |
2782 sizeint = (size - 1) / self.defsize + 1 | |
2783 if bold: | |
2784 sizeint = sizeint + 2 + int(sizeratio) | |
2785 charstring = binar(self.kmatrix) | |
2786 charstring = ( | |
2787 self.kmatrixwid * self.kmatrixhei - len(charstring) | |
2788 ) * "0" + charstring | |
2789 if len(charstring) > self.kmatrixwid * self.kmatrixhei: | |
2790 charstring = charstring[0 - self.kmatrixwid * self.kmatrixhei :] | |
2791 for i in range(0, len(charstring), self.kmatrixwid): | |
2792 for j in range(i, i + self.kmatrixwid): | |
2793 if charstring[j] == "1": | |
2794 for k in range(sizeint): | |
2795 for l in range(sizeint): | |
2796 if ital and rotate == -1: | |
2797 x = ( | |
2798 xpos | |
2799 + ( | |
2800 int( | |
2801 ( | |
2802 ( | |
2803 self.kmatrixori | |
2804 - self.kmatrixwid | |
2805 + j / self.kmatrixwid | |
2806 ) | |
2807 ) | |
2808 * sizeratio | |
2809 ) | |
2810 - l | |
2811 ) | |
2812 / 3 | |
2813 ) | |
2814 elif ital: | |
2815 x = ( | |
2816 xpos | |
2817 + ( | |
2818 int( | |
2819 ( | |
2820 self.defsize | |
2821 - ( | |
2822 self.kmatrixori | |
2823 + j / self.kmatrixwid | |
2824 ) | |
2825 ) | |
2826 * sizeratio | |
2827 ) | |
2828 - l | |
2829 ) | |
2830 / 3 | |
2831 ) | |
2832 if rotate == 1: | |
2833 self.plotPoint( | |
2834 y | |
2835 + int( | |
2836 (self.kmatrixori + j / self.kmatrixwid) | |
2837 * sizeratio | |
2838 ) | |
2839 - l | |
2840 - self.defsize, | |
2841 x + int((j % self.kmatrixwid) * sizeratio) - k, | |
2842 ) | |
2843 elif rotate == -1: | |
2844 self.plotPoint( | |
2845 y | |
2846 + int( | |
2847 ( | |
2848 self.defsize | |
2849 - (self.kmatrixori + j / self.kmatrixwid) | |
2850 ) | |
2851 * sizeratio | |
2852 ) | |
2853 - l, | |
2854 2 * x | |
2855 - (x + int((j % self.kmatrixwid) * sizeratio) - k), | |
2856 ) | |
2857 else: | |
2858 self.plotPoint( | |
2859 x + int((j % self.kmatrixwid) * sizeratio) - k, | |
2860 y | |
2861 + int( | |
2862 ( | |
2863 self.defsize | |
2864 - (self.kmatrixori + j / self.kmatrixwid) | |
2865 ) | |
2866 * sizeratio | |
2867 ) | |
2868 - l, | |
2869 ) | |
2870 | |
2871 def writel(self, x, y, size, ital, bold, sans, rotate): | |
2872 xpos = x | |
2873 sizeratio = size * 1.0 / self.defsize | |
2874 sizeint = (size - 1) / self.defsize + 1 | |
2875 if bold: | |
2876 sizeint = sizeint + 2 + int(sizeratio) | |
2877 charstring = binar(self.lmatrix) | |
2878 charstring = ( | |
2879 self.lmatrixwid * self.lmatrixhei - len(charstring) | |
2880 ) * "0" + charstring | |
2881 if len(charstring) > self.lmatrixwid * self.lmatrixhei: | |
2882 charstring = charstring[0 - self.lmatrixwid * self.lmatrixhei :] | |
2883 for i in range(0, len(charstring), self.lmatrixwid): | |
2884 for j in range(i, i + self.lmatrixwid): | |
2885 if charstring[j] == "1": | |
2886 for k in range(sizeint): | |
2887 for l in range(sizeint): | |
2888 if ital and rotate == -1: | |
2889 x = ( | |
2890 xpos | |
2891 + ( | |
2892 int( | |
2893 ( | |
2894 ( | |
2895 self.lmatrixori | |
2896 - self.lmatrixwid | |
2897 + j / self.lmatrixwid | |
2898 ) | |
2899 ) | |
2900 * sizeratio | |
2901 ) | |
2902 - l | |
2903 ) | |
2904 / 3 | |
2905 ) | |
2906 elif ital: | |
2907 x = ( | |
2908 xpos | |
2909 + ( | |
2910 int( | |
2911 ( | |
2912 self.defsize | |
2913 - ( | |
2914 self.lmatrixori | |
2915 + j / self.lmatrixwid | |
2916 ) | |
2917 ) | |
2918 * sizeratio | |
2919 ) | |
2920 - l | |
2921 ) | |
2922 / 3 | |
2923 ) | |
2924 if rotate == 1: | |
2925 self.plotPoint( | |
2926 y | |
2927 + int( | |
2928 (self.lmatrixori + j / self.lmatrixwid) | |
2929 * sizeratio | |
2930 ) | |
2931 - l | |
2932 - self.defsize, | |
2933 x + int((j % self.lmatrixwid) * sizeratio) - k, | |
2934 ) | |
2935 elif rotate == -1: | |
2936 self.plotPoint( | |
2937 y | |
2938 + int( | |
2939 ( | |
2940 self.defsize | |
2941 - (self.lmatrixori + j / self.lmatrixwid) | |
2942 ) | |
2943 * sizeratio | |
2944 ) | |
2945 - l, | |
2946 2 * x | |
2947 - (x + int((j % self.lmatrixwid) * sizeratio) - k), | |
2948 ) | |
2949 else: | |
2950 self.plotPoint( | |
2951 x + int((j % self.lmatrixwid) * sizeratio) - k, | |
2952 y | |
2953 + int( | |
2954 ( | |
2955 self.defsize | |
2956 - (self.lmatrixori + j / self.lmatrixwid) | |
2957 ) | |
2958 * sizeratio | |
2959 ) | |
2960 - l, | |
2961 ) | |
2962 | |
2963 def writem(self, x, y, size, ital, bold, sans, rotate): | |
2964 xpos = x | |
2965 sizeratio = size * 1.0 / self.defsize | |
2966 sizeint = (size - 1) / self.defsize + 1 | |
2967 if bold: | |
2968 sizeint = sizeint + 2 + int(sizeratio) | |
2969 charstring = binar(self.mmatrix) | |
2970 charstring = ( | |
2971 self.mmatrixwid * self.mmatrixhei - len(charstring) | |
2972 ) * "0" + charstring | |
2973 if len(charstring) > self.mmatrixwid * self.mmatrixhei: | |
2974 charstring = charstring[0 - self.mmatrixwid * self.mmatrixhei :] | |
2975 for i in range(0, len(charstring), self.mmatrixwid): | |
2976 for j in range(i, i + self.mmatrixwid): | |
2977 if charstring[j] == "1": | |
2978 for k in range(sizeint): | |
2979 for l in range(sizeint): | |
2980 if ital and rotate == -1: | |
2981 x = ( | |
2982 xpos | |
2983 + ( | |
2984 int( | |
2985 ( | |
2986 ( | |
2987 self.mmatrixori | |
2988 - self.mmatrixwid | |
2989 + j / self.mmatrixwid | |
2990 ) | |
2991 ) | |
2992 * sizeratio | |
2993 ) | |
2994 - l | |
2995 ) | |
2996 / 3 | |
2997 ) | |
2998 elif ital: | |
2999 x = ( | |
3000 xpos | |
3001 + ( | |
3002 int( | |
3003 ( | |
3004 self.defsize | |
3005 - ( | |
3006 self.mmatrixori | |
3007 + j / self.mmatrixwid | |
3008 ) | |
3009 ) | |
3010 * sizeratio | |
3011 ) | |
3012 - l | |
3013 ) | |
3014 / 3 | |
3015 ) | |
3016 if rotate == 1: | |
3017 self.plotPoint( | |
3018 y | |
3019 + int( | |
3020 (self.mmatrixori + j / self.mmatrixwid) | |
3021 * sizeratio | |
3022 ) | |
3023 - l | |
3024 - self.defsize, | |
3025 x + int((j % self.mmatrixwid) * sizeratio) - k, | |
3026 ) | |
3027 elif rotate == -1: | |
3028 self.plotPoint( | |
3029 y | |
3030 + int( | |
3031 ( | |
3032 self.defsize | |
3033 - (self.mmatrixori + j / self.mmatrixwid) | |
3034 ) | |
3035 * sizeratio | |
3036 ) | |
3037 - l, | |
3038 2 * x | |
3039 - (x + int((j % self.mmatrixwid) * sizeratio) - k), | |
3040 ) | |
3041 else: | |
3042 self.plotPoint( | |
3043 x + int((j % self.mmatrixwid) * sizeratio) - k, | |
3044 y | |
3045 + int( | |
3046 ( | |
3047 self.defsize | |
3048 - (self.mmatrixori + j / self.mmatrixwid) | |
3049 ) | |
3050 * sizeratio | |
3051 ) | |
3052 - l, | |
3053 ) | |
3054 | |
3055 def writen(self, x, y, size, ital, bold, sans, rotate): | |
3056 xpos = x | |
3057 sizeratio = size * 1.0 / self.defsize | |
3058 sizeint = (size - 1) / self.defsize + 1 | |
3059 if bold: | |
3060 sizeint = sizeint + 2 + int(sizeratio) | |
3061 charstring = binar(self.nmatrix) | |
3062 charstring = ( | |
3063 self.nmatrixwid * self.nmatrixhei - len(charstring) | |
3064 ) * "0" + charstring | |
3065 if len(charstring) > self.nmatrixwid * self.nmatrixhei: | |
3066 charstring = charstring[0 - self.nmatrixwid * self.nmatrixhei :] | |
3067 for i in range(0, len(charstring), self.nmatrixwid): | |
3068 for j in range(i, i + self.nmatrixwid): | |
3069 if charstring[j] == "1": | |
3070 for k in range(sizeint): | |
3071 for l in range(sizeint): | |
3072 if ital and rotate == -1: | |
3073 x = ( | |
3074 xpos | |
3075 + ( | |
3076 int( | |
3077 ( | |
3078 ( | |
3079 self.nmatrixori | |
3080 - self.nmatrixwid | |
3081 + j / self.nmatrixwid | |
3082 ) | |
3083 ) | |
3084 * sizeratio | |
3085 ) | |
3086 - l | |
3087 ) | |
3088 / 3 | |
3089 ) | |
3090 elif ital: | |
3091 x = ( | |
3092 xpos | |
3093 + ( | |
3094 int( | |
3095 ( | |
3096 self.defsize | |
3097 - ( | |
3098 self.nmatrixori | |
3099 + j / self.nmatrixwid | |
3100 ) | |
3101 ) | |
3102 * sizeratio | |
3103 ) | |
3104 - l | |
3105 ) | |
3106 / 3 | |
3107 ) | |
3108 if rotate == 1: | |
3109 self.plotPoint( | |
3110 y | |
3111 + int( | |
3112 (self.nmatrixori + j / self.nmatrixwid) | |
3113 * sizeratio | |
3114 ) | |
3115 - l | |
3116 - self.defsize, | |
3117 x + int((j % self.nmatrixwid) * sizeratio) - k, | |
3118 ) | |
3119 elif rotate == -1: | |
3120 self.plotPoint( | |
3121 y | |
3122 + int( | |
3123 ( | |
3124 self.defsize | |
3125 - (self.nmatrixori + j / self.nmatrixwid) | |
3126 ) | |
3127 * sizeratio | |
3128 ) | |
3129 - l, | |
3130 2 * x | |
3131 - (x + int((j % self.nmatrixwid) * sizeratio) - k), | |
3132 ) | |
3133 else: | |
3134 self.plotPoint( | |
3135 x + int((j % self.nmatrixwid) * sizeratio) - k, | |
3136 y | |
3137 + int( | |
3138 ( | |
3139 self.defsize | |
3140 - (self.nmatrixori + j / self.nmatrixwid) | |
3141 ) | |
3142 * sizeratio | |
3143 ) | |
3144 - l, | |
3145 ) | |
3146 | |
3147 def writeo(self, x, y, size, ital, bold, sans, rotate): | |
3148 xpos = x | |
3149 sizeratio = size * 1.0 / self.defsize | |
3150 sizeint = (size - 1) / self.defsize + 1 | |
3151 if bold: | |
3152 sizeint = sizeint + 2 + int(sizeratio) | |
3153 charstring = binar(self.omatrix) | |
3154 charstring = ( | |
3155 self.omatrixwid * self.omatrixhei - len(charstring) | |
3156 ) * "0" + charstring | |
3157 if len(charstring) > self.omatrixwid * self.omatrixhei: | |
3158 charstring = charstring[0 - self.omatrixwid * self.omatrixhei :] | |
3159 for i in range(0, len(charstring), self.omatrixwid): | |
3160 for j in range(i, i + self.omatrixwid): | |
3161 if charstring[j] == "1": | |
3162 for k in range(sizeint): | |
3163 for l in range(sizeint): | |
3164 if ital and rotate == -1: | |
3165 x = ( | |
3166 xpos | |
3167 + ( | |
3168 int( | |
3169 ( | |
3170 ( | |
3171 self.omatrixori | |
3172 - self.omatrixwid | |
3173 + j / self.omatrixwid | |
3174 ) | |
3175 ) | |
3176 * sizeratio | |
3177 ) | |
3178 - l | |
3179 ) | |
3180 / 3 | |
3181 ) | |
3182 elif ital: | |
3183 x = ( | |
3184 xpos | |
3185 + ( | |
3186 int( | |
3187 ( | |
3188 self.defsize | |
3189 - ( | |
3190 self.omatrixori | |
3191 + j / self.omatrixwid | |
3192 ) | |
3193 ) | |
3194 * sizeratio | |
3195 ) | |
3196 - l | |
3197 ) | |
3198 / 3 | |
3199 ) | |
3200 if rotate == 1: | |
3201 self.plotPoint( | |
3202 y | |
3203 + int( | |
3204 (self.omatrixori + j / self.omatrixwid) | |
3205 * sizeratio | |
3206 ) | |
3207 - l | |
3208 - self.defsize, | |
3209 x + int((j % self.omatrixwid) * sizeratio) - k, | |
3210 ) | |
3211 elif rotate == -1: | |
3212 self.plotPoint( | |
3213 y | |
3214 + int( | |
3215 ( | |
3216 self.defsize | |
3217 - (self.omatrixori + j / self.omatrixwid) | |
3218 ) | |
3219 * sizeratio | |
3220 ) | |
3221 - l, | |
3222 2 * x | |
3223 - (x + int((j % self.omatrixwid) * sizeratio) - k), | |
3224 ) | |
3225 else: | |
3226 self.plotPoint( | |
3227 x + int((j % self.omatrixwid) * sizeratio) - k, | |
3228 y | |
3229 + int( | |
3230 ( | |
3231 self.defsize | |
3232 - (self.omatrixori + j / self.omatrixwid) | |
3233 ) | |
3234 * sizeratio | |
3235 ) | |
3236 - l, | |
3237 ) | |
3238 | |
3239 def writep(self, x, y, size, ital, bold, sans, rotate): | |
3240 xpos = x | |
3241 sizeratio = size * 1.0 / self.defsize | |
3242 sizeint = (size - 1) / self.defsize + 1 | |
3243 if bold: | |
3244 sizeint = sizeint + 2 + int(sizeratio) | |
3245 charstring = binar(self.pmatrix) | |
3246 charstring = ( | |
3247 self.pmatrixwid * self.pmatrixhei - len(charstring) | |
3248 ) * "0" + charstring | |
3249 if len(charstring) > self.pmatrixwid * self.pmatrixhei: | |
3250 charstring = charstring[0 - self.pmatrixwid * self.pmatrixhei :] | |
3251 for i in range(0, len(charstring), self.pmatrixwid): | |
3252 for j in range(i, i + self.pmatrixwid): | |
3253 if charstring[j] == "1": | |
3254 for k in range(sizeint): | |
3255 for l in range(sizeint): | |
3256 if ital and rotate == -1: | |
3257 x = ( | |
3258 xpos | |
3259 + ( | |
3260 int( | |
3261 ( | |
3262 ( | |
3263 self.pmatrixori | |
3264 - self.pmatrixwid | |
3265 + j / self.pmatrixwid | |
3266 ) | |
3267 ) | |
3268 * sizeratio | |
3269 ) | |
3270 - l | |
3271 ) | |
3272 / 3 | |
3273 ) | |
3274 elif ital: | |
3275 x = ( | |
3276 xpos | |
3277 + ( | |
3278 int( | |
3279 ( | |
3280 self.defsize | |
3281 - ( | |
3282 self.pmatrixori | |
3283 + j / self.pmatrixwid | |
3284 ) | |
3285 ) | |
3286 * sizeratio | |
3287 ) | |
3288 - l | |
3289 ) | |
3290 / 3 | |
3291 ) | |
3292 if rotate == 1: | |
3293 self.plotPoint( | |
3294 y | |
3295 + int( | |
3296 (self.pmatrixori + j / self.pmatrixwid) | |
3297 * sizeratio | |
3298 ) | |
3299 - l | |
3300 - self.defsize, | |
3301 x + int((j % self.pmatrixwid) * sizeratio) - k, | |
3302 ) | |
3303 elif rotate == -1: | |
3304 self.plotPoint( | |
3305 y | |
3306 + int( | |
3307 ( | |
3308 self.defsize | |
3309 - (self.pmatrixori + j / self.pmatrixwid) | |
3310 ) | |
3311 * sizeratio | |
3312 ) | |
3313 - l, | |
3314 2 * x | |
3315 - (x + int((j % self.pmatrixwid) * sizeratio) - k), | |
3316 ) | |
3317 else: | |
3318 self.plotPoint( | |
3319 x + int((j % self.pmatrixwid) * sizeratio) - k, | |
3320 y | |
3321 + int( | |
3322 ( | |
3323 self.defsize | |
3324 - (self.pmatrixori + j / self.pmatrixwid) | |
3325 ) | |
3326 * sizeratio | |
3327 ) | |
3328 - l, | |
3329 ) | |
3330 | |
3331 def writeq(self, x, y, size, ital, bold, sans, rotate): | |
3332 xpos = x | |
3333 sizeratio = size * 1.0 / self.defsize | |
3334 sizeint = (size - 1) / self.defsize + 1 | |
3335 if bold: | |
3336 sizeint = sizeint + 2 + int(sizeratio) | |
3337 charstring = binar(self.qmatrix) | |
3338 charstring = ( | |
3339 self.qmatrixwid * self.qmatrixhei - len(charstring) | |
3340 ) * "0" + charstring | |
3341 if len(charstring) > self.qmatrixwid * self.qmatrixhei: | |
3342 charstring = charstring[0 - self.qmatrixwid * self.qmatrixhei :] | |
3343 for i in range(0, len(charstring), self.qmatrixwid): | |
3344 for j in range(i, i + self.qmatrixwid): | |
3345 if charstring[j] == "1": | |
3346 for k in range(sizeint): | |
3347 for l in range(sizeint): | |
3348 if ital and rotate == -1: | |
3349 x = ( | |
3350 xpos | |
3351 + ( | |
3352 int( | |
3353 ( | |
3354 ( | |
3355 self.qmatrixori | |
3356 - self.qmatrixwid | |
3357 + j / self.qmatrixwid | |
3358 ) | |
3359 ) | |
3360 * sizeratio | |
3361 ) | |
3362 - l | |
3363 ) | |
3364 / 3 | |
3365 ) | |
3366 elif ital: | |
3367 x = ( | |
3368 xpos | |
3369 + ( | |
3370 int( | |
3371 ( | |
3372 self.defsize | |
3373 - ( | |
3374 self.qmatrixori | |
3375 + j / self.qmatrixwid | |
3376 ) | |
3377 ) | |
3378 * sizeratio | |
3379 ) | |
3380 - l | |
3381 ) | |
3382 / 3 | |
3383 ) | |
3384 if rotate == 1: | |
3385 self.plotPoint( | |
3386 y | |
3387 + int( | |
3388 (self.qmatrixori + j / self.qmatrixwid) | |
3389 * sizeratio | |
3390 ) | |
3391 - l | |
3392 - self.defsize, | |
3393 x + int((j % self.qmatrixwid) * sizeratio) - k, | |
3394 ) | |
3395 elif rotate == -1: | |
3396 self.plotPoint( | |
3397 y | |
3398 + int( | |
3399 ( | |
3400 self.defsize | |
3401 - (self.qmatrixori + j / self.qmatrixwid) | |
3402 ) | |
3403 * sizeratio | |
3404 ) | |
3405 - l, | |
3406 2 * x | |
3407 - (x + int((j % self.qmatrixwid) * sizeratio) - k), | |
3408 ) | |
3409 else: | |
3410 self.plotPoint( | |
3411 x + int((j % self.qmatrixwid) * sizeratio) - k, | |
3412 y | |
3413 + int( | |
3414 ( | |
3415 self.defsize | |
3416 - (self.qmatrixori + j / self.qmatrixwid) | |
3417 ) | |
3418 * sizeratio | |
3419 ) | |
3420 - l, | |
3421 ) | |
3422 | |
3423 def writer(self, x, y, size, ital, bold, sans, rotate): | |
3424 xpos = x | |
3425 sizeratio = size * 1.0 / self.defsize | |
3426 sizeint = (size - 1) / self.defsize + 1 | |
3427 if bold: | |
3428 sizeint = sizeint + 2 + int(sizeratio) | |
3429 charstring = binar(self.rmatrix) | |
3430 charstring = ( | |
3431 self.rmatrixwid * self.rmatrixhei - len(charstring) | |
3432 ) * "0" + charstring | |
3433 if len(charstring) > self.rmatrixwid * self.rmatrixhei: | |
3434 charstring = charstring[0 - self.rmatrixwid * self.rmatrixhei :] | |
3435 for i in range(0, len(charstring), self.rmatrixwid): | |
3436 for j in range(i, i + self.rmatrixwid): | |
3437 if charstring[j] == "1": | |
3438 for k in range(sizeint): | |
3439 for l in range(sizeint): | |
3440 if ital and rotate == -1: | |
3441 x = ( | |
3442 xpos | |
3443 + ( | |
3444 int( | |
3445 ( | |
3446 ( | |
3447 self.rmatrixori | |
3448 - self.rmatrixwid | |
3449 + j / self.rmatrixwid | |
3450 ) | |
3451 ) | |
3452 * sizeratio | |
3453 ) | |
3454 - l | |
3455 ) | |
3456 / 3 | |
3457 ) | |
3458 elif ital: | |
3459 x = ( | |
3460 xpos | |
3461 + ( | |
3462 int( | |
3463 ( | |
3464 self.defsize | |
3465 - ( | |
3466 self.rmatrixori | |
3467 + j / self.rmatrixwid | |
3468 ) | |
3469 ) | |
3470 * sizeratio | |
3471 ) | |
3472 - l | |
3473 ) | |
3474 / 3 | |
3475 ) | |
3476 if rotate == 1: | |
3477 self.plotPoint( | |
3478 y | |
3479 + int( | |
3480 (self.rmatrixori + j / self.rmatrixwid) | |
3481 * sizeratio | |
3482 ) | |
3483 - l | |
3484 - self.defsize, | |
3485 x + int((j % self.rmatrixwid) * sizeratio) - k, | |
3486 ) | |
3487 elif rotate == -1: | |
3488 self.plotPoint( | |
3489 y | |
3490 + int( | |
3491 ( | |
3492 self.defsize | |
3493 - (self.rmatrixori + j / self.rmatrixwid) | |
3494 ) | |
3495 * sizeratio | |
3496 ) | |
3497 - l, | |
3498 2 * x | |
3499 - (x + int((j % self.rmatrixwid) * sizeratio) - k), | |
3500 ) | |
3501 else: | |
3502 self.plotPoint( | |
3503 x + int((j % self.rmatrixwid) * sizeratio) - k, | |
3504 y | |
3505 + int( | |
3506 ( | |
3507 self.defsize | |
3508 - (self.rmatrixori + j / self.rmatrixwid) | |
3509 ) | |
3510 * sizeratio | |
3511 ) | |
3512 - l, | |
3513 ) | |
3514 | |
3515 def writes(self, x, y, size, ital, bold, sans, rotate): | |
3516 xpos = x | |
3517 sizeratio = size * 1.0 / self.defsize | |
3518 sizeint = (size - 1) / self.defsize + 1 | |
3519 if bold: | |
3520 sizeint = sizeint + 2 + int(sizeratio) | |
3521 charstring = binar(self.smatrix) | |
3522 charstring = ( | |
3523 self.smatrixwid * self.smatrixhei - len(charstring) | |
3524 ) * "0" + charstring | |
3525 if len(charstring) > self.smatrixwid * self.smatrixhei: | |
3526 charstring = charstring[0 - self.smatrixwid * self.smatrixhei :] | |
3527 for i in range(0, len(charstring), self.smatrixwid): | |
3528 for j in range(i, i + self.smatrixwid): | |
3529 if charstring[j] == "1": | |
3530 for k in range(sizeint): | |
3531 for l in range(sizeint): | |
3532 if ital and rotate == -1: | |
3533 x = ( | |
3534 xpos | |
3535 + ( | |
3536 int( | |
3537 ( | |
3538 ( | |
3539 self.smatrixori | |
3540 - self.smatrixwid | |
3541 + j / self.smatrixwid | |
3542 ) | |
3543 ) | |
3544 * sizeratio | |
3545 ) | |
3546 - l | |
3547 ) | |
3548 / 3 | |
3549 ) | |
3550 elif ital: | |
3551 x = ( | |
3552 xpos | |
3553 + ( | |
3554 int( | |
3555 ( | |
3556 self.defsize | |
3557 - ( | |
3558 self.smatrixori | |
3559 + j / self.smatrixwid | |
3560 ) | |
3561 ) | |
3562 * sizeratio | |
3563 ) | |
3564 - l | |
3565 ) | |
3566 / 3 | |
3567 ) | |
3568 if rotate == 1: | |
3569 self.plotPoint( | |
3570 y | |
3571 + int( | |
3572 (self.smatrixori + j / self.smatrixwid) | |
3573 * sizeratio | |
3574 ) | |
3575 - l | |
3576 - self.defsize, | |
3577 x + int((j % self.smatrixwid) * sizeratio) - k, | |
3578 ) | |
3579 elif rotate == -1: | |
3580 self.plotPoint( | |
3581 y | |
3582 + int( | |
3583 ( | |
3584 self.defsize | |
3585 - (self.smatrixori + j / self.smatrixwid) | |
3586 ) | |
3587 * sizeratio | |
3588 ) | |
3589 - l, | |
3590 2 * x | |
3591 - (x + int((j % self.smatrixwid) * sizeratio) - k), | |
3592 ) | |
3593 else: | |
3594 self.plotPoint( | |
3595 x + int((j % self.smatrixwid) * sizeratio) - k, | |
3596 y | |
3597 + int( | |
3598 ( | |
3599 self.defsize | |
3600 - (self.smatrixori + j / self.smatrixwid) | |
3601 ) | |
3602 * sizeratio | |
3603 ) | |
3604 - l, | |
3605 ) | |
3606 | |
3607 def writet(self, x, y, size, ital, bold, sans, rotate): | |
3608 xpos = x | |
3609 sizeratio = size * 1.0 / self.defsize | |
3610 sizeint = (size - 1) / self.defsize + 1 | |
3611 if bold: | |
3612 sizeint = sizeint + 2 + int(sizeratio) | |
3613 charstring = binar(self.tmatrix) | |
3614 charstring = ( | |
3615 self.tmatrixwid * self.tmatrixhei - len(charstring) | |
3616 ) * "0" + charstring | |
3617 if len(charstring) > self.tmatrixwid * self.tmatrixhei: | |
3618 charstring = charstring[0 - self.tmatrixwid * self.tmatrixhei :] | |
3619 for i in range(0, len(charstring), self.tmatrixwid): | |
3620 for j in range(i, i + self.tmatrixwid): | |
3621 if charstring[j] == "1": | |
3622 for k in range(sizeint): | |
3623 for l in range(sizeint): | |
3624 if ital and rotate == -1: | |
3625 x = ( | |
3626 xpos | |
3627 + ( | |
3628 int( | |
3629 ( | |
3630 ( | |
3631 self.tmatrixori | |
3632 - self.tmatrixwid | |
3633 + j / self.tmatrixwid | |
3634 ) | |
3635 ) | |
3636 * sizeratio | |
3637 ) | |
3638 - l | |
3639 ) | |
3640 / 3 | |
3641 ) | |
3642 elif ital: | |
3643 x = ( | |
3644 xpos | |
3645 + ( | |
3646 int( | |
3647 ( | |
3648 self.defsize | |
3649 - ( | |
3650 self.tmatrixori | |
3651 + j / self.tmatrixwid | |
3652 ) | |
3653 ) | |
3654 * sizeratio | |
3655 ) | |
3656 - l | |
3657 ) | |
3658 / 3 | |
3659 ) | |
3660 if rotate == 1: | |
3661 self.plotPoint( | |
3662 y | |
3663 + int( | |
3664 (self.tmatrixori + j / self.tmatrixwid) | |
3665 * sizeratio | |
3666 ) | |
3667 - l | |
3668 - self.defsize, | |
3669 x + int((j % self.tmatrixwid) * sizeratio) - k, | |
3670 ) | |
3671 elif rotate == -1: | |
3672 self.plotPoint( | |
3673 y | |
3674 + int( | |
3675 ( | |
3676 self.defsize | |
3677 - (self.tmatrixori + j / self.tmatrixwid) | |
3678 ) | |
3679 * sizeratio | |
3680 ) | |
3681 - l, | |
3682 2 * x | |
3683 - (x + int((j % self.tmatrixwid) * sizeratio) - k), | |
3684 ) | |
3685 else: | |
3686 self.plotPoint( | |
3687 x + int((j % self.tmatrixwid) * sizeratio) - k, | |
3688 y | |
3689 + int( | |
3690 ( | |
3691 self.defsize | |
3692 - (self.tmatrixori + j / self.tmatrixwid) | |
3693 ) | |
3694 * sizeratio | |
3695 ) | |
3696 - l, | |
3697 ) | |
3698 | |
3699 def writeu(self, x, y, size, ital, bold, sans, rotate): | |
3700 xpos = x | |
3701 sizeratio = size * 1.0 / self.defsize | |
3702 sizeint = (size - 1) / self.defsize + 1 | |
3703 if bold: | |
3704 sizeint = sizeint + 2 + int(sizeratio) | |
3705 charstring = binar(self.umatrix) | |
3706 charstring = ( | |
3707 self.umatrixwid * self.umatrixhei - len(charstring) | |
3708 ) * "0" + charstring | |
3709 if len(charstring) > self.umatrixwid * self.umatrixhei: | |
3710 charstring = charstring[0 - self.umatrixwid * self.umatrixhei :] | |
3711 for i in range(0, len(charstring), self.umatrixwid): | |
3712 for j in range(i, i + self.umatrixwid): | |
3713 if charstring[j] == "1": | |
3714 for k in range(sizeint): | |
3715 for l in range(sizeint): | |
3716 if ital and rotate == -1: | |
3717 x = ( | |
3718 xpos | |
3719 + ( | |
3720 int( | |
3721 ( | |
3722 ( | |
3723 self.umatrixori | |
3724 - self.umatrixwid | |
3725 + j / self.umatrixwid | |
3726 ) | |
3727 ) | |
3728 * sizeratio | |
3729 ) | |
3730 - l | |
3731 ) | |
3732 / 3 | |
3733 ) | |
3734 elif ital: | |
3735 x = ( | |
3736 xpos | |
3737 + ( | |
3738 int( | |
3739 ( | |
3740 self.defsize | |
3741 - ( | |
3742 self.umatrixori | |
3743 + j / self.umatrixwid | |
3744 ) | |
3745 ) | |
3746 * sizeratio | |
3747 ) | |
3748 - l | |
3749 ) | |
3750 / 3 | |
3751 ) | |
3752 if rotate == 1: | |
3753 self.plotPoint( | |
3754 y | |
3755 + int( | |
3756 (self.umatrixori + j / self.umatrixwid) | |
3757 * sizeratio | |
3758 ) | |
3759 - l | |
3760 - self.defsize, | |
3761 x + int((j % self.umatrixwid) * sizeratio) - k, | |
3762 ) | |
3763 elif rotate == -1: | |
3764 self.plotPoint( | |
3765 y | |
3766 + int( | |
3767 ( | |
3768 self.defsize | |
3769 - (self.umatrixori + j / self.umatrixwid) | |
3770 ) | |
3771 * sizeratio | |
3772 ) | |
3773 - l, | |
3774 2 * x | |
3775 - (x + int((j % self.umatrixwid) * sizeratio) - k), | |
3776 ) | |
3777 else: | |
3778 self.plotPoint( | |
3779 x + int((j % self.umatrixwid) * sizeratio) - k, | |
3780 y | |
3781 + int( | |
3782 ( | |
3783 self.defsize | |
3784 - (self.umatrixori + j / self.umatrixwid) | |
3785 ) | |
3786 * sizeratio | |
3787 ) | |
3788 - l, | |
3789 ) | |
3790 | |
3791 def writev(self, x, y, size, ital, bold, sans, rotate): | |
3792 xpos = x | |
3793 sizeratio = size * 1.0 / self.defsize | |
3794 sizeint = (size - 1) / self.defsize + 1 | |
3795 if bold: | |
3796 sizeint = sizeint + 2 + int(sizeratio) | |
3797 charstring = binar(self.vmatrix) | |
3798 charstring = ( | |
3799 self.vmatrixwid * self.vmatrixhei - len(charstring) | |
3800 ) * "0" + charstring | |
3801 if len(charstring) > self.vmatrixwid * self.vmatrixhei: | |
3802 charstring = charstring[0 - self.vmatrixwid * self.vmatrixhei :] | |
3803 for i in range(0, len(charstring), self.vmatrixwid): | |
3804 for j in range(i, i + self.vmatrixwid): | |
3805 if charstring[j] == "1": | |
3806 for k in range(sizeint): | |
3807 for l in range(sizeint): | |
3808 if ital and rotate == -1: | |
3809 x = ( | |
3810 xpos | |
3811 + ( | |
3812 int( | |
3813 ( | |
3814 ( | |
3815 self.vmatrixori | |
3816 - self.vmatrixwid | |
3817 + j / self.vmatrixwid | |
3818 ) | |
3819 ) | |
3820 * sizeratio | |
3821 ) | |
3822 - l | |
3823 ) | |
3824 / 3 | |
3825 ) | |
3826 elif ital: | |
3827 x = ( | |
3828 xpos | |
3829 + ( | |
3830 int( | |
3831 ( | |
3832 self.defsize | |
3833 - ( | |
3834 self.vmatrixori | |
3835 + j / self.vmatrixwid | |
3836 ) | |
3837 ) | |
3838 * sizeratio | |
3839 ) | |
3840 - l | |
3841 ) | |
3842 / 3 | |
3843 ) | |
3844 if rotate == 1: | |
3845 self.plotPoint( | |
3846 y | |
3847 + int( | |
3848 (self.vmatrixori + j / self.vmatrixwid) | |
3849 * sizeratio | |
3850 ) | |
3851 - l | |
3852 - self.defsize, | |
3853 x + int((j % self.vmatrixwid) * sizeratio) - k, | |
3854 ) | |
3855 elif rotate == -1: | |
3856 self.plotPoint( | |
3857 y | |
3858 + int( | |
3859 ( | |
3860 self.defsize | |
3861 - (self.vmatrixori + j / self.vmatrixwid) | |
3862 ) | |
3863 * sizeratio | |
3864 ) | |
3865 - l, | |
3866 2 * x | |
3867 - (x + int((j % self.vmatrixwid) * sizeratio) - k), | |
3868 ) | |
3869 else: | |
3870 self.plotPoint( | |
3871 x + int((j % self.vmatrixwid) * sizeratio) - k, | |
3872 y | |
3873 + int( | |
3874 ( | |
3875 self.defsize | |
3876 - (self.vmatrixori + j / self.vmatrixwid) | |
3877 ) | |
3878 * sizeratio | |
3879 ) | |
3880 - l, | |
3881 ) | |
3882 | |
3883 def writew(self, x, y, size, ital, bold, sans, rotate): | |
3884 xpos = x | |
3885 sizeratio = size * 1.0 / self.defsize | |
3886 sizeint = (size - 1) / self.defsize + 1 | |
3887 if bold: | |
3888 sizeint = sizeint + 2 + int(sizeratio) | |
3889 charstring = binar(self.wmatrix) | |
3890 charstring = ( | |
3891 self.wmatrixwid * self.wmatrixhei - len(charstring) | |
3892 ) * "0" + charstring | |
3893 if len(charstring) > self.wmatrixwid * self.wmatrixhei: | |
3894 charstring = charstring[0 - self.wmatrixwid * self.wmatrixhei :] | |
3895 for i in range(0, len(charstring), self.wmatrixwid): | |
3896 for j in range(i, i + self.wmatrixwid): | |
3897 if charstring[j] == "1": | |
3898 for k in range(sizeint): | |
3899 for l in range(sizeint): | |
3900 if ital and rotate == -1: | |
3901 x = ( | |
3902 xpos | |
3903 + ( | |
3904 int( | |
3905 ( | |
3906 ( | |
3907 self.wmatrixori | |
3908 - self.wmatrixwid | |
3909 + j / self.wmatrixwid | |
3910 ) | |
3911 ) | |
3912 * sizeratio | |
3913 ) | |
3914 - l | |
3915 ) | |
3916 / 3 | |
3917 ) | |
3918 elif ital: | |
3919 x = ( | |
3920 xpos | |
3921 + ( | |
3922 int( | |
3923 ( | |
3924 self.defsize | |
3925 - ( | |
3926 self.wmatrixori | |
3927 + j / self.wmatrixwid | |
3928 ) | |
3929 ) | |
3930 * sizeratio | |
3931 ) | |
3932 - l | |
3933 ) | |
3934 / 3 | |
3935 ) | |
3936 if rotate == 1: | |
3937 self.plotPoint( | |
3938 y | |
3939 + int( | |
3940 (self.wmatrixori + j / self.wmatrixwid) | |
3941 * sizeratio | |
3942 ) | |
3943 - l | |
3944 - self.defsize, | |
3945 x + int((j % self.wmatrixwid) * sizeratio) - k, | |
3946 ) | |
3947 elif rotate == -1: | |
3948 self.plotPoint( | |
3949 y | |
3950 + int( | |
3951 ( | |
3952 self.defsize | |
3953 - (self.wmatrixori + j / self.wmatrixwid) | |
3954 ) | |
3955 * sizeratio | |
3956 ) | |
3957 - l, | |
3958 2 * x | |
3959 - (x + int((j % self.wmatrixwid) * sizeratio) - k), | |
3960 ) | |
3961 else: | |
3962 self.plotPoint( | |
3963 x + int((j % self.wmatrixwid) * sizeratio) - k, | |
3964 y | |
3965 + int( | |
3966 ( | |
3967 self.defsize | |
3968 - (self.wmatrixori + j / self.wmatrixwid) | |
3969 ) | |
3970 * sizeratio | |
3971 ) | |
3972 - l, | |
3973 ) | |
3974 | |
3975 def writex(self, x, y, size, ital, bold, sans, rotate): | |
3976 xpos = x | |
3977 sizeratio = size * 1.0 / self.defsize | |
3978 sizeint = (size - 1) / self.defsize + 1 | |
3979 if bold: | |
3980 sizeint = sizeint + 2 + int(sizeratio) | |
3981 charstring = binar(self.xmatrix) | |
3982 charstring = ( | |
3983 self.xmatrixwid * self.xmatrixhei - len(charstring) | |
3984 ) * "0" + charstring | |
3985 if len(charstring) > self.xmatrixwid * self.xmatrixhei: | |
3986 charstring = charstring[0 - self.xmatrixwid * self.xmatrixhei :] | |
3987 for i in range(0, len(charstring), self.xmatrixwid): | |
3988 for j in range(i, i + self.xmatrixwid): | |
3989 if charstring[j] == "1": | |
3990 for k in range(sizeint): | |
3991 for l in range(sizeint): | |
3992 if ital and rotate == -1: | |
3993 x = ( | |
3994 xpos | |
3995 + ( | |
3996 int( | |
3997 ( | |
3998 ( | |
3999 self.xmatrixori | |
4000 - self.xmatrixwid | |
4001 + j / self.xmatrixwid | |
4002 ) | |
4003 ) | |
4004 * sizeratio | |
4005 ) | |
4006 - l | |
4007 ) | |
4008 / 3 | |
4009 ) | |
4010 elif ital: | |
4011 x = ( | |
4012 xpos | |
4013 + ( | |
4014 int( | |
4015 ( | |
4016 self.defsize | |
4017 - ( | |
4018 self.xmatrixori | |
4019 + j / self.xmatrixwid | |
4020 ) | |
4021 ) | |
4022 * sizeratio | |
4023 ) | |
4024 - l | |
4025 ) | |
4026 / 3 | |
4027 ) | |
4028 if rotate == 1: | |
4029 self.plotPoint( | |
4030 y | |
4031 + int( | |
4032 (self.xmatrixori + j / self.xmatrixwid) | |
4033 * sizeratio | |
4034 ) | |
4035 - l | |
4036 - self.defsize, | |
4037 x + int((j % self.xmatrixwid) * sizeratio) - k, | |
4038 ) | |
4039 elif rotate == -1: | |
4040 self.plotPoint( | |
4041 y | |
4042 + int( | |
4043 ( | |
4044 self.defsize | |
4045 - (self.xmatrixori + j / self.xmatrixwid) | |
4046 ) | |
4047 * sizeratio | |
4048 ) | |
4049 - l, | |
4050 2 * x | |
4051 - (x + int((j % self.xmatrixwid) * sizeratio) - k), | |
4052 ) | |
4053 else: | |
4054 self.plotPoint( | |
4055 x + int((j % self.xmatrixwid) * sizeratio) - k, | |
4056 y | |
4057 + int( | |
4058 ( | |
4059 self.defsize | |
4060 - (self.xmatrixori + j / self.xmatrixwid) | |
4061 ) | |
4062 * sizeratio | |
4063 ) | |
4064 - l, | |
4065 ) | |
4066 | |
4067 def writey(self, x, y, size, ital, bold, sans, rotate): | |
4068 xpos = x | |
4069 sizeratio = size * 1.0 / self.defsize | |
4070 sizeint = (size - 1) / self.defsize + 1 | |
4071 if bold: | |
4072 sizeint = sizeint + 2 + int(sizeratio) | |
4073 charstring = binar(self.ymatrix) | |
4074 charstring = ( | |
4075 self.ymatrixwid * self.ymatrixhei - len(charstring) | |
4076 ) * "0" + charstring | |
4077 if len(charstring) > self.ymatrixwid * self.ymatrixhei: | |
4078 charstring = charstring[0 - self.ymatrixwid * self.ymatrixhei :] | |
4079 for i in range(0, len(charstring), self.ymatrixwid): | |
4080 for j in range(i, i + self.ymatrixwid): | |
4081 if charstring[j] == "1": | |
4082 for k in range(sizeint): | |
4083 for l in range(sizeint): | |
4084 if ital and rotate == -1: | |
4085 x = ( | |
4086 xpos | |
4087 + ( | |
4088 int( | |
4089 ( | |
4090 ( | |
4091 self.ymatrixori | |
4092 - self.ymatrixwid | |
4093 + j / self.ymatrixwid | |
4094 ) | |
4095 ) | |
4096 * sizeratio | |
4097 ) | |
4098 - l | |
4099 ) | |
4100 / 3 | |
4101 ) | |
4102 elif ital: | |
4103 x = ( | |
4104 xpos | |
4105 + ( | |
4106 int( | |
4107 ( | |
4108 self.defsize | |
4109 - ( | |
4110 self.ymatrixori | |
4111 + j / self.ymatrixwid | |
4112 ) | |
4113 ) | |
4114 * sizeratio | |
4115 ) | |
4116 - l | |
4117 ) | |
4118 / 3 | |
4119 ) | |
4120 if rotate == 1: | |
4121 self.plotPoint( | |
4122 y | |
4123 + int( | |
4124 (self.ymatrixori + j / self.ymatrixwid) | |
4125 * sizeratio | |
4126 ) | |
4127 - l | |
4128 - self.defsize, | |
4129 x + int((j % self.ymatrixwid) * sizeratio) - k, | |
4130 ) | |
4131 elif rotate == -1: | |
4132 self.plotPoint( | |
4133 y | |
4134 + int( | |
4135 ( | |
4136 self.defsize | |
4137 - (self.ymatrixori + j / self.ymatrixwid) | |
4138 ) | |
4139 * sizeratio | |
4140 ) | |
4141 - l, | |
4142 2 * x | |
4143 - (x + int((j % self.ymatrixwid) * sizeratio) - k), | |
4144 ) | |
4145 else: | |
4146 self.plotPoint( | |
4147 x + int((j % self.ymatrixwid) * sizeratio) - k, | |
4148 y | |
4149 + int( | |
4150 ( | |
4151 self.defsize | |
4152 - (self.ymatrixori + j / self.ymatrixwid) | |
4153 ) | |
4154 * sizeratio | |
4155 ) | |
4156 - l, | |
4157 ) | |
4158 | |
4159 def writez(self, x, y, size, ital, bold, sans, rotate): | |
4160 xpos = x | |
4161 sizeratio = size * 1.0 / self.defsize | |
4162 sizeint = (size - 1) / self.defsize + 1 | |
4163 if bold: | |
4164 sizeint = sizeint + 2 + int(sizeratio) | |
4165 charstring = binar(self.zmatrix) | |
4166 charstring = ( | |
4167 self.zmatrixwid * self.zmatrixhei - len(charstring) | |
4168 ) * "0" + charstring | |
4169 if len(charstring) > self.zmatrixwid * self.zmatrixhei: | |
4170 charstring = charstring[0 - self.zmatrixwid * self.zmatrixhei :] | |
4171 for i in range(0, len(charstring), self.zmatrixwid): | |
4172 for j in range(i, i + self.zmatrixwid): | |
4173 if charstring[j] == "1": | |
4174 for k in range(sizeint): | |
4175 for l in range(sizeint): | |
4176 if ital and rotate == -1: | |
4177 x = ( | |
4178 xpos | |
4179 + ( | |
4180 int( | |
4181 ( | |
4182 ( | |
4183 self.zmatrixori | |
4184 - self.zmatrixwid | |
4185 + j / self.zmatrixwid | |
4186 ) | |
4187 ) | |
4188 * sizeratio | |
4189 ) | |
4190 - l | |
4191 ) | |
4192 / 3 | |
4193 ) | |
4194 elif ital: | |
4195 x = ( | |
4196 xpos | |
4197 + ( | |
4198 int( | |
4199 ( | |
4200 self.defsize | |
4201 - ( | |
4202 self.zmatrixori | |
4203 + j / self.zmatrixwid | |
4204 ) | |
4205 ) | |
4206 * sizeratio | |
4207 ) | |
4208 - l | |
4209 ) | |
4210 / 3 | |
4211 ) | |
4212 if rotate == 1: | |
4213 self.plotPoint( | |
4214 y | |
4215 + int( | |
4216 (self.zmatrixori + j / self.zmatrixwid) | |
4217 * sizeratio | |
4218 ) | |
4219 - l | |
4220 - self.defsize, | |
4221 x + int((j % self.zmatrixwid) * sizeratio) - k, | |
4222 ) | |
4223 elif rotate == -1: | |
4224 self.plotPoint( | |
4225 y | |
4226 + int( | |
4227 ( | |
4228 self.defsize | |
4229 - (self.zmatrixori + j / self.zmatrixwid) | |
4230 ) | |
4231 * sizeratio | |
4232 ) | |
4233 - l, | |
4234 2 * x | |
4235 - (x + int((j % self.zmatrixwid) * sizeratio) - k), | |
4236 ) | |
4237 else: | |
4238 self.plotPoint( | |
4239 x + int((j % self.zmatrixwid) * sizeratio) - k, | |
4240 y | |
4241 + int( | |
4242 ( | |
4243 self.defsize | |
4244 - (self.zmatrixori + j / self.zmatrixwid) | |
4245 ) | |
4246 * sizeratio | |
4247 ) | |
4248 - l, | |
4249 ) | |
4250 | |
4251 def writeA(self, x, y, size, ital, bold, sans, rotate): | |
4252 xpos = x | |
4253 sizeratio = size * 1.0 / self.defsize | |
4254 sizeint = (size - 1) / self.defsize + 1 | |
4255 if bold: | |
4256 sizeint = sizeint + 2 + int(sizeratio) | |
4257 charstring = binar(self.Amatrix) | |
4258 charstring = ( | |
4259 self.Amatrixwid * self.Amatrixhei - len(charstring) | |
4260 ) * "0" + charstring | |
4261 if len(charstring) > self.Amatrixwid * self.Amatrixhei: | |
4262 charstring = charstring[0 - self.Amatrixwid * self.Amatrixhei :] | |
4263 for i in range(0, len(charstring), self.Amatrixwid): | |
4264 for j in range(i, i + self.Amatrixwid): | |
4265 if charstring[j] == "1": | |
4266 for k in range(sizeint): | |
4267 for l in range(sizeint): | |
4268 if ital and rotate == -1: | |
4269 x = ( | |
4270 xpos | |
4271 + ( | |
4272 int( | |
4273 ( | |
4274 ( | |
4275 self.Amatrixori | |
4276 - self.Amatrixwid | |
4277 + j / self.Amatrixwid | |
4278 ) | |
4279 ) | |
4280 * sizeratio | |
4281 ) | |
4282 - l | |
4283 ) | |
4284 / 3 | |
4285 ) | |
4286 elif ital: | |
4287 x = ( | |
4288 xpos | |
4289 + ( | |
4290 int( | |
4291 ( | |
4292 self.defsize | |
4293 - ( | |
4294 self.Amatrixori | |
4295 + j / self.Amatrixwid | |
4296 ) | |
4297 ) | |
4298 * sizeratio | |
4299 ) | |
4300 - l | |
4301 ) | |
4302 / 3 | |
4303 ) | |
4304 if rotate == 1: | |
4305 self.plotPoint( | |
4306 y | |
4307 + int( | |
4308 (self.Amatrixori + j / self.Amatrixwid) | |
4309 * sizeratio | |
4310 ) | |
4311 - l | |
4312 - self.defsize, | |
4313 x + int((j % self.Amatrixwid) * sizeratio) - k, | |
4314 ) | |
4315 elif rotate == -1: | |
4316 self.plotPoint( | |
4317 y | |
4318 + int( | |
4319 ( | |
4320 self.defsize | |
4321 - (self.Amatrixori + j / self.Amatrixwid) | |
4322 ) | |
4323 * sizeratio | |
4324 ) | |
4325 - l, | |
4326 2 * x | |
4327 - (x + int((j % self.Amatrixwid) * sizeratio) - k), | |
4328 ) | |
4329 else: | |
4330 self.plotPoint( | |
4331 x + int((j % self.Amatrixwid) * sizeratio) - k, | |
4332 y | |
4333 + int( | |
4334 ( | |
4335 self.defsize | |
4336 - (self.Amatrixori + j / self.Amatrixwid) | |
4337 ) | |
4338 * sizeratio | |
4339 ) | |
4340 - l, | |
4341 ) | |
4342 | |
4343 def writeB(self, x, y, size, ital, bold, sans, rotate): | |
4344 xpos = x | |
4345 sizeratio = size * 1.0 / self.defsize | |
4346 sizeint = (size - 1) / self.defsize + 1 | |
4347 if bold: | |
4348 sizeint = sizeint + 2 + int(sizeratio) | |
4349 charstring = binar(self.Bmatrix) | |
4350 charstring = ( | |
4351 self.Bmatrixwid * self.Bmatrixhei - len(charstring) | |
4352 ) * "0" + charstring | |
4353 if len(charstring) > self.Bmatrixwid * self.Bmatrixhei: | |
4354 charstring = charstring[0 - self.Bmatrixwid * self.Bmatrixhei :] | |
4355 for i in range(0, len(charstring), self.Bmatrixwid): | |
4356 for j in range(i, i + self.Bmatrixwid): | |
4357 if charstring[j] == "1": | |
4358 for k in range(sizeint): | |
4359 for l in range(sizeint): | |
4360 if ital and rotate == -1: | |
4361 x = ( | |
4362 xpos | |
4363 + ( | |
4364 int( | |
4365 ( | |
4366 ( | |
4367 self.Bmatrixori | |
4368 - self.Bmatrixwid | |
4369 + j / self.Bmatrixwid | |
4370 ) | |
4371 ) | |
4372 * sizeratio | |
4373 ) | |
4374 - l | |
4375 ) | |
4376 / 3 | |
4377 ) | |
4378 elif ital: | |
4379 x = ( | |
4380 xpos | |
4381 + ( | |
4382 int( | |
4383 ( | |
4384 self.defsize | |
4385 - ( | |
4386 self.Bmatrixori | |
4387 + j / self.Bmatrixwid | |
4388 ) | |
4389 ) | |
4390 * sizeratio | |
4391 ) | |
4392 - l | |
4393 ) | |
4394 / 3 | |
4395 ) | |
4396 if rotate == 1: | |
4397 self.plotPoint( | |
4398 y | |
4399 + int( | |
4400 (self.Bmatrixori + j / self.Bmatrixwid) | |
4401 * sizeratio | |
4402 ) | |
4403 - l | |
4404 - self.defsize, | |
4405 x + int((j % self.Bmatrixwid) * sizeratio) - k, | |
4406 ) | |
4407 elif rotate == -1: | |
4408 self.plotPoint( | |
4409 y | |
4410 + int( | |
4411 ( | |
4412 self.defsize | |
4413 - (self.Bmatrixori + j / self.Bmatrixwid) | |
4414 ) | |
4415 * sizeratio | |
4416 ) | |
4417 - l, | |
4418 2 * x | |
4419 - (x + int((j % self.Bmatrixwid) * sizeratio) - k), | |
4420 ) | |
4421 else: | |
4422 self.plotPoint( | |
4423 x + int((j % self.Bmatrixwid) * sizeratio) - k, | |
4424 y | |
4425 + int( | |
4426 ( | |
4427 self.defsize | |
4428 - (self.Bmatrixori + j / self.Bmatrixwid) | |
4429 ) | |
4430 * sizeratio | |
4431 ) | |
4432 - l, | |
4433 ) | |
4434 | |
4435 def writeC(self, x, y, size, ital, bold, sans, rotate): | |
4436 xpos = x | |
4437 sizeratio = size * 1.0 / self.defsize | |
4438 sizeint = (size - 1) / self.defsize + 1 | |
4439 if bold: | |
4440 sizeint = sizeint + 2 + int(sizeratio) | |
4441 charstring = binar(self.Cmatrix) | |
4442 charstring = ( | |
4443 self.Cmatrixwid * self.Cmatrixhei - len(charstring) | |
4444 ) * "0" + charstring | |
4445 if len(charstring) > self.Cmatrixwid * self.Cmatrixhei: | |
4446 charstring = charstring[0 - self.Cmatrixwid * self.Cmatrixhei :] | |
4447 for i in range(0, len(charstring), self.Cmatrixwid): | |
4448 for j in range(i, i + self.Cmatrixwid): | |
4449 if charstring[j] == "1": | |
4450 for k in range(sizeint): | |
4451 for l in range(sizeint): | |
4452 if ital and rotate == -1: | |
4453 x = ( | |
4454 xpos | |
4455 + ( | |
4456 int( | |
4457 ( | |
4458 ( | |
4459 self.Cmatrixori | |
4460 - self.Cmatrixwid | |
4461 + j / self.Cmatrixwid | |
4462 ) | |
4463 ) | |
4464 * sizeratio | |
4465 ) | |
4466 - l | |
4467 ) | |
4468 / 3 | |
4469 ) | |
4470 elif ital: | |
4471 x = ( | |
4472 xpos | |
4473 + ( | |
4474 int( | |
4475 ( | |
4476 self.defsize | |
4477 - ( | |
4478 self.Cmatrixori | |
4479 + j / self.Cmatrixwid | |
4480 ) | |
4481 ) | |
4482 * sizeratio | |
4483 ) | |
4484 - l | |
4485 ) | |
4486 / 3 | |
4487 ) | |
4488 if rotate == 1: | |
4489 self.plotPoint( | |
4490 y | |
4491 + int( | |
4492 (self.Cmatrixori + j / self.Cmatrixwid) | |
4493 * sizeratio | |
4494 ) | |
4495 - l | |
4496 - self.defsize, | |
4497 x + int((j % self.Cmatrixwid) * sizeratio) - k, | |
4498 ) | |
4499 elif rotate == -1: | |
4500 self.plotPoint( | |
4501 y | |
4502 + int( | |
4503 ( | |
4504 self.defsize | |
4505 - (self.Cmatrixori + j / self.Cmatrixwid) | |
4506 ) | |
4507 * sizeratio | |
4508 ) | |
4509 - l, | |
4510 2 * x | |
4511 - (x + int((j % self.Cmatrixwid) * sizeratio) - k), | |
4512 ) | |
4513 else: | |
4514 self.plotPoint( | |
4515 x + int((j % self.Cmatrixwid) * sizeratio) - k, | |
4516 y | |
4517 + int( | |
4518 ( | |
4519 self.defsize | |
4520 - (self.Cmatrixori + j / self.Cmatrixwid) | |
4521 ) | |
4522 * sizeratio | |
4523 ) | |
4524 - l, | |
4525 ) | |
4526 | |
4527 def writeD(self, x, y, size, ital, bold, sans, rotate): | |
4528 xpos = x | |
4529 sizeratio = size * 1.0 / self.defsize | |
4530 sizeint = (size - 1) / self.defsize + 1 | |
4531 if bold: | |
4532 sizeint = sizeint + 2 + int(sizeratio) | |
4533 charstring = binar(self.Dmatrix) | |
4534 charstring = ( | |
4535 self.Dmatrixwid * self.Dmatrixhei - len(charstring) | |
4536 ) * "0" + charstring | |
4537 if len(charstring) > self.Dmatrixwid * self.Dmatrixhei: | |
4538 charstring = charstring[0 - self.Dmatrixwid * self.Dmatrixhei :] | |
4539 for i in range(0, len(charstring), self.Dmatrixwid): | |
4540 for j in range(i, i + self.Dmatrixwid): | |
4541 if charstring[j] == "1": | |
4542 for k in range(sizeint): | |
4543 for l in range(sizeint): | |
4544 if ital and rotate == -1: | |
4545 x = ( | |
4546 xpos | |
4547 + ( | |
4548 int( | |
4549 ( | |
4550 ( | |
4551 self.Dmatrixori | |
4552 - self.Dmatrixwid | |
4553 + j / self.Dmatrixwid | |
4554 ) | |
4555 ) | |
4556 * sizeratio | |
4557 ) | |
4558 - l | |
4559 ) | |
4560 / 3 | |
4561 ) | |
4562 elif ital: | |
4563 x = ( | |
4564 xpos | |
4565 + ( | |
4566 int( | |
4567 ( | |
4568 self.defsize | |
4569 - ( | |
4570 self.Dmatrixori | |
4571 + j / self.Dmatrixwid | |
4572 ) | |
4573 ) | |
4574 * sizeratio | |
4575 ) | |
4576 - l | |
4577 ) | |
4578 / 3 | |
4579 ) | |
4580 if rotate == 1: | |
4581 self.plotPoint( | |
4582 y | |
4583 + int( | |
4584 (self.Dmatrixori + j / self.Dmatrixwid) | |
4585 * sizeratio | |
4586 ) | |
4587 - l | |
4588 - self.defsize, | |
4589 x + int((j % self.Dmatrixwid) * sizeratio) - k, | |
4590 ) | |
4591 elif rotate == -1: | |
4592 self.plotPoint( | |
4593 y | |
4594 + int( | |
4595 ( | |
4596 self.defsize | |
4597 - (self.Dmatrixori + j / self.Dmatrixwid) | |
4598 ) | |
4599 * sizeratio | |
4600 ) | |
4601 - l, | |
4602 2 * x | |
4603 - (x + int((j % self.Dmatrixwid) * sizeratio) - k), | |
4604 ) | |
4605 else: | |
4606 self.plotPoint( | |
4607 x + int((j % self.Dmatrixwid) * sizeratio) - k, | |
4608 y | |
4609 + int( | |
4610 ( | |
4611 self.defsize | |
4612 - (self.Dmatrixori + j / self.Dmatrixwid) | |
4613 ) | |
4614 * sizeratio | |
4615 ) | |
4616 - l, | |
4617 ) | |
4618 | |
4619 def writeE(self, x, y, size, ital, bold, sans, rotate): | |
4620 xpos = x | |
4621 sizeratio = size * 1.0 / self.defsize | |
4622 sizeint = (size - 1) / self.defsize + 1 | |
4623 if bold: | |
4624 sizeint = sizeint + 2 + int(sizeratio) | |
4625 charstring = binar(self.Ematrix) | |
4626 charstring = ( | |
4627 self.Ematrixwid * self.Ematrixhei - len(charstring) | |
4628 ) * "0" + charstring | |
4629 if len(charstring) > self.Ematrixwid * self.Ematrixhei: | |
4630 charstring = charstring[0 - self.Ematrixwid * self.Ematrixhei :] | |
4631 for i in range(0, len(charstring), self.Ematrixwid): | |
4632 for j in range(i, i + self.Ematrixwid): | |
4633 if charstring[j] == "1": | |
4634 for k in range(sizeint): | |
4635 for l in range(sizeint): | |
4636 if ital and rotate == -1: | |
4637 x = ( | |
4638 xpos | |
4639 + ( | |
4640 int( | |
4641 ( | |
4642 ( | |
4643 self.Ematrixori | |
4644 - self.Ematrixwid | |
4645 + j / self.Ematrixwid | |
4646 ) | |
4647 ) | |
4648 * sizeratio | |
4649 ) | |
4650 - l | |
4651 ) | |
4652 / 3 | |
4653 ) | |
4654 elif ital: | |
4655 x = ( | |
4656 xpos | |
4657 + ( | |
4658 int( | |
4659 ( | |
4660 self.defsize | |
4661 - ( | |
4662 self.Ematrixori | |
4663 + j / self.Ematrixwid | |
4664 ) | |
4665 ) | |
4666 * sizeratio | |
4667 ) | |
4668 - l | |
4669 ) | |
4670 / 3 | |
4671 ) | |
4672 if rotate == 1: | |
4673 self.plotPoint( | |
4674 y | |
4675 + int( | |
4676 (self.Ematrixori + j / self.Ematrixwid) | |
4677 * sizeratio | |
4678 ) | |
4679 - l | |
4680 - self.defsize, | |
4681 x + int((j % self.Ematrixwid) * sizeratio) - k, | |
4682 ) | |
4683 elif rotate == -1: | |
4684 self.plotPoint( | |
4685 y | |
4686 + int( | |
4687 ( | |
4688 self.defsize | |
4689 - (self.Ematrixori + j / self.Ematrixwid) | |
4690 ) | |
4691 * sizeratio | |
4692 ) | |
4693 - l, | |
4694 2 * x | |
4695 - (x + int((j % self.Ematrixwid) * sizeratio) - k), | |
4696 ) | |
4697 else: | |
4698 self.plotPoint( | |
4699 x + int((j % self.Ematrixwid) * sizeratio) - k, | |
4700 y | |
4701 + int( | |
4702 ( | |
4703 self.defsize | |
4704 - (self.Ematrixori + j / self.Ematrixwid) | |
4705 ) | |
4706 * sizeratio | |
4707 ) | |
4708 - l, | |
4709 ) | |
4710 | |
4711 def writeF(self, x, y, size, ital, bold, sans, rotate): | |
4712 xpos = x | |
4713 sizeratio = size * 1.0 / self.defsize | |
4714 sizeint = (size - 1) / self.defsize + 1 | |
4715 if bold: | |
4716 sizeint = sizeint + 2 + int(sizeratio) | |
4717 charstring = binar(self.Fmatrix) | |
4718 charstring = ( | |
4719 self.Fmatrixwid * self.Fmatrixhei - len(charstring) | |
4720 ) * "0" + charstring | |
4721 if len(charstring) > self.Fmatrixwid * self.Fmatrixhei: | |
4722 charstring = charstring[0 - self.Fmatrixwid * self.Fmatrixhei :] | |
4723 for i in range(0, len(charstring), self.Fmatrixwid): | |
4724 for j in range(i, i + self.Fmatrixwid): | |
4725 if charstring[j] == "1": | |
4726 for k in range(sizeint): | |
4727 for l in range(sizeint): | |
4728 if ital and rotate == -1: | |
4729 x = ( | |
4730 xpos | |
4731 + ( | |
4732 int( | |
4733 ( | |
4734 ( | |
4735 self.Fmatrixori | |
4736 - self.Fmatrixwid | |
4737 + j / self.Fmatrixwid | |
4738 ) | |
4739 ) | |
4740 * sizeratio | |
4741 ) | |
4742 - l | |
4743 ) | |
4744 / 3 | |
4745 ) | |
4746 elif ital: | |
4747 x = ( | |
4748 xpos | |
4749 + ( | |
4750 int( | |
4751 ( | |
4752 self.defsize | |
4753 - ( | |
4754 self.Fmatrixori | |
4755 + j / self.Fmatrixwid | |
4756 ) | |
4757 ) | |
4758 * sizeratio | |
4759 ) | |
4760 - l | |
4761 ) | |
4762 / 3 | |
4763 ) | |
4764 if rotate == 1: | |
4765 self.plotPoint( | |
4766 y | |
4767 + int( | |
4768 (self.Fmatrixori + j / self.Fmatrixwid) | |
4769 * sizeratio | |
4770 ) | |
4771 - l | |
4772 - self.defsize, | |
4773 x + int((j % self.Fmatrixwid) * sizeratio) - k, | |
4774 ) | |
4775 elif rotate == -1: | |
4776 self.plotPoint( | |
4777 y | |
4778 + int( | |
4779 ( | |
4780 self.defsize | |
4781 - (self.Fmatrixori + j / self.Fmatrixwid) | |
4782 ) | |
4783 * sizeratio | |
4784 ) | |
4785 - l, | |
4786 2 * x | |
4787 - (x + int((j % self.Fmatrixwid) * sizeratio) - k), | |
4788 ) | |
4789 else: | |
4790 self.plotPoint( | |
4791 x + int((j % self.Fmatrixwid) * sizeratio) - k, | |
4792 y | |
4793 + int( | |
4794 ( | |
4795 self.defsize | |
4796 - (self.Fmatrixori + j / self.Fmatrixwid) | |
4797 ) | |
4798 * sizeratio | |
4799 ) | |
4800 - l, | |
4801 ) | |
4802 | |
4803 def writeG(self, x, y, size, ital, bold, sans, rotate): | |
4804 xpos = x | |
4805 sizeratio = size * 1.0 / self.defsize | |
4806 sizeint = (size - 1) / self.defsize + 1 | |
4807 if bold: | |
4808 sizeint = sizeint + 2 + int(sizeratio) | |
4809 charstring = binar(self.Gmatrix) | |
4810 charstring = ( | |
4811 self.Gmatrixwid * self.Gmatrixhei - len(charstring) | |
4812 ) * "0" + charstring | |
4813 if len(charstring) > self.Gmatrixwid * self.Gmatrixhei: | |
4814 charstring = charstring[0 - self.Gmatrixwid * self.Gmatrixhei :] | |
4815 for i in range(0, len(charstring), self.Gmatrixwid): | |
4816 for j in range(i, i + self.Gmatrixwid): | |
4817 if charstring[j] == "1": | |
4818 for k in range(sizeint): | |
4819 for l in range(sizeint): | |
4820 if ital and rotate == -1: | |
4821 x = ( | |
4822 xpos | |
4823 + ( | |
4824 int( | |
4825 ( | |
4826 ( | |
4827 self.Gmatrixori | |
4828 - self.Gmatrixwid | |
4829 + j / self.Gmatrixwid | |
4830 ) | |
4831 ) | |
4832 * sizeratio | |
4833 ) | |
4834 - l | |
4835 ) | |
4836 / 3 | |
4837 ) | |
4838 elif ital: | |
4839 x = ( | |
4840 xpos | |
4841 + ( | |
4842 int( | |
4843 ( | |
4844 self.defsize | |
4845 - ( | |
4846 self.Gmatrixori | |
4847 + j / self.Gmatrixwid | |
4848 ) | |
4849 ) | |
4850 * sizeratio | |
4851 ) | |
4852 - l | |
4853 ) | |
4854 / 3 | |
4855 ) | |
4856 if rotate == 1: | |
4857 self.plotPoint( | |
4858 y | |
4859 + int( | |
4860 (self.Gmatrixori + j / self.Gmatrixwid) | |
4861 * sizeratio | |
4862 ) | |
4863 - l | |
4864 - self.defsize, | |
4865 x + int((j % self.Gmatrixwid) * sizeratio) - k, | |
4866 ) | |
4867 elif rotate == -1: | |
4868 self.plotPoint( | |
4869 y | |
4870 + int( | |
4871 ( | |
4872 self.defsize | |
4873 - (self.Gmatrixori + j / self.Gmatrixwid) | |
4874 ) | |
4875 * sizeratio | |
4876 ) | |
4877 - l, | |
4878 2 * x | |
4879 - (x + int((j % self.Gmatrixwid) * sizeratio) - k), | |
4880 ) | |
4881 else: | |
4882 self.plotPoint( | |
4883 x + int((j % self.Gmatrixwid) * sizeratio) - k, | |
4884 y | |
4885 + int( | |
4886 ( | |
4887 self.defsize | |
4888 - (self.Gmatrixori + j / self.Gmatrixwid) | |
4889 ) | |
4890 * sizeratio | |
4891 ) | |
4892 - l, | |
4893 ) | |
4894 | |
4895 def writeH(self, x, y, size, ital, bold, sans, rotate): | |
4896 xpos = x | |
4897 sizeratio = size * 1.0 / self.defsize | |
4898 sizeint = (size - 1) / self.defsize + 1 | |
4899 if bold: | |
4900 sizeint = sizeint + 2 + int(sizeratio) | |
4901 charstring = binar(self.Hmatrix) | |
4902 charstring = ( | |
4903 self.Hmatrixwid * self.Hmatrixhei - len(charstring) | |
4904 ) * "0" + charstring | |
4905 if len(charstring) > self.Hmatrixwid * self.Hmatrixhei: | |
4906 charstring = charstring[0 - self.Hmatrixwid * self.Hmatrixhei :] | |
4907 for i in range(0, len(charstring), self.Hmatrixwid): | |
4908 for j in range(i, i + self.Hmatrixwid): | |
4909 if charstring[j] == "1": | |
4910 for k in range(sizeint): | |
4911 for l in range(sizeint): | |
4912 if ital and rotate == -1: | |
4913 x = ( | |
4914 xpos | |
4915 + ( | |
4916 int( | |
4917 ( | |
4918 ( | |
4919 self.Hmatrixori | |
4920 - self.Hmatrixwid | |
4921 + j / self.Hmatrixwid | |
4922 ) | |
4923 ) | |
4924 * sizeratio | |
4925 ) | |
4926 - l | |
4927 ) | |
4928 / 3 | |
4929 ) | |
4930 elif ital: | |
4931 x = ( | |
4932 xpos | |
4933 + ( | |
4934 int( | |
4935 ( | |
4936 self.defsize | |
4937 - ( | |
4938 self.Hmatrixori | |
4939 + j / self.Hmatrixwid | |
4940 ) | |
4941 ) | |
4942 * sizeratio | |
4943 ) | |
4944 - l | |
4945 ) | |
4946 / 3 | |
4947 ) | |
4948 if rotate == 1: | |
4949 self.plotPoint( | |
4950 y | |
4951 + int( | |
4952 (self.Hmatrixori + j / self.Hmatrixwid) | |
4953 * sizeratio | |
4954 ) | |
4955 - l | |
4956 - self.defsize, | |
4957 x + int((j % self.Hmatrixwid) * sizeratio) - k, | |
4958 ) | |
4959 elif rotate == -1: | |
4960 self.plotPoint( | |
4961 y | |
4962 + int( | |
4963 ( | |
4964 self.defsize | |
4965 - (self.Hmatrixori + j / self.Hmatrixwid) | |
4966 ) | |
4967 * sizeratio | |
4968 ) | |
4969 - l, | |
4970 2 * x | |
4971 - (x + int((j % self.Hmatrixwid) * sizeratio) - k), | |
4972 ) | |
4973 else: | |
4974 self.plotPoint( | |
4975 x + int((j % self.Hmatrixwid) * sizeratio) - k, | |
4976 y | |
4977 + int( | |
4978 ( | |
4979 self.defsize | |
4980 - (self.Hmatrixori + j / self.Hmatrixwid) | |
4981 ) | |
4982 * sizeratio | |
4983 ) | |
4984 - l, | |
4985 ) | |
4986 | |
4987 def writeI(self, x, y, size, ital, bold, sans, rotate): | |
4988 xpos = x | |
4989 sizeratio = size * 1.0 / self.defsize | |
4990 sizeint = (size - 1) / self.defsize + 1 | |
4991 if bold: | |
4992 sizeint = sizeint + 2 + int(sizeratio) | |
4993 charstring = binar(self.Imatrix) | |
4994 charstring = ( | |
4995 self.Imatrixwid * self.Imatrixhei - len(charstring) | |
4996 ) * "0" + charstring | |
4997 if len(charstring) > self.Imatrixwid * self.Imatrixhei: | |
4998 charstring = charstring[0 - self.Imatrixwid * self.Imatrixhei :] | |
4999 for i in range(0, len(charstring), self.Imatrixwid): | |
5000 for j in range(i, i + self.Imatrixwid): | |
5001 if charstring[j] == "1": | |
5002 for k in range(sizeint): | |
5003 for l in range(sizeint): | |
5004 if ital and rotate == -1: | |
5005 x = ( | |
5006 xpos | |
5007 + ( | |
5008 int( | |
5009 ( | |
5010 ( | |
5011 self.Imatrixori | |
5012 - self.Imatrixwid | |
5013 + j / self.Imatrixwid | |
5014 ) | |
5015 ) | |
5016 * sizeratio | |
5017 ) | |
5018 - l | |
5019 ) | |
5020 / 3 | |
5021 ) | |
5022 elif ital: | |
5023 x = ( | |
5024 xpos | |
5025 + ( | |
5026 int( | |
5027 ( | |
5028 self.defsize | |
5029 - ( | |
5030 self.Imatrixori | |
5031 + j / self.Imatrixwid | |
5032 ) | |
5033 ) | |
5034 * sizeratio | |
5035 ) | |
5036 - l | |
5037 ) | |
5038 / 3 | |
5039 ) | |
5040 if rotate == 1: | |
5041 self.plotPoint( | |
5042 y | |
5043 + int( | |
5044 (self.Imatrixori + j / self.Imatrixwid) | |
5045 * sizeratio | |
5046 ) | |
5047 - l | |
5048 - self.defsize, | |
5049 x + int((j % self.Imatrixwid) * sizeratio) - k, | |
5050 ) | |
5051 elif rotate == -1: | |
5052 self.plotPoint( | |
5053 y | |
5054 + int( | |
5055 ( | |
5056 self.defsize | |
5057 - (self.Imatrixori + j / self.Imatrixwid) | |
5058 ) | |
5059 * sizeratio | |
5060 ) | |
5061 - l, | |
5062 2 * x | |
5063 - (x + int((j % self.Imatrixwid) * sizeratio) - k), | |
5064 ) | |
5065 else: | |
5066 self.plotPoint( | |
5067 x + int((j % self.Imatrixwid) * sizeratio) - k, | |
5068 y | |
5069 + int( | |
5070 ( | |
5071 self.defsize | |
5072 - (self.Imatrixori + j / self.Imatrixwid) | |
5073 ) | |
5074 * sizeratio | |
5075 ) | |
5076 - l, | |
5077 ) | |
5078 | |
5079 def writeJ(self, x, y, size, ital, bold, sans, rotate): | |
5080 xpos = x | |
5081 sizeratio = size * 1.0 / self.defsize | |
5082 sizeint = (size - 1) / self.defsize + 1 | |
5083 if bold: | |
5084 sizeint = sizeint + 2 + int(sizeratio) | |
5085 charstring = binar(self.Jmatrix) | |
5086 charstring = ( | |
5087 self.Jmatrixwid * self.Jmatrixhei - len(charstring) | |
5088 ) * "0" + charstring | |
5089 if len(charstring) > self.Jmatrixwid * self.Jmatrixhei: | |
5090 charstring = charstring[0 - self.Jmatrixwid * self.Jmatrixhei :] | |
5091 for i in range(0, len(charstring), self.Jmatrixwid): | |
5092 for j in range(i, i + self.Jmatrixwid): | |
5093 if charstring[j] == "1": | |
5094 for k in range(sizeint): | |
5095 for l in range(sizeint): | |
5096 if ital and rotate == -1: | |
5097 x = ( | |
5098 xpos | |
5099 + ( | |
5100 int( | |
5101 ( | |
5102 ( | |
5103 self.Jmatrixori | |
5104 - self.Jmatrixwid | |
5105 + j / self.Jmatrixwid | |
5106 ) | |
5107 ) | |
5108 * sizeratio | |
5109 ) | |
5110 - l | |
5111 ) | |
5112 / 3 | |
5113 ) | |
5114 elif ital: | |
5115 x = ( | |
5116 xpos | |
5117 + ( | |
5118 int( | |
5119 ( | |
5120 self.defsize | |
5121 - ( | |
5122 self.Jmatrixori | |
5123 + j / self.Jmatrixwid | |
5124 ) | |
5125 ) | |
5126 * sizeratio | |
5127 ) | |
5128 - l | |
5129 ) | |
5130 / 3 | |
5131 ) | |
5132 if rotate == 1: | |
5133 self.plotPoint( | |
5134 y | |
5135 + int( | |
5136 (self.Jmatrixori + j / self.Jmatrixwid) | |
5137 * sizeratio | |
5138 ) | |
5139 - l | |
5140 - self.defsize, | |
5141 x + int((j % self.Jmatrixwid) * sizeratio) - k, | |
5142 ) | |
5143 elif rotate == -1: | |
5144 self.plotPoint( | |
5145 y | |
5146 + int( | |
5147 ( | |
5148 self.defsize | |
5149 - (self.Jmatrixori + j / self.Jmatrixwid) | |
5150 ) | |
5151 * sizeratio | |
5152 ) | |
5153 - l, | |
5154 2 * x | |
5155 - (x + int((j % self.Jmatrixwid) * sizeratio) - k), | |
5156 ) | |
5157 else: | |
5158 self.plotPoint( | |
5159 x + int((j % self.Jmatrixwid) * sizeratio) - k, | |
5160 y | |
5161 + int( | |
5162 ( | |
5163 self.defsize | |
5164 - (self.Jmatrixori + j / self.Jmatrixwid) | |
5165 ) | |
5166 * sizeratio | |
5167 ) | |
5168 - l, | |
5169 ) | |
5170 | |
5171 def writeK(self, x, y, size, ital, bold, sans, rotate): | |
5172 xpos = x | |
5173 sizeratio = size * 1.0 / self.defsize | |
5174 sizeint = (size - 1) / self.defsize + 1 | |
5175 if bold: | |
5176 sizeint = sizeint + 2 + int(sizeratio) | |
5177 charstring = binar(self.Kmatrix) | |
5178 charstring = ( | |
5179 self.Kmatrixwid * self.Kmatrixhei - len(charstring) | |
5180 ) * "0" + charstring | |
5181 if len(charstring) > self.Kmatrixwid * self.Kmatrixhei: | |
5182 charstring = charstring[0 - self.Kmatrixwid * self.Kmatrixhei :] | |
5183 for i in range(0, len(charstring), self.Kmatrixwid): | |
5184 for j in range(i, i + self.Kmatrixwid): | |
5185 if charstring[j] == "1": | |
5186 for k in range(sizeint): | |
5187 for l in range(sizeint): | |
5188 if ital and rotate == -1: | |
5189 x = ( | |
5190 xpos | |
5191 + ( | |
5192 int( | |
5193 ( | |
5194 ( | |
5195 self.Kmatrixori | |
5196 - self.Kmatrixwid | |
5197 + j / self.Kmatrixwid | |
5198 ) | |
5199 ) | |
5200 * sizeratio | |
5201 ) | |
5202 - l | |
5203 ) | |
5204 / 3 | |
5205 ) | |
5206 elif ital: | |
5207 x = ( | |
5208 xpos | |
5209 + ( | |
5210 int( | |
5211 ( | |
5212 self.defsize | |
5213 - ( | |
5214 self.Kmatrixori | |
5215 + j / self.Kmatrixwid | |
5216 ) | |
5217 ) | |
5218 * sizeratio | |
5219 ) | |
5220 - l | |
5221 ) | |
5222 / 3 | |
5223 ) | |
5224 if rotate == 1: | |
5225 self.plotPoint( | |
5226 y | |
5227 + int( | |
5228 (self.Kmatrixori + j / self.Kmatrixwid) | |
5229 * sizeratio | |
5230 ) | |
5231 - l | |
5232 - self.defsize, | |
5233 x + int((j % self.Kmatrixwid) * sizeratio) - k, | |
5234 ) | |
5235 elif rotate == -1: | |
5236 self.plotPoint( | |
5237 y | |
5238 + int( | |
5239 ( | |
5240 self.defsize | |
5241 - (self.Kmatrixori + j / self.Kmatrixwid) | |
5242 ) | |
5243 * sizeratio | |
5244 ) | |
5245 - l, | |
5246 2 * x | |
5247 - (x + int((j % self.Kmatrixwid) * sizeratio) - k), | |
5248 ) | |
5249 else: | |
5250 self.plotPoint( | |
5251 x + int((j % self.Kmatrixwid) * sizeratio) - k, | |
5252 y | |
5253 + int( | |
5254 ( | |
5255 self.defsize | |
5256 - (self.Kmatrixori + j / self.Kmatrixwid) | |
5257 ) | |
5258 * sizeratio | |
5259 ) | |
5260 - l, | |
5261 ) | |
5262 | |
5263 def writeL(self, x, y, size, ital, bold, sans, rotate): | |
5264 xpos = x | |
5265 sizeratio = size * 1.0 / self.defsize | |
5266 sizeint = (size - 1) / self.defsize + 1 | |
5267 if bold: | |
5268 sizeint = sizeint + 2 + int(sizeratio) | |
5269 charstring = binar(self.Lmatrix) | |
5270 charstring = ( | |
5271 self.Lmatrixwid * self.Lmatrixhei - len(charstring) | |
5272 ) * "0" + charstring | |
5273 if len(charstring) > self.Lmatrixwid * self.Lmatrixhei: | |
5274 charstring = charstring[0 - self.Lmatrixwid * self.Lmatrixhei :] | |
5275 for i in range(0, len(charstring), self.Lmatrixwid): | |
5276 for j in range(i, i + self.Lmatrixwid): | |
5277 if charstring[j] == "1": | |
5278 for k in range(sizeint): | |
5279 for l in range(sizeint): | |
5280 if ital and rotate == -1: | |
5281 x = ( | |
5282 xpos | |
5283 + ( | |
5284 int( | |
5285 ( | |
5286 ( | |
5287 self.Lmatrixori | |
5288 - self.Lmatrixwid | |
5289 + j / self.Lmatrixwid | |
5290 ) | |
5291 ) | |
5292 * sizeratio | |
5293 ) | |
5294 - l | |
5295 ) | |
5296 / 3 | |
5297 ) | |
5298 elif ital: | |
5299 x = ( | |
5300 xpos | |
5301 + ( | |
5302 int( | |
5303 ( | |
5304 self.defsize | |
5305 - ( | |
5306 self.Lmatrixori | |
5307 + j / self.Lmatrixwid | |
5308 ) | |
5309 ) | |
5310 * sizeratio | |
5311 ) | |
5312 - l | |
5313 ) | |
5314 / 3 | |
5315 ) | |
5316 if rotate == 1: | |
5317 self.plotPoint( | |
5318 y | |
5319 + int( | |
5320 (self.Lmatrixori + j / self.Lmatrixwid) | |
5321 * sizeratio | |
5322 ) | |
5323 - l | |
5324 - self.defsize, | |
5325 x + int((j % self.Lmatrixwid) * sizeratio) - k, | |
5326 ) | |
5327 elif rotate == -1: | |
5328 self.plotPoint( | |
5329 y | |
5330 + int( | |
5331 ( | |
5332 self.defsize | |
5333 - (self.Lmatrixori + j / self.Lmatrixwid) | |
5334 ) | |
5335 * sizeratio | |
5336 ) | |
5337 - l, | |
5338 2 * x | |
5339 - (x + int((j % self.Lmatrixwid) * sizeratio) - k), | |
5340 ) | |
5341 else: | |
5342 self.plotPoint( | |
5343 x + int((j % self.Lmatrixwid) * sizeratio) - k, | |
5344 y | |
5345 + int( | |
5346 ( | |
5347 self.defsize | |
5348 - (self.Lmatrixori + j / self.Lmatrixwid) | |
5349 ) | |
5350 * sizeratio | |
5351 ) | |
5352 - l, | |
5353 ) | |
5354 | |
5355 def writeM(self, x, y, size, ital, bold, sans, rotate): | |
5356 xpos = x | |
5357 sizeratio = size * 1.0 / self.defsize | |
5358 sizeint = (size - 1) / self.defsize + 1 | |
5359 if bold: | |
5360 sizeint = sizeint + 2 + int(sizeratio) | |
5361 charstring = binar(self.Mmatrix) | |
5362 charstring = ( | |
5363 self.Mmatrixwid * self.Mmatrixhei - len(charstring) | |
5364 ) * "0" + charstring | |
5365 if len(charstring) > self.Mmatrixwid * self.Mmatrixhei: | |
5366 charstring = charstring[0 - self.Mmatrixwid * self.Mmatrixhei :] | |
5367 for i in range(0, len(charstring), self.Mmatrixwid): | |
5368 for j in range(i, i + self.Mmatrixwid): | |
5369 if charstring[j] == "1": | |
5370 for k in range(sizeint): | |
5371 for l in range(sizeint): | |
5372 if ital and rotate == -1: | |
5373 x = ( | |
5374 xpos | |
5375 + ( | |
5376 int( | |
5377 ( | |
5378 ( | |
5379 self.Mmatrixori | |
5380 - self.Mmatrixwid | |
5381 + j / self.Mmatrixwid | |
5382 ) | |
5383 ) | |
5384 * sizeratio | |
5385 ) | |
5386 - l | |
5387 ) | |
5388 / 3 | |
5389 ) | |
5390 elif ital: | |
5391 x = ( | |
5392 xpos | |
5393 + ( | |
5394 int( | |
5395 ( | |
5396 self.defsize | |
5397 - ( | |
5398 self.Mmatrixori | |
5399 + j / self.Mmatrixwid | |
5400 ) | |
5401 ) | |
5402 * sizeratio | |
5403 ) | |
5404 - l | |
5405 ) | |
5406 / 3 | |
5407 ) | |
5408 if rotate == 1: | |
5409 self.plotPoint( | |
5410 y | |
5411 + int( | |
5412 (self.Mmatrixori + j / self.Mmatrixwid) | |
5413 * sizeratio | |
5414 ) | |
5415 - l | |
5416 - self.defsize, | |
5417 x + int((j % self.Mmatrixwid) * sizeratio) - k, | |
5418 ) | |
5419 elif rotate == -1: | |
5420 self.plotPoint( | |
5421 y | |
5422 + int( | |
5423 ( | |
5424 self.defsize | |
5425 - (self.Mmatrixori + j / self.Mmatrixwid) | |
5426 ) | |
5427 * sizeratio | |
5428 ) | |
5429 - l, | |
5430 2 * x | |
5431 - (x + int((j % self.Mmatrixwid) * sizeratio) - k), | |
5432 ) | |
5433 else: | |
5434 self.plotPoint( | |
5435 x + int((j % self.Mmatrixwid) * sizeratio) - k, | |
5436 y | |
5437 + int( | |
5438 ( | |
5439 self.defsize | |
5440 - (self.Mmatrixori + j / self.Mmatrixwid) | |
5441 ) | |
5442 * sizeratio | |
5443 ) | |
5444 - l, | |
5445 ) | |
5446 | |
5447 def writeN(self, x, y, size, ital, bold, sans, rotate): | |
5448 xpos = x | |
5449 sizeratio = size * 1.0 / self.defsize | |
5450 sizeint = (size - 1) / self.defsize + 1 | |
5451 if bold: | |
5452 sizeint = sizeint + 2 + int(sizeratio) | |
5453 charstring = binar(self.Nmatrix) | |
5454 charstring = ( | |
5455 self.Nmatrixwid * self.Nmatrixhei - len(charstring) | |
5456 ) * "0" + charstring | |
5457 if len(charstring) > self.Nmatrixwid * self.Nmatrixhei: | |
5458 charstring = charstring[0 - self.Nmatrixwid * self.Nmatrixhei :] | |
5459 for i in range(0, len(charstring), self.Nmatrixwid): | |
5460 for j in range(i, i + self.Nmatrixwid): | |
5461 if charstring[j] == "1": | |
5462 for k in range(sizeint): | |
5463 for l in range(sizeint): | |
5464 if ital and rotate == -1: | |
5465 x = ( | |
5466 xpos | |
5467 + ( | |
5468 int( | |
5469 ( | |
5470 ( | |
5471 self.Nmatrixori | |
5472 - self.Nmatrixwid | |
5473 + j / self.Nmatrixwid | |
5474 ) | |
5475 ) | |
5476 * sizeratio | |
5477 ) | |
5478 - l | |
5479 ) | |
5480 / 3 | |
5481 ) | |
5482 elif ital: | |
5483 x = ( | |
5484 xpos | |
5485 + ( | |
5486 int( | |
5487 ( | |
5488 self.defsize | |
5489 - ( | |
5490 self.Nmatrixori | |
5491 + j / self.Nmatrixwid | |
5492 ) | |
5493 ) | |
5494 * sizeratio | |
5495 ) | |
5496 - l | |
5497 ) | |
5498 / 3 | |
5499 ) | |
5500 if rotate == 1: | |
5501 self.plotPoint( | |
5502 y | |
5503 + int( | |
5504 (self.Nmatrixori + j / self.Nmatrixwid) | |
5505 * sizeratio | |
5506 ) | |
5507 - l | |
5508 - self.defsize, | |
5509 x + int((j % self.Nmatrixwid) * sizeratio) - k, | |
5510 ) | |
5511 elif rotate == -1: | |
5512 self.plotPoint( | |
5513 y | |
5514 + int( | |
5515 ( | |
5516 self.defsize | |
5517 - (self.Nmatrixori + j / self.Nmatrixwid) | |
5518 ) | |
5519 * sizeratio | |
5520 ) | |
5521 - l, | |
5522 2 * x | |
5523 - (x + int((j % self.Nmatrixwid) * sizeratio) - k), | |
5524 ) | |
5525 else: | |
5526 self.plotPoint( | |
5527 x + int((j % self.Nmatrixwid) * sizeratio) - k, | |
5528 y | |
5529 + int( | |
5530 ( | |
5531 self.defsize | |
5532 - (self.Nmatrixori + j / self.Nmatrixwid) | |
5533 ) | |
5534 * sizeratio | |
5535 ) | |
5536 - l, | |
5537 ) | |
5538 | |
5539 def writeO(self, x, y, size, ital, bold, sans, rotate): | |
5540 xpos = x | |
5541 sizeratio = size * 1.0 / self.defsize | |
5542 sizeint = (size - 1) / self.defsize + 1 | |
5543 if bold: | |
5544 sizeint = sizeint + 2 + int(sizeratio) | |
5545 charstring = binar(self.Omatrix) | |
5546 charstring = ( | |
5547 self.Omatrixwid * self.Omatrixhei - len(charstring) | |
5548 ) * "0" + charstring | |
5549 if len(charstring) > self.Omatrixwid * self.Omatrixhei: | |
5550 charstring = charstring[0 - self.Omatrixwid * self.Omatrixhei :] | |
5551 for i in range(0, len(charstring), self.Omatrixwid): | |
5552 for j in range(i, i + self.Omatrixwid): | |
5553 if charstring[j] == "1": | |
5554 for k in range(sizeint): | |
5555 for l in range(sizeint): | |
5556 if ital and rotate == -1: | |
5557 x = ( | |
5558 xpos | |
5559 + ( | |
5560 int( | |
5561 ( | |
5562 ( | |
5563 self.Omatrixori | |
5564 - self.Omatrixwid | |
5565 + j / self.Omatrixwid | |
5566 ) | |
5567 ) | |
5568 * sizeratio | |
5569 ) | |
5570 - l | |
5571 ) | |
5572 / 3 | |
5573 ) | |
5574 elif ital: | |
5575 x = ( | |
5576 xpos | |
5577 + ( | |
5578 int( | |
5579 ( | |
5580 self.defsize | |
5581 - ( | |
5582 self.Omatrixori | |
5583 + j / self.Omatrixwid | |
5584 ) | |
5585 ) | |
5586 * sizeratio | |
5587 ) | |
5588 - l | |
5589 ) | |
5590 / 3 | |
5591 ) | |
5592 if rotate == 1: | |
5593 self.plotPoint( | |
5594 y | |
5595 + int( | |
5596 (self.Omatrixori + j / self.Omatrixwid) | |
5597 * sizeratio | |
5598 ) | |
5599 - l | |
5600 - self.defsize, | |
5601 x + int((j % self.Omatrixwid) * sizeratio) - k, | |
5602 ) | |
5603 elif rotate == -1: | |
5604 self.plotPoint( | |
5605 y | |
5606 + int( | |
5607 ( | |
5608 self.defsize | |
5609 - (self.Omatrixori + j / self.Omatrixwid) | |
5610 ) | |
5611 * sizeratio | |
5612 ) | |
5613 - l, | |
5614 2 * x | |
5615 - (x + int((j % self.Omatrixwid) * sizeratio) - k), | |
5616 ) | |
5617 else: | |
5618 self.plotPoint( | |
5619 x + int((j % self.Omatrixwid) * sizeratio) - k, | |
5620 y | |
5621 + int( | |
5622 ( | |
5623 self.defsize | |
5624 - (self.Omatrixori + j / self.Omatrixwid) | |
5625 ) | |
5626 * sizeratio | |
5627 ) | |
5628 - l, | |
5629 ) | |
5630 | |
5631 def writeP(self, x, y, size, ital, bold, sans, rotate): | |
5632 xpos = x | |
5633 sizeratio = size * 1.0 / self.defsize | |
5634 sizeint = (size - 1) / self.defsize + 1 | |
5635 if bold: | |
5636 sizeint = sizeint + 2 + int(sizeratio) | |
5637 charstring = binar(self.Pmatrix) | |
5638 charstring = ( | |
5639 self.Pmatrixwid * self.Pmatrixhei - len(charstring) | |
5640 ) * "0" + charstring | |
5641 if len(charstring) > self.Pmatrixwid * self.Pmatrixhei: | |
5642 charstring = charstring[0 - self.Pmatrixwid * self.Pmatrixhei :] | |
5643 for i in range(0, len(charstring), self.Pmatrixwid): | |
5644 for j in range(i, i + self.Pmatrixwid): | |
5645 if charstring[j] == "1": | |
5646 for k in range(sizeint): | |
5647 for l in range(sizeint): | |
5648 if ital and rotate == -1: | |
5649 x = ( | |
5650 xpos | |
5651 + ( | |
5652 int( | |
5653 ( | |
5654 ( | |
5655 self.Pmatrixori | |
5656 - self.Pmatrixwid | |
5657 + j / self.Pmatrixwid | |
5658 ) | |
5659 ) | |
5660 * sizeratio | |
5661 ) | |
5662 - l | |
5663 ) | |
5664 / 3 | |
5665 ) | |
5666 elif ital: | |
5667 x = ( | |
5668 xpos | |
5669 + ( | |
5670 int( | |
5671 ( | |
5672 self.defsize | |
5673 - ( | |
5674 self.Pmatrixori | |
5675 + j / self.Pmatrixwid | |
5676 ) | |
5677 ) | |
5678 * sizeratio | |
5679 ) | |
5680 - l | |
5681 ) | |
5682 / 3 | |
5683 ) | |
5684 if rotate == 1: | |
5685 self.plotPoint( | |
5686 y | |
5687 + int( | |
5688 (self.Pmatrixori + j / self.Pmatrixwid) | |
5689 * sizeratio | |
5690 ) | |
5691 - l | |
5692 - self.defsize, | |
5693 x + int((j % self.Pmatrixwid) * sizeratio) - k, | |
5694 ) | |
5695 elif rotate == -1: | |
5696 self.plotPoint( | |
5697 y | |
5698 + int( | |
5699 ( | |
5700 self.defsize | |
5701 - (self.Pmatrixori + j / self.Pmatrixwid) | |
5702 ) | |
5703 * sizeratio | |
5704 ) | |
5705 - l, | |
5706 2 * x | |
5707 - (x + int((j % self.Pmatrixwid) * sizeratio) - k), | |
5708 ) | |
5709 else: | |
5710 self.plotPoint( | |
5711 x + int((j % self.Pmatrixwid) * sizeratio) - k, | |
5712 y | |
5713 + int( | |
5714 ( | |
5715 self.defsize | |
5716 - (self.Pmatrixori + j / self.Pmatrixwid) | |
5717 ) | |
5718 * sizeratio | |
5719 ) | |
5720 - l, | |
5721 ) | |
5722 | |
5723 def writeQ(self, x, y, size, ital, bold, sans, rotate): | |
5724 xpos = x | |
5725 sizeratio = size * 1.0 / self.defsize | |
5726 sizeint = (size - 1) / self.defsize + 1 | |
5727 if bold: | |
5728 sizeint = sizeint + 2 + int(sizeratio) | |
5729 charstring = binar(self.Qmatrix) | |
5730 charstring = ( | |
5731 self.Qmatrixwid * self.Qmatrixhei - len(charstring) | |
5732 ) * "0" + charstring | |
5733 if len(charstring) > self.Qmatrixwid * self.Qmatrixhei: | |
5734 charstring = charstring[0 - self.Qmatrixwid * self.Qmatrixhei :] | |
5735 for i in range(0, len(charstring), self.Qmatrixwid): | |
5736 for j in range(i, i + self.Qmatrixwid): | |
5737 if charstring[j] == "1": | |
5738 for k in range(sizeint): | |
5739 for l in range(sizeint): | |
5740 if ital and rotate == -1: | |
5741 x = ( | |
5742 xpos | |
5743 + ( | |
5744 int( | |
5745 ( | |
5746 ( | |
5747 self.Qmatrixori | |
5748 - self.Qmatrixwid | |
5749 + j / self.Qmatrixwid | |
5750 ) | |
5751 ) | |
5752 * sizeratio | |
5753 ) | |
5754 - l | |
5755 ) | |
5756 / 3 | |
5757 ) | |
5758 elif ital: | |
5759 x = ( | |
5760 xpos | |
5761 + ( | |
5762 int( | |
5763 ( | |
5764 self.defsize | |
5765 - ( | |
5766 self.Qmatrixori | |
5767 + j / self.Qmatrixwid | |
5768 ) | |
5769 ) | |
5770 * sizeratio | |
5771 ) | |
5772 - l | |
5773 ) | |
5774 / 3 | |
5775 ) | |
5776 if rotate == 1: | |
5777 self.plotPoint( | |
5778 y | |
5779 + int( | |
5780 (self.Qmatrixori + j / self.Qmatrixwid) | |
5781 * sizeratio | |
5782 ) | |
5783 - l | |
5784 - self.defsize, | |
5785 x + int((j % self.Qmatrixwid) * sizeratio) - k, | |
5786 ) | |
5787 elif rotate == -1: | |
5788 self.plotPoint( | |
5789 y | |
5790 + int( | |
5791 ( | |
5792 self.defsize | |
5793 - (self.Qmatrixori + j / self.Qmatrixwid) | |
5794 ) | |
5795 * sizeratio | |
5796 ) | |
5797 - l, | |
5798 2 * x | |
5799 - (x + int((j % self.Qmatrixwid) * sizeratio) - k), | |
5800 ) | |
5801 else: | |
5802 self.plotPoint( | |
5803 x + int((j % self.Qmatrixwid) * sizeratio) - k, | |
5804 y | |
5805 + int( | |
5806 ( | |
5807 self.defsize | |
5808 - (self.Qmatrixori + j / self.Qmatrixwid) | |
5809 ) | |
5810 * sizeratio | |
5811 ) | |
5812 - l, | |
5813 ) | |
5814 | |
5815 def writeR(self, x, y, size, ital, bold, sans, rotate): | |
5816 xpos = x | |
5817 sizeratio = size * 1.0 / self.defsize | |
5818 sizeint = (size - 1) / self.defsize + 1 | |
5819 if bold: | |
5820 sizeint = sizeint + 2 + int(sizeratio) | |
5821 charstring = binar(self.Rmatrix) | |
5822 charstring = ( | |
5823 self.Rmatrixwid * self.Rmatrixhei - len(charstring) | |
5824 ) * "0" + charstring | |
5825 if len(charstring) > self.Rmatrixwid * self.Rmatrixhei: | |
5826 charstring = charstring[0 - self.Rmatrixwid * self.Rmatrixhei :] | |
5827 for i in range(0, len(charstring), self.Rmatrixwid): | |
5828 for j in range(i, i + self.Rmatrixwid): | |
5829 if charstring[j] == "1": | |
5830 for k in range(sizeint): | |
5831 for l in range(sizeint): | |
5832 if ital and rotate == -1: | |
5833 x = ( | |
5834 xpos | |
5835 + ( | |
5836 int( | |
5837 ( | |
5838 ( | |
5839 self.Rmatrixori | |
5840 - self.Rmatrixwid | |
5841 + j / self.Rmatrixwid | |
5842 ) | |
5843 ) | |
5844 * sizeratio | |
5845 ) | |
5846 - l | |
5847 ) | |
5848 / 3 | |
5849 ) | |
5850 elif ital: | |
5851 x = ( | |
5852 xpos | |
5853 + ( | |
5854 int( | |
5855 ( | |
5856 self.defsize | |
5857 - ( | |
5858 self.Rmatrixori | |
5859 + j / self.Rmatrixwid | |
5860 ) | |
5861 ) | |
5862 * sizeratio | |
5863 ) | |
5864 - l | |
5865 ) | |
5866 / 3 | |
5867 ) | |
5868 if rotate == 1: | |
5869 self.plotPoint( | |
5870 y | |
5871 + int( | |
5872 (self.Rmatrixori + j / self.Rmatrixwid) | |
5873 * sizeratio | |
5874 ) | |
5875 - l | |
5876 - self.defsize, | |
5877 x + int((j % self.Rmatrixwid) * sizeratio) - k, | |
5878 ) | |
5879 elif rotate == -1: | |
5880 self.plotPoint( | |
5881 y | |
5882 + int( | |
5883 ( | |
5884 self.defsize | |
5885 - (self.Rmatrixori + j / self.Rmatrixwid) | |
5886 ) | |
5887 * sizeratio | |
5888 ) | |
5889 - l, | |
5890 2 * x | |
5891 - (x + int((j % self.Rmatrixwid) * sizeratio) - k), | |
5892 ) | |
5893 else: | |
5894 self.plotPoint( | |
5895 x + int((j % self.Rmatrixwid) * sizeratio) - k, | |
5896 y | |
5897 + int( | |
5898 ( | |
5899 self.defsize | |
5900 - (self.Rmatrixori + j / self.Rmatrixwid) | |
5901 ) | |
5902 * sizeratio | |
5903 ) | |
5904 - l, | |
5905 ) | |
5906 | |
5907 def writeS(self, x, y, size, ital, bold, sans, rotate): | |
5908 xpos = x | |
5909 sizeratio = size * 1.0 / self.defsize | |
5910 sizeint = (size - 1) / self.defsize + 1 | |
5911 if bold: | |
5912 sizeint = sizeint + 2 + int(sizeratio) | |
5913 charstring = binar(self.Smatrix) | |
5914 charstring = ( | |
5915 self.Smatrixwid * self.Smatrixhei - len(charstring) | |
5916 ) * "0" + charstring | |
5917 if len(charstring) > self.Smatrixwid * self.Smatrixhei: | |
5918 charstring = charstring[0 - self.Smatrixwid * self.Smatrixhei :] | |
5919 for i in range(0, len(charstring), self.Smatrixwid): | |
5920 for j in range(i, i + self.Smatrixwid): | |
5921 if charstring[j] == "1": | |
5922 for k in range(sizeint): | |
5923 for l in range(sizeint): | |
5924 if ital and rotate == -1: | |
5925 x = ( | |
5926 xpos | |
5927 + ( | |
5928 int( | |
5929 ( | |
5930 ( | |
5931 self.Smatrixori | |
5932 - self.Smatrixwid | |
5933 + j / self.Smatrixwid | |
5934 ) | |
5935 ) | |
5936 * sizeratio | |
5937 ) | |
5938 - l | |
5939 ) | |
5940 / 3 | |
5941 ) | |
5942 elif ital: | |
5943 x = ( | |
5944 xpos | |
5945 + ( | |
5946 int( | |
5947 ( | |
5948 self.defsize | |
5949 - ( | |
5950 self.Smatrixori | |
5951 + j / self.Smatrixwid | |
5952 ) | |
5953 ) | |
5954 * sizeratio | |
5955 ) | |
5956 - l | |
5957 ) | |
5958 / 3 | |
5959 ) | |
5960 if rotate == 1: | |
5961 self.plotPoint( | |
5962 y | |
5963 + int( | |
5964 (self.Smatrixori + j / self.Smatrixwid) | |
5965 * sizeratio | |
5966 ) | |
5967 - l | |
5968 - self.defsize, | |
5969 x + int((j % self.Smatrixwid) * sizeratio) - k, | |
5970 ) | |
5971 elif rotate == -1: | |
5972 self.plotPoint( | |
5973 y | |
5974 + int( | |
5975 ( | |
5976 self.defsize | |
5977 - (self.Smatrixori + j / self.Smatrixwid) | |
5978 ) | |
5979 * sizeratio | |
5980 ) | |
5981 - l, | |
5982 2 * x | |
5983 - (x + int((j % self.Smatrixwid) * sizeratio) - k), | |
5984 ) | |
5985 else: | |
5986 self.plotPoint( | |
5987 x + int((j % self.Smatrixwid) * sizeratio) - k, | |
5988 y | |
5989 + int( | |
5990 ( | |
5991 self.defsize | |
5992 - (self.Smatrixori + j / self.Smatrixwid) | |
5993 ) | |
5994 * sizeratio | |
5995 ) | |
5996 - l, | |
5997 ) | |
5998 | |
5999 def writeT(self, x, y, size, ital, bold, sans, rotate): | |
6000 xpos = x | |
6001 sizeratio = size * 1.0 / self.defsize | |
6002 sizeint = (size - 1) / self.defsize + 1 | |
6003 if bold: | |
6004 sizeint = sizeint + 2 + int(sizeratio) | |
6005 charstring = binar(self.Tmatrix) | |
6006 charstring = ( | |
6007 self.Tmatrixwid * self.Tmatrixhei - len(charstring) | |
6008 ) * "0" + charstring | |
6009 if len(charstring) > self.Tmatrixwid * self.Tmatrixhei: | |
6010 charstring = charstring[0 - self.Tmatrixwid * self.Tmatrixhei :] | |
6011 for i in range(0, len(charstring), self.Tmatrixwid): | |
6012 for j in range(i, i + self.Tmatrixwid): | |
6013 if charstring[j] == "1": | |
6014 for k in range(sizeint): | |
6015 for l in range(sizeint): | |
6016 if ital and rotate == -1: | |
6017 x = ( | |
6018 xpos | |
6019 + ( | |
6020 int( | |
6021 ( | |
6022 ( | |
6023 self.Tmatrixori | |
6024 - self.Tmatrixwid | |
6025 + j / self.Tmatrixwid | |
6026 ) | |
6027 ) | |
6028 * sizeratio | |
6029 ) | |
6030 - l | |
6031 ) | |
6032 / 3 | |
6033 ) | |
6034 elif ital: | |
6035 x = ( | |
6036 xpos | |
6037 + ( | |
6038 int( | |
6039 ( | |
6040 self.defsize | |
6041 - ( | |
6042 self.Tmatrixori | |
6043 + j / self.Tmatrixwid | |
6044 ) | |
6045 ) | |
6046 * sizeratio | |
6047 ) | |
6048 - l | |
6049 ) | |
6050 / 3 | |
6051 ) | |
6052 if rotate == 1: | |
6053 self.plotPoint( | |
6054 y | |
6055 + int( | |
6056 (self.Tmatrixori + j / self.Tmatrixwid) | |
6057 * sizeratio | |
6058 ) | |
6059 - l | |
6060 - self.defsize, | |
6061 x + int((j % self.Tmatrixwid) * sizeratio) - k, | |
6062 ) | |
6063 elif rotate == -1: | |
6064 self.plotPoint( | |
6065 y | |
6066 + int( | |
6067 ( | |
6068 self.defsize | |
6069 - (self.Tmatrixori + j / self.Tmatrixwid) | |
6070 ) | |
6071 * sizeratio | |
6072 ) | |
6073 - l, | |
6074 2 * x | |
6075 - (x + int((j % self.Tmatrixwid) * sizeratio) - k), | |
6076 ) | |
6077 else: | |
6078 self.plotPoint( | |
6079 x + int((j % self.Tmatrixwid) * sizeratio) - k, | |
6080 y | |
6081 + int( | |
6082 ( | |
6083 self.defsize | |
6084 - (self.Tmatrixori + j / self.Tmatrixwid) | |
6085 ) | |
6086 * sizeratio | |
6087 ) | |
6088 - l, | |
6089 ) | |
6090 | |
6091 def writeU(self, x, y, size, ital, bold, sans, rotate): | |
6092 xpos = x | |
6093 sizeratio = size * 1.0 / self.defsize | |
6094 sizeint = (size - 1) / self.defsize + 1 | |
6095 if bold: | |
6096 sizeint = sizeint + 2 + int(sizeratio) | |
6097 charstring = binar(self.Umatrix) | |
6098 charstring = ( | |
6099 self.Umatrixwid * self.Umatrixhei - len(charstring) | |
6100 ) * "0" + charstring | |
6101 if len(charstring) > self.Umatrixwid * self.Umatrixhei: | |
6102 charstring = charstring[0 - self.Umatrixwid * self.Umatrixhei :] | |
6103 for i in range(0, len(charstring), self.Umatrixwid): | |
6104 for j in range(i, i + self.Umatrixwid): | |
6105 if charstring[j] == "1": | |
6106 for k in range(sizeint): | |
6107 for l in range(sizeint): | |
6108 if ital and rotate == -1: | |
6109 x = ( | |
6110 xpos | |
6111 + ( | |
6112 int( | |
6113 ( | |
6114 ( | |
6115 self.Umatrixori | |
6116 - self.Umatrixwid | |
6117 + j / self.Umatrixwid | |
6118 ) | |
6119 ) | |
6120 * sizeratio | |
6121 ) | |
6122 - l | |
6123 ) | |
6124 / 3 | |
6125 ) | |
6126 elif ital: | |
6127 x = ( | |
6128 xpos | |
6129 + ( | |
6130 int( | |
6131 ( | |
6132 self.defsize | |
6133 - ( | |
6134 self.Umatrixori | |
6135 + j / self.Umatrixwid | |
6136 ) | |
6137 ) | |
6138 * sizeratio | |
6139 ) | |
6140 - l | |
6141 ) | |
6142 / 3 | |
6143 ) | |
6144 if rotate == 1: | |
6145 self.plotPoint( | |
6146 y | |
6147 + int( | |
6148 (self.Umatrixori + j / self.Umatrixwid) | |
6149 * sizeratio | |
6150 ) | |
6151 - l | |
6152 - self.defsize, | |
6153 x + int((j % self.Umatrixwid) * sizeratio) - k, | |
6154 ) | |
6155 elif rotate == -1: | |
6156 self.plotPoint( | |
6157 y | |
6158 + int( | |
6159 ( | |
6160 self.defsize | |
6161 - (self.Umatrixori + j / self.Umatrixwid) | |
6162 ) | |
6163 * sizeratio | |
6164 ) | |
6165 - l, | |
6166 2 * x | |
6167 - (x + int((j % self.Umatrixwid) * sizeratio) - k), | |
6168 ) | |
6169 else: | |
6170 self.plotPoint( | |
6171 x + int((j % self.Umatrixwid) * sizeratio) - k, | |
6172 y | |
6173 + int( | |
6174 ( | |
6175 self.defsize | |
6176 - (self.Umatrixori + j / self.Umatrixwid) | |
6177 ) | |
6178 * sizeratio | |
6179 ) | |
6180 - l, | |
6181 ) | |
6182 | |
6183 def writeV(self, x, y, size, ital, bold, sans, rotate): | |
6184 xpos = x | |
6185 sizeratio = size * 1.0 / self.defsize | |
6186 sizeint = (size - 1) / self.defsize + 1 | |
6187 if bold: | |
6188 sizeint = sizeint + 2 + int(sizeratio) | |
6189 charstring = binar(self.Vmatrix) | |
6190 charstring = ( | |
6191 self.Vmatrixwid * self.Vmatrixhei - len(charstring) | |
6192 ) * "0" + charstring | |
6193 if len(charstring) > self.Vmatrixwid * self.Vmatrixhei: | |
6194 charstring = charstring[0 - self.Vmatrixwid * self.Vmatrixhei :] | |
6195 for i in range(0, len(charstring), self.Vmatrixwid): | |
6196 for j in range(i, i + self.Vmatrixwid): | |
6197 if charstring[j] == "1": | |
6198 for k in range(sizeint): | |
6199 for l in range(sizeint): | |
6200 if ital and rotate == -1: | |
6201 x = ( | |
6202 xpos | |
6203 + ( | |
6204 int( | |
6205 ( | |
6206 ( | |
6207 self.Vmatrixori | |
6208 - self.Vmatrixwid | |
6209 + j / self.Vmatrixwid | |
6210 ) | |
6211 ) | |
6212 * sizeratio | |
6213 ) | |
6214 - l | |
6215 ) | |
6216 / 3 | |
6217 ) | |
6218 elif ital: | |
6219 x = ( | |
6220 xpos | |
6221 + ( | |
6222 int( | |
6223 ( | |
6224 self.defsize | |
6225 - ( | |
6226 self.Vmatrixori | |
6227 + j / self.Vmatrixwid | |
6228 ) | |
6229 ) | |
6230 * sizeratio | |
6231 ) | |
6232 - l | |
6233 ) | |
6234 / 3 | |
6235 ) | |
6236 if rotate == 1: | |
6237 self.plotPoint( | |
6238 y | |
6239 + int( | |
6240 (self.Vmatrixori + j / self.Vmatrixwid) | |
6241 * sizeratio | |
6242 ) | |
6243 - l | |
6244 - self.defsize, | |
6245 x + int((j % self.Vmatrixwid) * sizeratio) - k, | |
6246 ) | |
6247 elif rotate == -1: | |
6248 self.plotPoint( | |
6249 y | |
6250 + int( | |
6251 ( | |
6252 self.defsize | |
6253 - (self.Vmatrixori + j / self.Vmatrixwid) | |
6254 ) | |
6255 * sizeratio | |
6256 ) | |
6257 - l, | |
6258 2 * x | |
6259 - (x + int((j % self.Vmatrixwid) * sizeratio) - k), | |
6260 ) | |
6261 else: | |
6262 self.plotPoint( | |
6263 x + int((j % self.Vmatrixwid) * sizeratio) - k, | |
6264 y | |
6265 + int( | |
6266 ( | |
6267 self.defsize | |
6268 - (self.Vmatrixori + j / self.Vmatrixwid) | |
6269 ) | |
6270 * sizeratio | |
6271 ) | |
6272 - l, | |
6273 ) | |
6274 | |
6275 def writeW(self, x, y, size, ital, bold, sans, rotate): | |
6276 xpos = x | |
6277 sizeratio = size * 1.0 / self.defsize | |
6278 sizeint = (size - 1) / self.defsize + 1 | |
6279 if bold: | |
6280 sizeint = sizeint + 2 + int(sizeratio) | |
6281 charstring = binar(self.Wmatrix) | |
6282 charstring = ( | |
6283 self.Wmatrixwid * self.Wmatrixhei - len(charstring) | |
6284 ) * "0" + charstring | |
6285 if len(charstring) > self.Wmatrixwid * self.Wmatrixhei: | |
6286 charstring = charstring[0 - self.Wmatrixwid * self.Wmatrixhei :] | |
6287 for i in range(0, len(charstring), self.Wmatrixwid): | |
6288 for j in range(i, i + self.Wmatrixwid): | |
6289 if charstring[j] == "1": | |
6290 for k in range(sizeint): | |
6291 for l in range(sizeint): | |
6292 if ital and rotate == -1: | |
6293 x = ( | |
6294 xpos | |
6295 + ( | |
6296 int( | |
6297 ( | |
6298 ( | |
6299 self.Wmatrixori | |
6300 - self.Wmatrixwid | |
6301 + j / self.Wmatrixwid | |
6302 ) | |
6303 ) | |
6304 * sizeratio | |
6305 ) | |
6306 - l | |
6307 ) | |
6308 / 3 | |
6309 ) | |
6310 elif ital: | |
6311 x = ( | |
6312 xpos | |
6313 + ( | |
6314 int( | |
6315 ( | |
6316 self.defsize | |
6317 - ( | |
6318 self.Wmatrixori | |
6319 + j / self.Wmatrixwid | |
6320 ) | |
6321 ) | |
6322 * sizeratio | |
6323 ) | |
6324 - l | |
6325 ) | |
6326 / 3 | |
6327 ) | |
6328 if rotate == 1: | |
6329 self.plotPoint( | |
6330 y | |
6331 + int( | |
6332 (self.Wmatrixori + j / self.Wmatrixwid) | |
6333 * sizeratio | |
6334 ) | |
6335 - l | |
6336 - self.defsize, | |
6337 x + int((j % self.Wmatrixwid) * sizeratio) - k, | |
6338 ) | |
6339 elif rotate == -1: | |
6340 self.plotPoint( | |
6341 y | |
6342 + int( | |
6343 ( | |
6344 self.defsize | |
6345 - (self.Wmatrixori + j / self.Wmatrixwid) | |
6346 ) | |
6347 * sizeratio | |
6348 ) | |
6349 - l, | |
6350 2 * x | |
6351 - (x + int((j % self.Wmatrixwid) * sizeratio) - k), | |
6352 ) | |
6353 else: | |
6354 self.plotPoint( | |
6355 x + int((j % self.Wmatrixwid) * sizeratio) - k, | |
6356 y | |
6357 + int( | |
6358 ( | |
6359 self.defsize | |
6360 - (self.Wmatrixori + j / self.Wmatrixwid) | |
6361 ) | |
6362 * sizeratio | |
6363 ) | |
6364 - l, | |
6365 ) | |
6366 | |
6367 def writeX(self, x, y, size, ital, bold, sans, rotate): | |
6368 xpos = x | |
6369 sizeratio = size * 1.0 / self.defsize | |
6370 sizeint = (size - 1) / self.defsize + 1 | |
6371 if bold: | |
6372 sizeint = sizeint + 2 + int(sizeratio) | |
6373 charstring = binar(self.Xmatrix) | |
6374 charstring = ( | |
6375 self.Xmatrixwid * self.Xmatrixhei - len(charstring) | |
6376 ) * "0" + charstring | |
6377 if len(charstring) > self.Xmatrixwid * self.Xmatrixhei: | |
6378 charstring = charstring[0 - self.Xmatrixwid * self.Xmatrixhei :] | |
6379 for i in range(0, len(charstring), self.Xmatrixwid): | |
6380 for j in range(i, i + self.Xmatrixwid): | |
6381 if charstring[j] == "1": | |
6382 for k in range(sizeint): | |
6383 for l in range(sizeint): | |
6384 if ital and rotate == -1: | |
6385 x = ( | |
6386 xpos | |
6387 + ( | |
6388 int( | |
6389 ( | |
6390 ( | |
6391 self.Xmatrixori | |
6392 - self.Xmatrixwid | |
6393 + j / self.Xmatrixwid | |
6394 ) | |
6395 ) | |
6396 * sizeratio | |
6397 ) | |
6398 - l | |
6399 ) | |
6400 / 3 | |
6401 ) | |
6402 elif ital: | |
6403 x = ( | |
6404 xpos | |
6405 + ( | |
6406 int( | |
6407 ( | |
6408 self.defsize | |
6409 - ( | |
6410 self.Xmatrixori | |
6411 + j / self.Xmatrixwid | |
6412 ) | |
6413 ) | |
6414 * sizeratio | |
6415 ) | |
6416 - l | |
6417 ) | |
6418 / 3 | |
6419 ) | |
6420 if rotate == 1: | |
6421 self.plotPoint( | |
6422 y | |
6423 + int( | |
6424 (self.Xmatrixori + j / self.Xmatrixwid) | |
6425 * sizeratio | |
6426 ) | |
6427 - l | |
6428 - self.defsize, | |
6429 x + int((j % self.Xmatrixwid) * sizeratio) - k, | |
6430 ) | |
6431 elif rotate == -1: | |
6432 self.plotPoint( | |
6433 y | |
6434 + int( | |
6435 ( | |
6436 self.defsize | |
6437 - (self.Xmatrixori + j / self.Xmatrixwid) | |
6438 ) | |
6439 * sizeratio | |
6440 ) | |
6441 - l, | |
6442 2 * x | |
6443 - (x + int((j % self.Xmatrixwid) * sizeratio) - k), | |
6444 ) | |
6445 else: | |
6446 self.plotPoint( | |
6447 x + int((j % self.Xmatrixwid) * sizeratio) - k, | |
6448 y | |
6449 + int( | |
6450 ( | |
6451 self.defsize | |
6452 - (self.Xmatrixori + j / self.Xmatrixwid) | |
6453 ) | |
6454 * sizeratio | |
6455 ) | |
6456 - l, | |
6457 ) | |
6458 | |
6459 def writeY(self, x, y, size, ital, bold, sans, rotate): | |
6460 xpos = x | |
6461 sizeratio = size * 1.0 / self.defsize | |
6462 sizeint = (size - 1) / self.defsize + 1 | |
6463 if bold: | |
6464 sizeint = sizeint + 2 + int(sizeratio) | |
6465 charstring = binar(self.Ymatrix) | |
6466 charstring = ( | |
6467 self.Ymatrixwid * self.Ymatrixhei - len(charstring) | |
6468 ) * "0" + charstring | |
6469 if len(charstring) > self.Ymatrixwid * self.Ymatrixhei: | |
6470 charstring = charstring[0 - self.Ymatrixwid * self.Ymatrixhei :] | |
6471 for i in range(0, len(charstring), self.Ymatrixwid): | |
6472 for j in range(i, i + self.Ymatrixwid): | |
6473 if charstring[j] == "1": | |
6474 for k in range(sizeint): | |
6475 for l in range(sizeint): | |
6476 if ital and rotate == -1: | |
6477 x = ( | |
6478 xpos | |
6479 + ( | |
6480 int( | |
6481 ( | |
6482 ( | |
6483 self.Ymatrixori | |
6484 - self.Ymatrixwid | |
6485 + j / self.Ymatrixwid | |
6486 ) | |
6487 ) | |
6488 * sizeratio | |
6489 ) | |
6490 - l | |
6491 ) | |
6492 / 3 | |
6493 ) | |
6494 elif ital: | |
6495 x = ( | |
6496 xpos | |
6497 + ( | |
6498 int( | |
6499 ( | |
6500 self.defsize | |
6501 - ( | |
6502 self.Ymatrixori | |
6503 + j / self.Ymatrixwid | |
6504 ) | |
6505 ) | |
6506 * sizeratio | |
6507 ) | |
6508 - l | |
6509 ) | |
6510 / 3 | |
6511 ) | |
6512 if rotate == 1: | |
6513 self.plotPoint( | |
6514 y | |
6515 + int( | |
6516 (self.Ymatrixori + j / self.Ymatrixwid) | |
6517 * sizeratio | |
6518 ) | |
6519 - l | |
6520 - self.defsize, | |
6521 x + int((j % self.Ymatrixwid) * sizeratio) - k, | |
6522 ) | |
6523 elif rotate == -1: | |
6524 self.plotPoint( | |
6525 y | |
6526 + int( | |
6527 ( | |
6528 self.defsize | |
6529 - (self.Ymatrixori + j / self.Ymatrixwid) | |
6530 ) | |
6531 * sizeratio | |
6532 ) | |
6533 - l, | |
6534 2 * x | |
6535 - (x + int((j % self.Ymatrixwid) * sizeratio) - k), | |
6536 ) | |
6537 else: | |
6538 self.plotPoint( | |
6539 x + int((j % self.Ymatrixwid) * sizeratio) - k, | |
6540 y | |
6541 + int( | |
6542 ( | |
6543 self.defsize | |
6544 - (self.Ymatrixori + j / self.Ymatrixwid) | |
6545 ) | |
6546 * sizeratio | |
6547 ) | |
6548 - l, | |
6549 ) | |
6550 | |
6551 def writeZ(self, x, y, size, ital, bold, sans, rotate): | |
6552 xpos = x | |
6553 sizeratio = size * 1.0 / self.defsize | |
6554 sizeint = (size - 1) / self.defsize + 1 | |
6555 if bold: | |
6556 sizeint = sizeint + 2 + int(sizeratio) | |
6557 charstring = binar(self.Zmatrix) | |
6558 charstring = ( | |
6559 self.Zmatrixwid * self.Zmatrixhei - len(charstring) | |
6560 ) * "0" + charstring | |
6561 if len(charstring) > self.Zmatrixwid * self.Zmatrixhei: | |
6562 charstring = charstring[0 - self.Zmatrixwid * self.Zmatrixhei :] | |
6563 for i in range(0, len(charstring), self.Zmatrixwid): | |
6564 for j in range(i, i + self.Zmatrixwid): | |
6565 if charstring[j] == "1": | |
6566 for k in range(sizeint): | |
6567 for l in range(sizeint): | |
6568 if ital and rotate == -1: | |
6569 x = ( | |
6570 xpos | |
6571 + ( | |
6572 int( | |
6573 ( | |
6574 ( | |
6575 self.Zmatrixori | |
6576 - self.Zmatrixwid | |
6577 + j / self.Zmatrixwid | |
6578 ) | |
6579 ) | |
6580 * sizeratio | |
6581 ) | |
6582 - l | |
6583 ) | |
6584 / 3 | |
6585 ) | |
6586 elif ital: | |
6587 x = ( | |
6588 xpos | |
6589 + ( | |
6590 int( | |
6591 ( | |
6592 self.defsize | |
6593 - ( | |
6594 self.Zmatrixori | |
6595 + j / self.Zmatrixwid | |
6596 ) | |
6597 ) | |
6598 * sizeratio | |
6599 ) | |
6600 - l | |
6601 ) | |
6602 / 3 | |
6603 ) | |
6604 if rotate == 1: | |
6605 self.plotPoint( | |
6606 y | |
6607 + int( | |
6608 (self.Zmatrixori + j / self.Zmatrixwid) | |
6609 * sizeratio | |
6610 ) | |
6611 - l | |
6612 - self.defsize, | |
6613 x + int((j % self.Zmatrixwid) * sizeratio) - k, | |
6614 ) | |
6615 elif rotate == -1: | |
6616 self.plotPoint( | |
6617 y | |
6618 + int( | |
6619 ( | |
6620 self.defsize | |
6621 - (self.Zmatrixori + j / self.Zmatrixwid) | |
6622 ) | |
6623 * sizeratio | |
6624 ) | |
6625 - l, | |
6626 2 * x | |
6627 - (x + int((j % self.Zmatrixwid) * sizeratio) - k), | |
6628 ) | |
6629 else: | |
6630 self.plotPoint( | |
6631 x + int((j % self.Zmatrixwid) * sizeratio) - k, | |
6632 y | |
6633 + int( | |
6634 ( | |
6635 self.defsize | |
6636 - (self.Zmatrixori + j / self.Zmatrixwid) | |
6637 ) | |
6638 * sizeratio | |
6639 ) | |
6640 - l, | |
6641 ) | |
6642 | |
6643 def writeone(self, x, y, size, ital, bold, sans, rotate): | |
6644 xpos = x | |
6645 sizeratio = size * 1.0 / self.defsize | |
6646 sizeint = (size - 1) / self.defsize + 1 | |
6647 if bold: | |
6648 sizeint = sizeint + 2 + int(sizeratio) | |
6649 charstring = binar(self.onematrix) | |
6650 charstring = ( | |
6651 self.onematrixwid * self.onematrixhei - len(charstring) | |
6652 ) * "0" + charstring | |
6653 if len(charstring) > self.onematrixwid * self.onematrixhei: | |
6654 charstring = charstring[0 - self.onematrixwid * self.onematrixhei :] | |
6655 for i in range(0, len(charstring), self.onematrixwid): | |
6656 for j in range(i, i + self.onematrixwid): | |
6657 if charstring[j] == "1": | |
6658 for k in range(sizeint): | |
6659 for l in range(sizeint): | |
6660 if ital and rotate == -1: | |
6661 x = ( | |
6662 xpos | |
6663 + ( | |
6664 int( | |
6665 ( | |
6666 ( | |
6667 self.onematrixori | |
6668 - self.onematrixwid | |
6669 + j / self.onematrixwid | |
6670 ) | |
6671 ) | |
6672 * sizeratio | |
6673 ) | |
6674 - l | |
6675 ) | |
6676 / 3 | |
6677 ) | |
6678 elif ital: | |
6679 x = ( | |
6680 xpos | |
6681 + ( | |
6682 int( | |
6683 ( | |
6684 self.defsize | |
6685 - ( | |
6686 self.onematrixori | |
6687 + j / self.onematrixwid | |
6688 ) | |
6689 ) | |
6690 * sizeratio | |
6691 ) | |
6692 - l | |
6693 ) | |
6694 / 3 | |
6695 ) | |
6696 if rotate == 1: | |
6697 self.plotPoint( | |
6698 y | |
6699 + int( | |
6700 (self.onematrixori + j / self.onematrixwid) | |
6701 * sizeratio | |
6702 ) | |
6703 - l | |
6704 - self.defsize, | |
6705 x + int((j % self.onematrixwid) * sizeratio) - k, | |
6706 ) | |
6707 elif rotate == -1: | |
6708 self.plotPoint( | |
6709 y | |
6710 + int( | |
6711 ( | |
6712 self.defsize | |
6713 - ( | |
6714 self.onematrixori | |
6715 + j / self.onematrixwid | |
6716 ) | |
6717 ) | |
6718 * sizeratio | |
6719 ) | |
6720 - l, | |
6721 2 * x | |
6722 - ( | |
6723 x + int((j % self.onematrixwid) * sizeratio) - k | |
6724 ), | |
6725 ) | |
6726 else: | |
6727 self.plotPoint( | |
6728 x + int((j % self.onematrixwid) * sizeratio) - k, | |
6729 y | |
6730 + int( | |
6731 ( | |
6732 self.defsize | |
6733 - ( | |
6734 self.onematrixori | |
6735 + j / self.onematrixwid | |
6736 ) | |
6737 ) | |
6738 * sizeratio | |
6739 ) | |
6740 - l, | |
6741 ) | |
6742 | |
6743 def writetwo(self, x, y, size, ital, bold, sans, rotate): | |
6744 xpos = x | |
6745 sizeratio = size * 1.0 / self.defsize | |
6746 sizeint = (size - 1) / self.defsize + 1 | |
6747 if bold: | |
6748 sizeint = sizeint + 2 + int(sizeratio) | |
6749 charstring = binar(self.twomatrix) | |
6750 charstring = ( | |
6751 self.twomatrixwid * self.twomatrixhei - len(charstring) | |
6752 ) * "0" + charstring | |
6753 if len(charstring) > self.twomatrixwid * self.twomatrixhei: | |
6754 charstring = charstring[0 - self.twomatrixwid * self.twomatrixhei :] | |
6755 for i in range(0, len(charstring), self.twomatrixwid): | |
6756 for j in range(i, i + self.twomatrixwid): | |
6757 if charstring[j] == "1": | |
6758 for k in range(sizeint): | |
6759 for l in range(sizeint): | |
6760 if ital and rotate == -1: | |
6761 x = ( | |
6762 xpos | |
6763 + ( | |
6764 int( | |
6765 ( | |
6766 ( | |
6767 self.twomatrixori | |
6768 - self.twomatrixwid | |
6769 + j / self.twomatrixwid | |
6770 ) | |
6771 ) | |
6772 * sizeratio | |
6773 ) | |
6774 - l | |
6775 ) | |
6776 / 3 | |
6777 ) | |
6778 elif ital: | |
6779 x = ( | |
6780 xpos | |
6781 + ( | |
6782 int( | |
6783 ( | |
6784 self.defsize | |
6785 - ( | |
6786 self.twomatrixori | |
6787 + j / self.twomatrixwid | |
6788 ) | |
6789 ) | |
6790 * sizeratio | |
6791 ) | |
6792 - l | |
6793 ) | |
6794 / 3 | |
6795 ) | |
6796 if rotate == 1: | |
6797 self.plotPoint( | |
6798 y | |
6799 + int( | |
6800 (self.twomatrixori + j / self.twomatrixwid) | |
6801 * sizeratio | |
6802 ) | |
6803 - l | |
6804 - self.defsize, | |
6805 x + int((j % self.twomatrixwid) * sizeratio) - k, | |
6806 ) | |
6807 elif rotate == -1: | |
6808 self.plotPoint( | |
6809 y | |
6810 + int( | |
6811 ( | |
6812 self.defsize | |
6813 - ( | |
6814 self.twomatrixori | |
6815 + j / self.twomatrixwid | |
6816 ) | |
6817 ) | |
6818 * sizeratio | |
6819 ) | |
6820 - l, | |
6821 2 * x | |
6822 - ( | |
6823 x + int((j % self.twomatrixwid) * sizeratio) - k | |
6824 ), | |
6825 ) | |
6826 else: | |
6827 self.plotPoint( | |
6828 x + int((j % self.twomatrixwid) * sizeratio) - k, | |
6829 y | |
6830 + int( | |
6831 ( | |
6832 self.defsize | |
6833 - ( | |
6834 self.twomatrixori | |
6835 + j / self.twomatrixwid | |
6836 ) | |
6837 ) | |
6838 * sizeratio | |
6839 ) | |
6840 - l, | |
6841 ) | |
6842 | |
6843 def writethree(self, x, y, size, ital, bold, sans, rotate): | |
6844 xpos = x | |
6845 sizeratio = size * 1.0 / self.defsize | |
6846 sizeint = (size - 1) / self.defsize + 1 | |
6847 if bold: | |
6848 sizeint = sizeint + 2 + int(sizeratio) | |
6849 charstring = binar(self.threematrix) | |
6850 charstring = ( | |
6851 self.threematrixwid * self.threematrixhei - len(charstring) | |
6852 ) * "0" + charstring | |
6853 if len(charstring) > self.threematrixwid * self.threematrixhei: | |
6854 charstring = charstring[0 - self.threematrixwid * self.threematrixhei :] | |
6855 for i in range(0, len(charstring), self.threematrixwid): | |
6856 for j in range(i, i + self.threematrixwid): | |
6857 if charstring[j] == "1": | |
6858 for k in range(sizeint): | |
6859 for l in range(sizeint): | |
6860 if ital and rotate == -1: | |
6861 x = ( | |
6862 xpos | |
6863 + ( | |
6864 int( | |
6865 ( | |
6866 ( | |
6867 self.threematrixori | |
6868 - self.threematrixwid | |
6869 + j / self.threematrixwid | |
6870 ) | |
6871 ) | |
6872 * sizeratio | |
6873 ) | |
6874 - l | |
6875 ) | |
6876 / 3 | |
6877 ) | |
6878 elif ital: | |
6879 x = ( | |
6880 xpos | |
6881 + ( | |
6882 int( | |
6883 ( | |
6884 self.defsize | |
6885 - ( | |
6886 self.threematrixori | |
6887 + j / self.threematrixwid | |
6888 ) | |
6889 ) | |
6890 * sizeratio | |
6891 ) | |
6892 - l | |
6893 ) | |
6894 / 3 | |
6895 ) | |
6896 if rotate == 1: | |
6897 self.plotPoint( | |
6898 y | |
6899 + int( | |
6900 (self.threematrixori + j / self.threematrixwid) | |
6901 * sizeratio | |
6902 ) | |
6903 - l | |
6904 - self.defsize, | |
6905 x + int((j % self.threematrixwid) * sizeratio) - k, | |
6906 ) | |
6907 elif rotate == -1: | |
6908 self.plotPoint( | |
6909 y | |
6910 + int( | |
6911 ( | |
6912 self.defsize | |
6913 - ( | |
6914 self.threematrixori | |
6915 + j / self.threematrixwid | |
6916 ) | |
6917 ) | |
6918 * sizeratio | |
6919 ) | |
6920 - l, | |
6921 2 * x | |
6922 - ( | |
6923 x | |
6924 + int((j % self.threematrixwid) * sizeratio) | |
6925 - k | |
6926 ), | |
6927 ) | |
6928 else: | |
6929 self.plotPoint( | |
6930 x + int((j % self.threematrixwid) * sizeratio) - k, | |
6931 y | |
6932 + int( | |
6933 ( | |
6934 self.defsize | |
6935 - ( | |
6936 self.threematrixori | |
6937 + j / self.threematrixwid | |
6938 ) | |
6939 ) | |
6940 * sizeratio | |
6941 ) | |
6942 - l, | |
6943 ) | |
6944 | |
6945 def writefour(self, x, y, size, ital, bold, sans, rotate): | |
6946 xpos = x | |
6947 sizeratio = size * 1.0 / self.defsize | |
6948 sizeint = (size - 1) / self.defsize + 1 | |
6949 if bold: | |
6950 sizeint = sizeint + 2 + int(sizeratio) | |
6951 charstring = binar(self.fourmatrix) | |
6952 charstring = ( | |
6953 self.fourmatrixwid * self.fourmatrixhei - len(charstring) | |
6954 ) * "0" + charstring | |
6955 if len(charstring) > self.fourmatrixwid * self.fourmatrixhei: | |
6956 charstring = charstring[0 - self.fourmatrixwid * self.fourmatrixhei :] | |
6957 for i in range(0, len(charstring), self.fourmatrixwid): | |
6958 for j in range(i, i + self.fourmatrixwid): | |
6959 if charstring[j] == "1": | |
6960 for k in range(sizeint): | |
6961 for l in range(sizeint): | |
6962 if ital and rotate == -1: | |
6963 x = ( | |
6964 xpos | |
6965 + ( | |
6966 int( | |
6967 ( | |
6968 ( | |
6969 self.fourmatrixori | |
6970 - self.fourmatrixwid | |
6971 + j / self.fourmatrixwid | |
6972 ) | |
6973 ) | |
6974 * sizeratio | |
6975 ) | |
6976 - l | |
6977 ) | |
6978 / 3 | |
6979 ) | |
6980 elif ital: | |
6981 x = ( | |
6982 xpos | |
6983 + ( | |
6984 int( | |
6985 ( | |
6986 self.defsize | |
6987 - ( | |
6988 self.fourmatrixori | |
6989 + j / self.fourmatrixwid | |
6990 ) | |
6991 ) | |
6992 * sizeratio | |
6993 ) | |
6994 - l | |
6995 ) | |
6996 / 3 | |
6997 ) | |
6998 if rotate == 1: | |
6999 self.plotPoint( | |
7000 y | |
7001 + int( | |
7002 (self.fourmatrixori + j / self.fourmatrixwid) | |
7003 * sizeratio | |
7004 ) | |
7005 - l | |
7006 - self.defsize, | |
7007 x + int((j % self.fourmatrixwid) * sizeratio) - k, | |
7008 ) | |
7009 elif rotate == -1: | |
7010 self.plotPoint( | |
7011 y | |
7012 + int( | |
7013 ( | |
7014 self.defsize | |
7015 - ( | |
7016 self.fourmatrixori | |
7017 + j / self.fourmatrixwid | |
7018 ) | |
7019 ) | |
7020 * sizeratio | |
7021 ) | |
7022 - l, | |
7023 2 * x | |
7024 - ( | |
7025 x | |
7026 + int((j % self.fourmatrixwid) * sizeratio) | |
7027 - k | |
7028 ), | |
7029 ) | |
7030 else: | |
7031 self.plotPoint( | |
7032 x + int((j % self.fourmatrixwid) * sizeratio) - k, | |
7033 y | |
7034 + int( | |
7035 ( | |
7036 self.defsize | |
7037 - ( | |
7038 self.fourmatrixori | |
7039 + j / self.fourmatrixwid | |
7040 ) | |
7041 ) | |
7042 * sizeratio | |
7043 ) | |
7044 - l, | |
7045 ) | |
7046 | |
7047 def writefive(self, x, y, size, ital, bold, sans, rotate): | |
7048 xpos = x | |
7049 sizeratio = size * 1.0 / self.defsize | |
7050 sizeint = (size - 1) / self.defsize + 1 | |
7051 if bold: | |
7052 sizeint = sizeint + 2 + int(sizeratio) | |
7053 charstring = binar(self.fivematrix) | |
7054 charstring = ( | |
7055 self.fivematrixwid * self.fivematrixhei - len(charstring) | |
7056 ) * "0" + charstring | |
7057 if len(charstring) > self.fivematrixwid * self.fivematrixhei: | |
7058 charstring = charstring[0 - self.fivematrixwid * self.fivematrixhei :] | |
7059 for i in range(0, len(charstring), self.fivematrixwid): | |
7060 for j in range(i, i + self.fivematrixwid): | |
7061 if charstring[j] == "1": | |
7062 for k in range(sizeint): | |
7063 for l in range(sizeint): | |
7064 if ital and rotate == -1: | |
7065 x = ( | |
7066 xpos | |
7067 + ( | |
7068 int( | |
7069 ( | |
7070 ( | |
7071 self.fivematrixori | |
7072 - self.fivematrixwid | |
7073 + j / self.fivematrixwid | |
7074 ) | |
7075 ) | |
7076 * sizeratio | |
7077 ) | |
7078 - l | |
7079 ) | |
7080 / 3 | |
7081 ) | |
7082 elif ital: | |
7083 x = ( | |
7084 xpos | |
7085 + ( | |
7086 int( | |
7087 ( | |
7088 self.defsize | |
7089 - ( | |
7090 self.fivematrixori | |
7091 + j / self.fivematrixwid | |
7092 ) | |
7093 ) | |
7094 * sizeratio | |
7095 ) | |
7096 - l | |
7097 ) | |
7098 / 3 | |
7099 ) | |
7100 if rotate == 1: | |
7101 self.plotPoint( | |
7102 y | |
7103 + int( | |
7104 (self.fivematrixori + j / self.fivematrixwid) | |
7105 * sizeratio | |
7106 ) | |
7107 - l | |
7108 - self.defsize, | |
7109 x + int((j % self.fivematrixwid) * sizeratio) - k, | |
7110 ) | |
7111 elif rotate == -1: | |
7112 self.plotPoint( | |
7113 y | |
7114 + int( | |
7115 ( | |
7116 self.defsize | |
7117 - ( | |
7118 self.fivematrixori | |
7119 + j / self.fivematrixwid | |
7120 ) | |
7121 ) | |
7122 * sizeratio | |
7123 ) | |
7124 - l, | |
7125 2 * x | |
7126 - ( | |
7127 x | |
7128 + int((j % self.fivematrixwid) * sizeratio) | |
7129 - k | |
7130 ), | |
7131 ) | |
7132 else: | |
7133 self.plotPoint( | |
7134 x + int((j % self.fivematrixwid) * sizeratio) - k, | |
7135 y | |
7136 + int( | |
7137 ( | |
7138 self.defsize | |
7139 - ( | |
7140 self.fivematrixori | |
7141 + j / self.fivematrixwid | |
7142 ) | |
7143 ) | |
7144 * sizeratio | |
7145 ) | |
7146 - l, | |
7147 ) | |
7148 | |
7149 def writesix(self, x, y, size, ital, bold, sans, rotate): | |
7150 xpos = x | |
7151 sizeratio = size * 1.0 / self.defsize | |
7152 sizeint = (size - 1) / self.defsize + 1 | |
7153 if bold: | |
7154 sizeint = sizeint + 2 + int(sizeratio) | |
7155 charstring = binar(self.sixmatrix) | |
7156 charstring = ( | |
7157 self.sixmatrixwid * self.sixmatrixhei - len(charstring) | |
7158 ) * "0" + charstring | |
7159 if len(charstring) > self.sixmatrixwid * self.sixmatrixhei: | |
7160 charstring = charstring[0 - self.sixmatrixwid * self.sixmatrixhei :] | |
7161 for i in range(0, len(charstring), self.sixmatrixwid): | |
7162 for j in range(i, i + self.sixmatrixwid): | |
7163 if charstring[j] == "1": | |
7164 for k in range(sizeint): | |
7165 for l in range(sizeint): | |
7166 if ital and rotate == -1: | |
7167 x = ( | |
7168 xpos | |
7169 + ( | |
7170 int( | |
7171 ( | |
7172 ( | |
7173 self.sixmatrixori | |
7174 - self.sixmatrixwid | |
7175 + j / self.sixmatrixwid | |
7176 ) | |
7177 ) | |
7178 * sizeratio | |
7179 ) | |
7180 - l | |
7181 ) | |
7182 / 3 | |
7183 ) | |
7184 elif ital: | |
7185 x = ( | |
7186 xpos | |
7187 + ( | |
7188 int( | |
7189 ( | |
7190 self.defsize | |
7191 - ( | |
7192 self.sixmatrixori | |
7193 + j / self.sixmatrixwid | |
7194 ) | |
7195 ) | |
7196 * sizeratio | |
7197 ) | |
7198 - l | |
7199 ) | |
7200 / 3 | |
7201 ) | |
7202 if rotate == 1: | |
7203 self.plotPoint( | |
7204 y | |
7205 + int( | |
7206 (self.sixmatrixori + j / self.sixmatrixwid) | |
7207 * sizeratio | |
7208 ) | |
7209 - l | |
7210 - self.defsize, | |
7211 x + int((j % self.sixmatrixwid) * sizeratio) - k, | |
7212 ) | |
7213 elif rotate == -1: | |
7214 self.plotPoint( | |
7215 y | |
7216 + int( | |
7217 ( | |
7218 self.defsize | |
7219 - ( | |
7220 self.sixmatrixori | |
7221 + j / self.sixmatrixwid | |
7222 ) | |
7223 ) | |
7224 * sizeratio | |
7225 ) | |
7226 - l, | |
7227 2 * x | |
7228 - ( | |
7229 x + int((j % self.sixmatrixwid) * sizeratio) - k | |
7230 ), | |
7231 ) | |
7232 else: | |
7233 self.plotPoint( | |
7234 x + int((j % self.sixmatrixwid) * sizeratio) - k, | |
7235 y | |
7236 + int( | |
7237 ( | |
7238 self.defsize | |
7239 - ( | |
7240 self.sixmatrixori | |
7241 + j / self.sixmatrixwid | |
7242 ) | |
7243 ) | |
7244 * sizeratio | |
7245 ) | |
7246 - l, | |
7247 ) | |
7248 | |
7249 def writeseven(self, x, y, size, ital, bold, sans, rotate): | |
7250 xpos = x | |
7251 sizeratio = size * 1.0 / self.defsize | |
7252 sizeint = (size - 1) / self.defsize + 1 | |
7253 if bold: | |
7254 sizeint = sizeint + 2 + int(sizeratio) | |
7255 charstring = binar(self.sevenmatrix) | |
7256 charstring = ( | |
7257 self.sevenmatrixwid * self.sevenmatrixhei - len(charstring) | |
7258 ) * "0" + charstring | |
7259 if len(charstring) > self.sevenmatrixwid * self.sevenmatrixhei: | |
7260 charstring = charstring[0 - self.sevenmatrixwid * self.sevenmatrixhei :] | |
7261 for i in range(0, len(charstring), self.sevenmatrixwid): | |
7262 for j in range(i, i + self.sevenmatrixwid): | |
7263 if charstring[j] == "1": | |
7264 for k in range(sizeint): | |
7265 for l in range(sizeint): | |
7266 if ital and rotate == -1: | |
7267 x = ( | |
7268 xpos | |
7269 + ( | |
7270 int( | |
7271 ( | |
7272 ( | |
7273 self.sevenmatrixori | |
7274 - self.sevenmatrixwid | |
7275 + j / self.sevenmatrixwid | |
7276 ) | |
7277 ) | |
7278 * sizeratio | |
7279 ) | |
7280 - l | |
7281 ) | |
7282 / 3 | |
7283 ) | |
7284 elif ital: | |
7285 x = ( | |
7286 xpos | |
7287 + ( | |
7288 int( | |
7289 ( | |
7290 self.defsize | |
7291 - ( | |
7292 self.sevenmatrixori | |
7293 + j / self.sevenmatrixwid | |
7294 ) | |
7295 ) | |
7296 * sizeratio | |
7297 ) | |
7298 - l | |
7299 ) | |
7300 / 3 | |
7301 ) | |
7302 if rotate == 1: | |
7303 self.plotPoint( | |
7304 y | |
7305 + int( | |
7306 (self.sevenmatrixori + j / self.sevenmatrixwid) | |
7307 * sizeratio | |
7308 ) | |
7309 - l | |
7310 - self.defsize, | |
7311 x + int((j % self.sevenmatrixwid) * sizeratio) - k, | |
7312 ) | |
7313 elif rotate == -1: | |
7314 self.plotPoint( | |
7315 y | |
7316 + int( | |
7317 ( | |
7318 self.defsize | |
7319 - ( | |
7320 self.sevenmatrixori | |
7321 + j / self.sevenmatrixwid | |
7322 ) | |
7323 ) | |
7324 * sizeratio | |
7325 ) | |
7326 - l, | |
7327 2 * x | |
7328 - ( | |
7329 x | |
7330 + int((j % self.sevenmatrixwid) * sizeratio) | |
7331 - k | |
7332 ), | |
7333 ) | |
7334 else: | |
7335 self.plotPoint( | |
7336 x + int((j % self.sevenmatrixwid) * sizeratio) - k, | |
7337 y | |
7338 + int( | |
7339 ( | |
7340 self.defsize | |
7341 - ( | |
7342 self.sevenmatrixori | |
7343 + j / self.sevenmatrixwid | |
7344 ) | |
7345 ) | |
7346 * sizeratio | |
7347 ) | |
7348 - l, | |
7349 ) | |
7350 | |
7351 def writeeight(self, x, y, size, ital, bold, sans, rotate): | |
7352 xpos = x | |
7353 sizeratio = size * 1.0 / self.defsize | |
7354 sizeint = (size - 1) / self.defsize + 1 | |
7355 if bold: | |
7356 sizeint = sizeint + 2 + int(sizeratio) | |
7357 charstring = binar(self.eightmatrix) | |
7358 charstring = ( | |
7359 self.eightmatrixwid * self.eightmatrixhei - len(charstring) | |
7360 ) * "0" + charstring | |
7361 if len(charstring) > self.eightmatrixwid * self.eightmatrixhei: | |
7362 charstring = charstring[0 - self.eightmatrixwid * self.eightmatrixhei :] | |
7363 for i in range(0, len(charstring), self.eightmatrixwid): | |
7364 for j in range(i, i + self.eightmatrixwid): | |
7365 if charstring[j] == "1": | |
7366 for k in range(sizeint): | |
7367 for l in range(sizeint): | |
7368 if ital and rotate == -1: | |
7369 x = ( | |
7370 xpos | |
7371 + ( | |
7372 int( | |
7373 ( | |
7374 ( | |
7375 self.eightmatrixori | |
7376 - self.eightmatrixwid | |
7377 + j / self.eightmatrixwid | |
7378 ) | |
7379 ) | |
7380 * sizeratio | |
7381 ) | |
7382 - l | |
7383 ) | |
7384 / 3 | |
7385 ) | |
7386 elif ital: | |
7387 x = ( | |
7388 xpos | |
7389 + ( | |
7390 int( | |
7391 ( | |
7392 self.defsize | |
7393 - ( | |
7394 self.eightmatrixori | |
7395 + j / self.eightmatrixwid | |
7396 ) | |
7397 ) | |
7398 * sizeratio | |
7399 ) | |
7400 - l | |
7401 ) | |
7402 / 3 | |
7403 ) | |
7404 if rotate == 1: | |
7405 self.plotPoint( | |
7406 y | |
7407 + int( | |
7408 (self.eightmatrixori + j / self.eightmatrixwid) | |
7409 * sizeratio | |
7410 ) | |
7411 - l | |
7412 - self.defsize, | |
7413 x + int((j % self.eightmatrixwid) * sizeratio) - k, | |
7414 ) | |
7415 elif rotate == -1: | |
7416 self.plotPoint( | |
7417 y | |
7418 + int( | |
7419 ( | |
7420 self.defsize | |
7421 - ( | |
7422 self.eightmatrixori | |
7423 + j / self.eightmatrixwid | |
7424 ) | |
7425 ) | |
7426 * sizeratio | |
7427 ) | |
7428 - l, | |
7429 2 * x | |
7430 - ( | |
7431 x | |
7432 + int((j % self.eightmatrixwid) * sizeratio) | |
7433 - k | |
7434 ), | |
7435 ) | |
7436 else: | |
7437 self.plotPoint( | |
7438 x + int((j % self.eightmatrixwid) * sizeratio) - k, | |
7439 y | |
7440 + int( | |
7441 ( | |
7442 self.defsize | |
7443 - ( | |
7444 self.eightmatrixori | |
7445 + j / self.eightmatrixwid | |
7446 ) | |
7447 ) | |
7448 * sizeratio | |
7449 ) | |
7450 - l, | |
7451 ) | |
7452 | |
7453 def writenine(self, x, y, size, ital, bold, sans, rotate): | |
7454 xpos = x | |
7455 sizeratio = size * 1.0 / self.defsize | |
7456 sizeint = (size - 1) / self.defsize + 1 | |
7457 if bold: | |
7458 sizeint = sizeint + 2 + int(sizeratio) | |
7459 charstring = binar(self.ninematrix) | |
7460 charstring = ( | |
7461 self.ninematrixwid * self.ninematrixhei - len(charstring) | |
7462 ) * "0" + charstring | |
7463 if len(charstring) > self.ninematrixwid * self.ninematrixhei: | |
7464 charstring = charstring[0 - self.ninematrixwid * self.ninematrixhei :] | |
7465 for i in range(0, len(charstring), self.ninematrixwid): | |
7466 for j in range(i, i + self.ninematrixwid): | |
7467 if charstring[j] == "1": | |
7468 for k in range(sizeint): | |
7469 for l in range(sizeint): | |
7470 if ital and rotate == -1: | |
7471 x = ( | |
7472 xpos | |
7473 + ( | |
7474 int( | |
7475 ( | |
7476 ( | |
7477 self.ninematrixori | |
7478 - self.ninematrixwid | |
7479 + j / self.ninematrixwid | |
7480 ) | |
7481 ) | |
7482 * sizeratio | |
7483 ) | |
7484 - l | |
7485 ) | |
7486 / 3 | |
7487 ) | |
7488 elif ital: | |
7489 x = ( | |
7490 xpos | |
7491 + ( | |
7492 int( | |
7493 ( | |
7494 self.defsize | |
7495 - ( | |
7496 self.ninematrixori | |
7497 + j / self.ninematrixwid | |
7498 ) | |
7499 ) | |
7500 * sizeratio | |
7501 ) | |
7502 - l | |
7503 ) | |
7504 / 3 | |
7505 ) | |
7506 if rotate == 1: | |
7507 self.plotPoint( | |
7508 y | |
7509 + int( | |
7510 (self.ninematrixori + j / self.ninematrixwid) | |
7511 * sizeratio | |
7512 ) | |
7513 - l | |
7514 - self.defsize, | |
7515 x + int((j % self.ninematrixwid) * sizeratio) - k, | |
7516 ) | |
7517 elif rotate == -1: | |
7518 self.plotPoint( | |
7519 y | |
7520 + int( | |
7521 ( | |
7522 self.defsize | |
7523 - ( | |
7524 self.ninematrixori | |
7525 + j / self.ninematrixwid | |
7526 ) | |
7527 ) | |
7528 * sizeratio | |
7529 ) | |
7530 - l, | |
7531 2 * x | |
7532 - ( | |
7533 x | |
7534 + int((j % self.ninematrixwid) * sizeratio) | |
7535 - k | |
7536 ), | |
7537 ) | |
7538 else: | |
7539 self.plotPoint( | |
7540 x + int((j % self.ninematrixwid) * sizeratio) - k, | |
7541 y | |
7542 + int( | |
7543 ( | |
7544 self.defsize | |
7545 - ( | |
7546 self.ninematrixori | |
7547 + j / self.ninematrixwid | |
7548 ) | |
7549 ) | |
7550 * sizeratio | |
7551 ) | |
7552 - l, | |
7553 ) | |
7554 | |
7555 def writeten(self, x, y, size, ital, bold, sans, rotate): | |
7556 xpos = x | |
7557 sizeratio = size * 1.0 / self.defsize | |
7558 sizeint = (size - 1) / self.defsize + 1 | |
7559 if bold: | |
7560 sizeint = sizeint + 2 + int(sizeratio) | |
7561 charstring = binar(self.tenmatrix) | |
7562 charstring = ( | |
7563 self.tenmatrixwid * self.tenmatrixhei - len(charstring) | |
7564 ) * "0" + charstring | |
7565 if len(charstring) > self.tenmatrixwid * self.tenmatrixhei: | |
7566 charstring = charstring[0 - self.tenmatrixwid * self.tenmatrixhei :] | |
7567 for i in range(0, len(charstring), self.tenmatrixwid): | |
7568 for j in range(i, i + self.tenmatrixwid): | |
7569 if charstring[j] == "1": | |
7570 for k in range(sizeint): | |
7571 for l in range(sizeint): | |
7572 if ital and rotate == -1: | |
7573 x = ( | |
7574 xpos | |
7575 + ( | |
7576 int( | |
7577 ( | |
7578 ( | |
7579 self.tenmatrixori | |
7580 - self.tenmatrixwid | |
7581 + j / self.tenmatrixwid | |
7582 ) | |
7583 ) | |
7584 * sizeratio | |
7585 ) | |
7586 - l | |
7587 ) | |
7588 / 3 | |
7589 ) | |
7590 elif ital: | |
7591 x = ( | |
7592 xpos | |
7593 + ( | |
7594 int( | |
7595 ( | |
7596 self.defsize | |
7597 - ( | |
7598 self.tenmatrixori | |
7599 + j / self.tenmatrixwid | |
7600 ) | |
7601 ) | |
7602 * sizeratio | |
7603 ) | |
7604 - l | |
7605 ) | |
7606 / 3 | |
7607 ) | |
7608 if rotate == 1: | |
7609 self.plotPoint( | |
7610 y | |
7611 + int( | |
7612 (self.tenmatrixori + j / self.tenmatrixwid) | |
7613 * sizeratio | |
7614 ) | |
7615 - l | |
7616 - self.defsize, | |
7617 x + int((j % self.tenmatrixwid) * sizeratio) - k, | |
7618 ) | |
7619 elif rotate == -1: | |
7620 self.plotPoint( | |
7621 y | |
7622 + int( | |
7623 ( | |
7624 self.defsize | |
7625 - ( | |
7626 self.tenmatrixori | |
7627 + j / self.tenmatrixwid | |
7628 ) | |
7629 ) | |
7630 * sizeratio | |
7631 ) | |
7632 - l, | |
7633 2 * x | |
7634 - ( | |
7635 x + int((j % self.tenmatrixwid) * sizeratio) - k | |
7636 ), | |
7637 ) | |
7638 else: | |
7639 self.plotPoint( | |
7640 x + int((j % self.tenmatrixwid) * sizeratio) - k, | |
7641 y | |
7642 + int( | |
7643 ( | |
7644 self.defsize | |
7645 - ( | |
7646 self.tenmatrixori | |
7647 + j / self.tenmatrixwid | |
7648 ) | |
7649 ) | |
7650 * sizeratio | |
7651 ) | |
7652 - l, | |
7653 ) | |
7654 | |
7655 def write_(self, x, y, size, ital, bold, sans, rotate): | |
7656 xpos = x | |
7657 sizeratio = size * 1.0 / self.defsize | |
7658 sizeint = (size - 1) / self.defsize + 1 | |
7659 if bold: | |
7660 sizeint = sizeint + 2 + int(sizeratio) | |
7661 charstring = binar(self._matrix) | |
7662 charstring = ( | |
7663 self._matrixwid * self._matrixhei - len(charstring) | |
7664 ) * "0" + charstring | |
7665 if len(charstring) > self._matrixwid * self._matrixhei: | |
7666 charstring = charstring[0 - self._matrixwid * self._matrixhei :] | |
7667 for i in range(0, len(charstring), self._matrixwid): | |
7668 for j in range(i, i + self._matrixwid): | |
7669 if charstring[j] == "1": | |
7670 for k in range(sizeint): | |
7671 for l in range(sizeint): | |
7672 if ital and rotate == -1: | |
7673 x = ( | |
7674 xpos | |
7675 + ( | |
7676 int( | |
7677 ( | |
7678 ( | |
7679 self._matrixori | |
7680 - self._matrixwid | |
7681 + j / self._matrixwid | |
7682 ) | |
7683 ) | |
7684 * sizeratio | |
7685 ) | |
7686 - l | |
7687 ) | |
7688 / 3 | |
7689 ) | |
7690 elif ital: | |
7691 x = ( | |
7692 xpos | |
7693 + ( | |
7694 int( | |
7695 ( | |
7696 self.defsize | |
7697 - ( | |
7698 self._matrixori | |
7699 + j / self._matrixwid | |
7700 ) | |
7701 ) | |
7702 * sizeratio | |
7703 ) | |
7704 - l | |
7705 ) | |
7706 / 3 | |
7707 ) | |
7708 if rotate == 1: | |
7709 self.plotPoint( | |
7710 y | |
7711 + int( | |
7712 (self._matrixori + j / self._matrixwid) | |
7713 * sizeratio | |
7714 ) | |
7715 - l | |
7716 - self.defsize, | |
7717 x + int((j % self._matrixwid) * sizeratio) - k, | |
7718 ) | |
7719 elif rotate == -1: | |
7720 self.plotPoint( | |
7721 y | |
7722 + int( | |
7723 ( | |
7724 self.defsize | |
7725 - (self._matrixori + j / self._matrixwid) | |
7726 ) | |
7727 * sizeratio | |
7728 ) | |
7729 - l, | |
7730 2 * x | |
7731 - (x + int((j % self._matrixwid) * sizeratio) - k), | |
7732 ) | |
7733 else: | |
7734 self.plotPoint( | |
7735 x + int((j % self._matrixwid) * sizeratio) - k, | |
7736 y | |
7737 + int( | |
7738 ( | |
7739 self.defsize | |
7740 - (self._matrixori + j / self._matrixwid) | |
7741 ) | |
7742 * sizeratio | |
7743 ) | |
7744 - l, | |
7745 ) | |
7746 | |
7747 def writeminus(self, x, y, size, ital, bold, sans, rotate): | |
7748 xpos = x | |
7749 sizeratio = size * 1.0 / self.defsize | |
7750 sizeint = (size - 1) / self.defsize + 1 | |
7751 if bold: | |
7752 sizeint = sizeint + 2 + int(sizeratio) | |
7753 charstring = binar(self.minusmatrix) | |
7754 charstring = ( | |
7755 self.minusmatrixwid * self.minusmatrixhei - len(charstring) | |
7756 ) * "0" + charstring | |
7757 if len(charstring) > self.minusmatrixwid * self.minusmatrixhei: | |
7758 charstring = charstring[0 - self.minusmatrixwid * self.minusmatrixhei :] | |
7759 for i in range(0, len(charstring), self.minusmatrixwid): | |
7760 for j in range(i, i + self.minusmatrixwid): | |
7761 if charstring[j] == "1": | |
7762 for k in range(sizeint): | |
7763 for l in range(sizeint): | |
7764 if ital and rotate == -1: | |
7765 x = ( | |
7766 xpos | |
7767 + ( | |
7768 int( | |
7769 ( | |
7770 ( | |
7771 self.minusmatrixori | |
7772 - self.minusmatrixwid | |
7773 + j / self.minusmatrixwid | |
7774 ) | |
7775 ) | |
7776 * sizeratio | |
7777 ) | |
7778 - l | |
7779 ) | |
7780 / 3 | |
7781 ) | |
7782 elif ital: | |
7783 x = ( | |
7784 xpos | |
7785 + ( | |
7786 int( | |
7787 ( | |
7788 self.defsize | |
7789 - ( | |
7790 self.minusmatrixori | |
7791 + j / self.minusmatrixwid | |
7792 ) | |
7793 ) | |
7794 * sizeratio | |
7795 ) | |
7796 - l | |
7797 ) | |
7798 / 3 | |
7799 ) | |
7800 if rotate == 1: | |
7801 self.plotPoint( | |
7802 y | |
7803 + int( | |
7804 (self.minusmatrixori + j / self.minusmatrixwid) | |
7805 * sizeratio | |
7806 ) | |
7807 - l | |
7808 - self.defsize, | |
7809 x + int((j % self.minusmatrixwid) * sizeratio) - k, | |
7810 ) | |
7811 elif rotate == -1: | |
7812 self.plotPoint( | |
7813 y | |
7814 + int( | |
7815 ( | |
7816 self.defsize | |
7817 - ( | |
7818 self.minusmatrixori | |
7819 + j / self.minusmatrixwid | |
7820 ) | |
7821 ) | |
7822 * sizeratio | |
7823 ) | |
7824 - l, | |
7825 2 * x | |
7826 - ( | |
7827 x | |
7828 + int((j % self.minusmatrixwid) * sizeratio) | |
7829 - k | |
7830 ), | |
7831 ) | |
7832 else: | |
7833 self.plotPoint( | |
7834 x + int((j % self.minusmatrixwid) * sizeratio) - k, | |
7835 y | |
7836 + int( | |
7837 ( | |
7838 self.defsize | |
7839 - ( | |
7840 self.minusmatrixori | |
7841 + j / self.minusmatrixwid | |
7842 ) | |
7843 ) | |
7844 * sizeratio | |
7845 ) | |
7846 - l, | |
7847 ) | |
7848 | |
7849 def writeplus(self, x, y, size, ital, bold, sans, rotate): | |
7850 xpos = x | |
7851 sizeratio = size * 1.0 / self.defsize | |
7852 sizeint = (size - 1) / self.defsize + 1 | |
7853 if bold: | |
7854 sizeint = sizeint + 2 + int(sizeratio) | |
7855 charstring = binar(self.plusmatrix) | |
7856 charstring = ( | |
7857 self.plusmatrixwid * self.plusmatrixhei - len(charstring) | |
7858 ) * "0" + charstring | |
7859 if len(charstring) > self.plusmatrixwid * self.plusmatrixhei: | |
7860 charstring = charstring[0 - self.plusmatrixwid * self.plusmatrixhei :] | |
7861 for i in range(0, len(charstring), self.plusmatrixwid): | |
7862 for j in range(i, i + self.plusmatrixwid): | |
7863 if charstring[j] == "1": | |
7864 for k in range(sizeint): | |
7865 for l in range(sizeint): | |
7866 if ital and rotate == -1: | |
7867 x = ( | |
7868 xpos | |
7869 + ( | |
7870 int( | |
7871 ( | |
7872 ( | |
7873 self.plusmatrixori | |
7874 - self.plusmatrixwid | |
7875 + j / self.plusmatrixwid | |
7876 ) | |
7877 ) | |
7878 * sizeratio | |
7879 ) | |
7880 - l | |
7881 ) | |
7882 / 3 | |
7883 ) | |
7884 elif ital: | |
7885 x = ( | |
7886 xpos | |
7887 + ( | |
7888 int( | |
7889 ( | |
7890 self.defsize | |
7891 - ( | |
7892 self.plusmatrixori | |
7893 + j / self.plusmatrixwid | |
7894 ) | |
7895 ) | |
7896 * sizeratio | |
7897 ) | |
7898 - l | |
7899 ) | |
7900 / 3 | |
7901 ) | |
7902 if rotate == 1: | |
7903 self.plotPoint( | |
7904 y | |
7905 + int( | |
7906 (self.plusmatrixori + j / self.plusmatrixwid) | |
7907 * sizeratio | |
7908 ) | |
7909 - l | |
7910 - self.defsize, | |
7911 x + int((j % self.plusmatrixwid) * sizeratio) - k, | |
7912 ) | |
7913 elif rotate == -1: | |
7914 self.plotPoint( | |
7915 y | |
7916 + int( | |
7917 ( | |
7918 self.defsize | |
7919 - ( | |
7920 self.plusmatrixori | |
7921 + j / self.plusmatrixwid | |
7922 ) | |
7923 ) | |
7924 * sizeratio | |
7925 ) | |
7926 - l, | |
7927 2 * x | |
7928 - ( | |
7929 x | |
7930 + int((j % self.plusmatrixwid) * sizeratio) | |
7931 - k | |
7932 ), | |
7933 ) | |
7934 else: | |
7935 self.plotPoint( | |
7936 x + int((j % self.plusmatrixwid) * sizeratio) - k, | |
7937 y | |
7938 + int( | |
7939 ( | |
7940 self.defsize | |
7941 - ( | |
7942 self.plusmatrixori | |
7943 + j / self.plusmatrixwid | |
7944 ) | |
7945 ) | |
7946 * sizeratio | |
7947 ) | |
7948 - l, | |
7949 ) | |
7950 | |
7951 def writeequal(self, x, y, size, ital, bold, sans, rotate): | |
7952 xpos = x | |
7953 sizeratio = size * 1.0 / self.defsize | |
7954 sizeint = (size - 1) / self.defsize + 1 | |
7955 if bold: | |
7956 sizeint = sizeint + 2 + int(sizeratio) | |
7957 charstring = binar(self.equalmatrix) | |
7958 charstring = ( | |
7959 self.equalmatrixwid * self.equalmatrixhei - len(charstring) | |
7960 ) * "0" + charstring | |
7961 if len(charstring) > self.equalmatrixwid * self.equalmatrixhei: | |
7962 charstring = charstring[0 - self.equalmatrixwid * self.equalmatrixhei :] | |
7963 for i in range(0, len(charstring), self.equalmatrixwid): | |
7964 for j in range(i, i + self.equalmatrixwid): | |
7965 if charstring[j] == "1": | |
7966 for k in range(sizeint): | |
7967 for l in range(sizeint): | |
7968 if ital and rotate == -1: | |
7969 x = ( | |
7970 xpos | |
7971 + ( | |
7972 int( | |
7973 ( | |
7974 ( | |
7975 self.equalmatrixori | |
7976 - self.equalmatrixwid | |
7977 + j / self.equalmatrixwid | |
7978 ) | |
7979 ) | |
7980 * sizeratio | |
7981 ) | |
7982 - l | |
7983 ) | |
7984 / 3 | |
7985 ) | |
7986 elif ital: | |
7987 x = ( | |
7988 xpos | |
7989 + ( | |
7990 int( | |
7991 ( | |
7992 self.defsize | |
7993 - ( | |
7994 self.equalmatrixori | |
7995 + j / self.equalmatrixwid | |
7996 ) | |
7997 ) | |
7998 * sizeratio | |
7999 ) | |
8000 - l | |
8001 ) | |
8002 / 3 | |
8003 ) | |
8004 if rotate == 1: | |
8005 self.plotPoint( | |
8006 y | |
8007 + int( | |
8008 (self.equalmatrixori + j / self.equalmatrixwid) | |
8009 * sizeratio | |
8010 ) | |
8011 - l | |
8012 - self.defsize, | |
8013 x + int((j % self.equalmatrixwid) * sizeratio) - k, | |
8014 ) | |
8015 elif rotate == -1: | |
8016 self.plotPoint( | |
8017 y | |
8018 + int( | |
8019 ( | |
8020 self.defsize | |
8021 - ( | |
8022 self.equalmatrixori | |
8023 + j / self.equalmatrixwid | |
8024 ) | |
8025 ) | |
8026 * sizeratio | |
8027 ) | |
8028 - l, | |
8029 2 * x | |
8030 - ( | |
8031 x | |
8032 + int((j % self.equalmatrixwid) * sizeratio) | |
8033 - k | |
8034 ), | |
8035 ) | |
8036 else: | |
8037 self.plotPoint( | |
8038 x + int((j % self.equalmatrixwid) * sizeratio) - k, | |
8039 y | |
8040 + int( | |
8041 ( | |
8042 self.defsize | |
8043 - ( | |
8044 self.equalmatrixori | |
8045 + j / self.equalmatrixwid | |
8046 ) | |
8047 ) | |
8048 * sizeratio | |
8049 ) | |
8050 - l, | |
8051 ) | |
8052 | |
8053 def writeexcl(self, x, y, size, ital, bold, sans, rotate): | |
8054 xpos = x | |
8055 sizeratio = size * 1.0 / self.defsize | |
8056 sizeint = (size - 1) / self.defsize + 1 | |
8057 if bold: | |
8058 sizeint = sizeint + 2 + int(sizeratio) | |
8059 charstring = binar(self.exclmatrix) | |
8060 charstring = ( | |
8061 self.exclmatrixwid * self.exclmatrixhei - len(charstring) | |
8062 ) * "0" + charstring | |
8063 if len(charstring) > self.exclmatrixwid * self.exclmatrixhei: | |
8064 charstring = charstring[0 - self.exclmatrixwid * self.exclmatrixhei :] | |
8065 for i in range(0, len(charstring), self.exclmatrixwid): | |
8066 for j in range(i, i + self.exclmatrixwid): | |
8067 if charstring[j] == "1": | |
8068 for k in range(sizeint): | |
8069 for l in range(sizeint): | |
8070 if ital and rotate == -1: | |
8071 x = ( | |
8072 xpos | |
8073 + ( | |
8074 int( | |
8075 ( | |
8076 ( | |
8077 self.exclmatrixori | |
8078 - self.exclmatrixwid | |
8079 + j / self.exclmatrixwid | |
8080 ) | |
8081 ) | |
8082 * sizeratio | |
8083 ) | |
8084 - l | |
8085 ) | |
8086 / 3 | |
8087 ) | |
8088 elif ital: | |
8089 x = ( | |
8090 xpos | |
8091 + ( | |
8092 int( | |
8093 ( | |
8094 self.defsize | |
8095 - ( | |
8096 self.exclmatrixori | |
8097 + j / self.exclmatrixwid | |
8098 ) | |
8099 ) | |
8100 * sizeratio | |
8101 ) | |
8102 - l | |
8103 ) | |
8104 / 3 | |
8105 ) | |
8106 if rotate == 1: | |
8107 self.plotPoint( | |
8108 y | |
8109 + int( | |
8110 (self.exclmatrixori + j / self.exclmatrixwid) | |
8111 * sizeratio | |
8112 ) | |
8113 - l | |
8114 - self.defsize, | |
8115 x + int((j % self.exclmatrixwid) * sizeratio) - k, | |
8116 ) | |
8117 elif rotate == -1: | |
8118 self.plotPoint( | |
8119 y | |
8120 + int( | |
8121 ( | |
8122 self.defsize | |
8123 - ( | |
8124 self.exclmatrixori | |
8125 + j / self.exclmatrixwid | |
8126 ) | |
8127 ) | |
8128 * sizeratio | |
8129 ) | |
8130 - l, | |
8131 2 * x | |
8132 - ( | |
8133 x | |
8134 + int((j % self.exclmatrixwid) * sizeratio) | |
8135 - k | |
8136 ), | |
8137 ) | |
8138 else: | |
8139 self.plotPoint( | |
8140 x + int((j % self.exclmatrixwid) * sizeratio) - k, | |
8141 y | |
8142 + int( | |
8143 ( | |
8144 self.defsize | |
8145 - ( | |
8146 self.exclmatrixori | |
8147 + j / self.exclmatrixwid | |
8148 ) | |
8149 ) | |
8150 * sizeratio | |
8151 ) | |
8152 - l, | |
8153 ) | |
8154 | |
8155 def writeat(self, x, y, size, ital, bold, sans, rotate): | |
8156 xpos = x | |
8157 sizeratio = size * 1.0 / self.defsize | |
8158 sizeint = (size - 1) / self.defsize + 1 | |
8159 if bold: | |
8160 sizeint = sizeint + 2 + int(sizeratio) | |
8161 charstring = binar(self.atmatrix) | |
8162 charstring = ( | |
8163 self.atmatrixwid * self.atmatrixhei - len(charstring) | |
8164 ) * "0" + charstring | |
8165 if len(charstring) > self.atmatrixwid * self.atmatrixhei: | |
8166 charstring = charstring[0 - self.atmatrixwid * self.atmatrixhei :] | |
8167 for i in range(0, len(charstring), self.atmatrixwid): | |
8168 for j in range(i, i + self.atmatrixwid): | |
8169 if charstring[j] == "1": | |
8170 for k in range(sizeint): | |
8171 for l in range(sizeint): | |
8172 if ital and rotate == -1: | |
8173 x = ( | |
8174 xpos | |
8175 + ( | |
8176 int( | |
8177 ( | |
8178 ( | |
8179 self.atmatrixori | |
8180 - self.atmatrixwid | |
8181 + j / self.atmatrixwid | |
8182 ) | |
8183 ) | |
8184 * sizeratio | |
8185 ) | |
8186 - l | |
8187 ) | |
8188 / 3 | |
8189 ) | |
8190 elif ital: | |
8191 x = ( | |
8192 xpos | |
8193 + ( | |
8194 int( | |
8195 ( | |
8196 self.defsize | |
8197 - ( | |
8198 self.atmatrixori | |
8199 + j / self.atmatrixwid | |
8200 ) | |
8201 ) | |
8202 * sizeratio | |
8203 ) | |
8204 - l | |
8205 ) | |
8206 / 3 | |
8207 ) | |
8208 if rotate == 1: | |
8209 self.plotPoint( | |
8210 y | |
8211 + int( | |
8212 (self.atmatrixori + j / self.atmatrixwid) | |
8213 * sizeratio | |
8214 ) | |
8215 - l | |
8216 - self.defsize, | |
8217 x + int((j % self.atmatrixwid) * sizeratio) - k, | |
8218 ) | |
8219 elif rotate == -1: | |
8220 self.plotPoint( | |
8221 y | |
8222 + int( | |
8223 ( | |
8224 self.defsize | |
8225 - (self.atmatrixori + j / self.atmatrixwid) | |
8226 ) | |
8227 * sizeratio | |
8228 ) | |
8229 - l, | |
8230 2 * x | |
8231 - (x + int((j % self.atmatrixwid) * sizeratio) - k), | |
8232 ) | |
8233 else: | |
8234 self.plotPoint( | |
8235 x + int((j % self.atmatrixwid) * sizeratio) - k, | |
8236 y | |
8237 + int( | |
8238 ( | |
8239 self.defsize | |
8240 - (self.atmatrixori + j / self.atmatrixwid) | |
8241 ) | |
8242 * sizeratio | |
8243 ) | |
8244 - l, | |
8245 ) | |
8246 | |
8247 def writehash(self, x, y, size, ital, bold, sans, rotate): | |
8248 xpos = x | |
8249 sizeratio = size * 1.0 / self.defsize | |
8250 sizeint = (size - 1) / self.defsize + 1 | |
8251 if bold: | |
8252 sizeint = sizeint + 2 + int(sizeratio) | |
8253 charstring = binar(self.hashmatrix) | |
8254 charstring = ( | |
8255 self.hashmatrixwid * self.hashmatrixhei - len(charstring) | |
8256 ) * "0" + charstring | |
8257 if len(charstring) > self.hashmatrixwid * self.hashmatrixhei: | |
8258 charstring = charstring[0 - self.hashmatrixwid * self.hashmatrixhei :] | |
8259 for i in range(0, len(charstring), self.hashmatrixwid): | |
8260 for j in range(i, i + self.hashmatrixwid): | |
8261 if charstring[j] == "1": | |
8262 for k in range(sizeint): | |
8263 for l in range(sizeint): | |
8264 if ital and rotate == -1: | |
8265 x = ( | |
8266 xpos | |
8267 + ( | |
8268 int( | |
8269 ( | |
8270 ( | |
8271 self.hashmatrixori | |
8272 - self.hashmatrixwid | |
8273 + j / self.hashmatrixwid | |
8274 ) | |
8275 ) | |
8276 * sizeratio | |
8277 ) | |
8278 - l | |
8279 ) | |
8280 / 3 | |
8281 ) | |
8282 elif ital: | |
8283 x = ( | |
8284 xpos | |
8285 + ( | |
8286 int( | |
8287 ( | |
8288 self.defsize | |
8289 - ( | |
8290 self.hashmatrixori | |
8291 + j / self.hashmatrixwid | |
8292 ) | |
8293 ) | |
8294 * sizeratio | |
8295 ) | |
8296 - l | |
8297 ) | |
8298 / 3 | |
8299 ) | |
8300 if rotate == 1: | |
8301 self.plotPoint( | |
8302 y | |
8303 + int( | |
8304 (self.hashmatrixori + j / self.hashmatrixwid) | |
8305 * sizeratio | |
8306 ) | |
8307 - l | |
8308 - self.defsize, | |
8309 x + int((j % self.hashmatrixwid) * sizeratio) - k, | |
8310 ) | |
8311 elif rotate == -1: | |
8312 self.plotPoint( | |
8313 y | |
8314 + int( | |
8315 ( | |
8316 self.defsize | |
8317 - ( | |
8318 self.hashmatrixori | |
8319 + j / self.hashmatrixwid | |
8320 ) | |
8321 ) | |
8322 * sizeratio | |
8323 ) | |
8324 - l, | |
8325 2 * x | |
8326 - ( | |
8327 x | |
8328 + int((j % self.hashmatrixwid) * sizeratio) | |
8329 - k | |
8330 ), | |
8331 ) | |
8332 else: | |
8333 self.plotPoint( | |
8334 x + int((j % self.hashmatrixwid) * sizeratio) - k, | |
8335 y | |
8336 + int( | |
8337 ( | |
8338 self.defsize | |
8339 - ( | |
8340 self.hashmatrixori | |
8341 + j / self.hashmatrixwid | |
8342 ) | |
8343 ) | |
8344 * sizeratio | |
8345 ) | |
8346 - l, | |
8347 ) | |
8348 | |
8349 def writedollar(self, x, y, size, ital, bold, sans, rotate): | |
8350 xpos = x | |
8351 sizeratio = size * 1.0 / self.defsize | |
8352 sizeint = (size - 1) / self.defsize + 1 | |
8353 if bold: | |
8354 sizeint = sizeint + 2 + int(sizeratio) | |
8355 charstring = binar(self.dollarmatrix) | |
8356 charstring = ( | |
8357 self.dollarmatrixwid * self.dollarmatrixhei - len(charstring) | |
8358 ) * "0" + charstring | |
8359 if len(charstring) > self.dollarmatrixwid * self.dollarmatrixhei: | |
8360 charstring = charstring[0 - self.dollarmatrixwid * self.dollarmatrixhei :] | |
8361 for i in range(0, len(charstring), self.dollarmatrixwid): | |
8362 for j in range(i, i + self.dollarmatrixwid): | |
8363 if charstring[j] == "1": | |
8364 for k in range(sizeint): | |
8365 for l in range(sizeint): | |
8366 if ital and rotate == -1: | |
8367 x = ( | |
8368 xpos | |
8369 + ( | |
8370 int( | |
8371 ( | |
8372 ( | |
8373 self.dollarmatrixori | |
8374 - self.dollarmatrixwid | |
8375 + j / self.dollarmatrixwid | |
8376 ) | |
8377 ) | |
8378 * sizeratio | |
8379 ) | |
8380 - l | |
8381 ) | |
8382 / 3 | |
8383 ) | |
8384 elif ital: | |
8385 x = ( | |
8386 xpos | |
8387 + ( | |
8388 int( | |
8389 ( | |
8390 self.defsize | |
8391 - ( | |
8392 self.dollarmatrixori | |
8393 + j / self.dollarmatrixwid | |
8394 ) | |
8395 ) | |
8396 * sizeratio | |
8397 ) | |
8398 - l | |
8399 ) | |
8400 / 3 | |
8401 ) | |
8402 if rotate == 1: | |
8403 self.plotPoint( | |
8404 y | |
8405 + int( | |
8406 ( | |
8407 self.dollarmatrixori | |
8408 + j / self.dollarmatrixwid | |
8409 ) | |
8410 * sizeratio | |
8411 ) | |
8412 - l | |
8413 - self.defsize, | |
8414 x + int((j % self.dollarmatrixwid) * sizeratio) - k, | |
8415 ) | |
8416 elif rotate == -1: | |
8417 self.plotPoint( | |
8418 y | |
8419 + int( | |
8420 ( | |
8421 self.defsize | |
8422 - ( | |
8423 self.dollarmatrixori | |
8424 + j / self.dollarmatrixwid | |
8425 ) | |
8426 ) | |
8427 * sizeratio | |
8428 ) | |
8429 - l, | |
8430 2 * x | |
8431 - ( | |
8432 x | |
8433 + int((j % self.dollarmatrixwid) * sizeratio) | |
8434 - k | |
8435 ), | |
8436 ) | |
8437 else: | |
8438 self.plotPoint( | |
8439 x + int((j % self.dollarmatrixwid) * sizeratio) - k, | |
8440 y | |
8441 + int( | |
8442 ( | |
8443 self.defsize | |
8444 - ( | |
8445 self.dollarmatrixori | |
8446 + j / self.dollarmatrixwid | |
8447 ) | |
8448 ) | |
8449 * sizeratio | |
8450 ) | |
8451 - l, | |
8452 ) | |
8453 | |
8454 def writepercent(self, x, y, size, ital, bold, sans, rotate): | |
8455 xpos = x | |
8456 sizeratio = size * 1.0 / self.defsize | |
8457 sizeint = (size - 1) / self.defsize + 1 | |
8458 if bold: | |
8459 sizeint = sizeint + 2 + int(sizeratio) | |
8460 charstring = binar(self.percentmatrix) | |
8461 charstring = ( | |
8462 self.percentmatrixwid * self.percentmatrixhei - len(charstring) | |
8463 ) * "0" + charstring | |
8464 if len(charstring) > self.percentmatrixwid * self.percentmatrixhei: | |
8465 charstring = charstring[0 - self.percentmatrixwid * self.percentmatrixhei :] | |
8466 for i in range(0, len(charstring), self.percentmatrixwid): | |
8467 for j in range(i, i + self.percentmatrixwid): | |
8468 if charstring[j] == "1": | |
8469 for k in range(sizeint): | |
8470 for l in range(sizeint): | |
8471 if ital and rotate == -1: | |
8472 x = ( | |
8473 xpos | |
8474 + ( | |
8475 int( | |
8476 ( | |
8477 ( | |
8478 self.percentmatrixori | |
8479 - self.percentmatrixwid | |
8480 + j / self.percentmatrixwid | |
8481 ) | |
8482 ) | |
8483 * sizeratio | |
8484 ) | |
8485 - l | |
8486 ) | |
8487 / 3 | |
8488 ) | |
8489 elif ital: | |
8490 x = ( | |
8491 xpos | |
8492 + ( | |
8493 int( | |
8494 ( | |
8495 self.defsize | |
8496 - ( | |
8497 self.percentmatrixori | |
8498 + j / self.percentmatrixwid | |
8499 ) | |
8500 ) | |
8501 * sizeratio | |
8502 ) | |
8503 - l | |
8504 ) | |
8505 / 3 | |
8506 ) | |
8507 if rotate == 1: | |
8508 self.plotPoint( | |
8509 y | |
8510 + int( | |
8511 ( | |
8512 self.percentmatrixori | |
8513 + j / self.percentmatrixwid | |
8514 ) | |
8515 * sizeratio | |
8516 ) | |
8517 - l | |
8518 - self.defsize, | |
8519 x | |
8520 + int((j % self.percentmatrixwid) * sizeratio) | |
8521 - k, | |
8522 ) | |
8523 elif rotate == -1: | |
8524 self.plotPoint( | |
8525 y | |
8526 + int( | |
8527 ( | |
8528 self.defsize | |
8529 - ( | |
8530 self.percentmatrixori | |
8531 + j / self.percentmatrixwid | |
8532 ) | |
8533 ) | |
8534 * sizeratio | |
8535 ) | |
8536 - l, | |
8537 2 * x | |
8538 - ( | |
8539 x | |
8540 + int((j % self.percentmatrixwid) * sizeratio) | |
8541 - k | |
8542 ), | |
8543 ) | |
8544 else: | |
8545 self.plotPoint( | |
8546 x | |
8547 + int((j % self.percentmatrixwid) * sizeratio) | |
8548 - k, | |
8549 y | |
8550 + int( | |
8551 ( | |
8552 self.defsize | |
8553 - ( | |
8554 self.percentmatrixori | |
8555 + j / self.percentmatrixwid | |
8556 ) | |
8557 ) | |
8558 * sizeratio | |
8559 ) | |
8560 - l, | |
8561 ) | |
8562 | |
8563 def writehat(self, x, y, size, ital, bold, sans, rotate): | |
8564 xpos = x | |
8565 sizeratio = size * 1.0 / self.defsize | |
8566 sizeint = (size - 1) / self.defsize + 1 | |
8567 if bold: | |
8568 sizeint = sizeint + 2 + int(sizeratio) | |
8569 charstring = binar(self.hatmatrix) | |
8570 charstring = ( | |
8571 self.hatmatrixwid * self.hatmatrixhei - len(charstring) | |
8572 ) * "0" + charstring | |
8573 if len(charstring) > self.hatmatrixwid * self.hatmatrixhei: | |
8574 charstring = charstring[0 - self.hatmatrixwid * self.hatmatrixhei :] | |
8575 for i in range(0, len(charstring), self.hatmatrixwid): | |
8576 for j in range(i, i + self.hatmatrixwid): | |
8577 if charstring[j] == "1": | |
8578 for k in range(sizeint): | |
8579 for l in range(sizeint): | |
8580 if ital and rotate == -1: | |
8581 x = ( | |
8582 xpos | |
8583 + ( | |
8584 int( | |
8585 ( | |
8586 ( | |
8587 self.hatmatrixori | |
8588 - self.hatmatrixwid | |
8589 + j / self.hatmatrixwid | |
8590 ) | |
8591 ) | |
8592 * sizeratio | |
8593 ) | |
8594 - l | |
8595 ) | |
8596 / 3 | |
8597 ) | |
8598 elif ital: | |
8599 x = ( | |
8600 xpos | |
8601 + ( | |
8602 int( | |
8603 ( | |
8604 self.defsize | |
8605 - ( | |
8606 self.hatmatrixori | |
8607 + j / self.hatmatrixwid | |
8608 ) | |
8609 ) | |
8610 * sizeratio | |
8611 ) | |
8612 - l | |
8613 ) | |
8614 / 3 | |
8615 ) | |
8616 if rotate == 1: | |
8617 self.plotPoint( | |
8618 y | |
8619 + int( | |
8620 (self.hatmatrixori + j / self.hatmatrixwid) | |
8621 * sizeratio | |
8622 ) | |
8623 - l | |
8624 - self.defsize, | |
8625 x + int((j % self.hatmatrixwid) * sizeratio) - k, | |
8626 ) | |
8627 elif rotate == -1: | |
8628 self.plotPoint( | |
8629 y | |
8630 + int( | |
8631 ( | |
8632 self.defsize | |
8633 - ( | |
8634 self.hatmatrixori | |
8635 + j / self.hatmatrixwid | |
8636 ) | |
8637 ) | |
8638 * sizeratio | |
8639 ) | |
8640 - l, | |
8641 2 * x | |
8642 - ( | |
8643 x + int((j % self.hatmatrixwid) * sizeratio) - k | |
8644 ), | |
8645 ) | |
8646 else: | |
8647 self.plotPoint( | |
8648 x + int((j % self.hatmatrixwid) * sizeratio) - k, | |
8649 y | |
8650 + int( | |
8651 ( | |
8652 self.defsize | |
8653 - ( | |
8654 self.hatmatrixori | |
8655 + j / self.hatmatrixwid | |
8656 ) | |
8657 ) | |
8658 * sizeratio | |
8659 ) | |
8660 - l, | |
8661 ) | |
8662 | |
8663 def writeamp(self, x, y, size, ital, bold, sans, rotate): | |
8664 xpos = x | |
8665 sizeratio = size * 1.0 / self.defsize | |
8666 sizeint = (size - 1) / self.defsize + 1 | |
8667 if bold: | |
8668 sizeint = sizeint + 2 + int(sizeratio) | |
8669 charstring = binar(self.ampmatrix) | |
8670 charstring = ( | |
8671 self.ampmatrixwid * self.ampmatrixhei - len(charstring) | |
8672 ) * "0" + charstring | |
8673 if len(charstring) > self.ampmatrixwid * self.ampmatrixhei: | |
8674 charstring = charstring[0 - self.ampmatrixwid * self.ampmatrixhei :] | |
8675 for i in range(0, len(charstring), self.ampmatrixwid): | |
8676 for j in range(i, i + self.ampmatrixwid): | |
8677 if charstring[j] == "1": | |
8678 for k in range(sizeint): | |
8679 for l in range(sizeint): | |
8680 if ital and rotate == -1: | |
8681 x = ( | |
8682 xpos | |
8683 + ( | |
8684 int( | |
8685 ( | |
8686 ( | |
8687 self.ampmatrixori | |
8688 - self.ampmatrixwid | |
8689 + j / self.ampmatrixwid | |
8690 ) | |
8691 ) | |
8692 * sizeratio | |
8693 ) | |
8694 - l | |
8695 ) | |
8696 / 3 | |
8697 ) | |
8698 elif ital: | |
8699 x = ( | |
8700 xpos | |
8701 + ( | |
8702 int( | |
8703 ( | |
8704 self.defsize | |
8705 - ( | |
8706 self.ampmatrixori | |
8707 + j / self.ampmatrixwid | |
8708 ) | |
8709 ) | |
8710 * sizeratio | |
8711 ) | |
8712 - l | |
8713 ) | |
8714 / 3 | |
8715 ) | |
8716 if rotate == 1: | |
8717 self.plotPoint( | |
8718 y | |
8719 + int( | |
8720 (self.ampmatrixori + j / self.ampmatrixwid) | |
8721 * sizeratio | |
8722 ) | |
8723 - l | |
8724 - self.defsize, | |
8725 x + int((j % self.ampmatrixwid) * sizeratio) - k, | |
8726 ) | |
8727 elif rotate == -1: | |
8728 self.plotPoint( | |
8729 y | |
8730 + int( | |
8731 ( | |
8732 self.defsize | |
8733 - ( | |
8734 self.ampmatrixori | |
8735 + j / self.ampmatrixwid | |
8736 ) | |
8737 ) | |
8738 * sizeratio | |
8739 ) | |
8740 - l, | |
8741 2 * x | |
8742 - ( | |
8743 x + int((j % self.ampmatrixwid) * sizeratio) - k | |
8744 ), | |
8745 ) | |
8746 else: | |
8747 self.plotPoint( | |
8748 x + int((j % self.ampmatrixwid) * sizeratio) - k, | |
8749 y | |
8750 + int( | |
8751 ( | |
8752 self.defsize | |
8753 - ( | |
8754 self.ampmatrixori | |
8755 + j / self.ampmatrixwid | |
8756 ) | |
8757 ) | |
8758 * sizeratio | |
8759 ) | |
8760 - l, | |
8761 ) | |
8762 | |
8763 def writestrix(self, x, y, size, ital, bold, sans, rotate): | |
8764 xpos = x | |
8765 sizeratio = size * 1.0 / self.defsize | |
8766 sizeint = (size - 1) / self.defsize + 1 | |
8767 if bold: | |
8768 sizeint = sizeint + 2 + int(sizeratio) | |
8769 charstring = binar(self.strixmatrix) | |
8770 charstring = ( | |
8771 self.strixmatrixwid * self.strixmatrixhei - len(charstring) | |
8772 ) * "0" + charstring | |
8773 if len(charstring) > self.strixmatrixwid * self.strixmatrixhei: | |
8774 charstring = charstring[0 - self.strixmatrixwid * self.strixmatrixhei :] | |
8775 for i in range(0, len(charstring), self.strixmatrixwid): | |
8776 for j in range(i, i + self.strixmatrixwid): | |
8777 if charstring[j] == "1": | |
8778 for k in range(sizeint): | |
8779 for l in range(sizeint): | |
8780 if ital and rotate == -1: | |
8781 x = ( | |
8782 xpos | |
8783 + ( | |
8784 int( | |
8785 ( | |
8786 ( | |
8787 self.strixmatrixori | |
8788 - self.strixmatrixwid | |
8789 + j / self.strixmatrixwid | |
8790 ) | |
8791 ) | |
8792 * sizeratio | |
8793 ) | |
8794 - l | |
8795 ) | |
8796 / 3 | |
8797 ) | |
8798 elif ital: | |
8799 x = ( | |
8800 xpos | |
8801 + ( | |
8802 int( | |
8803 ( | |
8804 self.defsize | |
8805 - ( | |
8806 self.strixmatrixori | |
8807 + j / self.strixmatrixwid | |
8808 ) | |
8809 ) | |
8810 * sizeratio | |
8811 ) | |
8812 - l | |
8813 ) | |
8814 / 3 | |
8815 ) | |
8816 if rotate == 1: | |
8817 self.plotPoint( | |
8818 y | |
8819 + int( | |
8820 (self.strixmatrixori + j / self.strixmatrixwid) | |
8821 * sizeratio | |
8822 ) | |
8823 - l | |
8824 - self.defsize, | |
8825 x + int((j % self.strixmatrixwid) * sizeratio) - k, | |
8826 ) | |
8827 elif rotate == -1: | |
8828 self.plotPoint( | |
8829 y | |
8830 + int( | |
8831 ( | |
8832 self.defsize | |
8833 - ( | |
8834 self.strixmatrixori | |
8835 + j / self.strixmatrixwid | |
8836 ) | |
8837 ) | |
8838 * sizeratio | |
8839 ) | |
8840 - l, | |
8841 2 * x | |
8842 - ( | |
8843 x | |
8844 + int((j % self.strixmatrixwid) * sizeratio) | |
8845 - k | |
8846 ), | |
8847 ) | |
8848 else: | |
8849 self.plotPoint( | |
8850 x + int((j % self.strixmatrixwid) * sizeratio) - k, | |
8851 y | |
8852 + int( | |
8853 ( | |
8854 self.defsize | |
8855 - ( | |
8856 self.strixmatrixori | |
8857 + j / self.strixmatrixwid | |
8858 ) | |
8859 ) | |
8860 * sizeratio | |
8861 ) | |
8862 - l, | |
8863 ) | |
8864 | |
8865 def writeopencpar(self, x, y, size, ital, bold, sans, rotate): | |
8866 xpos = x | |
8867 sizeratio = size * 1.0 / self.defsize | |
8868 sizeint = (size - 1) / self.defsize + 1 | |
8869 if bold: | |
8870 sizeint = sizeint + 2 + int(sizeratio) | |
8871 charstring = binar(self.opencparmatrix) | |
8872 charstring = ( | |
8873 self.opencparmatrixwid * self.opencparmatrixhei - len(charstring) | |
8874 ) * "0" + charstring | |
8875 if len(charstring) > self.opencparmatrixwid * self.opencparmatrixhei: | |
8876 charstring = charstring[ | |
8877 0 - self.opencparmatrixwid * self.opencparmatrixhei : | |
8878 ] | |
8879 for i in range(0, len(charstring), self.opencparmatrixwid): | |
8880 for j in range(i, i + self.opencparmatrixwid): | |
8881 if charstring[j] == "1": | |
8882 for k in range(sizeint): | |
8883 for l in range(sizeint): | |
8884 if ital and rotate == -1: | |
8885 x = ( | |
8886 xpos | |
8887 + ( | |
8888 int( | |
8889 ( | |
8890 ( | |
8891 self.opencparmatrixori | |
8892 - self.opencparmatrixwid | |
8893 + j / self.opencparmatrixwid | |
8894 ) | |
8895 ) | |
8896 * sizeratio | |
8897 ) | |
8898 - l | |
8899 ) | |
8900 / 3 | |
8901 ) | |
8902 elif ital: | |
8903 x = ( | |
8904 xpos | |
8905 + ( | |
8906 int( | |
8907 ( | |
8908 self.defsize | |
8909 - ( | |
8910 self.opencparmatrixori | |
8911 + j / self.opencparmatrixwid | |
8912 ) | |
8913 ) | |
8914 * sizeratio | |
8915 ) | |
8916 - l | |
8917 ) | |
8918 / 3 | |
8919 ) | |
8920 if rotate == 1: | |
8921 self.plotPoint( | |
8922 y | |
8923 + int( | |
8924 ( | |
8925 self.opencparmatrixori | |
8926 + j / self.opencparmatrixwid | |
8927 ) | |
8928 * sizeratio | |
8929 ) | |
8930 - l | |
8931 - self.defsize, | |
8932 x | |
8933 + int((j % self.opencparmatrixwid) * sizeratio) | |
8934 - k, | |
8935 ) | |
8936 elif rotate == -1: | |
8937 self.plotPoint( | |
8938 y | |
8939 + int( | |
8940 ( | |
8941 self.defsize | |
8942 - ( | |
8943 self.opencparmatrixori | |
8944 + j / self.opencparmatrixwid | |
8945 ) | |
8946 ) | |
8947 * sizeratio | |
8948 ) | |
8949 - l, | |
8950 2 * x | |
8951 - ( | |
8952 x | |
8953 + int((j % self.opencparmatrixwid) * sizeratio) | |
8954 - k | |
8955 ), | |
8956 ) | |
8957 else: | |
8958 self.plotPoint( | |
8959 x | |
8960 + int((j % self.opencparmatrixwid) * sizeratio) | |
8961 - k, | |
8962 y | |
8963 + int( | |
8964 ( | |
8965 self.defsize | |
8966 - ( | |
8967 self.opencparmatrixori | |
8968 + j / self.opencparmatrixwid | |
8969 ) | |
8970 ) | |
8971 * sizeratio | |
8972 ) | |
8973 - l, | |
8974 ) | |
8975 | |
8976 def writeclosecpar(self, x, y, size, ital, bold, sans, rotate): | |
8977 xpos = x | |
8978 sizeratio = size * 1.0 / self.defsize | |
8979 sizeint = (size - 1) / self.defsize + 1 | |
8980 if bold: | |
8981 sizeint = sizeint + 2 + int(sizeratio) | |
8982 charstring = binar(self.closecparmatrix) | |
8983 charstring = ( | |
8984 self.closecparmatrixwid * self.closecparmatrixhei - len(charstring) | |
8985 ) * "0" + charstring | |
8986 if len(charstring) > self.closecparmatrixwid * self.closecparmatrixhei: | |
8987 charstring = charstring[ | |
8988 0 - self.closecparmatrixwid * self.closecparmatrixhei : | |
8989 ] | |
8990 for i in range(0, len(charstring), self.closecparmatrixwid): | |
8991 for j in range(i, i + self.closecparmatrixwid): | |
8992 if charstring[j] == "1": | |
8993 for k in range(sizeint): | |
8994 for l in range(sizeint): | |
8995 if ital and rotate == -1: | |
8996 x = ( | |
8997 xpos | |
8998 + ( | |
8999 int( | |
9000 ( | |
9001 ( | |
9002 self.closecparmatrixori | |
9003 - self.closecparmatrixwid | |
9004 + j / self.closecparmatrixwid | |
9005 ) | |
9006 ) | |
9007 * sizeratio | |
9008 ) | |
9009 - l | |
9010 ) | |
9011 / 3 | |
9012 ) | |
9013 elif ital: | |
9014 x = ( | |
9015 xpos | |
9016 + ( | |
9017 int( | |
9018 ( | |
9019 self.defsize | |
9020 - ( | |
9021 self.closecparmatrixori | |
9022 + j / self.closecparmatrixwid | |
9023 ) | |
9024 ) | |
9025 * sizeratio | |
9026 ) | |
9027 - l | |
9028 ) | |
9029 / 3 | |
9030 ) | |
9031 if rotate == 1: | |
9032 self.plotPoint( | |
9033 y | |
9034 + int( | |
9035 ( | |
9036 self.closecparmatrixori | |
9037 + j / self.closecparmatrixwid | |
9038 ) | |
9039 * sizeratio | |
9040 ) | |
9041 - l | |
9042 - self.defsize, | |
9043 x | |
9044 + int((j % self.closecparmatrixwid) * sizeratio) | |
9045 - k, | |
9046 ) | |
9047 elif rotate == -1: | |
9048 self.plotPoint( | |
9049 y | |
9050 + int( | |
9051 ( | |
9052 self.defsize | |
9053 - ( | |
9054 self.closecparmatrixori | |
9055 + j / self.closecparmatrixwid | |
9056 ) | |
9057 ) | |
9058 * sizeratio | |
9059 ) | |
9060 - l, | |
9061 2 * x | |
9062 - ( | |
9063 x | |
9064 + int((j % self.closecparmatrixwid) * sizeratio) | |
9065 - k | |
9066 ), | |
9067 ) | |
9068 else: | |
9069 self.plotPoint( | |
9070 x | |
9071 + int((j % self.closecparmatrixwid) * sizeratio) | |
9072 - k, | |
9073 y | |
9074 + int( | |
9075 ( | |
9076 self.defsize | |
9077 - ( | |
9078 self.closecparmatrixori | |
9079 + j / self.closecparmatrixwid | |
9080 ) | |
9081 ) | |
9082 * sizeratio | |
9083 ) | |
9084 - l, | |
9085 ) | |
9086 | |
9087 def writeopenspar(self, x, y, size, ital, bold, sans, rotate): | |
9088 xpos = x | |
9089 sizeratio = size * 1.0 / self.defsize | |
9090 sizeint = (size - 1) / self.defsize + 1 | |
9091 if bold: | |
9092 sizeint = sizeint + 2 + int(sizeratio) | |
9093 charstring = binar(self.opensparmatrix) | |
9094 charstring = ( | |
9095 self.opensparmatrixwid * self.opensparmatrixhei - len(charstring) | |
9096 ) * "0" + charstring | |
9097 if len(charstring) > self.opensparmatrixwid * self.opensparmatrixhei: | |
9098 charstring = charstring[ | |
9099 0 - self.opensparmatrixwid * self.opensparmatrixhei : | |
9100 ] | |
9101 for i in range(0, len(charstring), self.opensparmatrixwid): | |
9102 for j in range(i, i + self.opensparmatrixwid): | |
9103 if charstring[j] == "1": | |
9104 for k in range(sizeint): | |
9105 for l in range(sizeint): | |
9106 if ital and rotate == -1: | |
9107 x = ( | |
9108 xpos | |
9109 + ( | |
9110 int( | |
9111 ( | |
9112 ( | |
9113 self.opensparmatrixori | |
9114 - self.opensparmatrixwid | |
9115 + j / self.opensparmatrixwid | |
9116 ) | |
9117 ) | |
9118 * sizeratio | |
9119 ) | |
9120 - l | |
9121 ) | |
9122 / 3 | |
9123 ) | |
9124 elif ital: | |
9125 x = ( | |
9126 xpos | |
9127 + ( | |
9128 int( | |
9129 ( | |
9130 self.defsize | |
9131 - ( | |
9132 self.opensparmatrixori | |
9133 + j / self.opensparmatrixwid | |
9134 ) | |
9135 ) | |
9136 * sizeratio | |
9137 ) | |
9138 - l | |
9139 ) | |
9140 / 3 | |
9141 ) | |
9142 if rotate == 1: | |
9143 self.plotPoint( | |
9144 y | |
9145 + int( | |
9146 ( | |
9147 self.opensparmatrixori | |
9148 + j / self.opensparmatrixwid | |
9149 ) | |
9150 * sizeratio | |
9151 ) | |
9152 - l | |
9153 - self.defsize, | |
9154 x | |
9155 + int((j % self.opensparmatrixwid) * sizeratio) | |
9156 - k, | |
9157 ) | |
9158 elif rotate == -1: | |
9159 self.plotPoint( | |
9160 y | |
9161 + int( | |
9162 ( | |
9163 self.defsize | |
9164 - ( | |
9165 self.opensparmatrixori | |
9166 + j / self.opensparmatrixwid | |
9167 ) | |
9168 ) | |
9169 * sizeratio | |
9170 ) | |
9171 - l, | |
9172 2 * x | |
9173 - ( | |
9174 x | |
9175 + int((j % self.opensparmatrixwid) * sizeratio) | |
9176 - k | |
9177 ), | |
9178 ) | |
9179 else: | |
9180 self.plotPoint( | |
9181 x | |
9182 + int((j % self.opensparmatrixwid) * sizeratio) | |
9183 - k, | |
9184 y | |
9185 + int( | |
9186 ( | |
9187 self.defsize | |
9188 - ( | |
9189 self.opensparmatrixori | |
9190 + j / self.opensparmatrixwid | |
9191 ) | |
9192 ) | |
9193 * sizeratio | |
9194 ) | |
9195 - l, | |
9196 ) | |
9197 | |
9198 def writeclosespar(self, x, y, size, ital, bold, sans, rotate): | |
9199 xpos = x | |
9200 sizeratio = size * 1.0 / self.defsize | |
9201 sizeint = (size - 1) / self.defsize + 1 | |
9202 if bold: | |
9203 sizeint = sizeint + 2 + int(sizeratio) | |
9204 charstring = binar(self.closesparmatrix) | |
9205 charstring = ( | |
9206 self.closesparmatrixwid * self.closesparmatrixhei - len(charstring) | |
9207 ) * "0" + charstring | |
9208 if len(charstring) > self.closesparmatrixwid * self.closesparmatrixhei: | |
9209 charstring = charstring[ | |
9210 0 - self.closesparmatrixwid * self.closesparmatrixhei : | |
9211 ] | |
9212 for i in range(0, len(charstring), self.closesparmatrixwid): | |
9213 for j in range(i, i + self.closesparmatrixwid): | |
9214 if charstring[j] == "1": | |
9215 for k in range(sizeint): | |
9216 for l in range(sizeint): | |
9217 if ital and rotate == -1: | |
9218 x = ( | |
9219 xpos | |
9220 + ( | |
9221 int( | |
9222 ( | |
9223 ( | |
9224 self.closesparmatrixori | |
9225 - self.closesparmatrixwid | |
9226 + j / self.closesparmatrixwid | |
9227 ) | |
9228 ) | |
9229 * sizeratio | |
9230 ) | |
9231 - l | |
9232 ) | |
9233 / 3 | |
9234 ) | |
9235 elif ital: | |
9236 x = ( | |
9237 xpos | |
9238 + ( | |
9239 int( | |
9240 ( | |
9241 self.defsize | |
9242 - ( | |
9243 self.closesparmatrixori | |
9244 + j / self.closesparmatrixwid | |
9245 ) | |
9246 ) | |
9247 * sizeratio | |
9248 ) | |
9249 - l | |
9250 ) | |
9251 / 3 | |
9252 ) | |
9253 if rotate == 1: | |
9254 self.plotPoint( | |
9255 y | |
9256 + int( | |
9257 ( | |
9258 self.closesparmatrixori | |
9259 + j / self.closesparmatrixwid | |
9260 ) | |
9261 * sizeratio | |
9262 ) | |
9263 - l | |
9264 - self.defsize, | |
9265 x | |
9266 + int((j % self.closesparmatrixwid) * sizeratio) | |
9267 - k, | |
9268 ) | |
9269 elif rotate == -1: | |
9270 self.plotPoint( | |
9271 y | |
9272 + int( | |
9273 ( | |
9274 self.defsize | |
9275 - ( | |
9276 self.closesparmatrixori | |
9277 + j / self.closesparmatrixwid | |
9278 ) | |
9279 ) | |
9280 * sizeratio | |
9281 ) | |
9282 - l, | |
9283 2 * x | |
9284 - ( | |
9285 x | |
9286 + int((j % self.closesparmatrixwid) * sizeratio) | |
9287 - k | |
9288 ), | |
9289 ) | |
9290 else: | |
9291 self.plotPoint( | |
9292 x | |
9293 + int((j % self.closesparmatrixwid) * sizeratio) | |
9294 - k, | |
9295 y | |
9296 + int( | |
9297 ( | |
9298 self.defsize | |
9299 - ( | |
9300 self.closesparmatrixori | |
9301 + j / self.closesparmatrixwid | |
9302 ) | |
9303 ) | |
9304 * sizeratio | |
9305 ) | |
9306 - l, | |
9307 ) | |
9308 | |
9309 def writebackslash(self, x, y, size, ital, bold, sans, rotate): | |
9310 xpos = x | |
9311 sizeratio = size * 1.0 / self.defsize | |
9312 sizeint = (size - 1) / self.defsize + 1 | |
9313 if bold: | |
9314 sizeint = sizeint + 2 + int(sizeratio) | |
9315 charstring = binar(self.backslashmatrix) | |
9316 charstring = ( | |
9317 self.backslashmatrixwid * self.backslashmatrixhei - len(charstring) | |
9318 ) * "0" + charstring | |
9319 if len(charstring) > self.backslashmatrixwid * self.backslashmatrixhei: | |
9320 charstring = charstring[ | |
9321 0 - self.backslashmatrixwid * self.backslashmatrixhei : | |
9322 ] | |
9323 for i in range(0, len(charstring), self.backslashmatrixwid): | |
9324 for j in range(i, i + self.backslashmatrixwid): | |
9325 if charstring[j] == "1": | |
9326 for k in range(sizeint): | |
9327 for l in range(sizeint): | |
9328 if ital and rotate == -1: | |
9329 x = ( | |
9330 xpos | |
9331 + ( | |
9332 int( | |
9333 ( | |
9334 ( | |
9335 self.backslashmatrixori | |
9336 - self.backslashmatrixwid | |
9337 + j / self.backslashmatrixwid | |
9338 ) | |
9339 ) | |
9340 * sizeratio | |
9341 ) | |
9342 - l | |
9343 ) | |
9344 / 3 | |
9345 ) | |
9346 elif ital: | |
9347 x = ( | |
9348 xpos | |
9349 + ( | |
9350 int( | |
9351 ( | |
9352 self.defsize | |
9353 - ( | |
9354 self.backslashmatrixori | |
9355 + j / self.backslashmatrixwid | |
9356 ) | |
9357 ) | |
9358 * sizeratio | |
9359 ) | |
9360 - l | |
9361 ) | |
9362 / 3 | |
9363 ) | |
9364 if rotate == 1: | |
9365 self.plotPoint( | |
9366 y | |
9367 + int( | |
9368 ( | |
9369 self.backslashmatrixori | |
9370 + j / self.backslashmatrixwid | |
9371 ) | |
9372 * sizeratio | |
9373 ) | |
9374 - l | |
9375 - self.defsize, | |
9376 x | |
9377 + int((j % self.backslashmatrixwid) * sizeratio) | |
9378 - k, | |
9379 ) | |
9380 elif rotate == -1: | |
9381 self.plotPoint( | |
9382 y | |
9383 + int( | |
9384 ( | |
9385 self.defsize | |
9386 - ( | |
9387 self.backslashmatrixori | |
9388 + j / self.backslashmatrixwid | |
9389 ) | |
9390 ) | |
9391 * sizeratio | |
9392 ) | |
9393 - l, | |
9394 2 * x | |
9395 - ( | |
9396 x | |
9397 + int((j % self.backslashmatrixwid) * sizeratio) | |
9398 - k | |
9399 ), | |
9400 ) | |
9401 else: | |
9402 self.plotPoint( | |
9403 x | |
9404 + int((j % self.backslashmatrixwid) * sizeratio) | |
9405 - k, | |
9406 y | |
9407 + int( | |
9408 ( | |
9409 self.defsize | |
9410 - ( | |
9411 self.backslashmatrixori | |
9412 + j / self.backslashmatrixwid | |
9413 ) | |
9414 ) | |
9415 * sizeratio | |
9416 ) | |
9417 - l, | |
9418 ) | |
9419 | |
9420 def writesemicol(self, x, y, size, ital, bold, sans, rotate): | |
9421 xpos = x | |
9422 sizeratio = size * 1.0 / self.defsize | |
9423 sizeint = (size - 1) / self.defsize + 1 | |
9424 if bold: | |
9425 sizeint = sizeint + 2 + int(sizeratio) | |
9426 charstring = binar(self.semicolmatrix) | |
9427 charstring = ( | |
9428 self.semicolmatrixwid * self.semicolmatrixhei - len(charstring) | |
9429 ) * "0" + charstring | |
9430 if len(charstring) > self.semicolmatrixwid * self.semicolmatrixhei: | |
9431 charstring = charstring[0 - self.semicolmatrixwid * self.semicolmatrixhei :] | |
9432 for i in range(0, len(charstring), self.semicolmatrixwid): | |
9433 for j in range(i, i + self.semicolmatrixwid): | |
9434 if charstring[j] == "1": | |
9435 for k in range(sizeint): | |
9436 for l in range(sizeint): | |
9437 if ital and rotate == -1: | |
9438 x = ( | |
9439 xpos | |
9440 + ( | |
9441 int( | |
9442 ( | |
9443 ( | |
9444 self.semicolmatrixori | |
9445 - self.semicolmatrixwid | |
9446 + j / self.semicolmatrixwid | |
9447 ) | |
9448 ) | |
9449 * sizeratio | |
9450 ) | |
9451 - l | |
9452 ) | |
9453 / 3 | |
9454 ) | |
9455 elif ital: | |
9456 x = ( | |
9457 xpos | |
9458 + ( | |
9459 int( | |
9460 ( | |
9461 self.defsize | |
9462 - ( | |
9463 self.semicolmatrixori | |
9464 + j / self.semicolmatrixwid | |
9465 ) | |
9466 ) | |
9467 * sizeratio | |
9468 ) | |
9469 - l | |
9470 ) | |
9471 / 3 | |
9472 ) | |
9473 if rotate == 1: | |
9474 self.plotPoint( | |
9475 y | |
9476 + int( | |
9477 ( | |
9478 self.semicolmatrixori | |
9479 + j / self.semicolmatrixwid | |
9480 ) | |
9481 * sizeratio | |
9482 ) | |
9483 - l | |
9484 - self.defsize, | |
9485 x | |
9486 + int((j % self.semicolmatrixwid) * sizeratio) | |
9487 - k, | |
9488 ) | |
9489 elif rotate == -1: | |
9490 self.plotPoint( | |
9491 y | |
9492 + int( | |
9493 ( | |
9494 self.defsize | |
9495 - ( | |
9496 self.semicolmatrixori | |
9497 + j / self.semicolmatrixwid | |
9498 ) | |
9499 ) | |
9500 * sizeratio | |
9501 ) | |
9502 - l, | |
9503 2 * x | |
9504 - ( | |
9505 x | |
9506 + int((j % self.semicolmatrixwid) * sizeratio) | |
9507 - k | |
9508 ), | |
9509 ) | |
9510 else: | |
9511 self.plotPoint( | |
9512 x | |
9513 + int((j % self.semicolmatrixwid) * sizeratio) | |
9514 - k, | |
9515 y | |
9516 + int( | |
9517 ( | |
9518 self.defsize | |
9519 - ( | |
9520 self.semicolmatrixori | |
9521 + j / self.semicolmatrixwid | |
9522 ) | |
9523 ) | |
9524 * sizeratio | |
9525 ) | |
9526 - l, | |
9527 ) | |
9528 | |
9529 def writepost(self, x, y, size, ital, bold, sans, rotate): | |
9530 xpos = x | |
9531 sizeratio = size * 1.0 / self.defsize | |
9532 sizeint = (size - 1) / self.defsize + 1 | |
9533 if bold: | |
9534 sizeint = sizeint + 2 + int(sizeratio) | |
9535 charstring = binar(self.postmatrix) | |
9536 charstring = ( | |
9537 self.postmatrixwid * self.postmatrixhei - len(charstring) | |
9538 ) * "0" + charstring | |
9539 if len(charstring) > self.postmatrixwid * self.postmatrixhei: | |
9540 charstring = charstring[0 - self.postmatrixwid * self.postmatrixhei :] | |
9541 for i in range(0, len(charstring), self.postmatrixwid): | |
9542 for j in range(i, i + self.postmatrixwid): | |
9543 if charstring[j] == "1": | |
9544 for k in range(sizeint): | |
9545 for l in range(sizeint): | |
9546 if ital and rotate == -1: | |
9547 x = ( | |
9548 xpos | |
9549 + ( | |
9550 int( | |
9551 ( | |
9552 ( | |
9553 self.postmatrixori | |
9554 - self.postmatrixwid | |
9555 + j / self.postmatrixwid | |
9556 ) | |
9557 ) | |
9558 * sizeratio | |
9559 ) | |
9560 - l | |
9561 ) | |
9562 / 3 | |
9563 ) | |
9564 elif ital: | |
9565 x = ( | |
9566 xpos | |
9567 + ( | |
9568 int( | |
9569 ( | |
9570 self.defsize | |
9571 - ( | |
9572 self.postmatrixori | |
9573 + j / self.postmatrixwid | |
9574 ) | |
9575 ) | |
9576 * sizeratio | |
9577 ) | |
9578 - l | |
9579 ) | |
9580 / 3 | |
9581 ) | |
9582 if rotate == 1: | |
9583 self.plotPoint( | |
9584 y | |
9585 + int( | |
9586 (self.postmatrixori + j / self.postmatrixwid) | |
9587 * sizeratio | |
9588 ) | |
9589 - l | |
9590 - self.defsize, | |
9591 x + int((j % self.postmatrixwid) * sizeratio) - k, | |
9592 ) | |
9593 elif rotate == -1: | |
9594 self.plotPoint( | |
9595 y | |
9596 + int( | |
9597 ( | |
9598 self.defsize | |
9599 - ( | |
9600 self.postmatrixori | |
9601 + j / self.postmatrixwid | |
9602 ) | |
9603 ) | |
9604 * sizeratio | |
9605 ) | |
9606 - l, | |
9607 2 * x | |
9608 - ( | |
9609 x | |
9610 + int((j % self.postmatrixwid) * sizeratio) | |
9611 - k | |
9612 ), | |
9613 ) | |
9614 else: | |
9615 self.plotPoint( | |
9616 x + int((j % self.postmatrixwid) * sizeratio) - k, | |
9617 y | |
9618 + int( | |
9619 ( | |
9620 self.defsize | |
9621 - ( | |
9622 self.postmatrixori | |
9623 + j / self.postmatrixwid | |
9624 ) | |
9625 ) | |
9626 * sizeratio | |
9627 ) | |
9628 - l, | |
9629 ) | |
9630 | |
9631 def writecomma(self, x, y, size, ital, bold, sans, rotate): | |
9632 xpos = x | |
9633 sizeratio = size * 1.0 / self.defsize | |
9634 sizeint = (size - 1) / self.defsize + 1 | |
9635 if bold: | |
9636 sizeint = sizeint + 2 + int(sizeratio) | |
9637 charstring = binar(self.commamatrix) | |
9638 charstring = ( | |
9639 self.commamatrixwid * self.commamatrixhei - len(charstring) | |
9640 ) * "0" + charstring | |
9641 if len(charstring) > self.commamatrixwid * self.commamatrixhei: | |
9642 charstring = charstring[0 - self.commamatrixwid * self.commamatrixhei :] | |
9643 for i in range(0, len(charstring), self.commamatrixwid): | |
9644 for j in range(i, i + self.commamatrixwid): | |
9645 if charstring[j] == "1": | |
9646 for k in range(sizeint): | |
9647 for l in range(sizeint): | |
9648 if ital and rotate == -1: | |
9649 x = ( | |
9650 xpos | |
9651 + ( | |
9652 int( | |
9653 ( | |
9654 ( | |
9655 self.commamatrixori | |
9656 - self.commamatrixwid | |
9657 + j / self.commamatrixwid | |
9658 ) | |
9659 ) | |
9660 * sizeratio | |
9661 ) | |
9662 - l | |
9663 ) | |
9664 / 3 | |
9665 ) | |
9666 elif ital: | |
9667 x = ( | |
9668 xpos | |
9669 + ( | |
9670 int( | |
9671 ( | |
9672 self.defsize | |
9673 - ( | |
9674 self.commamatrixori | |
9675 + j / self.commamatrixwid | |
9676 ) | |
9677 ) | |
9678 * sizeratio | |
9679 ) | |
9680 - l | |
9681 ) | |
9682 / 3 | |
9683 ) | |
9684 if rotate == 1: | |
9685 self.plotPoint( | |
9686 y | |
9687 + int( | |
9688 (self.commamatrixori + j / self.commamatrixwid) | |
9689 * sizeratio | |
9690 ) | |
9691 - l | |
9692 - self.defsize, | |
9693 x + int((j % self.commamatrixwid) * sizeratio) - k, | |
9694 ) | |
9695 elif rotate == -1: | |
9696 self.plotPoint( | |
9697 y | |
9698 + int( | |
9699 ( | |
9700 self.defsize | |
9701 - ( | |
9702 self.commamatrixori | |
9703 + j / self.commamatrixwid | |
9704 ) | |
9705 ) | |
9706 * sizeratio | |
9707 ) | |
9708 - l, | |
9709 2 * x | |
9710 - ( | |
9711 x | |
9712 + int((j % self.commamatrixwid) * sizeratio) | |
9713 - k | |
9714 ), | |
9715 ) | |
9716 else: | |
9717 self.plotPoint( | |
9718 x + int((j % self.commamatrixwid) * sizeratio) - k, | |
9719 y | |
9720 + int( | |
9721 ( | |
9722 self.defsize | |
9723 - ( | |
9724 self.commamatrixori | |
9725 + j / self.commamatrixwid | |
9726 ) | |
9727 ) | |
9728 * sizeratio | |
9729 ) | |
9730 - l, | |
9731 ) | |
9732 | |
9733 def writefullstop(self, x, y, size, ital, bold, sans, rotate): | |
9734 xpos = x | |
9735 sizeratio = size * 1.0 / self.defsize | |
9736 sizeint = (size - 1) / self.defsize + 1 | |
9737 if bold: | |
9738 sizeint = sizeint + 2 + int(sizeratio) | |
9739 charstring = binar(self.fullstopmatrix) | |
9740 charstring = ( | |
9741 self.fullstopmatrixwid * self.fullstopmatrixhei - len(charstring) | |
9742 ) * "0" + charstring | |
9743 if len(charstring) > self.fullstopmatrixwid * self.fullstopmatrixhei: | |
9744 charstring = charstring[ | |
9745 0 - self.fullstopmatrixwid * self.fullstopmatrixhei : | |
9746 ] | |
9747 for i in range(0, len(charstring), self.fullstopmatrixwid): | |
9748 for j in range(i, i + self.fullstopmatrixwid): | |
9749 if charstring[j] == "1": | |
9750 for k in range(sizeint): | |
9751 for l in range(sizeint): | |
9752 if ital and rotate == -1: | |
9753 x = ( | |
9754 xpos | |
9755 + ( | |
9756 int( | |
9757 ( | |
9758 ( | |
9759 self.fullstopmatrixori | |
9760 - self.fullstopmatrixwid | |
9761 + j / self.fullstopmatrixwid | |
9762 ) | |
9763 ) | |
9764 * sizeratio | |
9765 ) | |
9766 - l | |
9767 ) | |
9768 / 3 | |
9769 ) | |
9770 elif ital: | |
9771 x = ( | |
9772 xpos | |
9773 + ( | |
9774 int( | |
9775 ( | |
9776 self.defsize | |
9777 - ( | |
9778 self.fullstopmatrixori | |
9779 + j / self.fullstopmatrixwid | |
9780 ) | |
9781 ) | |
9782 * sizeratio | |
9783 ) | |
9784 - l | |
9785 ) | |
9786 / 3 | |
9787 ) | |
9788 if rotate == 1: | |
9789 self.plotPoint( | |
9790 y | |
9791 + int( | |
9792 ( | |
9793 self.fullstopmatrixori | |
9794 + j / self.fullstopmatrixwid | |
9795 ) | |
9796 * sizeratio | |
9797 ) | |
9798 - l | |
9799 - self.defsize, | |
9800 x | |
9801 + int((j % self.fullstopmatrixwid) * sizeratio) | |
9802 - k, | |
9803 ) | |
9804 elif rotate == -1: | |
9805 self.plotPoint( | |
9806 y | |
9807 + int( | |
9808 ( | |
9809 self.defsize | |
9810 - ( | |
9811 self.fullstopmatrixori | |
9812 + j / self.fullstopmatrixwid | |
9813 ) | |
9814 ) | |
9815 * sizeratio | |
9816 ) | |
9817 - l, | |
9818 2 * x | |
9819 - ( | |
9820 x | |
9821 + int((j % self.fullstopmatrixwid) * sizeratio) | |
9822 - k | |
9823 ), | |
9824 ) | |
9825 else: | |
9826 self.plotPoint( | |
9827 x | |
9828 + int((j % self.fullstopmatrixwid) * sizeratio) | |
9829 - k, | |
9830 y | |
9831 + int( | |
9832 ( | |
9833 self.defsize | |
9834 - ( | |
9835 self.fullstopmatrixori | |
9836 + j / self.fullstopmatrixwid | |
9837 ) | |
9838 ) | |
9839 * sizeratio | |
9840 ) | |
9841 - l, | |
9842 ) | |
9843 | |
9844 def writeforslash(self, x, y, size, ital, bold, sans, rotate): | |
9845 xpos = x | |
9846 sizeratio = size * 1.0 / self.defsize | |
9847 sizeint = (size - 1) / self.defsize + 1 | |
9848 if bold: | |
9849 sizeint = sizeint + 2 + int(sizeratio) | |
9850 charstring = binar(self.forslashmatrix) | |
9851 charstring = ( | |
9852 self.forslashmatrixwid * self.forslashmatrixhei - len(charstring) | |
9853 ) * "0" + charstring | |
9854 if len(charstring) > self.forslashmatrixwid * self.forslashmatrixhei: | |
9855 charstring = charstring[ | |
9856 0 - self.forslashmatrixwid * self.forslashmatrixhei : | |
9857 ] | |
9858 for i in range(0, len(charstring), self.forslashmatrixwid): | |
9859 for j in range(i, i + self.forslashmatrixwid): | |
9860 if charstring[j] == "1": | |
9861 for k in range(sizeint): | |
9862 for l in range(sizeint): | |
9863 if ital and rotate == -1: | |
9864 x = ( | |
9865 xpos | |
9866 + ( | |
9867 int( | |
9868 ( | |
9869 ( | |
9870 self.forslashmatrixori | |
9871 - self.forslashmatrixwid | |
9872 + j / self.forslashmatrixwid | |
9873 ) | |
9874 ) | |
9875 * sizeratio | |
9876 ) | |
9877 - l | |
9878 ) | |
9879 / 3 | |
9880 ) | |
9881 elif ital: | |
9882 x = ( | |
9883 xpos | |
9884 + ( | |
9885 int( | |
9886 ( | |
9887 self.defsize | |
9888 - ( | |
9889 self.forslashmatrixori | |
9890 + j / self.forslashmatrixwid | |
9891 ) | |
9892 ) | |
9893 * sizeratio | |
9894 ) | |
9895 - l | |
9896 ) | |
9897 / 3 | |
9898 ) | |
9899 if rotate == 1: | |
9900 self.plotPoint( | |
9901 y | |
9902 + int( | |
9903 ( | |
9904 self.forslashmatrixori | |
9905 + j / self.forslashmatrixwid | |
9906 ) | |
9907 * sizeratio | |
9908 ) | |
9909 - l | |
9910 - self.defsize, | |
9911 x | |
9912 + int((j % self.forslashmatrixwid) * sizeratio) | |
9913 - k, | |
9914 ) | |
9915 elif rotate == -1: | |
9916 self.plotPoint( | |
9917 y | |
9918 + int( | |
9919 ( | |
9920 self.defsize | |
9921 - ( | |
9922 self.forslashmatrixori | |
9923 + j / self.forslashmatrixwid | |
9924 ) | |
9925 ) | |
9926 * sizeratio | |
9927 ) | |
9928 - l, | |
9929 2 * x | |
9930 - ( | |
9931 x | |
9932 + int((j % self.forslashmatrixwid) * sizeratio) | |
9933 - k | |
9934 ), | |
9935 ) | |
9936 else: | |
9937 self.plotPoint( | |
9938 x | |
9939 + int((j % self.forslashmatrixwid) * sizeratio) | |
9940 - k, | |
9941 y | |
9942 + int( | |
9943 ( | |
9944 self.defsize | |
9945 - ( | |
9946 self.forslashmatrixori | |
9947 + j / self.forslashmatrixwid | |
9948 ) | |
9949 ) | |
9950 * sizeratio | |
9951 ) | |
9952 - l, | |
9953 ) | |
9954 | |
9955 def writelesthan(self, x, y, size, ital, bold, sans, rotate): | |
9956 xpos = x | |
9957 sizeratio = size * 1.0 / self.defsize | |
9958 sizeint = (size - 1) / self.defsize + 1 | |
9959 if bold: | |
9960 sizeint = sizeint + 2 + int(sizeratio) | |
9961 charstring = binar(self.lesthanmatrix) | |
9962 charstring = ( | |
9963 self.lesthanmatrixwid * self.lesthanmatrixhei - len(charstring) | |
9964 ) * "0" + charstring | |
9965 if len(charstring) > self.lesthanmatrixwid * self.lesthanmatrixhei: | |
9966 charstring = charstring[0 - self.lesthanmatrixwid * self.lesthanmatrixhei :] | |
9967 for i in range(0, len(charstring), self.lesthanmatrixwid): | |
9968 for j in range(i, i + self.lesthanmatrixwid): | |
9969 if charstring[j] == "1": | |
9970 for k in range(sizeint): | |
9971 for l in range(sizeint): | |
9972 if ital and rotate == -1: | |
9973 x = ( | |
9974 xpos | |
9975 + ( | |
9976 int( | |
9977 ( | |
9978 ( | |
9979 self.lesthanmatrixori | |
9980 - self.lesthanmatrixwid | |
9981 + j / self.lesthanmatrixwid | |
9982 ) | |
9983 ) | |
9984 * sizeratio | |
9985 ) | |
9986 - l | |
9987 ) | |
9988 / 3 | |
9989 ) | |
9990 elif ital: | |
9991 x = ( | |
9992 xpos | |
9993 + ( | |
9994 int( | |
9995 ( | |
9996 self.defsize | |
9997 - ( | |
9998 self.lesthanmatrixori | |
9999 + j / self.lesthanmatrixwid | |
10000 ) | |
10001 ) | |
10002 * sizeratio | |
10003 ) | |
10004 - l | |
10005 ) | |
10006 / 3 | |
10007 ) | |
10008 if rotate == 1: | |
10009 self.plotPoint( | |
10010 y | |
10011 + int( | |
10012 ( | |
10013 self.lesthanmatrixori | |
10014 + j / self.lesthanmatrixwid | |
10015 ) | |
10016 * sizeratio | |
10017 ) | |
10018 - l | |
10019 - self.defsize, | |
10020 x | |
10021 + int((j % self.lesthanmatrixwid) * sizeratio) | |
10022 - k, | |
10023 ) | |
10024 elif rotate == -1: | |
10025 self.plotPoint( | |
10026 y | |
10027 + int( | |
10028 ( | |
10029 self.defsize | |
10030 - ( | |
10031 self.lesthanmatrixori | |
10032 + j / self.lesthanmatrixwid | |
10033 ) | |
10034 ) | |
10035 * sizeratio | |
10036 ) | |
10037 - l, | |
10038 2 * x | |
10039 - ( | |
10040 x | |
10041 + int((j % self.lesthanmatrixwid) * sizeratio) | |
10042 - k | |
10043 ), | |
10044 ) | |
10045 else: | |
10046 self.plotPoint( | |
10047 x | |
10048 + int((j % self.lesthanmatrixwid) * sizeratio) | |
10049 - k, | |
10050 y | |
10051 + int( | |
10052 ( | |
10053 self.defsize | |
10054 - ( | |
10055 self.lesthanmatrixori | |
10056 + j / self.lesthanmatrixwid | |
10057 ) | |
10058 ) | |
10059 * sizeratio | |
10060 ) | |
10061 - l, | |
10062 ) | |
10063 | |
10064 def writegreatthan(self, x, y, size, ital, bold, sans, rotate): | |
10065 xpos = x | |
10066 sizeratio = size * 1.0 / self.defsize | |
10067 sizeint = (size - 1) / self.defsize + 1 | |
10068 if bold: | |
10069 sizeint = sizeint + 2 + int(sizeratio) | |
10070 charstring = binar(self.greatthanmatrix) | |
10071 charstring = ( | |
10072 self.greatthanmatrixwid * self.greatthanmatrixhei - len(charstring) | |
10073 ) * "0" + charstring | |
10074 if len(charstring) > self.greatthanmatrixwid * self.greatthanmatrixhei: | |
10075 charstring = charstring[ | |
10076 0 - self.greatthanmatrixwid * self.greatthanmatrixhei : | |
10077 ] | |
10078 for i in range(0, len(charstring), self.greatthanmatrixwid): | |
10079 for j in range(i, i + self.greatthanmatrixwid): | |
10080 if charstring[j] == "1": | |
10081 for k in range(sizeint): | |
10082 for l in range(sizeint): | |
10083 if ital and rotate == -1: | |
10084 x = ( | |
10085 xpos | |
10086 + ( | |
10087 int( | |
10088 ( | |
10089 ( | |
10090 self.greatthanmatrixori | |
10091 - self.greatthanmatrixwid | |
10092 + j / self.greatthanmatrixwid | |
10093 ) | |
10094 ) | |
10095 * sizeratio | |
10096 ) | |
10097 - l | |
10098 ) | |
10099 / 3 | |
10100 ) | |
10101 elif ital: | |
10102 x = ( | |
10103 xpos | |
10104 + ( | |
10105 int( | |
10106 ( | |
10107 self.defsize | |
10108 - ( | |
10109 self.greatthanmatrixori | |
10110 + j / self.greatthanmatrixwid | |
10111 ) | |
10112 ) | |
10113 * sizeratio | |
10114 ) | |
10115 - l | |
10116 ) | |
10117 / 3 | |
10118 ) | |
10119 if rotate == 1: | |
10120 self.plotPoint( | |
10121 y | |
10122 + int( | |
10123 ( | |
10124 self.greatthanmatrixori | |
10125 + j / self.greatthanmatrixwid | |
10126 ) | |
10127 * sizeratio | |
10128 ) | |
10129 - l | |
10130 - self.defsize, | |
10131 x | |
10132 + int((j % self.greatthanmatrixwid) * sizeratio) | |
10133 - k, | |
10134 ) | |
10135 elif rotate == -1: | |
10136 self.plotPoint( | |
10137 y | |
10138 + int( | |
10139 ( | |
10140 self.defsize | |
10141 - ( | |
10142 self.greatthanmatrixori | |
10143 + j / self.greatthanmatrixwid | |
10144 ) | |
10145 ) | |
10146 * sizeratio | |
10147 ) | |
10148 - l, | |
10149 2 * x | |
10150 - ( | |
10151 x | |
10152 + int((j % self.greatthanmatrixwid) * sizeratio) | |
10153 - k | |
10154 ), | |
10155 ) | |
10156 else: | |
10157 self.plotPoint( | |
10158 x | |
10159 + int((j % self.greatthanmatrixwid) * sizeratio) | |
10160 - k, | |
10161 y | |
10162 + int( | |
10163 ( | |
10164 self.defsize | |
10165 - ( | |
10166 self.greatthanmatrixori | |
10167 + j / self.greatthanmatrixwid | |
10168 ) | |
10169 ) | |
10170 * sizeratio | |
10171 ) | |
10172 - l, | |
10173 ) | |
10174 | |
10175 def writequestion(self, x, y, size, ital, bold, sans, rotate): | |
10176 xpos = x | |
10177 sizeratio = size * 1.0 / self.defsize | |
10178 sizeint = (size - 1) / self.defsize + 1 | |
10179 if bold: | |
10180 sizeint = sizeint + 2 + int(sizeratio) | |
10181 charstring = binar(self.questionmatrix) | |
10182 charstring = ( | |
10183 self.questionmatrixwid * self.questionmatrixhei - len(charstring) | |
10184 ) * "0" + charstring | |
10185 if len(charstring) > self.questionmatrixwid * self.questionmatrixhei: | |
10186 charstring = charstring[ | |
10187 0 - self.questionmatrixwid * self.questionmatrixhei : | |
10188 ] | |
10189 for i in range(0, len(charstring), self.questionmatrixwid): | |
10190 for j in range(i, i + self.questionmatrixwid): | |
10191 if charstring[j] == "1": | |
10192 for k in range(sizeint): | |
10193 for l in range(sizeint): | |
10194 if ital and rotate == -1: | |
10195 x = ( | |
10196 xpos | |
10197 + ( | |
10198 int( | |
10199 ( | |
10200 ( | |
10201 self.questionmatrixori | |
10202 - self.questionmatrixwid | |
10203 + j / self.questionmatrixwid | |
10204 ) | |
10205 ) | |
10206 * sizeratio | |
10207 ) | |
10208 - l | |
10209 ) | |
10210 / 3 | |
10211 ) | |
10212 elif ital: | |
10213 x = ( | |
10214 xpos | |
10215 + ( | |
10216 int( | |
10217 ( | |
10218 self.defsize | |
10219 - ( | |
10220 self.questionmatrixori | |
10221 + j / self.questionmatrixwid | |
10222 ) | |
10223 ) | |
10224 * sizeratio | |
10225 ) | |
10226 - l | |
10227 ) | |
10228 / 3 | |
10229 ) | |
10230 if rotate == 1: | |
10231 self.plotPoint( | |
10232 y | |
10233 + int( | |
10234 ( | |
10235 self.questionmatrixori | |
10236 + j / self.questionmatrixwid | |
10237 ) | |
10238 * sizeratio | |
10239 ) | |
10240 - l | |
10241 - self.defsize, | |
10242 x | |
10243 + int((j % self.questionmatrixwid) * sizeratio) | |
10244 - k, | |
10245 ) | |
10246 elif rotate == -1: | |
10247 self.plotPoint( | |
10248 y | |
10249 + int( | |
10250 ( | |
10251 self.defsize | |
10252 - ( | |
10253 self.questionmatrixori | |
10254 + j / self.questionmatrixwid | |
10255 ) | |
10256 ) | |
10257 * sizeratio | |
10258 ) | |
10259 - l, | |
10260 2 * x | |
10261 - ( | |
10262 x | |
10263 + int((j % self.questionmatrixwid) * sizeratio) | |
10264 - k | |
10265 ), | |
10266 ) | |
10267 else: | |
10268 self.plotPoint( | |
10269 x | |
10270 + int((j % self.questionmatrixwid) * sizeratio) | |
10271 - k, | |
10272 y | |
10273 + int( | |
10274 ( | |
10275 self.defsize | |
10276 - ( | |
10277 self.questionmatrixori | |
10278 + j / self.questionmatrixwid | |
10279 ) | |
10280 ) | |
10281 * sizeratio | |
10282 ) | |
10283 - l, | |
10284 ) | |
10285 | |
10286 def writecolon(self, x, y, size, ital, bold, sans, rotate): | |
10287 xpos = x | |
10288 sizeratio = size * 1.0 / self.defsize | |
10289 sizeint = (size - 1) / self.defsize + 1 | |
10290 if bold: | |
10291 sizeint = sizeint + 2 + int(sizeratio) | |
10292 charstring = binar(self.colonmatrix) | |
10293 charstring = ( | |
10294 self.colonmatrixwid * self.colonmatrixhei - len(charstring) | |
10295 ) * "0" + charstring | |
10296 if len(charstring) > self.colonmatrixwid * self.colonmatrixhei: | |
10297 charstring = charstring[0 - self.colonmatrixwid * self.colonmatrixhei :] | |
10298 for i in range(0, len(charstring), self.colonmatrixwid): | |
10299 for j in range(i, i + self.colonmatrixwid): | |
10300 if charstring[j] == "1": | |
10301 for k in range(sizeint): | |
10302 for l in range(sizeint): | |
10303 if ital and rotate == -1: | |
10304 x = ( | |
10305 xpos | |
10306 + ( | |
10307 int( | |
10308 ( | |
10309 ( | |
10310 self.colonmatrixori | |
10311 - self.colonmatrixwid | |
10312 + j / self.colonmatrixwid | |
10313 ) | |
10314 ) | |
10315 * sizeratio | |
10316 ) | |
10317 - l | |
10318 ) | |
10319 / 3 | |
10320 ) | |
10321 elif ital: | |
10322 x = ( | |
10323 xpos | |
10324 + ( | |
10325 int( | |
10326 ( | |
10327 self.defsize | |
10328 - ( | |
10329 self.colonmatrixori | |
10330 + j / self.colonmatrixwid | |
10331 ) | |
10332 ) | |
10333 * sizeratio | |
10334 ) | |
10335 - l | |
10336 ) | |
10337 / 3 | |
10338 ) | |
10339 if rotate == 1: | |
10340 self.plotPoint( | |
10341 y | |
10342 + int( | |
10343 (self.colonmatrixori + j / self.colonmatrixwid) | |
10344 * sizeratio | |
10345 ) | |
10346 - l | |
10347 - self.defsize, | |
10348 x + int((j % self.colonmatrixwid) * sizeratio) - k, | |
10349 ) | |
10350 elif rotate == -1: | |
10351 self.plotPoint( | |
10352 y | |
10353 + int( | |
10354 ( | |
10355 self.defsize | |
10356 - ( | |
10357 self.colonmatrixori | |
10358 + j / self.colonmatrixwid | |
10359 ) | |
10360 ) | |
10361 * sizeratio | |
10362 ) | |
10363 - l, | |
10364 2 * x | |
10365 - ( | |
10366 x | |
10367 + int((j % self.colonmatrixwid) * sizeratio) | |
10368 - k | |
10369 ), | |
10370 ) | |
10371 else: | |
10372 self.plotPoint( | |
10373 x + int((j % self.colonmatrixwid) * sizeratio) - k, | |
10374 y | |
10375 + int( | |
10376 ( | |
10377 self.defsize | |
10378 - ( | |
10379 self.colonmatrixori | |
10380 + j / self.colonmatrixwid | |
10381 ) | |
10382 ) | |
10383 * sizeratio | |
10384 ) | |
10385 - l, | |
10386 ) | |
10387 | |
10388 def writequote(self, x, y, size, ital, bold, sans, rotate): | |
10389 xpos = x | |
10390 sizeratio = size * 1.0 / self.defsize | |
10391 sizeint = (size - 1) / self.defsize + 1 | |
10392 if bold: | |
10393 sizeint = sizeint + 2 + int(sizeratio) | |
10394 charstring = binar(self.quotematrix) | |
10395 charstring = ( | |
10396 self.quotematrixwid * self.quotematrixhei - len(charstring) | |
10397 ) * "0" + charstring | |
10398 if len(charstring) > self.quotematrixwid * self.quotematrixhei: | |
10399 charstring = charstring[0 - self.quotematrixwid * self.quotematrixhei :] | |
10400 for i in range(0, len(charstring), self.quotematrixwid): | |
10401 for j in range(i, i + self.quotematrixwid): | |
10402 if charstring[j] == "1": | |
10403 for k in range(sizeint): | |
10404 for l in range(sizeint): | |
10405 if ital and rotate == -1: | |
10406 x = ( | |
10407 xpos | |
10408 + ( | |
10409 int( | |
10410 ( | |
10411 ( | |
10412 self.quotematrixori | |
10413 - self.quotematrixwid | |
10414 + j / self.quotematrixwid | |
10415 ) | |
10416 ) | |
10417 * sizeratio | |
10418 ) | |
10419 - l | |
10420 ) | |
10421 / 3 | |
10422 ) | |
10423 elif ital: | |
10424 x = ( | |
10425 xpos | |
10426 + ( | |
10427 int( | |
10428 ( | |
10429 self.defsize | |
10430 - ( | |
10431 self.quotematrixori | |
10432 + j / self.quotematrixwid | |
10433 ) | |
10434 ) | |
10435 * sizeratio | |
10436 ) | |
10437 - l | |
10438 ) | |
10439 / 3 | |
10440 ) | |
10441 if rotate == 1: | |
10442 self.plotPoint( | |
10443 y | |
10444 + int( | |
10445 (self.quotematrixori + j / self.quotematrixwid) | |
10446 * sizeratio | |
10447 ) | |
10448 - l | |
10449 - self.defsize, | |
10450 x + int((j % self.quotematrixwid) * sizeratio) - k, | |
10451 ) | |
10452 elif rotate == -1: | |
10453 self.plotPoint( | |
10454 y | |
10455 + int( | |
10456 ( | |
10457 self.defsize | |
10458 - ( | |
10459 self.quotematrixori | |
10460 + j / self.quotematrixwid | |
10461 ) | |
10462 ) | |
10463 * sizeratio | |
10464 ) | |
10465 - l, | |
10466 2 * x | |
10467 - ( | |
10468 x | |
10469 + int((j % self.quotematrixwid) * sizeratio) | |
10470 - k | |
10471 ), | |
10472 ) | |
10473 else: | |
10474 self.plotPoint( | |
10475 x + int((j % self.quotematrixwid) * sizeratio) - k, | |
10476 y | |
10477 + int( | |
10478 ( | |
10479 self.defsize | |
10480 - ( | |
10481 self.quotematrixori | |
10482 + j / self.quotematrixwid | |
10483 ) | |
10484 ) | |
10485 * sizeratio | |
10486 ) | |
10487 - l, | |
10488 ) | |
10489 | |
10490 def writeopensquig(self, x, y, size, ital, bold, sans, rotate): | |
10491 xpos = x | |
10492 sizeratio = size * 1.0 / self.defsize | |
10493 sizeint = (size - 1) / self.defsize + 1 | |
10494 if bold: | |
10495 sizeint = sizeint + 2 + int(sizeratio) | |
10496 charstring = binar(self.opensquigmatrix) | |
10497 charstring = ( | |
10498 self.opensquigmatrixwid * self.opensquigmatrixhei - len(charstring) | |
10499 ) * "0" + charstring | |
10500 if len(charstring) > self.opensquigmatrixwid * self.opensquigmatrixhei: | |
10501 charstring = charstring[ | |
10502 0 - self.opensquigmatrixwid * self.opensquigmatrixhei : | |
10503 ] | |
10504 for i in range(0, len(charstring), self.opensquigmatrixwid): | |
10505 for j in range(i, i + self.opensquigmatrixwid): | |
10506 if charstring[j] == "1": | |
10507 for k in range(sizeint): | |
10508 for l in range(sizeint): | |
10509 if ital and rotate == -1: | |
10510 x = ( | |
10511 xpos | |
10512 + ( | |
10513 int( | |
10514 ( | |
10515 ( | |
10516 self.opensquigmatrixori | |
10517 - self.opensquigmatrixwid | |
10518 + j / self.opensquigmatrixwid | |
10519 ) | |
10520 ) | |
10521 * sizeratio | |
10522 ) | |
10523 - l | |
10524 ) | |
10525 / 3 | |
10526 ) | |
10527 elif ital: | |
10528 x = ( | |
10529 xpos | |
10530 + ( | |
10531 int( | |
10532 ( | |
10533 self.defsize | |
10534 - ( | |
10535 self.opensquigmatrixori | |
10536 + j / self.opensquigmatrixwid | |
10537 ) | |
10538 ) | |
10539 * sizeratio | |
10540 ) | |
10541 - l | |
10542 ) | |
10543 / 3 | |
10544 ) | |
10545 if rotate == 1: | |
10546 self.plotPoint( | |
10547 y | |
10548 + int( | |
10549 ( | |
10550 self.opensquigmatrixori | |
10551 + j / self.opensquigmatrixwid | |
10552 ) | |
10553 * sizeratio | |
10554 ) | |
10555 - l | |
10556 - self.defsize, | |
10557 x | |
10558 + int((j % self.opensquigmatrixwid) * sizeratio) | |
10559 - k, | |
10560 ) | |
10561 elif rotate == -1: | |
10562 self.plotPoint( | |
10563 y | |
10564 + int( | |
10565 ( | |
10566 self.defsize | |
10567 - ( | |
10568 self.opensquigmatrixori | |
10569 + j / self.opensquigmatrixwid | |
10570 ) | |
10571 ) | |
10572 * sizeratio | |
10573 ) | |
10574 - l, | |
10575 2 * x | |
10576 - ( | |
10577 x | |
10578 + int((j % self.opensquigmatrixwid) * sizeratio) | |
10579 - k | |
10580 ), | |
10581 ) | |
10582 else: | |
10583 self.plotPoint( | |
10584 x | |
10585 + int((j % self.opensquigmatrixwid) * sizeratio) | |
10586 - k, | |
10587 y | |
10588 + int( | |
10589 ( | |
10590 self.defsize | |
10591 - ( | |
10592 self.opensquigmatrixori | |
10593 + j / self.opensquigmatrixwid | |
10594 ) | |
10595 ) | |
10596 * sizeratio | |
10597 ) | |
10598 - l, | |
10599 ) | |
10600 | |
10601 def writeclosesquig(self, x, y, size, ital, bold, sans, rotate): | |
10602 xpos = x | |
10603 sizeratio = size * 1.0 / self.defsize | |
10604 sizeint = (size - 1) / self.defsize + 1 | |
10605 if bold: | |
10606 sizeint = sizeint + 2 + int(sizeratio) | |
10607 charstring = binar(self.closesquigmatrix) | |
10608 charstring = ( | |
10609 self.closesquigmatrixwid * self.closesquigmatrixhei - len(charstring) | |
10610 ) * "0" + charstring | |
10611 if len(charstring) > self.closesquigmatrixwid * self.closesquigmatrixhei: | |
10612 charstring = charstring[ | |
10613 0 - self.closesquigmatrixwid * self.closesquigmatrixhei : | |
10614 ] | |
10615 for i in range(0, len(charstring), self.closesquigmatrixwid): | |
10616 for j in range(i, i + self.closesquigmatrixwid): | |
10617 if charstring[j] == "1": | |
10618 for k in range(sizeint): | |
10619 for l in range(sizeint): | |
10620 if ital and rotate == -1: | |
10621 x = ( | |
10622 xpos | |
10623 + ( | |
10624 int( | |
10625 ( | |
10626 ( | |
10627 self.closesquigmatrixori | |
10628 - self.closesquigmatrixwid | |
10629 + j / self.closesquigmatrixwid | |
10630 ) | |
10631 ) | |
10632 * sizeratio | |
10633 ) | |
10634 - l | |
10635 ) | |
10636 / 3 | |
10637 ) | |
10638 elif ital: | |
10639 x = ( | |
10640 xpos | |
10641 + ( | |
10642 int( | |
10643 ( | |
10644 self.defsize | |
10645 - ( | |
10646 self.closesquigmatrixori | |
10647 + j / self.closesquigmatrixwid | |
10648 ) | |
10649 ) | |
10650 * sizeratio | |
10651 ) | |
10652 - l | |
10653 ) | |
10654 / 3 | |
10655 ) | |
10656 if rotate == 1: | |
10657 self.plotPoint( | |
10658 y | |
10659 + int( | |
10660 ( | |
10661 self.closesquigmatrixori | |
10662 + j / self.closesquigmatrixwid | |
10663 ) | |
10664 * sizeratio | |
10665 ) | |
10666 - l | |
10667 - self.defsize, | |
10668 x | |
10669 + int((j % self.closesquigmatrixwid) * sizeratio) | |
10670 - k, | |
10671 ) | |
10672 elif rotate == -1: | |
10673 self.plotPoint( | |
10674 y | |
10675 + int( | |
10676 ( | |
10677 self.defsize | |
10678 - ( | |
10679 self.closesquigmatrixori | |
10680 + j / self.closesquigmatrixwid | |
10681 ) | |
10682 ) | |
10683 * sizeratio | |
10684 ) | |
10685 - l, | |
10686 2 * x | |
10687 - ( | |
10688 x | |
10689 + int( | |
10690 (j % self.closesquigmatrixwid) * sizeratio | |
10691 ) | |
10692 - k | |
10693 ), | |
10694 ) | |
10695 else: | |
10696 self.plotPoint( | |
10697 x | |
10698 + int((j % self.closesquigmatrixwid) * sizeratio) | |
10699 - k, | |
10700 y | |
10701 + int( | |
10702 ( | |
10703 self.defsize | |
10704 - ( | |
10705 self.closesquigmatrixori | |
10706 + j / self.closesquigmatrixwid | |
10707 ) | |
10708 ) | |
10709 * sizeratio | |
10710 ) | |
10711 - l, | |
10712 ) | |
10713 | |
10714 def writebar(self, x, y, size, ital, bold, sans, rotate): | |
10715 xpos = x | |
10716 sizeratio = size * 1.0 / self.defsize | |
10717 sizeint = (size - 1) / self.defsize + 1 | |
10718 if bold: | |
10719 sizeint = sizeint + 2 + int(sizeratio) | |
10720 charstring = binar(self.barmatrix) | |
10721 charstring = ( | |
10722 self.barmatrixwid * self.barmatrixhei - len(charstring) | |
10723 ) * "0" + charstring | |
10724 if len(charstring) > self.barmatrixwid * self.barmatrixhei: | |
10725 charstring = charstring[0 - self.barmatrixwid * self.barmatrixhei :] | |
10726 for i in range(0, len(charstring), self.barmatrixwid): | |
10727 for j in range(i, i + self.barmatrixwid): | |
10728 if charstring[j] == "1": | |
10729 for k in range(sizeint): | |
10730 for l in range(sizeint): | |
10731 if ital and rotate == -1: | |
10732 x = ( | |
10733 xpos | |
10734 + ( | |
10735 int( | |
10736 ( | |
10737 ( | |
10738 self.barmatrixori | |
10739 - self.barmatrixwid | |
10740 + j / self.barmatrixwid | |
10741 ) | |
10742 ) | |
10743 * sizeratio | |
10744 ) | |
10745 - l | |
10746 ) | |
10747 / 3 | |
10748 ) | |
10749 elif ital: | |
10750 x = ( | |
10751 xpos | |
10752 + ( | |
10753 int( | |
10754 ( | |
10755 self.defsize | |
10756 - ( | |
10757 self.barmatrixori | |
10758 + j / self.barmatrixwid | |
10759 ) | |
10760 ) | |
10761 * sizeratio | |
10762 ) | |
10763 - l | |
10764 ) | |
10765 / 3 | |
10766 ) | |
10767 if rotate == 1: | |
10768 self.plotPoint( | |
10769 y | |
10770 + int( | |
10771 (self.barmatrixori + j / self.barmatrixwid) | |
10772 * sizeratio | |
10773 ) | |
10774 - l | |
10775 - self.defsize, | |
10776 x + int((j % self.barmatrixwid) * sizeratio) - k, | |
10777 ) | |
10778 elif rotate == -1: | |
10779 self.plotPoint( | |
10780 y | |
10781 + int( | |
10782 ( | |
10783 self.defsize | |
10784 - ( | |
10785 self.barmatrixori | |
10786 + j / self.barmatrixwid | |
10787 ) | |
10788 ) | |
10789 * sizeratio | |
10790 ) | |
10791 - l, | |
10792 2 * x | |
10793 - ( | |
10794 x + int((j % self.barmatrixwid) * sizeratio) - k | |
10795 ), | |
10796 ) | |
10797 else: | |
10798 self.plotPoint( | |
10799 x + int((j % self.barmatrixwid) * sizeratio) - k, | |
10800 y | |
10801 + int( | |
10802 ( | |
10803 self.defsize | |
10804 - ( | |
10805 self.barmatrixori | |
10806 + j / self.barmatrixwid | |
10807 ) | |
10808 ) | |
10809 * sizeratio | |
10810 ) | |
10811 - l, | |
10812 ) | |
10813 | |
10814 def writemisc(self, x, y, size, ital, bold, sans, rotate): | |
10815 xpos = x | |
10816 sizeratio = size * 1.0 / self.defsize | |
10817 sizeint = (size - 1) / self.defsize + 1 | |
10818 if bold: | |
10819 sizeint = sizeint + 2 + int(sizeratio) | |
10820 charstring = binar(self.miscmatrix) | |
10821 charstring = ( | |
10822 self.miscmatrixwid * self.miscmatrixhei - len(charstring) | |
10823 ) * "0" + charstring | |
10824 if len(charstring) > self.miscmatrixwid * self.miscmatrixhei: | |
10825 charstring = charstring[0 - self.miscmatrixwid * self.miscmatrixhei :] | |
10826 for i in range(0, len(charstring), self.miscmatrixwid): | |
10827 for j in range(i, i + self.miscmatrixwid): | |
10828 if charstring[j] == "1": | |
10829 for k in range(sizeint): | |
10830 for l in range(sizeint): | |
10831 if ital and rotate == -1: | |
10832 x = ( | |
10833 xpos | |
10834 + ( | |
10835 int( | |
10836 ( | |
10837 ( | |
10838 self.miscmatrixori | |
10839 - self.miscmatrixwid | |
10840 + j / self.miscmatrixwid | |
10841 ) | |
10842 ) | |
10843 * sizeratio | |
10844 ) | |
10845 - l | |
10846 ) | |
10847 / 3 | |
10848 ) | |
10849 elif ital: | |
10850 x = ( | |
10851 xpos | |
10852 + ( | |
10853 int( | |
10854 ( | |
10855 self.defsize | |
10856 - ( | |
10857 self.miscmatrixori | |
10858 + j / self.miscmatrixwid | |
10859 ) | |
10860 ) | |
10861 * sizeratio | |
10862 ) | |
10863 - l | |
10864 ) | |
10865 / 3 | |
10866 ) | |
10867 if rotate == 1: | |
10868 self.plotPoint( | |
10869 y | |
10870 + int( | |
10871 (self.miscmatrixori + j / self.miscmatrixwid) | |
10872 * sizeratio | |
10873 ) | |
10874 - l | |
10875 - self.defsize, | |
10876 x + int((j % self.miscmatrixwid) * sizeratio) - k, | |
10877 ) | |
10878 elif rotate == -1: | |
10879 self.plotPoint( | |
10880 y | |
10881 + int( | |
10882 ( | |
10883 self.defsize | |
10884 - ( | |
10885 self.miscmatrixori | |
10886 + j / self.miscmatrixwid | |
10887 ) | |
10888 ) | |
10889 * sizeratio | |
10890 ) | |
10891 - l, | |
10892 2 * x | |
10893 - ( | |
10894 x | |
10895 + int((j % self.miscmatrixwid) * sizeratio) | |
10896 - k | |
10897 ), | |
10898 ) | |
10899 else: | |
10900 self.plotPoint( | |
10901 x + int((j % self.miscmatrixwid) * sizeratio) - k, | |
10902 y | |
10903 + int( | |
10904 ( | |
10905 self.defsize | |
10906 - ( | |
10907 self.miscmatrixori | |
10908 + j / self.miscmatrixwid | |
10909 ) | |
10910 ) | |
10911 * sizeratio | |
10912 ) | |
10913 - l, | |
10914 ) | |
10915 | |
10916 def writeString( | |
10917 self, thestring, x, y, size, ital=False, bold=False, rotate=0, justify="left" | |
10918 ): | |
10919 xpos = x | |
10920 if rotate != 0: | |
10921 xpos, y = y, xpos | |
10922 if justify == "right": | |
10923 xpos -= self.lengthString(thestring, size) | |
10924 for i in thestring: | |
10925 if i == "a": | |
10926 self.writea(xpos, y, size, ital, bold, True, rotate) | |
10927 if rotate == -1: | |
10928 xpos -= self.amatrixwid * size / self.defsize + 1 + size / 20 | |
10929 else: | |
10930 xpos += self.amatrixwid * size / self.defsize + 1 + size / 20 | |
10931 elif i == "b": | |
10932 self.writeb(xpos, y, size, ital, bold, True, rotate) | |
10933 if rotate == -1: | |
10934 xpos -= self.bmatrixwid * size / self.defsize + 1 + size / 20 | |
10935 else: | |
10936 xpos += self.bmatrixwid * size / self.defsize + 1 + size / 20 | |
10937 elif i == "c": | |
10938 self.writec(xpos, y, size, ital, bold, True, rotate) | |
10939 if rotate == -1: | |
10940 xpos -= self.cmatrixwid * size / self.defsize + 1 + size / 20 | |
10941 else: | |
10942 xpos += self.cmatrixwid * size / self.defsize + 1 + size / 20 | |
10943 elif i == "d": | |
10944 self.writed(xpos, y, size, ital, bold, True, rotate) | |
10945 if rotate == -1: | |
10946 xpos -= self.dmatrixwid * size / self.defsize + 1 + size / 20 | |
10947 else: | |
10948 xpos += self.dmatrixwid * size / self.defsize + 1 + size / 20 | |
10949 elif i == "e": | |
10950 self.writee(xpos, y, size, ital, bold, True, rotate) | |
10951 if rotate == -1: | |
10952 xpos -= self.ematrixwid * size / self.defsize + 1 + size / 20 | |
10953 else: | |
10954 xpos += self.ematrixwid * size / self.defsize + 1 + size / 20 | |
10955 elif i == "f": | |
10956 self.writef(xpos, y, size, ital, bold, True, rotate) | |
10957 if rotate == -1: | |
10958 xpos -= self.fmatrixwid * size / self.defsize + 1 + size / 20 | |
10959 else: | |
10960 xpos += self.fmatrixwid * size / self.defsize + 1 + size / 20 | |
10961 elif i == "g": | |
10962 self.writeg(xpos, y, size, ital, bold, True, rotate) | |
10963 if rotate == -1: | |
10964 xpos -= self.gmatrixwid * size / self.defsize + 1 + size / 20 | |
10965 else: | |
10966 xpos += self.gmatrixwid * size / self.defsize + 1 + size / 20 | |
10967 elif i == "h": | |
10968 self.writeh(xpos, y, size, ital, bold, True, rotate) | |
10969 if rotate == -1: | |
10970 xpos -= self.hmatrixwid * size / self.defsize + 1 + size / 20 | |
10971 else: | |
10972 xpos += self.hmatrixwid * size / self.defsize + 1 + size / 20 | |
10973 elif i == "i": | |
10974 self.writei(xpos, y, size, ital, bold, True, rotate) | |
10975 if rotate == -1: | |
10976 xpos -= self.imatrixwid * size / self.defsize + 1 + size / 20 | |
10977 else: | |
10978 xpos += self.imatrixwid * size / self.defsize + 1 + size / 20 | |
10979 elif i == "j": | |
10980 self.writej(xpos, y, size, ital, bold, True, rotate) | |
10981 if rotate == -1: | |
10982 xpos -= self.jmatrixwid * size / self.defsize + 1 + size / 20 | |
10983 else: | |
10984 xpos += self.jmatrixwid * size / self.defsize + 1 + size / 20 | |
10985 elif i == "k": | |
10986 self.writek(xpos, y, size, ital, bold, True, rotate) | |
10987 if rotate == -1: | |
10988 xpos -= self.kmatrixwid * size / self.defsize + 1 + size / 20 | |
10989 else: | |
10990 xpos += self.kmatrixwid * size / self.defsize + 1 + size / 20 | |
10991 elif i == "l": | |
10992 self.writel(xpos, y, size, ital, bold, True, rotate) | |
10993 if rotate == -1: | |
10994 xpos -= self.lmatrixwid * size / self.defsize + 1 + size / 20 | |
10995 else: | |
10996 xpos += self.lmatrixwid * size / self.defsize + 1 + size / 20 | |
10997 elif i == "m": | |
10998 self.writem(xpos, y, size, ital, bold, True, rotate) | |
10999 if rotate == -1: | |
11000 xpos -= self.mmatrixwid * size / self.defsize + 1 + size / 20 | |
11001 else: | |
11002 xpos += self.mmatrixwid * size / self.defsize + 1 + size / 20 | |
11003 elif i == "n": | |
11004 self.writen(xpos, y, size, ital, bold, True, rotate) | |
11005 if rotate == -1: | |
11006 xpos -= self.nmatrixwid * size / self.defsize + 1 + size / 20 | |
11007 else: | |
11008 xpos += self.nmatrixwid * size / self.defsize + 1 + size / 20 | |
11009 elif i == "o": | |
11010 self.writeo(xpos, y, size, ital, bold, True, rotate) | |
11011 if rotate == -1: | |
11012 xpos -= self.omatrixwid * size / self.defsize + 1 + size / 20 | |
11013 else: | |
11014 xpos += self.omatrixwid * size / self.defsize + 1 + size / 20 | |
11015 elif i == "p": | |
11016 self.writep(xpos, y, size, ital, bold, True, rotate) | |
11017 if rotate == -1: | |
11018 xpos -= self.pmatrixwid * size / self.defsize + 1 + size / 20 | |
11019 else: | |
11020 xpos += self.pmatrixwid * size / self.defsize + 1 + size / 20 | |
11021 elif i == "q": | |
11022 self.writeq(xpos, y, size, ital, bold, True, rotate) | |
11023 if rotate == -1: | |
11024 xpos -= self.qmatrixwid * size / self.defsize + 1 + size / 20 | |
11025 else: | |
11026 xpos += self.qmatrixwid * size / self.defsize + 1 + size / 20 | |
11027 elif i == "r": | |
11028 self.writer(xpos, y, size, ital, bold, True, rotate) | |
11029 if rotate == -1: | |
11030 xpos -= self.rmatrixwid * size / self.defsize + 1 + size / 20 | |
11031 else: | |
11032 xpos += self.rmatrixwid * size / self.defsize + 1 + size / 20 | |
11033 elif i == "s": | |
11034 self.writes(xpos, y, size, ital, bold, True, rotate) | |
11035 if rotate == -1: | |
11036 xpos -= self.smatrixwid * size / self.defsize + 1 + size / 20 | |
11037 else: | |
11038 xpos += self.smatrixwid * size / self.defsize + 1 + size / 20 | |
11039 elif i == "t": | |
11040 self.writet(xpos, y, size, ital, bold, True, rotate) | |
11041 if rotate == -1: | |
11042 xpos -= self.tmatrixwid * size / self.defsize + 1 + size / 20 | |
11043 else: | |
11044 xpos += self.tmatrixwid * size / self.defsize + 1 + size / 20 | |
11045 elif i == "u": | |
11046 self.writeu(xpos, y, size, ital, bold, True, rotate) | |
11047 if rotate == -1: | |
11048 xpos -= self.umatrixwid * size / self.defsize + 1 + size / 20 | |
11049 else: | |
11050 xpos += self.umatrixwid * size / self.defsize + 1 + size / 20 | |
11051 elif i == "v": | |
11052 self.writev(xpos, y, size, ital, bold, True, rotate) | |
11053 if rotate == -1: | |
11054 xpos -= self.vmatrixwid * size / self.defsize + 1 + size / 20 | |
11055 else: | |
11056 xpos += self.vmatrixwid * size / self.defsize + 1 + size / 20 | |
11057 elif i == "w": | |
11058 self.writew(xpos, y, size, ital, bold, True, rotate) | |
11059 if rotate == -1: | |
11060 xpos -= self.wmatrixwid * size / self.defsize + 1 + size / 20 | |
11061 else: | |
11062 xpos += self.wmatrixwid * size / self.defsize + 1 + size / 20 | |
11063 elif i == "x": | |
11064 self.writex(xpos, y, size, ital, bold, True, rotate) | |
11065 if rotate == -1: | |
11066 xpos -= self.xmatrixwid * size / self.defsize + 1 + size / 20 | |
11067 else: | |
11068 xpos += self.xmatrixwid * size / self.defsize + 1 + size / 20 | |
11069 elif i == "y": | |
11070 self.writey(xpos, y, size, ital, bold, True, rotate) | |
11071 if rotate == -1: | |
11072 xpos -= self.ymatrixwid * size / self.defsize + 1 + size / 20 | |
11073 else: | |
11074 xpos += self.ymatrixwid * size / self.defsize + 1 + size / 20 | |
11075 elif i == "z": | |
11076 self.writez(xpos, y, size, ital, bold, True, rotate) | |
11077 if rotate == -1: | |
11078 xpos -= self.zmatrixwid * size / self.defsize + 1 + size / 20 | |
11079 else: | |
11080 xpos += self.zmatrixwid * size / self.defsize + 1 + size / 20 | |
11081 elif i == "A": | |
11082 self.writeA(xpos, y, size, ital, bold, True, rotate) | |
11083 if rotate == -1: | |
11084 xpos -= self.Amatrixwid * size / self.defsize + 1 + size / 20 | |
11085 else: | |
11086 xpos += self.Amatrixwid * size / self.defsize + 1 + size / 20 | |
11087 elif i == "B": | |
11088 self.writeB(xpos, y, size, ital, bold, True, rotate) | |
11089 if rotate == -1: | |
11090 xpos -= self.Bmatrixwid * size / self.defsize + 1 + size / 20 | |
11091 else: | |
11092 xpos += self.Bmatrixwid * size / self.defsize + 1 + size / 20 | |
11093 elif i == "C": | |
11094 self.writeC(xpos, y, size, ital, bold, True, rotate) | |
11095 if rotate == -1: | |
11096 xpos -= self.Cmatrixwid * size / self.defsize + 1 + size / 20 | |
11097 else: | |
11098 xpos += self.Cmatrixwid * size / self.defsize + 1 + size / 20 | |
11099 elif i == "D": | |
11100 self.writeD(xpos, y, size, ital, bold, True, rotate) | |
11101 if rotate == -1: | |
11102 xpos -= self.Dmatrixwid * size / self.defsize + 1 + size / 20 | |
11103 else: | |
11104 xpos += self.Dmatrixwid * size / self.defsize + 1 + size / 20 | |
11105 elif i == "E": | |
11106 self.writeE(xpos, y, size, ital, bold, True, rotate) | |
11107 if rotate == -1: | |
11108 xpos -= self.Ematrixwid * size / self.defsize + 1 + size / 20 | |
11109 else: | |
11110 xpos += self.Ematrixwid * size / self.defsize + 1 + size / 20 | |
11111 elif i == "F": | |
11112 self.writeF(xpos, y, size, ital, bold, True, rotate) | |
11113 if rotate == -1: | |
11114 xpos -= self.Fmatrixwid * size / self.defsize + 1 + size / 20 | |
11115 else: | |
11116 xpos += self.Fmatrixwid * size / self.defsize + 1 + size / 20 | |
11117 elif i == "G": | |
11118 self.writeG(xpos, y, size, ital, bold, True, rotate) | |
11119 if rotate == -1: | |
11120 xpos -= self.Gmatrixwid * size / self.defsize + 1 + size / 20 | |
11121 else: | |
11122 xpos += self.Gmatrixwid * size / self.defsize + 1 + size / 20 | |
11123 elif i == "H": | |
11124 self.writeH(xpos, y, size, ital, bold, True, rotate) | |
11125 if rotate == -1: | |
11126 xpos -= self.Hmatrixwid * size / self.defsize + 1 + size / 20 | |
11127 else: | |
11128 xpos += self.Hmatrixwid * size / self.defsize + 1 + size / 20 | |
11129 elif i == "I": | |
11130 self.writeI(xpos, y, size, ital, bold, True, rotate) | |
11131 if rotate == -1: | |
11132 xpos -= self.Imatrixwid * size / self.defsize + 1 + size / 20 | |
11133 else: | |
11134 xpos += self.Imatrixwid * size / self.defsize + 1 + size / 20 | |
11135 elif i == "J": | |
11136 self.writeJ(xpos, y, size, ital, bold, True, rotate) | |
11137 if rotate == -1: | |
11138 xpos -= self.Jmatrixwid * size / self.defsize + 1 + size / 20 | |
11139 else: | |
11140 xpos += self.Jmatrixwid * size / self.defsize + 1 + size / 20 | |
11141 elif i == "K": | |
11142 self.writeK(xpos, y, size, ital, bold, True, rotate) | |
11143 if rotate == -1: | |
11144 xpos -= self.Kmatrixwid * size / self.defsize + 1 + size / 20 | |
11145 else: | |
11146 xpos += self.Kmatrixwid * size / self.defsize + 1 + size / 20 | |
11147 elif i == "L": | |
11148 self.writeL(xpos, y, size, ital, bold, True, rotate) | |
11149 if rotate == -1: | |
11150 xpos -= self.Lmatrixwid * size / self.defsize + 1 + size / 20 | |
11151 else: | |
11152 xpos += self.Lmatrixwid * size / self.defsize + 1 + size / 20 | |
11153 elif i == "M": | |
11154 self.writeM(xpos, y, size, ital, bold, True, rotate) | |
11155 if rotate == -1: | |
11156 xpos -= self.Mmatrixwid * size / self.defsize + 1 + size / 20 | |
11157 else: | |
11158 xpos += self.Mmatrixwid * size / self.defsize + 1 + size / 20 | |
11159 elif i == "N": | |
11160 self.writeN(xpos, y, size, ital, bold, True, rotate) | |
11161 if rotate == -1: | |
11162 xpos -= self.Nmatrixwid * size / self.defsize + 1 + size / 20 | |
11163 else: | |
11164 xpos += self.Nmatrixwid * size / self.defsize + 1 + size / 20 | |
11165 elif i == "O": | |
11166 self.writeO(xpos, y, size, ital, bold, True, rotate) | |
11167 if rotate == -1: | |
11168 xpos -= self.Omatrixwid * size / self.defsize + 1 + size / 20 | |
11169 else: | |
11170 xpos += self.Omatrixwid * size / self.defsize + 1 + size / 20 | |
11171 elif i == "P": | |
11172 self.writeP(xpos, y, size, ital, bold, True, rotate) | |
11173 if rotate == -1: | |
11174 xpos -= self.Pmatrixwid * size / self.defsize + 1 + size / 20 | |
11175 else: | |
11176 xpos += self.Pmatrixwid * size / self.defsize + 1 + size / 20 | |
11177 elif i == "Q": | |
11178 self.writeQ(xpos, y, size, ital, bold, True, rotate) | |
11179 if rotate == -1: | |
11180 xpos -= self.Qmatrixwid * size / self.defsize + 1 + size / 20 | |
11181 else: | |
11182 xpos += self.Qmatrixwid * size / self.defsize + 1 + size / 20 | |
11183 elif i == "R": | |
11184 self.writeR(xpos, y, size, ital, bold, True, rotate) | |
11185 if rotate == -1: | |
11186 xpos -= self.Rmatrixwid * size / self.defsize + 1 + size / 20 | |
11187 else: | |
11188 xpos += self.Rmatrixwid * size / self.defsize + 1 + size / 20 | |
11189 elif i == "S": | |
11190 self.writeS(xpos, y, size, ital, bold, True, rotate) | |
11191 if rotate == -1: | |
11192 xpos -= self.Smatrixwid * size / self.defsize + 1 + size / 20 | |
11193 else: | |
11194 xpos += self.Smatrixwid * size / self.defsize + 1 + size / 20 | |
11195 elif i == "T": | |
11196 self.writeT(xpos, y, size, ital, bold, True, rotate) | |
11197 if rotate == -1: | |
11198 xpos -= self.Tmatrixwid * size / self.defsize + 1 + size / 20 | |
11199 else: | |
11200 xpos += self.Tmatrixwid * size / self.defsize + 1 + size / 20 | |
11201 elif i == "U": | |
11202 self.writeU(xpos, y, size, ital, bold, True, rotate) | |
11203 if rotate == -1: | |
11204 xpos -= self.Umatrixwid * size / self.defsize + 1 + size / 20 | |
11205 else: | |
11206 xpos += self.Umatrixwid * size / self.defsize + 1 + size / 20 | |
11207 elif i == "V": | |
11208 self.writeV(xpos, y, size, ital, bold, True, rotate) | |
11209 if rotate == -1: | |
11210 xpos -= self.Vmatrixwid * size / self.defsize + 1 + size / 20 | |
11211 else: | |
11212 xpos += self.Vmatrixwid * size / self.defsize + 1 + size / 20 | |
11213 elif i == "W": | |
11214 self.writeW(xpos, y, size, ital, bold, True, rotate) | |
11215 if rotate == -1: | |
11216 xpos -= self.Wmatrixwid * size / self.defsize + 1 + size / 20 | |
11217 else: | |
11218 xpos += self.Wmatrixwid * size / self.defsize + 1 + size / 20 | |
11219 elif i == "X": | |
11220 self.writeX(xpos, y, size, ital, bold, True, rotate) | |
11221 if rotate == -1: | |
11222 xpos -= self.Xmatrixwid * size / self.defsize + 1 + size / 20 | |
11223 else: | |
11224 xpos += self.Xmatrixwid * size / self.defsize + 1 + size / 20 | |
11225 elif i == "Y": | |
11226 self.writeY(xpos, y, size, ital, bold, True, rotate) | |
11227 if rotate == -1: | |
11228 xpos -= self.Ymatrixwid * size / self.defsize + 1 + size / 20 | |
11229 else: | |
11230 xpos += self.Ymatrixwid * size / self.defsize + 1 + size / 20 | |
11231 elif i == "Z": | |
11232 self.writeZ(xpos, y, size, ital, bold, True, rotate) | |
11233 if rotate == -1: | |
11234 xpos -= self.Zmatrixwid * size / self.defsize + 1 + size / 20 | |
11235 else: | |
11236 xpos += self.Zmatrixwid * size / self.defsize + 1 + size / 20 | |
11237 elif i == "1": | |
11238 self.writeone(xpos, y, size, ital, bold, True, rotate) | |
11239 if rotate == -1: | |
11240 xpos -= self.onematrixwid * size / self.defsize + 1 + size / 20 | |
11241 else: | |
11242 xpos += self.onematrixwid * size / self.defsize + 1 + size / 20 | |
11243 elif i == "2": | |
11244 self.writetwo(xpos, y, size, ital, bold, True, rotate) | |
11245 if rotate == -1: | |
11246 xpos -= self.twomatrixwid * size / self.defsize + 1 + size / 20 | |
11247 else: | |
11248 xpos += self.twomatrixwid * size / self.defsize + 1 + size / 20 | |
11249 elif i == "3": | |
11250 self.writethree(xpos, y, size, ital, bold, True, rotate) | |
11251 if rotate == -1: | |
11252 xpos -= self.threematrixwid * size / self.defsize + 1 + size / 20 | |
11253 else: | |
11254 xpos += self.threematrixwid * size / self.defsize + 1 + size / 20 | |
11255 elif i == "4": | |
11256 self.writefour(xpos, y, size, ital, bold, True, rotate) | |
11257 if rotate == -1: | |
11258 xpos -= self.fourmatrixwid * size / self.defsize + 1 + size / 20 | |
11259 else: | |
11260 xpos += self.fourmatrixwid * size / self.defsize + 1 + size / 20 | |
11261 elif i == "5": | |
11262 self.writefive(xpos, y, size, ital, bold, True, rotate) | |
11263 if rotate == -1: | |
11264 xpos -= self.fivematrixwid * size / self.defsize + 1 + size / 20 | |
11265 else: | |
11266 xpos += self.fivematrixwid * size / self.defsize + 1 + size / 20 | |
11267 elif i == "6": | |
11268 self.writesix(xpos, y, size, ital, bold, True, rotate) | |
11269 if rotate == -1: | |
11270 xpos -= self.sixmatrixwid * size / self.defsize + 1 + size / 20 | |
11271 else: | |
11272 xpos += self.sixmatrixwid * size / self.defsize + 1 + size / 20 | |
11273 elif i == "7": | |
11274 self.writeseven(xpos, y, size, ital, bold, True, rotate) | |
11275 if rotate == -1: | |
11276 xpos -= self.sevenmatrixwid * size / self.defsize + 1 + size / 20 | |
11277 else: | |
11278 xpos += self.sevenmatrixwid * size / self.defsize + 1 + size / 20 | |
11279 elif i == "8": | |
11280 self.writeeight(xpos, y, size, ital, bold, True, rotate) | |
11281 if rotate == -1: | |
11282 xpos -= self.eightmatrixwid * size / self.defsize + 1 + size / 20 | |
11283 else: | |
11284 xpos += self.eightmatrixwid * size / self.defsize + 1 + size / 20 | |
11285 elif i == "9": | |
11286 self.writenine(xpos, y, size, ital, bold, True, rotate) | |
11287 if rotate == -1: | |
11288 xpos -= self.ninematrixwid * size / self.defsize + 1 + size / 20 | |
11289 else: | |
11290 xpos += self.ninematrixwid * size / self.defsize + 1 + size / 20 | |
11291 elif i == "0": | |
11292 self.writeten(xpos, y, size, ital, bold, True, rotate) | |
11293 if rotate == -1: | |
11294 xpos -= self.tenmatrixwid * size / self.defsize + 1 + size / 20 | |
11295 else: | |
11296 xpos += self.tenmatrixwid * size / self.defsize + 1 + size / 20 | |
11297 elif i == "_": | |
11298 self.write_(xpos, y, size, ital, bold, True, rotate) | |
11299 if rotate == -1: | |
11300 xpos -= self._matrixwid * size / self.defsize + 1 + size / 20 | |
11301 else: | |
11302 xpos += self._matrixwid * size / self.defsize + 1 + size / 20 | |
11303 elif i == "-": | |
11304 self.writeminus(xpos, y, size, ital, bold, True, rotate) | |
11305 if rotate == -1: | |
11306 xpos -= self.minusmatrixwid * size / self.defsize + 1 + size / 20 | |
11307 else: | |
11308 xpos += self.minusmatrixwid * size / self.defsize + 1 + size / 20 | |
11309 elif i == "+": | |
11310 self.writeplus(xpos, y, size, ital, bold, True, rotate) | |
11311 if rotate == -1: | |
11312 xpos -= self.plusmatrixwid * size / self.defsize + 1 + size / 20 | |
11313 else: | |
11314 xpos += self.plusmatrixwid * size / self.defsize + 1 + size / 20 | |
11315 elif i == "=": | |
11316 self.writeequal(xpos, y, size, ital, bold, True, rotate) | |
11317 if rotate == -1: | |
11318 xpos -= self.equalmatrixwid * size / self.defsize + 1 + size / 20 | |
11319 else: | |
11320 xpos += self.equalmatrixwid * size / self.defsize + 1 + size / 20 | |
11321 elif i == "!": | |
11322 self.writeexcl(xpos, y, size, ital, bold, True, rotate) | |
11323 if rotate == -1: | |
11324 xpos -= self.exclmatrixwid * size / self.defsize + 1 + size / 20 | |
11325 else: | |
11326 xpos += self.exclmatrixwid * size / self.defsize + 1 + size / 20 | |
11327 elif i == "@": | |
11328 self.writeat(xpos, y, size, ital, bold, True, rotate) | |
11329 if rotate == -1: | |
11330 xpos -= self.atmatrixwid * size / self.defsize + 1 + size / 20 | |
11331 else: | |
11332 xpos += self.atmatrixwid * size / self.defsize + 1 + size / 20 | |
11333 elif i == "#": | |
11334 self.writehash(xpos, y, size, ital, bold, True, rotate) | |
11335 if rotate == -1: | |
11336 xpos -= self.hashmatrixwid * size / self.defsize + 1 + size / 20 | |
11337 else: | |
11338 xpos += self.hashmatrixwid * size / self.defsize + 1 + size / 20 | |
11339 elif i == "$": | |
11340 self.writedollar(xpos, y, size, ital, bold, True, rotate) | |
11341 if rotate == -1: | |
11342 xpos -= self.dollarmatrixwid * size / self.defsize + 1 + size / 20 | |
11343 else: | |
11344 xpos += self.dollarmatrixwid * size / self.defsize + 1 + size / 20 | |
11345 elif i == "%": | |
11346 self.writepercent(xpos, y, size, ital, bold, True, rotate) | |
11347 if rotate == -1: | |
11348 xpos -= self.percentmatrixwid * size / self.defsize + 1 + size / 20 | |
11349 else: | |
11350 xpos += self.percentmatrixwid * size / self.defsize + 1 + size / 20 | |
11351 elif i == "^": | |
11352 self.writehat(xpos, y, size, ital, bold, True, rotate) | |
11353 if rotate == -1: | |
11354 xpos -= self.hatmatrixwid * size / self.defsize + 1 + size / 20 | |
11355 else: | |
11356 xpos += self.hatmatrixwid * size / self.defsize + 1 + size / 20 | |
11357 elif i == "&": | |
11358 self.writeamp(xpos, y, size, ital, bold, True, rotate) | |
11359 if rotate == -1: | |
11360 xpos -= self.ampmatrixwid * size / self.defsize + 1 + size / 20 | |
11361 else: | |
11362 xpos += self.ampmatrixwid * size / self.defsize + 1 + size / 20 | |
11363 elif i == "*": | |
11364 self.writestrix(xpos, y, size, ital, bold, True, rotate) | |
11365 if rotate == -1: | |
11366 xpos -= self.strixmatrixwid * size / self.defsize + 1 + size / 20 | |
11367 else: | |
11368 xpos += self.strixmatrixwid * size / self.defsize + 1 + size / 20 | |
11369 elif i == "(": | |
11370 self.writeopencpar(xpos, y, size, ital, bold, True, rotate) | |
11371 if rotate == -1: | |
11372 xpos -= self.opencparmatrixwid * size / self.defsize + 1 + size / 20 | |
11373 else: | |
11374 xpos += self.opencparmatrixwid * size / self.defsize + 1 + size / 20 | |
11375 elif i == ")": | |
11376 self.writeclosecpar(xpos, y, size, ital, bold, True, rotate) | |
11377 if rotate == -1: | |
11378 xpos -= ( | |
11379 self.closecparmatrixwid * size / self.defsize + 1 + size / 20 | |
11380 ) | |
11381 else: | |
11382 xpos += ( | |
11383 self.closecparmatrixwid * size / self.defsize + 1 + size / 20 | |
11384 ) | |
11385 elif i == "[": | |
11386 self.writeopenspar(xpos, y, size, ital, bold, True, rotate) | |
11387 if rotate == -1: | |
11388 xpos -= self.opensparmatrixwid * size / self.defsize + 1 + size / 20 | |
11389 else: | |
11390 xpos += self.opensparmatrixwid * size / self.defsize + 1 + size / 20 | |
11391 elif i == "]": | |
11392 self.writeclosespar(xpos, y, size, ital, bold, True, rotate) | |
11393 if rotate == -1: | |
11394 xpos -= ( | |
11395 self.closesparmatrixwid * size / self.defsize + 1 + size / 20 | |
11396 ) | |
11397 else: | |
11398 xpos += ( | |
11399 self.closesparmatrixwid * size / self.defsize + 1 + size / 20 | |
11400 ) | |
11401 elif i == "\\": | |
11402 self.writebackslash(xpos, y, size, ital, bold, True, rotate) | |
11403 if rotate == -1: | |
11404 xpos -= ( | |
11405 self.backslashmatrixwid * size / self.defsize + 1 + size / 20 | |
11406 ) | |
11407 else: | |
11408 xpos += ( | |
11409 self.backslashmatrixwid * size / self.defsize + 1 + size / 20 | |
11410 ) | |
11411 elif i == ";": | |
11412 self.writesemicol(xpos, y, size, ital, bold, True, rotate) | |
11413 if rotate == -1: | |
11414 xpos -= self.semicolmatrixwid * size / self.defsize + 1 + size / 20 | |
11415 else: | |
11416 xpos += self.semicolmatrixwid * size / self.defsize + 1 + size / 20 | |
11417 elif i == "'": | |
11418 self.writepost(xpos, y, size, ital, bold, True, rotate) | |
11419 if rotate == -1: | |
11420 xpos -= self.postmatrixwid * size / self.defsize + 1 + size / 20 | |
11421 else: | |
11422 xpos += self.postmatrixwid * size / self.defsize + 1 + size / 20 | |
11423 elif i == ",": | |
11424 self.writecomma(xpos, y, size, ital, bold, True, rotate) | |
11425 if rotate == -1: | |
11426 xpos -= self.commamatrixwid * size / self.defsize + 1 + size / 20 | |
11427 else: | |
11428 xpos += self.commamatrixwid * size / self.defsize + 1 + size / 20 | |
11429 elif i == ".": | |
11430 self.writefullstop(xpos, y, size, ital, bold, True, rotate) | |
11431 if rotate == -1: | |
11432 xpos -= self.fullstopmatrixwid * size / self.defsize + 1 + size / 20 | |
11433 else: | |
11434 xpos += self.fullstopmatrixwid * size / self.defsize + 1 + size / 20 | |
11435 elif i == "/": | |
11436 self.writeforslash(xpos, y, size, ital, bold, True, rotate) | |
11437 if rotate == -1: | |
11438 xpos -= self.forslashmatrixwid * size / self.defsize + 1 + size / 20 | |
11439 else: | |
11440 xpos += self.forslashmatrixwid * size / self.defsize + 1 + size / 20 | |
11441 elif i == "<": | |
11442 self.writelesthan(xpos, y, size, ital, bold, True, rotate) | |
11443 if rotate == -1: | |
11444 xpos -= self.lesthanmatrixwid * size / self.defsize + 1 + size / 20 | |
11445 else: | |
11446 xpos += self.lesthanmatrixwid * size / self.defsize + 1 + size / 20 | |
11447 elif i == ">": | |
11448 self.writegreatthan(xpos, y, size, ital, bold, True, rotate) | |
11449 if rotate == -1: | |
11450 xpos -= ( | |
11451 self.greatthanmatrixwid * size / self.defsize + 1 + size / 20 | |
11452 ) | |
11453 else: | |
11454 xpos += ( | |
11455 self.greatthanmatrixwid * size / self.defsize + 1 + size / 20 | |
11456 ) | |
11457 elif i == "?": | |
11458 self.writequestion(xpos, y, size, ital, bold, True, rotate) | |
11459 if rotate == -1: | |
11460 xpos -= self.questionmatrixwid * size / self.defsize + 1 + size / 20 | |
11461 else: | |
11462 xpos += self.questionmatrixwid * size / self.defsize + 1 + size / 20 | |
11463 elif i == ":": | |
11464 self.writecolon(xpos, y, size, ital, bold, True, rotate) | |
11465 if rotate == -1: | |
11466 xpos -= self.colonmatrixwid * size / self.defsize + 1 + size / 20 | |
11467 else: | |
11468 xpos += self.colonmatrixwid * size / self.defsize + 1 + size / 20 | |
11469 elif i == '"': | |
11470 self.writequote(xpos, y, size, ital, bold, True, rotate) | |
11471 if rotate == -1: | |
11472 xpos -= self.quotematrixwid * size / self.defsize + 1 + size / 20 | |
11473 else: | |
11474 xpos += self.quotematrixwid * size / self.defsize + 1 + size / 20 | |
11475 elif i == "{": | |
11476 self.writeopensquig(xpos, y, size, ital, bold, True, rotate) | |
11477 if rotate == -1: | |
11478 xpos -= ( | |
11479 self.opensquigmatrixwid * size / self.defsize + 1 + size / 20 | |
11480 ) | |
11481 else: | |
11482 xpos += ( | |
11483 self.opensquigmatrixwid * size / self.defsize + 1 + size / 20 | |
11484 ) | |
11485 elif i == "}": | |
11486 self.writeclosesquig(xpos, y, size, ital, bold, True, rotate) | |
11487 if rotate == -1: | |
11488 xpos -= ( | |
11489 self.closesquigmatrixwid * size / self.defsize + 1 + size / 20 | |
11490 ) | |
11491 else: | |
11492 xpos += ( | |
11493 self.closesquigmatrixwid * size / self.defsize + 1 + size / 20 | |
11494 ) | |
11495 elif i == "|": | |
11496 self.writebar(xpos, y, size, ital, bold, True, rotate) | |
11497 if rotate == -1: | |
11498 xpos -= self.barmatrixwid * size / self.defsize + 1 + size / 20 | |
11499 else: | |
11500 xpos += self.barmatrixwid * size / self.defsize + 1 + size / 20 | |
11501 elif i == " ": | |
11502 if rotate == -1: | |
11503 xpos -= 24 * size / self.defsize + 1 + size / 20 | |
11504 else: | |
11505 xpos += 24 * size / self.defsize + 1 + size / 20 | |
11506 else: | |
11507 self.writemisc(xpos, y, size, ital, bold, True, rotate) | |
11508 if rotate == -1: | |
11509 xpos -= self.miscmatrixwid * size / self.defsize + 1 + size / 20 | |
11510 else: | |
11511 xpos += self.miscmatrixwid * size / self.defsize + 1 + size / 20 | |
11512 | |
11513 def lengthString(self, theString, size): | |
11514 xpos = 0 | |
11515 for i in theString: | |
11516 if i == "a": | |
11517 xpos += self.amatrixwid * size / self.defsize + 1 + size / 20 | |
11518 elif i == "b": | |
11519 xpos += self.bmatrixwid * size / self.defsize + 1 + size / 20 | |
11520 elif i == "c": | |
11521 xpos += self.cmatrixwid * size / self.defsize + 1 + size / 20 | |
11522 elif i == "d": | |
11523 xpos += self.dmatrixwid * size / self.defsize + 1 + size / 20 | |
11524 elif i == "e": | |
11525 xpos += self.ematrixwid * size / self.defsize + 1 + size / 20 | |
11526 elif i == "f": | |
11527 xpos += self.fmatrixwid * size / self.defsize + 1 + size / 20 | |
11528 elif i == "g": | |
11529 xpos += self.gmatrixwid * size / self.defsize + 1 + size / 20 | |
11530 elif i == "h": | |
11531 xpos += self.hmatrixwid * size / self.defsize + 1 + size / 20 | |
11532 elif i == "i": | |
11533 xpos += self.imatrixwid * size / self.defsize + 1 + size / 20 | |
11534 elif i == "j": | |
11535 xpos += self.jmatrixwid * size / self.defsize + 1 + size / 20 | |
11536 elif i == "k": | |
11537 xpos += self.kmatrixwid * size / self.defsize + 1 + size / 20 | |
11538 elif i == "l": | |
11539 xpos += self.lmatrixwid * size / self.defsize + 1 + size / 20 | |
11540 elif i == "m": | |
11541 xpos += self.mmatrixwid * size / self.defsize + 1 + size / 20 | |
11542 elif i == "n": | |
11543 xpos += self.nmatrixwid * size / self.defsize + 1 + size / 20 | |
11544 elif i == "o": | |
11545 xpos += self.omatrixwid * size / self.defsize + 1 + size / 20 | |
11546 elif i == "p": | |
11547 xpos += self.pmatrixwid * size / self.defsize + 1 + size / 20 | |
11548 elif i == "q": | |
11549 xpos += self.qmatrixwid * size / self.defsize + 1 + size / 20 | |
11550 elif i == "r": | |
11551 xpos += self.rmatrixwid * size / self.defsize + 1 + size / 20 | |
11552 elif i == "s": | |
11553 xpos += self.smatrixwid * size / self.defsize + 1 + size / 20 | |
11554 elif i == "t": | |
11555 xpos += self.tmatrixwid * size / self.defsize + 1 + size / 20 | |
11556 elif i == "u": | |
11557 xpos += self.umatrixwid * size / self.defsize + 1 + size / 20 | |
11558 elif i == "v": | |
11559 xpos += self.vmatrixwid * size / self.defsize + 1 + size / 20 | |
11560 elif i == "w": | |
11561 xpos += self.wmatrixwid * size / self.defsize + 1 + size / 20 | |
11562 elif i == "x": | |
11563 xpos += self.xmatrixwid * size / self.defsize + 1 + size / 20 | |
11564 elif i == "y": | |
11565 xpos += self.ymatrixwid * size / self.defsize + 1 + size / 20 | |
11566 elif i == "z": | |
11567 xpos += self.zmatrixwid * size / self.defsize + 1 + size / 20 | |
11568 elif i == "A": | |
11569 xpos += self.Amatrixwid * size / self.defsize + 1 + size / 20 | |
11570 elif i == "B": | |
11571 xpos += self.Bmatrixwid * size / self.defsize + 1 + size / 20 | |
11572 elif i == "C": | |
11573 xpos += self.Cmatrixwid * size / self.defsize + 1 + size / 20 | |
11574 elif i == "D": | |
11575 xpos += self.Dmatrixwid * size / self.defsize + 1 + size / 20 | |
11576 elif i == "E": | |
11577 xpos += self.Ematrixwid * size / self.defsize + 1 + size / 20 | |
11578 elif i == "F": | |
11579 xpos += self.Fmatrixwid * size / self.defsize + 1 + size / 20 | |
11580 elif i == "G": | |
11581 xpos += self.Gmatrixwid * size / self.defsize + 1 + size / 20 | |
11582 elif i == "H": | |
11583 xpos += self.Hmatrixwid * size / self.defsize + 1 + size / 20 | |
11584 elif i == "I": | |
11585 xpos += self.Imatrixwid * size / self.defsize + 1 + size / 20 | |
11586 elif i == "J": | |
11587 xpos += self.Jmatrixwid * size / self.defsize + 1 + size / 20 | |
11588 elif i == "K": | |
11589 xpos += self.Kmatrixwid * size / self.defsize + 1 + size / 20 | |
11590 elif i == "L": | |
11591 xpos += self.Lmatrixwid * size / self.defsize + 1 + size / 20 | |
11592 elif i == "M": | |
11593 xpos += self.Mmatrixwid * size / self.defsize + 1 + size / 20 | |
11594 elif i == "N": | |
11595 xpos += self.Nmatrixwid * size / self.defsize + 1 + size / 20 | |
11596 elif i == "O": | |
11597 xpos += self.Omatrixwid * size / self.defsize + 1 + size / 20 | |
11598 elif i == "P": | |
11599 xpos += self.Pmatrixwid * size / self.defsize + 1 + size / 20 | |
11600 elif i == "Q": | |
11601 xpos += self.Qmatrixwid * size / self.defsize + 1 + size / 20 | |
11602 elif i == "R": | |
11603 xpos += self.Rmatrixwid * size / self.defsize + 1 + size / 20 | |
11604 elif i == "S": | |
11605 xpos += self.Smatrixwid * size / self.defsize + 1 + size / 20 | |
11606 elif i == "T": | |
11607 xpos += self.Tmatrixwid * size / self.defsize + 1 + size / 20 | |
11608 elif i == "U": | |
11609 xpos += self.Umatrixwid * size / self.defsize + 1 + size / 20 | |
11610 elif i == "V": | |
11611 xpos += self.Vmatrixwid * size / self.defsize + 1 + size / 20 | |
11612 elif i == "W": | |
11613 xpos += self.Wmatrixwid * size / self.defsize + 1 + size / 20 | |
11614 elif i == "X": | |
11615 xpos += self.Xmatrixwid * size / self.defsize + 1 + size / 20 | |
11616 elif i == "Y": | |
11617 xpos += self.Ymatrixwid * size / self.defsize + 1 + size / 20 | |
11618 elif i == "Z": | |
11619 xpos += self.Zmatrixwid * size / self.defsize + 1 + size / 20 | |
11620 elif i == "1": | |
11621 xpos += self.onematrixwid * size / self.defsize + 1 + size / 20 | |
11622 elif i == "2": | |
11623 xpos += self.twomatrixwid * size / self.defsize + 1 + size / 20 | |
11624 elif i == "3": | |
11625 xpos += self.threematrixwid * size / self.defsize + 1 + size / 20 | |
11626 elif i == "4": | |
11627 xpos += self.fourmatrixwid * size / self.defsize + 1 + size / 20 | |
11628 elif i == "5": | |
11629 xpos += self.fivematrixwid * size / self.defsize + 1 + size / 20 | |
11630 elif i == "6": | |
11631 xpos += self.sixmatrixwid * size / self.defsize + 1 + size / 20 | |
11632 elif i == "7": | |
11633 xpos += self.sevenmatrixwid * size / self.defsize + 1 + size / 20 | |
11634 elif i == "8": | |
11635 xpos += self.eightmatrixwid * size / self.defsize + 1 + size / 20 | |
11636 elif i == "9": | |
11637 xpos += self.ninematrixwid * size / self.defsize + 1 + size / 20 | |
11638 elif i == "0": | |
11639 xpos += self.tenmatrixwid * size / self.defsize + 1 + size / 20 | |
11640 elif i == "_": | |
11641 xpos += self._matrixwid * size / self.defsize + 1 + size / 20 | |
11642 elif i == "-": | |
11643 xpos += self.minusmatrixwid * size / self.defsize + 1 + size / 20 | |
11644 elif i == "+": | |
11645 xpos += self.plusmatrixwid * size / self.defsize + 1 + size / 20 | |
11646 elif i == "=": | |
11647 xpos += self.equalmatrixwid * size / self.defsize + 1 + size / 20 | |
11648 elif i == "!": | |
11649 xpos += self.exclmatrixwid * size / self.defsize + 1 + size / 20 | |
11650 elif i == "@": | |
11651 xpos += self.atmatrixwid * size / self.defsize + 1 + size / 20 | |
11652 elif i == "#": | |
11653 xpos += self.hashmatrixwid * size / self.defsize + 1 + size / 20 | |
11654 elif i == "$": | |
11655 xpos += self.dollarmatrixwid * size / self.defsize + 1 + size / 20 | |
11656 elif i == "%": | |
11657 xpos += self.percentmatrixwid * size / self.defsize + 1 + size / 20 | |
11658 elif i == "^": | |
11659 xpos += self.hatmatrixwid * size / self.defsize + 1 + size / 20 | |
11660 elif i == "&": | |
11661 xpos += self.ampmatrixwid * size / self.defsize + 1 + size / 20 | |
11662 elif i == "*": | |
11663 xpos += self.strixmatrixwid * size / self.defsize + 1 + size / 20 | |
11664 elif i == "(": | |
11665 xpos += self.opencparmatrixwid * size / self.defsize + 1 + size / 20 | |
11666 elif i == ")": | |
11667 xpos += self.closecparmatrixwid * size / self.defsize + 1 + size / 20 | |
11668 elif i == "[": | |
11669 xpos += self.opensparmatrixwid * size / self.defsize + 1 + size / 20 | |
11670 elif i == "]": | |
11671 xpos += self.closesparmatrixwid * size / self.defsize + 1 + size / 20 | |
11672 elif i == "\\": | |
11673 xpos += self.backslashmatrixwid * size / self.defsize + 1 + size / 20 | |
11674 elif i == ";": | |
11675 xpos += self.semicolmatrixwid * size / self.defsize + 1 + size / 20 | |
11676 elif i == "'": | |
11677 xpos += self.postmatrixwid * size / self.defsize + 1 + size / 20 | |
11678 elif i == ",": | |
11679 xpos += self.commamatrixwid * size / self.defsize + 1 + size / 20 | |
11680 elif i == ".": | |
11681 xpos += self.fullstopmatrixwid * size / self.defsize + 1 + size / 20 | |
11682 elif i == "/": | |
11683 xpos += self.forslashmatrixwid * size / self.defsize + 1 + size / 20 | |
11684 elif i == "<": | |
11685 xpos += self.lesthanmatrixwid * size / self.defsize + 1 + size / 20 | |
11686 elif i == ">": | |
11687 xpos += self.greatthanmatrixwid * size / self.defsize + 1 + size / 20 | |
11688 elif i == "?": | |
11689 xpos += self.questionmatrixwid * size / self.defsize + 1 + size / 20 | |
11690 elif i == ":": | |
11691 xpos += self.colonmatrixwid * size / self.defsize + 1 + size / 20 | |
11692 elif i == '"': | |
11693 xpos += self.quotematrixwid * size / self.defsize + 1 + size / 20 | |
11694 elif i == "{": | |
11695 xpos += self.opensquigmatrixwid * size / self.defsize + 1 + size / 20 | |
11696 elif i == "}": | |
11697 xpos += self.closesquigmatrixwid * size / self.defsize + 1 + size / 20 | |
11698 elif i == "|": | |
11699 xpos += self.barmatrixwid * size / self.defsize + 1 + size / 20 | |
11700 elif i == " ": | |
11701 xpos += 24 * size / self.defsize + 1 + size / 20 | |
11702 else: | |
11703 xpos += self.miscmatrixwid * size / self.defsize + 1 + size / 20 | |
11704 return xpos | |
11705 | |
11706 def setDefaultPenColor(self): | |
11707 self.currentPen = self.fg | |
11708 | |
11709 def setPenColor(self, p): | |
11710 oldColor = self.currentPen | |
11711 # look for c in palette | |
11712 pnum = p.toLong() | |
11713 try: | |
11714 self.currentPen = self.palette.index(pnum) | |
11715 except ValueError: | |
11716 if len(self.palette) < 256: | |
11717 self.palette.append(pnum) | |
11718 self.currentPen = len(self.palette) - 1 | |
11719 else: | |
11720 self.currentPen = self.fg | |
11721 | |
11722 return Color.fromLong(self.palette[oldColor]) | |
11723 | |
11724 def getPenColor(self): | |
11725 return Color.fromLong(self.palette[self.currentPen]) | |
11726 | |
11727 def plotPoint(self, x, y): | |
11728 if 0 <= x < self.wd and 0 <= y < self.ht: | |
11729 x = int(x) | |
11730 y = int(y) | |
11731 self.bitarray[y][x] = self.currentPen | |
11732 | |
11733 def drawOutRect(self, x, y, wid, ht, lt): | |
11734 if wid == 1: | |
11735 if lt != 0: | |
11736 temp = self.getPenColor() | |
11737 self.setPenColor(Color.BLACK) | |
11738 self.drawLine(x, y, x, y + ht - 1) | |
11739 self.setPenColor(temp) | |
11740 else: | |
11741 self.drawLine(x, y, x, y + ht - 1) | |
11742 else: | |
11743 if lt > wid / 2 and lt != 1: | |
11744 lt = wid / 2 | |
11745 if lt > ht / 2 and lt != 1: | |
11746 lt = ht / 2 | |
11747 self.drawRect(x, y, wid, ht, True) | |
11748 temp = self.getPenColor() | |
11749 self.setPenColor(Color.BLACK) | |
11750 for i in range(lt): | |
11751 self.drawRect(x + i, y + i, wid - i, ht - i) | |
11752 self.setPenColor(temp) | |
11753 | |
11754 def drawRect(self, x, y, wid, ht, fill=False): | |
11755 x = int(x) | |
11756 y = int(y) | |
11757 cury = y | |
11758 | |
11759 # subtract one for line width | |
11760 wid -= 1 | |
11761 ht -= 1 | |
11762 | |
11763 self.drawLine(x, y, x + wid, y) | |
11764 if fill: | |
11765 cury = y | |
11766 while cury < y + ht: | |
11767 self.drawLine(x, cury, x + wid, cury) | |
11768 cury += 1 | |
11769 else: | |
11770 self.drawLine(x, y, x, y + ht) | |
11771 self.drawLine(x + wid, y, x + wid, y + ht) | |
11772 self.drawLine(x, y + ht, x + wid, y + ht) | |
11773 | |
11774 def drawSquare(self, x, y, wid, fill=False): | |
11775 self.drawRect(x, y, wid, wid, fill) | |
11776 | |
11777 def drawDash(self, x1, y1, x2, y2, wid=1, dashl=3, dashg=3): | |
11778 currX = x1 | |
11779 currY = y1 | |
11780 if x1 == x2: | |
11781 for i in range(wid): | |
11782 currY = y1 | |
11783 while (y1 < y2 and currY + dashl < y2) or ( | |
11784 y1 > y2 and currY - dashl > y2 | |
11785 ): | |
11786 if y1 < y2: | |
11787 self.drawLine(currX, currY, currX, currY + dashl) | |
11788 currY = currY + dashl + dashg | |
11789 else: | |
11790 self.drawLine(currX, currY, currX, currY - dashl) | |
11791 currY = currY - dashl - dashg | |
11792 if (y1 < y2 and currY < y2) or (y2 < y1 and currY > y2): | |
11793 self.drawLine(currX, currY, currX, y2) | |
11794 currX -= 1 | |
11795 elif y1 == y2: | |
11796 for i in range(wid): | |
11797 currX = x1 | |
11798 while (x1 < x2 and currX + dashl < x2) or ( | |
11799 x1 > x2 and currX - dashl > x1 | |
11800 ): | |
11801 if x1 < x2: | |
11802 self.drawLine(currX, currY, currX + dashl, currY) | |
11803 currX = currX + dashl + dashg | |
11804 else: | |
11805 self.drawLine(currX, currY, currX - dashl, currY) | |
11806 currX = currX - dashl - dashg | |
11807 if (x1 < x2 and currX < x2) or (x2 < x1 and currX > x2): | |
11808 self.drawLine(currX, currY, x2, currY) | |
11809 currY -= 1 | |
11810 else: | |
11811 ratio = abs(x1 - x2) * 1.0 / abs(y1 - y2) | |
11812 while (x1 < x2 and currX + dashl * min([ratio, 1]) < x2) or ( | |
11813 x1 > x2 and currX - dashl * min([ratio, 1]) > x2 | |
11814 ): | |
11815 if ratio > 1: | |
11816 if x1 < x2: | |
11817 nextX = currX + dashl | |
11818 currXt = currX + dashl + dashg | |
11819 else: | |
11820 nextX = currX - dashl | |
11821 currXt = currX - dashl - dashg | |
11822 if y1 < y2: | |
11823 nextY = currY + dashl / ratio | |
11824 currYt = currY + (dashl + dashg) / ratio | |
11825 else: | |
11826 nextY = currY - dashl / ratio | |
11827 currYt = currY - (dashl + dashg) / ratio | |
11828 else: | |
11829 if x1 < x2: | |
11830 nextX = currX + dashl * ratio | |
11831 currXt = currX + (dashl + dashg) * ratio | |
11832 else: | |
11833 nextX = currX - dashl * ratio | |
11834 currXt = currX - (dashl + dashg) * ratio | |
11835 if y1 < y2: | |
11836 nextY = currY + dashl | |
11837 currYt = currY + dashl + dashg | |
11838 else: | |
11839 nextY = currY - dashl | |
11840 currYt = currY - (dashl + dashg) | |
11841 self.drawLine(currX, currY, nextX, nextY) | |
11842 currX = currXt | |
11843 currY = currYt | |
11844 if currX + dashl * min([ratio, 1]) < x2: | |
11845 self.drawLine(currX, currY, x2, y2) | |
11846 | |
11847 def drawRightArrow(self, x, y, wid, ht, lt, outline=True): | |
11848 if lt > ht / 2: | |
11849 lt = ht / 2 | |
11850 x1 = x + wid | |
11851 y1 = y + ht / 2 | |
11852 x2 = x + wid - ht / 2 | |
11853 ht -= 1 | |
11854 if wid > ht / 2: | |
11855 for i in range(y, y + ht + 1): | |
11856 self.drawLine(x2, i, x1, y1) | |
11857 self.drawRect(x, y + ht / 4, wid - ht / 2, ht / 2, True) | |
11858 if outline: | |
11859 temp = self.getPenColor() | |
11860 self.setPenColor(Color.BLACK) | |
11861 for i in range(lt): | |
11862 self.drawLine(x + i, y + ht / 4 + i, x2 + i, y + ht / 4 + i) | |
11863 self.drawLine(x2 + i, y + ht / 4 + i, x2 + i, y + i * 2) | |
11864 self.drawLine(x2 + i, y + i * 2, x1 - i, y1) | |
11865 self.drawLine(x1 - i, y1, x2 + i, y + ht - i * 2) | |
11866 self.drawLine( | |
11867 x2 + i, y + ht - i * 2, x2 + i, y + ht / 4 + ht / 2 - i | |
11868 ) | |
11869 self.drawLine( | |
11870 x2 + i, y + ht / 4 + ht / 2 - i, x + i, y + ht / 4 + ht / 2 - i | |
11871 ) | |
11872 self.drawLine(x + i, y + ht / 4 + ht / 2 - i, x + i, y + ht / 4 + i) | |
11873 self.setPenColor(temp) | |
11874 else: | |
11875 for i in range(y, y + ht + 1): | |
11876 self.drawLine(x, i, x1, y1) | |
11877 if outline and lt != 0: | |
11878 temp = self.getPenColor() | |
11879 self.setPenColor(Color.BLACK) | |
11880 for i in range(lt): | |
11881 self.drawLine(x, y + ht - i, x1 - i, y1) | |
11882 self.drawLine(x, y + i, x1 - i, y1) | |
11883 if x1 != x: | |
11884 crapliney1 = (y1 - y) / (x1 - x) * (x + i - x + 1) + y | |
11885 crapliney2 = y + ht - (y1 - y) / (x1 - x) * (x + i - x + 1) | |
11886 self.drawLine(x + i, crapliney1, x + i, crapliney2) | |
11887 self.setPenColor(temp) | |
11888 | |
11889 def drawLeftArrow(self, x, y, wid, ht, lt, outline=True): | |
11890 if lt > ht / 2: | |
11891 lt = ht / 2 | |
11892 y1 = y + (ht / 2) | |
11893 x1 = x + wid | |
11894 x2 = x + ht / 2 | |
11895 ht -= 1 | |
11896 if wid > ht / 2: | |
11897 for i in range(y, y + ht + 1): | |
11898 self.drawLine(x, y1, x2, i) | |
11899 self.drawRect(x2, y + ht / 4, wid - ht / 2, ht / 2, True) | |
11900 if outline: | |
11901 temp = self.getPenColor() | |
11902 self.setPenColor(Color.BLACK) | |
11903 for i in range(lt): | |
11904 self.drawLine(x + i, y1, x2 - i, y + i * 2) | |
11905 self.drawLine(x2 - i, y + i * 2, x2 - i, y + ht / 4 + i) | |
11906 self.drawLine(x2 - i, y + ht / 4 + i, x1 - i, y + ht / 4 + i) | |
11907 self.drawLine( | |
11908 x1 - i, y + ht / 4 + i, x1 - i, y + ht / 4 + ht / 2 - i | |
11909 ) | |
11910 self.drawLine( | |
11911 x1 - i, y + ht / 4 + ht / 2 - i, x2 - i, y + ht / 4 + ht / 2 - i | |
11912 ) | |
11913 self.drawLine( | |
11914 x2 - i, y + ht / 4 + ht / 2 - i, x2 - i, y + ht - i * 2 | |
11915 ) | |
11916 self.drawLine(x2 - i, y + ht - i * 2, x + i, y1) | |
11917 self.setPenColor(temp) | |
11918 else: | |
11919 if lt > wid / 2: | |
11920 lt = wid / 2 | |
11921 for i in range(y, y + ht + 1): | |
11922 self.drawLine(x, y1, x1, i) | |
11923 if outline and lt != 0: | |
11924 temp = self.getPenColor() | |
11925 self.setPenColor(Color.BLACK) | |
11926 for i in range(lt): | |
11927 self.drawLine(x + i, y1, x1, y + i) | |
11928 if x1 != x: | |
11929 crapliney1 = (y1 - y) / (x1 - x) * (x + i - x + 1) + y | |
11930 crapliney2 = y + ht - (y1 - y) / (x1 - x) * (x + i - x + 1) | |
11931 self.drawLine(x1 - i, crapliney1, x1 - i, crapliney2) | |
11932 self.drawLine(x1, y + ht - i, x + i, y1) | |
11933 self.setPenColor(temp) | |
11934 | |
11935 def drawRightFrame(self, x, y, wid, ht, lt, frame, outline=True): | |
11936 if lt > ht / 2: | |
11937 lt = ht / 2 | |
11938 if frame == 1: | |
11939 y1 = y + ht / 2 | |
11940 y2 = y + ht * 5 / 8 | |
11941 y3 = y + ht * 3 / 4 | |
11942 elif frame == 2: | |
11943 y1 = y + ht * 5 / 8 | |
11944 y2 = y + ht * 3 / 4 | |
11945 y3 = y + ht * 7 / 8 | |
11946 elif frame == 0: | |
11947 y1 = y + ht * 3 / 4 | |
11948 y2 = y + ht * 7 / 8 | |
11949 y3 = y + ht - 1 | |
11950 x1 = x | |
11951 x2 = x + wid - ht / 8 | |
11952 x3 = x + wid | |
11953 if wid > ht / 8: | |
11954 for i in range(y1, y3 + 1): | |
11955 self.drawLine(x1, i, x2, i) | |
11956 self.drawLine(x2, i, x3, y2) | |
11957 if outline: | |
11958 temp = self.getPenColor() | |
11959 self.setPenColor(Color.BLACK) | |
11960 for i in range(lt): | |
11961 self.drawLine(x1, y1 + i, x2, y1 + i) | |
11962 self.drawLine(x2, y1 + i, x3 - i, y2) | |
11963 self.drawLine(x3 - i, y2, x2, y3 - i) | |
11964 self.drawLine(x2, y3 - i, x1, y3 - i) | |
11965 self.drawLine(x1 + i, y3 - i, x1 + i, y1 + i) | |
11966 self.setPenColor(temp) | |
11967 else: | |
11968 for i in range(y1, y3 + 1): | |
11969 self.drawLine(x1, i, x3, y2) | |
11970 if outline: | |
11971 temp = self.getPenColor() | |
11972 self.setPenColor(Color.BLACK) | |
11973 self.drawLine(x1, y1, x3, y2) | |
11974 self.drawLine(x3, y2, x1, y3) | |
11975 self.drawLine(x1, y1, x1, y3) | |
11976 self.setPenColor(temp) | |
11977 | |
11978 def drawRightFrameRect(self, x, y, wid, ht, lt, frame, outline=True): | |
11979 if lt > ht / 2: | |
11980 lt = ht / 2 | |
11981 if frame == 1: | |
11982 y1 = y + ht / 2 | |
11983 y3 = y + ht * 3 / 4 | |
11984 elif frame == 2: | |
11985 y1 = y + ht * 5 / 8 | |
11986 y3 = y + ht * 7 / 8 | |
11987 elif frame == 0: | |
11988 y1 = y + ht * 3 / 4 | |
11989 y3 = y + ht - 1 | |
11990 x1 = x | |
11991 x2 = x + wid | |
11992 for i in range(y1, y3 + 1): | |
11993 self.drawLine(x1, i, x2, i) | |
11994 if outline: | |
11995 temp = self.getPenColor() | |
11996 self.setPenColor(Color.BLACK) | |
11997 for i in range(lt): | |
11998 self.drawLine(x1, y1 + i, x2, y1 + i) | |
11999 self.drawLine(x2, y1 + i, x2 - i, y3) | |
12000 self.drawLine(x2, y3 - i, x1, y3 - i) | |
12001 self.drawLine(x1 + i, y3 - i, x1 + i, y1 + i) | |
12002 self.setPenColor(temp) | |
12003 | |
12004 def drawLeftFrame(self, x, y, wid, ht, lt, frame, outline=True): | |
12005 if lt > ht / 2: | |
12006 lt = ht / 2 | |
12007 if frame == 1: | |
12008 y1 = y | |
12009 y2 = y + ht / 8 | |
12010 y3 = y + ht / 4 | |
12011 elif frame == 2: | |
12012 y1 = y + ht / 8 | |
12013 y2 = y + ht / 4 | |
12014 y3 = y + ht * 3 / 8 | |
12015 elif frame == 0: | |
12016 y1 = y + ht / 4 | |
12017 y2 = y + ht * 3 / 8 | |
12018 y3 = y + ht / 2 | |
12019 x1 = x + wid | |
12020 x2 = x + ht / 8 | |
12021 x3 = x | |
12022 if wid > ht / 8: | |
12023 for i in range(y1, y3 + 1): | |
12024 self.drawLine(x1, i, x2, i) | |
12025 self.drawLine(x2, i, x3, y2) | |
12026 if outline: | |
12027 temp = self.getPenColor() | |
12028 self.setPenColor(Color.BLACK) | |
12029 for i in range(lt): | |
12030 self.drawLine(x1, y1 + i, x2, y1 + i) | |
12031 self.drawLine(x2, y1 + i, x3 - i, y2) | |
12032 self.drawLine(x3 - i, y2, x2, y3 - i) | |
12033 self.drawLine(x2, y3 - i, x1, y3 - i) | |
12034 self.drawLine(x1 + i, y3 - i, x1 + i, y1 + i) | |
12035 self.setPenColor(temp) | |
12036 else: | |
12037 for i in range(y1, y3 + 1): | |
12038 self.drawLine(x1, i, x3, y2) | |
12039 if outline: | |
12040 temp = self.getPenColor() | |
12041 self.setPenColor(Color.BLACK) | |
12042 self.drawLine(x1, y1, x3, y2) | |
12043 self.drawLine(x3, y2, x1, y3) | |
12044 self.drawLine(x1, y1, x1, y3) | |
12045 self.setPenColor(temp) | |
12046 | |
12047 def drawLeftFrameRect(self, x, y, wid, ht, lt, frame, outline=True): | |
12048 if lt > ht / 2: | |
12049 lt = ht / 2 | |
12050 if frame == 1: | |
12051 y1 = y | |
12052 y3 = y + ht / 4 | |
12053 elif frame == 2: | |
12054 y1 = y + ht / 8 | |
12055 y3 = y + ht * 3 / 8 | |
12056 elif frame == 0: | |
12057 y1 = y + ht / 4 | |
12058 y3 = y + ht / 2 | |
12059 x1 = x + wid | |
12060 x2 = x | |
12061 for i in range(y1, y3 + 1): | |
12062 self.drawLine(x1, i, x2, i) | |
12063 if outline: | |
12064 temp = self.getPenColor() | |
12065 self.setPenColor(Color.BLACK) | |
12066 for i in range(lt): | |
12067 self.drawLine(x1, y1 + i, x2, y1 + i) | |
12068 self.drawLine(x2 - i, y1, x2 - i, y3) | |
12069 self.drawLine(x2, y3 - i, x1, y3 - i) | |
12070 self.drawLine(x1 + i, y3, x1 + i, y1) | |
12071 self.setPenColor(temp) | |
12072 | |
12073 def drawPointer(self, x, y, ht, lt, outline=True): | |
12074 x1 = x - int(round(0.577350269 * ht / 2)) | |
12075 x2 = x + int(round(0.577350269 * ht / 2)) | |
12076 y1 = y + ht / 2 | |
12077 y2 = y + ht - 1 | |
12078 for i in range(x1, x2 + 1): | |
12079 self.drawLine(i, y2, x, y1) | |
12080 if outline: | |
12081 temp = self.getPenColor() | |
12082 self.setPenColor(Color.BLACK) | |
12083 self.drawLine(x, y1, x1, y2) | |
12084 self.drawLine(x, y1, x2, y2) | |
12085 self.drawLine(x1, y2, x2, y2) | |
12086 self.setPenColor(temp) | |
12087 | |
12088 def bresLine(x, y, x2, y2): | |
12089 """Bresenham line algorithm""" | |
12090 steep = 0 | |
12091 coords = [] | |
12092 dx = int(abs(x2 - x) + 0.5) | |
12093 if (x2 - x) > 0: | |
12094 sx = 1 | |
12095 else: | |
12096 sx = -1 | |
12097 dy = int(abs(y2 - y) + 0.5) | |
12098 if (y2 - y) > 0: | |
12099 sy = 1 | |
12100 else: | |
12101 sy = -1 | |
12102 if dy > dx: | |
12103 steep = 1 | |
12104 x, y = y, x | |
12105 dx, dy = dy, dx | |
12106 sx, sy = sy, sx | |
12107 dx2 = dx * 2 | |
12108 dy2 = dy * 2 | |
12109 d = dy2 - dx | |
12110 for i in range(0, dx): | |
12111 coords.append((x, y)) | |
12112 while d >= 0: | |
12113 y += sy | |
12114 d -= dx2 | |
12115 x += sx | |
12116 d += dy2 | |
12117 | |
12118 if steep: # transpose x's and y's | |
12119 coords = [(c[1], c[0]) for c in coords] | |
12120 | |
12121 coords.append((x2, y2)) | |
12122 | |
12123 return coords | |
12124 | |
12125 bresLine = staticmethod(bresLine) | |
12126 | |
12127 def _drawLine(self, x1, y1, x2, y2): | |
12128 # special checks for vert and horiz lines | |
12129 if x1 == x2: | |
12130 if 0 <= x1 < self.wd: | |
12131 if y2 < y1: | |
12132 y1, y2 = y2, y1 | |
12133 cury = max(y1, 0) | |
12134 maxy = min(y2, self.ht - 1) | |
12135 while cury <= maxy: | |
12136 self.plotPoint(x1, cury) | |
12137 cury += 1 | |
12138 return | |
12139 | |
12140 if y1 == y2: | |
12141 if 0 <= y1 < self.ht: | |
12142 if x2 < x1: | |
12143 x1, x2 = x2, x1 | |
12144 curx = max(x1, 0) | |
12145 maxx = min(x2, self.wd - 1) | |
12146 while curx <= maxx: | |
12147 self.plotPoint(curx, y1) | |
12148 curx += 1 | |
12149 return | |
12150 | |
12151 for pt in BitMap.bresLine(x1, y1, x2, y2): | |
12152 self.plotPoint(pt[0], pt[1]) | |
12153 | |
12154 def _drawLines(self, lineSegs): | |
12155 for x1, y1, x2, y2 in lineSegs: | |
12156 self._drawLine(x1, y1, x2, y2) | |
12157 | |
12158 def drawLine(self, x1, y1, x2, y2, type=LINE_SOLID): | |
12159 if type == BitMap.LINE_SOLID: | |
12160 self._drawLine(x1, y1, x2, y2) | |
12161 elif type == BitMap.LINE_DASHED: | |
12162 # how many segs? | |
12163 len = hypot(x2 - x1, y2 - y1) | |
12164 numsegs = len / BitMap._DASH_LEN | |
12165 dx = (x2 - x1) / numsegs | |
12166 dy = (y2 - y1) / numsegs | |
12167 dx2 = dx / 2.0 | |
12168 dy2 = dy / 2.0 | |
12169 if x2 < x1: | |
12170 x1, x2 = x2, x1 | |
12171 y1, y2 = y2, y1 | |
12172 segs = [] | |
12173 curx = x1 | |
12174 cury = y1 | |
12175 for i in range(int(numsegs)): | |
12176 segs.append((curx, cury, curx + dx2, cury + dy2)) | |
12177 curx += dx | |
12178 cury += dy | |
12179 if curx + dx2 > x2: | |
12180 segs.append((curx, cury, x2, y2)) | |
12181 else: | |
12182 segs.append((curx, cury, curx + dx2, cury + dy2)) | |
12183 self._drawLines(segs) | |
12184 elif type == BitMap.LINE_DOTTED: | |
12185 len = hypot(x2 - x1, y2 - y1) | |
12186 numsegs = len / BitMap._DOT_LEN | |
12187 dx = (x2 - x1) / numsegs | |
12188 dy = (y2 - y1) / numsegs | |
12189 dx2 = dx / 2.0 | |
12190 dy2 = dy / 2.0 | |
12191 if x2 < x1: | |
12192 x1, x2 = x2, x1 | |
12193 y1, y2 = y2, y1 | |
12194 segs = [] | |
12195 curx = x1 | |
12196 cury = y1 | |
12197 for i in range(int(numsegs)): | |
12198 segs.append((curx, cury, curx + dx2, cury + dy2)) | |
12199 curx += dx | |
12200 cury += dy | |
12201 if curx + dx2 > x2: | |
12202 segs.append((curx, cury, x2, y2)) | |
12203 else: | |
12204 segs.append((curx, cury, curx + dx2, cury + dy2)) | |
12205 self._drawLines(segs) | |
12206 elif type == BitMap.LINE_DOT_DASH: | |
12207 len = hypot(x2 - x1, y2 - y1) | |
12208 numsegs = len / BitMap._DOT_DASH_LEN | |
12209 dx = (x2 - x1) / numsegs | |
12210 dy = (y2 - y1) / numsegs | |
12211 dx3 = dx / 3.0 | |
12212 dy3 = dy / 3.0 | |
12213 dx23 = 0.62 * dx | |
12214 dy23 = 0.62 * dy | |
12215 dx56 = 0.78 * dx | |
12216 dy56 = 0.78 * dy | |
12217 if x2 < x1: | |
12218 x1, x2 = x2, x1 | |
12219 y1, y2 = y2, y1 | |
12220 segs = [] | |
12221 curx = x1 | |
12222 cury = y1 | |
12223 for i in range(int(numsegs)): | |
12224 segs.append((curx, cury, curx + dx3, cury + dy3)) | |
12225 segs.append((curx + dx23, cury + dy23, curx + dx56, cury + dy56)) | |
12226 curx += dx | |
12227 cury += dy | |
12228 if curx + dx3 > x2: | |
12229 segs.append((curx, cury, x2, y2)) | |
12230 else: | |
12231 segs.append((curx, cury, curx + dx3, cury + dy3)) | |
12232 if curx + dx23 < x2: | |
12233 if curx + dx56 > x2: | |
12234 segs.append((curx + dx23, cury + dy23, x2, y2)) | |
12235 else: | |
12236 segs.append( | |
12237 (curx + dx23, cury + dy23, curx + dx56, cury + dy56) | |
12238 ) | |
12239 else: | |
12240 pass # segs.append( ( curx, cury, curx + dx3, cury + dy3 ) ) | |
12241 segs.append((curx, cury, x2, y2)) | |
12242 self._drawLines(segs) | |
12243 | |
12244 def drawCircle(self, cx, cy, r, fill=False): | |
12245 x = 0 | |
12246 y = r | |
12247 d = 1 - r | |
12248 | |
12249 self.plotPoint(cx, cy + y) | |
12250 self.plotPoint(cx, cy - y) | |
12251 if fill: | |
12252 self.drawLine(cx - y, cy, cx + y, cy) | |
12253 else: | |
12254 self.plotPoint(cx + y, cy) | |
12255 self.plotPoint(cx - y, cy) | |
12256 | |
12257 while y > x: | |
12258 if d < 0: | |
12259 d += 2 * x + 3 | |
12260 else: | |
12261 d += 2 * (x - y) + 5 | |
12262 y -= 1 | |
12263 x += 1 | |
12264 | |
12265 if fill: | |
12266 self.drawLine(cx + x - 1, cy + y, cx - x + 1, cy + y) | |
12267 self.drawLine(cx - x + 1, cy - y, cx + x - 1, cy - y) | |
12268 self.drawLine(cx + y - 1, cy + x, cx - y + 1, cy + x) | |
12269 self.drawLine(cx - y + 1, cy - x, cx + y - 1, cy - x) | |
12270 else: | |
12271 self.plotPoint(cx + x, cy + y) | |
12272 self.plotPoint(cx + y, cy + x) | |
12273 self.plotPoint(cx - x, cy - y) | |
12274 self.plotPoint(cx - y, cy - x) | |
12275 self.plotPoint(cx + x, cy - y) | |
12276 self.plotPoint(cx - y, cy + x) | |
12277 self.plotPoint(cx - x, cy + y) | |
12278 self.plotPoint(cx + y, cy - x) | |
12279 | |
12280 # method for creating gif string | |
12281 def createGIFString(self, oneistone): | |
12282 if not oneistone: | |
12283 if self.wd > 1000: | |
12284 modifier = 1000.0 / self.wd | |
12285 self.wd = 1000 | |
12286 self.ht = int(self.ht * modifier) | |
12287 else: | |
12288 oneistone = True | |
12289 binarystring = "GIF89a" # header | |
12290 binarystring += ( | |
12291 struct.pack("h", self.wd) | |
12292 + struct.pack("h", self.ht) | |
12293 + chr(int("10010110", 2)) | |
12294 + "\x00\x00" | |
12295 ) | |
12296 if len(self.palette) <= 128: | |
12297 for i in self.palette: | |
12298 colour = Color.fromLong(i) | |
12299 binarystring += chr(colour.red) + chr(colour.grn) + chr(colour.blu) | |
12300 for i in range(128 - len(self.palette)): | |
12301 binarystring += chr(255) + chr(255) + chr(255) | |
12302 else: | |
12303 for i in range(8): # 128 colour table | |
12304 for j in range(4): | |
12305 for k in range(4): | |
12306 binarystring += chr(int(i * 36.5)) + chr(j * 85) + chr(k * 85) | |
12307 binarystring += ( | |
12308 ",\x00\x00\x00\x00" | |
12309 + struct.pack("h", self.wd) | |
12310 + struct.pack("h", self.ht) | |
12311 + "\x00" | |
12312 ) # image descriptor | |
12313 binarystring += "\x07" # LZW Minimum code size | |
12314 pixstring = "" | |
12315 self.bitarray.reverse() | |
12316 for a, i in enumerate(self.bitarray): | |
12317 for b, j in enumerate(i): | |
12318 if len(self.palette) <= 128: | |
12319 if oneistone: | |
12320 pixstring += chr(j) | |
12321 else: | |
12322 if ( | |
12323 int(a * modifier) != int((a - 1) * modifier) or a == 0 | |
12324 ) and (int(b * modifier) != int((b - 1) * modifier) or b == 0): | |
12325 pixstring += chr(j) | |
12326 else: | |
12327 colourhash = self.palette[j] | |
12328 colour = Color.fromLong(colourhash) | |
12329 colbin = ( | |
12330 "{0:b}".format(colour.red / 32).zfill(3) | |
12331 + "{0:b}".format(colour.grn / 64).zfill(2) | |
12332 + "{0:b}".format(colour.blu / 64).zfill(2) | |
12333 ) | |
12334 if oneistone: | |
12335 pixstring += chr(int(colbin, 2)) | |
12336 else: | |
12337 if ( | |
12338 int(a * modifier) != int((a - 1) * modifier) or a == 0 | |
12339 ) and (int(b * modifier) != int((b - 1) * modifier) or b == 0): | |
12340 pixstring += chr(int(colbin, 2)) | |
12341 for i in range(0, len(pixstring), 8): | |
12342 binarystring += "\x09\x80" + pixstring[i : i + 8] | |
12343 binarystring += "\x01\x81" | |
12344 binarystring += "\x00;" | |
12345 return base64.b64encode(binarystring) | |
12346 | |
12347 def _saveBitMapNoCompression(self, filename): | |
12348 # open file | |
12349 f = file(filename, "wb") | |
12350 | |
12351 # write bitmap header | |
12352 f.write("BM") | |
12353 f.write( | |
12354 longToString(54 + 256 * 4 + self.ht * self.wd) | |
12355 ) # DWORD size in bytes of the file | |
12356 f.write(longToString(0)) # DWORD 0 | |
12357 f.write(longToString(54 + 256 * 4)) # DWORD offset to the data | |
12358 f.write(longToString(40)) # DWORD header size = 40 | |
12359 f.write(longToString(self.wd)) # DWORD image width | |
12360 f.write(longToString(self.ht)) # DWORD image height | |
12361 f.write(shortToString(1)) # WORD planes = 1 | |
12362 f.write(shortToString(8)) # WORD bits per pixel = 8 | |
12363 f.write(longToString(0)) # DWORD compression = 0 | |
12364 f.write( | |
12365 longToString(self.wd * self.ht) | |
12366 ) # DWORD sizeimage = size in bytes of the bitmap = width * height | |
12367 f.write(longToString(0)) # DWORD horiz pixels per meter (?) | |
12368 f.write(longToString(0)) # DWORD ver pixels per meter (?) | |
12369 f.write(longToString(256)) # DWORD number of s used = 256 | |
12370 f.write( | |
12371 longToString(len(self.palette)) | |
12372 ) # DWORD number of "import s = len( self.palette ) | |
12373 | |
12374 # write bitmap palette | |
12375 for clr in self.palette: | |
12376 f.write(longToString(clr)) | |
12377 for i in range(len(self.palette), 256): | |
12378 f.write(longToString(0)) | |
12379 | |
12380 # write pixels | |
12381 for row in self.bitarray: | |
12382 for pixel in row: | |
12383 f.write(chr(pixel)) | |
12384 padding = (4 - len(row) % 4) % 4 | |
12385 for i in range(padding): | |
12386 f.write(chr(0)) | |
12387 | |
12388 # close file | |
12389 f.close() | |
12390 | |
12391 def _saveBitMapWithCompression(self, filename): | |
12392 """ """ | |
12393 # open file | |
12394 f = file(filename, "wb") | |
12395 | |
12396 # write bitmap header | |
12397 f.write("BM") | |
12398 f.write( | |
12399 longToString(54 + 256 * 4 + self.ht * self.wd) | |
12400 ) # DWORD size in bytes of the file | |
12401 f.write(longToString(0)) # DWORD 0 | |
12402 f.write(longToString(54 + 256 * 4)) # DWORD offset to the data | |
12403 f.write(longToString(40)) # DWORD header size = 40 | |
12404 f.write(longToString(self.wd)) # DWORD image width | |
12405 f.write(longToString(self.ht)) # DWORD image height | |
12406 f.write(shortToString(1)) # WORD planes = 1 | |
12407 f.write(shortToString(8)) # WORD bits per pixel = 8 | |
12408 f.write(longToString(1)) # DWORD compression = 1=RLE8 | |
12409 f.write( | |
12410 longToString(self.wd * self.ht) | |
12411 ) # DWORD sizeimage = size in bytes of the bitmap = width * height | |
12412 f.write(longToString(0)) # DWORD horiz pixels per meter (?) | |
12413 f.write(longToString(0)) # DWORD ver pixels per meter (?) | |
12414 f.write(longToString(256)) # DWORD number of s used = 256 | |
12415 f.write( | |
12416 longToString(len(self.palette)) | |
12417 ) # DWORD number of "import s = len( self.palette ) | |
12418 | |
12419 # write bitmap palette | |
12420 for clr in self.palette: | |
12421 f.write(longToString(clr)) | |
12422 for i in range(len(self.palette), 256): | |
12423 f.write(longToString(0)) | |
12424 | |
12425 # write pixels | |
12426 pixelBytes = 0 | |
12427 for row in self.bitarray: | |
12428 rleStart = 0 | |
12429 curPixel = rleStart + 1 | |
12430 while curPixel < len(row): | |
12431 if row[curPixel] != row[rleStart] or curPixel - rleStart == 255: | |
12432 # write out from rleStart thru curPixel-1 | |
12433 f.write(chr(curPixel - rleStart)) | |
12434 f.write(chr(row[rleStart])) | |
12435 pixelBytes += 2 | |
12436 rleStart = curPixel | |
12437 else: | |
12438 pass | |
12439 curPixel += 1 | |
12440 | |
12441 # write out last run of s | |
12442 f.write(chr(curPixel - rleStart)) | |
12443 f.write(chr(row[rleStart])) | |
12444 pixelBytes += 2 | |
12445 | |
12446 # end of line code | |
12447 f.write(chr(0)) | |
12448 f.write(chr(0)) | |
12449 pixelBytes += 2 | |
12450 | |
12451 # end of bitmap code | |
12452 f.write(chr(0)) | |
12453 f.write(chr(1)) | |
12454 pixelBytes += 2 | |
12455 | |
12456 # now fix sizes in header | |
12457 f.seek(2) | |
12458 f.write( | |
12459 longToString(54 + 256 * 4 + pixelBytes) | |
12460 ) # DWORD size in bytes of the file | |
12461 f.seek(34) | |
12462 f.write(longToString(pixelBytes)) # DWORD size in bytes of the file | |
12463 | |
12464 # close file | |
12465 f.close() | |
12466 | |
12467 def saveFile(self, filename, compress=True): | |
12468 if compress: | |
12469 self._saveBitMapWithCompression(filename) | |
12470 else: | |
12471 self._saveBitMapNoCompression(filename) | |
12472 | |
12473 | |
12474 # For converting arttemis colour codes to an RGB value | |
12475 def artColourTable(x): | |
12476 if x == 0: | |
12477 y = (255, 255, 255) | |
12478 elif x == 1: | |
12479 y = (100, 100, 100) | |
12480 elif x == 2: | |
12481 y = (255, 0, 0) | |
12482 elif x == 3: | |
12483 y = (0, 255, 0) | |
12484 elif x == 4: | |
12485 y = (0, 0, 255) | |
12486 elif x == 5: | |
12487 y = (0, 255, 255) | |
12488 elif x == 6: | |
12489 y = (255, 0, 255) | |
12490 elif x == 7: | |
12491 y = (255, 255, 0) | |
12492 elif x == 8: | |
12493 y = (152, 255, 152) | |
12494 elif x == 9: | |
12495 y = (135, 206, 250) | |
12496 elif x == 10: | |
12497 y = (255, 165, 0) | |
12498 elif x == 11: | |
12499 y = (200, 150, 100) | |
12500 elif x == 12: | |
12501 y = (255, 200, 200) | |
12502 elif x == 13: | |
12503 y = (170, 170, 170) | |
12504 elif x == 14: | |
12505 y = (0, 0, 0) | |
12506 elif x == 15: | |
12507 y = (255, 63, 63) | |
12508 elif x == 16: | |
12509 y = (255, 127, 127) | |
12510 elif x == 17: | |
12511 y = (255, 191, 191) | |
12512 return y | |
12513 | |
12514 | |
12515 # For reading in genbank or EMBL files | |
12516 def getArrows(filename, legname): | |
12517 length = None | |
12518 theseq = "" | |
12519 genbank = open(filename) | |
12520 outlist = [] | |
12521 getFeats = False | |
12522 emblcheck = False | |
12523 getColour = False | |
12524 getemblseq = False | |
12525 getgenseq = False | |
12526 getmultifasta = False | |
12527 for line in genbank: | |
12528 if "\t" in line: | |
12529 sys.stderr.write( | |
12530 "Tab found in genbank file, this may cause some Features to be missed, please remove tabs." | |
12531 ) | |
12532 if line.startswith("FEATURES") or line.startswith(" source"): | |
12533 getFeats = True | |
12534 elif line.startswith("FT"): | |
12535 getFeats = True | |
12536 emblcheck = True | |
12537 elif line.startswith(">") and not getFeats: | |
12538 if getmultifasta: | |
12539 theseq += "qqq" | |
12540 else: | |
12541 getmultifasta = True | |
12542 elif getmultifasta: | |
12543 theseq += line.rstrip() | |
12544 elif not line.startswith(" ") and not emblcheck: | |
12545 getFeats = False | |
12546 elif emblcheck: | |
12547 getFeats = False | |
12548 if line[2:].startswith(" ") and line[5] != " " and getFeats: | |
12549 feat, loc = line[2:].split() | |
12550 if "join(" in loc or "order(" in loc: | |
12551 if loc.startswith("join("): | |
12552 temp2 = loc[5:-1].split(",") | |
12553 strand = "+" | |
12554 elif loc.startswith("complement("): | |
12555 temp2 = loc[11:-1].split(",") | |
12556 strand = "-" | |
12557 elif loc.startswith("order("): | |
12558 temp2 = loc[6:-1].split(",") | |
12559 temp = [[], []] | |
12560 gotit = True | |
12561 for i in temp2: | |
12562 if ":" in i: | |
12563 i = i.split(":")[1] | |
12564 if "<" in i: | |
12565 i = i.replace("<", "") | |
12566 if ">" in i: | |
12567 i = i.replace(">", "") | |
12568 if ")" in i: | |
12569 i = i.replace(")", "") | |
12570 if i.startswith("complement("): | |
12571 strand = "-" | |
12572 i = i[11:] | |
12573 if i.startswith("join("): | |
12574 i = i[5:] | |
12575 if i.startswith("order("): | |
12576 i = i[6:] | |
12577 if ".." in i: | |
12578 try: | |
12579 start, stop = i.split("..") | |
12580 except: | |
12581 start, stop = "x", "y" | |
12582 elif "^" in i: | |
12583 try: | |
12584 start, stop = i.split("^") | |
12585 except: | |
12586 start, stop = "x", "y" | |
12587 elif "." in i: | |
12588 try: | |
12589 start, stop = i.split(".") | |
12590 except: | |
12591 start, stop = "x", "y" | |
12592 else: | |
12593 if i.startswith("gap("): | |
12594 start = None | |
12595 else: | |
12596 start = i | |
12597 stop = i | |
12598 try: | |
12599 if start != None: | |
12600 temp[0].append(int(start)) | |
12601 temp[1].append(int(stop)) | |
12602 except: | |
12603 if gotit: | |
12604 print("feature could not be processed:\n" + line) | |
12605 gotit = False | |
12606 if gotit: | |
12607 aninstance = feature(temp[0], temp[1], feat, strand, None, None) | |
12608 outlist.append(aninstance) | |
12609 if feat == "source": | |
12610 try: | |
12611 lengtht = max([max(temp[0]), max(temp[1])]) | |
12612 if lengtht > length: | |
12613 length = lengtht | |
12614 except: | |
12615 pass | |
12616 else: | |
12617 if loc.startswith("complement("): | |
12618 strand = "-" | |
12619 loc = loc[11:-1] | |
12620 else: | |
12621 strand = "+" | |
12622 if ":" in loc: | |
12623 loc = loc.split(":")[1] | |
12624 if "<" in loc: | |
12625 loc = loc.replace("<", "") | |
12626 if ">" in loc: | |
12627 loc = loc.replace(">", "") | |
12628 if ".." in loc: | |
12629 try: | |
12630 start, stop = loc.split("..") | |
12631 except: | |
12632 start, stop = "x", "y" | |
12633 elif "^" in loc: | |
12634 try: | |
12635 start, stop = loc.split("^") | |
12636 except: | |
12637 start, stop = "x", "y" | |
12638 elif "." in loc: | |
12639 try: | |
12640 start, stop = loc.split(".") | |
12641 except: | |
12642 start, stop = "x", "y" | |
12643 else: | |
12644 start = loc | |
12645 stop = loc | |
12646 try: | |
12647 aninstance = feature( | |
12648 int(start), int(stop), feat, strand, None, None | |
12649 ) | |
12650 outlist.append(aninstance) | |
12651 except: | |
12652 print("feature could not be processed:\n" + line) | |
12653 if feat == "source": | |
12654 try: | |
12655 lengtht = max([int(start), int(stop)]) | |
12656 if lengtht > length: | |
12657 length = lengtht | |
12658 except: | |
12659 pass | |
12660 elif line[2:].startswith(" /colour=") and getFeats: | |
12661 temp = line[27:-1] | |
12662 temp = temp.replace('"', "") | |
12663 temp = temp.replace("'", "") | |
12664 artColourF = temp.split() | |
12665 try: | |
12666 if len(artColourF) == 1: | |
12667 artColour = artColourTable(int(artColourF[0])) | |
12668 else: | |
12669 artColour = ( | |
12670 int(artColourF[0]), | |
12671 int(artColourF[1]), | |
12672 int(artColourF[2]), | |
12673 ) | |
12674 outlist[-1].colour = artColour | |
12675 except: | |
12676 print("Colour could not be processed:\n" + line) | |
12677 elif line[2:].startswith(" /color=") and getFeats: | |
12678 temp = line[26:-1] | |
12679 temp = temp.replace('"', "") | |
12680 temp = temp.replace("'", "") | |
12681 artColourF = temp.split() | |
12682 try: | |
12683 if len(artColourF) == 1: | |
12684 artColour = artColourTable(int(artColourF[0])) | |
12685 else: | |
12686 artColour = ( | |
12687 int(artColourF[0]), | |
12688 int(artColourF[1]), | |
12689 int(artColourF[2]), | |
12690 ) | |
12691 outlist[-1].colour = artColour | |
12692 except: | |
12693 print("Colour could not be processed:\n" + line) | |
12694 elif line[2:].startswith(" /colour=") and getFeats: | |
12695 temp = line[29:-1] | |
12696 temp = temp.replace('"', "") | |
12697 temp = temp.replace("'", "") | |
12698 artColourF = temp.split() | |
12699 try: | |
12700 if len(artColourF) == 1: | |
12701 artColour = artColourTable(int(artColourF[0])) | |
12702 else: | |
12703 artColour = ( | |
12704 int(artColourF[0]), | |
12705 int(artColourF[1]), | |
12706 int(artColourF[2]), | |
12707 ) | |
12708 outlist[-1].colour = artColour | |
12709 except: | |
12710 print("Colour could not be processed:\n" + line) | |
12711 elif line[2:].startswith(" /color=") and getFeats: | |
12712 temp = line[28:-1] | |
12713 temp = temp.replace('"', "") | |
12714 temp = temp.replace("'", "") | |
12715 try: | |
12716 artColourF = temp.split() | |
12717 if len(artColourF) == 1: | |
12718 artColour = artColourTable(int(artColourF[0])) | |
12719 else: | |
12720 artColour = ( | |
12721 int(artColourF[0]), | |
12722 int(artColourF[1]), | |
12723 int(artColourF[2]), | |
12724 ) | |
12725 except: | |
12726 print("Colour could not be processed:\n" + line) | |
12727 outlist[-1].colour = artColour | |
12728 elif ( | |
12729 line[2:].startswith(" /gene=") | |
12730 and getFeats | |
12731 and legname == "gene" | |
12732 ): | |
12733 outlist[-1].name = line.rstrip()[27:].replace('"', "") | |
12734 elif ( | |
12735 line[2:].startswith(" /product=") | |
12736 and getFeats | |
12737 and legname == "product" | |
12738 ): | |
12739 outlist[-1].name = line.rstrip()[30:].replace('"', "") | |
12740 elif ( | |
12741 line[2:].startswith(" /locus_tag=") | |
12742 and getFeats | |
12743 and legname == "locus_tag" | |
12744 ): | |
12745 outlist[-1].name = line.rstrip()[32:].replace('"', "") | |
12746 elif ( | |
12747 line[2:].startswith(" /note=") | |
12748 and getFeats | |
12749 and legname == "note" | |
12750 ): | |
12751 outlist[-1].name = line.rstrip()[27:].replace('"', "") | |
12752 elif line.startswith("ORIGIN") and length == None: | |
12753 getgenseq = True | |
12754 elif line.startswith("SQ Sequence ") and length == None: | |
12755 getemblseq = True | |
12756 elif line.startswith("//"): | |
12757 getemblseq = False | |
12758 getgenseq = False | |
12759 if length == None: | |
12760 length = len(theseq) | |
12761 elif getemblseq: | |
12762 theseq += "".join(line.split()[:-1]) | |
12763 elif getgenseq: | |
12764 theseq += "".join(line.split()[1:]) | |
12765 if getmultifasta: | |
12766 insertSize = len(theseq) / 500 | |
12767 multifastapos = 1 | |
12768 for i in theseq.split("qqq"): | |
12769 aninstance = feature( | |
12770 multifastapos, multifastapos + len(i) - 1, "contig", "+", None, None | |
12771 ) | |
12772 outlist.append(aninstance) | |
12773 multifastapos += len(i) - 1 + insertSize | |
12774 theseq = theseq.replace("qqq", "n" * int(len(theseq) / 500)) | |
12775 if length == None and theseq != "": | |
12776 length = len(theseq) | |
12777 return length, outlist | |
12778 | |
12779 | |
12780 # detects whether blast+ is in your path | |
12781 def isNewBlastDB(): | |
12782 path = os.environ["PATH"].split(os.pathsep) | |
12783 isit = False | |
12784 for i in path: | |
12785 if os.path.exists(i + "/" + "makeblastdb.exe") or os.path.exists( | |
12786 i + "/" "makeblastdb" | |
12787 ): | |
12788 isit = True | |
12789 return isit | |
12790 | |
12791 | |
12792 def isNewBlastn(): | |
12793 path = os.environ["PATH"].split(os.pathsep) | |
12794 isit = False | |
12795 for i in path: | |
12796 if os.path.exists(i + "/" + "blastn.exe") or os.path.exists(i + "/" "blastn"): | |
12797 isit = True | |
12798 return isit | |
12799 | |
12800 | |
12801 def isNewTblastx(): | |
12802 path = os.environ["PATH"].split(os.pathsep) | |
12803 isit = False | |
12804 for i in path: | |
12805 if os.path.exists(i + "/" + "tblastx.exe") or os.path.exists(i + "/" "tblastx"): | |
12806 isit = True | |
12807 return isit | |
12808 | |
12809 | |
12810 # detects legacy blast in your path | |
12811 def isLegBlastDB(): | |
12812 path = os.environ["PATH"].split(os.pathsep) | |
12813 isit = False | |
12814 for i in path: | |
12815 if os.path.exists(i + "/" + "formatdb.exe") or os.path.exists( | |
12816 i + "/" "formatdb" | |
12817 ): | |
12818 isit = True | |
12819 return isit | |
12820 | |
12821 | |
12822 def isLegBlastall(): | |
12823 path = os.environ["PATH"].split(os.pathsep) | |
12824 isit = False | |
12825 for i in path: | |
12826 if os.path.exists(i + "/" + "blastall.exe") or os.path.exists( | |
12827 i + "/" "blastall" | |
12828 ): | |
12829 isit = True | |
12830 return isit | |
12831 | |
12832 | |
12833 # gets all blast hits length >minlength and e value < mineval and identity > minident | |
12834 def getBlast(filename, minlength, mineval, minident): | |
12835 if filename == "": | |
12836 return [] | |
12837 blast = open(filename) | |
12838 testline = blast.readline() | |
12839 try: | |
12840 ( | |
12841 query, | |
12842 subject, | |
12843 ident, | |
12844 length, | |
12845 mismatch, | |
12846 indel, | |
12847 qStart, | |
12848 qEnd, | |
12849 rStart, | |
12850 rEnd, | |
12851 eVal, | |
12852 bitScore, | |
12853 ) = testline.split() | |
12854 ident = float(ident) | |
12855 length = int(length) | |
12856 mismatch = int(mismatch) | |
12857 indel = int(indel) | |
12858 qStart = int(qStart) | |
12859 qEnd = int(qEnd) | |
12860 rStart = int(rStart) | |
12861 rEnd = int(rEnd) | |
12862 eVal = float(eVal) | |
12863 bitScore = float(bitScore) | |
12864 crunch = False | |
12865 except: | |
12866 crunch = True | |
12867 blast.close() | |
12868 blast = open(filename) | |
12869 outlist = [] | |
12870 for line in blast: | |
12871 if crunch: | |
12872 score, ident, qStart, qEnd, query, rStart, rEnd, subject = line.split()[:8] | |
12873 qStart = int(qStart) | |
12874 qEnd = int(qEnd) | |
12875 eVal = 0 | |
12876 length = abs(qStart - qEnd) | |
12877 else: | |
12878 ( | |
12879 query, | |
12880 subject, | |
12881 ident, | |
12882 length, | |
12883 mismatch, | |
12884 indel, | |
12885 qStart, | |
12886 qEnd, | |
12887 rStart, | |
12888 rEnd, | |
12889 eVal, | |
12890 bitScore, | |
12891 ) = line.split() | |
12892 eVal = float(eVal) | |
12893 ident = float(ident) | |
12894 length = int(length) | |
12895 qStart = int(qStart) | |
12896 qEnd = int(qEnd) | |
12897 rStart = int(rStart) | |
12898 rEnd = int(rEnd) | |
12899 eVal = float(eVal) | |
12900 if length >= minlength and eVal <= mineval and ident >= minident: | |
12901 outlist.append((qStart, qEnd, rStart, rEnd, ident)) | |
12902 return outlist | |
12903 | |
12904 | |
12905 # draws teh image | |
12906 def draw( | |
12907 filename, | |
12908 minlength, | |
12909 mineval, | |
12910 minIdent, | |
12911 inputlist, | |
12912 width, | |
12913 height1, | |
12914 height2, | |
12915 minblastc, | |
12916 maxblastc, | |
12917 minblastci, | |
12918 maxblastci, | |
12919 drawfig1, | |
12920 drawfig2, | |
12921 drawfig3, | |
12922 compress, | |
12923 reverseList, | |
12924 featDict, | |
12925 glt, | |
12926 exont, | |
12927 genet, | |
12928 featlengths, | |
12929 aln, | |
12930 graphit, | |
12931 blastoutline, | |
12932 minmaxlist, | |
12933 autodetect, | |
12934 legend, | |
12935 legname, | |
12936 writebmp=0, | |
12937 ): | |
12938 # global variable for stopping script midway | |
12939 global abortCaptain | |
12940 secondlist = [] | |
12941 maxlength = 0 | |
12942 totalheight = 0 | |
12943 # returning a minident value of 101 means the script has been aborted | |
12944 minident = 101 | |
12945 # gets feature file and blast information | |
12946 for i in range(0, len(inputlist)): | |
12947 if i % 2 == 0: | |
12948 temp = getArrows(inputlist[i], legname) | |
12949 thirdlist = [] | |
12950 if minmaxlist[int(i / 2)][1] == "Max": | |
12951 if temp[0] == None: | |
12952 maxcut = featlengths[int(i / 2)] | |
12953 else: | |
12954 maxcut = temp[0] | |
12955 if minmaxlist[int(i / 2)][0] == 1: | |
12956 minmaxopt = 0 | |
12957 else: | |
12958 minmaxopt = 1 | |
12959 mincut = minmaxlist[int(i / 2)][0] | |
12960 else: | |
12961 mincut = minmaxlist[int(i / 2)][0] | |
12962 maxcut = minmaxlist[int(i / 2)][1] | |
12963 if minmaxlist[int(i / 2)][0] < minmaxlist[int(i / 2)][1]: | |
12964 minmaxopt = 1 | |
12965 else: | |
12966 minmaxopt = 2 | |
12967 for j in temp[1]: | |
12968 if j.type in featDict: | |
12969 if j.colour == None: | |
12970 j.colour = featDict[j.type][1] | |
12971 if minmaxopt == 0: | |
12972 thirdlist.append(j) | |
12973 elif minmaxopt == 1: | |
12974 if type(j.start) == int: | |
12975 if j.start >= mincut and j.stop <= maxcut: | |
12976 aninstance = feature( | |
12977 j.start - mincut + 1, | |
12978 j.stop - mincut + 1, | |
12979 j.type, | |
12980 j.strand, | |
12981 j.colour, | |
12982 j.name, | |
12983 ) | |
12984 thirdlist.append(aninstance) | |
12985 else: | |
12986 if j.start[0] >= mincut and j.stop[-1] <= maxcut: | |
12987 tempstart = [] | |
12988 for k in j.start: | |
12989 tempstart.append(k - mincut + 1) | |
12990 tempstop = [] | |
12991 for k in j.stop: | |
12992 tempstop.append(k - mincut + 1) | |
12993 aninstance = feature( | |
12994 tempstart, | |
12995 tempstop, | |
12996 j.type, | |
12997 j.strand, | |
12998 j.colour, | |
12999 j.name, | |
13000 ) | |
13001 thirdlist.append(aninstance) | |
13002 elif minmaxopt == 2: | |
13003 if temp[0] == None: | |
13004 templength = featlengths[int(i / 2)] | |
13005 else: | |
13006 templength = temp[0] | |
13007 if type(j.start) == int: | |
13008 if j.stop <= maxcut: | |
13009 tempstart = j.start + templength - mincut + 1 | |
13010 tempstop = j.stop + templength - mincut + 1 | |
13011 aninstance = feature( | |
13012 tempstart, | |
13013 tempstop, | |
13014 j.type, | |
13015 j.strand, | |
13016 j.colour, | |
13017 j.name, | |
13018 ) | |
13019 thirdlist.append(aninstance) | |
13020 elif j.start >= mincut: | |
13021 tempstart = j.start - mincut + 1 | |
13022 tempstop = j.stop - mincut + 1 | |
13023 aninstance = feature( | |
13024 tempstart, | |
13025 tempstop, | |
13026 j.type, | |
13027 j.strand, | |
13028 j.colour, | |
13029 j.name, | |
13030 ) | |
13031 thirdlist.append(aninstance) | |
13032 else: | |
13033 if j.stop[-1] <= maxcut: | |
13034 tempstart = [] | |
13035 for k in j.start: | |
13036 tempstart.append(k + templength - mincut + 1) | |
13037 tempstop = [] | |
13038 for k in j.stop: | |
13039 tempstop.append(k + templength - mincut + 1) | |
13040 aninstance = feature( | |
13041 tempstart, | |
13042 tempstop, | |
13043 j.type, | |
13044 j.strand, | |
13045 j.colour, | |
13046 j.name, | |
13047 ) | |
13048 thirdlist.append(aninstance) | |
13049 elif j.start[0] >= mincut: | |
13050 tempstart = [] | |
13051 for k in j.start: | |
13052 tempstart.append(k - mincut + 1) | |
13053 tempstop = [] | |
13054 for k in j.stop: | |
13055 tempstop.append(k - mincut + 1) | |
13056 aninstance = feature( | |
13057 tempstart, | |
13058 tempstop, | |
13059 j.type, | |
13060 j.strand, | |
13061 j.colour, | |
13062 j.name, | |
13063 ) | |
13064 thirdlist.append(aninstance) | |
13065 thirdlist.sort(key=lambda ii: ii.length(), reverse=True) | |
13066 if minmaxopt == 0: | |
13067 if temp[0] == None: | |
13068 secondlist.append((featlengths[int(i / 2)], thirdlist)) | |
13069 if featlengths[int(i / 2)] > maxlength: | |
13070 maxlength = featlengths[int(i / 2)] | |
13071 else: | |
13072 secondlist.append((temp[0], thirdlist)) | |
13073 if temp[0] > maxlength: | |
13074 maxlength = temp[0] | |
13075 elif minmaxopt == 1: | |
13076 secondlist.append((maxcut - mincut + 1, thirdlist)) | |
13077 if maxcut - mincut + 1 > maxlength: | |
13078 maxlength = maxcut - mincut + 1 | |
13079 elif minmaxopt == 2: | |
13080 if temp[0] == None: | |
13081 templength = featlengths[int(i / 2)] | |
13082 else: | |
13083 templength = temp[0] | |
13084 secondlist.append((templength - mincut + maxcut + 1, thirdlist)) | |
13085 if templength - mincut + maxcut + 1 > maxlength: | |
13086 maxlength = templength - mincut + maxlength + 1 | |
13087 totalheight += height1 | |
13088 else: | |
13089 totalheight += height2 | |
13090 temp = getBlast(inputlist[i], minlength, mineval, minIdent) | |
13091 for j in temp: | |
13092 if j[4] < minident: | |
13093 minident = j[4] | |
13094 secondlist.append(temp) | |
13095 # calculates offsets for genomes if best blast alignment is selected | |
13096 if autodetect and maxlength > 100000: | |
13097 tempsecond = [] | |
13098 minident = 101 | |
13099 for i in range(len(secondlist)): | |
13100 temp = [] | |
13101 if i % 2 == 0: | |
13102 for j in secondlist[i][1]: | |
13103 if type(j.start) == int: | |
13104 if (j.stop - j.start) * 1.0 / maxlength * width > 4: | |
13105 temp.append(j) | |
13106 else: | |
13107 if (j.stop[0] - j.start[0]) * 1.0 / maxlength * width > 4: | |
13108 temp.append(j) | |
13109 tempsecond.append((secondlist[i][0], temp)) | |
13110 else: | |
13111 for j in secondlist[i]: | |
13112 if (j[1] - j[0]) * 1.0 / maxlength * width > 3: | |
13113 temp.append(j) | |
13114 if j[4] < minident: | |
13115 minident = j[4] | |
13116 tempsecond.append(temp) | |
13117 secondlist = tempsecond | |
13118 if minIdent != 0: | |
13119 minident = minIdent | |
13120 if aln == "best blast": | |
13121 blastmatch = [0] | |
13122 for i in range(1, len(secondlist), 2): | |
13123 maxbitscore = 0 | |
13124 for j in secondlist[i]: | |
13125 if j[1] - j[0] > maxbitscore: | |
13126 qstart, qend, rstart, rend = j[0], j[1], j[2], j[3] | |
13127 maxbitscore = j[1] - j[0] | |
13128 if len(secondlist[i]) == 0: | |
13129 theQstart = 0 | |
13130 elif reverseList[int(i / 2)]: | |
13131 theQstart = secondlist[i - 1][0] - qend | |
13132 else: | |
13133 theQstart = qstart | |
13134 if reverseList[int((i + 1) / 2)]: | |
13135 if len(secondlist[i]) == 0: | |
13136 theRstart = 0 | |
13137 elif rstart < rend: | |
13138 theRstart = secondlist[i + 1][0] - rend | |
13139 else: | |
13140 theRstart = secondlist[i + 1][0] - rstart | |
13141 else: | |
13142 if len(secondlist[i]) == 0: | |
13143 theRstart = 0 | |
13144 elif rstart < rend: | |
13145 theRstart = rstart | |
13146 else: | |
13147 theRstart = rend | |
13148 blastmatch.append(blastmatch[-1] + theQstart - theRstart) | |
13149 theminblast = min(blastmatch) | |
13150 templist = [] | |
13151 for i in blastmatch: | |
13152 templist.append(i - theminblast) | |
13153 blastmatch = templist | |
13154 for i in range(0, len(secondlist) + 1, 2): | |
13155 if secondlist[i][0] + blastmatch[int(i / 2)] > maxlength: | |
13156 maxlength = secondlist[i][0] + blastmatch[int(i / 2)] | |
13157 leghei = 0 | |
13158 if legend == "Single column" or legend == "Two columns": | |
13159 legendArrows = set() | |
13160 legendList = [] | |
13161 for i in range(len(secondlist)): | |
13162 if i % 2 == 0: | |
13163 legendList.append([]) | |
13164 for j in secondlist[i][1]: | |
13165 if ( | |
13166 j.name != None | |
13167 and (j.name, j.colour, featDict[j.type][0]) not in legendArrows | |
13168 ): | |
13169 legendArrows.add((j.name, j.colour, featDict[j.type][0])) | |
13170 if type(j.start) == int: | |
13171 tempjstart = j.start | |
13172 else: | |
13173 tempjstart = j.start[0] | |
13174 legendList[int(i / 2)].append( | |
13175 (j.name, j.colour, featDict[j.type][0], tempjstart) | |
13176 ) | |
13177 if legend == "Single column": | |
13178 leghei += min([5000, len(legendArrows) * 90]) | |
13179 elif legend == "Two columns": | |
13180 leghei = min([5000, (len(legendArrows) + 1) / 2 * 90]) | |
13181 global shifter | |
13182 if legend == "Top" or legend == "Top & Bottom": | |
13183 toplegpos = [0, 0, 0, set(), set(), set()] | |
13184 legendTop = [] | |
13185 testbmp = BitMap(10, 10) | |
13186 if aln == "best blast": | |
13187 shifter = blastmatch[0] | |
13188 genrev1 = reverseList[0] | |
13189 for j in secondlist[0][1]: | |
13190 if j.name != None: | |
13191 if type(j.start) == int: | |
13192 firstleg = True | |
13193 secondleg = True | |
13194 thirdleg = True | |
13195 if genrev1: | |
13196 legpos = convertPosR( | |
13197 secondlist[0][0], | |
13198 maxlength, | |
13199 width, | |
13200 (j.start + j.stop) / 2, | |
13201 aln, | |
13202 ) | |
13203 else: | |
13204 legpos = convertPos( | |
13205 secondlist[0][0], | |
13206 maxlength, | |
13207 width, | |
13208 (j.start + j.stop) / 2, | |
13209 aln, | |
13210 ) | |
13211 for q in range(legpos - 40, legpos + 50): | |
13212 if q in toplegpos[3]: | |
13213 firstleg = False | |
13214 if q in toplegpos[4]: | |
13215 secondleg = False | |
13216 if q in toplegpos[5]: | |
13217 thirdleg = False | |
13218 if firstleg: | |
13219 therung = 1 | |
13220 if testbmp.lengthString(j.name[:10], 64) > toplegpos[0]: | |
13221 toplegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
13222 for q in range(legpos - 40, legpos + 50): | |
13223 toplegpos[3].add(q) | |
13224 # elif secondleg: | |
13225 # therung = 2 | |
13226 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[1]: | |
13227 # toplegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
13228 # for q in range(legpos - 40, legpos + 50): | |
13229 # toplegpos[4].add(q) | |
13230 # elif thirdleg: | |
13231 # therung = 3 | |
13232 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[2]: | |
13233 # toplegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
13234 # for q in range(legpos - 40, legpos + 50): | |
13235 # toplegpos[5].add(q) | |
13236 else: | |
13237 therung = None | |
13238 legendTop.append((j.name[:10], legpos, therung)) | |
13239 else: | |
13240 firstleg = True | |
13241 secondleg = True | |
13242 thirdleg = True | |
13243 if genrev1: | |
13244 legpos = convertPosR( | |
13245 secondlist[0][0], | |
13246 maxlength, | |
13247 width, | |
13248 (j.start[0] + j.stop[0]) / 2, | |
13249 aln, | |
13250 ) | |
13251 else: | |
13252 legpos = convertPos( | |
13253 secondlist[0][0], | |
13254 maxlength, | |
13255 width, | |
13256 (j.start[0] + j.stop[0]) / 2, | |
13257 aln, | |
13258 ) | |
13259 for q in range(legpos - 40, legpos + 50): | |
13260 if q in toplegpos[3]: | |
13261 firstleg = False | |
13262 if q in toplegpos[4]: | |
13263 secondleg = False | |
13264 if q in toplegpos[5]: | |
13265 thirdleg = False | |
13266 if firstleg: | |
13267 therung = 1 | |
13268 if testbmp.lengthString(j.name[:10], 64) > toplegpos[0]: | |
13269 toplegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
13270 for q in range(legpos - 40, legpos + 50): | |
13271 toplegpos[3].add(q) | |
13272 # elif secondleg: | |
13273 # therung = 2 | |
13274 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[1]: | |
13275 # toplegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
13276 # for q in range(legpos - 40, legpos + 50): | |
13277 # toplegpos[4].add(q) | |
13278 # elif thirdleg: | |
13279 # therung = 3 | |
13280 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[2]: | |
13281 # toplegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
13282 # for q in range(legpos - 40, legpos + 50): | |
13283 # toplegpos[5].add(q) | |
13284 else: | |
13285 therung = None | |
13286 legendTop.append((j.name[:10], legpos, therung)) | |
13287 totalheight += sum(toplegpos[:3]) + 40 | |
13288 if legend == "Bottom" or legend == "Top & Bottom": | |
13289 botlegpos = [0, 0, 0, set(), set(), set()] | |
13290 legendBot = [] | |
13291 testbmp = BitMap(10, 10) | |
13292 if aln == "best blast": | |
13293 shifter = blastmatch[-1] | |
13294 genrev1 = reverseList[-1] | |
13295 for j in secondlist[-1][1]: | |
13296 if j.name != None: | |
13297 if type(j.start) == int: | |
13298 firstleg = True | |
13299 secondleg = True | |
13300 thirdleg = True | |
13301 if genrev1: | |
13302 legpos = convertPosR( | |
13303 secondlist[-1][0], | |
13304 maxlength, | |
13305 width, | |
13306 (j.start + j.stop) / 2, | |
13307 aln, | |
13308 ) | |
13309 else: | |
13310 legpos = convertPos( | |
13311 secondlist[-1][0], | |
13312 maxlength, | |
13313 width, | |
13314 (j.start + j.stop) / 2, | |
13315 aln, | |
13316 ) | |
13317 for q in range(legpos - 40, legpos + 50): | |
13318 if q in botlegpos[3]: | |
13319 firstleg = False | |
13320 if q in botlegpos[4]: | |
13321 secondleg = False | |
13322 if q in botlegpos[5]: | |
13323 thirdleg = False | |
13324 if firstleg: | |
13325 therung = 1 | |
13326 if testbmp.lengthString(j.name[:10], 64) > botlegpos[0]: | |
13327 botlegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
13328 for q in range(legpos - 40, legpos + 50): | |
13329 botlegpos[3].add(q) | |
13330 # elif secondleg: | |
13331 # therung = 2 | |
13332 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[1]: | |
13333 # botlegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
13334 # for q in range(legpos - 40, legpos + 50): | |
13335 # botlegpos[4].add(q) | |
13336 # elif thirdleg: | |
13337 # therung = 3 | |
13338 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[2]: | |
13339 # botlegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
13340 # for q in range(legpos - 40, legpos + 50): | |
13341 # botlegpos[5].add(q) | |
13342 else: | |
13343 therung = None | |
13344 legendBot.append((j.name[:10], legpos, therung)) | |
13345 else: | |
13346 firstleg = True | |
13347 secondleg = True | |
13348 thirdleg = True | |
13349 if genrev1: | |
13350 legpos = convertPosR( | |
13351 secondlist[-1][0], | |
13352 maxlength, | |
13353 width, | |
13354 (j.start[0] + j.stop[0]) / 2, | |
13355 aln, | |
13356 ) | |
13357 else: | |
13358 legpos = convertPos( | |
13359 secondlist[-1][0], | |
13360 maxlength, | |
13361 width, | |
13362 (j.start[0] + j.stop[0]) / 2, | |
13363 aln, | |
13364 ) | |
13365 for q in range( | |
13366 (j.start[0] + j.stop[0]) / 2 - 40, | |
13367 (j.start[0] + j.stop[0]) / 2 + 50, | |
13368 ): | |
13369 if q in botlegpos[3]: | |
13370 firstleg = False | |
13371 if q in botlegpos[4]: | |
13372 secondleg = False | |
13373 if q in botlegpos[5]: | |
13374 thirdleg = False | |
13375 if firstleg: | |
13376 therung = 1 | |
13377 if testbmp.lengthString(j.name[:10], 64) > botlegpos[0]: | |
13378 botlegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
13379 for q in range( | |
13380 (j.start[0] + j.stop[0]) / 2 - 40, | |
13381 (j.start[0] + j.stop[0]) / 2 + 50, | |
13382 ): | |
13383 botlegpos[3].add(q) | |
13384 # elif secondleg: | |
13385 # therung = 2 | |
13386 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[1]: | |
13387 # botlegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
13388 # for q in range((j.start[0] + j.stop[0])/2 - 40, (j.start[0] + j.stop[0])/2 + 50): | |
13389 # botlegpos[4].add(q) | |
13390 # elif thirdleg: | |
13391 # therung = 3 | |
13392 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[2]: | |
13393 # botlegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
13394 # for q in range((j.start[0] + j.stop[0])/2 - 40, (j.start[0] + j.stop[0])/2 + 50): | |
13395 # botlegpos[5].add(q) | |
13396 else: | |
13397 therung = None | |
13398 legendBot.append( | |
13399 (j.name[:10], (j.start[0] + j.stop[0]) / 2, therung) | |
13400 ) | |
13401 totalheight += sum(botlegpos[:3]) + 40 | |
13402 # creates extra width for blast identity legend | |
13403 drawfig1hei = 0 | |
13404 if drawfig1 and minident != 101: | |
13405 drawfig1hei = 500 | |
13406 extraheight = 0 | |
13407 # creates extra height for scale legend | |
13408 drawfig2hei = 0 | |
13409 if drawfig2: | |
13410 drawfig2hei = height1 + 70 | |
13411 # creates extra height for graph | |
13412 totalheight += max([leghei, drawfig1hei, drawfig2hei]) | |
13413 hei = totalheight | |
13414 if graphit != None: | |
13415 hei += graphit[3] * len(graphit[0]) + 2 * graphit[7] * len(graphit[0]) | |
13416 extraheight = (graphit[3] + 20) * len(graphit[0]) | |
13417 bmp = BitMap(width, hei + 1) | |
13418 # draws the scale figure | |
13419 columnhei = max([leghei, drawfig1hei, drawfig2hei]) | |
13420 if legend == "Single column": | |
13421 index = 0 | |
13422 legendArrows = [] | |
13423 for i in range(len(legendList)): | |
13424 x = legendList[i] | |
13425 x.sort(key=operator.itemgetter(3)) | |
13426 if reverseList[i]: | |
13427 x.reverse() | |
13428 legendArrows += x | |
13429 for i in range(columnhei - 74, 10, -90): | |
13430 # print len(legendArrows), legendArrows[index][2] | |
13431 if index < len(legendArrows) and legendArrows[index][2] == "rect": | |
13432 theColor = Color( | |
13433 legendArrows[index][1][0], | |
13434 legendArrows[index][1][1], | |
13435 legendArrows[index][1][2], | |
13436 ) | |
13437 bmp.setPenColor(theColor) | |
13438 bmp.drawOutRect(5, i, 96, 64, genet) | |
13439 bmp.setPenColor(Color.BLACK) | |
13440 bmp.writeString(legendArrows[index][0], 106, i, 64) | |
13441 elif index < len(legendArrows) and legendArrows[index][2] == "arrow": | |
13442 theColor = Color( | |
13443 legendArrows[index][1][0], | |
13444 legendArrows[index][1][1], | |
13445 legendArrows[index][1][2], | |
13446 ) | |
13447 bmp.setPenColor(theColor) | |
13448 bmp.drawRightArrow(5, i, 96, 64, genet) | |
13449 bmp.setPenColor(Color.BLACK) | |
13450 bmp.writeString(legendArrows[index][0], 106, i, 64) | |
13451 elif index < len(legendArrows) and legendArrows[index][2] == "frame": | |
13452 theColor = Color( | |
13453 legendArrows[index][1][0], | |
13454 legendArrows[index][1][1], | |
13455 legendArrows[index][1][2], | |
13456 ) | |
13457 bmp.setPenColor(theColor) | |
13458 bmp.drawRightFrame(5, i - 48, 96, 128, genet, 1) | |
13459 bmp.setPenColor(Color.BLACK) | |
13460 bmp.writeString(legendArrows[index][0], 106, i, 64) | |
13461 elif index < len(legendArrows) and legendArrows[index][2] == "pointer": | |
13462 theColor = Color( | |
13463 legendArrows[index][1][0], | |
13464 legendArrows[index][1][1], | |
13465 legendArrows[index][1][2], | |
13466 ) | |
13467 bmp.setPenColor(theColor) | |
13468 bmp.drawPointer(34, i, 64, genet) | |
13469 bmp.setPenColor(Color.BLACK) | |
13470 bmp.writeString(legendArrows[index][0], 106, i, 64) | |
13471 else: | |
13472 print("wang") | |
13473 index += 1 | |
13474 elif legend == "Two columns": | |
13475 index = 0 | |
13476 legendArrows = [] | |
13477 for i in range(len(legendList)): | |
13478 x = legendList[i] | |
13479 x.sort(key=operator.itemgetter(3)) | |
13480 if reverseList[i]: | |
13481 x.reverse() | |
13482 legendArrows += x | |
13483 for i in range(columnhei - 74, 10, -90): | |
13484 if index < len(legendArrows) and legendArrows[index][2] == "rect": | |
13485 theColor = Color( | |
13486 legendArrows[index][1][0], | |
13487 legendArrows[index][1][1], | |
13488 legendArrows[index][1][2], | |
13489 ) | |
13490 bmp.setPenColor(theColor) | |
13491 bmp.drawOutRect(5, i, 96, 64, genet) | |
13492 bmp.setPenColor(Color.BLACK) | |
13493 bmp.writeString(legendArrows[index][0][:45], 106, i, 64) | |
13494 elif index < len(legendArrows) and legendArrows[index][2] == "arrow": | |
13495 theColor = Color( | |
13496 legendArrows[index][1][0], | |
13497 legendArrows[index][1][1], | |
13498 legendArrows[index][1][2], | |
13499 ) | |
13500 bmp.setPenColor(theColor) | |
13501 bmp.drawRightArrow(5, i, 96, 64, genet) | |
13502 bmp.setPenColor(Color.BLACK) | |
13503 bmp.writeString(legendArrows[index][0][:45], 106, i, 64) | |
13504 elif index < len(legendArrows) and legendArrows[index][2] == "frame": | |
13505 theColor = Color( | |
13506 legendArrows[index][1][0], | |
13507 legendArrows[index][1][1], | |
13508 legendArrows[index][1][2], | |
13509 ) | |
13510 bmp.setPenColor(theColor) | |
13511 bmp.drawRightFrame(5, i - 48, 96, 128, genet, 1) | |
13512 bmp.setPenColor(Color.BLACK) | |
13513 bmp.writeString(legendArrows[index][0][:45], 106, i, 64) | |
13514 elif index < len(legendArrows) and legendArrows[index][2] == "pointer": | |
13515 theColor = Color( | |
13516 legendArrows[index][1][0], | |
13517 legendArrows[index][1][1], | |
13518 legendArrows[index][1][2], | |
13519 ) | |
13520 bmp.setPenColor(theColor) | |
13521 bmp.drawPointer(34, i, 64, genet) | |
13522 bmp.setPenColor(Color.BLACK) | |
13523 bmp.writeString(legendArrows[index][0][:45], 106, i, 64) | |
13524 index += 1 | |
13525 for i in range(columnhei - 74, 10, -90): | |
13526 if index < len(legendArrows) and legendArrows[index][2] == "rect": | |
13527 theColor = Color( | |
13528 legendArrows[index][1][0], | |
13529 legendArrows[index][1][1], | |
13530 legendArrows[index][1][2], | |
13531 ) | |
13532 bmp.setPenColor(theColor) | |
13533 bmp.drawOutRect(5 + width / 3, i, 96, 64, genet) | |
13534 bmp.setPenColor(Color.BLACK) | |
13535 bmp.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
13536 elif index < len(legendArrows) and legendArrows[index][2] == "arrow": | |
13537 theColor = Color( | |
13538 legendArrows[index][1][0], | |
13539 legendArrows[index][1][1], | |
13540 legendArrows[index][1][2], | |
13541 ) | |
13542 bmp.setPenColor(theColor) | |
13543 bmp.drawRightArrow(5 + width / 3, i, 96, 64, genet) | |
13544 bmp.setPenColor(Color.BLACK) | |
13545 bmp.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
13546 elif index < len(legendArrows) and legendArrows[index][2] == "frame": | |
13547 theColor = Color( | |
13548 legendArrows[index][1][0], | |
13549 legendArrows[index][1][1], | |
13550 legendArrows[index][1][2], | |
13551 ) | |
13552 bmp.setPenColor(theColor) | |
13553 bmp.drawRightFrame(5 + width / 3, i - 48, 96, 128, genet, 1) | |
13554 bmp.setPenColor(Color.BLACK) | |
13555 bmp.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
13556 elif index < len(legendArrows) and legendArrows[index][2] == "pointer": | |
13557 theColor = Color( | |
13558 legendArrows[index][1][0], | |
13559 legendArrows[index][1][1], | |
13560 legendArrows[index][1][2], | |
13561 ) | |
13562 bmp.setPenColor(theColor) | |
13563 bmp.drawPointer(34 + width / 3, i, 64, genet) | |
13564 bmp.setPenColor(Color.BLACK) | |
13565 bmp.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
13566 index += 1 | |
13567 if legend == "Top" or legend == "Top & Bottom": | |
13568 rung1 = totalheight - sum(toplegpos[:3]) - 30 | |
13569 rung2 = rung1 + toplegpos[0] + 10 | |
13570 rung3 = rung2 + toplegpos[1] + 10 | |
13571 for i in legendTop: | |
13572 if i[0][0].lower() == i[0][0]: | |
13573 xpos = i[1] + 24 | |
13574 else: | |
13575 xpos = i[1] + 32 | |
13576 if i[2] == 1: | |
13577 bmp.writeString(i[0], xpos, rung1, 64, False, False, 1) | |
13578 elif i[2] == 2: | |
13579 bmp.writeString(i[0], xpos, rung2, 64, False, False, 1) | |
13580 elif i[2] == 3: | |
13581 bmp.writeString(i[0], xpos, rung3, 64, False, False, 1) | |
13582 | |
13583 if legend == "Bottom" or legend == "Top & Bottom": | |
13584 rung1 = sum(botlegpos[:3]) + 30 + columnhei | |
13585 rung2 = rung1 - botlegpos[0] - 10 | |
13586 rung3 = rung2 - botlegpos[1] - 10 | |
13587 for i in legendBot: | |
13588 if i[0][-1].lower() == i[0][-1]: | |
13589 xpos = i[1] + 24 | |
13590 else: | |
13591 xpos = i[1] + 32 | |
13592 if i[2] == 1: | |
13593 bmp.writeString(i[0], xpos, rung1, 64, False, False, 1, "right") | |
13594 elif i[2] == 2: | |
13595 bmp.writeString(i[0], xpos, rung2, 64, False, False, 1, "right") | |
13596 elif i[2] == 3: | |
13597 bmp.writeString(i[0], xpos, rung3, 64, False, False, 1, "right") | |
13598 if drawfig2 != False: | |
13599 bmp.setPenColor(Color.BLACK) | |
13600 x1 = width - 600 - drawfig2 * 1.0 / maxlength * width | |
13601 x2 = width - 600 | |
13602 bmp.drawLine(x1, columnhei - height1 / 2 - 74, x2, columnhei - height1 / 2 - 74) | |
13603 bmp.drawLine( | |
13604 x1, columnhei - height1 / 2 - 1 - 74, x2, columnhei - height1 / 2 - 1 - 74 | |
13605 ) | |
13606 bmp.drawLine( | |
13607 x1, columnhei - height1 / 2 + 1 - 74, x2, columnhei - height1 / 2 + 1 - 74 | |
13608 ) | |
13609 bmp.drawLine( | |
13610 x1 - 1, | |
13611 columnhei - height1 / 4 - 74, | |
13612 x1 - 1, | |
13613 columnhei - height1 / 4 * 3 - 74, | |
13614 ) | |
13615 bmp.drawLine( | |
13616 x1 + 1, | |
13617 columnhei - height1 / 4 - 74, | |
13618 x1 + 1, | |
13619 columnhei - height1 / 4 * 3 - 74, | |
13620 ) | |
13621 bmp.drawLine( | |
13622 x1, columnhei - height1 / 4 - 74, x1, columnhei - height1 / 4 * 3 - 74 | |
13623 ) | |
13624 bmp.drawLine( | |
13625 x2, columnhei - height1 / 4 - 74, x2, columnhei - height1 / 4 * 3 - 74 | |
13626 ) | |
13627 bmp.drawLine( | |
13628 x2 + 1, | |
13629 columnhei - height1 / 4 - 74, | |
13630 x2 + 1, | |
13631 columnhei - height1 / 4 * 3 - 74, | |
13632 ) | |
13633 bmp.drawLine( | |
13634 x2 - 1, | |
13635 columnhei - height1 / 4 - 74, | |
13636 x2 - 1, | |
13637 columnhei - height1 / 4 * 3 - 74, | |
13638 ) | |
13639 strfig2 = str(drawfig2) | |
13640 if strfig2[-6:] == "000000": | |
13641 strfig2 = strfig2[:-6] + " Mbp" | |
13642 elif strfig2[-3:] == "000": | |
13643 strfig2 = strfig2[:-3] + " Kbp" | |
13644 testbmp = BitMap(10, 10) | |
13645 bmp.writeString( | |
13646 strfig2, | |
13647 (x1 + x2) / 2 - testbmp.lengthString(strfig2, 64) / 2, | |
13648 columnhei - height1 / 4 - 59, | |
13649 64, | |
13650 ) | |
13651 # draws the graph | |
13652 if graphit != None: | |
13653 thearray, maxgc, mingc, gheight, glinet, gtype, gmaxy, ggap = graphit | |
13654 widthpixellist = [] | |
13655 leftpixellist = [] | |
13656 rightpixellist = [] | |
13657 for i in range(len(thearray)): | |
13658 if aln == "best blast": | |
13659 shifter = blastmatch[i] | |
13660 if reverseList[i]: | |
13661 rightpixel = convertPosR(secondlist[i * 2][0], maxlength, width, 0, aln) | |
13662 leftpixel = convertPosR( | |
13663 secondlist[i * 2][0], maxlength, width, secondlist[i * 2][0], aln | |
13664 ) | |
13665 thearray[i].reverse() | |
13666 else: | |
13667 leftpixel = convertPos(secondlist[i * 2][0], maxlength, width, 0, aln) | |
13668 rightpixel = convertPos( | |
13669 secondlist[i * 2][0], maxlength, width, secondlist[i * 2][0], aln | |
13670 ) | |
13671 | |
13672 widthpixel = rightpixel - leftpixel + 1 | |
13673 widthpixellist.append(widthpixel) | |
13674 leftpixellist.append(leftpixel) | |
13675 rightpixellist.append(rightpixel) | |
13676 neg = False | |
13677 if gmaxy == "Auto": | |
13678 gmaxy = 0 | |
13679 for i in range(0, len(thearray)): | |
13680 if min(thearray[i]) < 0: | |
13681 neg = True | |
13682 for j in range(0, widthpixellist[i]): | |
13683 aa = int(j * (len(thearray[i]) * 1.0 / widthpixellist[i])) | |
13684 bb = int((j + 1) * (len(thearray[i]) * 1.0 / widthpixellist[i])) | |
13685 if aa == bb: | |
13686 bb += 1 | |
13687 temparr = thearray[i][aa:bb] | |
13688 gyval = abs(sum(temparr) * 1.0 / len(temparr)) | |
13689 if gyval > gmaxy: | |
13690 gmaxy = gyval | |
13691 else: | |
13692 gmaxy = float(gmaxy) | |
13693 for i in range(0, len(thearray)): | |
13694 if min(thearray[i]) < 0: | |
13695 neg = True | |
13696 if neg: | |
13697 axispos = hei - ggap - gheight / 2 - glinet / 2 | |
13698 else: | |
13699 axispos = hei - ggap - gheight - glinet | |
13700 gc1, gc2, gc3 = maxgc | |
13701 maxgcColour = Color(gc1, gc2, gc3) | |
13702 bmp.setPenColor(maxgcColour) | |
13703 gc1, gc2, gc3 = mingc | |
13704 mingcColour = Color(gc1, gc2, gc3) | |
13705 for qq in range(len(thearray)): | |
13706 bmp.setPenColor(Color.BLACK) | |
13707 lastgypos = None | |
13708 for i in range(axispos, axispos + glinet): | |
13709 bmp.drawLine(leftpixellist[qq], i, rightpixellist[qq], i) | |
13710 bmp.setPenColor(maxgcColour) | |
13711 for i in range(0, widthpixellist[qq]): | |
13712 aa = int(i * (len(thearray[qq]) * 1.0 / widthpixellist[qq])) | |
13713 bb = int((i + 1) * (len(thearray[qq]) * 1.0 / widthpixellist[qq])) | |
13714 if aa == bb: | |
13715 bb += 1 | |
13716 temparr = thearray[qq][aa:bb] | |
13717 gyval = sum(temparr) * 1.0 / len(temparr) | |
13718 yvalpixratio = gyval / gmaxy | |
13719 if yvalpixratio > 1: | |
13720 yvalpixratio = 1 | |
13721 if yvalpixratio < -1: | |
13722 yvalpixratio = -1 | |
13723 if neg: | |
13724 if yvalpixratio < 0: | |
13725 gc1, gc2, gc3 = mingc | |
13726 bmp.setPenColor(mingcColour) | |
13727 yvalpix = round(yvalpixratio * (gheight / 2 - glinet / 2)) | |
13728 if gtype == "Line": | |
13729 if lastgypos != None: | |
13730 bmp.drawLine( | |
13731 leftpixellist[qq] + i - 1, | |
13732 lastgypos, | |
13733 leftpixellist[qq] + i, | |
13734 axispos + yvalpix, | |
13735 ) | |
13736 lastgypos = axispos + yvalpix | |
13737 elif gtype == "Histogram": | |
13738 bmp.drawLine( | |
13739 leftpixellist[qq] + i, | |
13740 axispos - 1, | |
13741 leftpixellist[qq] + i, | |
13742 axispos + yvalpix, | |
13743 ) | |
13744 else: | |
13745 gc1, gc2, gc3 = maxgc | |
13746 yvalpix = round( | |
13747 yvalpixratio * (gheight / 2 - (glinet - glinet / 2)) | |
13748 ) | |
13749 bmp.setPenColor(maxgcColour) | |
13750 if gtype == "Line": | |
13751 if lastgypos != None: | |
13752 bmp.drawLine( | |
13753 leftpixellist[qq] + i - 1, | |
13754 lastgypos, | |
13755 leftpixellist[qq] + i, | |
13756 axispos + glinet + yvalpix, | |
13757 ) | |
13758 lastgypos = axispos + glinet + yvalpix | |
13759 elif gtype == "Histogram" and round(yvalpix) != 0.0: | |
13760 bmp.drawLine( | |
13761 leftpixellist[qq] + i, | |
13762 axispos + glinet, | |
13763 leftpixellist[qq] + i, | |
13764 axispos + yvalpix, | |
13765 ) | |
13766 else: | |
13767 yvalpix = round(yvalpixratio * (gheight - glinet)) | |
13768 if gtype == "Line": | |
13769 if lastgypos != None: | |
13770 bmp.drawLine( | |
13771 leftpixellist[qq] + i - 1, | |
13772 lastgypos, | |
13773 i, | |
13774 leftpixellist[qq] + axispos + glinet + yvalpix, | |
13775 ) | |
13776 lastgypos = axispos + glinet + 1 + yvalpix | |
13777 elif gtype == "Histogram" and round(yvalpix) != 0.0: | |
13778 bmp.drawLine( | |
13779 leftpixellist[qq] + i, | |
13780 axispos + glinet, | |
13781 leftpixellist[qq] + i, | |
13782 axispos + glinet + yvalpix, | |
13783 ) | |
13784 axispos -= gheight + 2 * ggap + height1 + height2 | |
13785 modfig1 = (graphit[3] + 2 * ggap) * len(graphit[0]) | |
13786 else: | |
13787 modfig1 = 0 | |
13788 # draws the blast gradient legend | |
13789 if drawfig1 and minident != 101: | |
13790 bmp.setPenColor(Color.BLACK) | |
13791 bmp.writeString( | |
13792 str(int(round(minident))) + "%", width - 300, columnhei - 480, 64 | |
13793 ) | |
13794 bmp.writeString("100%", width - 300, columnhei - 84, 64) | |
13795 for i in range(columnhei - 480, columnhei - 20): | |
13796 ratio = round((i - (columnhei - 480) * 1.0) / 460, 2) | |
13797 r1 = int(minblastc[0] * (1 - ratio) + maxblastc[0] * ratio) | |
13798 r2 = int(minblastc[1] * (1 - ratio) + maxblastc[1] * ratio) | |
13799 r3 = int(minblastc[2] * (1 - ratio) + maxblastc[2] * ratio) | |
13800 theColor = Color(r1, r2, r3) | |
13801 bmp.setPenColor(theColor) | |
13802 bmp.drawLine(width - 400, i, width - 360, i) | |
13803 r1 = int(minblastci[0] * (1 - ratio) + maxblastci[0] * ratio) | |
13804 r2 = int(minblastci[1] * (1 - ratio) + maxblastci[1] * ratio) | |
13805 r3 = int(minblastci[2] * (1 - ratio) + maxblastci[2] * ratio) | |
13806 theColor = Color(r1, r2, r3) | |
13807 bmp.setPenColor(theColor) | |
13808 bmp.drawLine(width - 360, i, width - 320, i) | |
13809 # draws feature and blast figures | |
13810 for i in range(0, len(secondlist)): | |
13811 # draws the blast figure | |
13812 if i % 2 == 0: | |
13813 if aln == "best blast": | |
13814 shifter = blastmatch[int(i / 2)] | |
13815 genrev1 = reverseList[int(i / 2)] | |
13816 ymod = totalheight - (height1 * i / 2 + height2 * i / 2) - height1 | |
13817 if graphit != None and len(thearray) > 1: | |
13818 ymod += (gheight + 2 * ggap) * (len(thearray) - i / 2 - 1) | |
13819 if legend == "Top" or legend == "Top & Bottom": | |
13820 ymod -= sum(toplegpos[:3]) + 40 | |
13821 length = secondlist[i][0] | |
13822 bmp.setPenColor(Color.BLACK) | |
13823 jj = height1 / 2 + glt / 2 | |
13824 for j in range(glt): | |
13825 bmp.drawLine( | |
13826 convertPos(length, maxlength, width, 0, aln), | |
13827 (ymod + jj), | |
13828 convertPos(length, maxlength, width, length, aln), | |
13829 (ymod + jj), | |
13830 ) | |
13831 jj -= 1 | |
13832 bmp.setPenColor(Color.RED) | |
13833 for j in secondlist[i][1]: | |
13834 if abortCaptain: | |
13835 return None | |
13836 if (j.strand == "+" and not genrev1) or (j.strand == "-" and genrev1): | |
13837 theColor = Color(j.colour[0], j.colour[1], j.colour[2]) | |
13838 bmp.setPenColor(theColor) | |
13839 if type(j.start) == int: | |
13840 if genrev1: | |
13841 x2 = convertPosR(length, maxlength, width, j.start, aln) | |
13842 x1 = convertPosR(length, maxlength, width, j.stop, aln) | |
13843 else: | |
13844 x1 = convertPos(length, maxlength, width, j.start, aln) | |
13845 x2 = convertPos(length, maxlength, width, j.stop, aln) | |
13846 if featDict[j.type][0] == "rect": | |
13847 bmp.drawOutRect(x1, ymod, x2 - x1, height1, genet) | |
13848 elif featDict[j.type][0] == "arrow": | |
13849 bmp.drawRightArrow(x1, ymod, x2 - x1, height1, genet) | |
13850 elif featDict[j.type][0] == "frame": | |
13851 bmp.drawRightFrame( | |
13852 x1, ymod, x2 - x1, height1, genet, j.start % 3 | |
13853 ) | |
13854 elif featDict[j.type][0] == "pointer": | |
13855 bmp.drawPointer(x1, ymod, height1, genet) | |
13856 else: | |
13857 if genrev1: | |
13858 x2 = convertPosR(length, maxlength, width, j.start[-1], aln) | |
13859 x1 = convertPosR(length, maxlength, width, j.stop[-1], aln) | |
13860 else: | |
13861 x1 = convertPos(length, maxlength, width, j.start[-1], aln) | |
13862 x2 = convertPos(length, maxlength, width, j.stop[-1], aln) | |
13863 if featDict[j.type][0] == "rect": | |
13864 bmp.drawOutRect(x1, ymod, x2 - x1, height1, genet) | |
13865 elif featDict[j.type][0] == "arrow": | |
13866 bmp.drawRightArrow(x1, ymod, x2 - x1, height1, genet) | |
13867 elif featDict[j.type][0] == "frame": | |
13868 bmp.drawRightFrame( | |
13869 x1, ymod, x2 - x1, height1, genet, j.start[-1] % 3 | |
13870 ) | |
13871 elif featDict[j.type][0] == "pointer": | |
13872 bmp.drawPointer(x1, ymod, height1, genet) | |
13873 for k in range(2, len(j.start) + 1): | |
13874 if genrev1: | |
13875 x4 = convertPosR( | |
13876 length, maxlength, width, j.start[-k], aln | |
13877 ) | |
13878 x3 = convertPosR( | |
13879 length, maxlength, width, j.stop[-k], aln | |
13880 ) | |
13881 else: | |
13882 x3 = convertPos( | |
13883 length, maxlength, width, j.start[-k], aln | |
13884 ) | |
13885 x4 = convertPos( | |
13886 length, maxlength, width, j.stop[-k], aln | |
13887 ) | |
13888 if ( | |
13889 featDict[j.type][0] == "arrow" | |
13890 or featDict[j.type][0] == "rect" | |
13891 ): | |
13892 if x1 - x4 > 2: | |
13893 bmp.setPenColor(Color.BLACK) | |
13894 bmp.drawDash( | |
13895 x4, | |
13896 ymod + 3 * height1 / 4, | |
13897 x4, | |
13898 ymod + height1, | |
13899 exont, | |
13900 ) | |
13901 bmp.drawDash( | |
13902 x4, ymod + height1, x1, ymod + height1, exont | |
13903 ) | |
13904 bmp.drawDash( | |
13905 x1, | |
13906 ymod + height1, | |
13907 x1, | |
13908 ymod + 3 * height1 / 4, | |
13909 exont, | |
13910 ) | |
13911 bmp.setPenColor(theColor) | |
13912 bmp.drawOutRect( | |
13913 x3, ymod + height1 / 4, x4 - x3, height1 / 2, genet | |
13914 ) | |
13915 elif featDict[j.type][0] == "frame": | |
13916 if x1 - x4 > 2: | |
13917 bmp.setPenColor(Color.BLACK) | |
13918 bmp.drawDash( | |
13919 x4, | |
13920 ymod + 3 * height1 / 4, | |
13921 x4, | |
13922 ymod + height1, | |
13923 exont, | |
13924 ) | |
13925 bmp.drawDash( | |
13926 x4, ymod + height1, x1, ymod + height1, exont | |
13927 ) | |
13928 bmp.drawDash( | |
13929 x1, | |
13930 ymod + height1, | |
13931 x1, | |
13932 ymod + 3 * height1 / 4, | |
13933 exont, | |
13934 ) | |
13935 bmp.setPenColor(theColor) | |
13936 bmp.drawRightFrameRect( | |
13937 x3, ymod, x4 - x3, height1, genet, j.start[-k] % 3 | |
13938 ) | |
13939 x1, x2 = x3, x4 | |
13940 else: | |
13941 theColor = Color(j.colour[0], j.colour[1], j.colour[2]) | |
13942 bmp.setPenColor(theColor) | |
13943 if type(j.start) == int: | |
13944 if genrev1: | |
13945 x2 = convertPosR(length, maxlength, width, j.start, aln) | |
13946 x1 = convertPosR(length, maxlength, width, j.stop, aln) | |
13947 else: | |
13948 x1 = convertPos(length, maxlength, width, j.start, aln) | |
13949 x2 = convertPos(length, maxlength, width, j.stop, aln) | |
13950 if featDict[j.type][0] == "rect": | |
13951 bmp.drawOutRect(x1, ymod, x2 - x1, height1, genet) | |
13952 elif featDict[j.type][0] == "arrow": | |
13953 bmp.drawLeftArrow(x1, ymod, x2 - x1, height1, genet) | |
13954 elif featDict[j.type][0] == "frame": | |
13955 bmp.drawLeftFrame( | |
13956 x1, ymod, x2 - x1, height1, genet, j.stop % 3 | |
13957 ) | |
13958 elif featDict[j.type][0] == "pointer": | |
13959 bmp.drawPointer(x2, ymod, height1, genet) | |
13960 else: | |
13961 if genrev1: | |
13962 x2 = convertPosR(length, maxlength, width, j.start[0], aln) | |
13963 x1 = convertPosR(length, maxlength, width, j.stop[0], aln) | |
13964 else: | |
13965 x1 = convertPos(length, maxlength, width, j.start[0], aln) | |
13966 x2 = convertPos(length, maxlength, width, j.stop[0], aln) | |
13967 if featDict[j.type][0] == "rect": | |
13968 bmp.drawOutRect(x1, ymod, x2 - x1, height1, genet) | |
13969 elif featDict[j.type][0] == "arrow": | |
13970 bmp.drawLeftArrow(x1, ymod, x2 - x1, height1, genet) | |
13971 elif featDict[j.type][0] == "frame": | |
13972 bmp.drawLeftFrame( | |
13973 x1, ymod, x2 - x1, height1, genet, j.stop[0] % 3 | |
13974 ) | |
13975 elif featDict[j.type][0] == "pointer": | |
13976 bmp.drawPointer(x2, ymod, height1, genet) | |
13977 for k in range(1, len(j.start)): | |
13978 if genrev1: | |
13979 x4 = convertPosR( | |
13980 length, maxlength, width, j.start[k], aln | |
13981 ) | |
13982 x3 = convertPosR( | |
13983 length, maxlength, width, j.stop[k], aln | |
13984 ) | |
13985 else: | |
13986 x3 = convertPos( | |
13987 length, maxlength, width, j.start[k], aln | |
13988 ) | |
13989 x4 = convertPos( | |
13990 length, maxlength, width, j.stop[k], aln | |
13991 ) | |
13992 if ( | |
13993 featDict[j.type][0] == "rect" | |
13994 or featDict[j.type][0] == "arrow" | |
13995 ): | |
13996 if x3 - x2 > 2: | |
13997 bmp.setPenColor(Color.BLACK) | |
13998 bmp.drawDash( | |
13999 x2, | |
14000 ymod + 3 * height1 / 4, | |
14001 x2, | |
14002 ymod + height1, | |
14003 exont, | |
14004 ) | |
14005 bmp.drawDash( | |
14006 x2, ymod + height1, x3, ymod + height1, exont | |
14007 ) | |
14008 bmp.drawDash( | |
14009 x3, | |
14010 ymod + height1, | |
14011 x3, | |
14012 ymod + 3 * height1 / 4, | |
14013 exont, | |
14014 ) | |
14015 bmp.setPenColor(theColor) | |
14016 bmp.drawOutRect( | |
14017 x3, ymod + height1 / 4, x4 - x3, height1 / 2, genet | |
14018 ) | |
14019 elif featDict[j.type][0] == "frame": | |
14020 if x3 - x2 > 2: | |
14021 bmp.setPenColor(Color.BLACK) | |
14022 bmp.drawDash( | |
14023 x2, ymod + height1 / 4, x2, ymod, exont | |
14024 ) | |
14025 bmp.drawDash(x2, ymod, x3, ymod, exont) | |
14026 bmp.drawDash( | |
14027 x3, ymod, x3, ymod + height1 / 4, exont | |
14028 ) | |
14029 bmp.setPenColor(theColor) | |
14030 bmp.drawLeftFrameRect( | |
14031 x3, ymod, x4 - x3, height1, genet, j.stop[k] % 3 | |
14032 ) | |
14033 x1, x2 = x3, x4 | |
14034 else: | |
14035 # draws teh blast hits | |
14036 genrev2 = reverseList[int((i + 1) / 2)] | |
14037 length1 = secondlist[i - 1][0] | |
14038 length2 = secondlist[i + 1][0] | |
14039 ymod = ( | |
14040 totalheight | |
14041 - (height1 * (i - 1) / 2 + height2 * (i - 1) / 2) | |
14042 - height1 | |
14043 - 1 | |
14044 ) | |
14045 if graphit != None and len(thearray) > 1: | |
14046 ymod += (gheight + 2 * ggap) * (len(thearray) - i / 2 - 1) | |
14047 if legend == "Top" or legend == "Top & Bottom": | |
14048 ymod -= sum(toplegpos[:3]) + 40 | |
14049 y1 = ymod | |
14050 y2 = y1 - height2 + 1 | |
14051 for j in secondlist[i]: | |
14052 if abortCaptain: | |
14053 return None | |
14054 qStart, qEnd, rStart, rEnd, ident = j | |
14055 # is the blast hit inverted | |
14056 if ( | |
14057 (rStart < rEnd and not genrev1 and not genrev2) | |
14058 or (rStart > rEnd and not genrev1 and genrev2) | |
14059 or (rStart < rEnd and genrev1 and genrev2) | |
14060 or (rStart > rEnd and genrev1 and not genrev2) | |
14061 ): | |
14062 crisscross = False | |
14063 else: | |
14064 crisscross = True | |
14065 try: | |
14066 ratio = round((ident - minident) / (100 - minident), 2) | |
14067 except: | |
14068 ratio = 1 | |
14069 if crisscross: | |
14070 r1 = int(minblastci[0] * (1 - ratio) + maxblastci[0] * ratio) | |
14071 r2 = int(minblastci[1] * (1 - ratio) + maxblastci[1] * ratio) | |
14072 r3 = int(minblastci[2] * (1 - ratio) + maxblastci[2] * ratio) | |
14073 else: | |
14074 r1 = int(minblastc[0] * (1 - ratio) + maxblastc[0] * ratio) | |
14075 r2 = int(minblastc[1] * (1 - ratio) + maxblastc[1] * ratio) | |
14076 r3 = int(minblastc[2] * (1 - ratio) + maxblastc[2] * ratio) | |
14077 theColor = Color(r1, r2, r3) | |
14078 bmp.setPenColor(theColor) | |
14079 if aln == "best blast": | |
14080 shifter = blastmatch[int(i / 2)] | |
14081 if genrev1: | |
14082 x1e = convertPosR(length1, maxlength, width, qStart, aln) | |
14083 x1s = convertPosR(length1, maxlength, width, qEnd, aln) | |
14084 else: | |
14085 x1s = convertPos(length1, maxlength, width, qStart, aln) | |
14086 x1e = convertPos(length1, maxlength, width, qEnd, aln) | |
14087 if aln == "best blast": | |
14088 shifter = blastmatch[int((i + 1) / 2)] | |
14089 if genrev2 and rStart < rEnd: | |
14090 x2e = convertPosR(length2, maxlength, width, rStart, aln) | |
14091 x2s = convertPosR(length2, maxlength, width, rEnd, aln) | |
14092 elif genrev2 and rStart >= rEnd: | |
14093 x2s = convertPosR(length2, maxlength, width, rStart, aln) | |
14094 x2e = convertPosR(length2, maxlength, width, rEnd, aln) | |
14095 elif not genrev2 and rStart < rEnd: | |
14096 x2s = convertPos(length2, maxlength, width, rStart, aln) | |
14097 x2e = convertPos(length2, maxlength, width, rEnd, aln) | |
14098 else: | |
14099 x2e = convertPos(length2, maxlength, width, rStart, aln) | |
14100 x2s = convertPos(length2, maxlength, width, rEnd, aln) | |
14101 if crisscross: | |
14102 if x1e - x1s >= x2e - x2s: | |
14103 for k in range(x1s, x1e): | |
14104 try: | |
14105 x2 = x2e - (k - x1s) * 1.0 / (x1e - x1s) * (x2e - x2s) | |
14106 bmp.drawLine(k, y1, x2, y2) | |
14107 except: | |
14108 pass | |
14109 else: | |
14110 for k in range(x2s, x2e): | |
14111 x1 = x1e - (k - x2s) * 1.0 / (x2e - x2s) * (x1e - x1s) | |
14112 bmp.drawLine(x1, y1, k, y2) | |
14113 if blastoutline: | |
14114 bmp.setPenColor(Color.BLACK) | |
14115 bmp.drawLine(x1s, y1, x2e, y2) | |
14116 bmp.drawLine(x1e, y1, x2s, y2) | |
14117 else: | |
14118 if x1e - x1s >= x2e - x2s: | |
14119 for k in range(x1s, x1e): | |
14120 try: | |
14121 x2 = (k - x1s) * 1.0 / (x1e - x1s) * (x2e - x2s) + x2s | |
14122 bmp.drawLine(k, y1, x2, y2) | |
14123 bmp.drawLine(k + 1, y1, x2, y2) | |
14124 except: | |
14125 pass | |
14126 else: | |
14127 for k in range(x2s, x2e): | |
14128 x1 = (k - x2s) * 1.0 / (x2e - x2s) * (x1e - x1s) + x1s | |
14129 bmp.drawLine(x1, y1, k, y2) | |
14130 bmp.drawLine(x1, y1, k + 1, y2) | |
14131 if blastoutline: | |
14132 bmp.setPenColor(Color.BLACK) | |
14133 bmp.drawLine(x1s, y1, x2s, y2) | |
14134 bmp.drawLine(x1e, y1, x2e, y2) | |
14135 if writebmp == 0: | |
14136 bmp.saveFile(filename, compress) | |
14137 return minident | |
14138 elif writebmp == 1: | |
14139 return bmp.createGIFString(True), minident, bmp.wd, bmp.ht | |
14140 elif writebmp == 2: | |
14141 return bmp.createGIFString(False), minident, bmp.wd, bmp.ht | |
14142 | |
14143 | |
14144 def drawsvg( | |
14145 filename, | |
14146 minlength, | |
14147 mineval, | |
14148 minIdent, | |
14149 inputlist, | |
14150 width, | |
14151 height1, | |
14152 height2, | |
14153 minblastc, | |
14154 maxblastc, | |
14155 minblastci, | |
14156 maxblastci, | |
14157 drawfig1, | |
14158 drawfig2, | |
14159 drawfig3, | |
14160 compress, | |
14161 reverseList, | |
14162 featDict, | |
14163 glt, | |
14164 exont, | |
14165 genet, | |
14166 featlengths, | |
14167 aln, | |
14168 graphit, | |
14169 blastoutline, | |
14170 minmaxlist, | |
14171 autodetect, | |
14172 legend, | |
14173 legname, | |
14174 ): | |
14175 # global variable for stopping script midway | |
14176 global abortCaptain | |
14177 secondlist = [] | |
14178 maxlength = 0 | |
14179 totalheight = 0 | |
14180 # returning a minident value of 101 means the script has been aborted | |
14181 minident = 101 | |
14182 # gets feature file and blast information | |
14183 for i in range(0, len(inputlist)): | |
14184 if i % 2 == 0: | |
14185 temp = getArrows(inputlist[i], legname) | |
14186 thirdlist = [] | |
14187 if minmaxlist[int(i / 2)][1] == "Max": | |
14188 if temp[0] == None: | |
14189 maxcut = featlengths[int(i / 2)] | |
14190 else: | |
14191 maxcut = temp[0] | |
14192 if minmaxlist[int(i / 2)][0] == 1: | |
14193 minmaxopt = 0 | |
14194 else: | |
14195 minmaxopt = 1 | |
14196 mincut = minmaxlist[int(i / 2)][0] | |
14197 else: | |
14198 mincut = minmaxlist[int(i / 2)][0] | |
14199 maxcut = minmaxlist[int(i / 2)][1] | |
14200 if minmaxlist[int(i / 2)][0] < minmaxlist[int(i / 2)][1]: | |
14201 minmaxopt = 1 | |
14202 else: | |
14203 minmaxopt = 2 | |
14204 for j in temp[1]: | |
14205 if j.type in featDict: | |
14206 if j.colour == None: | |
14207 j.colour = featDict[j.type][1] | |
14208 if minmaxopt == 0: | |
14209 thirdlist.append(j) | |
14210 elif minmaxopt == 1: | |
14211 if type(j.start) == int: | |
14212 if j.start >= mincut and j.stop <= maxcut: | |
14213 aninstance = feature( | |
14214 j.start - mincut + 1, | |
14215 j.stop - mincut + 1, | |
14216 j.type, | |
14217 j.strand, | |
14218 j.colour, | |
14219 j.name, | |
14220 ) | |
14221 thirdlist.append(aninstance) | |
14222 else: | |
14223 if j.start[0] >= mincut and j.stop[-1] <= maxcut: | |
14224 tempstart = [] | |
14225 for k in j.start: | |
14226 tempstart.append(k - mincut + 1) | |
14227 tempstop = [] | |
14228 for k in j.stop: | |
14229 tempstop.append(k - mincut + 1) | |
14230 aninstance = feature( | |
14231 tempstart, | |
14232 tempstop, | |
14233 j.type, | |
14234 j.strand, | |
14235 j.colour, | |
14236 j.name, | |
14237 ) | |
14238 thirdlist.append(aninstance) | |
14239 elif minmaxopt == 2: | |
14240 if temp[0] == None: | |
14241 templength = featlength[int(i / 2)] | |
14242 else: | |
14243 templength = temp[0] | |
14244 if type(j.start) == int: | |
14245 if j.stop <= maxcut: | |
14246 tempstart = j.start + templength - mincut + 1 | |
14247 tempstop = j.stop + templength - mincut + 1 | |
14248 aninstance = feature( | |
14249 tempstart, | |
14250 tempstop, | |
14251 j.type, | |
14252 j.strand, | |
14253 j.colour, | |
14254 j.name, | |
14255 ) | |
14256 thirdlist.append(aninstance) | |
14257 elif j.start >= mincut: | |
14258 tempstart = j.start - mincut + 1 | |
14259 tempstop = j.stop - mincut + 1 | |
14260 aninstance = feature( | |
14261 tempstart, | |
14262 tempstop, | |
14263 j.type, | |
14264 j.strand, | |
14265 j.colour, | |
14266 j.name, | |
14267 ) | |
14268 thirdlist.append(aninstance) | |
14269 else: | |
14270 if j.stop[-1] <= maxcut: | |
14271 tempstart = [] | |
14272 for k in j.start: | |
14273 tempstart.append(k + templength - mincut + 1) | |
14274 tempstop = [] | |
14275 for k in j.stop: | |
14276 tempstop.append(k + templength - mincut + 1) | |
14277 aninstance = feature( | |
14278 tempstart, | |
14279 tempstop, | |
14280 j.type, | |
14281 j.strand, | |
14282 j.colour, | |
14283 j.name, | |
14284 ) | |
14285 thirdlist.append(aninstance) | |
14286 elif j.start[0] >= mincut: | |
14287 tempstart = [] | |
14288 for k in j.start: | |
14289 tempstart.append(k - mincut + 1) | |
14290 tempstop = [] | |
14291 for k in j.stop: | |
14292 tempstop.append(k - mincut + 1) | |
14293 aninstance = feature( | |
14294 tempstart, | |
14295 tempstop, | |
14296 j.type, | |
14297 j.strand, | |
14298 j.colour, | |
14299 j.name, | |
14300 ) | |
14301 thirdlist.append(aninstance) | |
14302 thirdlist.sort(key=lambda i: i.length(), reverse=True) | |
14303 if minmaxopt == 0: | |
14304 if temp[0] == None: | |
14305 secondlist.append((featlengths[int(i / 2)], thirdlist)) | |
14306 if featlengths[int(i / 2)] > maxlength: | |
14307 maxlength = featlengths[int(i / 2)] | |
14308 else: | |
14309 secondlist.append((temp[0], thirdlist)) | |
14310 if temp[0] >= maxlength: | |
14311 maxlength = temp[0] | |
14312 elif minmaxopt == 1: | |
14313 if maxcut == "Max": | |
14314 maxcut = temp[0] | |
14315 secondlist.append((maxcut - mincut + 1, thirdlist)) | |
14316 if maxcut - mincut + 1 > maxlength: | |
14317 maxlength = maxcut - mincut + 1 | |
14318 elif minmaxopt == 2: | |
14319 if temp[0] == None: | |
14320 templength = featlengths[int(i / 2)] | |
14321 else: | |
14322 templength = temp[0] | |
14323 secondlist.append((templength - mincut + maxcut + 1, thirdlist)) | |
14324 if templength - mincut + maxcut + 1 > maxlength: | |
14325 maxlength = templength - mincut + maxlength + 1 | |
14326 totalheight += height1 | |
14327 else: | |
14328 totalheight += height2 | |
14329 temp = getBlast(inputlist[i], minlength, mineval, minIdent) | |
14330 for j in temp: | |
14331 if j[4] < minident: | |
14332 minident = j[4] | |
14333 secondlist.append(temp) | |
14334 # calculates offsets for genomes if best blast alignment is selected | |
14335 if autodetect and maxlength > 100000: | |
14336 tempsecond = [] | |
14337 minident = 101 | |
14338 for i in range(len(secondlist)): | |
14339 temp = [] | |
14340 if i % 2 == 0: | |
14341 for j in secondlist[i][1]: | |
14342 if type(j.start) == int: | |
14343 if (j.stop - j.start) * 1.0 / maxlength * width > 4: | |
14344 temp.append(j) | |
14345 else: | |
14346 if (j.stop[0] - j.start[0]) * 1.0 / maxlength * width > 4: | |
14347 temp.append(j) | |
14348 tempsecond.append((secondlist[i][0], temp)) | |
14349 else: | |
14350 for j in secondlist[i]: | |
14351 if (j[1] - j[0]) * 1.0 / maxlength * width > 3: | |
14352 temp.append(j) | |
14353 if j[4] < minident: | |
14354 minident = j[4] | |
14355 tempsecond.append(temp) | |
14356 secondlist = tempsecond | |
14357 if minIdent != 0: | |
14358 minident = minIdent | |
14359 if aln == "best blast": | |
14360 blastmatch = [0] | |
14361 for i in range(1, len(secondlist), 2): | |
14362 maxbitscore = 0 | |
14363 for j in secondlist[i]: | |
14364 if j[1] - j[0] > maxbitscore: | |
14365 qstart, qend, rstart, rend = j[0], j[1], j[2], j[3] | |
14366 maxbitscore = j[1] - j[0] | |
14367 if len(secondlist[i]) == 0: | |
14368 theQstart = 0 | |
14369 elif reverseList[int(i / 2)]: | |
14370 theQstart = secondlist[i - 1][0] - qend | |
14371 else: | |
14372 theQstart = qstart | |
14373 if reverseList[int((i + 1) / 2)]: | |
14374 if len(secondlist[i]) == 0: | |
14375 theRstart = 0 | |
14376 elif rstart < rend: | |
14377 theRstart = secondlist[i + 1][0] - rend | |
14378 else: | |
14379 theRstart = secondlist[i + 1][0] - rstart | |
14380 else: | |
14381 if len(secondlist[i]) == 0: | |
14382 theRstart = 0 | |
14383 elif rstart < rend: | |
14384 theRstart = rstart | |
14385 else: | |
14386 theRstart = rend | |
14387 blastmatch.append(blastmatch[-1] + theQstart - theRstart) | |
14388 theminblast = min(blastmatch) | |
14389 templist = [] | |
14390 for i in blastmatch: | |
14391 templist.append(i - theminblast) | |
14392 blastmatch = templist | |
14393 for i in range(0, len(secondlist) + 1, 2): | |
14394 if secondlist[i][0] + blastmatch[int(i / 2)] > maxlength: | |
14395 maxlength = secondlist[i][0] + blastmatch[int(i / 2)] | |
14396 fighei = 0 | |
14397 if legend == "Single column" or legend == "Two columns": | |
14398 legendArrows = set() | |
14399 legendList = [] | |
14400 for i in range(len(secondlist)): | |
14401 if i % 2 == 0: | |
14402 legendList.append([]) | |
14403 for j in secondlist[i][1]: | |
14404 if ( | |
14405 j.name != None | |
14406 and (j.name, j.colour, featDict[j.type][0]) not in legendArrows | |
14407 ): | |
14408 legendArrows.add((j.name, j.colour, featDict[j.type][0])) | |
14409 if type(j.start) == int: | |
14410 tempjstart = j.start | |
14411 else: | |
14412 tempjstart = j.start[0] | |
14413 legendList[int(i / 2)].append( | |
14414 (j.name, j.colour, featDict[j.type][0], tempjstart) | |
14415 ) | |
14416 if legend == "Single column": | |
14417 fighei = min([5000, len(legendArrows) * 90]) | |
14418 elif legend == "Two columns": | |
14419 fighei = min([5000, (len(legendArrows) + 1) / 2 * 90]) | |
14420 global shifter | |
14421 if legend == "Top" or legend == "Top & Bottom": | |
14422 toplegpos = [0, 0, 0, set(), set(), set()] | |
14423 legendTop = [] | |
14424 testbmp = BitMap(10, 10) | |
14425 if aln == "best blast": | |
14426 shifter = blastmatch[0] | |
14427 genrev1 = reverseList[0] | |
14428 for j in secondlist[0][1]: | |
14429 if j.name != None: | |
14430 if type(j.start) == int: | |
14431 firstleg = True | |
14432 secondleg = True | |
14433 thirdleg = True | |
14434 if genrev1: | |
14435 legpos = convertPosR( | |
14436 secondlist[0][0], | |
14437 maxlength, | |
14438 width, | |
14439 (j.start + j.stop) / 2, | |
14440 aln, | |
14441 ) | |
14442 else: | |
14443 legpos = convertPos( | |
14444 secondlist[0][0], | |
14445 maxlength, | |
14446 width, | |
14447 (j.start + j.stop) / 2, | |
14448 aln, | |
14449 ) | |
14450 for q in range(legpos - 40, legpos + 50): | |
14451 if q in toplegpos[3]: | |
14452 firstleg = False | |
14453 if q in toplegpos[4]: | |
14454 secondleg = False | |
14455 if q in toplegpos[5]: | |
14456 thirdleg = False | |
14457 if firstleg: | |
14458 therung = 1 | |
14459 if testbmp.lengthString(j.name[:10], 64) > toplegpos[0]: | |
14460 toplegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
14461 for q in range(legpos - 40, legpos + 50): | |
14462 toplegpos[3].add(q) | |
14463 # elif secondleg: | |
14464 # therung = 2 | |
14465 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[1]: | |
14466 # toplegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
14467 # for q in range(legpos - 40, legpos + 50): | |
14468 # toplegpos[4].add(q) | |
14469 # elif thirdleg: | |
14470 # therung = 3 | |
14471 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[2]: | |
14472 # toplegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
14473 # for q in range(legpos - 40, legpos + 50): | |
14474 # toplegpos[5].add(q) | |
14475 else: | |
14476 therung = None | |
14477 legendTop.append((j.name[:10], legpos, therung)) | |
14478 else: | |
14479 firstleg = True | |
14480 secondleg = True | |
14481 thirdleg = True | |
14482 if genrev1: | |
14483 legpos = convertPosR( | |
14484 secondlist[0][0], | |
14485 maxlength, | |
14486 width, | |
14487 (j.start[0] + j.stop[0]) / 2, | |
14488 aln, | |
14489 ) | |
14490 else: | |
14491 legpos = convertPos( | |
14492 secondlist[0][0], | |
14493 maxlength, | |
14494 width, | |
14495 (j.start[0] + j.stop[0]) / 2, | |
14496 aln, | |
14497 ) | |
14498 for q in range(legpos - 40, legpos + 50): | |
14499 if q in toplegpos[3]: | |
14500 firstleg = False | |
14501 if q in toplegpos[4]: | |
14502 secondleg = False | |
14503 if q in toplegpos[5]: | |
14504 thirdleg = False | |
14505 if firstleg: | |
14506 therung = 1 | |
14507 if testbmp.lengthString(j.name[:10], 64) > toplegpos[0]: | |
14508 toplegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
14509 for q in range(legpos - 40, legpos + 50): | |
14510 toplegpos[3].add(q) | |
14511 # elif secondleg: | |
14512 # therung = 2 | |
14513 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[1]: | |
14514 # toplegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
14515 # for q in range(legpos - 40, legpos + 50): | |
14516 # toplegpos[4].add(q) | |
14517 # elif thirdleg: | |
14518 # therung = 3 | |
14519 # if testbmp.lengthString(j.name[:10], 64) > toplegpos[2]: | |
14520 # toplegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
14521 # for q in range(legpos - 40, legpos + 50): | |
14522 # toplegpos[5].add(q) | |
14523 else: | |
14524 therung = None | |
14525 legendTop.append((j.name[:10], legpos, therung)) | |
14526 totalheight += sum(toplegpos[:3]) + 40 | |
14527 if legend == "Bottom" or legend == "Top & Bottom": | |
14528 botlegpos = [0, 0, 0, set(), set(), set()] | |
14529 legendBot = [] | |
14530 testbmp = BitMap(10, 10) | |
14531 if aln == "best blast": | |
14532 shifter = blastmatch[-1] | |
14533 genrev1 = reverseList[-1] | |
14534 if aln == "best blast": | |
14535 shifter = blastmatch[-1] | |
14536 genrev1 = reverseList[-1] | |
14537 for j in secondlist[-1][1]: | |
14538 if j.name != None: | |
14539 if type(j.start) == int: | |
14540 firstleg = True | |
14541 secondleg = True | |
14542 thirdleg = True | |
14543 if genrev1: | |
14544 legpos = convertPosR( | |
14545 secondlist[-1][0], | |
14546 maxlength, | |
14547 width, | |
14548 (j.start + j.stop) / 2, | |
14549 aln, | |
14550 ) | |
14551 else: | |
14552 legpos = convertPos( | |
14553 secondlist[-1][0], | |
14554 maxlength, | |
14555 width, | |
14556 (j.start + j.stop) / 2, | |
14557 aln, | |
14558 ) | |
14559 for q in range(legpos - 40, legpos + 50): | |
14560 if q in botlegpos[3]: | |
14561 firstleg = False | |
14562 if q in botlegpos[4]: | |
14563 secondleg = False | |
14564 if q in botlegpos[5]: | |
14565 thirdleg = False | |
14566 if firstleg: | |
14567 therung = 1 | |
14568 if testbmp.lengthString(j.name[:10], 64) > botlegpos[0]: | |
14569 botlegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
14570 for q in range(legpos - 40, legpos + 50): | |
14571 botlegpos[3].add(q) | |
14572 # elif secondleg: | |
14573 # therung = 2 | |
14574 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[1]: | |
14575 # botlegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
14576 # for q in range(legpos - 40, legpos + 50): | |
14577 # botlegpos[4].add(q) | |
14578 # elif thirdleg: | |
14579 # therung = 3 | |
14580 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[2]: | |
14581 # botlegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
14582 # for q in range(legpos - 40, legpos + 50): | |
14583 # botlegpos[5].add(q) | |
14584 else: | |
14585 therung = None | |
14586 legendBot.append((j.name[:10], legpos, therung)) | |
14587 else: | |
14588 firstleg = True | |
14589 secondleg = True | |
14590 thirdleg = True | |
14591 if genrev1: | |
14592 legpos = convertPosR( | |
14593 secondlist[-1][0], | |
14594 maxlength, | |
14595 width, | |
14596 (j.start[0] + j.stop[0]) / 2, | |
14597 aln, | |
14598 ) | |
14599 else: | |
14600 legpos = convertPos( | |
14601 secondlist[-1][0], | |
14602 maxlength, | |
14603 width, | |
14604 (j.start[0] + j.stop[0]) / 2, | |
14605 aln, | |
14606 ) | |
14607 for q in range( | |
14608 (j.start[0] + j.stop[0]) / 2 - 40, | |
14609 (j.start[0] + j.stop[0]) / 2 + 50, | |
14610 ): | |
14611 if q in botlegpos[3]: | |
14612 firstleg = False | |
14613 if q in botlegpos[4]: | |
14614 secondleg = False | |
14615 if q in botlegpos[5]: | |
14616 thirdleg = False | |
14617 if firstleg: | |
14618 therung = 1 | |
14619 if testbmp.lengthString(j.name[:10], 64) > botlegpos[0]: | |
14620 botlegpos[0] = testbmp.lengthString(j.name[:10], 64) | |
14621 for q in range( | |
14622 (j.start[0] + j.stop[0]) / 2 - 40, | |
14623 (j.start[0] + j.stop[0]) / 2 + 50, | |
14624 ): | |
14625 botlegpos[3].add(q) | |
14626 # elif secondleg: | |
14627 # therung = 2 | |
14628 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[1]: | |
14629 # botlegpos[1] = testbmp.lengthString(j.name[:10], 64) | |
14630 # for q in range((j.start[0] + j.stop[0])/2 - 40, (j.start[0] + j.stop[0])/2 + 50): | |
14631 # botlegpos[4].add(q) | |
14632 # elif thirdleg: | |
14633 # therung = 3 | |
14634 # if testbmp.lengthString(j.name[:10], 64) > botlegpos[2]: | |
14635 # botlegpos[2] = testbmp.lengthString(j.name[:10], 64) | |
14636 # for q in range((j.start[0] + j.stop[0])/2 - 40, (j.start[0] + j.stop[0])/2 + 50): | |
14637 # botlegpos[5].add(q) | |
14638 else: | |
14639 therung = None | |
14640 legendBot.append( | |
14641 (j.name[:10], (j.start[0] + j.stop[0]) / 2, therung) | |
14642 ) | |
14643 totalheight += sum(botlegpos[:3]) + 40 | |
14644 # creates extra width for blast identity legend | |
14645 drawfig1hei = 0 | |
14646 if drawfig1 and minident != 101: | |
14647 drawfig1hei = 500 | |
14648 extraheight = 0 | |
14649 # creates extra height for scale legend | |
14650 drawfig2hei = 0 | |
14651 if drawfig2: | |
14652 drawfig2hei = height1 | |
14653 columnhei = max([fighei, drawfig1hei, drawfig2hei]) | |
14654 totalheight += columnhei | |
14655 hei = totalheight | |
14656 # creates extra height for graph | |
14657 if graphit != None: | |
14658 hei += graphit[3] * len(graphit[0]) + 2 * graphit[7] * len(graphit[0]) | |
14659 extraheight = (graphit[3] + 20) * len(graphit[0]) | |
14660 svg = scalableVectorGraphics(hei + 1, width) | |
14661 if legend == "Single column": | |
14662 index = 0 | |
14663 legendArrows = [] | |
14664 for i in range(len(legendList)): | |
14665 x = legendList[i] | |
14666 x.sort(key=operator.itemgetter(3)) | |
14667 if reverseList[i]: | |
14668 x.reverse() | |
14669 legendArrows += x | |
14670 for i in range(hei - columnhei + 74, hei, 90): | |
14671 if index < len(legendArrows) and legendArrows[index][2] == "rect": | |
14672 svg.drawOutRect(5, i - 64, 96, 64, legendArrows[index][1], genet) | |
14673 svg.writeString(legendArrows[index][0], 106, i, 64) | |
14674 elif index < len(legendArrows) and legendArrows[index][2] == "arrow": | |
14675 svg.drawRightArrow( | |
14676 5, i - 64, 96, 64, legendArrows[index][1], (0, 0, 0), genet | |
14677 ) | |
14678 svg.writeString(legendArrows[index][0], 106, i, 64) | |
14679 elif index < len(legendArrows) and legendArrows[index][2] == "frame": | |
14680 svg.drawRightFrame(5, i - 16, 96, 128, genet, 1, legendArrows[index][1]) | |
14681 svg.writeString(legendArrows[index][0], 106, i, 64) | |
14682 elif index < len(legendArrows) and legendArrows[index][2] == "pointer": | |
14683 svg.drawPointer(34, i - 64, 64, genet, legendArrows[index][1]) | |
14684 svg.writeString(legendArrows[index][0], 106, i, 64) | |
14685 index += 1 | |
14686 elif legend == "Two columns": | |
14687 index = 0 | |
14688 legendArrows = [] | |
14689 for i in range(len(legendList)): | |
14690 x = legendList[i] | |
14691 x.sort(key=operator.itemgetter(3)) | |
14692 if reverseList[i]: | |
14693 x.reverse() | |
14694 legendArrows += x | |
14695 for i in range(hei - columnhei + 74, hei, 90): | |
14696 if index < len(legendArrows) and legendArrows[index][2] == "rect": | |
14697 svg.drawOutRect(5, i - 64, 96, 64, legendArrows[index][1], genet) | |
14698 svg.writeString(legendArrows[index][0][:45], 106, i, 64) | |
14699 elif index < len(legendArrows) and legendArrows[index][2] == "arrow": | |
14700 svg.writeString(legendArrows[index][0][:45], 106, i, 64) | |
14701 svg.drawRightArrow( | |
14702 5, i - 64, 96, 64, legendArrows[index][1], (0, 0, 0), genet | |
14703 ) | |
14704 elif index < len(legendArrows) and legendArrows[index][2] == "frame": | |
14705 svg.drawRightFrame(5, i - 16, 96, 128, genet, 1, legendArrows[index][1]) | |
14706 svg.writeString(legendArrows[index][0][:45], 106, i, 64) | |
14707 elif index < len(legendArrows) and legendArrows[index][2] == "pointer": | |
14708 svg.drawPointer(34, i - 64, 64, genet, legendArrows[index][1]) | |
14709 svg.writeString(legendArrows[index][0][:45], 76, i, 64) | |
14710 index += 1 | |
14711 for i in range(hei - columnhei + 74, hei, 90): | |
14712 if index < len(legendArrows) and legendArrows[index][2] == "rect": | |
14713 svg.drawOutRect( | |
14714 5 + width / 3, i - 64, 96, 64, legendArrows[index][1], genet | |
14715 ) | |
14716 svg.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
14717 elif index < len(legendArrows) and legendArrows[index][2] == "arrow": | |
14718 svg.drawRightArrow( | |
14719 5 + width / 3, | |
14720 i - 64, | |
14721 96, | |
14722 64, | |
14723 legendArrows[index][1], | |
14724 (0, 0, 0), | |
14725 genet, | |
14726 ) | |
14727 svg.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
14728 elif index < len(legendArrows) and legendArrows[index][2] == "frame": | |
14729 svg.drawRightFrame( | |
14730 5 + width / 3, i - 16, 96, 128, genet, 1, legendArrows[index][1] | |
14731 ) | |
14732 svg.writeString(legendArrows[index][0][:45], 106 + width / 3, i, 64) | |
14733 elif index < len(legendArrows) and legendArrows[index][2] == "pointer": | |
14734 svg.drawPointer( | |
14735 34 + width / 3, i - 64, 64, genet, legendArrows[index][1] | |
14736 ) | |
14737 svg.writeString(legendArrows[index][0][:45], 76 + width / 3, i, 64) | |
14738 index += 1 | |
14739 if legend == "Top" or legend == "Top & Bottom": | |
14740 rung1 = sum(toplegpos[:3]) + 30 | |
14741 rung2 = rung1 - toplegpos[0] - 10 | |
14742 rung3 = rung2 - toplegpos[1] - 10 | |
14743 for i in legendTop: | |
14744 if i[0][0].lower() == i[0][0]: | |
14745 xpos = i[1] + 16 | |
14746 else: | |
14747 xpos = i[1] + 32 | |
14748 if i[2] == 1: | |
14749 svg.writeString(i[0], xpos, rung1, 64, False, False, 1) | |
14750 elif i[2] == 2: | |
14751 svg.writeString(i[0], xpos, rung2, 64, False, False, 1) | |
14752 elif i[2] == 3: | |
14753 svg.writeString(i[0], xpos, rung3, 64, False, False, 1) | |
14754 if legend == "Bottom" or legend == "Top & Bottom": | |
14755 rung1 = hei - sum(botlegpos[:3]) - 30 - columnhei | |
14756 rung2 = rung1 + botlegpos[0] + 10 | |
14757 rung3 = rung2 + botlegpos[1] + 10 | |
14758 for i in legendBot: | |
14759 if i[0][-1].lower() == i[0][-1]: | |
14760 xpos = i[1] + 16 | |
14761 else: | |
14762 xpos = i[1] + 32 | |
14763 if i[2] == 1: | |
14764 svg.writeString(i[0], xpos, rung1, 64, False, False, 1, "right") | |
14765 elif i[2] == 2: | |
14766 svg.writeString(i[0], xpos, rung2, 64, False, False, 1, "right") | |
14767 elif i[2] == 3: | |
14768 svg.writeString(i[0], xpos, rung3, 64, False, False, 1, "right") | |
14769 # draws the scale figure | |
14770 if drawfig2 != False: | |
14771 testbmp = BitMap(5, 5) | |
14772 x1 = width - 600 - drawfig2 * 1.0 / maxlength * width | |
14773 x2 = width - 600 | |
14774 svg.drawLine( | |
14775 x1, | |
14776 hei - columnhei + height1 / 2 + 70, | |
14777 x2, | |
14778 hei - columnhei + height1 / 2 + 70, | |
14779 3, | |
14780 ) | |
14781 svg.drawLine( | |
14782 x1, | |
14783 hei - columnhei + height1 / 4 + 70, | |
14784 x1, | |
14785 hei - columnhei + height1 / 4 * 3 + 70, | |
14786 3, | |
14787 ) | |
14788 svg.drawLine( | |
14789 x2, | |
14790 hei - columnhei + height1 / 4 + 70, | |
14791 x2, | |
14792 hei - columnhei + height1 / 4 * 3 + 70, | |
14793 3, | |
14794 ) | |
14795 strfig2 = str(drawfig2) | |
14796 if strfig2[-6:] == "000000": | |
14797 strfig2 = strfig2[:-6] + " Mbp" | |
14798 elif strfig2[-3:] == "000": | |
14799 strfig2 = strfig2[:-3] + " Kbp" | |
14800 svg.writeString( | |
14801 strfig2, | |
14802 (x1 + x2) / 2 - testbmp.lengthString(strfig2, 64) / 2, | |
14803 hei - columnhei + height1 / 4 + 65, | |
14804 64, | |
14805 ) | |
14806 # draws the graph | |
14807 if graphit != None: | |
14808 thearray, maxgc, mingc, gheight, glinet, gtype, gmaxy, ggap = graphit | |
14809 widthpixellist = [] | |
14810 leftpixellist = [] | |
14811 rightpixellist = [] | |
14812 for i in range(len(thearray)): | |
14813 if aln == "best blast": | |
14814 shifter = blastmatch[i] | |
14815 if reverseList[i]: | |
14816 rightpixel = convertPosR(secondlist[i * 2][0], maxlength, width, 0, aln) | |
14817 leftpixel = convertPosR( | |
14818 secondlist[i * 2][0], maxlength, width, secondlist[i * 2][0], aln | |
14819 ) | |
14820 thearray[i].reverse() | |
14821 else: | |
14822 leftpixel = convertPos(secondlist[i * 2][0], maxlength, width, 0, aln) | |
14823 rightpixel = convertPos( | |
14824 secondlist[i * 2][0], maxlength, width, secondlist[i * 2][0], aln | |
14825 ) | |
14826 | |
14827 widthpixel = rightpixel - leftpixel + 1 | |
14828 widthpixellist.append(widthpixel) | |
14829 leftpixellist.append(leftpixel) | |
14830 rightpixellist.append(rightpixel) | |
14831 neg = False | |
14832 if gmaxy == "Auto": | |
14833 gmaxy = 0 | |
14834 for i in range(0, len(thearray)): | |
14835 if min(thearray[i]) < 0: | |
14836 neg = True | |
14837 for j in range(0, widthpixellist[i]): | |
14838 aa = int(j * (len(thearray[i]) * 1.0 / widthpixellist[i])) | |
14839 bb = int((j + 1) * (len(thearray[i]) * 1.0 / widthpixellist[i])) | |
14840 if aa == bb: | |
14841 bb += 1 | |
14842 temparr = thearray[i][aa:bb] | |
14843 gyval = abs(sum(temparr) * 1.0 / len(temparr)) | |
14844 if gyval > gmaxy: | |
14845 gmaxy = gyval | |
14846 else: | |
14847 gmaxy = float(gmaxy) | |
14848 for i in range(0, len(thearray)): | |
14849 if min(thearray[i]) < 0: | |
14850 neg = True | |
14851 if neg: | |
14852 axispos = ggap + gheight / 2 + glinet / 2 | |
14853 else: | |
14854 axispos = ggap + gheight | |
14855 for qq in range(len(thearray)): | |
14856 lastgypos = None | |
14857 svg.drawLine( | |
14858 leftpixellist[qq], | |
14859 axispos + glinet / 2, | |
14860 rightpixellist[qq], | |
14861 axispos + glinet / 2, | |
14862 glinet, | |
14863 ) | |
14864 for i in range(0, widthpixellist[qq]): | |
14865 aa = int(i * (len(thearray[qq]) * 1.0 / widthpixellist[qq])) | |
14866 bb = int((i + 1) * (len(thearray[qq]) * 1.0 / widthpixellist[qq])) | |
14867 if aa == bb: | |
14868 bb += 1 | |
14869 temparr = thearray[qq][aa:bb] | |
14870 gyval = sum(temparr) * 1.0 / len(temparr) | |
14871 yvalpixratio = gyval / gmaxy | |
14872 if yvalpixratio > 1: | |
14873 yvalpixratio = 1 | |
14874 if yvalpixratio < -1: | |
14875 yvalpixratio = -1 | |
14876 if neg: | |
14877 if yvalpixratio < 0: | |
14878 gc1, gc2, gc3 = mingc | |
14879 yvalpix = round(yvalpixratio * (gheight / 2 - glinet / 2)) | |
14880 if gtype == "Line": | |
14881 if lastgypos != None: | |
14882 svg.drawLine( | |
14883 leftpixellist[qq] + i - 1, | |
14884 lastgypos, | |
14885 leftpixellist[qq] + i, | |
14886 axispos - yvalpix, | |
14887 1, | |
14888 mingc, | |
14889 ) | |
14890 lastgypos = axispos - yvalpix | |
14891 elif gtype == "Histogram": | |
14892 svg.drawLine( | |
14893 leftpixellist[qq] + i, | |
14894 axispos + glinet / 2, | |
14895 leftpixellist[qq] + i, | |
14896 axispos - yvalpix, | |
14897 1, | |
14898 mingc, | |
14899 ) | |
14900 else: | |
14901 gc1, gc2, gc3 = maxgc | |
14902 yvalpix = round( | |
14903 yvalpixratio * (gheight / 2 - (glinet - glinet / 2)) | |
14904 ) | |
14905 if gtype == "Line": | |
14906 if lastgypos != None: | |
14907 svg.drawLine( | |
14908 leftpixellist[qq] + i - 1, | |
14909 lastgypos, | |
14910 leftpixellist[qq] + i, | |
14911 axispos - glinet - yvalpix, | |
14912 1, | |
14913 maxgc, | |
14914 ) | |
14915 lastgypos = axispos - glinet - yvalpix | |
14916 elif gtype == "Histogram" and round(yvalpix) != 0.0: | |
14917 svg.drawLine( | |
14918 leftpixellist[qq] + i, | |
14919 axispos - glinet / 2, | |
14920 leftpixellist[qq] + i, | |
14921 axispos - yvalpix, | |
14922 1, | |
14923 maxgc, | |
14924 ) | |
14925 else: | |
14926 yvalpix = round(yvalpixratio * (gheight - glinet)) | |
14927 if gtype == "Line": | |
14928 if lastgypos != None: | |
14929 svg.drawLine( | |
14930 leftpixellist[qq] + i - 1, | |
14931 lastgypos, | |
14932 i, | |
14933 leftpixellist[qq] - axispos - glinet - yvalpix, | |
14934 1, | |
14935 maxgc, | |
14936 ) | |
14937 lastgypos = axispos - glinet - 1 - yvalpix | |
14938 elif gtype == "Histogram" and round(yvalpix) != 0.0: | |
14939 svg.drawLine( | |
14940 leftpixellist[qq] + i, | |
14941 axispos, | |
14942 leftpixellist[qq] + i, | |
14943 axispos - yvalpix, | |
14944 1, | |
14945 maxgc, | |
14946 ) | |
14947 axispos += gheight + 2 * ggap + height1 + height2 | |
14948 modfig1 = (graphit[3] + 2 * ggap) * len(graphit[0]) | |
14949 else: | |
14950 modfig1 = 0 | |
14951 # draws the blast gradient legend | |
14952 if drawfig1 and minident != 101: | |
14953 svg.writeString( | |
14954 str(int(round(minident))) + "%", width - 300, hei - columnhei + 480, 64 | |
14955 ) | |
14956 svg.writeString("100%", width - 300, hei - columnhei + 84, 64) | |
14957 svg.drawGradient( | |
14958 width - 400, hei - columnhei + 20, 40, 460, minblastc, maxblastc | |
14959 ) | |
14960 svg.drawGradient2( | |
14961 width - 360, hei - columnhei + 20, 40, 460, minblastci, maxblastci | |
14962 ) | |
14963 # draws feature and blast figures | |
14964 for i in range(0, len(secondlist)): | |
14965 # draws the blast figure | |
14966 if i % 2 == 0: | |
14967 if aln == "best blast": | |
14968 shifter = blastmatch[int(i / 2)] | |
14969 genrev1 = reverseList[int(i / 2)] | |
14970 ymod = height1 * i / 2 + height2 * i / 2 | |
14971 if graphit != None: | |
14972 ymod += (gheight + 2 * ggap) * (min([len(thearray), i / 2 + 1])) | |
14973 if legend == "Top" or legend == "Top & Bottom": | |
14974 ymod += sum(toplegpos[:3]) + 40 | |
14975 length = secondlist[i][0] | |
14976 svg.drawLine( | |
14977 convertPos(length, maxlength, width, 0, aln), | |
14978 ymod + height1 / 2, | |
14979 convertPos(length, maxlength, width, length, aln), | |
14980 ymod + height1 / 2, | |
14981 glt, | |
14982 ) | |
14983 for j in secondlist[i][1]: | |
14984 if abortCaptain: | |
14985 return None | |
14986 if (j.strand == "+" and not genrev1) or (j.strand == "-" and genrev1): | |
14987 if type(j.start) == int: | |
14988 if genrev1: | |
14989 x2 = convertPosR(length, maxlength, width, j.start, aln) | |
14990 x1 = convertPosR(length, maxlength, width, j.stop, aln) | |
14991 else: | |
14992 x1 = convertPos(length, maxlength, width, j.start, aln) | |
14993 x2 = convertPos(length, maxlength, width, j.stop, aln) | |
14994 if featDict[j.type][0] == "rect": | |
14995 svg.drawOutRect( | |
14996 x1, ymod, max([x2 - x1, 1]), height1, j.colour, genet | |
14997 ) | |
14998 elif featDict[j.type][0] == "arrow": | |
14999 svg.drawRightArrow( | |
15000 x1, | |
15001 ymod, | |
15002 max([x2 - x1, 1]), | |
15003 height1, | |
15004 j.colour, | |
15005 (0, 0, 0), | |
15006 genet, | |
15007 ) | |
15008 elif featDict[j.type][0] == "frame": | |
15009 svg.drawRightFrame( | |
15010 x1, | |
15011 ymod, | |
15012 max([x2 - x1, 1]), | |
15013 height1, | |
15014 genet, | |
15015 j.start % 3, | |
15016 j.colour, | |
15017 ) | |
15018 elif featDict[j.type][0] == "pointer": | |
15019 svg.drawPointer(x1, ymod, height1, genet, j.colour) | |
15020 else: | |
15021 if genrev1: | |
15022 x2 = convertPosR(length, maxlength, width, j.start[-1], aln) | |
15023 x1 = convertPosR(length, maxlength, width, j.stop[-1], aln) | |
15024 else: | |
15025 x1 = convertPos(length, maxlength, width, j.start[-1], aln) | |
15026 x2 = convertPos(length, maxlength, width, j.stop[-1], aln) | |
15027 if featDict[j.type][0] == "rect": | |
15028 svg.drawOutRect( | |
15029 x1, ymod, max([x2 - x1, 1]), height1, j.colour, genet | |
15030 ) | |
15031 elif featDict[j.type][0] == "arrow": | |
15032 svg.drawRightArrow( | |
15033 x1, | |
15034 ymod, | |
15035 max([x2 - x1, 1]), | |
15036 height1, | |
15037 j.colour, | |
15038 (0, 0, 0), | |
15039 genet, | |
15040 ) | |
15041 elif featDict[j.type][0] == "frame": | |
15042 svg.drawRightFrame( | |
15043 x1, | |
15044 ymod, | |
15045 max([x2 - x1, 1]), | |
15046 height1, | |
15047 genet, | |
15048 j.start[-1] % 3, | |
15049 j.colour, | |
15050 ) | |
15051 elif featDict[j.type][0] == "pointer": | |
15052 svg.drawPointer(x1, ymod, height1, genet, j.colour) | |
15053 for k in range(2, len(j.start) + 1): | |
15054 if genrev1: | |
15055 x4 = convertPosR( | |
15056 length, maxlength, width, j.start[-k], aln | |
15057 ) | |
15058 x3 = convertPosR( | |
15059 length, maxlength, width, j.stop[-k], aln | |
15060 ) | |
15061 else: | |
15062 x3 = convertPos( | |
15063 length, maxlength, width, j.start[-k], aln | |
15064 ) | |
15065 x4 = convertPos( | |
15066 length, maxlength, width, j.stop[-k], aln | |
15067 ) | |
15068 if ( | |
15069 featDict[j.type][0] == "arrow" | |
15070 or featDict[j.type][0] == "rect" | |
15071 ): | |
15072 if x1 - x4 > 2: | |
15073 svg.drawDash( | |
15074 x4, ymod + height1 / 4, x4, ymod, exont | |
15075 ) | |
15076 svg.drawDash(x4, ymod, x1, ymod, exont) | |
15077 svg.drawDash( | |
15078 x1, ymod, x1, ymod + height1 / 4, exont | |
15079 ) | |
15080 svg.drawOutRect( | |
15081 x3, | |
15082 ymod + height1 / 4, | |
15083 x4 - x3, | |
15084 height1 / 2, | |
15085 j.colour, | |
15086 genet, | |
15087 ) | |
15088 elif featDict[j.type][0] == "frame": | |
15089 if x1 - x4 > 2: | |
15090 svg.drawDash( | |
15091 x4, ymod + height1 / 4, x4, ymod, exont | |
15092 ) | |
15093 svg.drawDash(x4, ymod, x1, ymod, exont) | |
15094 svg.drawDash( | |
15095 x1, ymod, x1, ymod + height1 / 4, exont | |
15096 ) | |
15097 svg.drawRightFrameRect( | |
15098 x3, | |
15099 ymod, | |
15100 x4 - x3, | |
15101 height1, | |
15102 genet, | |
15103 j.start[-k] % 3, | |
15104 j.colour, | |
15105 ) | |
15106 # need to get exons working for other types | |
15107 x1, x2 = x3, x4 | |
15108 else: | |
15109 if type(j.start) == int: | |
15110 if genrev1: | |
15111 x2 = convertPosR(length, maxlength, width, j.start, aln) | |
15112 x1 = convertPosR(length, maxlength, width, j.stop, aln) | |
15113 else: | |
15114 x1 = convertPos(length, maxlength, width, j.start, aln) | |
15115 x2 = convertPos(length, maxlength, width, j.stop, aln) | |
15116 if featDict[j.type][0] == "rect": | |
15117 svg.drawOutRect(x1, ymod, x2 - x1, height1, j.colour, genet) | |
15118 elif featDict[j.type][0] == "arrow": | |
15119 svg.drawLeftArrow( | |
15120 x1, ymod, x2 - x1, height1, j.colour, (0, 0, 0), genet | |
15121 ) | |
15122 elif featDict[j.type][0] == "frame": | |
15123 svg.drawLeftFrame( | |
15124 x1, ymod, x2 - x1, height1, genet, j.stop % 3, j.colour | |
15125 ) | |
15126 elif featDict[j.type][0] == "pointer": | |
15127 svg.drawPointer(x1, ymod, height1, genet, j.colour) | |
15128 else: | |
15129 if genrev1: | |
15130 x2 = convertPosR(length, maxlength, width, j.start[0], aln) | |
15131 x1 = convertPosR(length, maxlength, width, j.stop[0], aln) | |
15132 else: | |
15133 x1 = convertPos(length, maxlength, width, j.start[0], aln) | |
15134 x2 = convertPos(length, maxlength, width, j.stop[0], aln) | |
15135 if featDict[j.type][0] == "rect": | |
15136 svg.drawOutRect(x1, ymod, x2 - x1, height1, j.colour, genet) | |
15137 elif featDict[j.type][0] == "arrow": | |
15138 svg.drawLeftArrow( | |
15139 x1, ymod, x2 - x1, height1, j.colour, (0, 0, 0), genet | |
15140 ) | |
15141 elif featDict[j.type][0] == "frame": | |
15142 svg.drawLeftFrame( | |
15143 x1, | |
15144 ymod, | |
15145 x2 - x1, | |
15146 height1, | |
15147 genet, | |
15148 j.stop[0] % 3, | |
15149 j.colour, | |
15150 ) | |
15151 elif featDict[j.type][0] == "pointer": | |
15152 svg.drawPointer(x1, ymod, height1, genet, j.colour) | |
15153 for k in range(1, len(j.start)): | |
15154 if genrev1: | |
15155 x4 = convertPosR( | |
15156 length, maxlength, width, j.start[k], aln | |
15157 ) | |
15158 x3 = convertPosR( | |
15159 length, maxlength, width, j.stop[k], aln | |
15160 ) | |
15161 else: | |
15162 x3 = convertPos( | |
15163 length, maxlength, width, j.start[k], aln | |
15164 ) | |
15165 x4 = convertPos( | |
15166 length, maxlength, width, j.stop[k], aln | |
15167 ) | |
15168 if ( | |
15169 featDict[j.type][0] == "rect" | |
15170 or featDict[j.type][0] == "arrow" | |
15171 ): | |
15172 if x3 - x2 > 2: | |
15173 svg.drawDash( | |
15174 x2, | |
15175 ymod + 3 * height1 / 4, | |
15176 x2, | |
15177 ymod + height1, | |
15178 exont, | |
15179 ) | |
15180 svg.drawDash( | |
15181 x2, ymod + height1, x3, ymod + height1, exont | |
15182 ) | |
15183 svg.drawDash( | |
15184 x3, | |
15185 ymod + height1, | |
15186 x3, | |
15187 ymod + 3 * height1 / 4, | |
15188 exont, | |
15189 ) | |
15190 elif featDict[j.type][0] == "frame": | |
15191 if x3 - x2 > 2: | |
15192 svg.drawDash( | |
15193 x2, | |
15194 ymod + 3 * height1 / 4, | |
15195 x2, | |
15196 ymod + height1, | |
15197 exont, | |
15198 ) | |
15199 svg.drawDash( | |
15200 x2, ymod + height1, x3, ymod + height1, exont | |
15201 ) | |
15202 svg.drawDash( | |
15203 x3, | |
15204 ymod + height1, | |
15205 x3, | |
15206 ymod + 3 * height1 / 4, | |
15207 exont, | |
15208 ) | |
15209 svg.drawLeftFrameRect( | |
15210 x3, | |
15211 ymod, | |
15212 x4 - x3, | |
15213 height1, | |
15214 genet, | |
15215 j.stop[k] % 3, | |
15216 j.colour, | |
15217 ) | |
15218 x1, x2 = x3, x4 | |
15219 else: | |
15220 # draws teh blast hits | |
15221 genrev2 = reverseList[int((i + 1) / 2)] | |
15222 length1 = secondlist[i - 1][0] | |
15223 length2 = secondlist[i + 1][0] | |
15224 ymod = (height1 * (i - 1) / 2 + height2 * (i - 1) / 2) - 1 + height1 | |
15225 if graphit != None: | |
15226 ymod += (gheight + 2 * ggap) * (min([len(thearray), i / 2 + 1])) | |
15227 if legend == "Top" or legend == "Top & Bottom": | |
15228 ymod += sum(toplegpos[:3]) + 40 | |
15229 y1 = ymod | |
15230 y2 = y1 + height2 + 1 | |
15231 for j in secondlist[i]: | |
15232 if abortCaptain: | |
15233 return None | |
15234 qStart, qEnd, rStart, rEnd, ident = j | |
15235 # is the blast hit inverted | |
15236 if ( | |
15237 (rStart < rEnd and not genrev1 and not genrev2) | |
15238 or (rStart > rEnd and not genrev1 and genrev2) | |
15239 or (rStart < rEnd and genrev1 and genrev2) | |
15240 or (rStart > rEnd and genrev1 and not genrev2) | |
15241 ): | |
15242 crisscross = False | |
15243 else: | |
15244 crisscross = True | |
15245 try: | |
15246 ratio = round((ident - minident) / (100 - minident), 2) | |
15247 except: | |
15248 ratio = 1 | |
15249 if crisscross: | |
15250 r1 = int(minblastci[0] * (1 - ratio) + maxblastci[0] * ratio) | |
15251 r2 = int(minblastci[1] * (1 - ratio) + maxblastci[1] * ratio) | |
15252 r3 = int(minblastci[2] * (1 - ratio) + maxblastci[2] * ratio) | |
15253 else: | |
15254 r1 = int(minblastc[0] * (1 - ratio) + maxblastc[0] * ratio) | |
15255 r2 = int(minblastc[1] * (1 - ratio) + maxblastc[1] * ratio) | |
15256 r3 = int(minblastc[2] * (1 - ratio) + maxblastc[2] * ratio) | |
15257 if aln == "best blast": | |
15258 shifter = blastmatch[int(i / 2)] | |
15259 if genrev1: | |
15260 x1e = convertPosR(length1, maxlength, width, qStart, aln) | |
15261 x1s = convertPosR(length1, maxlength, width, qEnd, aln) | |
15262 else: | |
15263 x1s = convertPos(length1, maxlength, width, qStart, aln) | |
15264 x1e = convertPos(length1, maxlength, width, qEnd, aln) | |
15265 if aln == "best blast": | |
15266 shifter = blastmatch[int((i + 1) / 2)] | |
15267 if genrev2 and rStart < rEnd: | |
15268 x2e = convertPosR(length2, maxlength, width, rStart, aln) | |
15269 x2s = convertPosR(length2, maxlength, width, rEnd, aln) | |
15270 elif genrev2 and rStart >= rEnd: | |
15271 x2s = convertPosR(length2, maxlength, width, rStart, aln) | |
15272 x2e = convertPosR(length2, maxlength, width, rEnd, aln) | |
15273 elif not genrev2 and rStart < rEnd: | |
15274 x2s = convertPos(length2, maxlength, width, rStart, aln) | |
15275 x2e = convertPos(length2, maxlength, width, rEnd, aln) | |
15276 else: | |
15277 x2e = convertPos(length2, maxlength, width, rStart, aln) | |
15278 x2s = convertPos(length2, maxlength, width, rEnd, aln) | |
15279 if crisscross: | |
15280 svg.drawBlastHit(x1s, y1, x1e, y1, x2s, y2, x2e, y2, (r1, r2, r3)) | |
15281 if blastoutline: | |
15282 svg.drawLine(x1s, y1, x2e, y2) | |
15283 svg.drawLine(x1e, y1, x2s, y2) | |
15284 else: | |
15285 svg.drawBlastHit(x1s, y1, x1e, y1, x2e, y2, x2s, y2, (r1, r2, r3)) | |
15286 if blastoutline: | |
15287 svg.drawLine(x1s, y1, x2s, y2) | |
15288 svg.drawLine(x1e, y1, x2e, y2) | |
15289 svg.writesvg(filename) | |
15290 return minident | |
15291 | |
15292 | |
15293 # The GUI | |
15294 class App: | |
15295 def __init__(self, master): | |
15296 self.pwd = os.getcwd() | |
15297 self.menubar = Menu(master) | |
15298 self.filemenu = Menu(self.menubar, tearoff=0) | |
15299 self.filemenu.add_command(label="New Figure", command=self.defaultoptions) | |
15300 self.filemenu.add_command(label="Save Settings", command=self.saveOptions) | |
15301 self.filemenu.add_command(label="Load Settings", command=self.openOptions) | |
15302 self.filemenu.add_separator() | |
15303 self.filemenu.add_command(label="Preferences", command=self.preferencewindow) | |
15304 self.filemenu.add_separator() | |
15305 self.filemenu.add_command(label="Exit", command=root.quit) | |
15306 self.menubar.add_cascade(label="File", menu=self.filemenu) | |
15307 | |
15308 # create more pulldown menus | |
15309 self.confmenu = Menu(self.menubar, tearoff=0) | |
15310 self.confmenu.add_command(label="Figure", command=self.figureoptions) | |
15311 self.confmenu.add_command(label="Annotation", command=self.annotateoptions) | |
15312 self.confmenu.add_command(label="Blast", command=self.blastoptions) | |
15313 self.confmenu.add_command(label="Graph", command=self.graphoptions) | |
15314 self.confmenu.add_command(label="Subregions", command=self.annmod) | |
15315 self.menubar.add_cascade(label="Image", menu=self.confmenu) | |
15316 | |
15317 self.blastmenu = Menu(self.menubar, tearoff=0) | |
15318 self.blastmenu.add_command( | |
15319 label="Download Blast Automatically", command=self.downloadBlastAuto | |
15320 ) | |
15321 self.blastmenu.add_command( | |
15322 label="Download Blast Manually", command=self.downloadBlastMan | |
15323 ) | |
15324 self.blastmenu.add_command( | |
15325 label="Choose Blast Location", command=self.chooseBlastDir | |
15326 ) | |
15327 self.menubar.add_cascade(label="Blast", menu=self.blastmenu) | |
15328 | |
15329 self.helpmenu = Menu(self.menubar, tearoff=0) | |
15330 self.helpmenu.add_command(label="Help", command=self.openhelpsite) | |
15331 self.helpmenu.add_command(label="Support", command=self.supportwin) | |
15332 self.helpmenu.add_separator() | |
15333 self.helpmenu.add_command(label="About", command=self.openabout) | |
15334 self.helpmenu.add_command(label="Reference", command=self.openref) | |
15335 self.menubar.add_cascade(label="Help", menu=self.helpmenu) | |
15336 master.config(menu=self.menubar) | |
15337 frame1 = Frame(master) | |
15338 frame1.grid(row=0, column=0, padx=40, pady=10) | |
15339 master.geometry("+10+20") | |
15340 self.showit = False | |
15341 self.running = False | |
15342 self.graphshow = False | |
15343 self.cutstate = None | |
15344 self.orderstate = None | |
15345 self.blastlDir = None | |
15346 self.blastnDir = None | |
15347 self.dblDir = None | |
15348 self.dbnDir = None | |
15349 self.workingDir = "test" | |
15350 self.mincutlist = {} | |
15351 self.maxcutlist = {} | |
15352 self.revlist = {} | |
15353 self.entrynum = 0 | |
15354 self.theTitle = Label( | |
15355 frame1, text="Easyfig 2.2.3", font="TkDefaultFont 24 bold" | |
15356 ) | |
15357 self.theTitle.grid(row=0, column=1, columnspan=3, padx=10, sticky="W") | |
15358 self.annLab = Label( | |
15359 frame1, text="Annotation Files", font="TkDefaultFont 13 bold underline" | |
15360 ) | |
15361 self.annLab.grid(row=1, column=2, pady=10) | |
15362 self.scrollbar = Scrollbar(frame1, orient=VERTICAL) | |
15363 self.genlist = DDlistbox(frame1, yscrollcommand=self.scrollbar.set) | |
15364 self.genlist.bind("<Double-Button-1>", self.annmod) | |
15365 self.genlist.config(height=10) | |
15366 self.blastlist = DDlistbox(frame1, yscrollcommand=self.scrollbar.set) | |
15367 self.blastlist.config(height=9) | |
15368 self.scrollbar.config(command=self.yview) | |
15369 self.scrollbar.grid(row=2, column=1, rowspan=9, sticky=NS) | |
15370 self.genlist.grid(row=2, column=2, rowspan=9) | |
15371 self.annLab = Label( | |
15372 frame1, text="Blast Files", font="TkDefaultFont 13 bold underline" | |
15373 ) | |
15374 self.annLab.grid(row=1, column=3) | |
15375 self.blastlist.grid(row=2, column=3, rowspan=9) | |
15376 self.addgenbutton = Button( | |
15377 frame1, text="Add feature file", command=self.addfeat | |
15378 ) | |
15379 self.addgenbutton.grid(row=11, column=2, sticky=EW) | |
15380 self.addgenbutton = Button(frame1, text="Add folder", command=self.addfolder) | |
15381 self.addgenbutton.grid(row=12, column=2, sticky=EW) | |
15382 self.removegenbutton = Button( | |
15383 frame1, text="Remove feature file", command=self.removefeat | |
15384 ) | |
15385 self.removegenbutton.grid(row=13, column=2, sticky=EW) | |
15386 | |
15387 self.addblastbutton = Button( | |
15388 frame1, text="Add blast file", command=self.addblast | |
15389 ) | |
15390 self.addblastbutton.grid(row=11, column=3, sticky=EW) | |
15391 self.removeblastbutton = Button( | |
15392 frame1, text="Remove blast file", command=self.removeblast | |
15393 ) | |
15394 self.removeblastbutton.grid(row=12, column=3, sticky=EW) | |
15395 | |
15396 self.spacefiller = Label(frame1, text=" ") | |
15397 self.spacefiller.grid(row=12, column=0) | |
15398 self.blastit = Button( | |
15399 frame1, text="Generate blastn Files", command=self.genBlast | |
15400 ) | |
15401 self.blastit.grid(row=14, column=3, sticky="EW") | |
15402 self.blastx = Button( | |
15403 frame1, text="Generate tblastx Files", command=self.genBlastX | |
15404 ) | |
15405 self.blastx.grid(row=15, column=3, sticky="EW") | |
15406 | |
15407 self.outfile = StringVar(value="") | |
15408 self.outopen = Button(frame1, text="Save As", command=self.getoutfile) | |
15409 self.outopen.grid(row=17, column=2, columnspan=2, sticky=W) | |
15410 self.outfilename = Entry(frame1, textvariable=self.outfile) | |
15411 self.outfilename.grid(row=17, column=2, columnspan=2) | |
15412 self.filetype = StringVar(value="Bitmap (bmp)") | |
15413 self.filetypelabel = Label(frame1, text="File type:") | |
15414 self.filetypelabel.grid(row=18, column=2, columnspan=2, pady=5, sticky=W) | |
15415 self.filetypeentry = OptionMenu( | |
15416 frame1, | |
15417 self.filetype, | |
15418 "Bitmap (bmp)", | |
15419 "Vector file (svg)", | |
15420 "Preview (shrink)", | |
15421 "Preview (1:1)", | |
15422 ) | |
15423 self.filetypeentry.grid(row=18, column=2, columnspan=2, pady=5) | |
15424 self.createFigure = Button( | |
15425 frame1, | |
15426 text="Create Figure", | |
15427 font="TkDefaultFont 12 bold", | |
15428 width=20, | |
15429 command=self.makeFigure, | |
15430 ) | |
15431 self.createFigure.grid(row=19, column=2, columnspan=2, rowspan=3, sticky="NS") | |
15432 | |
15433 self.processLab = Label(frame1, bg="#FFFF99", relief=SUNKEN) | |
15434 self.processLab.grid( | |
15435 row=14, column=1, rowspan=3, columnspan=2, sticky="NSEW", padx=5, pady=5 | |
15436 ) | |
15437 | |
15438 self.gap = Label(frame1, text=" ") | |
15439 self.gap.grid(row=18, column=3) | |
15440 self.gap2 = Label(frame1, text=" ") | |
15441 self.gap2.grid(row=16, column=3) | |
15442 self.gap3 = Label(frame1, text=" ") | |
15443 self.gap3.grid(row=19, column=4) | |
15444 self.gap4 = Label(frame1, text=" ") | |
15445 self.gap4.grid(row=20, column=4) | |
15446 self.gap4 = Label(frame1, text=" ") | |
15447 self.gap4.grid(row=21, column=4) | |
15448 | |
15449 self.defaultpreferences() | |
15450 if os.path.exists(".easyfig.pref"): | |
15451 self.opendefault() | |
15452 | |
15453 def yview(self, *args): | |
15454 apply(self.genlist.yview, args) | |
15455 apply(self.blastlist.yview, args) | |
15456 | |
15457 def addfolder(self): | |
15458 tempfolder = tkFileDialog.askdirectory( | |
15459 title="Please select a directory with feature files." | |
15460 ) | |
15461 if tempfolder == () or tempfolder == "": | |
15462 return | |
15463 for i in os.listdir(tempfolder): | |
15464 if self.entrynum == 99: | |
15465 if self.genlist.size() == 99: | |
15466 tkMessageBox.showerror( | |
15467 "Maximum feature files reached.", | |
15468 "At this time easyfig only supports 99 genomes.\nEasyfig_CL does not have a maximum limit.", | |
15469 ) | |
15470 return | |
15471 self.renumbergen() | |
15472 filename = tempfolder + "/" + i | |
15473 self.entrynum += 1 | |
15474 entryname = "%02d" % self.entrynum + ". " + filename | |
15475 self.genlist.insert(END, entryname) | |
15476 self.mincutlist[entryname[:2]] = "1" | |
15477 self.maxcutlist[entryname[:2]] = "Max" | |
15478 self.revlist[entryname[:2]] = False | |
15479 self.genlist.xview_moveto(1) | |
15480 | |
15481 def addfeat(self): | |
15482 if self.entrynum == 99: | |
15483 if self.genlist.size() == 99: | |
15484 tkMessageBox.showerror( | |
15485 "Maximum feature files reached.", | |
15486 "At this time easyfig only supports 99 genomes.\nEasyfig_CL does not have a maximum limit.", | |
15487 ) | |
15488 return | |
15489 self.renumbergen() | |
15490 filename = tkFileDialog.askopenfilename( | |
15491 filetypes=[ | |
15492 ( | |
15493 "genbank/embl/fasta", | |
15494 ( | |
15495 "*.gbk", | |
15496 "*.embl", | |
15497 "*.gb", | |
15498 "*.fa", | |
15499 "*.fna", | |
15500 "*.dna", | |
15501 "*.fas", | |
15502 "*.fasta", | |
15503 ), | |
15504 ), | |
15505 ("All files", "*"), | |
15506 ] | |
15507 ) | |
15508 if filename == "": | |
15509 return | |
15510 self.entrynum += 1 | |
15511 entryname = "%02d" % self.entrynum + ". " + filename | |
15512 self.genlist.insert(END, entryname) | |
15513 self.genlist.xview_moveto(1) | |
15514 self.mincutlist[entryname[:2]] = "1" | |
15515 self.maxcutlist[entryname[:2]] = "Max" | |
15516 self.revlist[entryname[:2]] = False | |
15517 | |
15518 def renumbergen(self): | |
15519 try: | |
15520 self.annwindow.destroy() | |
15521 except: | |
15522 pass | |
15523 tempmincutlist = {} | |
15524 tempmaxcutlist = {} | |
15525 temprevlist = {} | |
15526 for i in range(self.genlist.size()): | |
15527 tempgen = self.genlist.get(i) | |
15528 self.genlist.delete(i) | |
15529 self.genlist.insert(i, "%02d" % (i + 1) + tempgen[2:]) | |
15530 tempmincutlist["%02d" % (i + 1)] = self.mincutlist[tempgen[:2]] | |
15531 tempmaxcutlist["%02d" % (i + 1)] = self.maxcutlist[tempgen[:2]] | |
15532 temprevlist["%02d" % (i + 1)] = self.revlist[tempgen[:2]] | |
15533 self.mincutlist = tempmincutlist | |
15534 self.maxcutlist = tempmaxcutlist | |
15535 self.revlist = temprevlist | |
15536 self.entrynum = self.genlist.size() | |
15537 self.genlist.xview_moveto(1) | |
15538 | |
15539 def removefeat(self): | |
15540 self.genlist.delete(ANCHOR) | |
15541 self.renumbergen() | |
15542 | |
15543 def addblast(self): | |
15544 filename = tkFileDialog.askopenfilename() | |
15545 self.blastlist.insert(END, filename) | |
15546 self.blastlist.xview_moveto(1) | |
15547 self.orderstate = None | |
15548 self.cutstate = None | |
15549 | |
15550 def removeblast(self): | |
15551 self.blastlist.delete(ANCHOR) | |
15552 | |
15553 def defaultoptions(self): | |
15554 try: | |
15555 self.prefwin.destroy() | |
15556 except: | |
15557 pass | |
15558 try: | |
15559 self.figureoptionswindow.destroy() | |
15560 except: | |
15561 pass | |
15562 try: | |
15563 self.blastoptionswindow.destroy() | |
15564 except: | |
15565 pass | |
15566 try: | |
15567 self.annotateoptionswindow.destroy() | |
15568 except: | |
15569 pass | |
15570 try: | |
15571 self.graphoptionswindow.destroy() | |
15572 except: | |
15573 pass | |
15574 try: | |
15575 self.annwindow.destroy() | |
15576 except: | |
15577 pass | |
15578 try: | |
15579 self.doublecutswin.destroy() | |
15580 except: | |
15581 pass | |
15582 self.outfile.set("") | |
15583 self.genlist.delete(0, END) | |
15584 self.blastlist.delete(0, END) | |
15585 self.defaultpreferences() | |
15586 self.entrynum = 0 | |
15587 self.cutstate = None | |
15588 self.orderstate = None | |
15589 if os.path.exists(".easyfig.pref"): | |
15590 self.opendefault() | |
15591 else: | |
15592 self.defaultpreferences() | |
15593 | |
15594 def defaultpreferences(self): | |
15595 self.filetype.set("Bitmap (bmp)") | |
15596 self.figwidthvar = StringVar(value="5000") | |
15597 self.height1var = StringVar(value="150") | |
15598 self.height2var = StringVar(value="500") | |
15599 self.aln = StringVar(value="centre") | |
15600 self.autodetect = IntVar() | |
15601 self.autodetect.set(1) | |
15602 self.drawfig1 = IntVar() | |
15603 self.drawfig1.set(1) | |
15604 self.drawfig2var = StringVar(value="0") | |
15605 | |
15606 self.minlengthvar = StringVar(value="0") | |
15607 self.minevalvar = StringVar(value="0.001") | |
15608 self.minIdentvar = StringVar(value="0") | |
15609 self.minblastc = (200, 200, 200) | |
15610 self.minblastchex = "#C8C8C8" | |
15611 self.minblastci = (200, 200, 200) | |
15612 self.minblastcihex = "#C8C8C8" | |
15613 self.maxblastc = (100, 100, 100) | |
15614 self.maxblastchex = "#646464" | |
15615 self.maxblastci = (100, 100, 100) | |
15616 self.maxblastcihex = "#646464" | |
15617 self.blastoutline = IntVar() | |
15618 self.blastoutline.set(1) | |
15619 | |
15620 self.leg = StringVar(value="None") | |
15621 self.leg2 = StringVar(value="None") | |
15622 self.legname = StringVar(value="gene") | |
15623 self.gltvar = StringVar(value="20") | |
15624 self.exontvar = StringVar(value="2") | |
15625 self.genetvar = StringVar(value="1") | |
15626 | |
15627 self.genef = IntVar() | |
15628 self.genef.set(1) | |
15629 self.genefcolour = (64, 224, 208) | |
15630 self.genefcolourhex = "#40e0d0" | |
15631 self.genefrect = StringVar(value="arrow") | |
15632 | |
15633 self.cdsf = IntVar() | |
15634 self.cdsfcolour = (255, 140, 0) | |
15635 self.cdsfcolourhex = "#ff8c00" | |
15636 self.cdsfrect = StringVar(value="arrow") | |
15637 | |
15638 self.trnaf = IntVar() | |
15639 self.trnafcolour = (165, 42, 42) | |
15640 self.trnafcolourhex = "#a52a2a" | |
15641 self.trnafrect = StringVar(value="rect") | |
15642 | |
15643 self.miscf = IntVar() | |
15644 self.miscfcolour = (0, 191, 255) | |
15645 self.miscfcolourhex = "#00bfff" | |
15646 self.miscfrect = StringVar(value="rect") | |
15647 | |
15648 self.randfeat = StringVar() | |
15649 self.randf = IntVar() | |
15650 self.randfcolour = (72, 61, 139) | |
15651 self.randfcolourhex = "#483d8b" | |
15652 self.randfrect = StringVar(value="arrow") | |
15653 | |
15654 self.graphtype = StringVar(value="None") | |
15655 self.allorone = IntVar() | |
15656 self.graphfile = StringVar() | |
15657 self.step = StringVar(value="1000") | |
15658 self.windsize = StringVar(value="1000") | |
15659 self.graphheight = StringVar(value="200") | |
15660 self.maxy = StringVar(value="Auto") | |
15661 self.logit = IntVar() | |
15662 self.histo = StringVar(value="Histogram") | |
15663 self.graphlinet = StringVar(value="1") | |
15664 self.poscol = (255, 0, 0) | |
15665 self.poscolhex = "#FF0000" | |
15666 self.negcol = (0, 0, 255) | |
15667 self.negcolhex = "#0000FF" | |
15668 self.ggap = StringVar(value="10") | |
15669 self.blastnDir = None | |
15670 self.dbnDir = None | |
15671 | |
15672 def saveOptions(self): | |
15673 filename = "" | |
15674 filename = tkFileDialog.asksaveasfilename( | |
15675 filetypes=[("easycfg", "*.easycfg"), ("All files", "*")] | |
15676 ) | |
15677 if filename == "" or filename == (): | |
15678 return | |
15679 savefile = open(filename, "w") | |
15680 savefile.write("\t".join(self.genlist.get(0, END)) + "\n") | |
15681 for i in self.genlist.get(0, END): | |
15682 savefile.write( | |
15683 i[:2] | |
15684 + "\t" | |
15685 + self.mincutlist[i[:2]] | |
15686 + "\t" | |
15687 + self.maxcutlist[i[:2]] | |
15688 + "\t" | |
15689 + str(self.revlist[i[:2]]) | |
15690 + "\n" | |
15691 ) | |
15692 savefile.write("\t".join(self.blastlist.get(0, END)) + "\n") | |
15693 | |
15694 savefile.write(self.outfile.get() + "\n") | |
15695 savefile.write(self.filetype.get() + "\n") | |
15696 | |
15697 savefile.write(self.figwidthvar.get() + "\n") | |
15698 savefile.write(self.height1var.get() + "\n") | |
15699 savefile.write(self.height2var.get() + "\n") | |
15700 savefile.write(self.aln.get() + "\n") | |
15701 savefile.write(str(self.autodetect.get()) + "\n") | |
15702 savefile.write(str(self.drawfig1.get()) + "\n") | |
15703 savefile.write(self.drawfig2var.get() + "\n") | |
15704 | |
15705 savefile.write(self.minlengthvar.get() + "\n") | |
15706 savefile.write(self.minevalvar.get() + "\n") | |
15707 savefile.write(self.minIdentvar.get() + "\n") | |
15708 savefile.write(str(self.minblastc[0]) + "\n") | |
15709 savefile.write(str(self.minblastc[1]) + "\n") | |
15710 savefile.write(str(self.minblastc[2]) + "\n") | |
15711 savefile.write(self.minblastchex + "\n") | |
15712 savefile.write(str(self.minblastci[0]) + "\n") | |
15713 savefile.write(str(self.minblastci[1]) + "\n") | |
15714 savefile.write(str(self.minblastci[2]) + "\n") | |
15715 savefile.write(self.minblastcihex + "\n") | |
15716 savefile.write(str(self.maxblastc[0]) + "\n") | |
15717 savefile.write(str(self.maxblastc[1]) + "\n") | |
15718 savefile.write(str(self.maxblastc[2]) + "\n") | |
15719 savefile.write(self.maxblastchex + "\n") | |
15720 savefile.write(str(self.maxblastci[0]) + "\n") | |
15721 savefile.write(str(self.maxblastci[1]) + "\n") | |
15722 savefile.write(str(self.maxblastci[2]) + "\n") | |
15723 savefile.write(self.maxblastcihex + "\n") | |
15724 savefile.write(str(self.blastoutline.get()) + "\n") | |
15725 | |
15726 savefile.write(self.leg.get() + "\n") | |
15727 savefile.write(self.leg2.get() + "\n") | |
15728 savefile.write(self.legname.get() + "\n") | |
15729 savefile.write(self.gltvar.get() + "\n") | |
15730 savefile.write(self.exontvar.get() + "\n") | |
15731 savefile.write(self.genetvar.get() + "\n") | |
15732 | |
15733 savefile.write(str(self.genef.get()) + "\n") | |
15734 savefile.write(str(self.genefcolour[0]) + "\n") | |
15735 savefile.write(str(self.genefcolour[1]) + "\n") | |
15736 savefile.write(str(self.genefcolour[2]) + "\n") | |
15737 savefile.write(self.genefcolourhex + "\n") | |
15738 savefile.write(self.genefrect.get() + "\n") | |
15739 | |
15740 savefile.write(str(self.cdsf.get()) + "\n") | |
15741 savefile.write(str(self.cdsfcolour[0]) + "\n") | |
15742 savefile.write(str(self.cdsfcolour[1]) + "\n") | |
15743 savefile.write(str(self.cdsfcolour[2]) + "\n") | |
15744 savefile.write(self.cdsfcolourhex + "\n") | |
15745 savefile.write(self.cdsfrect.get() + "\n") | |
15746 | |
15747 savefile.write(str(self.trnaf.get()) + "\n") | |
15748 savefile.write(str(self.trnafcolour[0]) + "\n") | |
15749 savefile.write(str(self.trnafcolour[1]) + "\n") | |
15750 savefile.write(str(self.trnafcolour[2]) + "\n") | |
15751 savefile.write(self.trnafcolourhex + "\n") | |
15752 savefile.write(self.trnafrect.get() + "\n") | |
15753 | |
15754 savefile.write(str(self.miscf.get()) + "\n") | |
15755 savefile.write(str(self.miscfcolour[0]) + "\n") | |
15756 savefile.write(str(self.miscfcolour[1]) + "\n") | |
15757 savefile.write(str(self.miscfcolour[2]) + "\n") | |
15758 savefile.write(self.miscfcolourhex + "\n") | |
15759 savefile.write(self.miscfrect.get() + "\n") | |
15760 | |
15761 savefile.write(self.randfeat.get() + "\n") | |
15762 savefile.write(str(self.randf.get()) + "\n") | |
15763 savefile.write(str(self.randfcolour[0]) + "\n") | |
15764 savefile.write(str(self.randfcolour[1]) + "\n") | |
15765 savefile.write(str(self.randfcolour[2]) + "\n") | |
15766 savefile.write(self.randfcolourhex + "\n") | |
15767 savefile.write(self.randfrect.get() + "\n") | |
15768 | |
15769 savefile.write(self.graphtype.get() + "\n") | |
15770 savefile.write(str(self.allorone.get()) + "\n") | |
15771 savefile.write(self.graphfile.get() + "\n") | |
15772 savefile.write(self.step.get() + "\n") | |
15773 savefile.write(self.windsize.get() + "\n") | |
15774 savefile.write(self.graphheight.get() + "\n") | |
15775 savefile.write(self.maxy.get() + "\n") | |
15776 savefile.write(str(self.logit.get()) + "\n") | |
15777 savefile.write(self.histo.get() + "\n") | |
15778 savefile.write(self.graphlinet.get() + "\n") | |
15779 savefile.write(str(self.poscol[0]) + "\n") | |
15780 savefile.write(str(self.poscol[1]) + "\n") | |
15781 savefile.write(str(self.poscol[2]) + "\n") | |
15782 savefile.write(self.poscolhex + "\n") | |
15783 savefile.write(str(self.negcol[0]) + "\n") | |
15784 savefile.write(str(self.negcol[1]) + "\n") | |
15785 savefile.write(str(self.negcol[2]) + "\n") | |
15786 savefile.write(self.negcolhex + "\n") | |
15787 savefile.write(self.ggap.get() + "\n") | |
15788 savefile.close() | |
15789 | |
15790 def openOptions(self): | |
15791 try: | |
15792 filename = tkFileDialog.askopenfilename( | |
15793 filetypes=[("easycfg", "*.easycfg"), ("All files", "*")] | |
15794 ) | |
15795 if filename == "": | |
15796 return | |
15797 openfile = open(filename) | |
15798 templist = openfile.readline().rstrip().split("\t") | |
15799 self.genlist.delete(0, END) | |
15800 if templist == [""]: | |
15801 templist = [] | |
15802 for i in templist: | |
15803 self.genlist.insert(END, i) | |
15804 self.genlist.xview_moveto(1) | |
15805 for i in range(len(templist)): | |
15806 name, mincut, maxcut, rev = openfile.readline().rstrip().split("\t") | |
15807 self.mincutlist[name] = mincut | |
15808 self.maxcutlist[name] = maxcut | |
15809 if rev == "True": | |
15810 self.revlist[name] = True | |
15811 else: | |
15812 self.revlist[name] = False | |
15813 templist = openfile.readline().rstrip().split("\t") | |
15814 if templist == [""]: | |
15815 templist = [] | |
15816 self.blastlist.delete(0, END) | |
15817 for i in templist: | |
15818 self.blastlist.insert(END, i) | |
15819 self.blastlist.xview_moveto(1) | |
15820 self.outfile.set(openfile.readline().rstrip()) | |
15821 self.filetype.set(openfile.readline().rstrip()) | |
15822 | |
15823 self.figwidthvar.set(openfile.readline().rstrip()) | |
15824 self.height1var.set(openfile.readline().rstrip()) | |
15825 self.height2var.set(openfile.readline().rstrip()) | |
15826 self.aln.set(openfile.readline().rstrip()) | |
15827 self.autodetect.set(int(openfile.readline().rstrip())) | |
15828 self.drawfig1.set(int(openfile.readline().rstrip())) | |
15829 self.drawfig2var.set(openfile.readline().rstrip()) | |
15830 | |
15831 self.minlengthvar.set(openfile.readline().rstrip()) | |
15832 self.minevalvar.set(openfile.readline().rstrip()) | |
15833 self.minIdentvar.set(openfile.readline().rstrip()) | |
15834 x = int(openfile.readline().rstrip()) | |
15835 y = int(openfile.readline().rstrip()) | |
15836 z = int(openfile.readline().rstrip()) | |
15837 self.minblastc = (x, y, z) | |
15838 self.minblastchex = openfile.readline().rstrip() | |
15839 x = int(openfile.readline().rstrip()) | |
15840 y = int(openfile.readline().rstrip()) | |
15841 z = int(openfile.readline().rstrip()) | |
15842 self.minblastci = (x, y, z) | |
15843 self.minblastcihex = openfile.readline().rstrip() | |
15844 x = int(openfile.readline().rstrip()) | |
15845 y = int(openfile.readline().rstrip()) | |
15846 z = int(openfile.readline().rstrip()) | |
15847 self.maxblastc = (x, y, z) | |
15848 self.maxblastchex = openfile.readline().rstrip() | |
15849 x = int(openfile.readline().rstrip()) | |
15850 y = int(openfile.readline().rstrip()) | |
15851 z = int(openfile.readline().rstrip()) | |
15852 self.maxblastci = (x, y, z) | |
15853 self.maxblastcihex = openfile.readline().rstrip() | |
15854 self.blastoutline.set(int(openfile.readline().rstrip())) | |
15855 | |
15856 self.leg.set(openfile.readline().rstrip()) | |
15857 self.leg2.set(openfile.readline().rstrip()) | |
15858 self.legname.set(openfile.readline().rstrip()) | |
15859 self.gltvar.set(openfile.readline().rstrip()) | |
15860 self.exontvar.set(openfile.readline().rstrip()) | |
15861 self.genetvar.set(openfile.readline().rstrip()) | |
15862 | |
15863 self.genef.set(int(openfile.readline().rstrip())) | |
15864 x = int(openfile.readline().rstrip()) | |
15865 y = int(openfile.readline().rstrip()) | |
15866 z = int(openfile.readline().rstrip()) | |
15867 self.genefcolour = (x, y, z) | |
15868 self.genefcolourhex = openfile.readline().rstrip() | |
15869 self.genefrect.set(openfile.readline().rstrip()) | |
15870 | |
15871 self.cdsf.set(int(openfile.readline().rstrip())) | |
15872 x = int(openfile.readline().rstrip()) | |
15873 y = int(openfile.readline().rstrip()) | |
15874 z = int(openfile.readline().rstrip()) | |
15875 self.cdsfcolour = (x, y, z) | |
15876 self.cdsfcolourhex = openfile.readline().rstrip() | |
15877 self.cdsfrect.set(openfile.readline().rstrip()) | |
15878 | |
15879 self.trnaf.set(int(openfile.readline().rstrip())) | |
15880 x = int(openfile.readline().rstrip()) | |
15881 y = int(openfile.readline().rstrip()) | |
15882 z = int(openfile.readline().rstrip()) | |
15883 self.trnafcolour = (x, y, z) | |
15884 self.trnafcolourhex = openfile.readline().rstrip() | |
15885 self.trnafrect.set(openfile.readline().rstrip()) | |
15886 | |
15887 self.miscf.set(int(openfile.readline().rstrip())) | |
15888 x = int(openfile.readline().rstrip()) | |
15889 y = int(openfile.readline().rstrip()) | |
15890 z = int(openfile.readline().rstrip()) | |
15891 self.miscfcolour = (x, y, z) | |
15892 self.miscfcolourhex = openfile.readline().rstrip() | |
15893 self.miscfrect.set(openfile.readline().rstrip()) | |
15894 | |
15895 self.randfeat.set(openfile.readline().rstrip()) | |
15896 self.randf.set(int(openfile.readline().rstrip())) | |
15897 x = int(openfile.readline().rstrip()) | |
15898 y = int(openfile.readline().rstrip()) | |
15899 z = int(openfile.readline().rstrip()) | |
15900 self.randfcolour = (x, y, z) | |
15901 self.randfcolourhex = openfile.readline().rstrip() | |
15902 self.randfrect.set(openfile.readline().rstrip()) | |
15903 | |
15904 self.graphtype.set(openfile.readline().rstrip()) | |
15905 self.allorone.set(int(openfile.readline().rstrip())) | |
15906 self.graphfile.set(openfile.readline().rstrip()) | |
15907 self.step.set(openfile.readline().rstrip()) | |
15908 self.windsize.set(openfile.readline().rstrip()) | |
15909 self.graphheight.set(openfile.readline().rstrip()) | |
15910 self.maxy.set(openfile.readline().rstrip()) | |
15911 self.logit.set(openfile.readline().rstrip()) | |
15912 self.histo.set(openfile.readline().rstrip()) | |
15913 self.graphlinet.set(openfile.readline().rstrip()) | |
15914 x = int(openfile.readline().rstrip()) | |
15915 y = int(openfile.readline().rstrip()) | |
15916 z = int(openfile.readline().rstrip()) | |
15917 self.poscol = (x, y, z) | |
15918 self.poscolhex = openfile.readline().rstrip() | |
15919 x = int(openfile.readline().rstrip()) | |
15920 y = int(openfile.readline().rstrip()) | |
15921 z = int(openfile.readline().rstrip()) | |
15922 self.negcol = (x, y, z) | |
15923 self.negcolhex = openfile.readline().rstrip() | |
15924 self.ggap.set(openfile.readline().rstrip()) | |
15925 openfile.close() | |
15926 except: | |
15927 tkMessageBox.showerror("Try again.", "Easyfig config file invalid.") | |
15928 | |
15929 def opendefault(self): | |
15930 try: | |
15931 if not os.path.exists(".easyfig.pref"): | |
15932 self.defaultpreferences() | |
15933 return | |
15934 preffile = open(".easyfig.pref") | |
15935 gotpref = False | |
15936 for line in preffile: | |
15937 if line.startswith(">"): | |
15938 preflist = line.split("\t")[1:] | |
15939 gotpref = True | |
15940 preffile.close() | |
15941 if not gotpref: | |
15942 self.defaultpreferences() | |
15943 return | |
15944 self.filetype.set(preflist.pop(0)) | |
15945 | |
15946 self.figwidthvar.set(preflist.pop(0)) | |
15947 self.height1var.set(preflist.pop(0)) | |
15948 self.height2var.set(preflist.pop(0)) | |
15949 self.aln.set(preflist.pop(0)) | |
15950 self.autodetect.set(int(preflist.pop(0))) | |
15951 self.drawfig1.set(int(preflist.pop(0))) | |
15952 self.drawfig2var.set(preflist.pop(0)) | |
15953 | |
15954 self.minlengthvar.set(preflist.pop(0)) | |
15955 self.minevalvar.set(preflist.pop(0)) | |
15956 self.minIdentvar.set(preflist.pop(0)) | |
15957 x = int(preflist.pop(0)) | |
15958 y = int(preflist.pop(0)) | |
15959 z = int(preflist.pop(0)) | |
15960 self.minblastc = (x, y, z) | |
15961 self.minblastchex = preflist.pop(0) | |
15962 x = int(preflist.pop(0)) | |
15963 y = int(preflist.pop(0)) | |
15964 z = int(preflist.pop(0)) | |
15965 self.minblastci = (x, y, z) | |
15966 self.minblastcihex = preflist.pop(0) | |
15967 x = int(preflist.pop(0)) | |
15968 y = int(preflist.pop(0)) | |
15969 z = int(preflist.pop(0)) | |
15970 self.maxblastc = (x, y, z) | |
15971 self.maxblastchex = preflist.pop(0) | |
15972 x = int(preflist.pop(0)) | |
15973 y = int(preflist.pop(0)) | |
15974 z = int(preflist.pop(0)) | |
15975 self.maxblastci = (x, y, z) | |
15976 self.maxblastcihex = preflist.pop(0) | |
15977 self.blastoutline.set(int(preflist.pop(0))) | |
15978 | |
15979 self.leg.set(preflist.pop(0)) | |
15980 self.leg2.set(preflist.pop(0)) | |
15981 self.legname.set(preflist.pop(0)) | |
15982 self.gltvar.set(preflist.pop(0)) | |
15983 self.exontvar.set(preflist.pop(0)) | |
15984 self.genetvar.set(preflist.pop(0)) | |
15985 | |
15986 self.genef.set(int(preflist.pop(0))) | |
15987 x = int(preflist.pop(0)) | |
15988 y = int(preflist.pop(0)) | |
15989 z = int(preflist.pop(0)) | |
15990 self.genefcolour = (x, y, z) | |
15991 self.genefcolourhex = preflist.pop(0) | |
15992 self.genefrect.set(preflist.pop(0)) | |
15993 | |
15994 self.cdsf.set(int(preflist.pop(0))) | |
15995 x = int(preflist.pop(0)) | |
15996 y = int(preflist.pop(0)) | |
15997 z = int(preflist.pop(0)) | |
15998 self.cdsfcolour = (x, y, z) | |
15999 self.cdsfcolourhex = preflist.pop(0) | |
16000 self.cdsfrect.set(preflist.pop(0)) | |
16001 | |
16002 self.trnaf.set(int(preflist.pop(0))) | |
16003 x = int(preflist.pop(0)) | |
16004 y = int(preflist.pop(0)) | |
16005 z = int(preflist.pop(0)) | |
16006 self.trnafcolour = (x, y, z) | |
16007 self.trnafcolourhex = preflist.pop(0) | |
16008 self.trnafrect.set(preflist.pop(0)) | |
16009 | |
16010 self.miscf.set(int(preflist.pop(0))) | |
16011 x = int(preflist.pop(0)) | |
16012 y = int(preflist.pop(0)) | |
16013 z = int(preflist.pop(0)) | |
16014 self.miscfcolour = (x, y, z) | |
16015 self.miscfcolourhex = preflist.pop(0) | |
16016 self.miscfrect.set(preflist.pop(0)) | |
16017 | |
16018 self.randfeat.set(preflist.pop(0)) | |
16019 self.randf.set(int(preflist.pop(0))) | |
16020 x = int(preflist.pop(0)) | |
16021 y = int(preflist.pop(0)) | |
16022 z = int(preflist.pop(0)) | |
16023 self.randfcolour = (x, y, z) | |
16024 self.randfcolourhex = preflist.pop(0) | |
16025 self.randfrect.set(preflist.pop(0)) | |
16026 | |
16027 self.graphtype.set(preflist.pop(0)) | |
16028 self.allorone.set(int(preflist.pop(0))) | |
16029 self.graphfile.set(preflist.pop(0)) | |
16030 self.step.set(preflist.pop(0)) | |
16031 self.windsize.set(preflist.pop(0)) | |
16032 self.graphheight.set(preflist.pop(0)) | |
16033 self.maxy.set(preflist.pop(0)) | |
16034 self.logit.set(preflist.pop(0)) | |
16035 self.histo.set(preflist.pop(0)) | |
16036 self.graphlinet.set(preflist.pop(0)) | |
16037 x = int(preflist.pop(0)) | |
16038 y = int(preflist.pop(0)) | |
16039 z = int(preflist.pop(0)) | |
16040 self.poscol = (x, y, z) | |
16041 self.poscolhex = preflist.pop(0) | |
16042 x = int(preflist.pop(0)) | |
16043 y = int(preflist.pop(0)) | |
16044 z = int(preflist.pop(0)) | |
16045 self.negcol = (x, y, z) | |
16046 self.negcolhex = preflist.pop(0) | |
16047 self.ggap.set(preflist.pop(0)) | |
16048 self.blastnDir = preflist.pop(0) | |
16049 if self.blastnDir == "None": | |
16050 self.blastnDir = None | |
16051 self.dbnDir = preflist.pop(0).rstrip() | |
16052 if self.dbnDir == "None": | |
16053 self.dbnDir = None | |
16054 except: | |
16055 self.defaultpreferences() | |
16056 | |
16057 def openhelpsite(self): | |
16058 webbrowser.open_new("https://github.com/mjsull/Easyfig/wiki") | |
16059 | |
16060 def openabout(self): | |
16061 try: | |
16062 self.aboutpanel.destroy() | |
16063 except: | |
16064 pass | |
16065 self.aboutpanel = Toplevel() | |
16066 self.frame7 = Frame(self.aboutpanel) | |
16067 self.about1label = Label( | |
16068 self.frame7, text="Easyfig", font="TkDefaultFont 13 bold" | |
16069 ) | |
16070 self.about1label.grid(row=0, column=0) | |
16071 self.about2label = Label( | |
16072 self.frame7, | |
16073 text="Easyfig is a Python application for creating linear\n\ | |
16074 comparison figures of multiple genomic loci\n with an easy-to-use graphical user interface (GUI).\n\n\ | |
16075 Version 2.2.3\n\nIf Easyfig is used to generate figures for publication,\n\ | |
16076 please cite our paper:\n\n\ | |
16077 Sullivan MJ, Petty NK, Beatson SA. (2011)\nEasyfig: a genome comparison visualiser.\nBioinformatics; 27 (7): 1009-1010", | |
16078 ) | |
16079 self.about2label.grid(row=1, column=0) | |
16080 self.frame7.grid(padx=10, pady=10) | |
16081 | |
16082 def supportwin(self): | |
16083 try: | |
16084 self.supportpanel.destroy() | |
16085 except: | |
16086 pass | |
16087 self.supportpanel = Toplevel() | |
16088 self.frame9 = Frame(self.supportpanel) | |
16089 self.about1label1 = Label( | |
16090 self.frame9, text="Easyfig", font="TkDefaultFont 13 bold" | |
16091 ) | |
16092 self.about1label1.grid(row=0, column=0) | |
16093 self.supportlabel2 = Label( | |
16094 self.frame9, | |
16095 text="written by Mitchell Sullivan - mjsull@gmail.com\n\ | |
16096 To submit a bug please visit https://github.com/mjsull/Easyfig/issues.", | |
16097 ) | |
16098 self.supportlabel2.grid(row=1, column=0) | |
16099 self.frame9.grid(padx=10, pady=10) | |
16100 | |
16101 def preferencewindow(self): | |
16102 try: | |
16103 self.prefwin.destroy() | |
16104 except: | |
16105 pass | |
16106 self.prefwin = Toplevel() | |
16107 self.frame8 = Frame(self.prefwin) | |
16108 self.prefwin.title("preferences") | |
16109 self.scrollbar3 = Scrollbar(self.frame8) | |
16110 self.preflist = Listbox(self.frame8, yscrollcommand=self.scrollbar3.set) | |
16111 templist = ["easyfig_standard"] | |
16112 validfile = True | |
16113 if os.path.exists(".easyfig.pref"): | |
16114 preffile = open(".easyfig.pref") | |
16115 for line in preffile: | |
16116 if len(line.split("\t")) == 87: | |
16117 templist.append(line.split("\t")[0]) | |
16118 else: | |
16119 validfile = False | |
16120 if not validfile: | |
16121 nocompare = tkMessageBox.askquestion( | |
16122 "Preference file not valid", | |
16123 "Do you wish to create a new preference file at " | |
16124 + os.getcwd() | |
16125 + "/.easyfig.pref?", | |
16126 parent=self.frame8, | |
16127 ) | |
16128 if nocompare == "no": | |
16129 return | |
16130 else: | |
16131 preffile = open(".easyfig.pref", "w") | |
16132 preffile.close() | |
16133 templist.sort(key=str.lower) | |
16134 for i in templist: | |
16135 self.preflist.insert(END, i) | |
16136 self.preflist.grid(column=1, row=0, rowspan=10) | |
16137 self.scrollbar3.config(command=self.preflist.yview) | |
16138 self.scrollbar3.grid(column=0, row=0, rowspan=10, sticky=NS) | |
16139 self.addprefbut = Button( | |
16140 self.frame8, text="Save preferences as", command=self.addpref | |
16141 ) | |
16142 self.addprefbut.grid(column=2, row=0, sticky=EW) | |
16143 self.loadprefbut = Button( | |
16144 self.frame8, text="Load preferences", command=self.loadpref | |
16145 ) | |
16146 self.loadprefbut.grid(column=2, row=1, sticky=EW) | |
16147 self.removeprefbut = Button(self.frame8, text="Remove", command=self.removepref) | |
16148 self.removeprefbut.grid(column=2, row=2, sticky=EW) | |
16149 self.setdefaultbut = Button( | |
16150 self.frame8, text="Set as default", command=self.setdefault | |
16151 ) | |
16152 self.setdefaultbut.grid(column=2, row=3, sticky=EW) | |
16153 self.closeprefwinbut = Button( | |
16154 self.frame8, text="close", command=self.closeprefwin | |
16155 ) | |
16156 self.closeprefwinbut.grid(column=2, row=9, sticky=E) | |
16157 self.frame8.grid(padx=20, pady=20) | |
16158 | |
16159 def addpref(self): | |
16160 preffile = open(".easyfig.pref", "a") | |
16161 savename = tkSimpleDialog.askstring( | |
16162 "Input name", | |
16163 "Please choose name to save preferences under.", | |
16164 parent=self.frame8, | |
16165 ) | |
16166 if savename == None: | |
16167 return None | |
16168 while savename in self.preflist.get(0, END): | |
16169 savename = tkSimpleDialog.askstring( | |
16170 "Name taken", | |
16171 "Please choose name to save preferences under.", | |
16172 parent=self.frame8, | |
16173 ) | |
16174 if savename == None: | |
16175 return None | |
16176 savestring = savename + "\t" | |
16177 savestring += self.filetype.get() + "\t" | |
16178 savestring += self.figwidthvar.get() + "\t" | |
16179 savestring += self.height1var.get() + "\t" | |
16180 savestring += self.height2var.get() + "\t" | |
16181 savestring += self.aln.get() + "\t" | |
16182 savestring += str(self.autodetect.get()) + "\t" | |
16183 savestring += str(self.drawfig1.get()) + "\t" | |
16184 savestring += self.drawfig2var.get() + "\t" | |
16185 savestring += self.minlengthvar.get() + "\t" | |
16186 savestring += self.minevalvar.get() + "\t" | |
16187 savestring += self.minIdentvar.get() + "\t" | |
16188 savestring += str(self.minblastc[0]) + "\t" | |
16189 savestring += str(self.minblastc[1]) + "\t" | |
16190 savestring += str(self.minblastc[2]) + "\t" | |
16191 savestring += self.minblastchex + "\t" | |
16192 savestring += str(self.minblastci[0]) + "\t" | |
16193 savestring += str(self.minblastci[1]) + "\t" | |
16194 savestring += str(self.minblastci[2]) + "\t" | |
16195 savestring += self.minblastcihex + "\t" | |
16196 savestring += str(self.maxblastc[0]) + "\t" | |
16197 savestring += str(self.maxblastc[1]) + "\t" | |
16198 savestring += str(self.maxblastc[2]) + "\t" | |
16199 savestring += self.maxblastchex + "\t" | |
16200 savestring += str(self.maxblastci[0]) + "\t" | |
16201 savestring += str(self.maxblastci[1]) + "\t" | |
16202 savestring += str(self.maxblastci[2]) + "\t" | |
16203 savestring += self.maxblastcihex + "\t" | |
16204 savestring += str(self.blastoutline.get()) + "\t" | |
16205 savestring += self.leg.get() + "\t" | |
16206 savestring += self.leg2.get() + "\t" | |
16207 savestring += self.legname.get() + "\t" | |
16208 savestring += self.gltvar.get() + "\t" | |
16209 savestring += self.exontvar.get() + "\t" | |
16210 savestring += self.genetvar.get() + "\t" | |
16211 savestring += str(self.genef.get()) + "\t" | |
16212 savestring += str(self.genefcolour[0]) + "\t" | |
16213 savestring += str(self.genefcolour[1]) + "\t" | |
16214 savestring += str(self.genefcolour[2]) + "\t" | |
16215 savestring += self.genefcolourhex + "\t" | |
16216 savestring += self.genefrect.get() + "\t" | |
16217 savestring += str(self.cdsf.get()) + "\t" | |
16218 savestring += str(self.cdsfcolour[0]) + "\t" | |
16219 savestring += str(self.cdsfcolour[1]) + "\t" | |
16220 savestring += str(self.cdsfcolour[2]) + "\t" | |
16221 savestring += self.cdsfcolourhex + "\t" | |
16222 savestring += self.cdsfrect.get() + "\t" | |
16223 savestring += str(self.trnaf.get()) + "\t" | |
16224 savestring += str(self.trnafcolour[0]) + "\t" | |
16225 savestring += str(self.trnafcolour[1]) + "\t" | |
16226 savestring += str(self.trnafcolour[2]) + "\t" | |
16227 savestring += self.trnafcolourhex + "\t" | |
16228 savestring += self.trnafrect.get() + "\t" | |
16229 savestring += str(self.miscf.get()) + "\t" | |
16230 savestring += str(self.miscfcolour[0]) + "\t" | |
16231 savestring += str(self.miscfcolour[1]) + "\t" | |
16232 savestring += str(self.miscfcolour[2]) + "\t" | |
16233 savestring += self.miscfcolourhex + "\t" | |
16234 savestring += self.miscfrect.get() + "\t" | |
16235 savestring += self.randfeat.get() + "\t" | |
16236 savestring += str(self.randf.get()) + "\t" | |
16237 savestring += str(self.randfcolour[0]) + "\t" | |
16238 savestring += str(self.randfcolour[1]) + "\t" | |
16239 savestring += str(self.randfcolour[2]) + "\t" | |
16240 savestring += self.randfcolourhex + "\t" | |
16241 savestring += self.randfrect.get() + "\t" | |
16242 savestring += self.graphtype.get() + "\t" | |
16243 savestring += str(self.allorone.get()) + "\t" | |
16244 savestring += self.graphfile.get() + "\t" | |
16245 savestring += self.step.get() + "\t" | |
16246 savestring += self.windsize.get() + "\t" | |
16247 savestring += self.graphheight.get() + "\t" | |
16248 savestring += self.maxy.get() + "\t" | |
16249 savestring += str(self.logit.get()) + "\t" | |
16250 savestring += self.histo.get() + "\t" | |
16251 savestring += self.graphlinet.get() + "\t" | |
16252 savestring += str(self.poscol[0]) + "\t" | |
16253 savestring += str(self.poscol[1]) + "\t" | |
16254 savestring += str(self.poscol[2]) + "\t" | |
16255 savestring += self.poscolhex + "\t" | |
16256 savestring += str(self.negcol[0]) + "\t" | |
16257 savestring += str(self.negcol[1]) + "\t" | |
16258 savestring += str(self.negcol[2]) + "\t" | |
16259 savestring += self.negcolhex + "\t" | |
16260 savestring += self.ggap.get() + "\t" | |
16261 if self.blastnDir == None: | |
16262 savestring += "None\t" | |
16263 else: | |
16264 savestring += self.blastnDir + "\t" | |
16265 if self.dbnDir == None: | |
16266 savestring += "None\n" | |
16267 else: | |
16268 savestring += self.dbnDir + "\n" | |
16269 if savestring.count("\t") == 86: | |
16270 if savestring.startswith(">"): | |
16271 tkMessageBox.showerror( | |
16272 "Try again.", "Please remove > from start of preference name." | |
16273 ) | |
16274 else: | |
16275 preffile.write(savestring) | |
16276 self.preflist.insert(END, savename) | |
16277 else: | |
16278 tkMessageBox.showerror( | |
16279 "Try again.", "<tab> character in variable, please remove." | |
16280 ) | |
16281 preffile.close() | |
16282 | |
16283 def loadpref(self): | |
16284 try: | |
16285 prefname = self.preflist.get(ACTIVE) | |
16286 if prefname == "easyfig_standard": | |
16287 self.defaultpreferences() | |
16288 return | |
16289 if not os.path.exists(".easyfig.pref"): | |
16290 tkMessageBox.showerror("Try again.", "Where'd the preference file go?") | |
16291 return | |
16292 preffile = open(".easyfig.pref") | |
16293 for line in preffile: | |
16294 splitline = line.split("\t") | |
16295 if splitline[0] == prefname: | |
16296 preflist = splitline[1:] | |
16297 preffile.close() | |
16298 self.filetype.set(preflist.pop(0)) | |
16299 | |
16300 self.figwidthvar.set(preflist.pop(0)) | |
16301 self.height1var.set(preflist.pop(0)) | |
16302 self.height2var.set(preflist.pop(0)) | |
16303 self.aln.set(preflist.pop(0)) | |
16304 self.autodetect.set(int(preflist.pop(0))) | |
16305 self.drawfig1.set(int(preflist.pop(0))) | |
16306 self.drawfig2var.set(preflist.pop(0)) | |
16307 | |
16308 self.minlengthvar.set(preflist.pop(0)) | |
16309 self.minevalvar.set(preflist.pop(0)) | |
16310 self.minIdentvar.set(preflist.pop(0)) | |
16311 x = int(preflist.pop(0)) | |
16312 y = int(preflist.pop(0)) | |
16313 z = int(preflist.pop(0)) | |
16314 self.minblastc = (x, y, z) | |
16315 self.minblastchex = preflist.pop(0) | |
16316 x = int(preflist.pop(0)) | |
16317 y = int(preflist.pop(0)) | |
16318 z = int(preflist.pop(0)) | |
16319 self.minblastci = (x, y, z) | |
16320 self.minblastcihex = preflist.pop(0) | |
16321 x = int(preflist.pop(0)) | |
16322 y = int(preflist.pop(0)) | |
16323 z = int(preflist.pop(0)) | |
16324 self.maxblastc = (x, y, z) | |
16325 self.maxblastchex = preflist.pop(0) | |
16326 x = int(preflist.pop(0)) | |
16327 y = int(preflist.pop(0)) | |
16328 z = int(preflist.pop(0)) | |
16329 self.maxblastci = (x, y, z) | |
16330 self.maxblastcihex = preflist.pop(0) | |
16331 self.blastoutline.set(int(preflist.pop(0))) | |
16332 | |
16333 self.leg.set(preflist.pop(0)) | |
16334 self.leg2.set(preflist.pop(0)) | |
16335 self.legname.set(preflist.pop(0)) | |
16336 self.gltvar.set(preflist.pop(0)) | |
16337 self.exontvar.set(preflist.pop(0)) | |
16338 self.genetvar.set(preflist.pop(0)) | |
16339 | |
16340 self.genef.set(int(preflist.pop(0))) | |
16341 x = int(preflist.pop(0)) | |
16342 y = int(preflist.pop(0)) | |
16343 z = int(preflist.pop(0)) | |
16344 self.genefcolour = (x, y, z) | |
16345 self.genefcolourhex = preflist.pop(0) | |
16346 self.genefrect.set(preflist.pop(0)) | |
16347 | |
16348 self.cdsf.set(int(preflist.pop(0))) | |
16349 x = int(preflist.pop(0)) | |
16350 y = int(preflist.pop(0)) | |
16351 z = int(preflist.pop(0)) | |
16352 self.cdsfcolour = (x, y, z) | |
16353 self.cdsfcolourhex = preflist.pop(0) | |
16354 self.cdsfrect.set(preflist.pop(0)) | |
16355 | |
16356 self.trnaf.set(int(preflist.pop(0))) | |
16357 x = int(preflist.pop(0)) | |
16358 y = int(preflist.pop(0)) | |
16359 z = int(preflist.pop(0)) | |
16360 self.trnafcolour = (x, y, z) | |
16361 self.trnafcolourhex = preflist.pop(0) | |
16362 self.trnafrect.set(preflist.pop(0)) | |
16363 | |
16364 self.miscf.set(int(preflist.pop(0))) | |
16365 x = int(preflist.pop(0)) | |
16366 y = int(preflist.pop(0)) | |
16367 z = int(preflist.pop(0)) | |
16368 self.miscfcolour = (x, y, z) | |
16369 self.miscfcolourhex = preflist.pop(0) | |
16370 self.miscfrect.set(preflist.pop(0)) | |
16371 | |
16372 self.randfeat.set(preflist.pop(0)) | |
16373 self.randf.set(int(preflist.pop(0))) | |
16374 x = int(preflist.pop(0)) | |
16375 y = int(preflist.pop(0)) | |
16376 z = int(preflist.pop(0)) | |
16377 self.randfcolour = (x, y, z) | |
16378 self.randfcolourhex = preflist.pop(0) | |
16379 self.randfrect.set(preflist.pop(0)) | |
16380 | |
16381 self.graphtype.set(preflist.pop(0)) | |
16382 self.allorone.set(int(preflist.pop(0))) | |
16383 self.graphfile.set(preflist.pop(0)) | |
16384 self.step.set(preflist.pop(0)) | |
16385 self.windsize.set(preflist.pop(0)) | |
16386 self.graphheight.set(preflist.pop(0)) | |
16387 self.maxy.set(preflist.pop(0)) | |
16388 self.logit.set(preflist.pop(0)) | |
16389 self.histo.set(preflist.pop(0)) | |
16390 self.graphlinet.set(preflist.pop(0)) | |
16391 x = int(preflist.pop(0)) | |
16392 y = int(preflist.pop(0)) | |
16393 z = int(preflist.pop(0)) | |
16394 self.poscol = (x, y, z) | |
16395 self.poscolhex = preflist.pop(0) | |
16396 x = int(preflist.pop(0)) | |
16397 y = int(preflist.pop(0)) | |
16398 z = int(preflist.pop(0)) | |
16399 self.negcol = (x, y, z) | |
16400 self.negcolhex = preflist.pop(0) | |
16401 self.ggap.set(preflist.pop(0)) | |
16402 self.blastnDir = preflist.pop(0) | |
16403 if self.blastnDir == "None": | |
16404 self.blastnDir = None | |
16405 self.dbnDir = preflist.pop(0).rstrip() | |
16406 if self.dbnDir == "None": | |
16407 self.dbnDir = None | |
16408 except: | |
16409 self.defaultpreferences() | |
16410 tkMessageBox.showerror( | |
16411 "Preference File Invalid", "Loaded default preferences." | |
16412 ) | |
16413 nocompare = tkMessageBox.askquestion( | |
16414 "Preference file not valid", | |
16415 "Do you wish to create a new preference file at " | |
16416 + os.getcwd() | |
16417 + "/.easyfig.pref?", | |
16418 parent=self.frame8, | |
16419 ) | |
16420 if nocompare == "no": | |
16421 return | |
16422 else: | |
16423 preffile = open(".easyfig.pref", "w") | |
16424 preffile.close() | |
16425 self.preflist.delete(0, END) | |
16426 self.preflist.insert("easyfig_standard") | |
16427 | |
16428 def removepref(self): | |
16429 nocompare = tkMessageBox.askquestion( | |
16430 "Delete?", | |
16431 "Are you sure you wish to delete this preference?", | |
16432 parent=self.frame8, | |
16433 ) | |
16434 if nocompare == "no": | |
16435 return | |
16436 preffile = open(".easyfig.pref") | |
16437 preflist = [] | |
16438 prefname = self.preflist.get(ACTIVE) | |
16439 self.preflist.delete(ACTIVE) | |
16440 for line in preffile: | |
16441 if not line.split("\t")[0] == prefname: | |
16442 preflist.append(line) | |
16443 preffile.close() | |
16444 preffile = open(".easyfig.pref", "w") | |
16445 for i in preflist: | |
16446 preffile.write(i) | |
16447 preffile.close() | |
16448 | |
16449 def setdefault(self): | |
16450 preffile = open(".easyfig.pref") | |
16451 preflist = [] | |
16452 prefname = self.preflist.get(ACTIVE) | |
16453 if prefname.startswith(">"): | |
16454 return | |
16455 templist = [] | |
16456 for line in preffile: | |
16457 if line.startswith(">"): | |
16458 line = line[1:] | |
16459 elif line.split("\t")[0] == prefname: | |
16460 line = ">" + line | |
16461 templist.append(line.split("\t")[0]) | |
16462 preflist.append(line) | |
16463 preffile.close() | |
16464 preffile = open(".easyfig.pref", "w") | |
16465 for i in preflist: | |
16466 preffile.write(i) | |
16467 self.preflist.delete(0, END) | |
16468 templist.append("easyfig_standard") | |
16469 templist.sort(key=str.lower) | |
16470 for i in templist: | |
16471 self.preflist.insert(END, i) | |
16472 preffile.close() | |
16473 | |
16474 def closeprefwin(self): | |
16475 self.prefwin.destroy() | |
16476 | |
16477 def openref(self): | |
16478 webbrowser.open_new("http://www.ncbi.nlm.nih.gov/pubmed/21278367") | |
16479 | |
16480 def pickposcol(self): | |
16481 colour = tkColorChooser.askcolor(self.poscol, parent=self.graphoptionswindow) | |
16482 if colour != None: | |
16483 self.poscol = colour[0] | |
16484 self.poscolhex = colour[1] | |
16485 self.poscollabel.configure(bg=colour[1]) | |
16486 | |
16487 def picknegcol(self): | |
16488 colour = tkColorChooser.askcolor(self.negcol, parent=self.graphoptionswindow) | |
16489 if colour != None: | |
16490 self.negcol = colour[0] | |
16491 self.negcolhex = colour[1] | |
16492 self.negcollabel.configure(bg=colour[1]) | |
16493 | |
16494 def getGCcontent(self, filename, mincut, maxcut): | |
16495 try: | |
16496 gen = open(filename) | |
16497 getseq = False | |
16498 getembl = False | |
16499 seq = "" | |
16500 for line in gen: | |
16501 if line.startswith("ORIGIN"): | |
16502 getseq = True | |
16503 elif line.startswith("SQ Sequence"): | |
16504 getembl = True | |
16505 elif line.startswith("//"): | |
16506 getseq = False | |
16507 getembl = False | |
16508 elif getseq: | |
16509 seq += "".join(line.split()[1:]) | |
16510 elif getembl: | |
16511 seq += "".join(line.split()[:-1]) | |
16512 gen.close() | |
16513 seq = seq.upper() | |
16514 except: | |
16515 tkMessageBox.showerror( | |
16516 "Try again.", | |
16517 "feature file " + filename + " not valid, or does not exist.", | |
16518 ) | |
16519 return None | |
16520 if len(seq) == 0: | |
16521 tkMessageBox.showerror( | |
16522 "Try again.", "Sequence not found in feature file " + filename + "." | |
16523 ) | |
16524 return None | |
16525 if maxcut == "Max": | |
16526 seq = seq[int(mincut) - 1 :] | |
16527 elif int(maxcut) <= int(mincut): | |
16528 seq = seq[int(mincut) - 1 :] + seq[: int(maxcut) + 1] | |
16529 else: | |
16530 seq = seq[int(mincut) - 1 : int(maxcut) + 1] | |
16531 window1 = int(self.windsize.get()) / 2 | |
16532 window2 = int(self.windsize.get()) - window1 | |
16533 thearray = [] | |
16534 for i in range(0, len(seq), int(self.step.get())): | |
16535 seqstring = seq[max([0, i - window1]) : i + window2] | |
16536 thearray.append( | |
16537 (seqstring.count("G") + seqstring.count("C")) * 1.0 / len(seqstring) | |
16538 - 0.5 | |
16539 ) | |
16540 return thearray | |
16541 | |
16542 def getGCskew(self, filename, mincut, maxcut): | |
16543 try: | |
16544 getseq = False | |
16545 getembl = False | |
16546 seq = "" | |
16547 gen = open(filename) | |
16548 for line in gen: | |
16549 if line.startswith("ORIGIN"): | |
16550 getseq = True | |
16551 elif line.startswith("SQ Sequence"): | |
16552 getembl = True | |
16553 elif line.startswith("//"): | |
16554 getseq = False | |
16555 getembl = False | |
16556 elif getseq: | |
16557 seq += "".join(line.split()[1:]) | |
16558 elif getembl: | |
16559 seq += "".join(line.split()[:-1]) | |
16560 gen.close() | |
16561 seq = seq.upper() | |
16562 except: | |
16563 tkMessageBox.showerror( | |
16564 "Try again.", | |
16565 "feature file " + filename + " not valid, or does not exist.", | |
16566 ) | |
16567 return None | |
16568 if len(seq) == 0: | |
16569 tkMessageBox.showerror( | |
16570 "Try again.", "Sequence not found in feature file " + filename + "." | |
16571 ) | |
16572 return None | |
16573 window1 = int(self.windsize.get()) / 2 | |
16574 window2 = int(self.windsize.get()) - window1 | |
16575 if maxcut == "Max": | |
16576 seq = seq[int(mincut) - 1 :] | |
16577 elif int(maxcut) <= int(mincut): | |
16578 seq = seq[int(mincut) - 1 :] + seq[: int(maxcut) + 1] | |
16579 else: | |
16580 seq = seq[int(mincut) - 1 : int(maxcut) + 1] | |
16581 thearray = [] | |
16582 for i in range(0, len(seq), int(self.step.get())): | |
16583 seqstring = seq[max([0, i - window1]) : i + window2] | |
16584 gcount = seqstring.count("G") | |
16585 ccount = seqstring.count("C") | |
16586 try: | |
16587 thearray.append((gcount - ccount) * 1.0 / (gcount + ccount)) | |
16588 except: | |
16589 thearray.append(0) | |
16590 return thearray | |
16591 | |
16592 def getCoverage(self): | |
16593 # DEFNIITION: takes a file and reads in all contigs, their start positions and the reads located within the contig | |
16594 # REQUIRES: a valid ace file | |
16595 # RETURNS: A list of objects of class contig | |
16596 seq = "" | |
16597 getseq = False | |
16598 getembl = False | |
16599 try: | |
16600 gen = open(self.gen1.get()) | |
16601 for line in gen: | |
16602 if line.startswith("ORIGIN"): | |
16603 getseq = True | |
16604 elif line.startswith("SQ Sequence"): | |
16605 getembl = True | |
16606 elif line.startswith("//"): | |
16607 getseq = False | |
16608 getembl = False | |
16609 elif getseq: | |
16610 seq += "".join(line.split()[1:]) | |
16611 elif getembl: | |
16612 seq += "".join(line.split()[:-1]) | |
16613 gen.close() | |
16614 except: | |
16615 tkMessageBox.showerror( | |
16616 "Try again.", "feature file not valid, or does not exist." | |
16617 ) | |
16618 return None | |
16619 if len(seq) == 0: | |
16620 tkMessageBox.showerror("Try again.", "Sequence not found in feature file.") | |
16621 return None | |
16622 seq = seq.lower() | |
16623 if self.gen1maxcut.get() == "Max": | |
16624 seq = seq[int(self.gen1mincut.get()) - 1 :] | |
16625 elif int(self.gen1maxcut) <= int(self.gen1mincut): | |
16626 seq = seq[int(self.gen1mincut) - 1 :] + seq[: int(self.gen1maxcut) + 1] | |
16627 else: | |
16628 seq = seq[int(self.gen1mincut.get()) - 1 : (self.gen1maxcut.get()) + 1] | |
16629 outlist = [0 for i in range(len(seq))] | |
16630 readlist = [] # list of reads to be added to the contig class | |
16631 index = 0 # switches to 1 once program has dealt with the initial contig | |
16632 # iterates through the file determines what information is contained in each line then reads it to the | |
16633 # right locationregular expressions python | |
16634 transtab = string.maketrans("atgc", "tacg") | |
16635 for line in file: | |
16636 # puts name in file and starts reading sequence below | |
16637 if line.startswith("CO "): | |
16638 if index != 0: | |
16639 freqDict = {} | |
16640 for j in readlist: | |
16641 for k in range(j.startpos, (j.startpos + j.readLength)): | |
16642 if k in freqDict: | |
16643 freqDict[k] += 1 | |
16644 else: | |
16645 freqDict[k] = 1 | |
16646 coverageList = [] | |
16647 for j in range(1, len(contigSeq) + 1): | |
16648 if contigSeq[j - 1] != "*": | |
16649 coverageList.append(freqDict[j]) | |
16650 contigSeq = contigSeq.lower() | |
16651 thepos = seq.find(contigSeq) | |
16652 if thepos != -1: | |
16653 outlist = ( | |
16654 outlist[:thepos] | |
16655 + coverageList | |
16656 + outlist[thepos + len(coverageList) :] | |
16657 ) | |
16658 else: | |
16659 contigSeq = contigSeq[::-1] | |
16660 contigSeq = contigSeq.translate(transtab) | |
16661 thepos = seq.find(contigSeq) | |
16662 if thepos != -1: | |
16663 coverageList.reverse() | |
16664 outlist = ( | |
16665 outlist[:thepos] | |
16666 + coverageList | |
16667 + outlist[thepos + len(coverageList) :] | |
16668 ) | |
16669 readlist = [] | |
16670 index = 1 | |
16671 contigSeq = "" | |
16672 contigName = line.split()[ | |
16673 1 | |
16674 ] # splits the line into a list with elements seperated by whitespace characters | |
16675 # then returns the second element of that list (the name) | |
16676 readnumber = 0 # initiates the read number used to determine where the readsequence will be added | |
16677 # creates a object of class read with the name and location within the contig, leaves sequence as the | |
16678 # empty string to be read in later | |
16679 elif line.startswith("BQ"): | |
16680 index = 2 | |
16681 elif line.startswith("AF "): | |
16682 readIt = ( | |
16683 line.split() | |
16684 ) # splits the line into a list of strings seperated by whitespace characters | |
16685 readName = readIt[1] # the name of the read | |
16686 readPos = int(readIt[3]) # the position of the read within the contig | |
16687 readInstance = read( | |
16688 readName, readPos, None | |
16689 ) # creates an instance of class read | |
16690 readlist.append(readInstance) # appends to list | |
16691 elif index == 1: | |
16692 contigSeq += line[:-1] | |
16693 elif line.startswith("QA "): | |
16694 readlist[readnumber].startpos = ( | |
16695 readlist[readnumber].startpos + int(line.split()[1]) - 1 | |
16696 ) | |
16697 readlist[readnumber].readLength = ( | |
16698 int(line.split()[2]) - int(line.split()[1]) + 1 | |
16699 ) | |
16700 readnumber += 1 | |
16701 freqDict = {} | |
16702 for j in readlist: | |
16703 for k in range(j.startpos, (j.startpos + j.readLength)): | |
16704 if k in freqDict: | |
16705 freqDict[k] += 1 | |
16706 else: | |
16707 freqDict[k] = 1 | |
16708 coverageList = [] | |
16709 for j in range(1, len(contigSeq) + 1): | |
16710 if contigSeq[j - 1] != "*": | |
16711 coverageList.append(freqDict[j]) | |
16712 contigSeq = contigSeq.lower() | |
16713 thepos = seq.find(contigSeq) | |
16714 if thepos != -1: | |
16715 outlist = ( | |
16716 outlist[:thepos] + coverageList + outlist[thepos + len(coverageList) :] | |
16717 ) | |
16718 else: | |
16719 contigSeq = contigSeq[::-1] | |
16720 contigSeq = contigSeq.translate(transtab) | |
16721 thepos = seq.find(contigSeq) | |
16722 if thepos != -1: | |
16723 coverageList.reverse() | |
16724 outlist = ( | |
16725 outlist[:thepos] | |
16726 + coverageList | |
16727 + outlist[thepos + len(coverageList) :] | |
16728 ) | |
16729 return outlist | |
16730 | |
16731 def getCustom(self): | |
16732 try: | |
16733 thearray = [] | |
16734 gen = open(self.graphfile.get()) | |
16735 templine = gen.readline().rstrip().split("\t") | |
16736 linelen = len(templine) | |
16737 for i in templine: | |
16738 thearray.append([float(i)]) | |
16739 for line in gen: | |
16740 templine = line.rstrip().split("\t") | |
16741 for i in range(len(templine)): | |
16742 if templine[i] != "": | |
16743 thearray[i].append(float(templine[i])) | |
16744 return thearray | |
16745 except: | |
16746 tkMessageBox.showerror( | |
16747 "Try again.", "graph file not valid, or does not exist." | |
16748 ) | |
16749 return None | |
16750 | |
16751 def graphtypechanges(self, something): | |
16752 if something == "None": | |
16753 self.alloroneentry.config(state=DISABLED) | |
16754 self.graphfileentry.config(state=DISABLED) | |
16755 self.graphfilebut.config(state=DISABLED) | |
16756 self.stepentry.config(state=DISABLED) | |
16757 self.windsizeentry.config(state=DISABLED) | |
16758 self.graphheightentry.config(state=DISABLED) | |
16759 self.maxyentry.config(state=DISABLED) | |
16760 self.histoentry.config(state=DISABLED) | |
16761 self.graphlinetentry.config(state=DISABLED) | |
16762 self.poscolbutton.config(state=DISABLED) | |
16763 self.negcolbutton.config(state=DISABLED) | |
16764 self.logitbut.config(state=DISABLED) | |
16765 self.ggapentry.config(state=DISABLED) | |
16766 elif something == "GC Content": | |
16767 self.alloroneentry.config(state=NORMAL) | |
16768 self.graphfileentry.config(state=DISABLED) | |
16769 self.graphfilebut.config(state=DISABLED) | |
16770 self.stepentry.config(state=NORMAL) | |
16771 self.windsizeentry.config(state=NORMAL) | |
16772 self.graphheightentry.config(state=NORMAL) | |
16773 self.maxyentry.config(state=NORMAL) | |
16774 self.histoentry.config(state=NORMAL) | |
16775 self.graphlinetentry.config(state=NORMAL) | |
16776 self.poscolbutton.config(state=NORMAL) | |
16777 self.negcolbutton.config(state=NORMAL) | |
16778 self.logitbut.config(state=DISABLED) | |
16779 self.ggapentry.config(state=NORMAL) | |
16780 elif something == "GC Skew": | |
16781 self.alloroneentry.config(state=NORMAL) | |
16782 self.graphfileentry.config(state=DISABLED) | |
16783 self.graphfilebut.config(state=DISABLED) | |
16784 self.stepentry.config(state=NORMAL) | |
16785 self.windsizeentry.config(state=NORMAL) | |
16786 self.graphheightentry.config(state=NORMAL) | |
16787 self.maxyentry.config(state=NORMAL) | |
16788 self.histoentry.config(state=NORMAL) | |
16789 self.graphlinetentry.config(state=NORMAL) | |
16790 self.poscolbutton.config(state=NORMAL) | |
16791 self.negcolbutton.config(state=NORMAL) | |
16792 self.logitbut.config(state=DISABLED) | |
16793 self.ggapentry.config(state=NORMAL) | |
16794 elif something == "Coverage": | |
16795 self.alloroneentry.config(state=DISABLED) | |
16796 self.graphfileentry.config(state=NORMAL) | |
16797 self.graphfilebut.config(state=NORMAL) | |
16798 self.stepentry.config(state=DISABLED) | |
16799 self.windsizeentry.config(state=NORMAL) | |
16800 self.graphheightentry.config(state=NORMAL) | |
16801 self.maxyentry.config(state=NORMAL) | |
16802 self.histoentry.config(state=NORMAL) | |
16803 self.graphlinetentry.config(state=NORMAL) | |
16804 self.poscolbutton.config(state=NORMAL) | |
16805 self.negcolbutton.config(state=DISABLED) | |
16806 self.logitbut.config(state=NORMAL) | |
16807 self.ggapentry.config(state=NORMAL) | |
16808 elif something == "Custom": | |
16809 self.alloroneentry.config(state=NORMAL) | |
16810 self.graphfileentry.config(state=NORMAL) | |
16811 self.graphfilebut.config(state=NORMAL) | |
16812 self.stepentry.config(state=DISABLED) | |
16813 self.windsizeentry.config(state=DISABLED) | |
16814 self.graphheightentry.config(state=NORMAL) | |
16815 self.maxyentry.config(state=NORMAL) | |
16816 self.histoentry.config(state=NORMAL) | |
16817 self.graphlinetentry.config(state=NORMAL) | |
16818 self.poscolbutton.config(state=NORMAL) | |
16819 self.negcolbutton.config(state=NORMAL) | |
16820 self.logitbut.config(state=NORMAL) | |
16821 self.ggapentry.config(state=NORMAL) | |
16822 | |
16823 def figureoptions(self): | |
16824 try: | |
16825 self.figureoptionswindow.destroy() | |
16826 except: | |
16827 pass | |
16828 self.figureoptionswindow = Toplevel() | |
16829 self.figureoptionswindow.title("Figure") | |
16830 self.frame2 = Frame(self.figureoptionswindow) | |
16831 self.mainoptionslab = Label( | |
16832 self.frame2, text="Figure Options", font="TkDefaultFont 13 bold underline" | |
16833 ) | |
16834 self.mainoptionslab.grid(row=0, column=0) | |
16835 self.figwidthlabel = Label(self.frame2, text="Width of Figure (pixels):") | |
16836 self.figwidthlabel.grid(row=1, column=0) | |
16837 self.figwidthentry = Entry(self.frame2, textvariable=self.figwidthvar) | |
16838 self.figwidthentry.grid(row=1, column=1) | |
16839 self.gltlabel = Label(self.frame2, text="Thickness of genome line:") | |
16840 self.gltlabel.grid(row=2, column=0) | |
16841 self.gltentry = Entry(self.frame2, textvariable=self.gltvar) | |
16842 self.gltentry.grid(row=2, column=1) | |
16843 self.height1label = Label(self.frame2, text="Height of genes in figure:") | |
16844 self.height1label.grid(row=3, column=0) | |
16845 self.height1entry = Entry(self.frame2, textvariable=self.height1var) | |
16846 self.height1entry.grid(row=3, column=1) | |
16847 self.height2label = Label(self.frame2, text="Height of Blast hits in figure:") | |
16848 self.height2label.grid(row=4, column=0) | |
16849 self.height2entry = Entry(self.frame2, textvariable=self.height2var) | |
16850 self.height2entry.grid(row=4, column=1) | |
16851 self.alnlabel = Label(self.frame2, text="Alignment of genomes:") | |
16852 self.alnlabel.grid(row=5, column=0) | |
16853 self.alnentry = OptionMenu( | |
16854 self.frame2, self.aln, "left", "centre", "right", "best blast" | |
16855 ) | |
16856 self.alnentry.config(width=5) | |
16857 self.alnentry.grid(row=5, column=1, sticky=EW) | |
16858 self.legendoptionslab = Label( | |
16859 self.frame2, text="Legend Options", font="TkDefaultFont 13 bold" | |
16860 ) | |
16861 self.legendoptionslab.grid(row=6, column=0) | |
16862 self.drawfig1label = Label(self.frame2, text="Draw Blast identity legend?") | |
16863 self.drawfig1label.grid(row=7, column=0) | |
16864 self.drawfig1entry = Checkbutton(self.frame2, variable=self.drawfig1) | |
16865 self.drawfig1entry.grid(row=7, column=1) | |
16866 self.drawfig2label = Label( | |
16867 self.frame2, text="Length of scale legend (in base pairs):" | |
16868 ) | |
16869 self.drawfig2label.grid(row=8, column=0) | |
16870 self.drawfig2entry = Entry(self.frame2, textvariable=self.drawfig2var) | |
16871 self.drawfig2entry.grid(row=8, column=1) | |
16872 self.leg2label = Label(self.frame2, text="Feature Legend:") | |
16873 self.leg2label.grid(row=9, column=0) | |
16874 self.leg2entry = OptionMenu( | |
16875 self.frame2, self.leg2, "None", "Single column", "Two columns" | |
16876 ) | |
16877 self.leg2entry.grid(row=9, column=1, sticky=EW) | |
16878 self.legnamelabel = Label(self.frame2, text="Get feature name from") | |
16879 self.legnamelabel.grid(row=10, column=0) | |
16880 self.legnameentry = OptionMenu( | |
16881 self.frame2, self.legname, "gene", "product", "locus_tag", "note" | |
16882 ) | |
16883 self.legnameentry.grid(row=10, column=1, sticky=EW) | |
16884 self.figureoptionsclosebutton = Button( | |
16885 self.frame2, text="close", command=self.figureoptionsclose | |
16886 ) | |
16887 self.figureoptionsclosebutton.grid(row=11, column=1, sticky=E, pady=5) | |
16888 self.figureoptionswindow.geometry("+30+40") | |
16889 self.frame2.grid(padx=30, pady=10) | |
16890 | |
16891 def figureoptionsclose(self): | |
16892 self.figureoptionswindow.destroy() | |
16893 | |
16894 def blastoptions(self): | |
16895 try: | |
16896 self.blastoptionswindow.destroy() | |
16897 except: | |
16898 pass | |
16899 self.blastoptionswindow = Toplevel() | |
16900 self.blastoptionswindow.title("Blast") | |
16901 self.frame3 = Frame(self.blastoptionswindow) | |
16902 self.blastoptionslab = Label( | |
16903 self.frame3, text="Blast Options", font="TkDefaultFont 13 bold underline" | |
16904 ) | |
16905 self.blastoptionslab.grid(row=0, column=0) | |
16906 self.minlengthlabel = Label(self.frame3, text="Min. length:") | |
16907 self.minlengthlabel.grid(row=1, column=0) | |
16908 self.minlengthentry = Entry(self.frame3, textvariable=self.minlengthvar) | |
16909 self.minlengthentry.grid(row=1, column=1, columnspan=4) | |
16910 self.minevallabel = Label(self.frame3, text="Max. e Value:") | |
16911 self.minevallabel.grid(row=2, column=0) | |
16912 self.minevalentry = Entry(self.frame3, textvariable=self.minevalvar) | |
16913 self.minevalentry.grid(row=2, column=1, columnspan=4) | |
16914 self.minIdentlabel = Label(self.frame3, text="Min. Identity value:") | |
16915 self.minIdentlabel.grid(row=3, column=0) | |
16916 self.minIdententry = Entry(self.frame3, textvariable=self.minIdentvar) | |
16917 self.minIdententry.grid(row=3, column=1, columnspan=4) | |
16918 self.blastlabel = Label(self.frame3, text="normal") | |
16919 self.blastlabel.grid(row=4, column=1, columnspan=2) | |
16920 self.blastilabel = Label(self.frame3, text="inverted") | |
16921 self.blastilabel.grid(row=4, column=3, columnspan=2) | |
16922 self.minblastctag = Label(self.frame3, text="Choose minimum blast colour:") | |
16923 self.minblastctag.grid(row=5, column=0) | |
16924 self.minblastcentry = Button(self.frame3, text="...", command=self.getminblastc) | |
16925 self.minblastcentry.grid(row=5, column=2) | |
16926 self.minblastclabel = Label( | |
16927 self.frame3, width=3, bg=self.minblastchex, relief=RIDGE | |
16928 ) | |
16929 self.minblastclabel.grid(row=5, column=1) | |
16930 self.minblastcentryi = Button( | |
16931 self.frame3, text="...", command=self.getminblastci | |
16932 ) | |
16933 self.minblastcentryi.grid(row=5, column=4) | |
16934 self.minblastclabeli = Label( | |
16935 self.frame3, width=3, bg=self.minblastcihex, relief=RIDGE | |
16936 ) | |
16937 self.minblastclabeli.grid(row=5, column=3) | |
16938 self.maxblastctag = Label(self.frame3, text="Choose maximum blast colour:") | |
16939 self.maxblastctag.grid(row=6, column=0) | |
16940 self.maxblastcentry = Button(self.frame3, text="...", command=self.getmaxblastc) | |
16941 self.maxblastcentry.grid(row=6, column=2) | |
16942 self.maxblastclabel = Label( | |
16943 self.frame3, width=3, bg=self.maxblastchex, relief=RIDGE | |
16944 ) | |
16945 self.maxblastclabel.grid(row=6, column=1) | |
16946 self.maxblastcentryi = Button( | |
16947 self.frame3, text="...", command=self.getmaxblastci | |
16948 ) | |
16949 self.maxblastcentryi.grid(row=6, column=4) | |
16950 self.maxblastclabeli = Label( | |
16951 self.frame3, width=3, bg=self.maxblastcihex, relief=RIDGE | |
16952 ) | |
16953 self.maxblastclabeli.grid(row=6, column=3) | |
16954 self.blastoutlinetag = Label(self.frame3, text="Outline blast hits in black:") | |
16955 self.blastoutlinetag.grid(row=7, column=0) | |
16956 self.blastoutlineentry = Checkbutton(self.frame3, variable=self.blastoutline) | |
16957 self.blastoutlineentry.grid(row=7, column=1, columnspan=4) | |
16958 self.autodetectlab = Label( | |
16959 self.frame3, text="Filter small blast hits/annotations:" | |
16960 ) | |
16961 self.autodetectlab.grid(row=8, column=0) | |
16962 self.autodetectentry = Checkbutton(self.frame3, variable=self.autodetect) | |
16963 self.autodetectentry.grid(row=8, column=1, columnspan=4) | |
16964 self.blastoptionsclosebutton = Button( | |
16965 self.frame3, text="close", command=self.blastoptionsclose | |
16966 ) | |
16967 self.blastoptionsclosebutton.grid( | |
16968 row=9, column=1, columnspan=4, sticky=E, pady=5 | |
16969 ) | |
16970 self.blastoptionswindow.geometry("+30+40") | |
16971 self.frame3.grid(padx=30, pady=10) | |
16972 | |
16973 def blastoptionsclose(self): | |
16974 self.blastoptionswindow.destroy() | |
16975 | |
16976 def annotateoptions(self): | |
16977 try: | |
16978 self.annotateoptionswindow.destroy() | |
16979 except: | |
16980 pass | |
16981 self.annotateoptionswindow = Toplevel() | |
16982 self.annotateoptionswindow.title("Annotation") | |
16983 self.frame4 = Frame(self.annotateoptionswindow) | |
16984 self.annotLab = Label( | |
16985 self.frame4, | |
16986 text="Annotation Options", | |
16987 font="TkDefaultFont 13 bold underline", | |
16988 ) | |
16989 self.annotLab.grid(row=0, column=0) | |
16990 self.leglabel = Label(self.frame4, text="Feature Labels:") | |
16991 self.leglabel.grid(row=1, column=0) | |
16992 self.leg = StringVar(value="None") | |
16993 self.legentry = OptionMenu( | |
16994 self.frame4, self.leg, "None", "Top", "Bottom", "Top & Bottom" | |
16995 ) | |
16996 self.legentry.config(width=5) | |
16997 self.legentry.grid(row=1, column=1, columnspan=4, sticky=EW) | |
16998 self.legnamelabel = Label(self.frame4, text="Get feature name from:") | |
16999 self.legnamelabel.grid(row=2, column=0) | |
17000 self.legnameentry = OptionMenu( | |
17001 self.frame4, self.legname, "gene", "product", "locus_tag", "note" | |
17002 ) | |
17003 self.legnameentry.grid(row=2, column=1, columnspan=4, sticky=EW) | |
17004 self.exontlabel = Label(self.frame4, text="Thickness of exon lines:") | |
17005 self.exontlabel.grid(row=3, column=0) | |
17006 self.exontentry = Entry(self.frame4, textvariable=self.exontvar) | |
17007 self.exontentry.grid(row=3, column=1, columnspan=4) | |
17008 self.genetlabel = Label(self.frame4, text="Thickness of gene outlines:") | |
17009 self.genetlabel.grid(row=4, column=0) | |
17010 self.genetentry = Entry(self.frame4, textvariable=self.genetvar) | |
17011 self.genetentry.grid(row=4, column=1, columnspan=4) | |
17012 | |
17013 self.featlabel = Label( | |
17014 self.frame4, text="Include following features", font="TkDefaultFont 13 bold" | |
17015 ) | |
17016 self.featlabel.grid(row=5, column=0) | |
17017 self.featcolour = Label( | |
17018 self.frame4, text="Colour", font="TkDefaultFont 13 bold" | |
17019 ) | |
17020 self.featcolour.grid(row=5, column=1, columnspan=2) | |
17021 self.featshape = Label(self.frame4, text="type", font="TkDefaultFont 13 bold") | |
17022 self.featshape.grid(row=5, column=3, columnspan=2) | |
17023 | |
17024 self.geneflabel = Label(self.frame4, text="gene") | |
17025 self.geneflabel.grid(row=6, column=0) | |
17026 self.genefentry = Checkbutton(self.frame4, variable=self.genef) | |
17027 self.genefentry.grid(row=6, column=0, sticky=E) | |
17028 self.genefcolourBut = Button( | |
17029 self.frame4, width=1, height=1, text="...", command=self.pickcolourgene | |
17030 ) | |
17031 self.genefcolourBut.grid(row=6, column=2) | |
17032 self.genefcolourlabel = Label( | |
17033 self.frame4, width=3, bg=self.genefcolourhex, relief=RIDGE | |
17034 ) | |
17035 self.genefcolourlabel.grid(row=6, column=1) | |
17036 self.genefrectentry = OptionMenu( | |
17037 self.frame4, self.genefrect, "arrow", "rect", "frame", "pointer" | |
17038 ) | |
17039 self.genefrectentry.config(width=10) | |
17040 self.genefrectentry.grid(row=6, column=3, columnspan=2, sticky=EW) | |
17041 | |
17042 self.cdsflabel = Label(self.frame4, text="CDS") | |
17043 self.cdsflabel.grid(row=7, column=0) | |
17044 self.cdsfentry = Checkbutton(self.frame4, variable=self.cdsf) | |
17045 self.cdsfentry.grid(row=7, column=0, sticky=E) | |
17046 self.cdsfcolourBut = Button( | |
17047 self.frame4, width=1, height=1, text="...", command=self.pickcolourcds | |
17048 ) | |
17049 self.cdsfcolourBut.grid(row=7, column=2) | |
17050 self.cdsfcolourlabel = Label( | |
17051 self.frame4, width=3, bg=self.cdsfcolourhex, relief=RIDGE | |
17052 ) | |
17053 self.cdsfcolourlabel.grid(row=7, column=1) | |
17054 self.cdsfrectentry = OptionMenu( | |
17055 self.frame4, self.cdsfrect, "arrow", "rect", "frame", "pointer" | |
17056 ) | |
17057 self.cdsfrectentry.config(width=6) | |
17058 self.cdsfrectentry.grid(row=7, column=3, columnspan=2, sticky=EW) | |
17059 | |
17060 self.trnaflabel = Label(self.frame4, text="tRNA") | |
17061 self.trnaflabel.grid(row=8, column=0) | |
17062 self.trnafentry = Checkbutton(self.frame4, variable=self.trnaf) | |
17063 self.trnafentry.grid(row=8, column=0, sticky=E) | |
17064 self.trnafcolourBut = Button( | |
17065 self.frame4, width=1, height=1, text="...", command=self.pickcolourtrna | |
17066 ) | |
17067 self.trnafcolourBut.grid(row=8, column=2) | |
17068 self.trnafcolourlabel = Label( | |
17069 self.frame4, width=3, bg=self.trnafcolourhex, relief=RIDGE | |
17070 ) | |
17071 self.trnafcolourlabel.grid(row=8, column=1) | |
17072 self.trnafrectentry = OptionMenu( | |
17073 self.frame4, self.trnafrect, "arrow", "rect", "frame", "pointer" | |
17074 ) | |
17075 self.trnafrectentry.config(width=6) | |
17076 self.trnafrectentry.grid(row=8, column=3, columnspan=2, sticky=EW) | |
17077 | |
17078 self.miscflabel = Label(self.frame4, text="misc_feature") | |
17079 self.miscflabel.grid(row=9, column=0) | |
17080 self.miscfentry = Checkbutton(self.frame4, variable=self.miscf) | |
17081 self.miscfentry.grid(row=9, column=0, sticky=E) | |
17082 self.miscfcolourBut = Button( | |
17083 self.frame4, width=1, height=1, text="...", command=self.pickcolourmisc | |
17084 ) | |
17085 self.miscfcolourBut.grid(row=9, column=2) | |
17086 self.miscfcolourlabel = Label( | |
17087 self.frame4, width=3, bg=self.miscfcolourhex, relief=RIDGE | |
17088 ) | |
17089 self.miscfcolourlabel.grid(row=9, column=1) | |
17090 self.miscfrectentry = OptionMenu( | |
17091 self.frame4, self.miscfrect, "arrow", "rect", "frame", "pointer" | |
17092 ) | |
17093 self.miscfrectentry.config(width=6) | |
17094 self.miscfrectentry.grid(row=9, column=3, columnspan=2, sticky=EW) | |
17095 | |
17096 self.randflabel = Entry(self.frame4, textvariable=self.randfeat) | |
17097 self.randflabel.grid(row=10, column=0) | |
17098 self.randfentry = Checkbutton(self.frame4, variable=self.randf) | |
17099 self.randfentry.grid(row=10, column=0, sticky=E) | |
17100 self.randfcolourBut = Button( | |
17101 self.frame4, width=1, height=1, text="...", command=self.pickcolourrand | |
17102 ) | |
17103 self.randfcolourBut.grid(row=10, column=2) | |
17104 self.randfcolourlabel = Label( | |
17105 self.frame4, width=3, bg=self.randfcolourhex, relief=RIDGE | |
17106 ) | |
17107 self.randfcolourlabel.grid(row=10, column=1) | |
17108 self.randfrectentry = OptionMenu( | |
17109 self.frame4, self.randfrect, "arrow", "rect", "frame", "pointer" | |
17110 ) | |
17111 self.randfrectentry.config(width=6) | |
17112 self.randfrectentry.grid(row=10, column=3, columnspan=2, sticky=EW) | |
17113 self.annotateoptionsclosebutton = Button( | |
17114 self.frame4, text="close", command=self.annotateoptionsclose | |
17115 ) | |
17116 self.annotateoptionsclosebutton.grid( | |
17117 row=11, column=3, columnspan=2, sticky=E, pady=5 | |
17118 ) | |
17119 self.annotateoptionswindow.geometry("+30+40") | |
17120 self.frame4.grid(padx=30, pady=10) | |
17121 | |
17122 def annotateoptionsclose(self): | |
17123 self.annotateoptionswindow.destroy() | |
17124 | |
17125 def graphoptions(self): | |
17126 try: | |
17127 self.graphoptionswindow.destroy() | |
17128 except: | |
17129 pass | |
17130 self.graphoptionswindow = Toplevel() | |
17131 self.graphoptionswindow.title("Graph") | |
17132 self.frame5 = Frame(self.graphoptionswindow) | |
17133 self.graphlabel = Label( | |
17134 self.frame5, text="Graph options", font="TkDefaultFont 13 bold" | |
17135 ) | |
17136 self.graphlabel.grid(row=0, column=0) | |
17137 | |
17138 self.graphtypelabel = Label(self.frame5, text="Graph:") | |
17139 self.graphtypelabel.grid(row=1, column=0) | |
17140 self.graphtypeentry = OptionMenu( | |
17141 self.frame5, | |
17142 self.graphtype, | |
17143 "None", | |
17144 "GC Content", | |
17145 "GC Skew", | |
17146 "Coverage", | |
17147 "Custom", | |
17148 command=self.graphtypechanges, | |
17149 ) | |
17150 self.graphtypeentry.grid(row=1, column=1) | |
17151 | |
17152 self.alloronelabel = Label(self.frame5, text="Multiple graphs:") | |
17153 self.alloronelabel.grid(row=2, column=0) | |
17154 self.alloroneentry = Checkbutton( | |
17155 self.frame5, variable=self.allorone, state=DISABLED | |
17156 ) | |
17157 self.alloroneentry.grid(row=2, column=1) | |
17158 | |
17159 self.graphfilelabel = Label(self.frame5, text="Input file:") | |
17160 self.graphfilelabel.grid(row=3, column=0) | |
17161 self.graphfileentry = Entry( | |
17162 self.frame5, textvariable=self.graphfile, state=DISABLED | |
17163 ) | |
17164 self.graphfileentry.grid(row=3, column=1) | |
17165 self.graphfilebut = Button( | |
17166 self.frame5, | |
17167 width=1, | |
17168 height=1, | |
17169 text="...", | |
17170 command=self.opengraphfile, | |
17171 state=DISABLED, | |
17172 ) | |
17173 self.graphfilebut.grid(row=3, column=2) | |
17174 | |
17175 self.steplabel = Label(self.frame5, text="Step size:") | |
17176 self.steplabel.grid(row=4, column=0) | |
17177 self.stepentry = Entry(self.frame5, textvariable=self.step, state=DISABLED) | |
17178 self.stepentry.grid(row=4, column=1) | |
17179 | |
17180 self.windsizelabel = Label(self.frame5, text="Window size:") | |
17181 self.windsizelabel.grid(row=5, column=0) | |
17182 self.windsizeentry = Entry( | |
17183 self.frame5, textvariable=self.windsize, state=DISABLED | |
17184 ) | |
17185 self.windsizeentry.grid(row=5, column=1) | |
17186 | |
17187 self.graphheightlabel = Label(self.frame5, text="Graph Height:") | |
17188 self.graphheightlabel.grid(row=6, column=0) | |
17189 self.graphheightentry = Entry( | |
17190 self.frame5, textvariable=self.graphheight, state=DISABLED | |
17191 ) | |
17192 self.graphheightentry.grid(row=6, column=1) | |
17193 | |
17194 self.maxylabel = Label(self.frame5, text="Maximum Y:") | |
17195 self.maxylabel.grid(row=7, column=0) | |
17196 self.maxyentry = Entry(self.frame5, textvariable=self.maxy, state=DISABLED) | |
17197 self.maxyentry.grid(row=7, column=1) | |
17198 | |
17199 self.logitlabel = Label(self.frame5, text="Log scale (log10):") | |
17200 self.logitlabel.grid(row=8, column=0) | |
17201 self.logitbut = Checkbutton(self.frame5, variable=self.logit, state=DISABLED) | |
17202 self.logitbut.grid(row=8, column=1) | |
17203 | |
17204 self.histolabel = Label(self.frame5, text="Graph Type:") | |
17205 self.histolabel.grid(row=9, column=0) | |
17206 self.histoentry = OptionMenu(self.frame5, self.histo, "Histogram", "Line") | |
17207 self.histoentry.config(state=DISABLED) | |
17208 self.histoentry.grid(row=9, column=1) | |
17209 | |
17210 self.graphlinetlabel = Label(self.frame5, text="Axis line thickness:") | |
17211 self.graphlinetlabel.grid(row=10, column=0) | |
17212 self.graphlinetentry = Entry( | |
17213 self.frame5, textvariable=self.graphlinet, state=DISABLED | |
17214 ) | |
17215 self.graphlinetentry.grid(row=10, column=1) | |
17216 | |
17217 self.poslabel = Label(self.frame5, text="Positive value colour:") | |
17218 self.poslabel.grid(row=11, column=0) | |
17219 self.poscollabel = Label(self.frame5, width=3, bg=self.poscolhex, relief=RIDGE) | |
17220 self.poscollabel.grid(row=11, column=1, sticky=EW) | |
17221 self.poscolbutton = Button( | |
17222 self.frame5, | |
17223 width=1, | |
17224 height=1, | |
17225 text="...", | |
17226 command=self.pickposcol, | |
17227 state=DISABLED, | |
17228 ) | |
17229 self.poscolbutton.grid(row=11, column=2) | |
17230 | |
17231 self.neglabel = Label(self.frame5, text="Negative value colour:") | |
17232 self.neglabel.grid(row=12, column=0) | |
17233 self.negcollabel = Label(self.frame5, width=3, bg=self.negcolhex, relief=RIDGE) | |
17234 self.negcollabel.grid(row=12, column=1, sticky=EW) | |
17235 self.negcolbutton = Button( | |
17236 self.frame5, | |
17237 width=1, | |
17238 height=1, | |
17239 text="...", | |
17240 command=self.picknegcol, | |
17241 state=DISABLED, | |
17242 ) | |
17243 self.negcolbutton.grid(row=12, column=2) | |
17244 | |
17245 self.ggaplabel = Label(self.frame5, text="Gap between graph and figure:") | |
17246 self.ggaplabel.grid(row=13, column=0) | |
17247 self.ggapentry = Entry(self.frame5, textvariable=self.ggap, state=DISABLED) | |
17248 self.ggapentry.grid(row=13, column=1) | |
17249 | |
17250 self.graphoptionsclosebutton = Button( | |
17251 self.frame5, text="close", command=self.graphoptionsclose | |
17252 ) | |
17253 self.graphoptionsclosebutton.grid( | |
17254 row=14, column=1, columnspan=2, sticky=E, pady=5 | |
17255 ) | |
17256 self.graphoptionswindow.geometry("+30+40") | |
17257 self.graphtypechanges(self.graphtype.get()) | |
17258 self.frame5.grid(padx=30, pady=10) | |
17259 | |
17260 def graphoptionsclose(self): | |
17261 self.graphoptionswindow.destroy() | |
17262 | |
17263 def opengraphfile(self): | |
17264 filename = tkFileDialog.askopenfilename(parent=self.graphoptionswindow) | |
17265 self.graphfile.set(filename) | |
17266 | |
17267 def pickcolourgene(self): | |
17268 colour = tkColorChooser.askcolor( | |
17269 self.genefcolour, parent=self.annotateoptionswindow | |
17270 ) | |
17271 if colour != None: | |
17272 self.genefcolour = colour[0] | |
17273 self.genefcolourhex = colour[1] | |
17274 self.genefcolourlabel.configure(bg=colour[1]) | |
17275 | |
17276 def pickcolourcds(self): | |
17277 colour = tkColorChooser.askcolor( | |
17278 self.cdsfcolour, parent=self.annotateoptionswindow | |
17279 ) | |
17280 if colour != None: | |
17281 self.cdsfcolour = colour[0] | |
17282 self.cdsfcolourhex = colour[1] | |
17283 self.cdsfcolourlabel.configure(bg=colour[1]) | |
17284 | |
17285 def pickcolourtrna(self): | |
17286 colour = tkColorChooser.askcolor( | |
17287 self.trnafcolour, parent=self.annotateoptionswindow | |
17288 ) | |
17289 if colour != None: | |
17290 self.trnafcolour = colour[0] | |
17291 self.trnafcolourhex = colour[1] | |
17292 self.trnafcolourlabel.configure(bg=colour[1]) | |
17293 | |
17294 def pickcolourrand(self): | |
17295 colour = tkColorChooser.askcolor( | |
17296 self.randfcolour, parent=self.annotateoptionswindow | |
17297 ) | |
17298 if colour != None: | |
17299 self.randfcolour = colour[0] | |
17300 self.randfcolourhex = colour[1] | |
17301 self.randfcolourlabel.configure(bg=colour[1]) | |
17302 | |
17303 def pickcolourmisc(self): | |
17304 colour = tkColorChooser.askcolor( | |
17305 self.miscfcolour, parent=self.annotateoptionswindow | |
17306 ) | |
17307 if colour != None: | |
17308 self.miscfcolour = colour[0] | |
17309 self.miscfcolourhex = colour[1] | |
17310 self.miscfcolourlabel.configure(bg=colour[1]) | |
17311 | |
17312 def getminblastc(self): | |
17313 colour = tkColorChooser.askcolor(self.minblastc, parent=self.blastoptionswindow) | |
17314 if colour != None: | |
17315 self.minblastc = colour[0] | |
17316 self.minblastchex = colour[1] | |
17317 self.minblastclabel.configure(bg=colour[1]) | |
17318 | |
17319 def getmaxblastc(self): | |
17320 colour = tkColorChooser.askcolor(self.maxblastc, parent=self.blastoptionswindow) | |
17321 if colour != None: | |
17322 self.maxblastc = colour[0] | |
17323 self.maxblastchex = colour[1] | |
17324 self.maxblastclabel.configure(bg=colour[1]) | |
17325 | |
17326 def getminblastci(self): | |
17327 colour = tkColorChooser.askcolor( | |
17328 self.minblastci, parent=self.blastoptionswindow | |
17329 ) | |
17330 if colour != None: | |
17331 self.minblastci = colour[0] | |
17332 self.minblastcihex = colour[1] | |
17333 self.minblastclabeli.configure(bg=colour[1]) | |
17334 | |
17335 def getmaxblastci(self): | |
17336 colour = tkColorChooser.askcolor( | |
17337 self.maxblastci, parent=self.blastoptionswindow | |
17338 ) | |
17339 if colour != None: | |
17340 self.maxblastci = colour[0] | |
17341 self.maxblastcihex = colour[1] | |
17342 self.maxblastclabeli.configure(bg=colour[1]) | |
17343 | |
17344 def makeFigure(self): | |
17345 global abortCaptain | |
17346 if self.outfile.get() == "" and not self.filetype.get().startswith("Preview"): | |
17347 self.getoutfile() | |
17348 if self.outfile.get() == "" and not self.filetype.get().startswith("Preview"): | |
17349 return None | |
17350 try: | |
17351 if self.thegenblast.isAlive(): | |
17352 tkMessageBox.showerror("Please wait", "BLAST already running.") | |
17353 return None | |
17354 except: | |
17355 pass | |
17356 if self.running: | |
17357 abortCaptain = True | |
17358 else: | |
17359 abortCaptain = False | |
17360 self.running = True | |
17361 self.createFigure.config(text="Cancel Figure") | |
17362 try: | |
17363 self.minlength = int(self.minlengthvar.get()) | |
17364 except: | |
17365 tkMessageBox.showerror( | |
17366 "Try again.", "Please enter a valid integer for minimum length." | |
17367 ) | |
17368 self.running = False | |
17369 self.createFigure.config(text="Create Figure") | |
17370 return None | |
17371 try: | |
17372 self.mineval = float(self.minevalvar.get()) | |
17373 except: | |
17374 tkMessageBox.showerror( | |
17375 "Try again.", | |
17376 "Please enter a valid floating point number for minimum e value.", | |
17377 ) | |
17378 self.running = False | |
17379 self.createFigure.config(text="Create Figure") | |
17380 return None | |
17381 try: | |
17382 self.minIdent = float(self.minIdentvar.get()) | |
17383 except: | |
17384 tkMessageBox.showerror( | |
17385 "Try again.", | |
17386 "Please enter a valid floating point number for minimum identity.", | |
17387 ) | |
17388 self.running = False | |
17389 self.createFigure.config(text="Create Figure") | |
17390 return None | |
17391 try: | |
17392 self.figwidth = int(self.figwidthvar.get()) | |
17393 except: | |
17394 tkMessageBox.showerror( | |
17395 "Try again.", "Please enter a valid integer for figure width." | |
17396 ) | |
17397 self.running = False | |
17398 self.createFigure.config(text="Create Figure") | |
17399 return None | |
17400 try: | |
17401 self.height1 = int(self.height1var.get()) | |
17402 except: | |
17403 tkMessageBox.showerror( | |
17404 "Try again.", "Please enter a valid integer for height of genes." | |
17405 ) | |
17406 self.running = False | |
17407 self.createFigure.config(text="Create Figure") | |
17408 return None | |
17409 try: | |
17410 self.height2 = int(self.height2var.get()) | |
17411 except: | |
17412 tkMessageBox.showerror( | |
17413 "Try again.", | |
17414 "Please enter a valid integer for height of blast matches.", | |
17415 ) | |
17416 self.running = False | |
17417 self.createFigure.config(text="Create Figure") | |
17418 return None | |
17419 try: | |
17420 self.glt = int(self.gltvar.get()) | |
17421 except: | |
17422 tkMessageBox.showerror( | |
17423 "Try again.", | |
17424 "Please enter a valid integer for genome line thickness.", | |
17425 ) | |
17426 self.running = False | |
17427 self.createFigure.config(text="Create Figure") | |
17428 return None | |
17429 try: | |
17430 self.exont = int(self.exontvar.get()) | |
17431 except: | |
17432 tkMessageBox.showerror( | |
17433 "Try again.", | |
17434 "Please enter a valid integer for exon line thickeness.", | |
17435 ) | |
17436 self.running = False | |
17437 self.createFigure.config(text="Create Figure") | |
17438 return None | |
17439 try: | |
17440 self.genet = int(self.genetvar.get()) | |
17441 except: | |
17442 tkMessageBox.showerror( | |
17443 "Try again.", | |
17444 "Please enter a valid integer for exon line thickeness.", | |
17445 ) | |
17446 self.running = False | |
17447 self.createFigure.config(text="Create Figure") | |
17448 return None | |
17449 self.featDict = {} | |
17450 if self.genef.get() == 1: | |
17451 self.featDict["gene"] = (self.genefrect.get(), self.genefcolour) | |
17452 if self.cdsf.get() == 1: | |
17453 self.featDict["CDS"] = (self.cdsfrect.get(), self.cdsfcolour) | |
17454 if self.trnaf.get() == 1: | |
17455 self.featDict["tRNA"] = (self.trnafrect.get(), self.trnafcolour) | |
17456 if self.miscf.get() == 1: | |
17457 self.featDict["misc_feature"] = (self.miscfrect.get(), self.miscfcolour) | |
17458 if self.randf.get() == 1: | |
17459 self.featDict[self.randfeat.get()] = ( | |
17460 self.randfrect.get(), | |
17461 self.randfcolour, | |
17462 ) | |
17463 self.reverseList = [] | |
17464 self.minmaxlist = [] | |
17465 for i in self.genlist.get(0, END): | |
17466 self.reverseList.append(self.revlist[i[:2]]) | |
17467 try: | |
17468 if self.maxcutlist[i[:2]] == "Max": | |
17469 self.minmaxlist.append((int(self.mincutlist[i[:2]]), "Max")) | |
17470 else: | |
17471 self.minmaxlist.append( | |
17472 (int(self.mincutlist[i[:2]]), int(self.maxcutlist[i[:2]])) | |
17473 ) | |
17474 except: | |
17475 tkMessageBox.showerror( | |
17476 "Try again.", | |
17477 "Please enter a valid integer cut off points for annotation file " | |
17478 + i[:2] | |
17479 + ".", | |
17480 ) | |
17481 self.running = False | |
17482 self.createFigure.config(text="Create Figure") | |
17483 return None | |
17484 if self.graphtype.get() != "None" and ( | |
17485 self.leg.get() == "Top" or self.leg.get() == "Top & Bottom" | |
17486 ): | |
17487 tkMessageBox.showerror( | |
17488 "Try again.", | |
17489 "Please Choose either the graph or the legend to be displayed above the figure.", | |
17490 ) | |
17491 self.running = False | |
17492 self.createFigure.config(text="Create Figure") | |
17493 return None | |
17494 if self.leg.get() != "None" and self.leg2.get() != "None": | |
17495 tkMessageBox.showerror( | |
17496 "Try again.", | |
17497 "Please Choose either feature labels or a feature legend.", | |
17498 ) | |
17499 self.running = False | |
17500 self.createFigure.config(text="Create Figure") | |
17501 return None | |
17502 else: | |
17503 if self.leg.get() == "None": | |
17504 self.theleg = self.leg2.get() | |
17505 else: | |
17506 self.theleg = self.leg.get() | |
17507 self.inputlist = [] | |
17508 self.graphlist = [] | |
17509 getit = True | |
17510 nocompare = False | |
17511 if self.genlist.size() > 1 and self.blastlist.size() == 0: | |
17512 nocompare = tkMessageBox.askquestion( | |
17513 "No blast files.", | |
17514 "Only gene figures will be drawn, continue?\n(To create a comparison figure please generate or manually input a blast file)", | |
17515 ) | |
17516 if nocompare == "no": | |
17517 self.running = False | |
17518 self.createFigure.config(text="Create Figure") | |
17519 return None | |
17520 else: | |
17521 nocompare = True | |
17522 if self.genlist.size() > 0: | |
17523 if self.graphtype.get() == "GC Content": | |
17524 self.graphlist.append( | |
17525 self.getGCcontent( | |
17526 self.genlist.get(0)[4:], | |
17527 self.mincutlist[self.genlist.get(0)[:2]], | |
17528 self.maxcutlist[self.genlist.get(0)[:2]], | |
17529 ) | |
17530 ) | |
17531 elif self.graphtype.get() == "GC Skew": | |
17532 self.graphlist.append( | |
17533 self.getGCskew( | |
17534 self.genlist.get(0)[4:], | |
17535 self.mincutlist[self.genlist.get(0)[:2]], | |
17536 self.maxcutlist[self.genlist.get(0)[:2]], | |
17537 ) | |
17538 ) | |
17539 self.inputlist.append(self.genlist.get(0)[4:]) | |
17540 tempfile = open(self.genlist.get(0)[4:]) | |
17541 getline = True | |
17542 line = tempfile.readline() | |
17543 while getline and line != "": | |
17544 if ( | |
17545 line.startswith("FT source") | |
17546 or line.startswith(" source") | |
17547 or line.startswith("ORIGIN") | |
17548 or line.startswith("SQ Sequence") | |
17549 or line.startswith(">") | |
17550 ): | |
17551 getline = False | |
17552 line = tempfile.readline() | |
17553 if getline: | |
17554 self.genlengths = [ | |
17555 tkSimpleDialog.askinteger( | |
17556 "Length not in file", | |
17557 "Please enter the length of genome in file 1", | |
17558 ) | |
17559 ] | |
17560 else: | |
17561 self.genlengths = [None] | |
17562 tempfile.close() | |
17563 else: | |
17564 tkMessageBox.showerror( | |
17565 "Try again.", "Please enter at least one feature file." | |
17566 ) | |
17567 self.running = False | |
17568 self.createFigure.config(text="Create Figure") | |
17569 return None | |
17570 if self.genlist.size() - 1 == self.blastlist.size() or nocompare: | |
17571 for i in range(self.genlist.size() - 1): | |
17572 self.inputlist.append(self.blastlist.get(i)) | |
17573 if ( | |
17574 self.graphtype.get() == "GC Content" | |
17575 and self.allorone.get() == 1 | |
17576 ): | |
17577 self.graphlist.append( | |
17578 self.getGCcontent( | |
17579 self.genlist.get(i + 1)[4:], | |
17580 self.mincutlist[self.genlist.get(i + 1)[:2]], | |
17581 self.maxcutlist[self.genlist.get(i + 1)[:2]], | |
17582 ) | |
17583 ) | |
17584 elif self.graphtype.get() == "GC Skew" and self.allorone.get() == 1: | |
17585 self.graphlist.append( | |
17586 self.getGCcontent( | |
17587 self.genlist.get(i + 1)[4:], | |
17588 self.mincutlist[self.genlist.get(i + 1)[:2]], | |
17589 self.maxcutlist[self.genlist.get(i + 1)[:2]], | |
17590 ) | |
17591 ) | |
17592 self.inputlist.append(self.genlist.get(i + 1)[4:]) | |
17593 tempfile = open(self.genlist.get(i + 1)[4:]) | |
17594 getline = True | |
17595 line = tempfile.readline() | |
17596 while getline and line != "": | |
17597 if ( | |
17598 line.startswith("FT source") | |
17599 or line.startswith(" source") | |
17600 or line.startswith("ORIGIN") | |
17601 or line.startswith("SQ Sequence") | |
17602 or line.startswith(">") | |
17603 ): | |
17604 getline = False | |
17605 line = tempfile.readline() | |
17606 if getline: | |
17607 self.genlengths.append( | |
17608 tkSimpleDialog.askinteger( | |
17609 "Length not in file", | |
17610 "Please enter the length of genome in file " | |
17611 + str(i + 1) | |
17612 + ".", | |
17613 ) | |
17614 ) | |
17615 else: | |
17616 self.genlengths.append(None) | |
17617 tempfile.close() | |
17618 else: | |
17619 if self.blastlist.size() >= self.genlist.size(): | |
17620 tkMessageBox.showerror("Try again.", "Too many blast files.") | |
17621 else: | |
17622 tkMessageBox.showerror("Try again.", "Too few blast files.") | |
17623 self.running = False | |
17624 self.createFigure.config(text="Create Figure") | |
17625 return None | |
17626 try: | |
17627 self.drawfig2 = int(self.drawfig2var.get()) | |
17628 if self.drawfig2 == 0: | |
17629 self.drawfig2 = False | |
17630 except: | |
17631 tkMessageBox.showerror( | |
17632 "Try again.", "Please enter a valid integer for length of figure 2." | |
17633 ) | |
17634 self.running = False | |
17635 self.createFigure.config(text="Create Figure") | |
17636 return None | |
17637 self.compress = False | |
17638 if self.drawfig1.get() == 1: | |
17639 self.vardrawfig1 = True | |
17640 else: | |
17641 self.vardrawfig1 = False | |
17642 if self.blastoutline.get() == 1: | |
17643 self.varblastoutline = True | |
17644 else: | |
17645 self.varblastoutline = False | |
17646 | |
17647 if self.graphtype.get() == "None": | |
17648 self.vargraphit = None | |
17649 elif self.graphtype.get() == "GC Content": | |
17650 self.vargraphit = [ | |
17651 self.graphlist, | |
17652 self.poscol, | |
17653 self.negcol, | |
17654 int(self.graphheight.get()), | |
17655 int(self.graphlinet.get()), | |
17656 self.histo.get(), | |
17657 self.maxy.get(), | |
17658 int(self.ggap.get()), | |
17659 ] | |
17660 if None in self.vargraphit[0]: | |
17661 self.running = False | |
17662 self.createFigure.config(text="Create Figure") | |
17663 return None | |
17664 elif self.graphtype.get() == "GC Skew": | |
17665 self.vargraphit = [ | |
17666 self.graphlist, | |
17667 self.poscol, | |
17668 self.negcol, | |
17669 int(self.graphheight.get()), | |
17670 int(self.graphlinet.get()), | |
17671 self.histo.get(), | |
17672 self.maxy.get(), | |
17673 int(self.ggap.get()), | |
17674 ] | |
17675 if None in self.vargraphit[0] == None: | |
17676 self.running = False | |
17677 self.createFigure.config(text="Create Figure") | |
17678 return None | |
17679 elif self.graphtype.get() == "Coverage": | |
17680 self.vargraphit = [ | |
17681 [self.getCoverage()], | |
17682 self.poscol, | |
17683 self.negcol, | |
17684 int(self.graphheight.get()), | |
17685 int(self.graphlinet.get()), | |
17686 self.histo.get(), | |
17687 self.maxy.get(), | |
17688 int(self.ggap.get()), | |
17689 ] | |
17690 if None in self.vargraphit[0]: | |
17691 self.running = False | |
17692 self.createFigure.config(text="Create Figure") | |
17693 return None | |
17694 elif self.graphtype.get() == "Custom": | |
17695 tempcustom = self.getCustom() | |
17696 if self.allorone.get() != 1: | |
17697 tempcustom = [tempcustom[0]] | |
17698 self.vargraphit = [ | |
17699 tempcustom, | |
17700 self.poscol, | |
17701 self.negcol, | |
17702 int(self.graphheight.get()), | |
17703 int(self.graphlinet.get()), | |
17704 self.histo.get(), | |
17705 self.maxy.get(), | |
17706 int(self.ggap.get()), | |
17707 ] | |
17708 if None in self.vargraphit[0]: | |
17709 self.running = False | |
17710 self.createFigure.config(text="Create Figure") | |
17711 return None | |
17712 if self.cutstate != None and self.cutstate != ( | |
17713 str(self.mincutlist), | |
17714 str(self.maxcutlist), | |
17715 ): | |
17716 tkMessageBox.showerror( | |
17717 "Try again.", | |
17718 "Please generate blast files again, blast files do not match modified annotation files.", | |
17719 ) | |
17720 self.running = False | |
17721 self.createFigure.config(text="Create Figure") | |
17722 return None | |
17723 if self.orderstate != None and self.orderstate != self.genlist.get(0, END): | |
17724 tkMessageBox.showerror( | |
17725 "Try again.", | |
17726 "Please generate blast files again, order of annotation files has been changed.", | |
17727 ) | |
17728 self.running = False | |
17729 self.createFigure.config(text="Create Figure") | |
17730 return None | |
17731 getit = True | |
17732 for i in self.inputlist: | |
17733 if not os.path.exists(i): | |
17734 if not i == "" and not nocompare: | |
17735 getit = False | |
17736 if not getit: | |
17737 tkMessageBox.showerror("Try again.", "A selected file does not exist.") | |
17738 self.running = False | |
17739 self.createFigure.config(text="Create Figure") | |
17740 return None | |
17741 else: | |
17742 self.thethread = threading.Thread(target=self.makeFigure2) | |
17743 self.thethread.start() | |
17744 self.thethread2 = threading.Thread(target=self.dotdotdot) | |
17745 self.thethread2.start() | |
17746 | |
17747 def dotdotdot(self): | |
17748 while self.thethread.isAlive(): | |
17749 time.sleep(0.5) | |
17750 self.processLab.config(text="Drawing figure..") | |
17751 time.sleep(0.5) | |
17752 self.processLab.config(text="Drawing figure...") | |
17753 time.sleep(0.5) | |
17754 self.processLab.config(text="Drawing figure.") | |
17755 if self.theminblast == 101: | |
17756 self.processLab.config(text="Drawing figure...\ncomplete.") | |
17757 elif self.theminblast == None: | |
17758 self.processLab.config(text="Drawing figure...\nfailed.") | |
17759 else: | |
17760 self.processLab.config(text="Drawing figure...\ncomplete.") | |
17761 self.running = False | |
17762 self.createFigure.config(text="Create Figure") | |
17763 | |
17764 def makeFigure2(self): | |
17765 if self.filetype.get() == "Bitmap (bmp)": | |
17766 if self.outfile.get()[-4:].lower() != ".bmp": | |
17767 theoutfile = self.outfile.get() + ".bmp" | |
17768 else: | |
17769 theoutfile = self.outfile.get() | |
17770 self.theminblast = draw( | |
17771 theoutfile, | |
17772 self.minlength, | |
17773 self.mineval, | |
17774 self.minIdent, | |
17775 self.inputlist, | |
17776 self.figwidth, | |
17777 self.height1, | |
17778 self.height2, | |
17779 self.minblastc, | |
17780 self.maxblastc, | |
17781 self.minblastci, | |
17782 self.maxblastci, | |
17783 self.vardrawfig1, | |
17784 self.drawfig2, | |
17785 False, | |
17786 self.compress, | |
17787 self.reverseList, | |
17788 self.featDict, | |
17789 self.glt, | |
17790 self.exont, | |
17791 self.genet, | |
17792 self.genlengths, | |
17793 self.aln.get(), | |
17794 self.vargraphit, | |
17795 self.varblastoutline, | |
17796 self.minmaxlist, | |
17797 self.autodetect.get() == 1, | |
17798 self.theleg, | |
17799 self.legname.get(), | |
17800 ) | |
17801 elif self.filetype.get() == "Vector file (svg)": | |
17802 if self.outfile.get()[-4:].lower() != ".svg": | |
17803 theoutfile = self.outfile.get() + ".svg" | |
17804 else: | |
17805 theoutfile = self.outfile.get() | |
17806 self.theminblast = drawsvg( | |
17807 theoutfile, | |
17808 self.minlength, | |
17809 self.mineval, | |
17810 self.minIdent, | |
17811 self.inputlist, | |
17812 self.figwidth, | |
17813 self.height1, | |
17814 self.height2, | |
17815 self.minblastc, | |
17816 self.maxblastc, | |
17817 self.minblastci, | |
17818 self.maxblastci, | |
17819 self.vardrawfig1, | |
17820 self.drawfig2, | |
17821 False, | |
17822 self.compress, | |
17823 self.reverseList, | |
17824 self.featDict, | |
17825 self.glt, | |
17826 self.exont, | |
17827 self.genet, | |
17828 self.genlengths, | |
17829 self.aln.get(), | |
17830 self.vargraphit, | |
17831 self.varblastoutline, | |
17832 self.minmaxlist, | |
17833 self.autodetect.get() == 1, | |
17834 self.theleg, | |
17835 self.legname.get(), | |
17836 ) | |
17837 else: | |
17838 self.theminblast = self.getPreview() | |
17839 | |
17840 def getPreview(self): | |
17841 try: | |
17842 self.prevwindow.destroy() | |
17843 except: | |
17844 pass | |
17845 theoutfile = None | |
17846 if self.filetype.get() == "Preview (1:1)": | |
17847 testit, self.theminblast, width, height = draw( | |
17848 theoutfile, | |
17849 self.minlength, | |
17850 self.mineval, | |
17851 self.minIdent, | |
17852 self.inputlist, | |
17853 self.figwidth, | |
17854 self.height1, | |
17855 self.height2, | |
17856 self.minblastc, | |
17857 self.maxblastc, | |
17858 self.minblastci, | |
17859 self.maxblastci, | |
17860 self.vardrawfig1, | |
17861 self.drawfig2, | |
17862 False, | |
17863 self.compress, | |
17864 self.reverseList, | |
17865 self.featDict, | |
17866 self.glt, | |
17867 self.exont, | |
17868 self.genet, | |
17869 self.genlengths, | |
17870 self.aln.get(), | |
17871 self.vargraphit, | |
17872 self.varblastoutline, | |
17873 self.minmaxlist, | |
17874 self.autodetect.get() == 1, | |
17875 self.theleg, | |
17876 self.legname.get(), | |
17877 1, | |
17878 ) | |
17879 else: | |
17880 testit, self.theminblast, width, height = draw( | |
17881 theoutfile, | |
17882 self.minlength, | |
17883 self.mineval, | |
17884 self.minIdent, | |
17885 self.inputlist, | |
17886 self.figwidth, | |
17887 self.height1, | |
17888 self.height2, | |
17889 self.minblastc, | |
17890 self.maxblastc, | |
17891 self.minblastci, | |
17892 self.maxblastci, | |
17893 self.vardrawfig1, | |
17894 self.drawfig2, | |
17895 False, | |
17896 self.compress, | |
17897 self.reverseList, | |
17898 self.featDict, | |
17899 self.glt, | |
17900 self.exont, | |
17901 self.genet, | |
17902 self.genlengths, | |
17903 self.aln.get(), | |
17904 self.vargraphit, | |
17905 self.varblastoutline, | |
17906 self.minmaxlist, | |
17907 self.autodetect.get() == 1, | |
17908 self.theleg, | |
17909 self.legname.get(), | |
17910 2, | |
17911 ) | |
17912 self.prevwindow = Toplevel() | |
17913 self.prevwindow.title("Preview") | |
17914 self.prevframe = Frame(self.prevwindow) | |
17915 self.prevwindow.grid_rowconfigure(0, weight=1) | |
17916 self.prevwindow.grid_columnconfigure(0, weight=1) | |
17917 self.prevwindow.geometry("+30+40") | |
17918 self.prevframe.grid(row=0, column=0, sticky=NSEW) | |
17919 self.prevframe.grid_rowconfigure(0, weight=1) | |
17920 self.prevframe.grid_columnconfigure(0, weight=1) | |
17921 xscrollbar = Scrollbar(self.prevframe, orient=HORIZONTAL) | |
17922 xscrollbar.grid(row=1, column=0, sticky=E + W) | |
17923 yscrollbar = Scrollbar(self.prevframe) | |
17924 yscrollbar.grid(row=0, column=1, sticky=N + S) | |
17925 self.canvas = Canvas( | |
17926 self.prevframe, | |
17927 bd=0, | |
17928 bg="#000000", | |
17929 scrollregion=(0, 0, width, height), | |
17930 xscrollcommand=xscrollbar.set, | |
17931 yscrollcommand=yscrollbar.set, | |
17932 ) | |
17933 test = PhotoImage(data=testit) | |
17934 self.canvas.create_image(0, 0, image=test, anchor=NW) | |
17935 self.canvas.grid(row=0, column=0, sticky=NSEW) | |
17936 self.canvas.image = test | |
17937 xscrollbar.config(command=self.canvas.xview) | |
17938 yscrollbar.config(command=self.canvas.yview) | |
17939 # label = Label(self.prevframe, image=test) | |
17940 # label.image = test | |
17941 # label.grid() | |
17942 # self.canvas.image = test | |
17943 return self.theminblast | |
17944 | |
17945 def gbk2fasta(self, genbank, out, mincut, maxcut): | |
17946 getseq = False | |
17947 getembl = False | |
17948 getmultifa = False | |
17949 seq = "" | |
17950 try: | |
17951 mincut = int(mincut) | |
17952 if mincut < 1: | |
17953 mincut = 1 | |
17954 if maxcut != "Max": | |
17955 maxcut = int(maxcut) | |
17956 if maxcut < 1: | |
17957 maxcut = 1 | |
17958 except: | |
17959 tkMessageBox.showerror("Try again.", "Annotation slice values not valid.") | |
17960 try: | |
17961 gen = open(genbank) | |
17962 outfile = open(out, "w") | |
17963 for line in gen: | |
17964 if line.startswith("ORIGIN"): | |
17965 getseq = True | |
17966 elif line.startswith("SQ Sequence"): | |
17967 getembl = True | |
17968 elif line.startswith(">"): | |
17969 if getmultifa: | |
17970 seq += "qqq" | |
17971 else: | |
17972 getmultifa = True | |
17973 elif line.startswith("//"): | |
17974 getseq = False | |
17975 getembl = False | |
17976 elif getseq: | |
17977 seq += "".join(line.split()[1:]) | |
17978 elif getembl: | |
17979 seq += "".join(line.split()[:-1]) | |
17980 elif getmultifa: | |
17981 seq += line.rstrip() | |
17982 if getmultifa: | |
17983 getset = set(seq) | |
17984 rightchars = set("atgcATGCqnNuUyYkKmMsSwWbBdDhHvVxXrR-") | |
17985 isitgood = True | |
17986 for i in getset: | |
17987 if not i in rightchars: | |
17988 isitgood = False | |
17989 if not isitgood: | |
17990 tkMessageBox.showerror( | |
17991 "Try again.", | |
17992 "Annotation file contains invalid characters.\ | |
17993 Check genbank/EMBL contains no lines starting with > or that\ | |
17994 fasta file contains only valid nucleotides", | |
17995 ) | |
17996 return 0 | |
17997 if "/" in out: | |
17998 outfile.write(">" + out.split("/")[1] + "\n") | |
17999 else: | |
18000 outfile.write(">" + out + "\n") | |
18001 if maxcut == "Max": | |
18002 maxcut = len(seq) | |
18003 if mincut == 1 and maxcut == len(seq): | |
18004 if getmultifa: | |
18005 seq = seq.replace("qqq", "n" * int(len(seq) / 500)) | |
18006 outfile.write(seq) | |
18007 elif mincut < maxcut: | |
18008 seq = seq[mincut - 1 : maxcut] | |
18009 if getmultifa: | |
18010 seq = seq.replace("qqq", "n" * int(len(seq) / 500)) | |
18011 outfile.write(seq) | |
18012 else: | |
18013 seq = seq[mincut - 1 :] + seq[:maxcut] | |
18014 if getmultifa: | |
18015 seq = seq.replace("qqq", "n" * int(len(seq) / 500)) | |
18016 outfile.write(seq) | |
18017 if len(seq) == 0: | |
18018 tkMessageBox.showerror( | |
18019 "Try again.", "There is no sequence in " + genbank + "." | |
18020 ) | |
18021 return 0 | |
18022 else: | |
18023 return 1 | |
18024 except: | |
18025 tkMessageBox.showerror("Try again.", genbank + " does not exist.") | |
18026 return 0 | |
18027 | |
18028 def genBlast(self): | |
18029 try: | |
18030 if self.thegenblast.isAlive(): | |
18031 tkMessageBox.showerror("Please wait", "BLAST already running.") | |
18032 return None | |
18033 except: | |
18034 pass | |
18035 try: | |
18036 if self.thethread.isAlive(): | |
18037 tkMessageBox.showerror("Please wait", "easyfig creating figure.") | |
18038 return None | |
18039 except: | |
18040 pass | |
18041 try: | |
18042 if self.thedlblast.isAlive(): | |
18043 tkMessageBox.showerror("Please wait", "Blast is downloading.") | |
18044 return None | |
18045 except: | |
18046 pass | |
18047 self.processLab.config(text="Performing blastn...") | |
18048 self.workingDir = tkFileDialog.askdirectory( | |
18049 title="Please select a working directory." | |
18050 ) | |
18051 if self.workingDir == (): | |
18052 self.processLab.config(text="Performing blastn...\nCancelled.") | |
18053 return None | |
18054 os.chdir(self.workingDir) | |
18055 index = 0 | |
18056 if self.genlist.size() < 2: | |
18057 tkMessageBox.showerror( | |
18058 "Try again.", | |
18059 "easyfig needs at least 2 genbank files to create blast files.", | |
18060 ) | |
18061 self.processLab.config(text="Performing blastn...\nCancelled.") | |
18062 return None | |
18063 else: | |
18064 thegenlist = self.genlist.get(0, END) | |
18065 for i in thegenlist: | |
18066 index += 1 | |
18067 temp = self.gbk2fasta( | |
18068 i[4:], | |
18069 str(index) + ".easyfig.fa", | |
18070 self.mincutlist[i[:2]], | |
18071 self.maxcutlist[i[:2]], | |
18072 ) | |
18073 if temp == 0: | |
18074 return None | |
18075 self.cutstate = (str(self.mincutlist), str(self.maxcutlist)) | |
18076 self.orderstate = self.genlist.get(0, END) | |
18077 if self.blastnDir == None: | |
18078 pass | |
18079 elif self.blastnDir[-11:] == "tblastx.exe": | |
18080 if os.path.exists(self.blastnDir[:-11] + "blastn.exe"): | |
18081 self.blastnDir = self.blastnDir[:-11] + "blastn.exe" | |
18082 else: | |
18083 self.blastnDir = None | |
18084 elif self.blastnDir[-7:] == "tblastx": | |
18085 if os.path.exists(self.blastnDir[:-7] + "blastn"): | |
18086 self.blastnDir = self.blastnDir[:-7] + "blastn" | |
18087 else: | |
18088 self.blastnDir = None | |
18089 if self.dbnDir != None: | |
18090 if not os.path.exists(self.dbnDir): | |
18091 self.dbnDir = None | |
18092 if self.blastnDir != None: | |
18093 if not os.path.exists(self.blastnDir): | |
18094 self.blastnDir = None | |
18095 if self.dbnDir != None: | |
18096 pass | |
18097 elif isNewBlastDB(): | |
18098 self.dbnDir = "makeblastdb" | |
18099 elif isLegBlastDB(): | |
18100 self.dblDir = "formatdb" | |
18101 elif os.path.exists("~/bin/makeblastdb"): | |
18102 self.dbnDir = "~/bin/makeblastdb" | |
18103 elif os.path.exists("/usr/local/ncbi/bin/makeblastdb"): | |
18104 self.blastnDir = "/usr/local/ncbi/bin/makeblastdb" | |
18105 elif os.path.exists("/usr/local/bin/makeblastdb"): | |
18106 self.dbnDir = "/usr/local/bin/makeblastdb" | |
18107 elif os.path.exists(self.pwd + "/makeblastdb"): | |
18108 self.dbnDir = self.pwd + "/makeblastdb" | |
18109 elif os.path.exists("/usr/local/ncbi/blast/bin/makeblastdb"): | |
18110 self.dbnDir = "/usr/local/ncbi/blast/bin/makeblastdb" | |
18111 elif os.path.exists("/usr/local/bin/formatdb"): | |
18112 self.dblDir = "/usr/local/bin/formatdb" | |
18113 elif os.path.exists("~/bin/formatdb"): | |
18114 self.dblDir = "~/bin/formatdb" | |
18115 elif os.path.exists(self.pwd + "/formatdb"): | |
18116 self.dblDir = self.pwd + "/formatdb" | |
18117 elif os.path.exists(self.pwd + "/makeblastdb.exe"): | |
18118 self.dbnDir = self.pwd + "/makeblastdb.exe" | |
18119 elif os.path.exists(self.pwd + "/formatdb.exe"): | |
18120 self.dblDir = self.pwd + "/formatdb.exe" | |
18121 else: | |
18122 folderlist = [] | |
18123 for letter in string.uppercase: | |
18124 if os.path.exists(letter + ":/program files/ncbi/"): | |
18125 folders = os.listdir(letter + ":/program files/ncbi/") | |
18126 for f in folders: | |
18127 if f.upper().startswith("BLAST"): | |
18128 folderlist.append(letter + ":/program files/ncbi/" + f) | |
18129 folderlist.sort(reverse=True) | |
18130 blastgot = False | |
18131 if len(folderlist) > 0: | |
18132 for f in folderlist: | |
18133 if not blastgot and os.path.exists(f + "/bin/makeblastdb.exe"): | |
18134 blastgot = True | |
18135 self.dblDir = '"' + f + '/bin/makeblastdb"' | |
18136 if self.blastnDir != None: | |
18137 pass | |
18138 elif isNewBlastn(): | |
18139 self.blastnDir = "blastn" | |
18140 elif isLegBlastall(): | |
18141 self.blastlDir = "blastall" | |
18142 elif os.path.exists("~/bin/blastn"): | |
18143 self.blastnDir = "~/bin/blastn" | |
18144 elif os.path.exists("/usr/local/ncbi/bin/blastn"): | |
18145 self.blastnDir = "/usr/local/ncbi/bin/blastn" | |
18146 elif os.path.exists("/usr/local/bin/blastn"): | |
18147 self.blastnDir = "/usr/local/bin/blastn" | |
18148 elif os.path.exists(self.pwd + "/blastn"): | |
18149 self.blastnDir = self.pwd + "/blastn" | |
18150 elif os.path.exists("/usr/local/ncbi/blast/bin/blastn"): | |
18151 self.blastnDir = "/usr/local/ncbi/blast/bin/blastn" | |
18152 elif os.path.exists("/usr/local/bin/blastall"): | |
18153 self.blastlDir = "/usr/local/bin/blastall" | |
18154 elif os.path.exists("~/bin/blastall"): | |
18155 self.blastlDir = "~/bin/blastall" | |
18156 elif os.path.exists(self.pwd + "/blastall"): | |
18157 self.blastlDir = self.pwd + "/blastall" | |
18158 elif os.path.exists(self.pwd + "/blastall.exe"): | |
18159 self.blastlDir = self.pwd + "/blastall.exe" | |
18160 elif os.path.exists(self.pwd + "/blastn.exe"): | |
18161 self.blastnDir = self.pwd + "/blastn.exe" | |
18162 else: | |
18163 folderlist = [] | |
18164 for letter in string.uppercase: | |
18165 if os.path.exists(letter + ":/program files/ncbi/"): | |
18166 folders = os.listdir(letter + ":/program files/ncbi/") | |
18167 for f in folders: | |
18168 if f.upper().startswith("BLAST"): | |
18169 folderlist.append(letter + ":/program files/ncbi/" + f) | |
18170 folderlist.sort(reverse=True) | |
18171 blastgot = False | |
18172 if len(folderlist) > 0: | |
18173 for f in folderlist: | |
18174 if not blastgot and os.path.exists(f + "/bin/blastn.exe"): | |
18175 blastgot = True | |
18176 self.blastnDir = '"' + f + '/bin/blastn"' | |
18177 if ( | |
18178 self.blastnDir == None | |
18179 and self.blastlDir == None | |
18180 or self.dbnDir == None | |
18181 and self.dblDir == None | |
18182 ): | |
18183 dlblast = tkMessageBox.askquestion( | |
18184 "Blast not found", "Do you wish to download Blast?" | |
18185 ) | |
18186 if dlblast != "no": | |
18187 self.thedlblast = threading.Thread(target=self.downloadBlast) | |
18188 self.thedlblast.start() | |
18189 return None | |
18190 tempdir = tkFileDialog.askdirectory( | |
18191 title="Please select a directory with blastn and makeblastdb." | |
18192 ) | |
18193 if tempdir == (): | |
18194 tempdir = "" | |
18195 if os.path.exists(tempdir + "/blastn.exe") and os.path.exists( | |
18196 tempdir + "/makeblastdb.exe" | |
18197 ): | |
18198 self.blastnDir = tempdir + "/blastn.exe" | |
18199 self.dbnDir = tempdir + "/makeblastdb.exe" | |
18200 elif os.path.exists(tempdir + "/blastn") and os.path.exists( | |
18201 tempdir + "/makeblastdb" | |
18202 ): | |
18203 self.blastnDir = tempdir + "/blastn" | |
18204 self.dbnDir = tempdir + "/makeblastdb" | |
18205 else: | |
18206 self.processLab.config( | |
18207 text="Performing blastn...\nInvadild directory.\nBlast not found." | |
18208 ) | |
18209 self.blastnDir = None | |
18210 self.dbnDir = None | |
18211 return None | |
18212 if self.workingDir == "": | |
18213 self.processLab.config(text="Performing blastn...\nCancelled.") | |
18214 return None | |
18215 self.thegenblast = threading.Thread(target=self.genBlast2) | |
18216 self.thegenblast.start() | |
18217 self.thegenblast2 = threading.Thread(target=self.genBlastDot) | |
18218 self.thegenblast2.start() | |
18219 | |
18220 def genBlastDot(self): | |
18221 while self.thegenblast.isAlive(): | |
18222 time.sleep(0.5) | |
18223 self.processLab.config(text="Performing blastn.") | |
18224 time.sleep(0.5) | |
18225 self.processLab.config(text="Performing blastn..") | |
18226 time.sleep(0.5) | |
18227 self.processLab.config(text="Performing blastn...") | |
18228 if self.blastlist.size() == self.genlist.size() - 1: | |
18229 self.processLab.config(text="Performing blastn...\ncomplete.") | |
18230 else: | |
18231 self.processLab.config( | |
18232 text="Blast has failed, please check genbank files and rerun." | |
18233 ) | |
18234 | |
18235 def genBlast2(self): | |
18236 self.blastlist.delete(0, END) | |
18237 the_tempdb_dir = os.path.abspath(".") + "/tempdb" | |
18238 for i in range(self.genlist.size() - 1): | |
18239 if self.dbnDir != None: | |
18240 subprocess.Popen( | |
18241 self.dbnDir | |
18242 + " -dbtype nucl -out " | |
18243 + the_tempdb_dir | |
18244 + " -in " | |
18245 + str(i + 2) | |
18246 + ".easyfig.fa", | |
18247 shell=True, | |
18248 ).wait() | |
18249 elif self.dblDir != None: | |
18250 subprocess.Popen( | |
18251 self.dblDir | |
18252 + " -p F -t tempdb -n tempdb -i " | |
18253 + str(i + 2) | |
18254 + ".easyfig.fa", | |
18255 shell=True, | |
18256 ).wait() | |
18257 if self.blastnDir: | |
18258 subprocess.Popen( | |
18259 self.blastnDir | |
18260 + " -task blastn -db " | |
18261 + the_tempdb_dir | |
18262 + " -outfmt 6 -query " | |
18263 + str(i + 1) | |
18264 + ".easyfig.fa -out " | |
18265 + str(i + 1) | |
18266 + str(i + 2) | |
18267 + ".easyfig.out", | |
18268 shell=True, | |
18269 ).wait() | |
18270 elif self.blastlDir: | |
18271 subprocess.Popen( | |
18272 self.blastlDir | |
18273 + " -p blastn -d " | |
18274 + the_tempdb_dir | |
18275 + " -F F -m 8 -a 8 -i " | |
18276 + str(i + 1) | |
18277 + ".easyfig.fa -o " | |
18278 + str(i + 1) | |
18279 + str(i + 2) | |
18280 + ".easyfig.out", | |
18281 shell=True, | |
18282 ).wait() | |
18283 self.blastlist.insert( | |
18284 END, self.workingDir + "/" + str(i + 1) + str(i + 2) + ".easyfig.out" | |
18285 ) | |
18286 self.blastlist.xview_moveto(1) | |
18287 if os.path.exists("tempdb.nhr"): | |
18288 os.remove("tempdb.nhr") | |
18289 if os.path.exists("tempdb.nin"): | |
18290 os.remove("tempdb.nin") | |
18291 if os.path.exists("error.log"): | |
18292 os.remove("error.log") | |
18293 if os.path.exists("tempdb.nsq"): | |
18294 os.remove("tempdb.nsq") | |
18295 if os.path.exists("formatdb.log"): | |
18296 os.remove("formatdb.log") | |
18297 os.chdir(self.pwd) | |
18298 | |
18299 def genBlastX(self): | |
18300 try: | |
18301 if self.thegenblast.isAlive(): | |
18302 tkMessageBox.showerror("Please wait", "BLAST already running.") | |
18303 return None | |
18304 except: | |
18305 pass | |
18306 try: | |
18307 if self.thethread.isAlive(): | |
18308 tkMessageBox.showerror("Please wait", "easyfig creating figure.") | |
18309 return None | |
18310 except: | |
18311 pass | |
18312 try: | |
18313 if self.thedlblast.isAlive(): | |
18314 tkMessageBox.showerror("Please wait", "Blast is downloading.") | |
18315 return None | |
18316 except: | |
18317 pass | |
18318 self.workingDir = tkFileDialog.askdirectory( | |
18319 title="Please select a working directory." | |
18320 ) | |
18321 if self.workingDir == (): | |
18322 self.processLab.config(text="Performing tblastx...\nCancelled.") | |
18323 return | |
18324 os.chdir(self.workingDir) | |
18325 index = 0 | |
18326 if self.genlist.size() < 2: | |
18327 tkMessageBox.showerror( | |
18328 "Try again.", | |
18329 "easyfig needs at least 2 genbank files to create blast files.", | |
18330 ) | |
18331 else: | |
18332 thegenlist = self.genlist.get(0, END) | |
18333 for i in thegenlist: | |
18334 index += 1 | |
18335 temp = self.gbk2fasta( | |
18336 i[4:], | |
18337 str(index) + ".easyfig.fa", | |
18338 self.mincutlist[i[:2]], | |
18339 self.maxcutlist[i[:2]], | |
18340 ) | |
18341 if temp == 0: | |
18342 return None | |
18343 self.cutstate = (str(self.mincutlist), str(self.maxcutlist)) | |
18344 self.orderstate = self.genlist.get(0, END) | |
18345 if self.blastnDir == None: | |
18346 pass | |
18347 elif self.blastnDir[-10:] == "blastn.exe": | |
18348 if os.path.exists(self.blastnDir[:-10] + "tblastx.exe"): | |
18349 self.blastnDir = self.blastnDir[:-10] + "tblastx.exe" | |
18350 else: | |
18351 self.blastnDir = None | |
18352 elif self.blastnDir[-6:] == "blastn": | |
18353 if os.path.exists(self.blastnDir[:-6] + "tblastx"): | |
18354 self.blastnDir = self.blastnDir[:-6] + "tblastx" | |
18355 else: | |
18356 self.blastnDir = None | |
18357 if self.dbnDir != None: | |
18358 if not os.path.exists(self.dbnDir): | |
18359 self.dbnDir = None | |
18360 if self.blastnDir != None: | |
18361 if not os.path.exists(self.blastnDir): | |
18362 self.blastnDir = None | |
18363 if self.dbnDir != None: | |
18364 pass | |
18365 elif isNewBlastDB(): | |
18366 self.dbnDir = "makeblastdb" | |
18367 elif isLegBlastDB(): | |
18368 self.dblDir = "formatdb" | |
18369 elif os.path.exists("~/bin/makeblastdb"): | |
18370 self.dbnDir = "~/bin/makeblastdb" | |
18371 elif os.path.exists("/usr/local/bin/makeblastdb"): | |
18372 self.dbnDir = "/usr/local/bin/makeblastdb" | |
18373 elif os.path.exists("./makeblastdb"): | |
18374 self.dbnDir = "./makeblastdb" | |
18375 elif os.path.exists("/usr/local/ncbi/bin/makeblastdb"): | |
18376 self.blastnDir = "/usr/local/ncbi/bin/makeblastdb" | |
18377 elif os.path.exists("/usr/local/ncbi/blast/bin/makeblastdb"): | |
18378 self.dbnDir = "/usr/local/ncbi/blast/bin/makeblastdb" | |
18379 elif os.path.exists("/usr/local/bin/formatdb"): | |
18380 self.dblDir = "/usr/local/bin/formatdb" | |
18381 elif os.path.exists("~/bin/formatdb"): | |
18382 self.dblDir = "~/bin/formatdb" | |
18383 elif os.path.exists("./formatdb"): | |
18384 self.dblDir = "./formatdb" | |
18385 elif os.path.exists("./makeblastdb.exe"): | |
18386 self.dbnDir = "./makeblastdb.exe" | |
18387 elif os.path.exists("./formatdb.exe"): | |
18388 self.dblDir = "./formatdb.exe" | |
18389 else: | |
18390 folderlist = [] | |
18391 for letter in string.uppercase: | |
18392 if os.path.exists(letter + ":/program files/ncbi/"): | |
18393 folders = os.listdir(letter + ":/program files/ncbi/") | |
18394 for f in folders: | |
18395 if f.upper().startswith("BLAST"): | |
18396 folderlist.append(letter + ":/program files/ncbi/" + f) | |
18397 folderlist.sort(reverse=True) | |
18398 blastgot = False | |
18399 if len(folderlist) > 0: | |
18400 for f in folderlist: | |
18401 if not blastgot and os.path.exists(f + "/bin/makeblastdb.exe"): | |
18402 blastgot = True | |
18403 self.dblDir = '"' + f + '/bin/makeblastdb"' | |
18404 if self.blastnDir != None: | |
18405 pass | |
18406 elif isNewTblastx(): | |
18407 self.blastnDir = "tblastx" | |
18408 elif isLegBlastall(): | |
18409 self.blastlDir = "blastall" | |
18410 elif os.path.exists("~/bin/tblastx"): | |
18411 self.blastnDir = "~/bin/tblastx" | |
18412 elif os.path.exists("/usr/local/ncbi/bin/tblastx"): | |
18413 self.blastnDir = "/usr/local/ncbi/bin/tblastx" | |
18414 elif os.path.exists("/usr/local/bin/tblastx"): | |
18415 self.blastnDir = "/usr/local/bin/tblastx" | |
18416 elif os.path.exists("./tblastx"): | |
18417 self.blastnDir = "./tblastx" | |
18418 elif os.path.exists("/usr/local/ncbi/blast/bin/tblastx"): | |
18419 self.blastnDir = "/usr/local/ncbi/blast/bin/tblastx" | |
18420 elif os.path.exists("/usr/local/bin/blastall"): | |
18421 self.blastlDir = "/usr/local/bin/blastall" | |
18422 elif os.path.exists("~/bin/blastall"): | |
18423 self.blastlDir = "~/bin/blastall" | |
18424 elif os.path.exists("./blastall"): | |
18425 self.blastlDir = "./blastall" | |
18426 elif os.path.exists("./tblastx.exe"): | |
18427 self.blastnDir = "./tblastx.exe" | |
18428 else: | |
18429 folderlist = [] | |
18430 for letter in string.uppercase: | |
18431 if os.path.exists(letter + ":/program files/ncbi/"): | |
18432 folders = os.listdir(letter + ":/program files/ncbi/") | |
18433 for f in folders: | |
18434 if f.upper().startswith("BLAST"): | |
18435 folderlist.append(letter + ":/program files/ncbi/" + f) | |
18436 folderlist.sort(reverse=True) | |
18437 blastgot = False | |
18438 if len(folderlist) > 0: | |
18439 for f in folderlist: | |
18440 if not blastgot and os.path.exists(f + "/bin/tblastx.exe"): | |
18441 blastgot = True | |
18442 self.blastnDir = '"' + f + '/bin/tblastx.exe"' | |
18443 if ( | |
18444 self.blastnDir == None | |
18445 and self.blastlDir == None | |
18446 or self.dbnDir == None | |
18447 and self.dbl == None | |
18448 ): | |
18449 dlblast = tkMessageBox.askquestion( | |
18450 "Blast not found", "Do you wish to download Blast?" | |
18451 ) | |
18452 if dlblast: | |
18453 self.thedlblast = threading.Thread(target=self.downloadBlast) | |
18454 self.thedlblast.start() | |
18455 return None | |
18456 tempdir = tkFileDialog.askdirectory( | |
18457 title="Please select a directory with tblastx and makeblastdb." | |
18458 ) | |
18459 if os.path.exists(tempdir + "/tblastx.exe") and os.path.exists( | |
18460 tempdir + "/makeblastdb.exe" | |
18461 ): | |
18462 self.blastnDir = tempdir + "/tblastx.exe" | |
18463 self.dbnDir = tempdir + "/makeblastdb.exe" | |
18464 elif os.path.exists(tempdir + "/tblastx") and os.path.exists( | |
18465 tempdir + "/makeblastdb" | |
18466 ): | |
18467 self.blastnDir = tempdir + "/tblastx" | |
18468 self.dbnDir = tempdir + "/makeblastdb" | |
18469 else: | |
18470 self.processLab.config( | |
18471 text="Performing blastn...\nInvadild directory.\nBlast not found." | |
18472 ) | |
18473 return None | |
18474 if self.workingDir == "": | |
18475 self.processLab.config(text="Performing blastn...\nCancelled.") | |
18476 return None | |
18477 self.thegenblast = threading.Thread(target=self.genBlastX2) | |
18478 self.thegenblast.start() | |
18479 self.thegenblast2 = threading.Thread(target=self.genBlastXdot) | |
18480 self.thegenblast2.start() | |
18481 | |
18482 def genBlastXdot(self): | |
18483 while self.thegenblast.isAlive(): | |
18484 time.sleep(0.5) | |
18485 self.processLab.config(text="Performing tblastx.") | |
18486 time.sleep(0.5) | |
18487 self.processLab.config(text="Performing tblastx..") | |
18488 time.sleep(0.5) | |
18489 self.processLab.config(text="Performing tblastx...") | |
18490 self.processLab.config(text="Performing tblastx...\ncomplete.") | |
18491 | |
18492 def genBlastX2(self): | |
18493 self.blastlist.delete(0, END) | |
18494 for i in range(self.genlist.size() - 1): | |
18495 if self.dbnDir != None: | |
18496 subprocess.Popen( | |
18497 self.dbnDir | |
18498 + " -dbtype nucl -out tempdb -in " | |
18499 + str(i + 2) | |
18500 + ".easyfig.fa", | |
18501 shell=True, | |
18502 ).wait() | |
18503 elif self.dblDir != None: | |
18504 subprocess.Popen( | |
18505 self.dblDir | |
18506 + " -p F -t tempdb -n tempdb -i " | |
18507 + str(i + 2) | |
18508 + ".easyfig.fa", | |
18509 shell=True, | |
18510 ).wait() | |
18511 if self.blastnDir: | |
18512 subprocess.Popen( | |
18513 self.blastnDir | |
18514 + " -db tempdb -outfmt 6 -query " | |
18515 + str(i + 1) | |
18516 + ".easyfig.fa -out " | |
18517 + str(i + 1) | |
18518 + str(i + 2) | |
18519 + ".easyfig.out", | |
18520 shell=True, | |
18521 ).wait() | |
18522 elif self.blastlDir: | |
18523 subprocess.Popen( | |
18524 self.blastlDir | |
18525 + " -p tblastx -d tempdb -F F -m 8 -a 8 -i " | |
18526 + str(i + 1) | |
18527 + ".easyfig.fa -o " | |
18528 + str(i + 1) | |
18529 + str(i + 2) | |
18530 + ".easyfig.out", | |
18531 shell=True, | |
18532 ).wait() | |
18533 self.blastlist.insert( | |
18534 END, self.workingDir + "/" + str(i + 1) + str(i + 2) + ".easyfig.out" | |
18535 ) | |
18536 self.blastlist.xview_moveto(1) | |
18537 if os.path.exists("tempdb.nhr"): | |
18538 os.remove("tempdb.nhr") | |
18539 if os.path.exists("tempdb.nin"): | |
18540 os.remove("tempdb.nin") | |
18541 if os.path.exists("error.log"): | |
18542 os.remove("error.log") | |
18543 if os.path.exists("tempdb.nsq"): | |
18544 os.remove("tempdb.nsq") | |
18545 if os.path.exists("formatdb.log"): | |
18546 os.remove("formatdb.log") | |
18547 os.chdir(self.pwd) | |
18548 | |
18549 def annmod(self, event=None): | |
18550 try: | |
18551 self.annwindow.destroy() | |
18552 except: | |
18553 pass | |
18554 self.annwindow = Toplevel() | |
18555 self.frame6 = Frame(self.annwindow) | |
18556 self.annwindow.title("Subregions") | |
18557 self.frangelab = Label(self.frame6, text="Range", font="TkDefaultFont 13 bold") | |
18558 self.frangelab.grid(row=0, column=2, columnspan=3) | |
18559 self.ffilelab = Label( | |
18560 self.frame6, text="Ann. file", font="TkDefaultFont 13 bold" | |
18561 ) | |
18562 self.ffilelab.grid(row=1, column=1, pady=10) | |
18563 self.fminlab = Label(self.frame6, text="Min", font="TkDefaultFont 13 bold") | |
18564 self.fminlab.grid(row=1, column=2, pady=10) | |
18565 self.fdotdot = Label(self.frame6, text=" .. ") | |
18566 self.fdotdot.grid(row=1, column=3) | |
18567 self.fmaxlab = Label(self.frame6, text="Max", font="TkDefaultFont 13 bold") | |
18568 self.fmaxlab.grid(row=1, column=4, pady=10) | |
18569 self.frevlab = Label(self.frame6, text="Reverse", font="TkDefaultFont 13 bold") | |
18570 self.frevlab.grid(row=1, column=5, pady=10) | |
18571 self.scrollbar2 = Scrollbar(self.frame6, orient=VERTICAL) | |
18572 self.fgenlist = Listbox( | |
18573 self.frame6, yscrollcommand=self.scrollbar2.set, exportselection=0 | |
18574 ) | |
18575 self.fgenlist.bind("<Button-1>", self.setselectedcuts) | |
18576 self.fgenlist.bind("<Double-Button-1>", self.doublecuts) | |
18577 self.fgenlist.bind("<MouseWheel>", self.onmousewheel) | |
18578 self.fgenlist.bind("<Button-4>", self.onmousewheel) | |
18579 self.fgenlist.bind("<Button-5>", self.onmousewheel) | |
18580 self.fgenlist.grid(row=2, column=1) | |
18581 self.fgenminlist = Listbox( | |
18582 self.frame6, yscrollcommand=self.scrollbar2.set, exportselection=0 | |
18583 ) | |
18584 self.fgenminlist.config(width=7) | |
18585 self.fgenminlist.bind("<Button-1>", self.setselectedcuts) | |
18586 self.fgenminlist.bind("<Double-Button-1>", self.doublecuts) | |
18587 self.fgenminlist.bind("<MouseWheel>", self.onmousewheel) | |
18588 self.fgenminlist.bind("<Button-4>", self.onmousewheel) | |
18589 self.fgenminlist.bind("<Button-5>", self.onmousewheel) | |
18590 self.fgenminlist.grid(row=2, column=2) | |
18591 self.fgenmaxlist = Listbox( | |
18592 self.frame6, yscrollcommand=self.scrollbar2.set, exportselection=0 | |
18593 ) | |
18594 self.fgenmaxlist.config(width=7) | |
18595 self.fgenmaxlist.bind("<Button-1>", self.setselectedcuts) | |
18596 self.fgenmaxlist.bind("<Double-Button-1>", self.doublecuts) | |
18597 self.fgenmaxlist.bind("<MouseWheel>", self.onmousewheel) | |
18598 self.fgenmaxlist.bind("<Button-4>", self.onmousewheel) | |
18599 self.fgenmaxlist.bind("<Button-5>", self.onmousewheel) | |
18600 self.fgenmaxlist.grid(row=2, column=4) | |
18601 self.fgenrevlist = Listbox( | |
18602 self.frame6, yscrollcommand=self.scrollbar2.set, exportselection=0 | |
18603 ) | |
18604 self.fgenrevlist.config(width=5) | |
18605 self.fgenrevlist.bind("<Button-1>", self.setselectedcuts) | |
18606 self.fgenrevlist.bind("<Double-Button-1>", self.doublecuts) | |
18607 self.fgenrevlist.bind("<MouseWheel>", self.onmousewheel) | |
18608 self.fgenrevlist.bind("<Button-4>", self.onmousewheel) | |
18609 self.fgenrevlist.bind("<Button-5>", self.onmousewheel) | |
18610 self.fgenrevlist.grid(row=2, column=5) | |
18611 self.scrollbar2.config(command=self.yview2) | |
18612 self.scrollbar2.grid(row=2, column=0, sticky=NS) | |
18613 annlist = self.genlist.get(0, END) | |
18614 annlistpostemp = self.genlist.curselection() | |
18615 for i in annlist: | |
18616 self.fgenlist.insert(END, i) | |
18617 self.fgenminlist.insert(END, self.mincutlist[i[:2]]) | |
18618 self.fgenmaxlist.insert(END, self.maxcutlist[i[:2]]) | |
18619 if self.revlist[i[:2]]: | |
18620 self.fgenrevlist.insert(END, "yes") | |
18621 else: | |
18622 self.fgenrevlist.insert(END, "no") | |
18623 self.fgenlist.xview_moveto(1) | |
18624 self.genmincut = StringVar() | |
18625 self.genmaxcut = StringVar() | |
18626 self.genrev = IntVar() | |
18627 self.mincutentry = Entry(self.frame6, textvariable=self.genmincut) | |
18628 self.mincutentry.config(width=7) | |
18629 self.mincutentry.grid(row=3, column=2) | |
18630 self.maxcutentry = Entry(self.frame6, textvariable=self.genmaxcut) | |
18631 self.maxcutentry.config(width=7) | |
18632 self.maxcutentry.grid(row=3, column=4) | |
18633 self.genrentry = Checkbutton(self.frame6, variable=self.genrev) | |
18634 self.genrentry.grid(row=3, column=5) | |
18635 if len(annlist) > 0 and annlistpostemp != (): | |
18636 self.fgenlist.selection_set(annlistpostemp) | |
18637 self.fgenminlist.selection_set(annlistpostemp) | |
18638 self.fgenmaxlist.selection_set(annlistpostemp) | |
18639 self.fgenrevlist.selection_set(annlistpostemp) | |
18640 self.fgenlist.see(annlistpostemp) | |
18641 self.fgenminlist.see(annlistpostemp) | |
18642 self.fgenmaxlist.see(annlistpostemp) | |
18643 self.fgenrevlist.see(annlistpostemp) | |
18644 self.genmincut.set(self.fgenminlist.get(annlistpostemp)) | |
18645 self.genmaxcut.set(self.fgenmaxlist.get(annlistpostemp)) | |
18646 if self.fgenrevlist.get(annlistpostemp) == "yes": | |
18647 self.genrev.set(1) | |
18648 else: | |
18649 self.genrev.set(0) | |
18650 self.changecutsbutton = Button( | |
18651 self.frame6, text=" change cutoffs ", command=self.changecuts | |
18652 ) | |
18653 self.changecutsbutton.grid(row=3, column=1, pady=10) | |
18654 self.annwindowclosebutton = Button( | |
18655 self.frame6, text="close", command=self.annwindowclose | |
18656 ) | |
18657 self.annwindowclosebutton.grid( | |
18658 row=12, column=4, columnspan=2, sticky=E, pady=10 | |
18659 ) | |
18660 self.annwindow.geometry("+30+40") | |
18661 self.frame6.grid(padx=30, pady=10) | |
18662 | |
18663 def changecuts(self): | |
18664 thepost = self.fgenlist.curselection() | |
18665 if thepost == (): | |
18666 tkMessageBox.showerror("Try again.", "Please select genome to change.") | |
18667 return | |
18668 else: | |
18669 thepost = int(thepost[0]) | |
18670 self.fgenminlist.delete(thepost) | |
18671 self.fgenminlist.insert(thepost, self.genmincut.get()) | |
18672 self.mincutlist[self.fgenlist.get(thepost)[:2]] = self.genmincut.get() | |
18673 self.fgenmaxlist.delete(thepost) | |
18674 self.fgenmaxlist.insert(thepost, self.genmaxcut.get()) | |
18675 self.maxcutlist[self.fgenlist.get(thepost)[:2]] = self.genmaxcut.get() | |
18676 self.fgenrevlist.delete(thepost) | |
18677 if self.genrev.get() == 1: | |
18678 self.fgenrevlist.insert(thepost, "yes") | |
18679 self.revlist[self.fgenlist.get(thepost)[:2]] = True | |
18680 else: | |
18681 self.fgenrevlist.insert(thepost, "no") | |
18682 self.revlist[self.fgenlist.get(thepost)[:2]] = False | |
18683 if not thepost == self.fgenlist.size() - 1: | |
18684 self.fgenlist.selection_clear(0, END) | |
18685 self.fgenlist.selection_set(thepost + 1, thepost + 1) | |
18686 self.fgenlist.see(thepost + 1) | |
18687 self.fgenminlist.selection_clear(0, END) | |
18688 self.fgenminlist.selection_set(thepost + 1, thepost + 1) | |
18689 self.fgenminlist.see(thepost + 1) | |
18690 self.fgenmaxlist.selection_clear(0, END) | |
18691 self.fgenmaxlist.selection_set(thepost + 1, thepost + 1) | |
18692 self.fgenmaxlist.see(thepost + 1) | |
18693 self.fgenrevlist.selection_clear(0, END) | |
18694 self.fgenrevlist.selection_set(thepost + 1, thepost + 1) | |
18695 self.fgenrevlist.see(thepost + 1) | |
18696 | |
18697 def yview2(self, *args): | |
18698 apply(self.fgenlist.yview, args) | |
18699 apply(self.fgenminlist.yview, args) | |
18700 apply(self.fgenmaxlist.yview, args) | |
18701 apply(self.fgenrevlist.yview, args) | |
18702 | |
18703 def onmousewheel(self, event): | |
18704 return "break" | |
18705 | |
18706 def setselectedcuts(self, event): | |
18707 selected = self.fgenlist.nearest(event.y) | |
18708 tempypos = self.fgenlist.yview()[0] | |
18709 self.fgenminlist.yview_moveto(tempypos) | |
18710 self.fgenmaxlist.yview_moveto(tempypos) | |
18711 self.fgenrevlist.yview_moveto(tempypos) | |
18712 self.fgenlist.selection_clear(0, END) | |
18713 self.fgenlist.selection_set(selected, selected) | |
18714 self.fgenminlist.selection_clear(0, END) | |
18715 self.fgenminlist.selection_set(selected, selected) | |
18716 self.fgenmaxlist.selection_clear(0, END) | |
18717 self.fgenmaxlist.selection_set(selected, selected) | |
18718 self.fgenrevlist.selection_clear(0, END) | |
18719 self.fgenrevlist.selection_set(selected, selected) | |
18720 self.genmincut.set(self.fgenminlist.get(selected)) | |
18721 self.genmaxcut.set(self.fgenmaxlist.get(selected)) | |
18722 if self.fgenrevlist.get(selected) == "yes": | |
18723 self.genrev.set(1) | |
18724 else: | |
18725 self.genrev.set(0) | |
18726 | |
18727 def doublecuts(self, event): | |
18728 try: | |
18729 self.doublecutswin.destroy() | |
18730 except: | |
18731 pass | |
18732 self.doublecutsel = self.fgenlist.nearest(event.y) | |
18733 self.doublecutswin = Toplevel(self.frame6) | |
18734 self.doublecutswin.title("Change subregion") | |
18735 self.frame10 = Frame(self.doublecutswin) | |
18736 self.dublabel1 = Label( | |
18737 self.frame10, | |
18738 text="Modify file " + self.fgenlist.get(self.doublecutsel)[:3], | |
18739 font="TkDefaultFont 13 bold", | |
18740 ) | |
18741 self.dublabel1.grid(row=0, column=0, pady=5) | |
18742 self.dublabel2 = Label(self.frame10, text="Min Cutoff:") | |
18743 self.dublabel2.grid(row=1, column=0) | |
18744 self.dublabel3 = Label(self.frame10, text="Max Cutoff:") | |
18745 self.dublabel3.grid(row=2, column=0) | |
18746 self.dublabel4 = Label(self.frame10, text="Reverse:") | |
18747 self.dublabel4.grid(row=3, column=0) | |
18748 self.dublabel2str = StringVar(value=self.fgenminlist.get(self.doublecutsel)) | |
18749 self.dublabel3str = StringVar(value=self.fgenmaxlist.get(self.doublecutsel)) | |
18750 if self.fgenrevlist.get(self.doublecutsel) == "yes": | |
18751 self.dublabel4int = IntVar(value=1) | |
18752 else: | |
18753 self.dublabel4int = IntVar(value=0) | |
18754 self.dublabel2ent = Entry(self.frame10, textvariable=self.dublabel2str) | |
18755 self.dublabel2ent.grid(row=1, column=1) | |
18756 self.dublabel3ent = Entry(self.frame10, textvariable=self.dublabel3str) | |
18757 self.dublabel3ent.grid(row=2, column=1) | |
18758 self.dublabel4ent = Checkbutton(self.frame10, variable=self.dublabel4int) | |
18759 self.dublabel4ent.grid(row=3, column=1) | |
18760 self.doublecutsclosebut = Button( | |
18761 self.frame10, text="Save & Close", command=self.doublecutsclose | |
18762 ) | |
18763 self.doublecutsclosebut.grid(row=4, column=1, sticky=E) | |
18764 self.doublecutswin.geometry("+40+50") | |
18765 self.frame10.grid(padx=20, pady=20) | |
18766 | |
18767 def doublecutsclose(self): | |
18768 self.fgenminlist.delete(self.doublecutsel) | |
18769 self.fgenminlist.insert(self.doublecutsel, self.dublabel2str.get()) | |
18770 self.mincutlist[ | |
18771 self.fgenlist.get(self.doublecutsel)[:2] | |
18772 ] = self.dublabel2str.get() | |
18773 self.fgenmaxlist.delete(self.doublecutsel) | |
18774 self.fgenmaxlist.insert(self.doublecutsel, self.dublabel3str.get()) | |
18775 self.maxcutlist[ | |
18776 self.fgenlist.get(self.doublecutsel)[:2] | |
18777 ] = self.dublabel3str.get() | |
18778 self.fgenrevlist.delete(self.doublecutsel) | |
18779 if self.dublabel4int.get() == 1: | |
18780 self.fgenrevlist.insert(self.doublecutsel, "yes") | |
18781 self.revlist[self.fgenlist.get(self.doublecutsel)[:2]] = True | |
18782 else: | |
18783 self.fgenrevlist.insert(self.doublecutsel, "no") | |
18784 self.revlist[self.fgenlist.get(self.doublecutsel)[:2]] = False | |
18785 self.doublecutswin.destroy() | |
18786 | |
18787 def annwindowclose(self): | |
18788 self.annwindow.destroy() | |
18789 | |
18790 def openFile1(self): | |
18791 filename = tkFileDialog.askopenfilename( | |
18792 filetypes=[ | |
18793 ( | |
18794 "genbank/embl/fasta", | |
18795 ( | |
18796 "*.gbk", | |
18797 "*.embl", | |
18798 "*.gb", | |
18799 "*.fa", | |
18800 "*.fna", | |
18801 "*.dna", | |
18802 "*.fas", | |
18803 "*.fasta", | |
18804 ), | |
18805 ), | |
18806 ("All files", "*"), | |
18807 ] | |
18808 ) | |
18809 self.gen1.set(filename) | |
18810 | |
18811 def openFile2(self): | |
18812 filename = tkFileDialog.askopenfilename( | |
18813 filetypes=[ | |
18814 ( | |
18815 "genbank/embl/fasta", | |
18816 ( | |
18817 "*.gbk", | |
18818 "*.embl", | |
18819 "*.gb", | |
18820 "*.fa", | |
18821 "*.fna", | |
18822 "*.dna", | |
18823 "*.fas", | |
18824 "*.fasta", | |
18825 ), | |
18826 ), | |
18827 ("All files", "*"), | |
18828 ] | |
18829 ) | |
18830 self.gen2.set(filename) | |
18831 | |
18832 def openFile3(self): | |
18833 filename = tkFileDialog.askopenfilename( | |
18834 filetypes=[ | |
18835 ( | |
18836 "genbank/embl/fasta", | |
18837 ( | |
18838 "*.gbk", | |
18839 "*.embl", | |
18840 "*.gb", | |
18841 "*.fa", | |
18842 "*.fna", | |
18843 "*.dna", | |
18844 "*.fas", | |
18845 "*.fasta", | |
18846 ), | |
18847 ), | |
18848 ("All files", "*"), | |
18849 ] | |
18850 ) | |
18851 self.gen3.set(filename) | |
18852 | |
18853 def openFile4(self): | |
18854 filename = tkFileDialog.askopenfilename( | |
18855 filetypes=[ | |
18856 ( | |
18857 "genbank/embl/fasta", | |
18858 ( | |
18859 "*.gbk", | |
18860 "*.embl", | |
18861 "*.gb", | |
18862 "*.fa", | |
18863 "*.fna", | |
18864 "*.dna", | |
18865 "*.fas", | |
18866 "*.fasta", | |
18867 ), | |
18868 ), | |
18869 ("All files", "*"), | |
18870 ] | |
18871 ) | |
18872 self.gen4.set(filename) | |
18873 | |
18874 def openFile5(self): | |
18875 filename = tkFileDialog.askopenfilename( | |
18876 filetypes=[ | |
18877 ( | |
18878 "genbank/embl/fasta", | |
18879 ( | |
18880 "*.gbk", | |
18881 "*.embl", | |
18882 "*.gb", | |
18883 "*.fa", | |
18884 "*.fna", | |
18885 "*.dna", | |
18886 "*.fas", | |
18887 "*.fasta", | |
18888 ), | |
18889 ), | |
18890 ("All files", "*"), | |
18891 ] | |
18892 ) | |
18893 self.gen5.set(filename) | |
18894 | |
18895 def openFile6(self): | |
18896 filename = tkFileDialog.askopenfilename( | |
18897 filetypes=[ | |
18898 ( | |
18899 "genbank/embl/fasta", | |
18900 ( | |
18901 "*.gbk", | |
18902 "*.embl", | |
18903 "*.gb", | |
18904 "*.fa", | |
18905 "*.fna", | |
18906 "*.dna", | |
18907 "*.fas", | |
18908 "*.fasta", | |
18909 ), | |
18910 ), | |
18911 ("All files", "*"), | |
18912 ] | |
18913 ) | |
18914 self.gen6.set(filename) | |
18915 | |
18916 def openFile7(self): | |
18917 filename = tkFileDialog.askopenfilename( | |
18918 filetypes=[ | |
18919 ( | |
18920 "genbank/embl/fasta", | |
18921 ( | |
18922 "*.gbk", | |
18923 "*.embl", | |
18924 "*.gb", | |
18925 "*.fa", | |
18926 "*.fna", | |
18927 "*.dna", | |
18928 "*.fas", | |
18929 "*.fasta", | |
18930 ), | |
18931 ), | |
18932 ("All files", "*"), | |
18933 ] | |
18934 ) | |
18935 self.gen7.set(filename) | |
18936 | |
18937 def openFile8(self): | |
18938 filename = tkFileDialog.askopenfilename( | |
18939 filetypes=[ | |
18940 ( | |
18941 "genbank/embl/fasta", | |
18942 ( | |
18943 "*.gbk", | |
18944 "*.embl", | |
18945 "*.gb", | |
18946 "*.fa", | |
18947 "*.fna", | |
18948 "*.dna", | |
18949 "*.fas", | |
18950 "*.fasta", | |
18951 ), | |
18952 ), | |
18953 ("All files", "*"), | |
18954 ] | |
18955 ) | |
18956 self.gen8.set(filename) | |
18957 | |
18958 def openFile9(self): | |
18959 filename = tkFileDialog.askopenfilename( | |
18960 filetypes=[ | |
18961 ( | |
18962 "genbank/embl/fasta", | |
18963 ( | |
18964 "*.gbk", | |
18965 "*.embl", | |
18966 "*.gb", | |
18967 "*.fa", | |
18968 "*.fna", | |
18969 "*.dna", | |
18970 "*.fas", | |
18971 "*.fasta", | |
18972 ), | |
18973 ), | |
18974 ("All files", "*"), | |
18975 ] | |
18976 ) | |
18977 self.gen9.set(filename) | |
18978 | |
18979 def openFile0(self): | |
18980 filename = tkFileDialog.askopenfilename( | |
18981 filetypes=[ | |
18982 ( | |
18983 "genbank/embl/fasta", | |
18984 ( | |
18985 "*.gbk", | |
18986 "*.embl", | |
18987 "*.gb", | |
18988 "*.fa", | |
18989 "*.fna", | |
18990 "*.dna", | |
18991 "*.fas", | |
18992 "*.fasta", | |
18993 ), | |
18994 ), | |
18995 ("All files", "*"), | |
18996 ] | |
18997 ) | |
18998 self.gen0.set(filename) | |
18999 | |
19000 def openBlast1(self): | |
19001 filename = tkFileDialog.askopenfilename() | |
19002 self.blast1.set(filename) | |
19003 | |
19004 def openBlast2(self): | |
19005 filename = tkFileDialog.askopenfilename() | |
19006 self.blast2.set(filename) | |
19007 | |
19008 def openBlast3(self): | |
19009 filename = tkFileDialog.askopenfilename() | |
19010 self.blast3.set(filename) | |
19011 | |
19012 def openBlast4(self): | |
19013 filename = tkFileDialog.askopenfilename() | |
19014 self.blast4.set(filename) | |
19015 | |
19016 def openBlast5(self): | |
19017 filename = tkFileDialog.askopenfilename() | |
19018 self.blast5.set(filename) | |
19019 | |
19020 def openBlast6(self): | |
19021 filename = tkFileDialog.askopenfilename() | |
19022 self.blast6.set(filename) | |
19023 | |
19024 def openBlast7(self): | |
19025 filename = tkFileDialog.askopenfilename() | |
19026 self.blast7.set(filename) | |
19027 | |
19028 def openBlast8(self): | |
19029 filename = tkFileDialog.askopenfilename() | |
19030 self.blast8.set(filename) | |
19031 | |
19032 def openBlast9(self): | |
19033 filename = tkFileDialog.askopenfilename() | |
19034 self.blast9.set(filename) | |
19035 | |
19036 def getoutfile(self): | |
19037 if self.filetype.get() == "Bitmap (bmp)": | |
19038 filename = tkFileDialog.asksaveasfilename( | |
19039 filetypes=[("bmp", "*.bmp"), ("All files", "*")] | |
19040 ) | |
19041 else: | |
19042 filename = tkFileDialog.asksaveasfilename( | |
19043 filetypes=[("svg", "*.svg"), ("All files", "*")] | |
19044 ) | |
19045 self.outfile.set(filename) | |
19046 | |
19047 def handleDownload(self, block): | |
19048 self.downloadFile.write(block) | |
19049 if ( | |
19050 self.thecount * 100 / self.totalBytes | |
19051 != (self.thecount + len(block)) * 100 / self.totalBytes | |
19052 ): | |
19053 try: | |
19054 self.processLab.config( | |
19055 text="Finding Blast... Done\nDownloading... " | |
19056 + str((self.thecount + len(block)) * 100 / self.totalBytes) | |
19057 + "%" | |
19058 ) | |
19059 except: | |
19060 pass | |
19061 self.thecount += len(block) | |
19062 | |
19063 def downloadBlastAuto(self): | |
19064 self.thedlblast = threading.Thread(target=self.downloadBlast) | |
19065 self.thedlblast.start() | |
19066 | |
19067 def downloadBlastMan(self): | |
19068 theplatform = platform.system() | |
19069 architecture = platform.architecture()[0] | |
19070 if theplatform == "Linux" and architecture == "32bit": | |
19071 ok = tkMessageBox.askokcancel( | |
19072 "Downloading Blast Manually", | |
19073 "Easyfig suggests downloading\nand extracting\nncbi-blast-x.x.x+-ia32-linux.tar.gz\n\ | |
19074 clicking ok will bring up\nthe download location\nin your browser.", | |
19075 ) | |
19076 if ok: | |
19077 webbrowser.open_new( | |
19078 "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/" | |
19079 ) | |
19080 elif theplatform == "Linux" and architecture == "64bit": | |
19081 ok = tkMessageBox.askokcancel( | |
19082 "Downloading Blast Manually", | |
19083 "Easyfig suggests downloading\nand extracting\nncbi-blast-x.x.x+-x64-linux.tar.gz\n\ | |
19084 clicking ok will bring up\nthe download location\nin your browser.", | |
19085 ) | |
19086 if ok: | |
19087 webbrowser.open_new( | |
19088 "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/" | |
19089 ) | |
19090 elif theplatform == "Windows" and architecture == "32bit": | |
19091 ok = tkMessageBox.askokcancel( | |
19092 "Downloading Blast Manually", | |
19093 "Easyfig suggests downloading\nand running\nncbi-blast-x.x.x+-win32.exe\n\ | |
19094 clicking ok will bring up\nthe download location\nin your browser.", | |
19095 ) | |
19096 if ok: | |
19097 webbrowser.open_new( | |
19098 "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/" | |
19099 ) | |
19100 elif theplatform == "Windows" and architecture == "64bit": | |
19101 ok = tkMessageBox.askokcancel( | |
19102 "Downloading Blast Manually", | |
19103 "Easyfig suggests downloading\nand running\nncbi-blast-x.x.x+-win64.exe\n\ | |
19104 clicking ok will bring up\nthe download location\nin your browser.", | |
19105 ) | |
19106 if ok: | |
19107 webbrowser.open_new( | |
19108 "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/" | |
19109 ) | |
19110 elif theplatform == "Darwin": | |
19111 ok = tkMessageBox.askokcancel( | |
19112 "Downloading Blast Manually", | |
19113 "Easyfig suggests downloading\nand running\nncbi-blast-x.x.x+.dmg\n\ | |
19114 clicking ok will bring up\nthe download location\nin your browser.", | |
19115 ) | |
19116 if ok: | |
19117 webbrowser.open_new( | |
19118 "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/" | |
19119 ) | |
19120 else: | |
19121 ok = tkMessageBox.askokcancel( | |
19122 "Downloading Blast Manually", | |
19123 "Easyfig suggests downloading\nand compiling\nncbi-blast-x.x.x+.src.tar.gz\n\ | |
19124 clicking ok will bring up\nthe download location\nin your browser.", | |
19125 ) | |
19126 if ok: | |
19127 webbrowser.open_new( | |
19128 "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/" | |
19129 ) | |
19130 | |
19131 def chooseBlastDir(self): | |
19132 tempdir = tkFileDialog.askdirectory( | |
19133 title="Please select a directory with blastn and makeblastdb." | |
19134 ) | |
19135 if tempdir == () or tempdir == "": | |
19136 return | |
19137 if os.path.exists(tempdir + "/blastn.exe") and os.path.exists( | |
19138 tempdir + "/makeblastdb.exe" | |
19139 ): | |
19140 self.blastnDir = tempdir + "/blastn.exe" | |
19141 self.dbnDir = tempdir + "/makeblastdb.exe" | |
19142 elif os.path.exists(tempdir + "/blastn") and os.path.exists( | |
19143 tempdir + "/makeblastdb" | |
19144 ): | |
19145 self.blastnDir = tempdir + "/blastn" | |
19146 self.dbnDir = tempdir + "/makeblastdb" | |
19147 else: | |
19148 tkMessageBox.showerror("Try again.", "Blast not found in Directory.") | |
19149 self.blastnDir = None | |
19150 self.dbnDir = None | |
19151 | |
19152 def downloadBlast(self): | |
19153 theplatform = platform.system() | |
19154 architecture = platform.architecture()[0] | |
19155 self.processLab.config(text="Finding Blast...") | |
19156 try: | |
19157 ftp = FTP("ftp.ncbi.nlm.nih.gov") | |
19158 ftp.login() | |
19159 ftp.cwd("blast/executables/blast+/LATEST/") | |
19160 files = [] | |
19161 ftp.dir(files.append) | |
19162 except: | |
19163 self.processLab.config( | |
19164 text="Unable to Create FTP \nconnection.\nPlease dowload manually." | |
19165 ) | |
19166 return | |
19167 filename = None | |
19168 try: | |
19169 true_platform = os.environ["PROCESSOR_ARCHITEW6432"] | |
19170 if true_platform == "AMD64": | |
19171 architecture = "64bit" | |
19172 except KeyError: | |
19173 pass | |
19174 for line in files: | |
19175 if ( | |
19176 theplatform == "Linux" | |
19177 and architecture == "32bit" | |
19178 and line.split()[8][-17:] == "ia32-linux.tar.gz" | |
19179 ): | |
19180 filename = line.split()[8] | |
19181 self.totalBytes = int(line.split()[4]) | |
19182 elif ( | |
19183 theplatform == "Linux" | |
19184 and architecture == "64bit" | |
19185 and line.split()[8][-16:] == "x64-linux.tar.gz" | |
19186 ): | |
19187 filename = line.split()[8] | |
19188 self.totalBytes = int(line.split()[4]) | |
19189 elif ( | |
19190 theplatform == "Windows" | |
19191 and architecture == "32bit" | |
19192 and line.split()[8][-17:] == "ia32-win32.tar.gz" | |
19193 ): | |
19194 filename = line.split()[8] | |
19195 self.totalBytes = int(line.split()[4]) | |
19196 elif ( | |
19197 theplatform == "Windows" | |
19198 and architecture == "64bit" | |
19199 and line.split()[8][-16:] == "x64-win64.tar.gz" | |
19200 ): | |
19201 filename = line.split()[8] | |
19202 self.totalBytes = int(line.split()[4]) | |
19203 elif ( | |
19204 theplatform == "Darwin" | |
19205 and line.split()[8][-23:] == "universal-macosx.tar.gz" | |
19206 ): | |
19207 filename = line.split()[8] | |
19208 self.totalBytes = int(line.split()[4]) | |
19209 if filename == None: | |
19210 self.processLab.config( | |
19211 text="Unable to download blast.\nPlease dowload manually." | |
19212 ) | |
19213 return | |
19214 self.thecount = 0 | |
19215 try: | |
19216 self.downloadFile = open(filename, "wb") | |
19217 except: | |
19218 self.processLab.config( | |
19219 text="Unable to download blast.\nPlease dowload manually." | |
19220 ) | |
19221 return | |
19222 ftp.retrbinary("RETR " + filename, self.handleDownload) | |
19223 self.downloadFile.close() | |
19224 self.processLab.config(text="Downloading... Complete\nExtracting file...") | |
19225 try: | |
19226 tfile = tarfile.open(filename, "r:gz") | |
19227 tfile.extractall() | |
19228 except: | |
19229 self.processLab.config( | |
19230 text="Unable to download blast.\nPlease dowload manually." | |
19231 ) | |
19232 return | |
19233 filenamedir = filename.split("+")[0] + "+" | |
19234 if theplatform == "Windows": | |
19235 try: | |
19236 shutil.move(filenamedir + "/bin/makeblastdb.exe", self.pwd) | |
19237 except: | |
19238 pass | |
19239 try: | |
19240 shutil.move(filenamedir + "/bin/blastn.exe", self.pwd) | |
19241 except: | |
19242 pass | |
19243 try: | |
19244 shutil.move(filenamedir + "/bin/tblastx.exe", self.pwd) | |
19245 except: | |
19246 pass | |
19247 else: | |
19248 try: | |
19249 shutil.move(filenamedir + "/bin/makeblastdb", self.pwd) | |
19250 except: | |
19251 pass | |
19252 try: | |
19253 shutil.move(filenamedir + "/bin/blastn", self.pwd) | |
19254 except: | |
19255 pass | |
19256 try: | |
19257 shutil.move(filenamedir + "/bin/tblastx", self.pwd) | |
19258 except: | |
19259 pass | |
19260 tfile.close() | |
19261 shutil.rmtree(filenamedir) | |
19262 os.remove(filename) | |
19263 if os.path.exists(self.pwd + "/blastn") or os.path.exists( | |
19264 self.pwd + "/blastn.exe" | |
19265 ): | |
19266 self.processLab.config(text="Extracting file... Done\nBLAST+ installed.") | |
19267 else: | |
19268 self.processLab.config( | |
19269 text="Unable to download blast.\nPlease dowload manually." | |
19270 ) | |
19271 | |
19272 | |
19273 def gbk2fasta(genbank, out, mincut, maxcut): | |
19274 getseq = False | |
19275 getembl = False | |
19276 getmultifa = False | |
19277 seq = "" | |
19278 try: | |
19279 mincut = int(mincut) | |
19280 if mincut < 1: | |
19281 mincut = 1 | |
19282 if maxcut != "Max": | |
19283 maxcut = int(maxcut) | |
19284 if maxcut < 1: | |
19285 maxcut = 1 | |
19286 except: | |
19287 print("Annotation slice values not valid.") | |
19288 try: | |
19289 gen = open(genbank) | |
19290 outfile = open(out, "w") | |
19291 for line in gen: | |
19292 if line.startswith("ORIGIN"): | |
19293 getseq = True | |
19294 elif line.startswith("SQ Sequence"): | |
19295 getembl = True | |
19296 elif line.startswith(">"): | |
19297 if getmultifa: | |
19298 seq += "qqq" | |
19299 else: | |
19300 getmultifa = True | |
19301 elif line.startswith("//"): | |
19302 getseq = False | |
19303 getembl = False | |
19304 elif getseq: | |
19305 seq += "".join(line.split()[1:]) | |
19306 elif getembl: | |
19307 seq += "".join(line.split()[:-1]) | |
19308 elif getmultifa: | |
19309 seq += line.rstrip() | |
19310 if getmultifa: | |
19311 getset = set(seq) | |
19312 rightchars = set("atgcATGCqnNuUyYkKmMsSwWbBdDhHvVxXrR-") | |
19313 isitgood = True | |
19314 for i in getset: | |
19315 if not i in rightchars: | |
19316 isitgood = False | |
19317 if not isitgood: | |
19318 print( | |
19319 "Annotation file contains invalid characters. Check genbank/EMBL contains no lines starting with > or that fasta file contains only valid nucleotides" | |
19320 ) | |
19321 return 0 | |
19322 if "/" in out: | |
19323 outfile.write(">" + out.split("/")[1] + "\n") | |
19324 else: | |
19325 outfile.write(">" + out + "\n") | |
19326 if maxcut == "Max": | |
19327 maxcut = len(seq) | |
19328 if mincut == 1 and maxcut == len(seq): | |
19329 if getmultifa: | |
19330 seq = seq.replace("qqq", "n" * int(len(seq) / 500)) | |
19331 outfile.write(seq) | |
19332 elif mincut < maxcut: | |
19333 seq = seq[mincut - 1 : maxcut] | |
19334 if getmultifa: | |
19335 seq = seq.replace("qqq", "n" * int(len(seq) / 500)) | |
19336 outfile.write(seq) | |
19337 else: | |
19338 seq = seq[mincut - 1 :] + seq[:maxcut] | |
19339 if getmultifa: | |
19340 seq = seq.replace("qqq", "n" * int(len(seq) / 500)) | |
19341 outfile.write(seq) | |
19342 if len(seq) == 0: | |
19343 print("There is no sequence in " + genbank + ".") | |
19344 return 0 | |
19345 else: | |
19346 return 1 | |
19347 except: | |
19348 print(genbank + " does not exist.") | |
19349 return 0 | |
19350 | |
19351 | |
19352 def getGCcontent(filename, windsize, step, mincut, maxcut): | |
19353 try: | |
19354 gen = open(filename) | |
19355 getseq = False | |
19356 getembl = False | |
19357 seq = "" | |
19358 for line in gen: | |
19359 if line.startswith("ORIGIN"): | |
19360 getseq = True | |
19361 elif line.startswith("SQ Sequence"): | |
19362 getembl = True | |
19363 elif line.startswith("//"): | |
19364 getseq = False | |
19365 getembl = False | |
19366 elif getseq: | |
19367 seq += "".join(line.split()[1:]) | |
19368 elif getembl: | |
19369 seq += "".join(line.split()[:-1]) | |
19370 gen.close() | |
19371 seq = seq.upper() | |
19372 except: | |
19373 print("Annotation file " + filename + " not valid.") | |
19374 return None | |
19375 if len(seq) == 0: | |
19376 print("Annotation file " + filename + " not valid.") | |
19377 return None | |
19378 if maxcut == "Max": | |
19379 seq = seq[int(mincut) - 1 :] | |
19380 elif int(maxcut) <= int(mincut): | |
19381 seq = seq[int(mincut) - 1 :] + seq[: int(maxcut) + 1] | |
19382 else: | |
19383 seq = seq[int(mincut) - 1 : int(maxcut) + 1] | |
19384 window1 = int(windsize) / 2 | |
19385 window2 = int(windsize) - window1 | |
19386 thearray = [] | |
19387 for i in range(0, len(seq), int(step)): | |
19388 seqstring = seq[max([0, i - window1]) : i + window2] | |
19389 thearray.append( | |
19390 (seqstring.count("G") + seqstring.count("C")) * 1.0 / len(seqstring) - 0.5 | |
19391 ) | |
19392 return thearray | |
19393 | |
19394 | |
19395 def getGCskew(filename, windsize, step, mincut, maxcut): | |
19396 try: | |
19397 getseq = False | |
19398 getembl = False | |
19399 seq = "" | |
19400 gen = open(filename) | |
19401 for line in gen: | |
19402 if line.startswith("ORIGIN"): | |
19403 getseq = True | |
19404 elif line.startswith("SQ Sequence"): | |
19405 getembl = True | |
19406 elif line.startswith("//"): | |
19407 getseq = False | |
19408 getembl = False | |
19409 elif getseq: | |
19410 seq += "".join(line.split()[1:]) | |
19411 elif getembl: | |
19412 seq += "".join(line.split()[:-1]) | |
19413 gen.close() | |
19414 seq = seq.upper() | |
19415 except: | |
19416 print("Annotation file " + filename + " not valid.") | |
19417 return None | |
19418 if len(seq) == 0: | |
19419 print("Annotation file " + filename + " not valid.") | |
19420 return None | |
19421 if maxcut == "Max": | |
19422 seq = seq[int(mincut) - 1 :] | |
19423 elif int(maxcut) <= int(mincut): | |
19424 seq = seq[int(mincut) - 1 :] + seq[: int(maxcut) + 1] | |
19425 else: | |
19426 seq = seq[int(mincut) - 1 : int(maxcut) + 1] | |
19427 window1 = int(windsize) / 2 | |
19428 window2 = int(windsize) - window1 | |
19429 thearray = [] | |
19430 for i in range(0, len(seq), int(step)): | |
19431 seqstring = seq[max([0, i - window1]) : i + window2] | |
19432 gcount = seqstring.count("G") | |
19433 ccount = seqstring.count("C") | |
19434 try: | |
19435 thearray.append((gcount - ccount) * 1.0 / (gcount + ccount)) | |
19436 except: | |
19437 thearray.append(0) | |
19438 return thearray | |
19439 | |
19440 | |
19441 def getCoverage(filename, filename2, mincut, maxcut): | |
19442 # DEFNIITION: takes a file and reads in all contigs, their start positions and the reads located within the contig | |
19443 # REQUIRES: a valid ace file | |
19444 # RETURNS: A list of objects of class contig | |
19445 seq = "" | |
19446 getseq = False | |
19447 getembl = False | |
19448 try: | |
19449 gen = open(filename) | |
19450 for line in gen: | |
19451 if line.startswith("ORIGIN"): | |
19452 getseq = True | |
19453 elif line.startswith("SQ Sequence"): | |
19454 getembl = True | |
19455 elif line.startswith("//"): | |
19456 getseq = False | |
19457 getembl = False | |
19458 elif getseq: | |
19459 seq += "".join(line.split()[1:]) | |
19460 elif getembl: | |
19461 seq += "".join(line.split()[:-1]) | |
19462 gen.close() | |
19463 except: | |
19464 print("Annotation file " + filename + " not valid.") | |
19465 return None | |
19466 if len(seq) == 0: | |
19467 print("Annotation file " + filename + " not valid.") | |
19468 return None | |
19469 seq = seq.lower() | |
19470 if maxcut == "Max": | |
19471 seq = seq[int(mincut) - 1 :] | |
19472 elif int(maxcut) <= int(mincut): | |
19473 seq = seq[int(mincut) - 1 :] + seq[: int(maxcut) + 1] | |
19474 else: | |
19475 seq = seq[int(mincut) - 1 : int(maxcut) + 1] | |
19476 outlist = [0 for i in range(len(seq))] | |
19477 readlist = [] # list of reads to be added to the contig class | |
19478 index = 0 # switches to 1 once program has dealt with the initial contig | |
19479 # iterates through the file determines what information is contained in each line then reads it to the | |
19480 # right locationregular expressions python | |
19481 transtab = string.maketrans("atgc", "tacg") | |
19482 acefile = open(filename2) | |
19483 for line in acefile: | |
19484 # puts name in file and starts reading sequence below | |
19485 if line.startswith("CO "): | |
19486 if index != 0: | |
19487 freqDict = {} | |
19488 for j in readlist: | |
19489 for k in range(j.startpos, (j.startpos + j.readLength)): | |
19490 if k in freqDict: | |
19491 freqDict[k] += 1 | |
19492 else: | |
19493 freqDict[k] = 1 | |
19494 coverageList = [] | |
19495 for j in range(1, len(contigSeq) + 1): | |
19496 if contigSeq[j - 1] != "*": | |
19497 coverageList.append(freqDict[j]) | |
19498 contigSeq = contigSeq.lower() | |
19499 thepos = seq.find(contigSeq) | |
19500 if thepos != -1: | |
19501 outlist = ( | |
19502 outlist[:thepos] | |
19503 + coverageList | |
19504 + outlist[thepos + len(coverageList) :] | |
19505 ) | |
19506 else: | |
19507 contigSeq = contigSeq[::-1] | |
19508 contigSeq = contigSeq.translate(transtab) | |
19509 thepos = seq.find(contigSeq) | |
19510 if thepos != -1: | |
19511 coverageList.reverse() | |
19512 outlist = ( | |
19513 outlist[:thepos] | |
19514 + coverageList | |
19515 + outlist[thepos + len(coverageList) :] | |
19516 ) | |
19517 readlist = [] | |
19518 index = 1 | |
19519 contigSeq = "" | |
19520 contigName = line.split()[ | |
19521 1 | |
19522 ] # splits the line into a list with elements seperated by whitespace characters | |
19523 # then returns the second element of that list (the name) | |
19524 readnumber = 0 # initiates the read number used to determine where the readsequence will be added | |
19525 # creates a object of class read with the name and location within the contig, leaves sequence as the | |
19526 # empty string to be read in later | |
19527 elif line.startswith("BQ"): | |
19528 index = 2 | |
19529 elif line.startswith("AF "): | |
19530 readIt = ( | |
19531 line.split() | |
19532 ) # splits the line into a list of strings seperated by whitespace characters | |
19533 readName = readIt[1] # the name of the read | |
19534 readPos = int(readIt[3]) # the position of the read within the contig | |
19535 readInstance = read( | |
19536 readName, readPos, None | |
19537 ) # creates an instance of class read | |
19538 readlist.append(readInstance) # appends to list | |
19539 elif index == 1: | |
19540 contigSeq += line[:-1] | |
19541 elif line.startswith("QA "): | |
19542 readlist[readnumber].startpos = ( | |
19543 readlist[readnumber].startpos + int(line.split()[1]) - 1 | |
19544 ) | |
19545 readlist[readnumber].readLength = ( | |
19546 int(line.split()[2]) - int(line.split()[1]) + 1 | |
19547 ) | |
19548 readnumber += 1 | |
19549 freqDict = {} | |
19550 for j in readlist: | |
19551 for k in range(j.startpos, (j.startpos + j.readLength)): | |
19552 if k in freqDict: | |
19553 freqDict[k] += 1 | |
19554 else: | |
19555 freqDict[k] = 1 | |
19556 coverageList = [] | |
19557 for j in range(1, len(contigSeq) + 1): | |
19558 if contigSeq[j - 1] != "*": | |
19559 coverageList.append(freqDict[j]) | |
19560 contigSeq = contigSeq.lower() | |
19561 thepos = seq.find(contigSeq) | |
19562 if thepos != -1: | |
19563 outlist = ( | |
19564 outlist[:thepos] + coverageList + outlist[thepos + len(coverageList) :] | |
19565 ) | |
19566 else: | |
19567 contigSeq = contigSeq[::-1] | |
19568 contigSeq = contigSeq.translate(transtab) | |
19569 thepos = seq.find(contigSeq) | |
19570 if thepos != -1: | |
19571 coverageList.reverse() | |
19572 outlist = ( | |
19573 outlist[:thepos] + coverageList + outlist[thepos + len(coverageList) :] | |
19574 ) | |
19575 return outlist | |
19576 | |
19577 | |
19578 def getCustom(filename): | |
19579 try: | |
19580 thearray = [] | |
19581 gen = open(filename) | |
19582 templine = gen.readline().rstrip().split("\t") | |
19583 linelen = len(templine) | |
19584 for i in templine: | |
19585 thearray.append([float(i)]) | |
19586 for line in gen: | |
19587 templine = line.rstrip().split("\t") | |
19588 for i in range(len(templine)): | |
19589 if templine[i] != "": | |
19590 thearray[i].append(float(templine[i])) | |
19591 return thearray | |
19592 except: | |
19593 print(filename + " not valid graph file.") | |
19594 return None | |
19595 | |
19596 | |
19597 def genBlast(inlist, cutlist): | |
19598 try: | |
19599 os.mkdir("temp_easyfig") | |
19600 except: | |
19601 pass | |
19602 num = 1 | |
19603 outlist = [] | |
19604 for i in inlist: | |
19605 gbk2fasta( | |
19606 i, | |
19607 "temp_easyfig/" + str(num) + ".easyfig.fa", | |
19608 cutlist[num - 1][0], | |
19609 cutlist[num - 1][1], | |
19610 ) | |
19611 num += 1 | |
19612 for i in range(len(inlist) - 1): | |
19613 if isNewBlastDB(): | |
19614 subprocess.Popen( | |
19615 "makeblastdb -dbtype nucl -out temp_easyfig/tempdb -in temp_easyfig/" | |
19616 + str(i + 2) | |
19617 + ".easyfig.fa", | |
19618 shell=True, | |
19619 ).wait() | |
19620 print( | |
19621 "makeblastdb -dbtype nucl -out temp_easyfig/tempdb -in temp_easyfig/" | |
19622 + str(i + 2) | |
19623 + ".easyfig.fa" | |
19624 ) | |
19625 elif isLegBlastDB(): | |
19626 subprocess.Popen( | |
19627 "formatdb -p F -t tempdb -n temp_easyfig/tempdb -i temp_easyfig/" | |
19628 + str(i + 2) | |
19629 + ".easyfig.fa", | |
19630 shell=True, | |
19631 ).wait() | |
19632 else: | |
19633 print("Could not find BLAST.") | |
19634 sys.exit() | |
19635 if isNewBlastn(): | |
19636 subprocess.Popen( | |
19637 "blastn -task blastn -db temp_easyfig/tempdb -outfmt 6 -query temp_easyfig/" | |
19638 + str(i + 1) | |
19639 + ".easyfig.fa -out temp_easyfig/" | |
19640 + str(i + 1) | |
19641 + str(i + 2) | |
19642 + ".easyfig.out", | |
19643 shell=True, | |
19644 ).wait() | |
19645 elif isLegBlastall(): | |
19646 subprocess.Popen( | |
19647 "blastall -p blastn -d temp_easyfig/tempdb -F F -m 8 -a 8 -i temp_easyfig/" | |
19648 + str(i + 1) | |
19649 + ".easyfig.fa -o temp_easyfig/" | |
19650 + str(i + 1) | |
19651 + str(i + 2) | |
19652 + ".easyfig.out", | |
19653 shell=True, | |
19654 ).wait() | |
19655 else: | |
19656 print("Could not find BLAST.") | |
19657 sys.exit() | |
19658 outlist.append(inlist[i]) | |
19659 outlist.append("temp_easyfig/" + str(i + 1) + str(i + 2) + ".easyfig.out") | |
19660 outlist.append(inlist[-1]) | |
19661 return outlist | |
19662 | |
19663 | |
19664 def genTBlastX(inlist, cutlist): | |
19665 pwd = os.getcwd() | |
19666 if os.path.exists("temp_easyfig"): | |
19667 print("please run from a directory without the folder temp_easyfig") | |
19668 sys.exit() | |
19669 os.mkdir("temp_easyfig") | |
19670 os.chdir("temp_easyfig") | |
19671 num = 1 | |
19672 outlist = [] | |
19673 for i in inlist: | |
19674 if i[0] in ["/", "\\", "~"]: | |
19675 thepath = i | |
19676 else: | |
19677 thepath = "../" + i | |
19678 gbk2fasta( | |
19679 thepath, str(num) + ".easyfig.fa", cutlist[num - 1][0], cutlist[num - 1][1] | |
19680 ) | |
19681 num += 1 | |
19682 for i in range(len(inlist) - 1): | |
19683 if isNewBlastDB(): | |
19684 subprocess.Popen( | |
19685 "makeblastdb -dbtype nucl -out tempdb -in " | |
19686 + str(i + 2) | |
19687 + ".easyfig.fa", | |
19688 shell=True, | |
19689 ).wait() | |
19690 elif isLegBlastDB(): | |
19691 subprocess.Popen( | |
19692 "formatdb -p F -t tempdb -n tempdb -i " + str(i + 2) + ".easyfig.fa", | |
19693 shell=True, | |
19694 ).wait() | |
19695 else: | |
19696 print("Could not find BLAST.") | |
19697 sys.exit() | |
19698 if isNewTblastx(): | |
19699 subprocess.Popen( | |
19700 "tblastx -db tempdb -outfmt 6 -query " | |
19701 + str(i + 1) | |
19702 + ".easyfig.fa -out " | |
19703 + str(i + 1) | |
19704 + str(i + 2) | |
19705 + ".easyfig.out", | |
19706 shell=True, | |
19707 ).wait() | |
19708 elif isLegBlastall(): | |
19709 subprocess.Popen( | |
19710 "blastall -p tblastx -d tempdb -F F -m 8 -a 8 -i " | |
19711 + str(i + 1) | |
19712 + ".easyfig.fa -o " | |
19713 + str(i + 1) | |
19714 + str(i + 2) | |
19715 + ".easyfig.out", | |
19716 shell=True, | |
19717 ).wait() | |
19718 else: | |
19719 print("Could not find BLAST.") | |
19720 sys.exit() | |
19721 outlist.append(inlist[i]) | |
19722 outlist.append(os.getcwd() + "/" + str(i + 1) + str(i + 2) + ".easyfig.out") | |
19723 os.chdir(pwd) | |
19724 outlist.append(inlist[-1]) | |
19725 return outlist | |
19726 | |
19727 | |
19728 global abortCaptain | |
19729 | |
19730 | |
19731 minlength = 0 | |
19732 mineval = 0.001 | |
19733 minIdent = 0 | |
19734 inputlist = [] | |
19735 width = 5000 | |
19736 height1 = 50 | |
19737 height2 = 100 | |
19738 minblastc = (200, 200, 200) | |
19739 maxblastc = (100, 100, 100) | |
19740 minblastci = (200, 200, 200) | |
19741 maxblastci = (100, 100, 100) | |
19742 drawfig1 = False | |
19743 drawfig2 = False | |
19744 drawfig3 = False | |
19745 compress = True | |
19746 reverseList = [] | |
19747 featDict = {} | |
19748 glt = 5 | |
19749 exont = 2 | |
19750 genet = 1 | |
19751 featlengths = [] | |
19752 aln = "centre" | |
19753 graphit = None | |
19754 blastoutline = True | |
19755 minmaxlist = [] | |
19756 getgc = False | |
19757 getgcskew = False | |
19758 getcoverage = False | |
19759 getcustom = False | |
19760 windsize = 1000 | |
19761 step = 1000 | |
19762 graphit = None | |
19763 multigraph = True | |
19764 loggraph = False | |
19765 gtype = "Histogram" | |
19766 axisthick = 1 | |
19767 pvc = (255, 0, 0) | |
19768 nvc = (0, 0, 255) | |
19769 ggap = 10 | |
19770 gheight = 50 | |
19771 blastit = True | |
19772 tblastit = False | |
19773 blastfiles = None | |
19774 lastflag = 1 | |
19775 filename = None | |
19776 svg = False | |
19777 filter = False | |
19778 keep_blast = False | |
19779 nofeat = False | |
19780 gmaxy = "Auto" | |
19781 legend = "None" | |
19782 legname = "gene" | |
19783 abortCaptain = False | |
19784 | |
19785 if ( | |
19786 len(sys.argv) >= 2 | |
19787 and sys.argv[1] != "--help" | |
19788 and sys.argv[1] != "-h" | |
19789 and sys.argv[1] != "-help" | |
19790 ): | |
19791 for i in range(1, len(sys.argv)): | |
19792 if sys.argv[i][:1] == "-": | |
19793 lastflag = i + 2 | |
19794 if sys.argv[i] == "-o": | |
19795 filename = sys.argv[i + 1] | |
19796 elif sys.argv[i] == "-e": | |
19797 mineval = float(sys.argv[i + 1]) | |
19798 elif sys.argv[i] == "-min_length": | |
19799 minlength = int(sys.argv[i + 1]) | |
19800 elif sys.argv[i] == "-i": | |
19801 minIdent = float(sys.argv[i + 1]) | |
19802 elif sys.argv[i] == "-width": | |
19803 width = int(sys.argv[i + 1]) | |
19804 elif sys.argv[i] == "-ann_height": | |
19805 height1 = int((sys.argv[i + 1])) | |
19806 elif sys.argv[i] == "-blast_height": | |
19807 height2 = int((sys.argv[i + 1])) | |
19808 elif sys.argv[i] == "-f1": | |
19809 if ( | |
19810 sys.argv[i + 1] == "T" | |
19811 or sys.argv[i + 1] == "t" | |
19812 or sys.argv[i + 1] == "True" | |
19813 or sys.argv[i + 1] == "true" | |
19814 ): | |
19815 drawfig1 = True | |
19816 elif ( | |
19817 sys.argv[i + 1] == "F" | |
19818 or sys.argv[i + 1] == "f" | |
19819 or sys.argv[i + 1] == "False" | |
19820 or sys.argv[i + 1] == "false" | |
19821 ): | |
19822 drawfig1 = False | |
19823 elif sys.argv[i] == "-f2": | |
19824 drawfig2 = int(sys.argv[i + 1]) | |
19825 elif sys.argv[i] == "-f3": | |
19826 drawfig3 = sys.argv[i + 1] | |
19827 elif sys.argv[i] == "-uncomp": | |
19828 if ( | |
19829 sys.argv[i + 1] == "T" | |
19830 or sys.argv[i + 1] == "t" | |
19831 or sys.argv[i + 1] == "True" | |
19832 or sys.argv[i + 1] == "true" | |
19833 ): | |
19834 compress = False | |
19835 elif sys.argv[i] == "-blastn": | |
19836 blastit = True | |
19837 lastflag -= 1 | |
19838 elif sys.argv[i] == "-tblastx": | |
19839 tblastit = True | |
19840 blastit = False | |
19841 lastflag -= 1 | |
19842 elif sys.argv[i] == "-blast_files": | |
19843 blastit = False | |
19844 blastfiles = i | |
19845 elif sys.argv[i] == "-blast_col": | |
19846 if sys.argv[i + 1].isdigit(): | |
19847 lastflag = i + 7 | |
19848 t1 = int(sys.argv[i + 1]) | |
19849 t2 = int(sys.argv[i + 2]) | |
19850 t3 = int(sys.argv[i + 3]) | |
19851 t4 = int(sys.argv[i + 4]) | |
19852 t5 = int(sys.argv[i + 5]) | |
19853 t6 = int(sys.argv[i + 6]) | |
19854 else: | |
19855 if sys.argv[i + 1] == "blue": | |
19856 t1, t2, t3, t4, t5, t6 = 30, 144, 255, 25, 25, 112 | |
19857 elif sys.argv[i + 1] == "red": | |
19858 t1, t2, t3, t4, t5, t6 = 200, 100, 0, 255, 0, 0 | |
19859 elif sys.argv[i + 1] == "gray": | |
19860 t1, t2, t3, t4, t5, t6 = 20, 20, 20, 175, 175, 175 | |
19861 minblastc = (t1, t2, t3) | |
19862 maxblastc = (t4, t5, t6) | |
19863 elif sys.argv[i] == "-blast_col_inv": | |
19864 if sys.argv[i + 1].isdigit(): | |
19865 lastflag = i + 7 | |
19866 t1 = int(sys.argv[i + 1]) | |
19867 t2 = int(sys.argv[i + 2]) | |
19868 t3 = int(sys.argv[i + 3]) | |
19869 t4 = int(sys.argv[i + 4]) | |
19870 t5 = int(sys.argv[i + 5]) | |
19871 t6 = int(sys.argv[i + 6]) | |
19872 else: | |
19873 if sys.argv[i + 1] == "blue": | |
19874 t1, t2, t3, t4, t5, t6 = 30, 144, 255, 25, 25, 112 | |
19875 elif sys.argv[i + 1] == "red": | |
19876 t1, t2, t3, t4, t5, t6 = 200, 100, 0, 255, 0, 0 | |
19877 minblastci = (t1, t2, t3) | |
19878 maxblastci = (t4, t5, t6) | |
19879 elif sys.argv[i] == "-f": | |
19880 r, g, b = 64, 224, 208 | |
19881 arrow = "arrow" | |
19882 feat = sys.argv[i + 1] | |
19883 if feat == "F": | |
19884 nofeat = True | |
19885 if len(sys.argv) > i + 2 and sys.argv[i + 2].isdigit(): | |
19886 r = int(sys.argv[i + 2]) | |
19887 g = int(sys.argv[i + 3]) | |
19888 b = int(sys.argv[i + 4]) | |
19889 if len(sys.argv) > i + 5 and ( | |
19890 sys.argv[i + 5] == "arrow" | |
19891 or sys.argv[i + 5] == "rect" | |
19892 or sys.argv[i + 5] == "frame" | |
19893 or sys.argv[i + 5] == "pointer" | |
19894 ): | |
19895 arrow = sys.argv[i + 5] | |
19896 lastflag = i + 6 | |
19897 else: | |
19898 lastflag = i + 5 | |
19899 if len(sys.argv) > i + 2 and ( | |
19900 sys.argv[i + 2] == "arrow" | |
19901 or sys.argv[i + 2] == "rect" | |
19902 or sys.argv[i + 2] == "frame" | |
19903 or sys.argv[i + 2] == "pointer" | |
19904 ): | |
19905 arrow = sys.argv[i + 2] | |
19906 lastflag = i + 3 | |
19907 featDict[feat] = (arrow, (r, g, b)) | |
19908 elif sys.argv[i] == "-glt": | |
19909 glt = int(sys.argv[i + 1]) | |
19910 elif sys.argv[i] == "-exont": | |
19911 exont = int(sys.argv[i + 1]) | |
19912 elif sys.argv[i] == genet: | |
19913 genet = int(sys.argv[i + 1]) | |
19914 elif sys.argv[i] == "-aln": | |
19915 aln = sys.argv[i + 1] | |
19916 if aln == "best": | |
19917 aln = "best blast" | |
19918 elif sys.argv[i] == "-bo": | |
19919 if ( | |
19920 sys.argv[i + 1] == "T" | |
19921 or sys.argv[i + 1] == "t" | |
19922 or sys.argv[i + 1] == "True" | |
19923 or sys.argv[i + 1] == "true" | |
19924 ): | |
19925 blastoutline = True | |
19926 else: | |
19927 blastoutline = False | |
19928 elif sys.argv[i] == "-G": | |
19929 if sys.argv[i + 1] == "GCContent": | |
19930 getgc = True | |
19931 elif sys.argv[i + 1] == "GCSkew": | |
19932 getgcskew = True | |
19933 elif sys.argv[i + 1] == "Coverage": | |
19934 getcoverage = True | |
19935 gfilename = sys.arv[i + 2] | |
19936 lastflag += 1 | |
19937 elif sys.argv[i + 1] == "Custom": | |
19938 getcustom = True | |
19939 gfilename = sys.argv[i + 2] | |
19940 lastflag += 1 | |
19941 else: | |
19942 print(sys.argv[i + 1] + " not a valid graph type") | |
19943 elif sys.argv[i] == "-wind_size": | |
19944 windsize = int(sys.argv[i + 1]) | |
19945 elif sys.argv[i] == "-step": | |
19946 step = int(sys.argv[i + 1]) | |
19947 elif sys.argv[i] == "-line": | |
19948 if ( | |
19949 sys.argv[i + 1] == "T" | |
19950 or sys.argv[i + 1] == "t" | |
19951 or sys.argv[i + 1] == "True" | |
19952 or sys.argv[i + 1] == "true" | |
19953 ): | |
19954 gtype = "Line" | |
19955 elif sys.argv[i] == "-axis_t": | |
19956 axisthick = sys.argv[i + 1] | |
19957 elif sys.argv[i] == "-pos_col": | |
19958 lastflag = i + 4 | |
19959 r = int(sys.argv[i + 1]) | |
19960 g = int(sys.argv[i + 2]) | |
19961 b = int(sys.argv[i + 3]) | |
19962 pvc = (r, g, b) | |
19963 elif sys.argv[i] == "-neg_col": | |
19964 lastflag = i + 4 | |
19965 r = int(sys.argv[i + 1]) | |
19966 g = int(sys.argv[i + 2]) | |
19967 b = int(sys.argv[i + 3]) | |
19968 nvc = (r, g, b) | |
19969 elif sys.argv[i] == "-g_height": | |
19970 gheight = int(sys.argv[i + 1]) | |
19971 elif sys.argv[i] == "-gap": | |
19972 ggap = int(sys.argv[i + 1]) | |
19973 elif sys.argv[i] == "-y_max": | |
19974 gmaxy = int(sys.argv[i + 1]) | |
19975 elif sys.argv[i] == "-A": | |
19976 if ( | |
19977 sys.argv[i + 1] == "T" | |
19978 or sys.argv[i + 1] == "t" | |
19979 or sys.argv[i + 1] == "True" | |
19980 or sys.argv[i + 1] == "true" | |
19981 ): | |
19982 auto = True | |
19983 else: | |
19984 auto = False | |
19985 elif sys.argv[i] == "-svg": | |
19986 svg = True | |
19987 lastflag -= 1 | |
19988 elif sys.argv[i] == "-keep": | |
19989 keep_blast = True | |
19990 lastflag -= 1 | |
19991 elif sys.argv[i] == "-filter": | |
19992 filter = True | |
19993 lastflag -= 1 | |
19994 elif sys.argv[i] == "-legend": | |
19995 if sys.argv[i + 1] == "single": | |
19996 legend = "Single column" | |
19997 elif sys.argv[i + 1] == "double": | |
19998 legend = "Two columns" | |
19999 elif sys.argv[i + 1] == "top": | |
20000 legend = "Top" | |
20001 elif sys.argv[i + 1] == "bottom": | |
20002 legend = "Bottom" | |
20003 elif sys.argv[i + 1] == "both": | |
20004 legend = "Top & Bottom" | |
20005 else: | |
20006 print( | |
20007 "Legend options are <single/double/top/bottom/both/None> (case sensitive), using None." | |
20008 ) | |
20009 elif sys.argv[i] == "-leg_name": | |
20010 legname = sys.argv[i + 1] | |
20011 inlist = sys.argv[lastflag + 1 :] | |
20012 if blastfiles != None and lastflag == blastfiles + 2: | |
20013 allthestuff = sys.argv[blastfiles + 1 :] | |
20014 allthestuff2 = [] | |
20015 for i in allthestuff: | |
20016 if i != "R" and i != "Max" and not i.isdigit(): | |
20017 allthestuff2.append(i) | |
20018 inlist = allthestuff[len(allthestuff2) / 2 :] | |
20019 last = inlist[0] | |
20020 inlist = inlist[1:] | |
20021 else: | |
20022 last = sys.argv[lastflag] | |
20023 templist = [] | |
20024 revlist = [] | |
20025 cutlist = [] | |
20026 rev = False | |
20027 cuts = [None, None] | |
20028 for i in inlist: | |
20029 if i == "R" or i == "Max" or i.isdigit(): | |
20030 if os.path.exists(i): | |
20031 sys.stderr.write( | |
20032 'Cannot tell if "' | |
20033 + i | |
20034 + '" is an file or argument (the file exists and this is also the argument to trim or reverse genome).\ | |
20035 \nPlease rename file (if file) or remove file from directory (if argument).\n' | |
20036 ) | |
20037 sys.exit() | |
20038 if i == "R": | |
20039 rev = True | |
20040 getit = True | |
20041 elif i.isdigit(): | |
20042 if cuts[0] == None: | |
20043 cuts[0] = int(i) | |
20044 else: | |
20045 cuts[1] = int(i) | |
20046 elif i == "Max": | |
20047 cuts[1] = i | |
20048 else: | |
20049 revlist.append(rev) | |
20050 if cuts == [None, None]: | |
20051 cuts = [1, "Max"] | |
20052 cutlist.append(tuple(cuts)) | |
20053 templist.append(last) | |
20054 rev = False | |
20055 cuts = [None, None] | |
20056 last = i | |
20057 revlist.append(rev) | |
20058 if cuts == [None, None]: | |
20059 cuts = [1, "Max"] | |
20060 cutlist.append(tuple(cuts)) | |
20061 for i in cutlist: | |
20062 if None in i: | |
20063 sys.stderr.write( | |
20064 "Please provide a start coordinate and end coordinate for genome cuts. (Only a single coordinate was provided)\n" | |
20065 ) | |
20066 sys.exit() | |
20067 templist.append(last) | |
20068 if getgc: | |
20069 thearray = [] | |
20070 for j in range(len(templist)): | |
20071 mincut, maxcut = cutlist[j] | |
20072 thearray.append(getGCcontent(templist[j], windsize, step, mincut, maxcut)) | |
20073 graphit = [thearray, pvc, nvc, gheight, axisthick, gtype, gmaxy, ggap] | |
20074 elif getgcskew: | |
20075 thearray = [] | |
20076 for j in range(len(templist)): | |
20077 mincut, maxcut = cutlist[j] | |
20078 thearray.append(getGCskew(templist[j], windsize, step, mincut, maxcut)) | |
20079 graphit = [thearray, pvc, nvc, gheight, axisthick, gtype, gmaxy, ggap] | |
20080 elif getcustom: | |
20081 thearray = getcustom(gfilename) | |
20082 graphit = [thearray, pvc, nvc, gheight, axisthick, gtype, gmaxy, ggap] | |
20083 elif getcoverage: | |
20084 thearray = [getCoverage(templist[0], gfilename, cutlist[0][0], cutlist[0][1])] | |
20085 graphit = [thearray, pvc, nvc, gheight, axisthick, gtype, gmaxy, ggap] | |
20086 if blastit: | |
20087 inlist = genBlast(templist, cutlist) | |
20088 elif tblastit: | |
20089 inlist = genTBlastX(templist, cutlist) | |
20090 elif blastfiles != None: | |
20091 inlist = [] | |
20092 tempfiles = sys.argv[blastfiles + 1 :] | |
20093 for i in templist[:-1]: | |
20094 inlist.append(i) | |
20095 inlist.append(tempfiles.pop(0)) | |
20096 inlist.append(templist[-1]) | |
20097 else: | |
20098 "Please choolse -blastn or -tblastx flags to generate blast files, or use -blast_files to use previously generated files." | |
20099 if filename == None: | |
20100 print("Please choose a file to write to (-o tag) and try agian.") | |
20101 sys.exit() | |
20102 if featDict == {} and not nofeat: | |
20103 featDict = {"CDS": ("arrow", (64, 224, 208))} | |
20104 if svg: | |
20105 x = drawsvg( | |
20106 filename, | |
20107 minlength, | |
20108 mineval, | |
20109 minIdent, | |
20110 inlist, | |
20111 width, | |
20112 height1, | |
20113 height2, | |
20114 minblastc, | |
20115 maxblastc, | |
20116 minblastci, | |
20117 maxblastci, | |
20118 drawfig1, | |
20119 drawfig2, | |
20120 drawfig3, | |
20121 compress, | |
20122 revlist, | |
20123 featDict, | |
20124 glt, | |
20125 exont, | |
20126 genet, | |
20127 featlengths, | |
20128 aln, | |
20129 graphit, | |
20130 blastoutline, | |
20131 cutlist, | |
20132 filter, | |
20133 legend, | |
20134 legname, | |
20135 ) | |
20136 else: | |
20137 x = draw( | |
20138 filename, | |
20139 minlength, | |
20140 mineval, | |
20141 minIdent, | |
20142 inlist, | |
20143 width, | |
20144 height1, | |
20145 height2, | |
20146 minblastc, | |
20147 maxblastc, | |
20148 minblastci, | |
20149 maxblastci, | |
20150 drawfig1, | |
20151 drawfig2, | |
20152 drawfig3, | |
20153 compress, | |
20154 revlist, | |
20155 featDict, | |
20156 glt, | |
20157 exont, | |
20158 genet, | |
20159 featlengths, | |
20160 aln, | |
20161 graphit, | |
20162 blastoutline, | |
20163 cutlist, | |
20164 filter, | |
20165 legend, | |
20166 legname, | |
20167 ) | |
20168 if (blastit or tblastit) and not keep_blast: | |
20169 shutil.rmtree("temp_easyfig") | |
20170 print("Minimum blast hit reported: " + str(x) + "%") | |
20171 | |
20172 elif len(sys.argv) == 1: | |
20173 from Tkinter import * | |
20174 import tkFileDialog | |
20175 import tkMessageBox | |
20176 import tkSimpleDialog | |
20177 import tkColorChooser | |
20178 | |
20179 class DDlistbox(Listbox): | |
20180 def __init__(self, master, **kw): | |
20181 kw["selectmode"] = SINGLE | |
20182 Listbox.__init__(self, master, kw) | |
20183 self.bind("<Button-1>", self.setCurrent) | |
20184 self.bind("<B1-Motion>", self.shiftSelection) | |
20185 self.curIndex = None | |
20186 | |
20187 def setCurrent(self, event): | |
20188 self.curIndex = self.nearest(event.y) | |
20189 | |
20190 def shiftSelection(self, event): | |
20191 i = self.nearest(event.y) | |
20192 if i < self.curIndex: | |
20193 x = self.get(i) | |
20194 self.delete(i) | |
20195 self.insert(i + 1, x) | |
20196 self.curIndex = i | |
20197 elif i > self.curIndex: | |
20198 x = self.get(i) | |
20199 self.delete(i) | |
20200 self.insert(i - 1, x) | |
20201 self.curIndex = i | |
20202 | |
20203 abortCaptain = False | |
20204 root = Tk() | |
20205 root.title("Easyfig.py") | |
20206 root.option_add("*Font", "TkDefaultFont 12") | |
20207 app = App(root) | |
20208 root.mainloop() | |
20209 else: | |
20210 print( | |
20211 """ | |
20212 Easyfig.py Written by: Mitchell Sullivan mjsull@gmail.com | |
20213 Supervisor: Dr. Scott Beatson University of Queensland 03.12.2010 | |
20214 | |
20215 License: GPLv3 | |
20216 | |
20217 Version 2.2.3 | |
20218 | |
20219 Usage: Easyfig.py [options] GenBank/EMBL/fasta GenBank/EMBL/fasta GenBank/EMBL/fasta ... | |
20220 | |
20221 This script should work on 1 to an infinite amount of GenBank/EMBL files (given enough memory) | |
20222 | |
20223 Adding 2 integers after the annotation file will crop the annotation file. | |
20224 Adding a R after the annotation file will reverse compliment it. | |
20225 | |
20226 WARNING: Will overwrite output file without warning. | |
20227 WARNING: Will delete temp_easyfig folder if -keep flag not given. | |
20228 | |
20229 *************************************************************** | |
20230 GenBank or EMBL file must have source line, or Sequence. | |
20231 ' source 1..<sequence length>' or 'FT source 1..<sequence length>' | |
20232 | |
20233 for GenBank / EMBL | |
20234 | |
20235 *************************************************************** | |
20236 | |
20237 The GenBank file preceding the blast file should always be the query | |
20238 the GenBank file after the blast file should always be the reference | |
20239 In it's present state only 'CDS' features will be recorded | |
20240 | |
20241 Options: | |
20242 -o <string> Specify output file. <REQUIRED!> | |
20243 -blastn Generate blastn files automatically. Requires blastall or blast+ | |
20244 in the path, Annotation file must have nucleotide sequence. [Default] | |
20245 -tblastx Generate tblastx files automatically. Requires blastall or blast+ | |
20246 in the path, Annotation file must have nucleotide sequence. | |
20247 -blast_files List of previously generated blast files, ordered. Query must be | |
20248 annotation file on top, reference annotation file on bottom. | |
20249 -svg Create Scalable Vector Graphics (svg) file instead of bmp. | |
20250 -filter Filter small blast hits or annotations (< 4 pixels wide). [F] | |
20251 | |
20252 | |
20253 GENERAL OPTIONS: | |
20254 -width <int> width of figure in pixels. [5000] | |
20255 -ann_height <int> height of annotations in figure (pixels). [50] | |
20256 -blast_height <int> height of blast hits in figure (pixels). [100] | |
20257 -f1 <T/F> draw colour gradient figure for blast hits. [F] | |
20258 -f2 <int> draw scale figure <int> base pairs long. [0] | |
20259 -uncomp <T/F> Do not compress figure. [F] | |
20260 -f <string> [r g b] [arrow/rect/pointer/frame] | |
20261 Draw features of type <string> (case sensitive) in the | |
20262 color r g b with illustration type arrow, rectangle, | |
20263 pointer or frame. Default light blue arrows. | |
20264 EXAMPLE: -f CDS 255 0 0 rect will draw all CDS features as | |
20265 a red rectangle. | |
20266 if none specified easyFig automatically draws CDS features. | |
20267 If you want a figure with no features drawn use -f F | |
20268 -glt <int> Genome line is <int> pixels thick [5] | |
20269 -exont <int> exon lines joining introns are <int> pixels thick. [1] | |
20270 -genet <int> outline of features is <int> pixels thick. [1] | |
20271 -aln <best/left/right/centre> [centre] | |
20272 Alignment of genomes | |
20273 best aligns feature file perpendicular to best blast hit. | |
20274 -legend <single/double/top/bottom/both/None> | |
20275 Single: Gene names in single column | |
20276 Double: Gene names in two columns | |
20277 Top: Top feature file genes labelled above figure | |
20278 Bottom: Bottom feature file genes labelled below figure | |
20279 Both: Top and bottom feature files genes labelled above | |
20280 and below genome. | |
20281 None: No legend or gene labelling <default> | |
20282 -leg_name Where to get feature name from [gene] | |
20283 | |
20284 BLAST OPTIONS: | |
20285 -e <float> maxmimum e value of blast hits to be drawn. [0.001] | |
20286 -i <float> minimum identity value of blast hits to be drawn. [0] | |
20287 -min_length <int> minimum length of blast hits to be drawn. [0] | |
20288 -blast_col <red/blue> changes blast hits to gradient of red or blue | |
20289 alternitively <int1 int2 int3 int4 int5 int6> | |
20290 defines color gradient for blast hits | |
20291 worst blast hit reported will be color int1 int2 int3 | |
20292 where int 1 2 3 is the RGB of color range[0-255] | |
20293 100% identity blast hits will be color int4 int5 int6 | |
20294 [default 20 20 20 175 175 175] <gray> | |
20295 | |
20296 -blast_col_inv Colour for inverted blast hits. | |
20297 -bo <T/F> Black outline of blast hits. [T] | |
20298 -keep Don't delete blast output (temp_easyfig/) | |
20299 | |
20300 GRAPH OPTIONS: | |
20301 -G <GCContent/GCSkew/Coverage/Custom [filename]> | |
20302 Plot GC Content, GC Skew, Coverage or Custom graph. | |
20303 if Coverage or Custom filename for ace or custom file needs | |
20304 to be provided. Details on how to make custom graph files | |
20305 in manual. | |
20306 -wind_size <int> Window size for calculating GC content/GC skew. [1000] | |
20307 -step <int> Step size for calculating GC content/GC skew. [1000] | |
20308 -line <T/F> Draw graph as a line graph. [T] | |
20309 -axis_t Thickness of X axis. [1] | |
20310 -pos_col <int int int> RGB colour of positive values in graph. [Red] | |
20311 -neg_col <int int int> RGB colour of negative values in graph. [Blue] | |
20312 -g_height <int> height of graph in pixels. [50] | |
20313 -gap gap between graph and annotations. [10] | |
20314 -y_max Maximum y value [Default: max Y calculated.] | |
20315 | |
20316 | |
20317 EXAMPLES: | |
20318 | |
20319 Easyfig.py -filter -o outfile.bmp genbank1.gbk genbank2.gbk genbank3.gbk | |
20320 | |
20321 Easiest way to generate a simple comparison file between three (or more) annotation | |
20322 files. Shows CDS features as red arrows. | |
20323 | |
20324 Easyfig.py -o outfile.bmp -e 0.00001 -f gene frame 0 0 255 -G GCContent ann1.embl ann2.gbk ann3.gbk ann4.embl | |
20325 | |
20326 Generate a blastn comparison between 4 annotation files, Display genes as blue | |
20327 arrows in frame. Only report blast hits under 0.00001 expect value. | |
20328 Display the GC content of each file as a graph. | |
20329 | |
20330 Easyfig.py -tblastx -o outfile.svg -svg ann1.embl 1 10000 ann2.embl 1 10000 R | |
20331 | |
20332 Show a tblastx comparison of the first 10000 base pairs of ann1.embl and ann2.embl | |
20333 Reverse compliment ann2.embl. Writes as a SVG file. | |
20334 | |
20335 | |
20336 this script uses a modified version of Paul McGuire's (http://www.geocities.com/ptmcg/ RIP (geocities, not paul)) | |
20337 bmp.py - module for constructing simple BMP graphics files | |
20338 """ | |
20339 ) |