Mercurial > repos > fubar > jbrowse2
comparison autogenJB2.py @ 67:cefe9dbf1d80 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 6dac6d6debf44c68eae2785e926fb8420f76958e-dirty
author | fubar |
---|---|
date | Thu, 28 Mar 2024 12:17:24 +0000 |
parents | bc10ad1dfb98 |
children | 7230a2422507 |
comparison
equal
deleted
inserted
replaced
66:bc10ad1dfb98 | 67:cefe9dbf1d80 |
---|---|
3 import os | 3 import os |
4 import sys | 4 import sys |
5 | 5 |
6 from jbrowse2 import JbrowseConnector as jbC | 6 from jbrowse2 import JbrowseConnector as jbC |
7 | 7 |
8 logging.basicConfig(level=logging.debug) | 8 |
9 logging.basicConfig(level=logging.DEBUG) | |
9 log = logging.getLogger("jbrowse") | 10 log = logging.getLogger("jbrowse") |
10 | |
11 | 11 |
12 if __name__ == "__main__": | 12 if __name__ == "__main__": |
13 parser = argparse.ArgumentParser(description="", epilog="") | 13 parser = argparse.ArgumentParser(description="", epilog="") |
14 parser.add_argument("--sessName", help="Session name", default="AutoJBrowse") | 14 parser.add_argument("--sessName", help="Session name", default="AutoJBrowse") |
15 parser.add_argument( | 15 parser.add_argument( |
60 guseuri.append("no") | 60 guseuri.append("no") |
61 jc = jbC( | 61 jc = jbC( |
62 outdir=args.outdir, | 62 outdir=args.outdir, |
63 jbrowse2path=args.jbrowse2path, | 63 jbrowse2path=args.jbrowse2path, |
64 ) | 64 ) |
65 genomes=[ | 65 genomes = ( |
66 [ | |
66 { | 67 { |
67 "path": x, | 68 "path": x, |
68 "label": genome_names[i], | 69 "label": genome_names[i], |
69 "useuri": guseuri[i], | 70 "useuri": guseuri[i], |
70 "meta": { | 71 "meta": { |
72 "dataset_dname": genome_names[i], | 73 "dataset_dname": genome_names[i], |
73 }, | 74 }, |
74 } | 75 } |
75 for i, x in enumerate(genome_paths) | 76 for i, x in enumerate(genome_paths) |
76 ], | 77 ], |
78 ) | |
77 logging.warn("#!!! paths=%s, genomes=%s" % (genome_paths, genomes)) | 79 logging.warn("#!!! paths=%s, genomes=%s" % (genome_paths, genomes)) |
78 assref_name = jc.process_genomes(genomes[0]) | 80 assref_name = jc.process_genomes(genomes[0]) |
79 default_session_data = { | 81 default_session_data = { |
80 "visibility": { | 82 "visibility": { |
81 "default_on": [], | 83 "default_on": [], |
87 listtracks = trackList | 89 listtracks = trackList |
88 # foo.paf must have a foo_paf.fasta or fasta.gz to match | 90 # foo.paf must have a foo_paf.fasta or fasta.gz to match |
89 tnames = [x[2] for x in listtracks] | 91 tnames = [x[2] for x in listtracks] |
90 texts = [x[1] for x in listtracks] | 92 texts = [x[1] for x in listtracks] |
91 for i, track in enumerate(listtracks): | 93 for i, track in enumerate(listtracks): |
92 track_conf = {"trackfiles": [], "category": "autogenerated", "assemblyNames": assref_name} | 94 track_conf = { |
95 "trackfiles": [], | |
96 "category": "autogenerated", | |
97 "assemblyNames": assref_name, | |
98 } | |
93 tpath, trext, trackname = track[:3] | 99 tpath, trext, trackname = track[:3] |
94 track_conf["dataset_id"] = trackname | 100 track_conf["dataset_id"] = trackname |
95 useuri = "no" | 101 useuri = "no" |
96 if tpath.startswith("http://") or tpath.startswith("https://"): | 102 if tpath.startswith("http://") or tpath.startswith("https://"): |
97 useuri = "yes" | 103 useuri = "yes" |
163 | 169 |
164 if keys: | 170 if keys: |
165 for key in keys: | 171 for key in keys: |
166 if trext in [ | 172 if trext in [ |
167 "bigwig", | 173 "bigwig", |
168 "gff", "gff3", | 174 "gff", |
175 "gff3", | |
169 "vcf", | 176 "vcf", |
170 "maf", | 177 "maf", |
171 ]: | 178 ]: |
172 default_session_data["visibility"]["default_on"].append(key) | 179 default_session_data["visibility"]["default_on"].append(key) |
173 else: | 180 else: |
177 if trext in ["gff", "gff3", "bed", "vcf", "maf", "blastxml"]: | 184 if trext in ["gff", "gff3", "bed", "vcf", "maf", "blastxml"]: |
178 ttype = "LinearBasicDisplay" | 185 ttype = "LinearBasicDisplay" |
179 if trext == "vcf": | 186 if trext == "vcf": |
180 ttype = "LinearVariantDisplay" | 187 ttype = "LinearVariantDisplay" |
181 style_json = { | 188 style_json = { |
182 "type": ttype, | 189 "type": ttype, |
183 "trackShowLabels": False, | 190 "trackShowLabels": False, |
184 "trackShowDescriptions": False | 191 "trackShowDescriptions": False, |
185 } | 192 } |
186 default_session_data["style"][key] = style_json | 193 default_session_data["style"][key] = style_json |
187 # general_data = { | 194 # general_data = { |
188 # "analytics": root.find("metadata/general/analytics").text, | 195 # "analytics": root.find("metadata/general/analytics").text, |
189 # "primary_color": root.find("metadata/general/primary_color").text, | 196 # "primary_color": root.find("metadata/general/primary_color").text, |
194 # } | 201 # } |
195 jc.add_general_configuration({}) | 202 jc.add_general_configuration({}) |
196 trackconf = jc.config_json.get("tracks", []) | 203 trackconf = jc.config_json.get("tracks", []) |
197 for gnome in jc.genome_names: | 204 for gnome in jc.genome_names: |
198 trackconf += jc.tracksToAdd[gnome] | 205 trackconf += jc.tracksToAdd[gnome] |
206 logging.warn( | |
207 "^^%% adding trackconf=%s for gnome %s" % (trackconf, gnome) | |
208 ) | |
199 jc.config_json["tracks"] = trackconf | 209 jc.config_json["tracks"] = trackconf |
200 jc.write_config() | 210 jc.write_config() |
201 default_session_data.update( | 211 default_session_data.update({"session_name": sessName}) |
202 {"session_name": sessName} | |
203 ) | |
204 track_conf.update(default_session_data) | 212 track_conf.update(default_session_data) |
205 jc.add_default_session(default_session_data) | 213 jc.add_default_session(default_session_data) |
206 # jc.text_index() not sure what broke here. | 214 # jc.text_index() not sure what broke here. |
207 else: | 215 else: |
208 sys.stderr.write( | 216 sys.stderr.write( |
209 "!!!! Collection has no suitable trackfiles for autogenJB2 - nothing to process" | 217 "!!!! Collection has no suitable trackfiles for autogenJB2 - nothing to process" |
210 ) | 218 ) |
211 |