Mercurial > repos > yating-l > hubarchivecreator
annotate bigPsl.py @ 65:5a4206366b41 draft
Uploaded
author | yating-l |
---|---|
date | Wed, 09 Aug 2017 16:40:21 -0400 |
parents | b39dd0b5a166 |
children |
rev | line source |
---|---|
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
1 #!/usr/bin/python |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
2 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
3 import os |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
4 import tempfile |
51
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents:
9
diff
changeset
|
5 import string |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
6 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
7 from Datatype import Datatype |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
8 from Track import Track |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
9 from TrackDb import TrackDb |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
10 from util import subtools |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
11 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
12 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
13 class bigPsl( Datatype ): |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
14 def __init__(self, input_bigpsl_false_path, data_bigpsl): |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
15 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
16 super(bigPsl, self).__init__() |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
17 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
18 self.input_bigpsl_false_path = input_bigpsl_false_path |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
19 self.name_bigpsl = data_bigpsl["name"] |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
20 self.priority = data_bigpsl["order_index"] |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
21 self.track_color = data_bigpsl["track_color"] |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
22 # TODO: Think about how to avoid repetition of the group_name everywhere |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
23 self.group_name = data_bigpsl["group_name"] |
57
b39dd0b5a166
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents:
52
diff
changeset
|
24 self.database = data_bigpsl["database"] |
52
c66803bff0cc
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents:
51
diff
changeset
|
25 if data_bigpsl["long_label"]: |
c66803bff0cc
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents:
51
diff
changeset
|
26 self.long_label = data_bigpsl["long_label"] |
c66803bff0cc
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents:
51
diff
changeset
|
27 else: |
c66803bff0cc
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents:
51
diff
changeset
|
28 self.long_label = self.name_bigpsl |
65 | 29 if data_bigpsl["search_index"]: |
30 self.search_index = data_bigpsl["search_index"] | |
31 else: | |
32 self.search_index = "" | |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
33 #sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
34 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
35 # Sort processing |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
36 #subtools.sort(self.input_bigpsl_false_path, sortedBedFile.name) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
37 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
38 # bedToBigBed processing |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
39 # TODO: Change the name of the bb, to tool + genome + .bb |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
40 trackName = "".join( ( self.name_bigpsl, '.bb' ) ) |
51
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents:
9
diff
changeset
|
41 |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
42 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
43 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
44 auto_sql_option = os.path.join(self.tool_directory, 'bigPsl.as') |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
45 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
46 with open(myBigBedFilePath, 'w') as bigBedFile: |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
47 subtools.bedToBigBed(self.input_bigpsl_false_path, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
48 self.chromSizesFile.name, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
49 bigBedFile.name, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
50 typeOption='bed12+12', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
51 tab='True', |
57
b39dd0b5a166
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents:
52
diff
changeset
|
52 autoSql=auto_sql_option, |
b39dd0b5a166
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents:
52
diff
changeset
|
53 extraIndex='name') |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
54 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
55 self.createTrack(file_path=trackName, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
56 track_name=trackName, |
52
c66803bff0cc
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents:
51
diff
changeset
|
57 long_label=self.long_label, track_type='bigPsl', visibility='dense', |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
58 priority=self.priority, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
59 track_file=myBigBedFilePath, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
60 track_color=self.track_color, |
57
b39dd0b5a166
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents:
52
diff
changeset
|
61 group_name=self.group_name, |
b39dd0b5a166
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents:
52
diff
changeset
|
62 database=self.database) |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
63 |
51
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents:
9
diff
changeset
|
64 |
9
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
65 # dataURL = "tracks/%s" % trackName |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
66 # |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
67 # trackDb = TrackDb( |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
68 # trackName=trackName, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
69 # longLabel=self.name_bed_simple_repeats, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
70 # shortLabel=self.getShortName( self.name_bed_simple_repeats ), |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
71 # trackDataURL=dataURL, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
72 # trackType='bigBed 4 +', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
73 # visibility='dense', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
74 # priority=self.priority, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
75 # ) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
76 # |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
77 # self.track = Track( |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
78 # trackFile=myBigBedFilePath, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
79 # trackDb=trackDb, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
80 # ) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
81 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
82 print("- bigPsl %s created" % self.name_bigpsl) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
83 #print("- %s created in %s" % (trackName, myBigBedFilePath)) |