Mercurial > repos > rmarenco > hubarchivecreator
view Gtf.py @ 11:d05236b15f81 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3760d0c8353b924ecf994131a5c2eb381aa81fb2
author | rmarenco |
---|---|
date | Wed, 27 Jul 2016 10:10:49 -0400 |
parents | acc233161f50 |
children | 25809f699cb3 |
line wrap: on
line source
#!/usr/bin/python import os import tempfile # Internal dependencies from Datatype import Datatype from Track import Track from TrackDb import TrackDb from util import subtools class Gtf( Datatype ): def __init__( self, input_gtf_false_path, data_gtf): super(Gtf, self).__init__() self.track = None self.input_gtf_false_path = input_gtf_false_path self.name_gtf = data_gtf["name"] self.priority = data_gtf["order_index"] #print "Creating TrackHub GTF from (falsePath: %s; name: %s)" % ( self.input_gtf_false_path, self.name_gtf) # TODO: See if we need these temporary files as part of the generated files genePredFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred") unsortedBedFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".unsortedBed") sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") # GtfToGenePred subtools.gtfToGenePred(self.input_gtf_false_path, genePredFile.name) # TODO: From there, refactor because common use with Gff3.py # genePredToBed processing subtools.genePredToBed(genePredFile.name, unsortedBedFile.name) # Sort processing subtools.sort(unsortedBedFile.name, sortedBedFile.name) # bedToBigBed processing # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb trackName = "".join( ( self.name_gtf, ".bb") ) myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) with open(myBigBedFilePath, 'w') as bigBedFile: subtools.bedToBigBed(sortedBedFile.name, self.chromSizesFile.name, bigBedFile.name) # Create the Track Object self.createTrack(file_path=trackName, track_name=trackName, long_label=self.name_gtf, track_type='bigBed 12 +', visibility='dense', priority=self.priority, track_file=myBigBedFilePath) # # dataURL = "tracks/%s" % trackName # # trackDb = TrackDb( # trackName=trackName, # longLabel=self.name_gtf, # shortLabel=self.getShortName( self.name_gtf ), # trackDataURL=dataURL, # trackType='bigBed 12 +', # visibility='dense', # priority=self.priority, # ) # self.track = Track( # trackFile=myBigBedFilePath, # trackDb=trackDb, # ) print("- Gtf %s created" % self.name_gtf) #print("- %s created in %s" % (trackName, myBigBedFilePath))