Mercurial > repos > artbio > rsem
comparison rsem.py @ 1:49795544dac7 draft
planemo upload for repository https://github.com/artbio/tools-artbio/tree/master/tools/rsem commit 62e8088d5f73cbb9b2f93e23a74636c77a06b492
author | artbio |
---|---|
date | Sun, 01 Apr 2018 18:28:24 -0400 |
parents | e5e836936d60 |
children | e00a79cf5f8c |
comparison
equal
deleted
inserted
replaced
0:e5e836936d60 | 1:49795544dac7 |
---|---|
170 for i, fname in enumerate(flist): | 170 for i, fname in enumerate(flist): |
171 if fname.endswith('.grp'): | 171 if fname.endswith('.grp'): |
172 dataset.metadata.reference_name = fname[:-4] | 172 dataset.metadata.reference_name = fname[:-4] |
173 break | 173 break |
174 self.regenerate_primary_file(dataset) | 174 self.regenerate_primary_file(dataset) |
175 | |
176 | |
177 class RsemBt2Reference(Html): | |
178 """Class describing an RSEM reference""" | |
179 MetadataElement(name='reference_name', default='rsem_bt2_ref', | |
180 desc='RSEM Bowtie2 Reference Name', readonly=True, | |
181 visible=True, set_in_upload=True, no_value='rsem_bt2_ref') | |
182 file_ext = 'rsem_bt2_ref' | |
183 allow_datatype_change = False | |
184 composite_type = 'auto_primary_file' | |
185 | |
186 def __init__(self, **kwd): | |
187 Html.__init__(self, **kwd) | |
188 """ | |
189 Expecting files: | |
190 extra_files_path/<reference_name>.grp | |
191 extra_files_path/<reference_name>.ti | |
192 extra_files_path/<reference_name>.seq | |
193 extra_files_path/<reference_name>.transcripts.fa | |
194 Optionally includes files: | |
195 extra_files_path/<reference_name>.chrlist | |
196 extra_files_path/<reference_name>.idx.fa | |
197 extra_files_path/<reference_name>.n2g.idx.fa | |
198 extra_files_path/<reference_name>.1.bt2 | |
199 extra_files_path/<reference_name>.2.bt2 | |
200 extra_files_path/<reference_name>.3.bt2 | |
201 extra_files_path/<reference_name>.4.bt2 | |
202 extra_files_path/<reference_name>.rev.1.bt2 | |
203 extra_files_path/<reference_name>.rev.2.bt2 | |
204 """ | |
205 self.add_composite_file('%s.grp', description='Group File', | |
206 substitute_name_with_metadata='reference_name', | |
207 is_binary=False) | |
208 self.add_composite_file('%s.ti', description='', | |
209 substitute_name_with_metadata='reference_name', | |
210 is_binary=False) | |
211 self.add_composite_file('%s.seq', description='', | |
212 substitute_name_with_metadata='reference_name', | |
213 is_binary=False) | |
214 self.add_composite_file('%s.transcripts.fa', description='', | |
215 substitute_name_with_metadata='reference_name', | |
216 is_binary=False) | |
217 self.add_composite_file('%s.chrlist', description='', | |
218 substitute_name_with_metadata='reference_name', | |
219 is_binary=False, optional=True) | |
220 self.add_composite_file('%s.idx.fa', description='', | |
221 substitute_name_with_metadata='reference_name', | |
222 is_binary=False, optional=True) | |
223 self.add_composite_file('%s.n2g.idx.fa', description='', | |
224 substitute_name_with_metadata='reference_name', | |
225 is_binary=False, optional=True) | |
226 self.add_composite_file('%s.1.bt2', description='', | |
227 substitute_name_with_metadata='reference_name', | |
228 is_binary=True, optional=True) | |
229 self.add_composite_file('%s.2.bt2', description='', | |
230 substitute_name_with_metadata='reference_name', | |
231 is_binary=True, optional=True) | |
232 self.add_composite_file('%s.3.bt2', description='', | |
233 substitute_name_with_metadata='reference_name', | |
234 is_binary=True, optional=True) | |
235 self.add_composite_file('%s.4.bt2', description='', | |
236 substitute_name_with_metadata='reference_name', | |
237 is_binary=True, optional=True) | |
238 self.add_composite_file('%s.rev.1.bt2', description='', | |
239 substitute_name_with_metadata='reference_name', | |
240 is_binary=True, optional=True) | |
241 self.add_composite_file('%s.rev.2.bt2', description='', | |
242 substitute_name_with_metadata='reference_name', | |
243 is_binary=True, optional=True) | |
244 | |
245 def generate_primary_file(self, dataset=None): | |
246 """ | |
247 This is called only at upload to write the file | |
248 cannot rename the datasets here - they come with | |
249 the default unfortunately | |
250 """ | |
251 | |
252 def regenerate_primary_file(self, dataset): | |
253 """ | |
254 cannot do this until we are setting metadata | |
255 """ | |
256 link_to_exts = ['.grp', '.ti', '.seq', '.fa', '.chrlist', '.log'] | |
257 ref_name = dataset.metadata.reference_name | |
258 efp = dataset.extra_files_path | |
259 flist = os.listdir(efp) | |
260 rval = ['<html><head><title>%s</title></head><body><p/>RSEM \ | |
261 Reference %s files:<p/><ul>' % (dataset.name, ref_name)] | |
262 rvalb = [] | |
263 for i, fname in enumerate(flist): | |
264 sfname = os.path.split(fname)[-1] | |
265 f, e = os.path.splitext(fname) | |
266 if e in link_to_exts: | |
267 rval.append('<li><a href="%s">%s</a></li>' % (sfname, sfname)) | |
268 else: | |
269 rvalb.append('<li>%s</li>' % (sfname)) | |
270 if len(rvalb) > 0: | |
271 rval += rvalb | |
272 rval.append('</ul></body></html>') | |
273 fh = file(dataset.file_name, 'w') | |
274 fh.write("\n".join(rval)) | |
275 fh.write('\n') | |
276 fh.close() | |
277 | |
278 def set_meta(self, dataset, **kwd): | |
279 Html.set_meta(self, dataset, **kwd) | |
280 efp = dataset.extra_files_path | |
281 flist = os.listdir(efp) | |
282 for i, fname in enumerate(flist): | |
283 if fname.endswith('.grp'): | |
284 dataset.metadata.reference_name = fname[:-4] | |
285 break | |
286 self.regenerate_primary_file(dataset) |