-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRG_exploder_gui.py
More file actions
2022 lines (1707 loc) · 87.5 KB
/
Copy pathRG_exploder_gui.py
File metadata and controls
2022 lines (1707 loc) · 87.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python3
Progver="RG_exploder_gui_19.py"
ProgverDate="25-Aug-2024"
'''
This module is the Tkinter GUI to run the RG_exploder_*.py suite
See RG_exploder_main.py for summary
Copyright © 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 ; Cary O'Donnell
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see the original repository at
https://github.com/snowlizardz/rg_exploder_shared, or the licences at <https://www.gnu.org/licenses/>.
Contact: syrgenreads@gmail.com
Created using python3 and BioPython
===========
The code in the section "Could be in another module" were once part of this GUI code,
but moved to RG_main when these sections starting calling RG_main objects.
When it became clear that much of these blocks of code added no value to RG_main as part of the App.vue / Vue.js GUI version, they
were moved out of RG_main back here. This to lighten the code burden on RG_main
The 'build' function is the original developer's name for the GUI function allowing the addition of further haplotypes,
created after the initial 'explode' function ie: the fragmentation of sequence into reads
'''
import re
import RG_exploder_io as RG_io # File input/output
import RG_exploder_globals as RG_globals # Configurable constants and preset defaults for user-configurable variables
import RG_exploder_main as RG_main
import RG_exploder_process as RG_process
import RG_exploder_builder as RG_builder
import tkinter as tk
from tkinter import font
from tkinter import ttk
from PIL import ImageTk, Image
import webbrowser
def initialise_stuff():
#initialise_global_vars() # Later dev explicitly setting variables to RG_globals made practically all of the definitions in this function redundant
initialise_modulevalues()
return
# End of initialise_stuff()
# ================= GUI module setups =========================
def initialise_modulevalues():
# Globals limited to this module
global Progver,ProgverDate
global local_begin,local_end,trans_Begin,trans_End,abs_Begin,abs_End
global Chrom_txt
local_begin=RG_globals.bio_parameters["target_build_variant"]["local_begin"]
local_end=RG_globals.bio_parameters["target_build_variant"]["local_end"]
abs_Begin=RG_globals.bio_parameters["target_build_variant"]["abs_Begin"]["value"]
abs_End=RG_globals.bio_parameters["target_build_variant"]["abs_End"]["value"]
trans_Begin=RG_globals.bio_parameters["target_build_variant"]["trans_Begin"]["value"]
trans_End=RG_globals.bio_parameters["target_build_variant"]["trans_End"]["value"]
Chrom_txt="X"
global run_count
run_count=0 # Count how many runs
global IUPAC_sub
IUPAC_sub=RG_globals.IUPAC_codes[:1]+"^"+RG_globals.IUPAC_codes[1:] # Insert a "^" to get a re.sub string for parsing pasted text. Bizarre hack
global previous_target_locus, previous_target_transcript_name
previous_target_locus=""
previous_target_transcript_name=RG_globals.empty_transcript_name
global ENS_target_url,ENS_target_url_txt,LRG_target_url,LRG_target_url_txt,ENS_ts_target_url,ENS_ts_target_url_txt
ENS_target_url="" # variable assigned on reading Refseq in python GUI
ENS_target_url_txt="" # variable assigned on reading Refseq in python GUI
LRG_target_url="" # variable assigned on reading Refseq in python GUI
LRG_target_url_txt="" # variable assigned on reading Refseq in python GUI
ENS_ts_target_url=""
ENS_ts_target_url_txt=""
global icondir
icondir="./icons/"
global results_links,results_idx
results_links=['']
results_idx=[]
global flags_output_labels,flags_output_bools
global config_limit_labels,config_limit_vals,config_limit_mins,config_limit_maxs
''' Use below for testing set_tog_bools(test_labels,test_booleans)
test_labels=["One","Two","Three"]
test_booleans=[False,True,False]
'''
set_flags_output_labels()
set_flags_output_bools()
set_flags_dict()
set_tog_bools(flags_output_labels,flags_output_bools)
set_tog_bools2(flags_output_labels2,flags_output_bools2)
set_config_limits()
set_spin_vals(config_limit_vals,config_limit_labels,config_limit_mins,config_limit_maxs)
set_src_slider_values_build([50,50],["Begin","End"],[0,0]) # New for builder
init_set_src_slider_values(18)# Set number of frequency sliders to a value that doesn't obscure messages panel # Hidden for builder
global max_seqlength,min_seqlength,max_ext_add,min_ext_add
max_seqlength=RG_globals.bio_parameters["target_build_variant"]["trans_Begin"]["max"]
min_seqlength=RG_globals.bio_parameters["target_build_variant"]["trans_Begin"]["min"]
max_ext_add=RG_globals.bio_parameters["target_build_variant"]["trans_Begin_ext"]["max"]
min_ext_add=RG_globals.bio_parameters["target_build_variant"]["trans_Begin_ext"]["min"]
return
# End of def initialise_modulevalues()
def set_flags_dict():
return # Available for testing
global flags_output_labels,flags_output_bools # externally pre-defined
global flags_dict
flags_dict={}
i=0
for label in flags_output_labels:
flags_dict[label]=flags_output_bools[i]
i+=1
# print("flags_dict: %s"%flags_dict)
def set_flags_output_labels():
global flags_output_labels,flag_widget_order,flags_output_labels2,flag_widget_order2
# Set values in flag_widget_order to set the order-positions in flags_output_labels and flags_output_bools
# this becomes the order in which "Output options" is presented for the boolean widgete
flag_widget_order={#"is_duplex":1, # Duplex reads
#"is_frg_paired_end":0, # Paired end reads
"is_flip_strand":0,
"is_fasta_out":1, # Reads in FASTA format
"is_onefrag_out":2, # Each possible read
"is_muts_only":3, # Variant reads only
"is_frg_label":4, # Annotate source positions ...
"is_use_absolute":5, # ...plus absolute position
"is_fastacigar_out":6, # CIGAR annotation
"is_vars_to_lower":7, # Substitutions in lower case
"is_journal_subs":8, # Journal the substitutions - Verbose documentation of variant substitutions
"is_fastq_out":9, # Reads in FASTQ format
"is_write_ref_fasta":10, # Save Template Sequence
"is_mut_out":11, # Save Haplotype Sequences
"is_write_ref_ingb":12, # Save Source features
"is_sam_out":13 # Reads in SAM format
}
flags_output_labels=[""] * len(flag_widget_order)
for item in flag_widget_order:
flags_output_labels[flag_widget_order[item]]=RG_globals.bio_parameters[item]["label"]
flag_widget_order2={"is_CDS":0, #
}
flags_output_labels2=[""] * len(flag_widget_order2)
for item in flag_widget_order2:
flags_output_labels2[flag_widget_order2[item]]=RG_globals.bio_parameters[item]["label"]
def set_flags_output_bools():
global flags_output_bools,flag_widget_order,flags_output_bools2,flag_widget_order2
flags_output_bools=[""] * len(flag_widget_order)
for item in flag_widget_order:
flags_output_bools[flag_widget_order[item]]=RG_globals.bio_parameters[item]["value"]
flags_output_bools2=[""]* len(flag_widget_order2)
for item in flag_widget_order2:
flags_output_bools2[flag_widget_order2[item]]=RG_globals.bio_parameters[item]["value"]
#print("flags_output_bools2 %s \n"%flags_output_bools2)
def set_config_limits():
# Not necessary to set all these as globals if incorporate set_spin_vals in this routine.
# Done here for consistency with the set_flags routines
global config_limit_labels,config_limit_vals,config_limit_mins,config_limit_maxs
config_limit_labels=[RG_globals.bio_parameters["Exome_extend"]["label"],
RG_globals.bio_parameters["Fraglen"]["label"],
RG_globals.bio_parameters["Fragdepth"]["label"],
RG_globals.bio_parameters["Qualmin"]["label"],
RG_globals.bio_parameters["Qualmax"]["label"],
RG_globals.bio_parameters["gauss_mean"]["label"],
RG_globals.bio_parameters["gauss_SD"]["label"]
]
config_limit_vals=[RG_globals.Exome_extend,RG_globals.Fraglen,RG_globals.Fragdepth,RG_globals.Qualmin,RG_globals.Qualmax,RG_globals.gauss_mean,RG_globals.gauss_SD]
config_limit_mins=[RG_globals.Exome_extend_Min,RG_globals.FraglenMin,RG_globals.FragdepthMin,RG_globals.QualMIN,RG_globals.QualMIN,RG_globals.gauss_mean_Min,RG_globals.gauss_SD_Min]
config_limit_maxs=[RG_globals.Exome_extend_Max,RG_globals.FraglenMax,RG_globals.FragdepthMax,RG_globals.QualMAX,RG_globals.QualMAX,RG_globals.gauss_mean_Max,RG_globals.gauss_SD_Max]
def set_tog_bools(in_labels,in_booleans):
global tog_labels,tog_booleans
tog_labels=in_labels
tog_booleans=[]
for val in in_booleans:
tog_booleans.append(val)
#print("A0:tog_booleans %s"%tog_booleans)
def set_tog_bools2(in_labels,in_booleans):
global tog_labels2,tog_booleans2
tog_labels2=in_labels
tog_booleans2=[]
for val in in_booleans:
tog_booleans2.append(val)
#print("A0:tog_booleans2 %s"%tog_booleans2)
def set_src_slider_values_build(invalues,inlabels,invalues2):
global src_sliders_vals_build,src_sliders_strvals_build,src_sliders_labels_build,src_sliders_straddvals_build
src_sliders_vals_build=[]
src_sliders_strvals_build=[]
src_sliders_labels_build=[]
src_sliders_straddvals_build=[]
count=0
for v in invalues:
src_sliders_vals_build.append(tk.IntVar(value=v))
src_sliders_strvals_build.append(tk.StringVar(value=str(v)))
src_sliders_labels_build.append(inlabels[count])
count+=1
for v in invalues2:
src_sliders_straddvals_build.append(tk.StringVar(value=str(v)))
def init_set_src_slider_values(length): # Not used in builder
global src_sliders_init_vals
global src_sliders_vals,src_sliders_strvals,src_sliders_labels
src_sliders_vals=[]
src_sliders_init_vals=[]
src_sliders_strvals=[]
src_sliders_labels=[]
preval=-1
for v in range(length):
src_sliders_vals.append(tk.IntVar(value=preval))
src_sliders_init_vals.append(tk.IntVar(value=preval))
src_sliders_strvals.append(tk.StringVar(value=str(preval)))
src_sliders_labels.append("hap%s"%v)
def set_spin_vals(in_values,in_labels,mins,maxes):
global spinvals,spin_labels,spin_mins,spin_maxs
#global spin_safe_vals
spinvals=[]
#spin_safe_vals=[]
spin_labels=[]
spin_mins=mins
spin_maxs=maxes
count=0
for v in in_labels:
spinvals.append(tk.StringVar(value=in_values[count]))
#spin_safe_vals.append(tk.StringVar(value=in_values[count]))
spin_labels.append(v)
count+=1
def to_bool(inflag):
# If these are text instead of Boolean, resets to Boolean
outflag={'True': True, 'False': False, True: True, False: False}.get(inflag)
#print("flag_to_bool: inflag %s , outflag %s"%(inflag,outflag))
return outflag
def flags_to_bools(inlist):
i=0
for item in inlist:
inlist[i]=to_bool(item)
i+=1
return inlist
def get_flags_output_bools():
global flags_output_bools,tog_booleans,flag_widget_order,tog_booleans2,flag_widget_order2
#print("A:flags_output_bools %s"%flags_output_bools)
#print("A1:tog_booleans %s"%tog_booleans)
#print("GUI flags1: RG_globals.is_mut_out %s"%RG_globals.is_mut_out)
tog_booleans=flags_to_bools(tog_booleans)
tog_booleans2=flags_to_bools(tog_booleans2)
flags_output_bools=tog_booleans
#print("1:flags_output_bools %s"%flags_output_bools)
#print("1:tog_booleans %s"%tog_booleans)
RG_globals.is_flip_strand=tog_booleans[flag_widget_order["is_flip_strand"]]
RG_globals.is_fasta_out=tog_booleans[flag_widget_order["is_fasta_out"]]
RG_globals.is_fastq_out=tog_booleans[flag_widget_order["is_fastq_out"]]
RG_globals.is_sam_out=tog_booleans[flag_widget_order["is_sam_out"]]
RG_globals.is_write_ref_fasta=tog_booleans[flag_widget_order["is_write_ref_fasta"]]
RG_globals.is_mut_out=tog_booleans[flag_widget_order["is_mut_out"]]
#print("GUI flags2: RG_globals.is_mut_out %s; flags_output_bools[4]%s"%(RG_globals.is_mut_out,flags_output_bools[4]))
RG_globals.is_write_ref_ingb=tog_booleans[flag_widget_order["is_write_ref_ingb"]]
RG_globals.is_onefrag_out=tog_booleans[flag_widget_order["is_onefrag_out"]]
RG_globals.is_muts_only=tog_booleans[flag_widget_order["is_muts_only"]]
##RG_globals.is_frg_paired_end=tog_booleans[flag_widget_order["is_frg_paired_end"]]
##RG_globals.is_duplex=tog_booleans[flag_widget_order["is_duplex"]]
RG_globals.is_frg_label=tog_booleans[flag_widget_order["is_frg_label"]]
RG_globals.is_use_absolute=tog_booleans[flag_widget_order["is_use_absolute"]]
RG_globals.is_fastacigar_out=tog_booleans[flag_widget_order["is_fastacigar_out"]]
RG_globals.is_vars_to_lower=tog_booleans[flag_widget_order["is_vars_to_lower"]]
RG_globals.is_journal_subs=tog_booleans[flag_widget_order["is_journal_subs"]]
RG_globals.is_CDS=tog_booleans2[flag_widget_order2["is_CDS"]]
set_flags_dict()
def get_config_limits():
# AKA: get_spin_vals
global spinvals,config_limit_vals
for i in range(len(spinvals)):
#print("1: label %s, value %s"%(config_limit_labels[i],config_limit_vals[i]))
#print("2: label %s, value %s"%(spin_labels[i],spinvals[i].get()))
config_limit_vals[i]=int(float(spinvals[i].get()))
RG_globals.Exome_extend=config_limit_vals[0]
RG_globals.Fraglen=config_limit_vals[1]
RG_globals.Fragdepth=config_limit_vals[2]
RG_globals.Qualmin=config_limit_vals[3]
RG_globals.Qualmax=config_limit_vals[4]
RG_globals.gauss_mean=config_limit_vals[5]
RG_globals.gauss_SD=config_limit_vals[6]
# Checks if the min & max require inversion
if RG_globals.Qualmax < RG_globals.Qualmin:
RG_globals.Qualmin,RG_globals.Qualmax=RG_globals.Qualmax,RG_globals.Qualmin
config_limit_vals[3],config_limit_vals[4]=config_limit_vals[4],config_limit_vals[3]
correct_spin_vals() #see comments in object
#refresh_gui() # Has no effect
return
def correct_spin_vals():
global previous_target_locus,previous_target_transcript_name
# Sledgehammer to re-set everything where the Qualmin/max are swapped
# Called conditionally only after a swap because the frame-refresh caused a screen-flicker when build absent
set_config_limits()
set_spin_vals(config_limit_vals,config_limit_labels,config_limit_mins,config_limit_maxs)
# Now update the spinboxes to show the correction by refreshing frame they are in
# However: since addition of the build frame the layout gets rearranged. Tried fixing ... no luck
#refresh_main_options_list() # Need to change because it messes up the build layout.
def get_mutfreqs():
# Set from src_sliders_init_vals (integers)
# or src_sliders_vals (tk.IntVar)
# or src_sliders_strvals (tk.StringVar)
# src_sliders_init_vals would be user-saved, but the others user-set
# could call save_src_sliders_vals() to force a save to src_sliders_init_vals, but would need a version without user-prompt
# which to force?
global src_sliders_init_vals,src_sliders_vals,src_sliders_strvals
count=0
for i in RG_globals.mutfreqs:
# For user-saved
#RG_globals.mutfreqs[count]=src_sliders_init_vals[count]
# For user-current-selection
#RG_globals.mutfreqs[count]=int(src_sliders_vals[count].get())
# or
RG_globals.mutfreqs[count]=int(src_sliders_strvals[count].get())
count += 1
#print(" src_sliders_init_vals: %s"% src_sliders_init_vals)
#print("RG_globals.mutfreqs: %s"%RG_globals.mutfreqs)
return
def save_and_leave():
#print("GUI save_and_leave1: RG_globals.is_mut_out %s"%RG_globals.is_mut_out)
get_mutfreqs()
#print("GUI save_and_leave2: RG_globals.is_mut_out %s"%RG_globals.is_mut_out)
get_flags_output_bools()
#print("GUI save_and_leave3: RG_globals.is_mut_out %s"%RG_globals.is_mut_out)
get_config_limits()
return
def increment_run():
global run_count,results_links, results_idx
run_count+=1
thisfilepath=RG_globals.pygui_outfilepathroot+RG_globals.target_locus+"/" # pygui_outfilepathroot as "output/" not suitable for this, must be full path
#results_links.append("file://%s"%RG_globals.outfilepathroot)
i=0 ; is_new = True
for item in results_links:
if item == thisfilepath:
results_idx.append(i)
is_new = False
break
i+=1
if is_new:
results_links.append(thisfilepath)
results_idx.append(len(results_links)-1)
def set_refseq_target_url():
# Call (eg: from GUI) to set URL without having read the reference file, by using config.json contents
RG_globals.ensembl_geneid=RG_globals.Reference_sequences[RG_globals.target_locus]["Ensembl_id"]
geneid=RG_globals.ensembl_geneid
LRG_id=RG_globals.Reference_sequences[RG_globals.target_locus]["LRG_id"]
global ENS_target_url,ENS_target_url_txt,LRG_target_url,LRG_target_url_txt,ENS_ts_target_url,ENS_ts_target_url_txt
global Chrom_txt
ENS_target_url=""
ENS_target_url_txt=""
LRG_target_url=""
LRG_target_url_txt=""
ENS_ts_target_url=""
ENS_ts_target_url_txt=""
GRChver_txt=RG_globals.Reference_sequences[RG_globals.target_locus]["Region"].split(":")[0]
Chrom_txt=RG_globals.Reference_sequences[RG_globals.target_locus]["Region"].split(":")[1]
# Special catch for non-standard chromosome identifiers such as PTEN_a
if len(Chrom_txt)>2:
Chrom_txt=Chrom_txt[:3]
if GRChver_txt== RG_globals.GRCh37_txt:
target="37"
elif GRChver_txt== RG_globals.GRCh38_txt:
target="38"
else:
target=""
if LRG_id != "":
#LRG_target_url=RG_globals.lrg_view_url+LRG_id+".xml"
LRG_target_url=RG_globals.lrg_view_url+LRG_id
#LRG_target_url_txt=RG_globals.bio_parameters["target_locus"]["label"]+" "+RG_globals.target_locus+": "+LRG_id
LRG_target_url_txt="LRG "+RG_globals.target_locus+": "+LRG_id
#print("LRG_target_url: %s"%LRG_target_url)
if "." in geneid:
geneid,version=RG_globals.ensembl_geneid.split(".")
if target=="37":
ENS_target_url=RG_globals.ensembl37_gene_url+"g="+geneid
#ENS_target_url_txt="Ensembl "+RG_globals.target_locus+": "+RG_globals.GRCh37_txt+":"+geneid
ENS_target_url_txt=RG_globals.GRCh37_txt+":"+geneid
elif target=="38":
ENS_target_url=RG_globals.ensembl38_gene_url+"g="+geneid
#ENS_target_url_txt="Ensembl "+RG_globals.target_locus+": "+RG_globals.GRCh38_txt+":"+geneid
ENS_target_url_txt=RG_globals.GRCh38_txt+":"+geneid
else:
ENS_target_url=""
#ENS_target_url_txt="Ensembl "+RG_globals.target_locus+": "+"no build "+":"+geneid
ENS_target_url_txt="GRCh??:"+geneid
if RG_globals.target_transcript_name == RG_globals.empty_transcript_name:
ENS_ts_target_url=ENS_target_url
ENS_ts_target_url_txt=ENS_target_url_txt
else:
tsid,version=RG_globals.Reference_sequences[RG_globals.target_locus]["mRNA"][RG_globals.target_transcript_name].split(".")
if target=="37":
# Special cases where transcript is not defined in build 37, is present in 38, and has been edited into the 37 source data
# eg: in config.json AK2-672715m(MANE_Select) and in genbank file "ENST00000672715m.1 , with 'm' as the triggering identifier
if tsid[-1:]=="m": # identify the modified id
tsid=tsid[:-1] # chop it for the hyperlink
target="38" # Switch to 38
if target=="37":
ENS_ts_target_url=RG_globals.ensembl37_transcript_url+"g="+geneid+";t="+tsid
elif target=="38":
ENS_ts_target_url=RG_globals.ensembl38_transcript_url+"g="+geneid+";t="+tsid
else:
ENS_ts_target_url=""
ENS_ts_target_url_txt="GRCh"+target+":"+tsid
#print("ENS_ts_target_url %s"%ENS_ts_target_url)
def results_hyperLink(event):
global results_links
#print("event.widget.tag_names(tk.CURRENT)[1]: %s"%event.widget.tag_names(tk.CURRENT)[1])
'''
Intermittently get the following message written to the Python shell when using the above after clicking on link
- or possibly the error is clicking just off the link, but it's not easily reproducible:
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py", line 1883, in __call__
return self.func(*args)
File "/Users/caryodonnell/Desktop/Replicon/python_exploder_scripts/RG_exploder_gui_06.py", line 392, in results_hyperLink
idx= int(event.widget.tag_names(tk.CURRENT)[1])
ValueError: invalid literal for int() with base 10: 'link'
Substitututed the try: except: construct to evade this error report.
'''
try:
idx= int(event.widget.tag_names(tk.CURRENT)[1])
#print ("idx %s, results_idx[idx-1]%s, results_links[results_idx[idx-1]] %s"%(idx,results_idx[idx-1],results_links[results_idx[idx-1]]))
webbrowser.open("file:///%s"%results_links[results_idx[idx-1]])
except:
# Yup - goes here instead: a silent fail without diagnostic print
# print("results_hyperLink(event) fail")
pass
def save_and_go():
global run_count,icondir
global go_img,gobutton
wait_img=ImageTk.PhotoImage(Image.open(icondir+"wait45.png"))
gobutton.configure(image=wait_img)
#gobutton.configure(text="WAIT")
gobutton.configure(state="disable")
save_and_leave()
#print("GUI save_and_go: RG_globals.is_mut_out %s"%RG_globals.is_mut_out)
increment_run()
write_GUI_text("Running Exploder on %s- run number %s\n"%(RG_globals.target_locus,run_count))
##RG_globals.bio_parameters["target_build_variant"]["exonplus_lookup"]=[0] # testing that setting exonplus_lookup to empty will force a re-run in main
is_successful=RG_main.call_exploder_main()
time_stamp=RG_globals.getime()
#print("is_successful %s"%is_successful)
if is_successful:
write_GUI_text("Run %s Complete at %s\n"%(run_count,time_stamp))
else:
write_GUI_text("Run %s Failed at %s\n"%(run_count,time_stamp))
extralabel,strandlabel=RG_globals.get_strand_extra_label()
write_GUI_results_link("%s_%s run results. Check time stamp!"%(RG_globals.get_locus_transcript(),extralabel))
gobutton.configure(state="normal")
gobutton.configure(image=go_img)
#gobutton.configure(text="GO")
# ================= END GUI module setups =========================
# ================= GUI module setups =========================
def set_pygui_defaults010():
global pygui_frame_labels,pygui_button_labels # Used as tk object labels
#"Save Variant to %s"%(RG_globals.bio_parameters["target_build_variant"]["hap_name"]["label"])]
pygui_frame_labels=["Messages Panel"]
pygui_button_labels=["Clear messages",
"Retrieve Reference Sequence",
"Save"]
# end of set_pygui_defaults010()
def tk_background_config(scope):
# Here in case it's needed
return
scope.configure(background="white")
def ttk_background_config(scope):
# Here in case it's needed
style_4 = {'fg': 'white', 'bg': 'coral2', 'activebackground':
'gray71', 'activeforeground': 'gray71'}
scope.configure(**style_4)
def initialise_tk():
set_pygui_defaults010()
global pygui_frame_labels,pygui_button_labels
global exploder_win,topbar,main,bottom_left,bottom_right
global exploder_win,topbar,main,main_left,main_vars_list,main_build,main_options_list
exploder_win= tk.Tk() # tk only, not ttk
tk_background_config(exploder_win)
exploder_win.title("Synthetic Reads Generator - Python tkinter GUI (v15)")
# Laying out grid
topbar=ttk.Frame(exploder_win)
main=ttk.Frame(exploder_win)
bottom_left=ttk.Frame(exploder_win)
bottom_centre=ttk.Frame(exploder_win)
bottom_right=ttk.Frame(exploder_win)
# Trying to set background all same
tk_background_config(main)
tk_background_config(topbar)
tk_background_config(main)
tk_background_config(bottom_left)
tk_background_config(bottom_right)
topbar.pack(side="top", fill="x")
main.pack(side="top", fill="both", expand=True)
bottom_left.pack(side="left", fill="both", expand=False)
bottom_centre.pack(side="left", fill="both", expand=False)
bottom_right.pack(side="right", fill="both", expand=False)
initialise_main_left(main)
initialise_main_vars_list(main)
initialise_main_options_list(main)
initialise_main_build(main)
main_left.pack(side="left", fill="both", expand=True)
main_vars_list.pack(side="left", fill="both", expand=True)
main_options_list.pack(side="left", fill="both", expand=True)
main_build.pack(side="left", fill="both", expand=True)
#topbar.label=tk.Label(topbar, width=30,text="Topbar Panel",foreground="blue")
#topbar.header=tk.Label(topbar,text="%s | %s"%(RG_globals.CustomerIDText,RG_globals.DatasetIDText))
topbar.header=ttk.Label(topbar,text="%s | %s"%(RG_globals.CustomerIDText,RG_globals.DatasetIDText))
tk_background_config(topbar.header)
topbar.header.pack()
#topbar.help=tk.Label(topbar,text="%s"%(RG_globals.help_label))
topbar.help=ttk.Label(topbar,text="%s"%(RG_globals.help_label))
topbar.help.pack()
set_topbar_help()
### Next lines add an Ensembl and LRG hyperlink to top of page, but these duplicated in titles of selection boxes
#topbar.ENS_label=tk.Label(topbar,text="Ensembl:%s"%RG_globals.target_locus)
#topbar.ENS_label.pack()
#topbar.LRG_label=tk.Label(topbar,text="LRG:%s"%RG_globals.target_locus)
#topbar.LRG_label.pack()
### If reinstate these, need to reinstate lines in refresh_genelabels as well
#bottom_left.label=tk.Label(bottom_left, width=30,text="Messages Panel",)
#bottom_left.label=tk.Label(bottom_left, width=30,text=pygui_frame_labels[0])
bottom_left.label=ttk.Label(bottom_left, width=30,text=pygui_frame_labels[0])
bottom_left.label.grid()
bottom_centre.label=ttk.Label(bottom_centre, width=30,text="")
bottom_centre.label.grid()
#bottom_right.label=tk.Label(bottom_right, width=30,text="Gene structure")
bottom_right.label=ttk.Label(bottom_right, width=30,text="Gene structure")
bottom_right.label.grid()
#main_vars_list.label=tk.Label(main_vars_list, width=10,text="Centre Panel",)
#main_vars_list.label.pack(side="top", fill="x")
# END Laying out grid
return
# END initialise_tk()
def set_generic_label(framelabel,hyperlink,url,urltxt):
if urltxt != "":
framelabel['text']=urltxt
f2 = font.Font(framelabel, framelabel.cget("font"))
if url != "":
f2.configure(underline = True)
framelabel.configure(font=f2)
framelabel['foreground']="blue"
framelabel['cursor']="hand2"
framelabel.bind('<Button-1>', hyperlink)
else:
#NB: Underline does not disappear
f2.configure(underline = False)
framelabel['foreground']="black"
framelabel['cursor']="arrow"
framelabel.unbind('<Button-1>')
def ensembl_hyperLink(event):
global ENS_target_url
if ENS_target_url != "":
webbrowser.open("%s"%ENS_target_url)
def set_topbar_ENS_label_link():
set_generic_label(topbar.ENS_label,ensembl_hyperLink,ENS_target_url,ENS_target_url_txt)
def lrg_hyperLink(event):
global LRG_target_url
#print("LRG_target_url %s"%LRG_target_url)
if LRG_target_url != "":
webbrowser.open("%s"%LRG_target_url)
def set_topbar_LRG_label_link():
set_generic_label(topbar.LRG_label,lrg_hyperLink,LRG_target_url,LRG_target_url_txt)
def set_listbox_locus_label():
#set_generic_label(main_left.genelistlabel,lrg_hyperLink,LRG_target_url,"") # LRG now
set_generic_label(main_left.genelistlabel,ensembl_hyperLink,ENS_target_url,ENS_target_url_txt)
def ensembl_ts_hyperLink(event):
global ENS_ts_target_url
if ENS_ts_target_url != "":
webbrowser.open("%s"%ENS_ts_target_url)
def set_listbox_transcript_label():
#set_generic_label(main_left.tslistlabel,ensembl_ts_hyperLink,ENS_ts_target_url,"")
set_generic_label(main_left.tslistlabel,ensembl_ts_hyperLink,ENS_ts_target_url,ENS_ts_target_url_txt)
def help_hyperLink(event):
if RG_globals.help_url != "":
webbrowser.open("%s"%RG_globals.help_url)
def set_topbar_help():
set_generic_label(topbar.help,help_hyperLink,RG_globals.help_url,"")
def initialise_main_left(frame):
global main_left
#main_left=tk.LabelFrame(main,text="Main_Left",padx=10,pady=10)
main_left=ttk.LabelFrame(main,text="Main_Left")
#tk_background_config(main_left)
set_gene_list(main_left)
def initialise_main_options_list(frame):
global main_options_list
#main_options_list=tk.LabelFrame(frame,text=" Output options",padx=10,pady=10)
#main_options_list=tk.LabelFrame(frame,text=RG_globals.options_label,padx=10,pady=10)
main_options_list=ttk.LabelFrame(frame,text=RG_globals.options_label)
#tk_background_config(main_options_list)
def initialise_main_vars_list(frame):
global main_vars_list
#main_vars_list=tk.LabelFrame(main,padx=10,pady=10) # Compatible with font setting in class source_sliders
main_vars_list=ttk.LabelFrame(main) # Not compatible with font setting in class source_sliders
#tk_background_config(main_vars_list)
set_slider_gene_label()
def initialise_main_build(frame):
global main_build
#main_build=tk.LabelFrame(main,padx=10,pady=10)
#main_build=tk.LabelFrame(main)
main_build=ttk.LabelFrame(main)
#tk_background_config(main_build)
set_slider_build_label()
#panel_build = tk.Frame(main_build)
panel_build = ttk.Frame(main_build)
#tk_background_config(panel_build)
panel_build.grid()
#panel_build.label=tk.Label(panel_build,text=" Source Local_pos Global_pos Extension")
panel_build.label=ttk.Label(panel_build,text=" Source Local_coord Extension Genome_coord")
panel_build.label.grid(row=0,column=0,sticky=tk.W)
def set_slider_gene_label():
set_gene_label(main_vars_list)
def set_slider_build_label():
set_builder_label(main_build)
def set_gene_label(frame):
#frame['text']=" %s %s"%(RG_globals.variants_header,RG_globals.frequency_label)
frame['text']=" %ss"%RG_globals.variants_label
frame_label=ttk.Label(frame,text=" %s %s"%(RG_globals.bio_parameters["target_build_variant"]["hap_name"]["label"],RG_globals.frequency_label))
frame_label.grid()
#frame['text']=" Source Name %s"%(RG_globals.frequency_label)
def set_builder_label(frame):
#frame['text']=" Label Position Extension Global_mapping" # Addition in builder
frame['text']=" Create a new %s %s"%(RG_globals.target_locus,RG_globals.variants_label) # Addition in builder
def set_gene_list(frame):
#frame['text']="Gene List:%s"%RG_globals.target_locus
#frame['text']=" Reference Gene"
#frame['text']=pygui_frame_labels[1]
frame['text']=RG_globals.reference_gene
# Source label/slider definitions
class source_sliders:
def __init__(self, master1,v_index,**kwargs):
global src_sliders_vals,src_sliders_strvals,src_sliders_labels
#self.panel2 = tk.Frame(master1)
self.panel2 = ttk.Frame(master1)
self.panel2.grid()
self.label=ttk.Label(self.panel2, width=15,text="%s_%s"%(RG_globals.target_locus,src_sliders_labels[v_index]))
self.label.grid(row=0,column=0,sticky=tk.W)
#f2 = font.Font(master1, master1.cget("font")) # Looks superfluous here
#self.label.configure(font=f2)# Not supported ttk.LabelFrame, so looks superfluous
####### Extra to make this a hyperlink to the source file
# However unless this is made READ only, implementing this allows the user to edit the file before a run.
# This is Dangerous because it will change the source file without verification of constraint to correct number range
# Best way to manage this is to use the 'Create a New Variations Source' feature aka 'Builder'
#f2.configure(underline = True)
#self.label['fg']="blue"
#self.label['cursor']="hand2"
#self.label.bind('<Button-1>', lambda e: self.haplotype_hyperLink(self.label['text']))
#######
self.entryvar=src_sliders_strvals[v_index]
#self.entry = tk.Entry(self.panel2, textvariable=self.entryvar, width=3)
self.entry = ttk.Entry(self.panel2, textvariable=self.entryvar, width=3)
self.entry.grid(row=0,column=1,sticky=tk.W)
self.blank=''
self.old_value = src_sliders_strvals[v_index].get()
self.zero='0'
self.entryvar.trace('w', self.checkentry)
self.get, self.set = self.entryvar.get, self.entryvar.set
self.scalevar=src_sliders_vals[v_index]
#self.scale2 = tk.Scale(self.panel2,variable = self.scalevar,orient=tk.HORIZONTAL,sliderlength=25,**kwargs)
self.scale2 = ttk.Scale(self.panel2,variable = self.scalevar,orient=tk.HORIZONTAL,**kwargs)
self.scale2.grid(row=0,column=2,sticky=tk.W)
self.scalevar.trace('w', self.setentryfromscale)
def checkentry(self, *args):
if self.get().isdigit():
# the current value is only digits; allow this
self.old_value = self.get()
self.scalevar.set(int(self.get()))
self.entryvar.set(str(self.scalevar.get()))
elif self.get() == self.blank:
# the current value is blank - set to zero
self.old_value = self.zero
self.scalevar.set(0)
# self.entryvar.set(str(self.scalevar.get()))
else:
# there's non-digit characters in the input; reject this
self.set(self.old_value)
def setentryfromscale(self, *args):
self.entryvar.set(str(self.scalevar.get()))
def haplotype_hyperLink(event,w_txt):
try:
#idx= int(event.widget.tag_names(tk.CURRENT)[1])
#print ("idx %s, results_idx[idx-1]%s, results_links[results_idx[idx-1]] %s"%(idx,results_idx[idx-1],results_links[results_idx[idx-1]]))
in_file="%s%s/%s%s"%(RG_globals.infilepathroot,RG_globals.target_locus,w_txt,RG_globals.Seq_IO_file_ext)
file_exists = RG_io.is_file(in_file)
if file_exists:
webbrowser.open("file:///%s"%in_file)
else:
clear_GUI_text()
write_GUI_text("File does not exist - this will occur after creating a new %s"%RG_globals.variants_label)
except:
# Yup - goes here instead: a silent fail without diagnostic print
# print("results_hyperLink(event) fail")
pass
class source_sliders_builder:# The Locus_Begin / Locus_End entry panels
def __init__(self, master1,v_index,**kwargs):
global src_sliders_vals_build,src_sliders_strvals_build,src_sliders_labels_build
global src_sliders_straddvals_build,max_seqlength,min_seqlength,max_ext_add,min_ext_add
global Chrom_txt
#self.panel2 = tk.Frame(master1)
self.panel2 = ttk.Frame(master1)
self.panel2.grid()
self.label=ttk.Label(self.panel2, width=11,text="%s"%(src_sliders_labels_build[v_index]))
self.label.grid(row=0,column=0,sticky=tk.W)
self.entryvar=src_sliders_strvals_build[v_index]
#self.entry = tk.Spinbox(self.panel2, textvariable=self.entryvar, width=6,from_=min_seqlength,to=max_seqlength)
self.entry = ttk.Spinbox(self.panel2, textvariable=self.entryvar, width=6,from_=min_seqlength,to=max_seqlength)
self.entry.grid(row=0,column=1,sticky=tk.W)
self.abspos=0
self.localpos=0
self.blank=''
self.old_value = src_sliders_strvals_build[v_index].get()
self.zero='1'
self.entryvar.trace('w', self.checkentry)
self.get, self.set = self.entryvar.get, self.entryvar.set
self.scalevar=src_sliders_vals_build[v_index]
self.scalevar.trace('w', self.checkentry2)
self.entry2var=src_sliders_straddvals_build[v_index]
#self.entry2 = tk.Spinbox(self.panel2, textvariable=self.entry2var, width=4,from_=min_ext_add,to=max_ext_add,state='readonly')
self.entry2 = ttk.Spinbox(self.panel2, textvariable=self.entry2var, width=4,from_=min_ext_add,to=max_ext_add,state='readonly')
self.entry2.grid(row=0,column=2,sticky=tk.W)
self.entry2var.trace('w', self.checkentry2)# Adds any change here to the absolute / genome coord
#self.complement_check(self)
self.complement_check() # Extra in builder
#self.abslabel=tk.Label(self.panel2, width=10,text=str(self.abspos))
self.abslabel=ttk.Label(self.panel2, width=11,text=str(self.abspos))
self.abslabel.grid(row=0,column=3,sticky=tk.W)
def checkentry(self, *args):
if self.get().isdigit():
# the current value is only digits; allow this
self.old_value = self.get()
self.scalevar.set(int(self.get()))
self.entryvar.set(str(self.scalevar.get()))
if int(self.entry.get()) > max_seqlength:
self.entryvar.set(str(max_seqlength))
self.set(str(max_seqlength))
elif self.get() == self.blank:
# the current value is blank - set to zero (or minimum)
self.old_value = self.zero
self.scalevar.set(1)
self.set(1)
#self.entryvar.set(str(self.scalevar.get()))
else:
# there's non-digit characters in the input; reject this
self.set(self.old_value)
def checkentry2(self, *args):
global max_seqlength,min_seqlength
self.entry.config(from_=min_seqlength, to=max_seqlength)
self.entryvar.set(str(self.scalevar.get()))
#self.complement_check(self)
self.complement_check() # Extra in builder
self.abslabel.config(text=Chrom_txt +":"+str(self.abspos))
self.entry.config(from_=min_seqlength, to=max_seqlength)
# Extra in builder
def complement_check(self,*args):
abs_offset=RG_globals.bio_parameters["target_build_variant"]["abs_offset"]
#exonplus_lookup=RG_globals.bio_parameters["target_build_variant"]["exonplus_lookup"]
self.extension=int(self.entry2var.get())
if self.entry.get() == self.blank:
self.entry.delete(0,"end")
self.entry.insert(0,1)
self.transpos=int(self.entry.get())
if self.transpos > max_seqlength:
self.transpos = max_seqlength
if RG_globals.target_transcript_name == RG_globals.empty_transcript_name:
headclip=RG_globals.bio_parameters["target_build_variant"]["headclip"] # This should be == the REFSEQ.Headclip value
#headclip=int(RG_globals.bio_parameters[RG_globals.target_locus]["Locus_range"].split(":")[0])-1 # Do not need the previous!
self.localpos=self.transpos+self.extension+headclip
else:
if RG_globals.Reference_sequences[RG_globals.target_locus]["is_join_complement"]:
modpos=-self.extension # alternative to headclip, but does same job here
else:
modpos=self.extension
self.localpos=int(RG_globals.exonplus_lookup[self.transpos])+int(modpos)
self.abspos=abs(abs_offset+self.localpos)
# Extra in builder
# END class source_sliders_builder
def src_sliders_build_clear_seqs():
global refseqtxt,varseqtxt,varnameseqtxt,out_seq,varnametxt,hapnameseqtxt,hapnametxt
refseqtxt.configure(state="normal")
refseqtxt.delete('1.0', tk.END)
refseqtxt.configure(state="disable")
varseqtxt.configure(state="normal")
varseqtxt.delete('1.0', tk.END)
varseqtxt.configure(state="disable")
out_seq=""
hapnameseqtxt.configure(state="normal")
hapnameseqtxt.delete('1.0', tk.END)
hapnameseqtxt.configure(state="disable")
hapnametxt="hap01"
varnameseqtxt.configure(state="normal")
varnameseqtxt.delete('1.0', tk.END)
varnameseqtxt.configure(state="disable")
varnametxt=""
def src_sliders_instantiate(window):
global src_slider_widgets,src_sliders_vals,src_slider_widgets_active_count,max_src_slider_widgets
src_slider_widgets=[]
src_slider_widgets_active_count=0
# Instantiating the label/slider display
for r in range(len(src_sliders_vals)):
# src_slider_widgets.append(source_sliders(window,r,from_=0, to=100,showvalue=0)) # Use showvalue to hide(0), or show(1) the slider values above the slider
src_slider_widgets.append(source_sliders(window,r,from_=0, to=100)) # showvalue not supported in ttk, but defaults to not showing above slider
src_slider_widgets_active_count=len(src_slider_widgets)
max_src_slider_widgets=len(src_slider_widgets)
# End Instantiating the label/slider display
return
def src_sliders_instantiate_build(window):
global src_slider_widgets_build,src_sliders_vals_build,max_seqlength,src_slider_widgets,max_src_slider_widgets
global local_begin,local_end,abs_Begin,abs_End,trans_Begin,trans_End
global refseqtxt,varseqtxt,out_seq,varnameseqtxt,hapnameseqtxt,hapnametxt
seq_region=""
seq_region_success=False
out_seq=""
varnametxt=""
hapnametxt="hap01"
abs_maptxt=""
src_slider_widgets_build=[]
# Instantiating the label/slider display
for r in range(len(src_sliders_vals_build)):
src_slider_widgets_build.append(source_sliders_builder(window,r, to=max_seqlength,showvalue=0))
def get_ref_range():
global local_begin, local_end
'''
if local_begin > local_end:
local_begin,local_end=local_end,local_begin #swap
'''
#print("local_end %s; local_begin %s; local_end-local_begin %s"%(local_end,local_begin,local_end-local_begin))
success=False
RG_globals.bio_parameters["target_build_variant"]["local_begin"]=local_begin
RG_globals.bio_parameters["target_build_variant"]["local_end"]=local_end
RG_globals.bio_parameters["target_build_variant"]["abs_Begin"]["value"]=abs_Begin
RG_globals.bio_parameters["target_build_variant"]["abs_End"]["value"]=abs_End
RG_globals.bio_parameters["target_build_variant"]["trans_Begin"]["value"]=trans_Begin
RG_globals.bio_parameters["target_build_variant"]["trans_End"]["value"]=trans_End
RG_globals.bio_parameters["target_build_variant"]["trans_Begin_ext"]["value"]=trans_Begin_ext
RG_globals.bio_parameters["target_build_variant"]["trans_End_ext"]["value"]=trans_End_ext
subseq,run_success=RG_builder.get_ref_subseq3(local_begin,local_end)
if run_success:
RG_globals.bio_parameters["target_build_variant"]["ref_subseq"]["value"]=str(subseq)
else:
RG_globals.bio_parameters["target_build_variant"]["ref_subseq"]["value"]="FAIL"
ref_range=RG_globals.bio_parameters["target_build_variant"]["ref_subseq"]["value"]
ref_string=RG_globals.bio_parameters["target_build_variant"]["ref_subseq"]["viewstring"]
#print("ref_range %s"%ref_range)
if ref_range !="FAIL":
success= True
return ref_range,ref_string,success
def calc_seq():
global varnametxt