Mercurial > repos > yating-l > hub_test
annotate BedSimpleRepeats.py @ 0:abcfd662b679 draft default tip
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
author | yating-l |
---|---|
date | Thu, 22 Dec 2016 17:53:00 -0500 |
parents | |
children |
rev | line source |
---|---|
0
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
1 #!/usr/bin/python |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
2 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
3 import os |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
4 import tempfile |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
5 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
6 from Datatype import Datatype |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
7 from Track import Track |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
8 from TrackDb import TrackDb |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
9 from util import subtools |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
10 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
11 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
12 class BedSimpleRepeats( Datatype ): |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
13 def __init__(self, input_bed_simple_repeats_false_path, data_bed_simple_repeats): |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
14 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
15 super(BedSimpleRepeats, self).__init__() |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
16 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
17 self.input_bed_simple_repeats_false_path = input_bed_simple_repeats_false_path |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
18 self.name_bed_simple_repeats = data_bed_simple_repeats["name"] |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
19 self.priority = data_bed_simple_repeats["order_index"] |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
20 self.track_color = data_bed_simple_repeats["track_color"] |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
21 # TODO: Think about how to avoid repetition of the group_name everywhere |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
22 self.group_name = data_bed_simple_repeats["group_name"] |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
23 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
24 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
25 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
26 # Sort processing |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
27 subtools.sort(self.input_bed_simple_repeats_false_path, sortedBedFile.name) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
28 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
29 # bedToBigBed processing |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
30 # TODO: Change the name of the bb, to tool + genome + .bb |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
31 trackName = "".join( ( self.name_bed_simple_repeats, '.bb' ) ) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
32 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
33 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
34 auto_sql_option = os.path.join(self.tool_directory, 'trf_simpleRepeat.as') |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
35 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
36 with open(myBigBedFilePath, 'w') as bigBedFile: |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
37 subtools.bedToBigBed(sortedBedFile.name, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
38 self.chromSizesFile.name, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
39 bigBedFile.name, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
40 typeOption='bed4+12', |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
41 autoSql=auto_sql_option) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
42 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
43 # Create the Track Object |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
44 self.createTrack(file_path=trackName, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
45 track_name=trackName, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
46 long_label=self.name_bed_simple_repeats, track_type='bigBed 4 +', visibility='dense', |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
47 priority=self.priority, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
48 track_file=myBigBedFilePath, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
49 track_color=self.track_color, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
50 group_name=self.group_name) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
51 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
52 # dataURL = "tracks/%s" % trackName |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
53 # |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
54 # trackDb = TrackDb( |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
55 # trackName=trackName, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
56 # longLabel=self.name_bed_simple_repeats, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
57 # shortLabel=self.getShortName( self.name_bed_simple_repeats ), |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
58 # trackDataURL=dataURL, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
59 # trackType='bigBed 4 +', |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
60 # visibility='dense', |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
61 # priority=self.priority, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
62 # ) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
63 # |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
64 # self.track = Track( |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
65 # trackFile=myBigBedFilePath, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
66 # trackDb=trackDb, |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
67 # ) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
68 |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
69 print("- Bed simple repeats %s created" % self.name_bed_simple_repeats) |
abcfd662b679
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff
changeset
|
70 #print("- %s created in %s" % (trackName, myBigBedFilePath)) |