Mercurial > repos > yating-l > jbrowse_hub
annotate TrackHub.py @ 37:046c5bfc0413 draft
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
author | yating-l |
---|---|
date | Fri, 17 Mar 2017 16:21:25 -0400 |
parents | d8049deb0c97 |
children | 75edbc203532 |
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): |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
47 track_label = track['label'] |
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
48 track_color = track['track_color'] |
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
49 track_type = track['track_type'] |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
50 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
|
51 self.createTrackList() |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
52 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
|
53 bam_track = dict() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
54 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
|
55 bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM' |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
56 bam_track['label'] = track_label |
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
57 bam_track['color'] = track_color |
23
2a12d257f95d
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
22
diff
changeset
|
58 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
|
59 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
|
60 utils.add_tracks_to_json(json_file, bam_track, 'add_tracks') |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
61 # 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
|
62 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
|
63 self.createTrackList() |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
64 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
|
65 bigwig_track = dict() |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
66 bigwig_track['label'] = track_label |
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
67 bigwig_track['color'] = track_color |
23
2a12d257f95d
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
22
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 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
|
72 else: |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
73 gff3_file = os.path.join(self.raw, track['fileName']) |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
74 if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf': |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
75 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments", "color" : "%s"}' % track_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
|
76 elif track['dataType'] == 'gff3_transcript': |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
77 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"transcriptType": "transcript", "color" : "%s"}' % track_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
|
78 elif track['dataType'] == 'gff3_mrna': |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
79 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json]) |
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
80 elif track['dataType'] == 'blastxml': |
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
81 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_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
|
82 else: |
37
046c5bfc0413
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
yating-l
parents:
31
diff
changeset
|
83 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_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
|
84 p.communicate() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
85 |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
86 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
|
87 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
|
88 p.communicate() |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
89 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
|
90 |
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 |
15
8627394693c6
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
12
diff
changeset
|
95 #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
|
96 #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
|
97 def outHtml(self): |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
111 htmlfile.write(htmlstr) |
0
e4f3f2ed4fa5
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
diff
changeset
|
112 |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
113 def createTrackList(self): |
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 |
26
a4a54b925c73
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit e81fecac281f299db00cfc88a068e056b031ae9d-dirty
yating-l
parents:
25
diff
changeset
|
118 |
5
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
119 |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
120 |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
121 |
e7c80e9b70ae
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
yating-l
parents:
0
diff
changeset
|
122 |