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