Mercurial > repos > yating-l > hubarchivecreator
annotate bigPsl.py @ 34:04b942019dce draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
author | yating-l |
---|---|
date | Thu, 29 Dec 2016 17:57:51 -0500 |
parents | d5781fe7b782 |
children | 364b8db8de17 |
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 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
5 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
6 from Datatype import Datatype |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
7 from Track import Track |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
8 from TrackDb import TrackDb |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
9 from util import subtools |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
10 |
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 class bigPsl( Datatype ): |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
13 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
|
14 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
15 super(bigPsl, self).__init__() |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
16 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
17 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
|
18 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
|
19 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
|
20 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
|
21 # 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
|
22 self.group_name = data_bigpsl["group_name"] |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
23 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
24 #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
|
25 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
26 # Sort processing |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
27 #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
|
28 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
29 # bedToBigBed processing |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
30 # 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
|
31 trackName = "".join( ( self.name_bigpsl, '.bb' ) ) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
32 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
|
33 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
34 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
|
35 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
36 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
|
37 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
|
38 self.chromSizesFile.name, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
39 bigBedFile.name, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
40 typeOption='bed12+12', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
41 tab='True', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
42 autoSql=auto_sql_option) |
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 # Create the Track Object |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
45 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
|
46 track_name=trackName, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
47 long_label=self.name_bigpsl, track_type='bigBed 12 +', visibility='dense', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
48 priority=self.priority, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
49 track_file=myBigBedFilePath, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
50 track_color=self.track_color, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
51 group_name=self.group_name) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
52 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
53 # dataURL = "tracks/%s" % trackName |
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 # trackDb = TrackDb( |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
56 # trackName=trackName, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
57 # 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
|
58 # 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
|
59 # trackDataURL=dataURL, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
60 # trackType='bigBed 4 +', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
61 # visibility='dense', |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
62 # priority=self.priority, |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
63 # ) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
64 # |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
65 # self.track = Track( |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
66 # trackFile=myBigBedFilePath, |
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 # ) |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
69 |
d5781fe7b782
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
yating-l
parents:
diff
changeset
|
70 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
|
71 #print("- %s created in %s" % (trackName, myBigBedFilePath)) |