changeset 26:df42241d3731 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c11beb58525fe6453a2180fe7783f6e8b0151901-dirty
author yating-l
date Mon, 03 Jul 2017 17:30:20 -0400
parents 99dad5f9444c
children cdd33c5c8ac1
files Bam.py Bed.py BedBlastAlignments.py BedSimpleRepeats.py BedSpliceJunctions.py BigBed.py BigWig.py Datatype.py Gff3.py Gtf.py Psl.py TrackDb.py bigPsl.py cytoBand.py hubArchiveCreator.xml templates/trackDb/layout.txt util/subtools.py
diffstat 17 files changed, 138 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Bam.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/Bam.py	Mon Jul 03 17:30:20 2017 -0400
@@ -37,6 +37,7 @@
 
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = self.data_bam["group_name"]
+        self.database = self.data_bam["database"]
         if self.data_bam["long_label"]:
             self.long_label = self.data_bam["long_label"]
         else:
@@ -58,7 +59,8 @@
                          long_label=self.long_label, track_type='bam', visibility='pack', priority=self.priority,
                          track_file=bam_index_file_path,
                          track_color=self.track_color,
-                         group_name=self.group_name
+                         group_name=self.group_name,
+                         database=self.database
                          )
         #
         # dataURL = "tracks/%s" % self.name_bam
--- a/Bed.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/Bed.py	Mon Jul 03 17:30:20 2017 -0400
@@ -26,6 +26,7 @@
         self.track_color = self.data_bed_generic["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = self.data_bed_generic["group_name"]
+        self.database = self.data_bed_generic["database"]
         if self.data_bed_generic["long_label"]:
             self.long_label = self.data_bed_generic["long_label"]
         else:
@@ -42,7 +43,9 @@
         with open(myBigBedFilePath, 'w') as self.bigBedFile:
             subtools.bedToBigBed(self.sortedBedFile.name,
                                  self.chromSizesFile.name,
-                                 self.bigBedFile.name)
+                                 self.bigBedFile.name,
+                                 extraIndex='name'
+                                 )
 
         # Create the Track Object
         self.createTrack(file_path=trackName,
@@ -51,7 +54,8 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         # dataURL = "tracks/%s" % trackName
         #
--- a/BedBlastAlignments.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/BedBlastAlignments.py	Mon Jul 03 17:30:20 2017 -0400
@@ -21,6 +21,7 @@
         self.track_color = data_bed_blast_alignments["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_bed_blast_alignments["group_name"]
+        self.database = data_bed_blast_alignments["database"]
         if data_bed_blast_alignments["long_label"]:
             self.long_label = data_bed_blast_alignments["long_label"]
         else:
@@ -44,7 +45,8 @@
                                  bigBedFile.name,
                                  typeOption='bed12+12',
                                  tab='True',
-                                 autoSql=auto_sql_option)
+                                 autoSql=auto_sql_option,
+                                 extraIndex='name')
 
         self.createTrack(file_path=trackName,
                          track_name=trackName,
@@ -52,7 +54,9 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database
+                         )
 
 
         # dataURL = "tracks/%s" % trackName
--- a/BedSimpleRepeats.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/BedSimpleRepeats.py	Mon Jul 03 17:30:20 2017 -0400
@@ -20,6 +20,7 @@
         self.track_color = data_bed_simple_repeats["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_bed_simple_repeats["group_name"]
+        self.database = data_bed_simple_repeats["database"]
         if data_bed_simple_repeats["long_label"]:
             self.long_label = data_bed_simple_repeats["long_label"]
         else:
@@ -42,7 +43,9 @@
                                  self.chromSizesFile.name,
                                  bigBedFile.name,
                                  typeOption='bed4+12',
-                                 autoSql=auto_sql_option)
+                                 autoSql=auto_sql_option,
+                                 extraIndex='name'
+                                 )
 
         # Create the Track Object
         self.createTrack(file_path=trackName,
@@ -51,7 +54,8 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         # dataURL = "tracks/%s" % trackName
         #
--- a/BedSpliceJunctions.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/BedSpliceJunctions.py	Mon Jul 03 17:30:20 2017 -0400
@@ -20,6 +20,7 @@
         self.track_color = data_bed_splice_junctions["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_bed_splice_junctions["group_name"]
+        self.database = data_bed_splice_junctions["database"]
         if data_bed_splice_junctions["long_label"]:
             self.long_label = data_bed_splice_junctions["long_label"]
         else:
@@ -41,7 +42,9 @@
                                  self.chromSizesFile.name,
                                  bigBedFile.name,
                                  typeOption='bed12+1',
-                                 autoSql=auto_sql_option)
+                                 autoSql=auto_sql_option,
+                                 extraIndex='name'
+                                 )
 
         # Create the Track Object
         self.createTrack(file_path=trackName,
@@ -50,7 +53,8 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         # dataURL = "tracks/%s" % trackName
         #
--- a/BigBed.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/BigBed.py	Mon Jul 03 17:30:20 2017 -0400
@@ -21,6 +21,7 @@
         self.priority = data_bigbed["order_index"]
         self.track_color = data_bigbed["track_color"]
         self.group_name = data_bigbed["group_name"]
+        self.database = data_bigbed["database"]
 
         track_name = "".join((self.name_bigbed, ".bigbed"))
         if data_bigbed["long_label"]:
@@ -43,7 +44,8 @@
                          priority=self.priority,
                          track_file=bigbed_file_path,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         print "- BigBed %s created" % self.name_bigbed
 
--- a/BigWig.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/BigWig.py	Mon Jul 03 17:30:20 2017 -0400
@@ -23,6 +23,7 @@
         self.track_color = data_bigwig["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_bigwig["group_name"]
+        self.database = data_bigwig["database"]
         if data_bigwig["long_label"]:
             self.long_label = data_bigwig["long_label"]
         else:
@@ -43,7 +44,8 @@
                          priority=self.priority,
                          track_file=myBigWigFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database = self.database)
 
         print("- BigWig %s created" % self.name_bigwig)
         #print("- %s created in %s" % (trackName, myBigWigFilePath))
--- a/Datatype.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/Datatype.py	Mon Jul 03 17:30:20 2017 -0400
@@ -76,7 +76,7 @@
                     file_path=None,
                     track_name=None, long_label=None, thick_draw_item='off',
                     short_label=None, track_type=None, visibility=None, priority=None,
-                    track_file=None, track_color='#000000', group_name="Default"):
+                    track_file=None, track_color='#000000', group_name="Default", database=""):
 
         # TODO: Remove the hardcoded "tracks" by the value used as variable from myTrackFolderPath
         data_url = "tracks/%s" % file_path
@@ -97,7 +97,6 @@
 
         #sanitize the track_name
         sanitized_name = subtools.fixName(track_name)
-        
         track_db = TrackDb(
                 trackName=sanitized_name,
                 longLabel=long_label,
@@ -108,7 +107,8 @@
                 thickDrawItem=thick_draw_item,
                 priority=priority,
                 track_color=rgb_ucsc,
-                group_name=group_name
+                group_name=group_name,
+                database=database
         )
 
         # Return the Bam Track Object
--- a/Gff3.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/Gff3.py	Mon Jul 03 17:30:20 2017 -0400
@@ -22,6 +22,7 @@
         self.track_color = data_gff3["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_gff3["group_name"]
+        self.database = data_gff3["database"]
         if data_gff3["long_label"]:
             self.long_label = data_gff3["long_label"]
         else:
@@ -55,7 +56,8 @@
                                  bigBedFile.name,
                                  autoSql=auto_sql_option,
                                  typeOption='bed12+8',
-                                 tab=True)
+                                 tab=True,
+                                 extraIndex='name')
 
         # Create the Track Object
         self.createTrack(file_path=trackName,
@@ -65,6 +67,7 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         print("- Gff3 %s created" % self.name_gff3)
--- a/Gtf.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/Gtf.py	Mon Jul 03 17:30:20 2017 -0400
@@ -28,6 +28,7 @@
         self.track_color = data_gtf["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_gtf["group_name"]
+        self.database = data_gtf["database"]
         if data_gtf["long_label"]:
             self.long_label = data_gtf["long_label"]
         else:
@@ -66,7 +67,8 @@
                                  bigBedFile.name,
                                  autoSql=auto_sql_option,
                                  typeOption='bed12+8',
-                                 tab=True)
+                                 tab=True,
+                                 extraIndex='name')
 
 
         # Create the Track Object
@@ -76,7 +78,8 @@
                          visibility='dense', priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         # TODO: Use Logging instead of print
         if modified_gtf.is_modified:
--- a/Psl.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/Psl.py	Mon Jul 03 17:30:20 2017 -0400
@@ -19,6 +19,7 @@
         self.track_color = data_psl["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_psl["group_name"]
+        self.database = data_psl["database"]
         if data_psl["long_label"]:
             self.long_label = data_psl["long_label"]
         else:
@@ -48,7 +49,8 @@
                                  big_psl_file.name,
                                  autoSql=auto_sql_option,
                                  typeOption='bed12+12',
-                                 tab=True)
+                                 tab=True,
+                                 extraIndex='name')
 
         # Create the Track Object
         self.createTrack(file_path=trackName,
@@ -58,6 +60,7 @@
                          priority=self.priority,
                          track_file=my_big_psl_file_path,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         print("- BigPsl %s created" % self.name_psl)
\ No newline at end of file
--- a/TrackDb.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/TrackDb.py	Mon Jul 03 17:30:20 2017 -0400
@@ -4,7 +4,7 @@
     """docstring for TrackDb"""
 
     def __init__(self, trackName="", longLabel="", shortLabel="", trackDataURL="", trackType="", visibility="",
-                 thickDrawItem='off', priority="0", track_color="#000000", group_name="Default"):
+                 thickDrawItem='off', priority="0", track_color="#000000", group_name="Default", database=""):
         super(TrackDb, self).__init__()
 
         self.trackName = trackName
@@ -17,3 +17,5 @@
         self.priority = priority
         self.track_color = track_color
         self.group_name = group_name
+        self.database = database
+            
\ No newline at end of file
--- a/bigPsl.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/bigPsl.py	Mon Jul 03 17:30:20 2017 -0400
@@ -21,6 +21,7 @@
         self.track_color = data_bigpsl["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_bigpsl["group_name"]
+        self.database = data_bigpsl["database"]
         if data_bigpsl["long_label"]:
             self.long_label = data_bigpsl["long_label"]
         else:
@@ -44,7 +45,8 @@
                                  bigBedFile.name,
                                  typeOption='bed12+12',
                                  tab='True',
-                                 autoSql=auto_sql_option)
+                                 autoSql=auto_sql_option,
+                                 extraIndex='name')
 
         self.createTrack(file_path=trackName,
                          track_name=trackName,
@@ -52,7 +54,8 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
 
         # dataURL = "tracks/%s" % trackName
--- a/cytoBand.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/cytoBand.py	Mon Jul 03 17:30:20 2017 -0400
@@ -20,6 +20,7 @@
         self.track_color = data_bed_cytoBand["track_color"]
         # TODO: Think about how to avoid repetition of the group_name everywhere
         self.group_name = data_bed_cytoBand["group_name"]
+        self.database = data_bed_cytoBand["database"]
         if data_bed_cytoBand["long_label"]:
             self.long_label = data_bed_cytoBand["long_label"]
         else:
@@ -52,7 +53,8 @@
                          priority=self.priority,
                          track_file=myBigBedFilePath,
                          track_color=self.track_color,
-                         group_name=self.group_name)
+                         group_name=self.group_name,
+                         database=self.database)
 
         # dataURL = "tracks/%s" % trackName
         #
--- a/hubArchiveCreator.xml	Fri Jun 02 17:36:24 2017 -0400
+++ b/hubArchiveCreator.xml	Mon Jul 03 17:30:20 2017 -0400
@@ -73,7 +73,8 @@
                 #set track_color = str($f.formatChoice.track_color)
                 #set group_name = str($g.group_name)
                 #set longLabel = str($f.formatChoice.longLabel)
-                #set extra_data_dict = {"track_color": $track_color,
+                #set extra_data_dict = {"database": "",
+                                        "track_color": $track_color,
                                         "group_name": $group_name,
                                         "long_label": $longLabel}
 
@@ -109,11 +110,15 @@
                     #end if
                     #if $f.formatChoice.bedChoice.bed_select == "bed_blast_alignment_option"
                         --bedBlastAlignments $f.formatChoice.bedChoice.BED_blast_alignment
+                        #set database = str($f.formatChoice.bedChoice.database)
+                        #silent extra_data_dict.update({"database": $database})
                         #silent $prepare_json($f.formatChoice.bedChoice.BED_blast_alignment, $index_track_final,
                                              extra_data_dict)
                     #end if
                     #if $f.formatChoice.bedChoice.bed_select == "bed_blat_alignment_option"
                         --bigpsl $f.formatChoice.bedChoice.BED_blat_alignment
+                        #set database = str($f.formatChoice.bedChoice.database)
+                        #silent extra_data_dict.update({"database": $database})
                         #silent $prepare_json($f.formatChoice.bedChoice.BED_blat_alignment, $index_track_final,
                                              extra_data_dict)
                     #end if
@@ -204,7 +209,7 @@
                                 type="data"
                                 label="BAM File"
                         />
-                        <param name="longLabel" type="text" size="80" label="Track label" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <!-- TODO: Find a solution to avoid repetition and to generate a new color depending on the others -->
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
@@ -264,6 +269,12 @@
                                         type="data"
                                         label="Bed Blast Alignments (Bed12+12) File"
                                 />
+                                <param name="database" type="select" label="Protein database">
+                                    <option value="NCBI" selected="true">NCBI</option>
+                                    <option value="UniProt">UniProt</option>
+                                    <option value="FlyBase">FlyBase</option>
+                                    <option value="Others">Others</option>
+                                </param>
                             </when>
                             <when value="bed_blat_alignment_option">
                                 <param
@@ -272,9 +283,13 @@
                                         type="data"
                                         label="Bed BLAT Alignments (bigPsl) File"
                                 />
+                                <param name="database" type="select" label="mRNA database">
+                                    <option value="NCBI" selected="true">NCBI</option>
+                                    <option value="Others">Others</option>
+                                </param>
                             </when>
                         </conditional>
-                        <param name="longLabel" type="text" size="30" label="Track name" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
                                 <valid initial="string.letters,string.digits">
@@ -290,7 +305,7 @@
                                 type="data"
                                 label="PSL File"
                         />
-                        <param name="longLabel" type="text" size="30" label="Track name" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
                                 <valid initial="string.letters,string.digits">
@@ -306,7 +321,7 @@
                                 type="data"
                                 label="BIGWIG File"
                         />
-                        <param name="longLabel" type="text" size="30" label="Track name" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
                                 <valid initial="string.letters,string.digits">
@@ -322,7 +337,7 @@
                                 type="data"
                                 label="BIGBED File"
                         />
-                        <param name="longLabel" type="text" size="30" label="Track name" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
                                 <valid initial="string.letters,string.digits">
@@ -338,7 +353,7 @@
                                 type="data"
                                 label="GFF3 File"
                         />
-                        <param name="longLabel" type="text" size="30" label="Track name" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
                                 <valid initial="string.letters,string.digits">
@@ -354,7 +369,7 @@
                                 type="data"
                                 label="GTF File"
                         />
-                        <param name="longLabel" type="text" size="30" label="Track name" />
+                        <param name="longLabel" type="text" size="76" label="Track label" help="It is limited to 76 printable characters, the first 17 printable characters will be used as a short label of the track" />
                         <param name="track_color" type="color" label="Track color" value="#000000">
                             <sanitizer>
                                 <valid initial="string.letters,string.digits">
--- a/templates/trackDb/layout.txt	Fri Jun 02 17:36:24 2017 -0400
+++ b/templates/trackDb/layout.txt	Mon Jul 03 17:30:20 2017 -0400
@@ -14,6 +14,54 @@
 maxHeightPixels 100:32:8
 windowingFunction mean+whiskers
 
+    % elif "bigBed 12 +" in trackDb.trackType and trackDb.database:
+
+track ${trackDb.trackName}
+longLabel ${trackDb.longLabel}
+shortLabel ${trackDb.shortLabel}
+bigDataUrl ${trackDb.trackDataURL}
+type ${trackDb.trackType}
+visibility ${trackDb.visibility}
+thickDrawItem ${trackDb.thickDrawItem}
+priority ${trackDb.priority}
+color ${trackDb.track_color}
+group ${trackDb.group_name.lower().replace(' ', '_')}
+searchIndex name
+        % if "NCBI" in trackDb.database:
+url https://www.ncbi.nlm.nih.gov/protein/$$
+urlLabel ${trackDb.database} Details:
+        % elif "UniProt" in trackDb.database:
+url http://www.uniprot.org/uniprot/$$
+urlLabel ${trackDb.database} Details:
+        % elif "FlyBase" in trackDb.database:
+url http://flybase.org/reports/$$
+urlLabel ${trackDb.database} Details:
+        % else:
+url https://www.ncbi.nlm.nih.gov/gquery/?term=$$
+urlLabel NCBI Details:
+        % endif
+        
+    % elif "bigPsl" in trackDb.trackType and trackDb.database:
+    
+track ${trackDb.trackName}
+longLabel ${trackDb.longLabel}
+shortLabel ${trackDb.shortLabel}
+bigDataUrl ${trackDb.trackDataURL}
+type ${trackDb.trackType}
+visibility ${trackDb.visibility}
+thickDrawItem ${trackDb.thickDrawItem}
+priority ${trackDb.priority}
+color ${trackDb.track_color}
+group ${trackDb.group_name.lower().replace(' ', '_')}
+searchIndex name
+    % if "NCBI" in trackDb.database:
+url https://www.ncbi.nlm.nih.gov/nuccore/$$
+urlLabel NCBI Details:
+    % else:
+url https://www.ncbi.nlm.nih.gov/gquery/?term=$$
+urlLabel NCBI Details:
+    % endif
+
     % else:
 
 ## See this http://genome.ucsc.edu/goldenPath/help/hgTrackHubHelp.html
@@ -27,6 +75,6 @@
 priority ${trackDb.priority}
 color ${trackDb.track_color}
 group ${trackDb.group_name.lower().replace(' ', '_')}
-
+searchIndex name
     % endif
 % endfor
--- a/util/subtools.py	Fri Jun 02 17:36:24 2017 -0400
+++ b/util/subtools.py	Mon Jul 03 17:30:20 2017 -0400
@@ -182,7 +182,7 @@
     return p
 
 def bedToBigBed(sorted_bed_file_name, chrom_sizes_file_name, big_bed_file_name,
-                typeOption=None, autoSql=None, tab=False):
+                typeOption=None, autoSql=None, tab=False, extraIndex=None):
     """
     Call bedToBigBed on sorted_bed_file_name, using chrom_sizes_file_name and write the result into big_bed_file_name
     :param sorted_bed_file_name:
@@ -209,6 +209,9 @@
         array_call.append(autoSql)
     if tab:
         array_call.append('-tab')
+    if extraIndex:
+        index = ''.join(['-extraIndex=', extraIndex])
+        array_call.append(index)
 
     p = _handleExceptionAndCheckCall(array_call)
     return p