Mercurial > repos > fubar > jbrowse2
comparison autogenJB2.py @ 48:460d5b6c5d98 draft
planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 3a43e9e0ffce0966101203102e769d1ced28618a-dirty
author | fubar |
---|---|
date | Wed, 06 Mar 2024 10:37:49 +0000 |
parents | 4181e97c70a7 |
children | ae12977c0e5e |
comparison
equal
deleted
inserted
replaced
47:3e53204c2419 | 48:460d5b6c5d98 |
---|---|
88 "default_off": [], | 88 "default_off": [], |
89 }, | 89 }, |
90 "style": {}, | 90 "style": {}, |
91 "style_labels": {}, | 91 "style_labels": {}, |
92 } | 92 } |
93 | 93 track_conf = {} |
94 listtracks = trackList | 94 listtracks = trackList |
95 # foo.paf must have a foo_paf.fasta or fasta.gz to match | 95 # foo.paf must have a foo_paf.fasta or fasta.gz to match |
96 tnames = [x[2] for x in listtracks] | 96 tnames = [x[2] for x in listtracks] |
97 texts = [x[1] for x in listtracks] | 97 texts = [x[1] for x in listtracks] |
98 for i, track in enumerate(listtracks): | 98 for i, track in enumerate(listtracks): |
99 tpath, trext, trackname = track[:3] | 99 tpath, trext, trackname = track[:3] |
100 track_conf["dataset_id"] = trackname | |
100 if trext == "paf": | 101 if trext == "paf": |
101 refname = trackname + "_paf.fasta" | 102 refname = trackname + "_paf.fasta" |
102 refdat = [x[2] for x in listtracks if x[2] == refname] | 103 refdat = [x[2] for x in listtracks if x[2] == refname] |
103 if not refdat: | 104 if not refdat: |
104 jc.logging.warn( | 105 jc.logging.warn( |
105 "!! No reference file %s corresponding to paf file %s found. Not building - there must be a corresponding fasta for each paf" | 106 "!! No reference file %s corresponding to paf file %s found. Not building - there must be a corresponding fasta for each paf" |
106 % (refname, trackname) | 107 % (refname, trackname) |
107 ) | 108 ) |
108 sys.exit(3) | 109 sys.exit(3) |
109 else: | 110 else: |
110 track_conf = { | 111 track_conf.update({ |
111 "conf": { | 112 "conf": { |
112 "options": { | 113 "options": { |
113 "paf": {"genome": refdat, "genome_label": trackname} | 114 "paf": {"genome": refdat, "genome_label": trackname} |
114 } | 115 } |
115 } | 116 } |
116 } | 117 }) |
117 elif trext == "bam": | 118 elif trext == "bam": |
118 ipath = track[3] | 119 ipath = track[3] |
119 if not os.path.exists(ipath): | 120 if not os.path.exists(ipath): |
120 ipath = os.path.realpath(os.path.join(jc.outdir, trackname + '.bai')) | 121 ipath = os.path.realpath(os.path.join(jc.outdir, trackname + '.bai')) |
121 cmd = ["samtools", "index", "-b", "-o", ipath, os.path.realpath(track[0])] | 122 cmd = ["samtools", "index", "-b", "-o", ipath, os.path.realpath(track[0])] |
122 sys.stdout.write('#### calling %s' % ' '.join(cmd)) | 123 sys.stdout.write('#### calling %s' % ' '.join(cmd)) |
123 jc.subprocess_check_call(cmd) | 124 jc.subprocess_check_call(cmd) |
124 track_conf = {"conf": {"options": {"bam": {"bam_index": ipath}}}} | 125 track_conf.update({"conf": {"options": {"bam": {"bam_index": ipath}}}}) |
125 elif trext == "cram": | 126 elif trext == "cram": |
126 ipath = track[3] | 127 ipath = track[3] |
127 if not os.path.exists(ipath): | 128 if not os.path.exists(ipath): |
128 jc.logging.info('calling %s' % ' '.join(cmd)) | 129 jc.logging.info('calling %s' % ' '.join(cmd)) |
129 ipath = os.path.realpath(os.path.join('./', trackname + '.crai')) | 130 ipath = os.path.realpath(os.path.join('./', trackname + '.crai')) |
130 cmd = ["samtools", "index", "-c", "-o", ipath, os.path.realpath(track[0])] | 131 cmd = ["samtools", "index", "-c", "-o", ipath, os.path.realpath(track[0])] |
131 sys.stdout.write('#### calling %s' % ' '.join(cmd)) | 132 sys.stdout.write('#### calling %s' % ' '.join(cmd)) |
132 jc.subprocess_check_call(cmd) | 133 jc.subprocess_check_call(cmd) |
133 track_conf = {"conf": {"options": {"cram": {"cram_index": ipath}}}} | 134 track_conf.update({"conf": {"options": {"cram": {"cram_index": ipath}}}}) |
134 else: | 135 track_conf["path"] = tpath |
135 track_conf = {} | |
136 track_conf["format"] = trext | 136 track_conf["format"] = trext |
137 track_conf["name"] = trackname | 137 track_conf["name"] = trackname |
138 track_conf["label"] = trackname | 138 track_conf["label"] = trackname |
139 useu = tpath.startswith('http://') or tpath.startswith('https://') | 139 useu = tpath.startswith('http://') or tpath.startswith('https://') |
140 useuri = 'no' | 140 useuri = 'no' |
141 if useu: | 141 if useu: |
142 useuri = 'yes' | 142 useuri = 'yes' |
143 track_conf["trackfiles"] = [ | 143 track_conf["trackfiles"] = [ |
144 (tpath, trext, useuri, trackname, {}), | 144 (tpath, trext, useuri, trackname, {}), |
145 ] | 145 ] |
146 track_conf["category"] = "Autogenerated" | 146 track_conf["category"] = "Autogenerated" |
147 keys = jc.process_annotations(track_conf) | 147 keys = jc.process_annotations(track_conf) |
148 | 148 |
149 if keys: | 149 if keys: |
150 for key in keys: | 150 for key in keys: |