annotate cytoBand.py @ 28:6aa28a85cc38 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 5bbecd016ad3a784ad030cb82a09a3ac40dc6060
author yating-l
date Mon, 10 Jul 2017 17:08:38 -0400
parents df42241d3731
children
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,
28
6aa28a85cc38 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 5bbecd016ad3a784ad030cb82a09a3ac40dc6060
yating-l
parents: 26
diff changeset
44 typeOption='bed4+1',
6aa28a85cc38 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 5bbecd016ad3a784ad030cb82a09a3ac40dc6060
yating-l
parents: 26
diff changeset
45 tab='True',
24
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
46 autoSql=auto_sql_option)
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
47
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
48 # Create the Track Object
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
49 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
50 track_name='cytoBandIdeo',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
51 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
52 track_type='bigBed',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
53 visibility='dense',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
54 priority=self.priority,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
55 track_file=myBigBedFilePath,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
56 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
57 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
58 database=self.database)
24
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
59
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
60 # dataURL = "tracks/%s" % trackName
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
61 #
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
62 # trackDb = TrackDb(
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
63 # trackName=trackName,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
64 # 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
65 # 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
66 # trackDataURL=dataURL,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
67 # trackType='bigBed 4 +',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
68 # visibility='dense',
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
69 # priority=self.priority,
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 #
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
72 # self.track = Track(
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
73 # trackFile=myBigBedFilePath,
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
74 # trackDb=trackDb,
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
fcc1021bd496 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
yating-l
parents:
diff changeset
77 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
78 #print("- %s created in %s" % (trackName, myBigBedFilePath))