comparison Gff3.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 # Internal dependencies
7 from Datatype import Datatype
8 from Track import Track
9 from TrackDb import TrackDb
10 from util import subtools
11
12
13 class Gff3( Datatype ):
14 def __init__(self, input_Gff3_false_path, data_gff3):
15 super( Gff3, self ).__init__()
16
17 self.track = None
18
19 self.input_Gff3_false_path = input_Gff3_false_path
20 self.name_gff3 = data_gff3["name"]
21 self.priority = data_gff3["order_index"]
22 self.track_color = data_gff3["track_color"]
23 # TODO: Think about how to avoid repetition of the group_name everywhere
24 self.group_name = data_gff3["group_name"]
25
26 # TODO: See if we need these temporary files as part of the generated files
27 unsorted_genePred_file = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred")
28 unsorted_bigGenePred_file = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsorted.bigGenePred")
29 sorted_biGenePred_file = tempfile.NamedTemporaryFile(suffix=".sorted.bigGenePred")
30
31 # gff3ToGenePred processing
32 subtools.gff3ToGenePred(self.input_Gff3_false_path, unsorted_genePred_file.name)
33
34 # genePredToBigGenePred
35 subtools.genePredToBigGenePred(unsorted_genePred_file.name, unsorted_bigGenePred_file.name)
36
37 # Sort processing
38 subtools.sort(unsorted_bigGenePred_file.name, sorted_biGenePred_file.name)
39
40 # TODO: Check if no errors
41
42 # bedToBigBed processing
43 trackName = "".join( (self.name_gff3, ".bb" ) )
44
45 auto_sql_option = os.path.join(self.tool_directory, 'bigGenePred.as')
46
47 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName)
48
49 with open(myBigBedFilePath, 'w') as bigBedFile:
50 subtools.bedToBigBed(sorted_biGenePred_file.name,
51 self.chromSizesFile.name,
52 bigBedFile.name,
53 autoSql=auto_sql_option,
54 typeOption='bed12+8',
55 tab=True)
56
57 # Create the Track Object
58 self.createTrack(file_path=trackName,
59 track_name=trackName,
60 long_label=self.name_gff3,
61 track_type='bigGenePred', visibility='dense',
62 priority=self.priority,
63 track_file=myBigBedFilePath,
64 track_color=self.track_color,
65 group_name=self.group_name)
66
67 print("- Gff3 %s created" % self.name_gff3)