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