annotate Gff3.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 # Internal dependencies
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
7 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
8 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
9 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
10 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
11
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
12
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
13 class Gff3( Datatype ):
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
14 def __init__(self, input_Gff3_false_path, data_gff3):
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
15 super( Gff3, 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.track = None
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
18
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
19 self.input_Gff3_false_path = input_Gff3_false_path
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
20 self.name_gff3 = data_gff3["name"]
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
21 self.priority = data_gff3["order_index"]
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
22 self.track_color = data_gff3["track_color"]
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
23 # 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
24 self.group_name = data_gff3["group_name"]
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 # TODO: See if we need these temporary files as part of the generated files
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
27 unsorted_genePred_file = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred")
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
28 unsorted_bigGenePred_file = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsorted.bigGenePred")
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
29 sorted_biGenePred_file = tempfile.NamedTemporaryFile(suffix=".sorted.bigGenePred")
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
30
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
31 # gff3ToGenePred processing
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
32 subtools.gff3ToGenePred(self.input_Gff3_false_path, unsorted_genePred_file.name)
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 # genePredToBigGenePred
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
35 subtools.genePredToBigGenePred(unsorted_genePred_file.name, unsorted_bigGenePred_file.name)
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
36
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
37 # Sort processing
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
38 subtools.sort(unsorted_bigGenePred_file.name, sorted_biGenePred_file.name)
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
39
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
40 # TODO: Check if no errors
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
41
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
42 # bedToBigBed processing
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
43 trackName = "".join( (self.name_gff3, ".bb" ) )
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
44
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
45 auto_sql_option = os.path.join(self.tool_directory, 'bigGenePred.as')
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
46
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
47 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
48
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
49 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
50 subtools.bedToBigBed(sorted_biGenePred_file.name,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
51 self.chromSizesFile.name,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
52 bigBedFile.name,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
53 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
54 typeOption='bed12+8',
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
55 tab=True)
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
56
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
57 # 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
58 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
59 track_name=trackName,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
60 long_label=self.name_gff3,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
61 track_type='bigGenePred', visibility='dense',
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
62 priority=self.priority,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
63 track_file=myBigBedFilePath,
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
64 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
65 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
66
abcfd662b679 planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test.git commit 199ae2b10f3b3e58cb4d4a3b9fb4b35db415c538-dirty
yating-l
parents:
diff changeset
67 print("- Gff3 %s created" % self.name_gff3)