comparison jbrowse2.py @ 72:2bdb748df098 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 9d5e563dde653450723415b0fccd2ebb4b82477e
author fubar
date Sat, 30 Mar 2024 22:33:29 +0000
parents e26a8a6d2d2e
children 3b2815efa5d9
comparison
equal deleted inserted replaced
71:e26a8a6d2d2e 72:2bdb748df098
1104 self.trackIdlist.append(tId) 1104 self.trackIdlist.append(tId)
1105 1105
1106 def add_paf(self, data, trackData, pafOpts, **kwargs): 1106 def add_paf(self, data, trackData, pafOpts, **kwargs):
1107 tname = trackData["name"] 1107 tname = trackData["name"]
1108 tId = trackData["label"] 1108 tId = trackData["label"]
1109 url = "%s.paf" % tId
1110 useuri = data.startswith("http://") or data.startswith("https://")
1111 if not useuri:
1112 dest = "%s/%s" % (self.outdir, url)
1113 self.symlink_or_copy(os.path.realpath(data), dest)
1114 else:
1115 url = data
1109 categ = trackData["category"] 1116 categ = trackData["category"]
1110 pgnames = [ 1117 pgnames = [
1111 x.strip() for x in pafOpts["genome_label"].split(",") if len(x.strip()) > 0 1118 x.strip() for x in pafOpts["genome_label"].split(",") if len(x.strip()) > 0
1112 ] 1119 ]
1113 pgpaths = [ 1120 pgpaths = [
1117 logging.debug( 1124 logging.debug(
1118 "### add_paf got pafOpts=%s, pgnames=%s, pgpaths=%s for %s" 1125 "### add_paf got pafOpts=%s, pgnames=%s, pgpaths=%s for %s"
1119 % (pafOpts, pgnames, pgpaths, tId) 1126 % (pafOpts, pgnames, pgpaths, tId)
1120 ) 1127 )
1121 for i, gname in enumerate(pgnames): 1128 for i, gname in enumerate(pgnames):
1122 lab = trackData["label"]
1123 if len(gname.split()) > 1: 1129 if len(gname.split()) > 1:
1124 gname = gname.split()[0] 1130 gname = gname.split()[0]
1125 passnames.append(gname) 1131 passnames.append(gname)
1126 # trouble from spacey names in command lines avoidance 1132 # trouble from spacey names in command lines avoidance
1127 useuri = pgpaths[i].startswith("http://") or pgpaths[i].startswith( 1133 useuri = pgpaths[i].startswith("http://") or pgpaths[i].startswith(
1128 "https://" 1134 "https://"
1129 ) 1135 )
1130 if not useuri: 1136
1131 url = "%s.paf" % (lab)
1132 else:
1133 url = data
1134 if gname not in self.genome_names: 1137 if gname not in self.genome_names:
1135 # ignore if already there - eg for duplicates among pafs. 1138 # ignore if already there - eg for duplicates among pafs.
1136 asstrack = self.make_assembly(pgpaths[i], gname, useuri) 1139 asstrack = self.make_assembly(pgpaths[i], gname, useuri)
1137 self.genome_names.append(gname) 1140 self.genome_names.append(gname)
1138 self.tracksToAdd[gname] = [] 1141 self.tracksToAdd[gname] = []
1139 self.assemblies.append(asstrack) 1142 self.assemblies.append(asstrack)
1140 if not useuri:
1141 dest = "%s/%s" % (self.outdir, url)
1142 self.symlink_or_copy(os.path.realpath(data), dest)
1143 trackDict = { 1143 trackDict = {
1144 "type": "SyntenyTrack", 1144 "type": "SyntenyTrack",
1145 "trackId": tId, 1145 "trackId": tId,
1146 "assemblyNames": passnames, 1146 "assemblyNames": passnames,
1147 "category": [ 1147 "category": [
1154 "assemblyNames": passnames, 1154 "assemblyNames": passnames,
1155 }, 1155 },
1156 "displays": [ 1156 "displays": [
1157 { 1157 {
1158 "type": "LGVSyntenyDisplay", 1158 "type": "LGVSyntenyDisplay",
1159 "displayId": "%s-LGVSyntenyDisplay" % lab, 1159 "displayId": "%s-LGVSyntenyDisplay" % tId,
1160 }, 1160 },
1161 {"type": "DotplotDisplay", "displayId": "%s-DotplotDisplay" % lab}, 1161 {
1162 "type": "DotplotDisplay",
1163 "displayId": "%s-DotplotDisplay" % tId,
1164 },
1162 { 1165 {
1163 "type": "LinearComparativeDisplay", 1166 "type": "LinearComparativeDisplay",
1164 "displayId": "%s-LinearComparativeDisplay" % lab, 1167 "displayId": "%s-LinearComparativeDisplay" % tId,
1165 }, 1168 },
1166 { 1169 {
1167 "type": "LinearSyntenyDisplay", 1170 "type": "LinearSyntenyDisplay",
1168 "displayId": "%s-LinearSyntenyDisplay" % lab, 1171 "displayId": "%s-LinearSyntenyDisplay" % tId,
1169 }, 1172 },
1170 ], 1173 ],
1171 } 1174 }
1172 style_json = { 1175 style_json = {
1173 "displays": [ 1176 "displays": [
1174 { 1177 {
1175 "type": "LGVSyntenyDisplay", 1178 "type": "LGVSyntenyDisplay",
1176 "displayId": "%s-LGVSyntenyDisplay" % lab, 1179 "displayId": "%s-LGVSyntenyDisplay" % tId,
1177 } 1180 }
1178 ] 1181 ]
1179 } 1182 }
1180 trackDict["style"] = style_json 1183 trackDict["style"] = style_json
1181 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) 1184 self.tracksToAdd[trackData["assemblyNames"]].append(trackDict)
1341 view_json = {"type": "LinearGenomeView", "tracks": tracks_data} 1344 view_json = {"type": "LinearGenomeView", "tracks": tracks_data}
1342 refName = self.assmeta[gnome][0].get("genome_firstcontig", None) 1345 refName = self.assmeta[gnome][0].get("genome_firstcontig", None)
1343 drdict = { 1346 drdict = {
1344 "reversed": False, 1347 "reversed": False,
1345 "assemblyName": gnome, 1348 "assemblyName": gnome,
1346 "start": 1, 1349 "start": 0,
1347 "end": 100000, 1350 "end": 100000,
1348 "refName": refName 1351 "refName": refName,
1349 } 1352 }
1350 ddl = default_data.get("defaultLocation", None) 1353 ddl = default_data.get("defaultLocation", None)
1351 if ddl: 1354 if ddl:
1352 loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) 1355 loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl)
1353 # allow commas like 100,000 but ignore as integer 1356 # allow commas like 100,000 but ignore as integer
1381 1384
1382 if "views" not in session_json: 1385 if "views" not in session_json:
1383 session_json["views"] = session_views 1386 session_json["views"] = session_views
1384 else: 1387 else:
1385 session_json["views"] += session_views 1388 session_json["views"] += session_views
1386 1389 pp = json.dumps(session_views, indent=2)
1387 config_json["defaultSession"] = session_json 1390 config_json["defaultSession"] = session_json
1388 self.config_json.update(config_json) 1391 self.config_json.update(config_json)
1389 1392 logging.debug("defaultSession=%s" % (pp))
1390 with open(self.config_json_file, "w") as config_file: 1393 with open(self.config_json_file, "w") as config_file:
1391 json.dump(self.config_json, config_file, indent=2) 1394 json.dump(self.config_json, config_file, indent=2)
1392 1395
1393 def add_general_configuration(self, data): 1396 def add_general_configuration(self, data):
1394 """ 1397 """