Mercurial > repos > fubar > jbrowse2
comparison jbrowse2.py @ 85:3b2ff9864995 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 264a3d6c7a29f396d359f33164ddf2cb1d9903f8-dirty
| author | fubar |
|---|---|
| date | Tue, 09 Apr 2024 00:26:49 +0000 |
| parents | 746eae952c18 |
| children | 408781c080fc |
comparison
equal
deleted
inserted
replaced
| 84:5c295cc220ed | 85:3b2ff9864995 |
|---|---|
| 473 } | 473 } |
| 474 | 474 |
| 475 if trackDict.get("displays", None): # use first if multiple like bed | 475 if trackDict.get("displays", None): # use first if multiple like bed |
| 476 style_data["type"] = trackDict["displays"][0]["type"] | 476 style_data["type"] = trackDict["displays"][0]["type"] |
| 477 style_data["displayId"] = trackDict["displays"][0]["displayId"] | 477 style_data["displayId"] = trackDict["displays"][0]["displayId"] |
| 478 wstyle = { | 478 return style_data |
| 479 "displays": [ | |
| 480 style_data, | |
| 481 ] | |
| 482 } | |
| 483 return wstyle | |
| 484 | 479 |
| 485 def getNrow(self, url): | 480 def getNrow(self, url): |
| 486 useuri = url.startswith("https://") or url.startswith("http://") | 481 useuri = url.startswith("https://") or url.startswith("http://") |
| 487 if not useuri: | 482 if not useuri: |
| 488 fl = open(url, "r").readlines() | 483 fl = open(url, "r").readlines() |
| 679 uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/fasta/GRCh38.fa.gz.gzi', | 674 uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/fasta/GRCh38.fa.gz.gzi', |
| 680 Cool will not be likely to be a good fit - see discussion at https://github.com/GMOD/jbrowse-components/issues/2438 | 675 Cool will not be likely to be a good fit - see discussion at https://github.com/GMOD/jbrowse-components/issues/2438 |
| 681 | 676 |
| 682 """ | 677 """ |
| 683 tId = trackData["label"] | 678 tId = trackData["label"] |
| 679 wasCool = trackData["wasCool"] | |
| 684 # can be served - if public. | 680 # can be served - if public. |
| 685 # dsId = trackData["metadata"]["dataset_id"] | 681 # dsId = trackData["metadata"]["dataset_id"] |
| 686 # url = "%s/api/datasets/%s/display?to_ext=hic " % (self.giURL, dsId) | 682 # url = "%s/api/datasets/%s/display?to_ext=hic " % (self.giURL, dsId) |
| 687 useuri = trackData["useuri"].lower() == "yes" | 683 useuri = trackData["useuri"].lower() == "yes" |
| 684 logging.debug("wasCool=%s, data=%s, tId=%s" % (wasCool, data, tId)) | |
| 688 if useuri: | 685 if useuri: |
| 689 uri = data | 686 uri = data |
| 690 else: | 687 else: |
| 691 uri = tId | 688 uri = tId + ".hic" |
| 692 # slashes in names cause path trouble | 689 if not wasCool: |
| 693 dest = os.path.join(self.outdir, uri) | 690 dest = os.path.join(self.outdir, uri) |
| 694 cmd = ["cp", data, dest] | 691 if not os.path.exists(dest): |
| 695 self.subprocess_check_call(cmd) | 692 cmd = ["cp", data, dest] |
| 693 self.subprocess_check_call(cmd) | |
| 694 else: | |
| 695 logging.error("not wasCool but %s exists" % dest) | |
| 696 categ = trackData["category"] | 696 categ = trackData["category"] |
| 697 trackDict = { | 697 trackDict = { |
| 698 "type": "HicTrack", | 698 "type": "HicTrack", |
| 699 "trackId": tId, | 699 "trackId": tId, |
| 700 "name": trackData["name"], | 700 "name": trackData["name"], |
| 852 style_json = self._prepare_track_style(trackDict) | 852 style_json = self._prepare_track_style(trackDict) |
| 853 trackDict["style"] = style_json | 853 trackDict["style"] = style_json |
| 854 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) | 854 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) |
| 855 self.trackIdlist.append(tId) | 855 self.trackIdlist.append(tId) |
| 856 | 856 |
| 857 def add_bam(self, data, trackData, bam_index=None, **kwargs): | 857 def add_bam(self, data, trackData, bam_indexes=None, **kwargs): |
| 858 tId = trackData["label"] | 858 tId = trackData["label"] |
| 859 realFName = trackData["key"] | |
| 859 useuri = trackData["useuri"].lower() == "yes" | 860 useuri = trackData["useuri"].lower() == "yes" |
| 860 bindex = bam_index | |
| 861 categ = trackData["category"] | 861 categ = trackData["category"] |
| 862 if useuri: | 862 if useuri: |
| 863 url = data | 863 url = data |
| 864 else: | 864 else: |
| 865 fname = tId | 865 fname = tId |
| 866 dest = "%s/%s" % (self.outdir, fname) | 866 dest = "%s/%s" % (self.outdir, fname) |
| 867 url = fname | 867 url = fname |
| 868 bindex = fname + ".bai" | 868 bindex = fname + ".bai" |
| 869 self.subprocess_check_call(["cp", data, dest]) | 869 self.subprocess_check_call(["cp", data, dest]) |
| 870 bi = bam_indexes.split() | |
| 871 bam_index = [ | |
| 872 x.split(",")[1].strip() | |
| 873 for x in bi | |
| 874 if "," in x and x.split(",")[0].strip() == realFName | |
| 875 ] | |
| 876 if len(bam_index) > 0: | |
| 877 bam_index = bam_index[0] | |
| 878 else: | |
| 879 bam_index = None | |
| 880 logging.debug( | |
| 881 "===realFName=%s got %s as bi, %s for bam_index" | |
| 882 % (realFName, bi, bam_index) | |
| 883 ) | |
| 870 if bam_index is not None and os.path.exists(bam_index): | 884 if bam_index is not None and os.path.exists(bam_index): |
| 871 if not os.path.exists(bindex): | 885 if not os.path.exists(bindex): |
| 872 # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest | 886 # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest |
| 873 self.subprocess_check_call(["cp", bam_index, bindex]) | 887 self.subprocess_check_call(["cp", bam_index, bindex]) |
| 874 else: | 888 else: |
| 907 style_json = self._prepare_track_style(trackDict) | 921 style_json = self._prepare_track_style(trackDict) |
| 908 trackDict["style"] = style_json | 922 trackDict["style"] = style_json |
| 909 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) | 923 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) |
| 910 self.trackIdlist.append(tId) | 924 self.trackIdlist.append(tId) |
| 911 | 925 |
| 912 def add_cram(self, data, trackData, cram_index=None, **kwargs): | 926 def add_cram(self, data, trackData, cram_indexes=None, **kwargs): |
| 913 tId = trackData["label"] | 927 tId = trackData["label"] |
| 928 realFName = trackData["key"] | |
| 914 categ = trackData["category"] | 929 categ = trackData["category"] |
| 915 useuri = trackData["useuri"].lower() == "yes" | 930 useuri = trackData["useuri"].lower() == "yes" |
| 916 gsa = self.assmeta.get(trackData["assemblyNames"], None) | 931 gsa = self.assmeta.get(trackData["assemblyNames"], None) |
| 917 if gsa: | 932 if gsa: |
| 918 genseqad = gsa[0]["genome_sequence_adapter"] | 933 genseqad = gsa[0]["genome_sequence_adapter"] |
| 924 else: | 939 else: |
| 925 fname = tId | 940 fname = tId |
| 926 dest = os.path.join(self.outdir, fname) | 941 dest = os.path.join(self.outdir, fname) |
| 927 url = fname | 942 url = fname |
| 928 self.subprocess_check_call(["cp", data, dest]) | 943 self.subprocess_check_call(["cp", data, dest]) |
| 929 if cram_index is not None and os.path.exists(cram_index): | 944 ci = cram_indexes.split() |
| 945 cram_index = [ | |
| 946 x.split(",")[1].strip() | |
| 947 for x in ci | |
| 948 if "," in x and x.split(",")[0] == realFName | |
| 949 ] | |
| 950 if len(cram_index) > 0: | |
| 951 cram_index = cram_index[0] | |
| 952 else: | |
| 953 cram_index = None | |
| 954 logging.debug( | |
| 955 "=== for %s got %s as cram_indexes, %s for cram_index" | |
| 956 % (realFName, cram_indexes, cram_index) | |
| 957 ) | |
| 958 if cram_index and os.path.exists(cram_index): | |
| 930 if not os.path.exists(dest + ".crai"): | 959 if not os.path.exists(dest + ".crai"): |
| 931 # most probably made by galaxy and stored in galaxy dirs, need to copy it to dest | 960 # most probably made by galaxy and stored in galaxy dirs, need to copy it to dest |
| 932 self.subprocess_check_call( | 961 self.subprocess_check_call( |
| 933 ["cp", os.path.realpath(cram_index), dest + ".crai"] | 962 ["cp", os.path.realpath(cram_index), dest + ".crai"] |
| 934 ) | 963 ) |
| 1086 categ = trackData["category"] | 1115 categ = trackData["category"] |
| 1087 useuri = trackData["useuri"].lower() == "yes" | 1116 useuri = trackData["useuri"].lower() == "yes" |
| 1088 if useuri: | 1117 if useuri: |
| 1089 url = data | 1118 url = data |
| 1090 else: | 1119 else: |
| 1091 url = tId + '.gz' | 1120 url = tId + ".gz" |
| 1092 dest = "%s/%s" % (self.outdir, url) | 1121 dest = "%s/%s" % (self.outdir, url) |
| 1093 self._sort_bed(data, dest) | 1122 self._sort_bed(data, dest) |
| 1094 trackDict = { | 1123 trackDict = { |
| 1095 "type": "FeatureTrack", | 1124 "type": "FeatureTrack", |
| 1096 "trackId": tId, | 1125 "trackId": tId, |
| 1201 "type": "LinearBasicDisplay", | 1230 "type": "LinearBasicDisplay", |
| 1202 "displayId": "%s-LinearSyntenyDisplay" % tId, | 1231 "displayId": "%s-LinearSyntenyDisplay" % tId, |
| 1203 }, | 1232 }, |
| 1204 ], | 1233 ], |
| 1205 } | 1234 } |
| 1206 if nrow > 20000: | 1235 if nrow > 10000: |
| 1207 style_json = { | 1236 style_json = { |
| 1208 "displays": [ | 1237 "type": "LGVSyntenyDisplay", |
| 1209 { | 1238 "displayId": "%s-LGVSyntenyDisplay" % tId, |
| 1210 "type": "LGVSyntenyDisplay", | |
| 1211 "displayId": "%s-LGVSyntenyDisplay" % tId, | |
| 1212 } | |
| 1213 ] | |
| 1214 } | 1239 } |
| 1215 else: | 1240 else: |
| 1216 style_json = { | 1241 style_json = { |
| 1217 "displays": [ | 1242 "type": "LinearBasicDisplay", |
| 1218 { | 1243 "displayId": "%s-LinearBasicDisplay" % tId, |
| 1219 "type": "LinearBasicDisplay", | |
| 1220 "displayId": "%s-LinearBasicDisplay" % tId, | |
| 1221 } | |
| 1222 ] | |
| 1223 } | 1244 } |
| 1224 | |
| 1225 trackDict["style"] = style_json | 1245 trackDict["style"] = style_json |
| 1226 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) | 1246 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) |
| 1227 self.trackIdlist.append(tId) | 1247 self.trackIdlist.append(tId) |
| 1228 | 1248 |
| 1229 def process_annotations(self, track): | 1249 def process_annotations(self, track): |
| 1264 self.add_gff( | 1284 self.add_gff( |
| 1265 dataset_path, | 1285 dataset_path, |
| 1266 outputTrackConfig, | 1286 outputTrackConfig, |
| 1267 ) | 1287 ) |
| 1268 elif dataset_ext in ("hic", "juicebox_hic"): | 1288 elif dataset_ext in ("hic", "juicebox_hic"): |
| 1289 outputTrackConfig["wasCool"] = False | |
| 1269 self.add_hic( | 1290 self.add_hic( |
| 1270 dataset_path, | 1291 dataset_path, |
| 1271 outputTrackConfig, | 1292 outputTrackConfig, |
| 1272 ) | 1293 ) |
| 1273 elif dataset_ext in ("cool", "mcool", "scool"): | 1294 elif dataset_ext in ("cool", "mcool", "scool"): |
| 1274 hic_url = outputTrackConfig["label"] | 1295 hic_url = outputTrackConfig["label"] |
| 1275 hic_path = os.path.join(self.outdir, hic_url) | 1296 hic_path = os.path.join(self.outdir, hic_url) + ".hic" |
| 1297 outputTrackConfig["wasCool"] = True | |
| 1276 self.subprocess_check_call( | 1298 self.subprocess_check_call( |
| 1277 [ | 1299 [ |
| 1278 "hictk", | 1300 "hictk", |
| 1279 "convert", | 1301 "convert", |
| 1280 "-f", | 1302 "-f", |
| 1282 "hic", | 1304 "hic", |
| 1283 dataset_path, | 1305 dataset_path, |
| 1284 hic_path, | 1306 hic_path, |
| 1285 ] | 1307 ] |
| 1286 ) | 1308 ) |
| 1309 logging.debug( | |
| 1310 "### ext=cool: wasCool=%s, hic_path=%s" | |
| 1311 % (outputTrackConfig["wasCool"], hic_path) | |
| 1312 ) | |
| 1287 self.add_hic( | 1313 self.add_hic( |
| 1288 hic_url, | 1314 hic_path, |
| 1289 outputTrackConfig, | 1315 outputTrackConfig, |
| 1290 ) | 1316 ) |
| 1291 elif dataset_ext in ("bed",): | 1317 elif dataset_ext in ("bed",): |
| 1292 self.add_bed( | 1318 self.add_bed( |
| 1293 dataset_path, | 1319 dataset_path, |
| 1304 dataset_path, | 1330 dataset_path, |
| 1305 outputTrackConfig, | 1331 outputTrackConfig, |
| 1306 ) | 1332 ) |
| 1307 elif dataset_ext == "bam": | 1333 elif dataset_ext == "bam": |
| 1308 real_indexes = track["conf"]["options"]["bam"]["bam_index"] | 1334 real_indexes = track["conf"]["options"]["bam"]["bam_index"] |
| 1335 logging.debug("**** add bam got %s for indexes" % real_indexes) | |
| 1309 self.add_bam( | 1336 self.add_bam( |
| 1310 dataset_path, | 1337 dataset_path, |
| 1311 outputTrackConfig, | 1338 outputTrackConfig, |
| 1312 bam_index=real_indexes, | 1339 bam_indexes=real_indexes, |
| 1313 ) | 1340 ) |
| 1314 elif dataset_ext == "cram": | 1341 elif dataset_ext == "cram": |
| 1315 real_indexes = track["conf"]["options"]["cram"]["cram_index"] | 1342 real_indexes = track["conf"]["options"]["cram"]["cram_index"] |
| 1343 logging.debug("**** add cram got %s for indexes" % real_indexes) | |
| 1316 self.add_cram( | 1344 self.add_cram( |
| 1317 dataset_path, | 1345 dataset_path, |
| 1318 outputTrackConfig, | 1346 outputTrackConfig, |
| 1319 cram_index=real_indexes, | 1347 cram_indexes=real_indexes, |
| 1320 ) | 1348 ) |
| 1321 elif dataset_ext == "blastxml": | 1349 elif dataset_ext == "blastxml": |
| 1322 self.add_blastxml( | 1350 self.add_blastxml( |
| 1323 dataset_path, | 1351 dataset_path, |
| 1324 outputTrackConfig, | 1352 outputTrackConfig, |
| 1353 session_json = config_json["defaultSession"] | 1381 session_json = config_json["defaultSession"] |
| 1354 session_views = [] | 1382 session_views = [] |
| 1355 else: | 1383 else: |
| 1356 session_json = {} | 1384 session_json = {} |
| 1357 session_views = [] | 1385 session_views = [] |
| 1358 for gnome in self.genome_names: | 1386 for gnome in self.assmeta.keys(): # assemblies have their own tracks |
| 1359 tracks_data = [] | 1387 tracks_data = [] |
| 1360 for track_conf in self.tracksToAdd[gnome]: | 1388 for track_conf in self.tracksToAdd[gnome]: |
| 1361 tId = track_conf["trackId"] | 1389 tId = track_conf["trackId"] |
| 1362 track_types[tId] = track_conf["type"] | 1390 if tId in default_data[gnome]["visibility"]["default_on"]: |
| 1363 style_data = default_data[gnome]["style"].get(tId, None) | 1391 track_types[tId] = track_conf["type"] |
| 1364 if not style_data: | 1392 style_data = default_data[gnome]["style"].get(tId, None) |
| 1365 logging.debug( | 1393 if not style_data: |
| 1366 "### No style data in default data %s for %s" | 1394 logging.debug( |
| 1367 % (default_data, tId) | 1395 "### No style data for %s in available default data %s" |
| 1396 % (tId, default_data) | |
| 1397 ) | |
| 1398 style_data = {"type": "LinearBasicDisplay"} | |
| 1399 if "displays" in track_conf: | |
| 1400 disp = track_conf["displays"][0]["type"] | |
| 1401 style_data["type"] = disp | |
| 1402 if track_conf.get("style_labels", None): | |
| 1403 # TODO fix this: it should probably go in a renderer block (SvgFeatureRenderer) but still does not work | |
| 1404 # TODO move this to per track displays? | |
| 1405 style_data["labels"] = track_conf["style_labels"] | |
| 1406 tracks_data.append( | |
| 1407 { | |
| 1408 "type": track_types[tId], | |
| 1409 "configuration": tId, | |
| 1410 "displays": [style_data], | |
| 1411 } | |
| 1368 ) | 1412 ) |
| 1369 style_data = {"type": "LinearBasicDisplay"} | 1413 view_json = { |
| 1370 if "displays" in track_conf: | 1414 "type": "LinearGenomeView", |
| 1371 disp = track_conf["displays"][0]["type"] | 1415 "offsetPx": 0, |
| 1372 style_data["type"] = disp | 1416 "minimized": False, |
| 1373 if track_conf.get("style_labels", None): | 1417 "tracks": tracks_data, |
| 1374 # TODO fix this: it should probably go in a renderer block (SvgFeatureRenderer) but still does not work | 1418 } |
| 1375 # TODO move this to per track displays? | 1419 logging.debug( |
| 1376 style_data["labels"] = track_conf["style_labels"] | 1420 "Looking for %s in self.ass_ %s" % (gnome, self.ass_first_contigs) |
| 1377 tracks_data.append( | 1421 ) |
| 1378 { | 1422 first = [x for x in self.ass_first_contigs if x[0] == gnome] |
| 1379 "type": track_types[tId], | 1423 if len(first) > 0: |
| 1380 "configuration": tId, | 1424 [gnome, refName, end] = first[0] |
| 1381 "displays": [style_data], | 1425 start = 0 |
| 1382 } | 1426 end = int(end) |
| 1427 drdict = { | |
| 1428 "refName": refName, | |
| 1429 "start": start, | |
| 1430 "end": end, | |
| 1431 "reversed": False, | |
| 1432 "assemblyName": gnome, | |
| 1433 } | |
| 1434 else: | |
| 1435 ddl = default_data.get("defaultLocation", None) | |
| 1436 if ddl: | |
| 1437 loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) | |
| 1438 # allow commas like 100,000 but ignore as integer | |
| 1439 if loc_match: | |
| 1440 refName = loc_match.group(1) | |
| 1441 drdict["refName"] = refName | |
| 1442 if loc_match.group(2) > "": | |
| 1443 drdict["start"] = int(loc_match.group(2).replace(",", "")) | |
| 1444 if loc_match.group(3) > "": | |
| 1445 drdict["end"] = int(loc_match.group(3).replace(",", "")) | |
| 1446 else: | |
| 1447 logging.info( | |
| 1448 "@@@ regexp could not match contig:start..end in the supplied location %s - please fix" | |
| 1449 % ddl | |
| 1450 ) | |
| 1451 if drdict.get("refName", None): | |
| 1452 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome | |
| 1453 view_json["displayedRegions"] = [ | |
| 1454 drdict, | |
| 1455 ] | |
| 1456 logging.info("@@@ defaultlocation %s for default session" % drdict) | |
| 1457 else: | |
| 1458 logging.info( | |
| 1459 "@@@ no track location for default session - please add one!" | |
| 1383 ) | 1460 ) |
| 1384 # paf genomes have no tracks associated so nothing for the view | 1461 session_views.append(view_json) |
| 1385 if len(tracks_data) > 0: | |
| 1386 view_json = { | |
| 1387 "type": "LinearGenomeView", | |
| 1388 "offsetPx": 0, | |
| 1389 "minimized": False, | |
| 1390 "tracks": tracks_data, | |
| 1391 } | |
| 1392 logging.debug( | |
| 1393 "Looking for %s in self.ass_ %s" % (gnome, self.ass_first_contigs) | |
| 1394 ) | |
| 1395 first = [x for x in self.ass_first_contigs if x[0] == gnome] | |
| 1396 if len(first) > 0: | |
| 1397 [gnome, refName, end] = first[0] | |
| 1398 start = 0 | |
| 1399 end = int(end) | |
| 1400 drdict = { | |
| 1401 "refName": refName, | |
| 1402 "start": start, | |
| 1403 "end": end, | |
| 1404 "reversed": False, | |
| 1405 "assemblyName": gnome, | |
| 1406 } | |
| 1407 else: | |
| 1408 ddl = default_data.get("defaultLocation", None) | |
| 1409 if ddl: | |
| 1410 loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) | |
| 1411 # allow commas like 100,000 but ignore as integer | |
| 1412 if loc_match: | |
| 1413 refName = loc_match.group(1) | |
| 1414 drdict["refName"] = refName | |
| 1415 if loc_match.group(2) > "": | |
| 1416 drdict["start"] = int( | |
| 1417 loc_match.group(2).replace(",", "") | |
| 1418 ) | |
| 1419 if loc_match.group(3) > "": | |
| 1420 drdict["end"] = int(loc_match.group(3).replace(",", "")) | |
| 1421 else: | |
| 1422 logging.info( | |
| 1423 "@@@ regexp could not match contig:start..end in the supplied location %s - please fix" | |
| 1424 % ddl | |
| 1425 ) | |
| 1426 if drdict.get("refName", None): | |
| 1427 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome | |
| 1428 view_json["displayedRegions"] = [ | |
| 1429 drdict, | |
| 1430 ] | |
| 1431 logging.info("@@@ defaultlocation %s for default session" % drdict) | |
| 1432 else: | |
| 1433 logging.info( | |
| 1434 "@@@ no track location for default session - please add one!" | |
| 1435 ) | |
| 1436 session_views.append(view_json) | |
| 1437 session_name = default_data.get("session_name", "New session") | 1462 session_name = default_data.get("session_name", "New session") |
| 1438 for key, value in mapped_chars.items(): | 1463 for key, value in mapped_chars.items(): |
| 1439 session_name = session_name.replace(value, key) | 1464 session_name = session_name.replace(value, key) |
| 1440 session_json["name"] = session_name | 1465 session_json["name"] = session_name |
| 1441 | 1466 |
| 1453 def add_defsess_to_index(self, data): | 1478 def add_defsess_to_index(self, data): |
| 1454 """ | 1479 """ |
| 1455 Included on request of the new codeowner, from Anthony's IUC PR. | 1480 Included on request of the new codeowner, from Anthony's IUC PR. |
| 1456 Had to be fixed to keep each assembly with the associated tracks for a default view. | 1481 Had to be fixed to keep each assembly with the associated tracks for a default view. |
| 1457 Originally used only the first assembly, putting all tracks there and so breaking some | 1482 Originally used only the first assembly, putting all tracks there and so breaking some |
| 1458 when tested with 2 or more. Seems ironic that this vital feature could not have ever been tested | 1483 when tested with 2 or more. |
| 1459 given that my declining to add it was the basis for a reviewer's rejection of my original IUC PR. | |
| 1460 A simple 2 line diff apparently. | |
| 1461 | |
| 1462 The technical problem is that this index.html hack breaks the promise of all the form fields | |
| 1463 for track controls such as visibility default that were working mostly. They need to be removed from the form by whoever | |
| 1464 thought this method was a good solution to the JB2 bug breaking config.json style default | |
| 1465 view coordinates. | |
| 1466 | |
| 1467 And no, dear reviewer of this code, please leave this piece of history. | |
| 1468 It is true and I prefer that it remain here to document my considerable discomfort at this unfair treatment. | |
| 1469 | 1484 |
| 1470 ---------------------------------------------------------- | 1485 ---------------------------------------------------------- |
| 1471 Add some default session settings: set some assemblies/tracks on/off | 1486 Add some default session settings: set some assemblies/tracks on/off |
| 1472 | 1487 |
| 1473 This allows to select a default view: | 1488 This allows to select a default view: |
| 1646 except KeyError: | 1661 except KeyError: |
| 1647 pass | 1662 pass |
| 1648 | 1663 |
| 1649 trackfiles = track.findall("files/trackFile") | 1664 trackfiles = track.findall("files/trackFile") |
| 1650 if trackfiles: | 1665 if trackfiles: |
| 1651 for x in track.findall("files/trackFile"): | 1666 for x in trackfiles: |
| 1652 track_conf["label"] = x.attrib["label"] | 1667 track_conf["label"] = x.attrib["label"] |
| 1653 track_conf["useuri"] = x.attrib["useuri"] | 1668 track_conf["useuri"] = x.attrib["useuri"] |
| 1654 if is_multi_bigwig: | 1669 if is_multi_bigwig: |
| 1655 multi_bigwig_paths.append( | 1670 multi_bigwig_paths.append( |
| 1656 ( | 1671 ( |
| 1696 ) | 1711 ) |
| 1697 | 1712 |
| 1698 track_conf["category"] = track.attrib["cat"] | 1713 track_conf["category"] = track.attrib["cat"] |
| 1699 track_conf["format"] = track.attrib["format"] | 1714 track_conf["format"] = track.attrib["format"] |
| 1700 track_conf["conf"] = etree_to_dict(track.find("options")) | 1715 track_conf["conf"] = etree_to_dict(track.find("options")) |
| 1701 track_conf["category"] = track.attrib["cat"] | |
| 1702 track_conf["format"] = track.attrib["format"] | |
| 1703 keys = jc.process_annotations(track_conf) | 1716 keys = jc.process_annotations(track_conf) |
| 1704 | 1717 |
| 1705 if keys: | 1718 if keys: |
| 1706 for key in keys: | 1719 for key in keys: |
| 1707 vis = track.attrib.get("visibility", "default_off") | 1720 vis = track.attrib.get("visibility", "default_off") |
| 1708 if not vis: | 1721 if not vis: |
| 1709 vis = "default_off" | 1722 vis = "default_off" |
| 1710 default_session_data[assref_name]["visibility"][vis].append(key) | 1723 default_session_data[assref_name]["visibility"][vis].append(key) |
| 1711 if track.find("options/style"): | 1724 trakdat = jc.tracksToAdd[assref_name] |
| 1712 default_session_data[assref_name]["style"][key] = { | 1725 stile = {} |
| 1713 item.tag: parse_style_conf(item) | 1726 for trak in trakdat: |
| 1714 for item in track.find("options/style") | 1727 if trak["trackId"] == key: |
| 1715 } | 1728 stile = trak.get("style", {}) |
| 1716 else: | 1729 if track.find("options/style"): |
| 1717 default_session_data[assref_name]["style"][key] = {} | 1730 supdate = { |
| 1718 logging.debug("no options/style found for %s" % (key)) | 1731 item.tag: parse_style_conf(item) |
| 1719 | 1732 for item in track.find("options/style") |
| 1720 if track.find("options/style_labels"): | 1733 } |
| 1721 default_session_data[assref_name]["style_labels"][key] = { | 1734 stile.update(supdate) |
| 1722 item.tag: parse_style_conf(item) | 1735 default_session_data[assref_name]["style"][key] = stile |
| 1723 for item in track.find("options/style_labels") | 1736 logging.debug("@@@ for %s got style=%s" % (key, stile)) |
| 1724 } | 1737 if track.find("options/style_labels"): |
| 1738 default_session_data[assref_name]["style_labels"][key] = { | |
| 1739 item.tag: parse_style_conf(item) | |
| 1740 for item in track.find("options/style_labels") | |
| 1741 } | |
| 1725 default_session_data[assref_name]["tracks"].append(key) | 1742 default_session_data[assref_name]["tracks"].append(key) |
| 1726 default_session_data["defaultLocation"] = root.find( | 1743 default_session_data["defaultLocation"] = root.find( |
| 1727 "metadata/general/defaultLocation" | 1744 "metadata/general/defaultLocation" |
| 1728 ).text | 1745 ).text |
| 1729 default_session_data["session_name"] = root.find( | 1746 default_session_data["session_name"] = root.find( |
