annotate cytoBand.py @ 25:99dad5f9444c draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
author yating-l
date Fri, 02 Jun 2017 17:36:24 -0400
parents fcc1021bd496
children df42241d3731
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
1 #!/usr/bin/python
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
2
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
3 import os
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
4 import tempfile
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
5
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
6 from Datatype import Datatype
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
7 from Track import Track
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
8 from TrackDb import TrackDb
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
9 from util import subtools
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
10
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
11
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
12 class cytoBand( Datatype ):
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
13 def __init__(self, input_bed_cytoBand_false_path, data_bed_cytoBand):
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
14
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
15 super(cytoBand, self).__init__()
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
16
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
17 self.input_bed_cytoBand_false_path = input_bed_cytoBand_false_path
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
18 self.name_bed_cytoBand = data_bed_cytoBand["name"]
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
19 self.priority = data_bed_cytoBand["order_index"]
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
20 self.track_color = data_bed_cytoBand["track_color"]
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
21 # TODO: Think about how to avoid repetition of the group_name everywhere
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
22 self.group_name = data_bed_cytoBand["group_name"]
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
23 if data_bed_cytoBand["long_label"]:
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
24 self.long_label = data_bed_cytoBand["long_label"]
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
25 else:
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
26 self.long_label = self.name_bed_cytoBand
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
27 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed")
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
28
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
29 # Sort processing
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
30 subtools.sort(self.input_bed_cytoBand_false_path, sortedBedFile.name)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
31
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
32 # bedToBigBed processing
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
33 # TODO: Change the name of the bb, to tool + genome + .bb
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
34 trackName = "".join( ( self.name_bed_cytoBand, '.bb' ) )
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
35 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
36
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
37 auto_sql_option = os.path.join(self.tool_directory, 'cytoBandIdeo.as')
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
38
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
39 with open(myBigBedFilePath, 'w') as bigBedFile:
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
40 subtools.bedToBigBed(sortedBedFile.name,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
41 self.chromSizesFile.name,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
42 bigBedFile.name,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
43 typeOption='bed4',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
44 autoSql=auto_sql_option)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
45
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
46 # Create the Track Object
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
47 self.createTrack(file_path=trackName,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
48 track_name='cytoBandIdeo',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
49 long_label=self.long_label,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
50 track_type='bigBed',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
51 visibility='dense',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
52 priority=self.priority,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
53 track_file=myBigBedFilePath,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
54 track_color=self.track_color,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
55 group_name=self.group_name)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
56
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
57 # dataURL = "tracks/%s" % trackName
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
58 #
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
59 # trackDb = TrackDb(
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
60 # trackName=trackName,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
61 # longLabel=self.name_bed_simple_repeats,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
62 # shortLabel=self.getShortName( self.name_bed_simple_repeats ),
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
63 # trackDataURL=dataURL,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
64 # trackType='bigBed 4 +',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
65 # visibility='dense',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
66 # priority=self.priority,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
67 # )
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
68 #
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
69 # self.track = Track(
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
70 # trackFile=myBigBedFilePath,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
71 # trackDb=trackDb,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
72 # )
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
73
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
74 print("- Bed splice junctions %s created" % self.name_bed_cytoBand)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
75 #print("- %s created in %s" % (trackName, myBigBedFilePath))