annotate bigPsl.py @ 22:7ddf651457df draft

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