comparison jbrowse.py @ 41:8774b28235bb draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 8556ea066463f5e112b6ded2c1527011ab1e3b38"
author iuc
date Thu, 31 Dec 2020 16:00:42 +0000
parents 17359b808b01
children 87dc4ce42281
comparison
equal deleted inserted replaced
40:17359b808b01 41:8774b28235bb
398 return subprocess.check_output(command, cwd=self.outdir) 398 return subprocess.check_output(command, cwd=self.outdir)
399 399
400 def _jbrowse_bin(self, command): 400 def _jbrowse_bin(self, command):
401 return os.path.realpath(os.path.join(self.jbrowse, 'bin', command)) 401 return os.path.realpath(os.path.join(self.jbrowse, 'bin', command))
402 402
403 def symlink_or_copy(self, src, dest):
404 if 'GALAXY_JBROWSE_SYMLINKS' in os.environ and bool(os.environ['GALAXY_JBROWSE_SYMLINKS']):
405 cmd = ['ln', '-s', src, dest]
406 else:
407 cmd = ['cp', src, dest]
408
409 return self.subprocess_check_call(cmd)
410
403 def process_genomes(self): 411 def process_genomes(self):
404 for genome_node in self.genome_paths: 412 for genome_node in self.genome_paths:
405 # We only expect one input genome per run. This for loop is just 413 # We only expect one input genome per run. This for loop is just
406 # easier to write than the alternative / catches any possible 414 # easier to write than the alternative / catches any possible
407 # issues. 415 # issues.
505 if blastOpts.get('index', 'false') == 'true': 513 if blastOpts.get('index', 'false') == 'true':
506 self.tracksToIndex.append("%s" % trackData['label']) 514 self.tracksToIndex.append("%s" % trackData['label'])
507 515
508 def add_bigwig(self, data, trackData, wiggleOpts, **kwargs): 516 def add_bigwig(self, data, trackData, wiggleOpts, **kwargs):
509 dest = os.path.join('data', 'raw', trackData['label'] + '.bw') 517 dest = os.path.join('data', 'raw', trackData['label'] + '.bw')
510 cmd = ['cp', data, dest] 518 self.symlink_or_copy(os.path.realpath(data), dest)
511 self.subprocess_check_call(cmd)
512 519
513 url = os.path.join('raw', trackData['label'] + '.bw') 520 url = os.path.join('raw', trackData['label'] + '.bw')
514 trackData.update({ 521 trackData.update({
515 "urlTemplate": url, 522 "urlTemplate": url,
516 "storeClass": "JBrowse/Store/SeqFeature/BigWig", 523 "storeClass": "JBrowse/Store/SeqFeature/BigWig",
533 def add_bigwig_multiple(self, data, trackData, wiggleOpts, **kwargs): 540 def add_bigwig_multiple(self, data, trackData, wiggleOpts, **kwargs):
534 541
535 urls = [] 542 urls = []
536 for idx, bw in enumerate(data): 543 for idx, bw in enumerate(data):
537 dest = os.path.join('data', 'raw', trackData['label'] + '_' + str(idx) + '.bw') 544 dest = os.path.join('data', 'raw', trackData['label'] + '_' + str(idx) + '.bw')
538 cmd = ['ln', '-s', bw[1], dest] 545 self.symlink_or_copy(bw[1], dest)
539 self.subprocess_check_call(cmd)
540 546
541 urls.append({"url": os.path.join('raw', trackData['label'] + '_' + str(idx) + '.bw'), "name": str(idx + 1) + ' - ' + bw[0]}) 547 urls.append({"url": os.path.join('raw', trackData['label'] + '_' + str(idx) + '.bw'), "name": str(idx + 1) + ' - ' + bw[0]})
542 548
543 trackData.update({ 549 trackData.update({
544 "urlTemplates": urls, 550 "urlTemplates": urls,
596 602
597 self._add_track_json(trackData) 603 self._add_track_json(trackData)
598 604
599 def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs): 605 def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):
600 dest = os.path.join('data', 'raw', trackData['label'] + '.bam') 606 dest = os.path.join('data', 'raw', trackData['label'] + '.bam')
601 cmd = ['ln', '-s', os.path.realpath(data), dest] 607 self.symlink_or_copy(os.path.realpath(data), dest)
602 self.subprocess_check_call(cmd) 608 self.symlink_or_copy(os.path.realpath(bam_index), dest + '.bai')
603
604 cmd = ['ln', '-s', os.path.realpath(bam_index), dest + '.bai']
605 self.subprocess_check_call(cmd)
606 609
607 url = os.path.join('raw', trackData['label'] + '.bam') 610 url = os.path.join('raw', trackData['label'] + '.bam')
608 trackData.update({ 611 trackData.update({
609 "urlTemplate": url, 612 "urlTemplate": url,
610 "type": "JBrowse/View/Track/Alignments2", 613 "type": "JBrowse/View/Track/Alignments2",