Mercurial > repos > rmarenco > hubarchivecreator
comparison Gtf.py @ 10:acc233161f50 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
author | rmarenco |
---|---|
date | Thu, 21 Jul 2016 05:58:51 -0400 |
parents | fb5e60d4d18a |
children | d05236b15f81 |
comparison
equal
deleted
inserted
replaced
9:4f9847539a28 | 10:acc233161f50 |
---|---|
9 from TrackDb import TrackDb | 9 from TrackDb import TrackDb |
10 from util import subtools | 10 from util import subtools |
11 | 11 |
12 | 12 |
13 class Gtf( Datatype ): | 13 class Gtf( Datatype ): |
14 def __init__( self, input_gtf_false_path, data_gtf, | 14 def __init__( self, input_gtf_false_path, data_gtf): |
15 input_fasta_file, extra_files_path, tool_directory ): | 15 |
16 super(Gtf, self).__init__( input_fasta_file=input_fasta_file, | 16 super(Gtf, self).__init__() |
17 extra_files_path=extra_files_path, | |
18 tool_directory=tool_directory ) | |
19 | 17 |
20 self.track = None | 18 self.track = None |
21 | 19 |
22 self.input_gtf_false_path = input_gtf_false_path | 20 self.input_gtf_false_path = input_gtf_false_path |
23 self.name_gtf = data_gtf["name"] | 21 self.name_gtf = data_gtf["name"] |
28 # TODO: See if we need these temporary files as part of the generated files | 26 # TODO: See if we need these temporary files as part of the generated files |
29 genePredFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred") | 27 genePredFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred") |
30 unsortedBedFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsortedBed") | 28 unsortedBedFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsortedBed") |
31 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") | 29 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") |
32 | 30 |
33 twoBitInfoFile = tempfile.NamedTemporaryFile(bufsize=0) | |
34 chromSizesFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".chrom.sizes") | |
35 | |
36 # GtfToGenePred | 31 # GtfToGenePred |
37 subtools.gtfToGenePred(self.input_gtf_false_path, genePredFile.name) | 32 subtools.gtfToGenePred(self.input_gtf_false_path, genePredFile.name) |
38 | 33 |
39 # TODO: From there, refactor because common use with Gff3.py | 34 # TODO: From there, refactor because common use with Gff3.py |
40 # genePredToBed processing | 35 # genePredToBed processing |
41 subtools.genePredToBed(genePredFile.name, unsortedBedFile.name) | 36 subtools.genePredToBed(genePredFile.name, unsortedBedFile.name) |
42 | 37 |
43 # Sort processing | 38 # Sort processing |
44 subtools.sort(unsortedBedFile.name, sortedBedFile.name) | 39 subtools.sort(unsortedBedFile.name, sortedBedFile.name) |
45 | 40 |
46 # TODO: Chehck if the twoBitInfo / ChromSizes is redundant and make an intermediate class | |
47 # Generate the twoBitInfo | |
48 subtools.twoBitInfo(self.twoBitFile.name, twoBitInfoFile.name) | |
49 | |
50 # Then we get the output to generate the chromSizes | |
51 # TODO: Check if no errors | |
52 subtools.sortChromSizes(twoBitInfoFile.name, chromSizesFile.name) | |
53 | |
54 # bedToBigBed processing | 41 # bedToBigBed processing |
55 # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb | 42 # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb |
56 trackName = "".join( ( self.name_gtf, ".bb") ) | 43 trackName = "".join( ( self.name_gtf, ".bb") ) |
57 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) | 44 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) |
58 with open(myBigBedFilePath, 'w') as bigBedFile: | 45 with open(myBigBedFilePath, 'w') as bigBedFile: |
59 subtools.bedToBigBed(sortedBedFile.name, chromSizesFile.name, bigBedFile.name) | 46 subtools.bedToBigBed(sortedBedFile.name, self.chromSizesFile.name, bigBedFile.name) |
60 | 47 |
61 # Create the Track Object | 48 # Create the Track Object |
62 dataURL = "tracks/%s" % trackName | 49 dataURL = "tracks/%s" % trackName |
63 | 50 |
64 trackDb = TrackDb( | 51 trackDb = TrackDb( |