annotate BedSpliceJunctions.py @ 57:b39dd0b5a166 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
author yating-l
date Fri, 30 Jun 2017 14:49:14 -0400
parents c66803bff0cc
children a0fc8379223c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"]
57
b39dd0b5a166 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents: 52
diff changeset
23 self.database = data_bed_splice_junctions["database"]
52
c66803bff0cc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents: 3
diff changeset
24 if data_bed_splice_junctions["long_label"]:
c66803bff0cc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents: 3
diff changeset
25 self.long_label = data_bed_splice_junctions["long_label"]
c66803bff0cc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents: 3
diff changeset
26 else:
c66803bff0cc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents: 3
diff changeset
27 self.long_label = self.name_bed_splice_junctions
3
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
28 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
29
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
30 # Sort processing
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
31 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
32
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
33 # bedToBigBed processing
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
34 # 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
35 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
36 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
37
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
38 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
39
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
40 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
41 subtools.bedToBigBed(sortedBedFile.name,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
42 self.chromSizesFile.name,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
43 bigBedFile.name,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
44 typeOption='bed12+1',
57
b39dd0b5a166 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ce28781f52a4f84039de300cb41e3982f2e8bf51-dirty
yating-l
parents: 52
diff changeset
45 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
46 )
3
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
47
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
48 # Create the Track Object
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
49 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
50 track_name=trackName,
52
c66803bff0cc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
yating-l
parents: 3
diff changeset
51 long_label=self.long_label, track_type='bigBed 12 +', visibility='dense',
3
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
52 priority=self.priority,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
53 track_file=myBigBedFilePath,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
54 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
55 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
56 database=self.database)
3
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
57
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
58 # dataURL = "tracks/%s" % trackName
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
59 #
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
60 # trackDb = TrackDb(
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
61 # trackName=trackName,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
62 # 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
63 # 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
64 # trackDataURL=dataURL,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
65 # trackType='bigBed 4 +',
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
66 # visibility='dense',
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
67 # priority=self.priority,
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 #
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
70 # self.track = Track(
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
71 # trackFile=myBigBedFilePath,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
72 # trackDb=trackDb,
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
73 # )
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
74
44577d6784b7 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e2db8aa3672f1222b415716054bfb3c5ccd132a1-dirty
yating-l
parents:
diff changeset
75 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
76 #print("- %s created in %s" % (trackName, myBigBedFilePath))