comparison Gff3.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 Gff3( Datatype ): 13 class Gff3( Datatype ):
14 def __init__( self, input_Gff3_false_path, data_gff3, 14 def __init__(self, input_Gff3_false_path, data_gff3):
15 input_fasta_false_path, extra_files_path, tool_directory ): 15 super( Gff3, self ).__init__()
16 super( Gff3, self ).__init__(
17 input_fasta_false_path, extra_files_path, tool_directory
18 )
19 16
20 self.track = None 17 self.track = None
21 18
22 self.input_Gff3_false_path = input_Gff3_false_path 19 self.input_Gff3_false_path = input_Gff3_false_path
23 self.name_gff3 = data_gff3["name"] 20 self.name_gff3 = data_gff3["name"]
27 genePredFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred") 24 genePredFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred")
28 unsortedBedFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsortedBed") 25 unsortedBedFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsortedBed")
29 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") 26 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed")
30 27
31 # TODO: Refactor into another Class to manage the twoBitInfo and ChromSizes (same process as in Gtf.py) 28 # TODO: Refactor into another Class to manage the twoBitInfo and ChromSizes (same process as in Gtf.py)
32 twoBitInfoFile = tempfile.NamedTemporaryFile(bufsize=0)
33 chromSizesFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".chrom.sizes")
34 29
35 # gff3ToGenePred processing 30 # gff3ToGenePred processing
36 subtools.gff3ToGenePred(self.input_Gff3_false_path, genePredFile.name) 31 subtools.gff3ToGenePred(self.input_Gff3_false_path, genePredFile.name)
37 32
38 # TODO: From there, refactor because common use with Gtf.py 33 # TODO: From there, refactor because common use with Gtf.py
40 subtools.genePredToBed(genePredFile.name, unsortedBedFile.name) 35 subtools.genePredToBed(genePredFile.name, unsortedBedFile.name)
41 36
42 # Sort processing 37 # Sort processing
43 subtools.sort(unsortedBedFile.name, sortedBedFile.name) 38 subtools.sort(unsortedBedFile.name, sortedBedFile.name)
44 39
45 # Generate the twoBitInfo
46 subtools.twoBitInfo(self.twoBitFile.name, twoBitInfoFile.name)
47
48 # Then we get the output to generate the chromSizes
49 # TODO: Check if no errors 40 # TODO: Check if no errors
50 subtools.sortChromSizes(twoBitInfoFile.name, chromSizesFile.name)
51 41
52 # bedToBigBed processing 42 # bedToBigBed processing
53 # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb 43 # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb
54 trackName = "".join( (self.name_gff3, ".bb" ) ) 44 trackName = "".join( (self.name_gff3, ".bb" ) )
55 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) 45 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName)
56 with open(myBigBedFilePath, 'w') as bigBedFile: 46 with open(myBigBedFilePath, 'w') as bigBedFile:
57 subtools.bedToBigBed(sortedBedFile.name, chromSizesFile.name, bigBedFile.name) 47 subtools.bedToBigBed(sortedBedFile.name, self.chromSizesFile.name, bigBedFile.name)
58 48
59 # Create the Track Object 49 # Create the Track Object
60 dataURL = "tracks/%s" % trackName 50 dataURL = "tracks/%s" % trackName
61 51
62 trackDb = TrackDb( 52 trackDb = TrackDb(