comparison Datatype.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
comparison
equal deleted inserted replaced
10:acc233161f50 11:d05236b15f81
7 7
8 import os 8 import os
9 import tempfile 9 import tempfile
10 10
11 from util import subtools 11 from util import subtools
12 from Track import Track
13 from TrackDb import TrackDb
12 14
13 15
14 class Datatype(object): 16 class Datatype(object):
15 17
16 twoBitFile = None 18 twoBitFile = None
23 myTrackFolderPath = None 25 myTrackFolderPath = None
24 26
25 twoBitFile = None 27 twoBitFile = None
26 chromSizesFile = None 28 chromSizesFile = None
27 29
30 track = None
31
28 def __init__(self): 32 def __init__(self):
29 33
30 not_init_message = "The {0} is not initialized." \ 34 not_init_message = "The {0} is not initialized." \
31 "Did you use pre_init static method first?" 35 "Did you use pre_init static method first?"
32 if Datatype.input_fasta_file is None: 36 if Datatype.input_fasta_file is None:
33 raise TypeError(not_init_message.format('reference genome')) 37 raise TypeError(not_init_message.format('reference genome'))
34 if Datatype.extra_files_path is None: 38 if Datatype.extra_files_path is None:
35 raise TypeError(not_init_message.format('track Hub path')) 39 raise TypeError(not_init_message.format('track Hub path'))
36 if Datatype.tool_directory is None: 40 if Datatype.tool_directory is None:
37 raise TypeError(not_init_message.format('tool directory')) 41 raise TypeError(not_init_message.format('tool directory'))
42
38 43
39 44
40 @staticmethod 45 @staticmethod
41 def pre_init(reference_genome, two_bit_path, chrom_sizes_file, 46 def pre_init(reference_genome, two_bit_path, chrom_sizes_file,
42 extra_files_path, tool_directory, specie_folder, tracks_folder): 47 extra_files_path, tool_directory, specie_folder, tracks_folder):
64 def getShortName( self, name_to_shortify ): 69 def getShortName( self, name_to_shortify ):
65 # Slice to get from Long label the short label 70 # Slice to get from Long label the short label
66 short_label_slice = slice(0, 15) 71 short_label_slice = slice(0, 15)
67 72
68 return name_to_shortify[short_label_slice] 73 return name_to_shortify[short_label_slice]
74
75 # TODO: Better handle parameters, use heritance mecanism
76 # TODO: Use default parameters for some, like visibility
77 def createTrack(self,
78 file_path=None,
79 track_name=None, long_label=None, thick_draw_item='off',
80 short_label=None, track_type=None, visibility=None, priority=None,
81 track_file=None):
82
83 # TODO: Remove the hardcoded "tracks" by the value used as variable from myTrackFolderPath
84 data_url = "tracks/%s" % file_path
85
86 if not short_label:
87 short_label = self.getShortName(long_label)
88
89 # Replace '_' by ' ', to invert the sanitization mecanism
90 # TODO: Find a better way to manage the sanitization of file path
91 long_label = long_label.replace("_", " ")
92 short_label = short_label.replace("_", " ")
93
94 track_db = TrackDb(
95 trackName=track_name,
96 longLabel=long_label,
97 shortLabel=short_label,
98 trackDataURL=data_url,
99 trackType=track_type,
100 visibility=visibility,
101 thickDrawItem=thick_draw_item,
102 priority=priority,
103 )
104
105 # Return the Bam Track Object
106 self.track = Track(
107 trackFile=track_file,
108 trackDb=track_db,
109 )