Mercurial > repos > fubar > jbrowse2
comparison jbrowse2.py @ 68:c4eb6a85db70 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit bd958a96352bf8dbd1fdb5a2e994d57a42446f33-dirty
author | fubar |
---|---|
date | Fri, 29 Mar 2024 07:27:20 +0000 |
parents | c81902830900 |
children | 7230a2422507 |
comparison
equal
deleted
inserted
replaced
67:cefe9dbf1d80 | 68:c4eb6a85db70 |
---|---|
501 ) | 501 ) |
502 assmeta.append(this_genome) | 502 assmeta.append(this_genome) |
503 self.assemblies += assembly | 503 self.assemblies += assembly |
504 self.assmeta[genome_names[0]] = assmeta | 504 self.assmeta[genome_names[0]] = assmeta |
505 self.tracksToAdd[genome_names[0]] = [] | 505 self.tracksToAdd[genome_names[0]] = [] |
506 if self.config_json.get("assemblies", None): | |
507 self.config_json["assemblies"] += assembly | |
508 else: | |
509 self.config_json["assemblies"] = assembly | |
510 self.genome_names += genome_names | 506 self.genome_names += genome_names |
511 return this_genome["genome_name"] | 507 return this_genome["genome_name"] |
512 | 508 |
513 def make_assembly(self, fapath, gname, useuri): | 509 def make_assembly(self, fapath, gname, useuri): |
514 if useuri: | 510 if useuri: |
1122 logging.debug( | 1118 logging.debug( |
1123 "### add_paf got pafOpts=%s, pgnames=%s, pgpaths=%s for %s" | 1119 "### add_paf got pafOpts=%s, pgnames=%s, pgpaths=%s for %s" |
1124 % (pafOpts, pgnames, pgpaths, tId) | 1120 % (pafOpts, pgnames, pgpaths, tId) |
1125 ) | 1121 ) |
1126 for i, gname in enumerate(pgnames): | 1122 for i, gname in enumerate(pgnames): |
1123 lab = trackData["label"] | |
1127 if len(gname.split()) > 1: | 1124 if len(gname.split()) > 1: |
1128 gname = gname.split()[0] | 1125 gname = gname.split()[0] |
1129 passnames.append(gname) | 1126 passnames.append(gname) |
1130 # trouble from spacey names in command lines avoidance | 1127 # trouble from spacey names in command lines avoidance |
1131 if gname not in self.genome_names: | 1128 if gname not in self.genome_names: |
1133 useuri = pgpaths[i].startswith("http://") or pgpaths[i].startswith( | 1130 useuri = pgpaths[i].startswith("http://") or pgpaths[i].startswith( |
1134 "https://" | 1131 "https://" |
1135 ) | 1132 ) |
1136 asstrack = self.make_assembly(pgpaths[i], gname, useuri) | 1133 asstrack = self.make_assembly(pgpaths[i], gname, useuri) |
1137 self.genome_names.append(gname) | 1134 self.genome_names.append(gname) |
1138 if self.config_json.get("assemblies", None): | 1135 self.tracksToAdd[gname] = [] |
1139 self.config_json["assemblies"].append(asstrack) | 1136 self.assemblies.append(asstrack) |
1137 if not useuri: | |
1138 url = "%s.paf" % (lab) | |
1139 dest = "%s/%s" % (self.outdir, url) | |
1140 self.symlink_or_copy(os.path.realpath(data), dest) | |
1140 else: | 1141 else: |
1141 self.config_json["assemblies"] = [ | 1142 url = data |
1142 asstrack, | |
1143 ] | |
1144 lab = trackData["label"] | |
1145 url = "%s.paf" % (lab) | |
1146 dest = "%s/%s" % (self.outdir, url) | |
1147 self.symlink_or_copy(os.path.realpath(data), dest) | |
1148 trackDict = { | 1143 trackDict = { |
1149 "type": "SyntenyTrack", | 1144 "type": "SyntenyTrack", |
1150 "trackId": tId, | 1145 "trackId": tId, |
1151 "assemblyNames": passnames, | 1146 "assemblyNames": passnames, |
1152 "category": [ | 1147 "category": [ |
1157 "type": "PAFAdapter", | 1152 "type": "PAFAdapter", |
1158 "pafLocation": {"uri": url}, | 1153 "pafLocation": {"uri": url}, |
1159 "assemblyNames": passnames, | 1154 "assemblyNames": passnames, |
1160 }, | 1155 }, |
1161 "displays": [ | 1156 "displays": [ |
1157 { | |
1158 "type": "LGVSyntenyDisplay", | |
1159 "displayId": "%s-LGVSyntenyDisplay" % lab, | |
1160 }, | |
1162 {"type": "DotplotDisplay", "displayId": "%s-DotplotDisplay" % lab}, | 1161 {"type": "DotplotDisplay", "displayId": "%s-DotplotDisplay" % lab}, |
1163 { | 1162 { |
1164 "type": "LinearComparativeDisplay", | 1163 "type": "LinearComparativeDisplay", |
1165 "displayId": "%s-LinearComparativeDisplay" % lab, | 1164 "displayId": "%s-LinearComparativeDisplay" % lab, |
1166 }, | 1165 }, |
1167 { | 1166 { |
1168 "type": "LinearSyntenyDisplay", | 1167 "type": "LinearSyntenyDisplay", |
1169 "displayId": "%s-LinearSyntenyDisplay" % lab, | 1168 "displayId": "%s-LinearSyntenyDisplay" % lab, |
1170 }, | |
1171 { | |
1172 "type": "LGVSyntenyDisplay", | |
1173 "displayId": "%s-LGVSyntenyDisplay" % lab, | |
1174 }, | 1169 }, |
1175 ], | 1170 ], |
1176 } | 1171 } |
1177 style_json = { | 1172 style_json = { |
1178 "displays": [ | 1173 "displays": [ |
1179 { | 1174 { |
1180 "type": "SyntenyDisplay", | 1175 "type": "LGVSyntenyDisplay", |
1181 "displayId": "%s-SyntenyDisplay" % lab, | 1176 "displayId": "%s-LGVSyntenyDisplay" % lab, |
1182 } | 1177 } |
1183 ] | 1178 ] |
1184 } | 1179 } |
1185 trackDict["style"] = style_json | 1180 trackDict["style"] = style_json |
1186 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) | 1181 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) |
1339 "type": track_types[tId], | 1334 "type": track_types[tId], |
1340 "configuration": tId, | 1335 "configuration": tId, |
1341 "displays": [style_data], | 1336 "displays": [style_data], |
1342 } | 1337 } |
1343 ) | 1338 ) |
1344 # The view for the assembly we're adding | 1339 # paf genomes have no tracks associated so nothing for the view |
1345 view_json = {"type": "LinearGenomeView", "tracks": tracks_data} | 1340 if len(tracks_data) > 0: |
1346 refName = self.assmeta[gnome][0].get("genome_firstcontig", None) | 1341 view_json = {"type": "LinearGenomeView", "tracks": tracks_data} |
1347 drdict = { | 1342 refName = self.assmeta[gnome][0].get("genome_firstcontig", None) |
1348 "reversed": False, | 1343 drdict = { |
1349 "assemblyName": gnome, | 1344 "reversed": False, |
1350 "start": 1, | 1345 "assemblyName": gnome, |
1351 "end": 100000, | 1346 "start": 1, |
1352 "refName": refName | 1347 "end": 100000, |
1353 } | 1348 "refName": refName |
1354 ddl = default_data.get("defaultLocation", None) | 1349 } |
1355 if ddl: | 1350 ddl = default_data.get("defaultLocation", None) |
1356 loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) | 1351 if ddl: |
1357 # allow commas like 100,000 but ignore as integer | 1352 loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) |
1358 if loc_match: | 1353 # allow commas like 100,000 but ignore as integer |
1359 refName = loc_match.group(1) | 1354 if loc_match: |
1360 drdict["refName"] = refName | 1355 refName = loc_match.group(1) |
1361 if loc_match.group(2) > "": | 1356 drdict["refName"] = refName |
1362 drdict["start"] = int(loc_match.group(2).replace(",", "")) | 1357 if loc_match.group(2) > "": |
1363 if loc_match.group(3) > "": | 1358 drdict["start"] = int(loc_match.group(2).replace(",", "")) |
1364 drdict["end"] = int(loc_match.group(3).replace(",", "")) | 1359 if loc_match.group(3) > "": |
1360 drdict["end"] = int(loc_match.group(3).replace(",", "")) | |
1361 else: | |
1362 logging.info( | |
1363 "@@@ regexp could not match contig:start..end in the supplied location %s - please fix" | |
1364 % ddl | |
1365 ) | |
1366 if drdict.get("refName", None): | |
1367 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome | |
1368 view_json["displayedRegions"] = [ | |
1369 drdict, | |
1370 ] | |
1371 logging.info("@@@ defaultlocation %s for default session" % drdict) | |
1365 else: | 1372 else: |
1366 logging.info( | 1373 logging.info( |
1367 "@@@ regexp could not match contig:start..end in the supplied location %s - please fix" | 1374 "@@@ no contig name found for default session - please add one!" |
1368 % ddl | |
1369 ) | 1375 ) |
1370 if drdict.get("refName", None): | 1376 session_views.append(view_json) |
1371 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome | |
1372 view_json["displayedRegions"] = [ | |
1373 drdict, | |
1374 ] | |
1375 logging.info("@@@ defaultlocation %s for default session" % drdict) | |
1376 else: | |
1377 logging.info( | |
1378 "@@@ no contig name found for default session - please add one!" | |
1379 ) | |
1380 session_views.append(view_json) | |
1381 session_name = default_data.get("session_name", "New session") | 1377 session_name = default_data.get("session_name", "New session") |
1382 for key, value in mapped_chars.items(): | 1378 for key, value in mapped_chars.items(): |
1383 session_name = session_name.replace(value, key) | 1379 session_name = session_name.replace(value, key) |
1384 session_json["name"] = session_name | 1380 session_json["name"] = session_name |
1385 | 1381 |
1609 "quaternary_color": root.find("metadata/general/quaternary_color").text, | 1605 "quaternary_color": root.find("metadata/general/quaternary_color").text, |
1610 "font_size": root.find("metadata/general/font_size").text, | 1606 "font_size": root.find("metadata/general/font_size").text, |
1611 } | 1607 } |
1612 jc.add_general_configuration(general_data) | 1608 jc.add_general_configuration(general_data) |
1613 trackconf = jc.config_json.get("tracks", []) | 1609 trackconf = jc.config_json.get("tracks", []) |
1610 logging.warn("genome_names=%s" % jc.genome_names) | |
1614 for gnome in jc.genome_names: | 1611 for gnome in jc.genome_names: |
1615 trackconf += jc.tracksToAdd[gnome] | 1612 trackconf += jc.tracksToAdd[gnome] |
1616 jc.config_json["tracks"] = trackconf | 1613 jc.config_json["tracks"] = trackconf |
1614 assconf = jc.config_json.get("assemblies", []) | |
1615 assconf += jc.assemblies | |
1616 jc.config_json["assemblies"] = assconf | |
1617 jc.write_config() | 1617 jc.write_config() |
1618 jc.add_default_session(default_session_data) | 1618 jc.add_default_session(default_session_data) |
1619 # jc.text_index() not sure what broke here. | 1619 # jc.text_index() not sure what broke here. |