Mercurial > repos > fubar > jbrowse2
comparison jbrowse2.py @ 35:15da358c3108 draft
planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 80b849766a962bac4bd0bb8cb69c118cc42699cd-dirty
author | fubar |
---|---|
date | Wed, 28 Feb 2024 10:08:57 +0000 |
parents | 2893ef33fba9 |
children | 7adde511daa1 |
comparison
equal
deleted
inserted
replaced
34:2893ef33fba9 | 35:15da358c3108 |
---|---|
1060 style_json = self._prepare_track_style(trackDict) | 1060 style_json = self._prepare_track_style(trackDict) |
1061 trackDict["style"] = style_json | 1061 trackDict["style"] = style_json |
1062 self.tracksToAdd.append(trackDict) | 1062 self.tracksToAdd.append(trackDict) |
1063 self.trackIdlist.append(tId) | 1063 self.trackIdlist.append(tId) |
1064 | 1064 |
1065 def add_hicab(self, data, trackData, hicOpts, **kwargs): | |
1066 rel_dest = os.path.join("data", trackData["label"] + ".hic") | |
1067 dest = os.path.join(self.outdir, rel_dest) | |
1068 | |
1069 self.symlink_or_copy(os.path.realpath(data), dest) | |
1070 | |
1071 self._add_track( | |
1072 trackData["label"], | |
1073 trackData["key"], | |
1074 trackData["category"], | |
1075 rel_dest, | |
1076 config={}, | |
1077 ) | |
1078 | |
1079 def add_sparql(self, url, query, query_refnames, trackData): | |
1080 | |
1081 json_track_data = { | |
1082 "type": "FeatureTrack", | |
1083 "trackId": id, | |
1084 "name": trackData["label"], | |
1085 "adapter": { | |
1086 "type": "SPARQLAdapter", | |
1087 "endpoint": {"uri": url, "locationType": "UriLocation"}, | |
1088 "queryTemplate": query, | |
1089 }, | |
1090 "category": [trackData["category"]], | |
1091 "assemblyNames": [self.genome_name], | |
1092 } | |
1093 | |
1094 if query_refnames: | |
1095 json_track_data["adapter"]["refNamesQueryTemplate"]: query_refnames | |
1096 | |
1097 self.subprocess_check_call( | |
1098 [ | |
1099 "jbrowse", | |
1100 "add-track-json", | |
1101 "--target", | |
1102 os.path.join(self.outdir, "data"), | |
1103 json_track_data, | |
1104 ] | |
1105 ) | |
1106 | |
1107 # Doesn't work as of 1.6.4, might work in the future | |
1108 # self.subprocess_check_call([ | |
1109 # 'jbrowse', 'add-track', | |
1110 # '--trackType', 'sparql', | |
1111 # '--name', trackData['label'], | |
1112 # '--category', trackData['category'], | |
1113 # '--target', os.path.join(self.outdir, 'data'), | |
1114 # '--trackId', id, | |
1115 # '--config', '{"queryTemplate": "%s"}' % query, | |
1116 # url]) | |
1117 | |
1118 def process_annotations(self, track): | 1065 def process_annotations(self, track): |
1119 category = track["category"].replace("__pd__date__pd__", TODAY) | 1066 category = track["category"].replace("__pd__date__pd__", TODAY) |
1120 for i, ( | 1067 for i, ( |
1121 dataset_path, | 1068 dataset_path, |
1122 dataset_ext, | 1069 dataset_ext, |
1188 self.add_bigwig( | 1135 self.add_bigwig( |
1189 dataset_path, | 1136 dataset_path, |
1190 outputTrackConfig, | 1137 outputTrackConfig, |
1191 ) | 1138 ) |
1192 elif dataset_ext == "bam": | 1139 elif dataset_ext == "bam": |
1193 real_indexes = track["conf"]["options"]["pileup"]["bam_indices"][ | 1140 real_indexes = track["conf"]["options"]["bam"]["bam_indices"][ |
1194 "bam_index" | 1141 "bam_index" |
1195 ] | 1142 ] |
1196 if not isinstance(real_indexes, list): | 1143 if not isinstance(real_indexes, list): |
1197 real_indexes = [real_indexes] | 1144 real_indexes = [real_indexes] |
1198 | 1145 |
1199 self.add_bam( | 1146 self.add_bam( |
1200 dataset_path, | 1147 dataset_path, |
1201 outputTrackConfig, | 1148 outputTrackConfig, |
1202 track["conf"]["options"]["pileup"], | 1149 track["conf"]["options"]["bam"], |
1203 bam_index=real_indexes[i], | 1150 bam_index=real_indexes[i], |
1204 ) | 1151 ) |
1205 elif dataset_ext == "cram": | 1152 elif dataset_ext == "cram": |
1206 real_indexes = track["conf"]["options"]["cram"]["cram_indices"][ | 1153 real_indexes = track["conf"]["options"]["cram"]["cram_indices"][ |
1207 "cram_index" | 1154 "cram_index" |
1473 x.attrib["ext"], | 1420 x.attrib["ext"], |
1474 x.attrib["label"], | 1421 x.attrib["label"], |
1475 metadata, | 1422 metadata, |
1476 ) | 1423 ) |
1477 ) | 1424 ) |
1478 else: | |
1479 # For tracks without files (rest, sparql) | |
1480 track_conf["trackfiles"].append( | |
1481 ( | |
1482 "", # N/A, no path for rest or sparql | |
1483 track.attrib["format"], | |
1484 track.find("options/label").text, | |
1485 {}, | |
1486 ) | |
1487 ) | |
1488 | 1425 |
1489 if is_multi_bigwig: | 1426 if is_multi_bigwig: |
1490 metadata = metadata_from_node(x.find("metadata")) | 1427 metadata = metadata_from_node(x.find("metadata")) |
1491 | 1428 |
1492 track_conf["trackfiles"].append( | 1429 track_conf["trackfiles"].append( |