changeset 37:046c5bfc0413 draft

planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
author yating-l
date Fri, 17 Mar 2017 16:21:25 -0400
parents d5ec43607f66
children 3a3591cf27f9
files TrackHub.py jbrowse_hub.xml trackObject.py
diffstat 3 files changed, 83 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/TrackHub.py	Fri Mar 17 13:04:11 2017 -0400
+++ b/TrackHub.py	Fri Mar 17 16:21:25 2017 -0400
@@ -44,37 +44,43 @@
             print "Cannot prepare reference error({0}): {1}".format(e.errno, e.strerror)
     #TODO: hard coded the bam and bigwig tracks. Need to allow users to customize the settings
     def addTrack(self, track):
+        track_label = track['label']
+        track_color = track['track_color']
+        track_type = track['track_type']
         if track['dataType'] == 'bam':
             self.createTrackList()
             json_file = os.path.join(self.json, "trackList.json")
             bam_track = dict()
             bam_track['type'] = 'JBrowse/View/Track/Alignments2'
             bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM'
-            bam_track['label'] = track['label']
+            bam_track['label'] = track_label
+            bam_track['color'] = track_color
             bam_track['urlTemplate'] = os.path.join('../raw', track['fileName'])
             bam_track['baiUrlTemplate'] = os.path.join('../raw', track['index'])
             utils.add_tracks_to_json(json_file, bam_track, 'add_tracks')
-            print "add bam track\n"
+           # print "add bam track\n"
         elif track['dataType'] == 'bigwig':
             self.createTrackList()
             json_file = os.path.join(self.json, "trackList.json")
             bigwig_track = dict()
-            bigwig_track['label'] = track['label']
+            bigwig_track['label'] = track_label
+            bigwig_track['color'] = track_color
             bigwig_track['urlTemplate'] = os.path.join('../raw', track['fileName'])
             bigwig_track['type'] = 'JBrowse/View/Track/Wiggle/XYPlot'
             bigwig_track['storeClass'] = 'JBrowse/Store/SeqFeature/BigWig'
             utils.add_tracks_to_json(json_file, bigwig_track, 'add_tracks')
         else: 
             gff3_file = os.path.join(self.raw, track['fileName'])
-            label = track['label']
             if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf':
-                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments"}', '--out', self.json])
+                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments", "color" : "%s"}' % track_color, '--out', self.json])
             elif track['dataType'] == 'gff3_transcript':
-                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'MyPlugin/GenePred', '--trackLabel', label, '--config', '{"transcriptType": "transcript"}', '--out', self.json])
+                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"transcriptType": "transcript", "color" : "%s"}' % track_color, '--out', self.json])
             elif track['dataType'] == 'gff3_mrna':
-                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'MyPlugin/GenePred', '--trackLabel', label, '--out', self.json])
+                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json])
+            elif track['dataType'] == 'blastxml':
+                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json])
             else:
-                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--out', self.json])
+                p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json])
             p.communicate()
             
     def indexName(self):
--- a/jbrowse_hub.xml	Fri Mar 17 13:04:11 2017 -0400
+++ b/jbrowse_hub.xml	Fri Mar 17 16:21:25 2017 -0400
@@ -38,7 +38,10 @@
 
         #for $f in $format
             #set track_label =  str($f.formatChoice.label)
-            #set extra_data_dict = {"label" : $track_label} 
+            #set track_color = str($f.formatChoice.track_color)
+            #set track_type = str($f.formatChoice.track_type)
+            #set extra_data_dict = {"label" : $track_label, 
+                                    "track_color" : $track_color} 
             #if $f.formatChoice.format_select == 'bed'
                 #if $f.formatChoice.bedChoice.bed_select == 'bed_simple_repeats_option'
                     --bedSimpleRepeats $f.formatChoice.bedChoice.BED_simple_repeats
@@ -104,7 +107,14 @@
                                 type="data"
                                 label="BAM File"
                         />
-                        <param name="label" type="text" size="30" value="${on_string}" label="Track name" />
+                        <param name="label" type="text" size="30" value = "Sequence Alignment" label="Track name" />
+                        <param name="track_color" type="color" label="Track color" value="#daa520">
+                            <sanitizer>
+                                <valid initial="string.letters,string.digits">
+                                    <add value="#"/>
+                                </valid>
+                            </sanitizer>
+                        </param>
                     </when>     
                     <when value="bed">
                         <conditional name="bedChoice">
@@ -129,7 +139,14 @@
                                 />
                             </when>
                         </conditional>
-                        <param name="label" type="text" size="30" value="${on_string}" label="Track name" />
+                        <param name="label" type="text" size="30" value="BED file" label="Track name" />
+                        <param name="track_color" type="color" label="Track color" value="#daa520">
+                            <sanitizer>
+                                <valid initial="string.letters,string.digits">
+                                    <add value="#"/>
+                                </valid>
+                            </sanitizer>
+                        </param>
                     </when>
                     <when value="blastxml">
                         <param
@@ -138,7 +155,18 @@
                                 type="data"
                                 label="Blast Alignments File"
                         />
-                        <param name="label" type="text" size="30" value="${on_string}" label="Track name" />
+                        <param name="label" type="text" size="30" value="Blast Alignment" label="Track name" />
+                        <param name="track_type" type="select" label="Set trackType">
+                            <option value="CanvasFeatures">CanvasFeatures (Default)</option>
+                            <option value="G-OnRamp_plugin/BlastAlignment">BlastAlignment (contain advanced features, need install G_OnRamp_plugin</option>
+                        </param>
+                        <param name="track_color" type="color" label="Track color" value="#daa520">
+                            <sanitizer>
+                                <valid initial="string.letters,string.digits">
+                                    <add value="#"/>
+                                </valid>
+                            </sanitizer>
+                        </param>
                     </when>
                     <when value="bigwig">
                         <param
@@ -147,7 +175,14 @@
                                 type="data"
                                 label="BIGWIG File"
                         />
-                        <param name="label" type="text" size="30" value="${on_string}" label="Track name" />
+                        <param name="label" type="text" size="30" value="Sequence Coverage" label="Track name" />
+                        <param name="track_color" type="color" label="Track color" value="#daa520">
+                            <sanitizer>
+                                <valid initial="string.letters,string.digits">
+                                    <add value="#"/>
+                                </valid>
+                            </sanitizer>
+                        </param>
                     </when>
                     <when value="gff3">
                         <conditional name="gff3Choice">
@@ -172,7 +207,18 @@
                                 />
                             </when>
                         </conditional>
-                        <param name="label" type="text" size="30" value="${on_string}" label="Track name" />
+                        <param name="label" type="text" size="30" value="Gene Prediction" label="Track name" />
+                        <param name="track_type" type="select" label="Set trackType">
+                            <option value="CanvasFeatures">CanvasFeatures (Default)</option>
+                            <option value="G-OnRamp_plugin/GenePred">GenePred (contain advanced features, need install G_OnRamp_plugin</option>
+                        </param>
+                        <param name="track_color" type="color" label="Track color" value="#daa520">
+                            <sanitizer>
+                                <valid initial="string.letters,string.digits">
+                                    <add value="#"/>
+                                </valid>
+                            </sanitizer>
+                        </param>
                     </when>
                     <when value="gtf">
                         <param
@@ -181,7 +227,14 @@
                                 type="data"
                                 label="GTF File"
                         />
-                        <param name="label" type="text" size="30" value="${on_string}" label="Track name" />
+                        <param name="label" type="text" size="30" value="Assembled Transcripts" label="Track name" />
+                        <param name="track_color" type="color" label="Track color" value="#daa520">
+                            <sanitizer>
+                                <valid initial="string.letters,string.digits">
+                                    <add value="#"/>
+                                </valid>
+                            </sanitizer>
+                        </param>
                     </when>  
             </conditional>
         </repeat>
--- a/trackObject.py	Fri Mar 17 13:04:11 2017 -0400
+++ b/trackObject.py	Fri Mar 17 16:21:25 2017 -0400
@@ -61,6 +61,13 @@
         track['fileName'] = fileName
         track['dataType'] = dataType
         track.update(metaData)
-        if 'label' not in metaData.keys():
-            track['label'] = fileName
+        #If the metadata is not set, use the default value
+        if 'name' not in metaData.keys() or track['name'] == '':
+            track['name'] = fileName
+        if 'label' not in metaData.keys() or track['label'] == '':
+            track['label'] = track['name']
+        if 'track_color' not in metaData.keys() or track['track_color'] == '':
+            track['track_color'] = "#daa520"
+        if 'track_type' not in metaData.keys() or track['track_type'] == '':
+            track['track_type'] = "CanvasFeatures"
         self.tracks.append(track)