Mercurial > repos > yating-l > jbrowse_hub
annotate TrackHub.py @ 31:d8049deb0c97 draft
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
author | yating-l |
---|---|
date | Fri, 17 Mar 2017 12:28:32 -0400 |
parents | a4a54b925c73 |
children | 046c5bfc0413 |
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: |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
10 def __init__(self, inputFiles, reference, outputDirect, tool_dir, genome, extra_files_path): |
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 |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
17 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
|
18 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
|
19 try: |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
20 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
|
21 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
|
22 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
|
23 except OSError as e: |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
24 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
|
25 else: |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
26 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
|
27 |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
28 def createHub(self): |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
29 self.prepareRefseq() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
30 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
|
31 self.addTrack(input_file) |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
32 self.indexName() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
33 self.makeArchive() |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
34 self.outHtml() |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
35 print "Success!\n" |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
36 |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
37 def prepareRefseq(self): |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
38 try: |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
39 #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
|
40 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
|
41 # 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
|
42 p.communicate() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
43 except OSError as e: |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
44 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
|
45 #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
|
46 def addTrack(self, track): |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
47 if track['dataType'] == 'bam': |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
48 self.createTrackList() |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
49 json_file = os.path.join(self.json, "trackList.json") |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
50 bam_track = dict() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
51 bam_track['type'] = 'JBrowse/View/Track/Alignments2' |
22
fcf2865c950c
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
21
diff
changeset
|
52 bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM' |
31
d8049deb0c97
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
26
diff
changeset
|
53 bam_track['label'] = track['label'] |
23
2a12d257f95d
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
22
diff
changeset
|
54 bam_track['urlTemplate'] = os.path.join('../raw', track['fileName']) |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
55 bam_track['baiUrlTemplate'] = os.path.join('../raw', track['index']) |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
56 utils.add_tracks_to_json(json_file, bam_track, 'add_tracks') |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
57 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
|
58 elif track['dataType'] == 'bigwig': |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
59 self.createTrackList() |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
60 json_file = os.path.join(self.json, "trackList.json") |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
61 bigwig_track = dict() |
31
d8049deb0c97
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
26
diff
changeset
|
62 bigwig_track['label'] = track['label'] |
23
2a12d257f95d
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
22
diff
changeset
|
63 bigwig_track['urlTemplate'] = os.path.join('../raw', track['fileName']) |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
64 bigwig_track['type'] = 'JBrowse/View/Track/Wiggle/XYPlot' |
22
fcf2865c950c
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
21
diff
changeset
|
65 bigwig_track['storeClass'] = 'JBrowse/Store/SeqFeature/BigWig' |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
66 utils.add_tracks_to_json(json_file, bigwig_track, 'add_tracks') |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
67 else: |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
68 gff3_file = os.path.join(self.raw, track['fileName']) |
31
d8049deb0c97
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
26
diff
changeset
|
69 label = track['label'] |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
70 if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf': |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
71 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments"}', '--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
|
72 elif track['dataType'] == 'gff3_transcript': |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
73 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'MyPlugin/GenePred', '--trackLabel', label, '--config', '{"transcriptType": "transcript"}', '--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
|
74 elif track['dataType'] == 'gff3_mrna': |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
75 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'MyPlugin/GenePred', '--trackLabel', label, '--out', self.json]) |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
76 else: |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
77 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--out', self.json]) |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
78 p.communicate() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
79 |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
80 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
|
81 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
|
82 p.communicate() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
83 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
|
84 |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 |
15
8627394693c6
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
12
diff
changeset
|
89 #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
|
90 #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
|
91 def outHtml(self): |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
105 htmlfile.write(htmlstr) |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
106 |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
107 def createTrackList(self): |
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
108 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
|
109 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
|
110 os.mknod(trackList) |
31
d8049deb0c97
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
26
diff
changeset
|
111 |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
112 |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
113 |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
114 |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
115 |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
116 |