Mercurial > repos > yating-l > hubarchivecreator
annotate BedSpliceJunctions.py @ 49:9c41fce74407 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
| author | yating-l |
|---|---|
| date | Fri, 30 Dec 2016 11:59:56 -0500 |
| parents | 44577d6784b7 |
| children | c66803bff0cc |
| rev | line source |
|---|---|
|
3
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
1 #!/usr/bin/python |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
2 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
3 import os |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
4 import tempfile |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
5 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
6 from Datatype import Datatype |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
7 from Track import Track |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
8 from TrackDb import TrackDb |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
9 from util import subtools |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
10 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
11 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
12 class BedSpliceJunctions( Datatype ): |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
13 def __init__(self, input_bed_splice_junctions_false_path, data_bed_splice_junctions): |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
14 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
15 super(BedSpliceJunctions, self).__init__() |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
16 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
17 self.input_bed_splice_junctions_false_path = input_bed_splice_junctions_false_path |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
18 self.name_bed_splice_junctions = data_bed_splice_junctions["name"] |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
19 self.priority = data_bed_splice_junctions["order_index"] |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
20 self.track_color = data_bed_splice_junctions["track_color"] |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
21 # TODO: Think about how to avoid repetition of the group_name everywhere |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
22 self.group_name = data_bed_splice_junctions["group_name"] |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
23 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
24 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
25 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
26 # Sort processing |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
27 subtools.sort(self.input_bed_splice_junctions_false_path, sortedBedFile.name) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
28 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
29 # bedToBigBed processing |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
30 # TODO: Change the name of the bb, to tool + genome + .bb |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
31 trackName = "".join( ( self.name_bed_splice_junctions, '.bb' ) ) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
32 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
33 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
34 auto_sql_option = os.path.join(self.tool_directory, 'spliceJunctions.as') |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
35 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
36 with open(myBigBedFilePath, 'w') as bigBedFile: |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
37 subtools.bedToBigBed(sortedBedFile.name, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
38 self.chromSizesFile.name, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
39 bigBedFile.name, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
40 typeOption='bed12+1', |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
41 autoSql=auto_sql_option) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
42 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
43 # Create the Track Object |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
44 self.createTrack(file_path=trackName, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
45 track_name=trackName, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
46 long_label=self.name_bed_splice_junctions, track_type='bigBed 12 +', visibility='dense', |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
47 priority=self.priority, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
48 track_file=myBigBedFilePath, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
49 track_color=self.track_color, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
50 group_name=self.group_name) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
51 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
52 # dataURL = "tracks/%s" % trackName |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
53 # |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
54 # trackDb = TrackDb( |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
55 # trackName=trackName, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
56 # longLabel=self.name_bed_simple_repeats, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
57 # shortLabel=self.getShortName( self.name_bed_simple_repeats ), |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
58 # trackDataURL=dataURL, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
59 # trackType='bigBed 4 +', |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
60 # visibility='dense', |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
61 # priority=self.priority, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
62 # ) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
63 # |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
64 # self.track = Track( |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
65 # trackFile=myBigBedFilePath, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
66 # trackDb=trackDb, |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
67 # ) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
68 |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
69 print("- Bed splice junctions %s created" % self.name_bed_splice_junctions) |
|
44577d6784b7
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff
changeset
|
70 #print("- %s created in %s" % (trackName, myBigBedFilePath)) |
