annotate TrackHub.py @ 48:6803152ea92a draft

planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 073c8ceda5eddfb4ccd07cfa96a8353e5535ffaf-dirty
author yating-l
date Tue, 28 Mar 2017 18:13:27 -0400
parents 15b4a74722d1
children 193e94a43f0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
1 #!/usr/bin/env python
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
2
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
3 import os
31
d8049deb0c97 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents: 26
diff changeset
4 import subprocess
d8049deb0c97 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents: 26
diff changeset
5 import shutil
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
6 import utils
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
7
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
8
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
9 class TrackHub:
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
10 def __init__(self, inputFiles, reference, outputDirect, tool_dir, genome, extra_files_path, metaData):
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
11 self.input_files = inputFiles.tracks
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
12 self.outfile = outputDirect
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
13 self.outfolder = extra_files_path
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
14 self.out_path = os.path.join(extra_files_path, genome)
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
15 self.reference = reference
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
16 self.tool_dir = tool_dir
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
17 self.metaData = metaData
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
18 self.raw = os.path.join(self.out_path, 'raw')
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
19 self.json = os.path.join(self.out_path, 'json')
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
20 try:
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
21 if os.path.exists(self.json):
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
22 shutil.rmtree(self.json)
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
23 os.makedirs(self.json)
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
24 except OSError as e:
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
25 print "Cannot create json folder error({0}): {1}".format(e.errno, e.strerror)
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
26 else:
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
27 print "Create jbrowse folder {}".format(self.out_path)
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
28
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
29 def createHub(self):
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
30 self.prepareRefseq()
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
31 for input_file in self.input_files:
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
32 self.addTrack(input_file)
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
33 self.indexName()
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
34 self.makeArchive()
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
35 self.outHtml()
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
36 print "Success!\n"
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
37
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
38 def prepareRefseq(self):
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
39 try:
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
40 #print os.path.join(self.tool_dir, 'prepare-refseqs.pl') + ", '--fasta', " + self.reference +", '--out', self.json])"
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
41 p = subprocess.Popen(['prepare-refseqs.pl', '--fasta', self.reference, '--out', self.json])
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
42 # Wait for process to terminate.
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
43 p.communicate()
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
44 except OSError as e:
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
45 print "Cannot prepare reference error({0}): {1}".format(e.errno, e.strerror)
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
46 #TODO: hard coded the bam and bigwig tracks. Need to allow users to customize the settings
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
47 def addTrack(self, track):
45
15b4a74722d1 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 73ede51a133dc8914812195a1b4cd512bfb8f23d
yating-l
parents: 44
diff changeset
48 #print "false_path" , track['false_path']
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
49 if track['false_path'] in self.metaData.keys():
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
50 metadata = self.metaData[track['false_path']]
39
75edbc203532 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents: 37
diff changeset
51 else:
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
52 metadata = {}
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
53 self.SetMetadata(track, metadata)
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
54 if track['dataType'] == 'bam':
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
55 self.Bam(track, metadata)
37
046c5bfc0413 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents: 31
diff changeset
56 # print "add bam track\n"
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
57 elif track['dataType'] == 'bigwig':
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
58 self.BigWig(track, metadata)
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
59 else:
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
60 gff3_file = os.path.join(self.raw, track['fileName'])
45
15b4a74722d1 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 73ede51a133dc8914812195a1b4cd512bfb8f23d
yating-l
parents: 44
diff changeset
61 if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf' or track['dataType'] == 'blastxml':
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
62 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', metadata['type'], '--trackLabel', metadata['label'], '--Config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments", "category" : "%s"}' % metadata['category'], '--clientConfig', '{"color" : "%s"}' % metadata['color'], '--out', self.json])
12
e1f188b43750 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 5
diff changeset
63 elif track['dataType'] == 'gff3_transcript':
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
64 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', metadata['type'], '--trackLabel', metadata['label'], '--Config', '{"transcriptType": "transcript", "category" : "%s"}' % metadata['category'], '--clientConfig', '{"color" : "%s"}' % metadata['color'], '--out', self.json])
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
65 else:
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
66 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', metadata['type'], '--trackLabel', metadata['label'], '--Config', '{"category" : "%s"}' % metadata['category'], '--clientConfig', '{"color" : "%s"}' % metadata['color'], '--out', self.json])
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
67 p.communicate()
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
68
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
69 def indexName(self):
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
70 p = subprocess.Popen(['generate-names.pl', '-v', '--out', self.json])
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
71 p.communicate()
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
72 print "finished name index \n"
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
73
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
74 def makeArchive(self):
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
75 shutil.make_archive(self.out_path, 'zip', self.out_path)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
76 shutil.rmtree(self.out_path)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
77
15
8627394693c6 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 12
diff changeset
78 #TODO: this will list all zip files in the filedir and sub-dirs. worked in Galaxy but all list zip files in test-data when
8627394693c6 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 12
diff changeset
79 #run it locally. May need modify
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
80 def outHtml(self):
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
81 with open(self.outfile, 'w') as htmlfile:
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
82 htmlstr = 'The JBrowse Hub is created: <br>'
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
83 zipfiles = '<li><a href = "%s">Download</a></li>'
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
84 filedir_abs = os.path.abspath(self.outfile)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
85 filedir = os.path.dirname(filedir_abs)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
86 filedir = os.path.join(filedir, self.outfolder)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
87 for root, dirs, files in os.walk(filedir):
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
88 for file in files:
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
89 if file.endswith('.zip'):
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
90 relative_directory = os.path.relpath(root, filedir)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
91 relative_file_path = os.path.join(relative_directory, file)
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
92 htmlstr += zipfiles % relative_file_path
15
8627394693c6 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 12
diff changeset
93
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
94 htmlfile.write(htmlstr)
0
e4f3f2ed4fa5 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff changeset
95
26
a4a54b925c73 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents: 25
diff changeset
96 def createTrackList(self):
a4a54b925c73 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents: 25
diff changeset
97 trackList = os.path.join(self.json, "trackList.json")
a4a54b925c73 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents: 25
diff changeset
98 if not os.path.exists(trackList):
a4a54b925c73 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents: 25
diff changeset
99 os.mknod(trackList)
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
100
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
101 def Bam(self, track, metadata):
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
102 #create trackList.json if not exist
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
103 self.createTrackList()
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
104 json_file = os.path.join(self.json, "trackList.json")
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
105 bam_track = dict()
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
106 bam_track['type'] = 'JBrowse/View/Track/Alignments2'
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
107 bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM'
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
108 bam_track['urlTemplate'] = os.path.join('../raw', track['fileName'])
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
109 bam_track['baiUrlTemplate'] = os.path.join('../raw', track['index'])
44
37422f705e9b planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 42
diff changeset
110 bam_track['label'] = metadata['label']
37422f705e9b planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 42
diff changeset
111 bam_track['category'] = metadata['category']
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
112 utils.add_tracks_to_json(json_file, bam_track, 'add_tracks')
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
113
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
114 def BigWig(self, track, metadata):
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
115 #create trackList.json if not exist
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
116 self.createTrackList()
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
117 json_file = os.path.join(self.json, "trackList.json")
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
118 bigwig_track = dict()
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
119 bigwig_track['urlTemplate'] = os.path.join('../raw', track['fileName'])
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
120 bigwig_track['type'] = 'JBrowse/View/Track/Wiggle/XYPlot'
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
121 bigwig_track['storeClass'] = 'JBrowse/Store/SeqFeature/BigWig'
44
37422f705e9b planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 42
diff changeset
122 bigwig_track['label'] = metadata['label']
37422f705e9b planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 42
diff changeset
123 bigwig_track['style'] = metadata['style']
37422f705e9b planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 42
diff changeset
124 bigwig_track['category'] = metadata['category']
42
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
125 utils.add_tracks_to_json(json_file, bigwig_track, 'add_tracks')
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
126
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
127 #If the metadata is not set, use the default value
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
128 def SetMetadata(self, track, metadata):
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
129 if 'label' not in metadata.keys() or metadata['label'] == '':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
130 metadata['label'] = track['fileName']
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
131 if 'color' not in metadata.keys() or metadata['color'] == '':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
132 metadata['color'] = "#daa520"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
133 if track['dataType'] == 'bigwig':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
134 if 'style' not in metadata.keys():
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
135 metadata['style'] = {}
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
136 if 'pos_color' not in metadata['style'] or metadata['style']['pos_color'] == '':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
137 metadata['pos_color'] = "#FFA600"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
138 if 'neg_color' not in metadata['style'] or metadata['style']['neg_color'] == '':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
139 metadata['neg_color'] = "#005EFF"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
140 if 'category' not in metadata.keys() or metadata['category'] == '':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
141 metadata['category'] = "Default group"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
142 if track['dataType'] == 'blastxml':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
143 metadata['type'] = "G-OnRamp_plugin/BlastAlignment"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
144 elif track['dataType'] == 'gff3_transcript' or track['dataType'] == 'gff3_mrna':
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
145 metadata['type'] = "G-OnRamp_plugin/GenePred"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
146 else:
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
147 metadata['type'] = "CanvasFeatures"
a5108e5010b4 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit 149c5cbda82f49f260767b5710f0c2160eebc881-dirty
yating-l
parents: 39
diff changeset
148
31
d8049deb0c97 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents: 26
diff changeset
149
26
a4a54b925c73 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents: 25
diff changeset
150
5
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
151
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
152
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
153
e7c80e9b70ae planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents: 0
diff changeset
154