# HG changeset patch
# User rmarenco
# Date 1475262864 14400
# Node ID c02720d1afee66a6a3d53b011e462c54cbc0d149
# Parent 3233451a3bd6e188873b6b7d03f4f9210ff1e3e2
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
diff -r 3233451a3bd6 -r c02720d1afee Bam.py
--- a/Bam.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Bam.py Fri Sep 30 15:14:24 2016 -0400
@@ -32,12 +32,11 @@
self.priority = self.data_bam["order_index"]
self.index_bam = self.data_bam["index"]
- # TODO: Think about how to avoir repetition of the color treatment
+ # TODO: Think about how to avoid repetition of the color treatment
self.track_color = self.data_bam["track_color"]
- logging.debug("Color of bam: {0}".format(self.track_color))
-
- #print "Creating TrackHub BAM from (falsePath: %s; name: %s)" % ( self.input_bam_false_path, self.name_bam)
+ # TODO: Think about how to avoid repetition of the group_name everywhere
+ self.group_name = self.data_bam["group_name"]
# First: Add the bam file
# Second: Add the bam index file, in the same folder (https://genome.ucsc.edu/goldenpath/help/bam.html)
@@ -55,7 +54,9 @@
track_name=self.name_bam,
long_label=self.name_bam, track_type='bam', visibility='pack', priority=self.priority,
track_file=bam_index_file_path,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name
+ )
#
# dataURL = "tracks/%s" % self.name_bam
#
diff -r 3233451a3bd6 -r c02720d1afee Bam.pyc
Binary file Bam.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee Bed.py
--- a/Bed.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Bed.py Fri Sep 30 15:14:24 2016 -0400
@@ -24,6 +24,9 @@
self.name_bed_generic = self.data_bed_generic["name"]
self.priority = self.data_bed_generic["order_index"]
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"]
+
# Sort processing
subtools.sort(self.inputBedGeneric, self.sortedBedFile.name)
@@ -44,7 +47,8 @@
long_label=self.name_bed_generic, track_type='bigBed', visibility='dense',
priority=self.priority,
track_file=myBigBedFilePath,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name)
# dataURL = "tracks/%s" % trackName
#
diff -r 3233451a3bd6 -r c02720d1afee Bed.pyc
Binary file Bed.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee BedSimpleRepeats.py
--- a/BedSimpleRepeats.py Sun Sep 25 11:25:38 2016 -0400
+++ b/BedSimpleRepeats.py Fri Sep 30 15:14:24 2016 -0400
@@ -18,6 +18,8 @@
self.name_bed_simple_repeats = data_bed_simple_repeats["name"]
self.priority = data_bed_simple_repeats["order_index"]
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"]
sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed")
@@ -44,7 +46,8 @@
long_label=self.name_bed_simple_repeats, track_type='bigBed 4 +', visibility='dense',
priority=self.priority,
track_file=myBigBedFilePath,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name)
# dataURL = "tracks/%s" % trackName
#
diff -r 3233451a3bd6 -r c02720d1afee BedSimpleRepeats.pyc
Binary file BedSimpleRepeats.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee BigWig.py
--- a/BigWig.py Sun Sep 25 11:25:38 2016 -0400
+++ b/BigWig.py Fri Sep 30 15:14:24 2016 -0400
@@ -19,6 +19,8 @@
self.name_bigwig = data_bigwig["name"]
self.priority = data_bigwig["order_index"]
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"]
#print "Creating TrackHub BigWig from (falsePath: %s; name: %s)" % ( self.input_bigwig_path, self.name_bigwig )
@@ -34,7 +36,8 @@
track_type='bigWig', visibility='full',
priority=self.priority,
track_file=myBigWigFilePath,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name)
# dataURL = "tracks/%s" % trackName
#
diff -r 3233451a3bd6 -r c02720d1afee BigWig.pyc
Binary file BigWig.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee Datatype.py
--- a/Datatype.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Datatype.py Fri Sep 30 15:14:24 2016 -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'):
+ track_file=None, track_color='#000000', group_name="Default"):
# TODO: Remove the hardcoded "tracks" by the value used as variable from myTrackFolderPath
data_url = "tracks/%s" % file_path
@@ -104,7 +104,8 @@
visibility=visibility,
thickDrawItem=thick_draw_item,
priority=priority,
- track_color=rgb_ucsc
+ track_color=rgb_ucsc,
+ group_name=group_name
)
# Return the Bam Track Object
diff -r 3233451a3bd6 -r c02720d1afee Datatype.pyc
Binary file Datatype.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee Gff3.py
--- a/Gff3.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Gff3.py Fri Sep 30 15:14:24 2016 -0400
@@ -20,6 +20,8 @@
self.name_gff3 = data_gff3["name"]
self.priority = data_gff3["order_index"]
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"]
# TODO: See if we need these temporary files as part of the generated files
unsorted_genePred_file = tempfile.NamedTemporaryFile(bufsize=0, suffix=".genePred")
@@ -59,6 +61,7 @@
track_type='bigGenePred', visibility='dense',
priority=self.priority,
track_file=myBigBedFilePath,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name)
print("- Gff3 %s created" % self.name_gff3)
diff -r 3233451a3bd6 -r c02720d1afee Gff3.pyc
Binary file Gff3.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee Gtf.py
--- a/Gtf.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Gtf.py Fri Sep 30 15:14:24 2016 -0400
@@ -21,6 +21,8 @@
self.name_gtf = data_gtf["name"]
self.priority = data_gtf["order_index"]
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"]
#print "Creating TrackHub GTF from (falsePath: %s; name: %s)" % ( self.input_gtf_false_path, self.name_gtf)
@@ -61,6 +63,7 @@
long_label=self.name_gtf, track_type='bigGenePred',
visibility='dense', priority=self.priority,
track_file=myBigBedFilePath,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name)
print("- Gtf %s created" % self.name_gtf)
diff -r 3233451a3bd6 -r c02720d1afee Gtf.pyc
Binary file Gtf.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee Psl.py
--- a/Psl.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Psl.py Fri Sep 30 15:14:24 2016 -0400
@@ -17,6 +17,8 @@
self.name_psl = data_psl["name"]
self.priority = data_psl["order_index"]
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"]
# Temporary files
unsorted_bed_formatted_psl_file = tempfile.NamedTemporaryFile(suffix='.psl')
@@ -52,6 +54,7 @@
track_type='bigPsl', visibility='dense',
priority=self.priority,
track_file=my_big_psl_file_path,
- track_color=self.track_color)
+ track_color=self.track_color,
+ group_name=self.group_name)
print("- BigPsl %s created" % self.name_psl)
\ No newline at end of file
diff -r 3233451a3bd6 -r c02720d1afee Psl.pyc
Binary file Psl.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee Track.py
--- a/Track.py Sun Sep 25 11:25:38 2016 -0400
+++ b/Track.py Fri Sep 30 15:14:24 2016 -0400
@@ -1,6 +1,6 @@
#!/usr/bin/python
-
+# TODO: Is this still useful?
class Track(object):
"""Class to manage the track informations needed for Track Hub, in the TrackDb text file"""
diff -r 3233451a3bd6 -r c02720d1afee Track.pyc
Binary file Track.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee TrackDb.py
--- a/TrackDb.py Sun Sep 25 11:25:38 2016 -0400
+++ b/TrackDb.py Fri Sep 30 15:14:24 2016 -0400
@@ -4,7 +4,7 @@
"""docstring for TrackDb"""
def __init__(self, trackName="", longLabel="", shortLabel="", trackDataURL="", trackType="", visibility="",
- thickDrawItem='off', priority="0", track_color="#000000"):
+ thickDrawItem='off', priority="0", track_color="#000000", group_name="Default"):
super(TrackDb, self).__init__()
self.trackName = trackName
@@ -16,3 +16,4 @@
self.thickDrawItem = thickDrawItem
self.priority = priority
self.track_color = track_color
+ self.group_name = group_name
diff -r 3233451a3bd6 -r c02720d1afee TrackDb.pyc
Binary file TrackDb.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee TrackHub.py
--- a/TrackHub.py Sun Sep 25 11:25:38 2016 -0400
+++ b/TrackHub.py Fri Sep 30 15:14:24 2016 -0400
@@ -33,11 +33,23 @@
self.default_pos = None
self.user_email = user_email
+ # Set containing the groups already added. Updated by addGroup()
+ self.groups = set()
+
# TODO: Modify according to the files passed in parameter
+ # ---- Templates ----
+ # Template trackDb
mylookup = TemplateLookup(directories=[os.path.join(tool_directory, 'templates/trackDb')],
output_encoding='utf-8', encoding_errors='replace')
self.trackDbTemplate = mylookup.get_template("layout.txt")
+ # Template groups
+ mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/groupsTxt')],
+ output_encoding='utf-8', encoding_errors='replace')
+ self.groupsTemplate = mylookup.get_template("layout.txt")
+
+ # ---- End Templates ----
+
self.extra_files_path = extra_files_path
self.outputFile = outputFile
@@ -68,16 +80,43 @@
def addTrack(self, trackDbObject=None):
# Create the trackDb.txt file in the specie folder, if not exists
# Else append the new track
+ # TODO: Get this out of the function
trackDbTxtFilePath = os.path.join(self.mySpecieFolderPath, 'trackDb.txt')
# Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object
with open(trackDbTxtFilePath, 'a+') as trackDbFile:
trackDbs = [trackDbObject]
+
+ # TODO: The addGroup does not belong here. Move it when the group becomes more than just a label
+ # Add the group as well, if exists in trackDbObject
+ self.addGroup(trackDbObject.group_name)
+
htmlMakoRendered = self.trackDbTemplate.render(
trackDbs=trackDbs
)
trackDbFile.write(htmlMakoRendered)
+ def addGroup(self, group_name="Default"):
+ # If not already present in self.groups, add to groups.txt
+ # Create the trackDb.txt file in the specie folder, if not exists
+ # Else append the new track
+ # TODO: Get this out of the function
+ groupsTxtFilePath = os.path.join(self.mySpecieFolderPath, 'groups.txt')
+
+ # If the group is already present, we don't need to add it
+ if group_name in self.groups:
+ return
+
+ # Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object
+ with open(groupsTxtFilePath, 'a+') as groupFile:
+ # Add the group as well, if exists in trackDbObject
+
+ htmlMakoRendered = self.groupsTemplate.render(
+ label=group_name
+ )
+ groupFile.write(htmlMakoRendered)
+ self.groups.add(group_name)
+
def terminate(self):
# Just a test to output a simple HTML
# TODO: Create a class to handle the file object
@@ -182,8 +221,8 @@
# Create the file groups.txt
# TODO: If not inputs for this, do no create the file
- groupsTxtFilePath = os.path.join(mySpecieFolderPath, 'groups.txt')
- self.__fillGroupsTxtFile__(groupsTxtFilePath)
+ # groupsTxtFilePath = os.path.join(mySpecieFolderPath, 'groups.txt')
+ # self.__fillGroupsTxtFile__(groupsTxtFilePath)
# Create the folder tracks into the specie folder
tracksFolderPath = os.path.join(mySpecieFolderPath, "tracks")
diff -r 3233451a3bd6 -r c02720d1afee TrackHub.pyc
Binary file TrackHub.pyc has changed
diff -r 3233451a3bd6 -r c02720d1afee hubArchiveCreator.py
--- a/hubArchiveCreator.py Sun Sep 25 11:25:38 2016 -0400
+++ b/hubArchiveCreator.py Fri Sep 30 15:14:24 2016 -0400
@@ -126,7 +126,6 @@
# We remove the spaces in ["name"] of inputs_data
sanitize_name_inputs(inputs_data)
-
# TODO: Check here all the binaries / tools we need. Exception if missing
# Create the Track Hub folder
diff -r 3233451a3bd6 -r c02720d1afee hubArchiveCreator.xml
--- a/hubArchiveCreator.xml Sun Sep 25 11:25:38 2016 -0400
+++ b/hubArchiveCreator.xml Fri Sep 30 15:14:24 2016 -0400
@@ -12,7 +12,8 @@
ucsc-genepredtobiggenepred
ucsc-gff3togenepred
ucsc-gtftogenepred
- ucsc-psltobigpsl
+
+
ucsc-twobitinfo
samtools
@@ -21,6 +22,7 @@
gtfToGenePred
genePredToBed
genePredToBigGenePred
+ pslToBigPsl
samtools
@@ -60,48 +62,59 @@
#end def
- #for $i, $f in enumerate( $format )
- #set track_color = str($f.formatChoice.track_color)
+ #for $i_g, $g in enumerate( $group )
+ #for $i, $f in enumerate( $g.format )
+
+ ## For each format, we have a few mandatory fields we store in a dict
+ #set track_color = str($f.formatChoice.track_color)
+ #set group_name = str($g.group_name)
- #if $f.formatChoice.format_select == "bam"
- --bam $f.formatChoice.BAM
- #set bam_index = $f.formatChoice.BAM.metadata.bam_index
- #silent $prepare_json($f.formatChoice.BAM, $i, {"index": $bam_index,
- "track_color": $track_color})
- #end if
- #if $f.formatChoice.format_select == "bed"
- #if $f.formatChoice.bedChoice.bed_select == "bed"
- --bed $f.formatChoice.bedChoice.BED
- #silent $prepare_json($f.formatChoice.bedChoice.BED, $i,
- {"track_color": $track_color})
- #end if
- #if $f.formatChoice.bedChoice.bed_select == "bed_simple_repeats_option"
- --bedSimpleRepeats $f.formatChoice.bedChoice.BED_simple_repeats
- #silent $prepare_json($f.formatChoice.bedChoice.BED_simple_repeats, $i,
- {"track_color": $track_color})
+ #set extra_data_dict = {"track_color": $track_color,
+ "group_name": $group_name}
+
+ #if $f.formatChoice.format_select == "bam"
+ --bam $f.formatChoice.BAM
+ #set bam_index = $f.formatChoice.BAM.metadata.bam_index
+
+ ## Add Bam format specific fields
+ #silent extra_data_dict.update({"index": $bam_index})
+
+ #silent $prepare_json($f.formatChoice.BAM, $i, extra_data_dict)
#end if
- #end if
- #if $f.formatChoice.format_select == "psl"
- --psl $f.formatChoice.PSL
- #silent $prepare_json($f.formatChoice.PSL, $i,
- {"track_color": $track_color})
- #end if
- #if $f.formatChoice.format_select == "bigwig"
- --bigwig $f.formatChoice.BIGWIG
- #silent $prepare_json($f.formatChoice.BIGWIG, $i,
- {"track_color": $track_color})
- #end if
- #if $f.formatChoice.format_select == "gff3"
- --gff3 $f.formatChoice.GFF3
- #silent $prepare_json($f.formatChoice.GFF3, $i,
- {"track_color": $track_color})
- #end if
- #if $f.formatChoice.format_select == "gtf"
- ## Add also GTF from Agustus? See https://github.com/ENCODE-DCC/kentUtils/issues/8
- --gtf $f.formatChoice.GTF
- #silent $prepare_json($f.formatChoice.GTF, $i,
- {"track_color": $track_color})
- #end if
+ #if $f.formatChoice.format_select == "bed"
+ #if $f.formatChoice.bedChoice.bed_select == "bed"
+ --bed $f.formatChoice.bedChoice.BED
+ #silent $prepare_json($f.formatChoice.bedChoice.BED, $i,
+ extra_data_dict)
+ #end if
+ #if $f.formatChoice.bedChoice.bed_select == "bed_simple_repeats_option"
+ --bedSimpleRepeats $f.formatChoice.bedChoice.BED_simple_repeats
+ #silent $prepare_json($f.formatChoice.bedChoice.BED_simple_repeats, $i,
+ extra_data_dict)
+ #end if
+ #end if
+ #if $f.formatChoice.format_select == "psl"
+ --psl $f.formatChoice.PSL
+ #silent $prepare_json($f.formatChoice.PSL, $i,
+ extra_data_dict)
+ #end if
+ #if $f.formatChoice.format_select == "bigwig"
+ --bigwig $f.formatChoice.BIGWIG
+ #silent $prepare_json($f.formatChoice.BIGWIG, $i,
+ extra_data_dict)
+ #end if
+ #if $f.formatChoice.format_select == "gff3"
+ --gff3 $f.formatChoice.GFF3
+ #silent $prepare_json($f.formatChoice.GFF3, $i,
+ extra_data_dict)
+ #end if
+ #if $f.formatChoice.format_select == "gtf"
+ ## Add also GTF from Agustus? See https://github.com/ENCODE-DCC/kentUtils/issues/8
+ --gtf $f.formatChoice.GTF
+ #silent $prepare_json($f.formatChoice.GTF, $i,
+ extra_data_dict)
+ #end if
+ #end for
#end for
## We combine the fasta file dataset name with his false path in a JSON object
@@ -139,126 +152,129 @@
type="data"
label="Reference genome"
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 3233451a3bd6 -r c02720d1afee templates/groupsTxt/layout.txt
--- a/templates/groupsTxt/layout.txt Sun Sep 25 11:25:38 2016 -0400
+++ b/templates/groupsTxt/layout.txt Fri Sep 30 15:14:24 2016 -0400
@@ -1,4 +1,5 @@
-name ${mapName}
-label ${labelMapping}
-priority ${prioriy}
-defaultIsClosed ${isClosed}
+name ${label.lower().replace(' ', '_')}
+label ${label}
+priority 2
+defaultIsClosed 0
+
diff -r 3233451a3bd6 -r c02720d1afee templates/trackDb/layout.txt
--- a/templates/trackDb/layout.txt Sun Sep 25 11:25:38 2016 -0400
+++ b/templates/trackDb/layout.txt Fri Sep 30 15:14:24 2016 -0400
@@ -9,5 +9,6 @@
thickDrawItem ${trackDb.thickDrawItem}
priority ${trackDb.priority}
color ${trackDb.track_color}
+ group ${trackDb.group_name.lower().replace(' ', '_')}
% endfor
diff -r 3233451a3bd6 -r c02720d1afee tool_dependencies.xml
--- a/tool_dependencies.xml Sun Sep 25 11:25:38 2016 -0400
+++ b/tool_dependencies.xml Fri Sep 30 15:14:24 2016 -0400
@@ -105,4 +105,27 @@
The tools downloaded by this dependency definition are free for academic use.
+
+
+
+
+
+
+
+ http://hgdownload.cse.ucsc.edu/admin/exe/macOSX.${architecture}/pslToBigPsl
+
+
+ http://hgdownload.cse.ucsc.edu/admin/exe/linux.${architecture}/pslToBigPsl
+
+
+
+ $INSTALL_DIR/bin/pslToBigPsl
+
+
+ $INSTALL_DIR/bin
+
+
+
+ The tools downloaded by this dependency definition are free for academic use.
+