annotate cytoBand.py @ 27:cdd33c5c8ac1 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 05fc99e5a081e3f2a0f152ad952ba60c50661229
author yating-l
date Mon, 10 Jul 2017 12:28:50 -0400
parents df42241d3731
children 6aa28a85cc38
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"]
26
df42241d3731 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c11beb58525fe6453a2180fe7783f6e8b0151901-dirty
yating-l
parents: 24
diff changeset
23 self.database = data_bed_cytoBand["database"]
24
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
24 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
25 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
26 else:
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
27 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
28 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
29
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
30 # Sort processing
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
31 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
32
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
33 # bedToBigBed processing
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
34 # 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
35 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
36 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
37
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
38 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
39
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
40 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
41 subtools.bedToBigBed(sortedBedFile.name,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
42 self.chromSizesFile.name,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
43 bigBedFile.name,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
44 typeOption='bed4',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
45 autoSql=auto_sql_option)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
46
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
47 # Create the Track Object
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
48 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
49 track_name='cytoBandIdeo',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
50 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
51 track_type='bigBed',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
52 visibility='dense',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
53 priority=self.priority,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
54 track_file=myBigBedFilePath,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
55 track_color=self.track_color,
26
df42241d3731 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c11beb58525fe6453a2180fe7783f6e8b0151901-dirty
yating-l
parents: 24
diff changeset
56 group_name=self.group_name,
df42241d3731 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c11beb58525fe6453a2180fe7783f6e8b0151901-dirty
yating-l
parents: 24
diff changeset
57 database=self.database)
24
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 # dataURL = "tracks/%s" % trackName
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
60 #
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
61 # trackDb = TrackDb(
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
62 # trackName=trackName,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
63 # 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
64 # 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
65 # trackDataURL=dataURL,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
66 # trackType='bigBed 4 +',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
67 # visibility='dense',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
68 # priority=self.priority,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
69 # )
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
70 #
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
71 # self.track = Track(
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
72 # trackFile=myBigBedFilePath,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
73 # trackDb=trackDb,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
74 # )
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
75
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
76 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
77 #print("- %s created in %s" % (trackName, myBigBedFilePath))