comparison BedSimpleRepeats.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
8 from TrackDb import TrackDb 8 from TrackDb import TrackDb
9 from util import subtools 9 from util import subtools
10 10
11 11
12 class BedSimpleRepeats( Datatype ): 12 class BedSimpleRepeats( Datatype ):
13 def __init__( self, input_bed_simple_repeats_false_path, data_bed_simple_repeats, 13 def __init__(self, input_bed_simple_repeats_false_path, data_bed_simple_repeats):
14 input_fasta_file, extra_files_path, tool_directory ):
15 14
16 super(BedSimpleRepeats, self).__init__( 15 super(BedSimpleRepeats, self).__init__()
17 input_fasta_file, extra_files_path, tool_directory
18 )
19 16
20 self.input_bed_simple_repeats_false_path = input_bed_simple_repeats_false_path 17 self.input_bed_simple_repeats_false_path = input_bed_simple_repeats_false_path
21 self.name_bed_simple_repeats = data_bed_simple_repeats["name"] 18 self.name_bed_simple_repeats = data_bed_simple_repeats["name"]
22 self.priority = data_bed_simple_repeats["order_index"] 19 self.priority = data_bed_simple_repeats["order_index"]
23 20
24 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") 21 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed")
25 twoBitInfoFile = tempfile.NamedTemporaryFile(bufsize=0)
26 chromSizesFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".chrom.sizes")
27 22
28 # Sort processing 23 # Sort processing
29 subtools.sort(self.input_bed_simple_repeats_false_path, sortedBedFile.name) 24 subtools.sort(self.input_bed_simple_repeats_false_path, sortedBedFile.name)
30
31 # TODO: Regroup in an mother class which handles the Chrom.sizes creation with Gff3 and Gtf
32 # Generate the chrom.sizes
33
34 subtools.twoBitInfo(self.twoBitFile.name, twoBitInfoFile.name)
35
36 # Then we get the output to inject into the sort
37 # TODO: Check if no errors
38 subtools.sortChromSizes(twoBitInfoFile.name, chromSizesFile.name)
39 25
40 # bedToBigBed processing 26 # bedToBigBed processing
41 # TODO: Change the name of the bb, to tool + genome + .bb 27 # TODO: Change the name of the bb, to tool + genome + .bb
42 trackName = "".join( ( self.name_bed_simple_repeats, '.bb' ) ) 28 trackName = "".join( ( self.name_bed_simple_repeats, '.bb' ) )
43 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) 29 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName)
44 auto_sql_option = "%s%s" % ('-as=', os.path.join(self.tool_directory, 'trf_simpleRepeat.as')) 30 auto_sql_option = "%s%s" % ('-as=', os.path.join(self.tool_directory, 'trf_simpleRepeat.as'))
45 with open(myBigBedFilePath, 'w') as bigBedFile: 31 with open(myBigBedFilePath, 'w') as bigBedFile:
46 subtools.bedToBigBed(sortedBedFile.name, chromSizesFile.name, bigBedFile.name, 32 subtools.bedToBigBed(sortedBedFile.name, self.chromSizesFile.name, bigBedFile.name,
47 typeOption='-type=bed4+12', 33 typeOption='-type=bed4+12',
48 autoSql=auto_sql_option) 34 autoSql=auto_sql_option)
49 35
50 # Create the Track Object 36 # Create the Track Object
51 dataURL = "tracks/%s" % trackName 37 dataURL = "tracks/%s" % trackName