Mercurial > repos > rmarenco > hubarchivecreator
changeset 21:884ee2a71680 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
author | yating-l |
---|---|
date | Wed, 12 Apr 2017 15:05:33 -0400 |
parents | 40469b265ddb |
children | 7ddf651457df |
files | Bam.py Bam.pyc Bed.pyc BedBlastAlignments.py BedBlastAlignments.pyc BedSimpleRepeats.pyc BedSpliceJunctions.pyc BigWig.pyc Datatype.py Datatype.pyc bigPsl.py bigPsl.pyc hubArchiveCreator.py hubArchiveCreator.xml util/subtools.py util/subtools.pyc |
diffstat | 16 files changed, 133 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Bam.py Fri Jan 20 17:12:03 2017 -0500 +++ b/Bam.py Wed Apr 12 15:05:33 2017 -0400 @@ -12,7 +12,7 @@ from Datatype import Datatype from Track import Track from TrackDb import TrackDb -from util import subtools + class Bam( Datatype ):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BedBlastAlignments.py Wed Apr 12 15:05:33 2017 -0400 @@ -0,0 +1,73 @@ +#!/usr/bin/python + +import os +import tempfile +import string + +from Datatype import Datatype +from Track import Track +from TrackDb import TrackDb +from util import subtools + + +class BedBlastAlignments( Datatype ): + def __init__(self, input_bed_blast_alignments_false_path, data_bed_blast_alignments): + + super(BedBlastAlignments, self).__init__() + + self.input_bed_blast_alignments_false_path = input_bed_blast_alignments_false_path + self.name_bed_blast_alignments = data_bed_blast_alignments["name"] + self.priority = data_bed_blast_alignments["order_index"] + 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"] + + #sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") + + # Sort processing + #subtools.sort(self.input_bigpsl_false_path, sortedBedFile.name) + + # bedToBigBed processing + # TODO: Change the name of the bb, to tool + genome + .bb + trackName = "".join( ( self.name_bed_blast_alignments, '.bb' ) ) + + myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) + + auto_sql_option = os.path.join(self.tool_directory, 'bigPsl.as') + + with open(myBigBedFilePath, 'w') as bigBedFile: + subtools.bedToBigBed(self.input_bed_blast_alignments_false_path, + self.chromSizesFile.name, + bigBedFile.name, + typeOption='bed12+12', + tab='True', + autoSql=auto_sql_option) + + self.createTrack(file_path=trackName, + track_name=trackName, + long_label=self.name_bed_blast_alignments, track_type='bigBed 12 +', visibility='dense', + priority=self.priority, + track_file=myBigBedFilePath, + track_color=self.track_color, + group_name=self.group_name) + + + # dataURL = "tracks/%s" % trackName + # + # trackDb = TrackDb( + # trackName=trackName, + # longLabel=self.name_bed_simple_repeats, + # shortLabel=self.getShortName( self.name_bed_simple_repeats ), + # trackDataURL=dataURL, + # trackType='bigBed 4 +', + # visibility='dense', + # priority=self.priority, + # ) + # + # self.track = Track( + # trackFile=myBigBedFilePath, + # trackDb=trackDb, + # ) + + print("- Bed Blast alignments %s created" % self.name_bed_blast_alignments) + #print("- %s created in %s" % (trackName, myBigBedFilePath))
--- a/Datatype.py Fri Jan 20 17:12:03 2017 -0500 +++ b/Datatype.py Wed Apr 12 15:05:33 2017 -0400 @@ -95,8 +95,11 @@ rgb_array = [int(hexa_without_sharp[i:i+2], 16) for i in (0, 2, 4)] rgb_ucsc = ','.join(map(str, rgb_array)) + #sanitize the track_name + sanitized_name = subtools.fixName(track_name) + track_db = TrackDb( - trackName=track_name, + trackName=sanitized_name, longLabel=long_label, shortLabel=short_label, trackDataURL=data_url,
--- a/bigPsl.py Fri Jan 20 17:12:03 2017 -0500 +++ b/bigPsl.py Wed Apr 12 15:05:33 2017 -0400 @@ -2,6 +2,7 @@ import os import tempfile +import string from Datatype import Datatype from Track import Track @@ -29,6 +30,7 @@ # bedToBigBed processing # TODO: Change the name of the bb, to tool + genome + .bb trackName = "".join( ( self.name_bigpsl, '.bb' ) ) + myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) auto_sql_option = os.path.join(self.tool_directory, 'bigPsl.as') @@ -41,15 +43,15 @@ tab='True', autoSql=auto_sql_option) - # Create the Track Object self.createTrack(file_path=trackName, track_name=trackName, - long_label=self.name_bigpsl, track_type='bigBed 12 +', visibility='dense', + long_label=self.name_bigpsl, track_type='bigPsl', visibility='dense', priority=self.priority, track_file=myBigBedFilePath, track_color=self.track_color, group_name=self.group_name) + # dataURL = "tracks/%s" % trackName # # trackDb = TrackDb(
--- a/hubArchiveCreator.py Fri Jan 20 17:12:03 2017 -0500 +++ b/hubArchiveCreator.py Wed Apr 12 15:05:33 2017 -0400 @@ -28,6 +28,7 @@ from Psl import Psl from TrackHub import TrackHub from bigPsl import bigPsl +from BedBlastAlignments import BedBlastAlignments # TODO: Verify each subprocessed dependency is accessible [gff3ToGenePred, genePredToBed, twoBitInfo, faToTwoBit, bedToBigBed, sort @@ -54,8 +55,11 @@ # Generic Bed (Blastx transformed to bed) parser.add_argument('--bed', action='append', help='Bed generic format') - # Bed12+12 (tblastn) - parser.add_argument('--bigpsl', action='append', help='bigPsl format') + # BigPsl (blat alignment) + parser.add_argument('--bigpsl', action='append', help='bigPsl format, using bigPsl.as') + + # Bed12+12 (tblastn alignment) + parser.add_argument('--bedBlastAlignments', action='append', help='Bed12+12 format, using bigPsl.as') # BigWig Management parser.add_argument('--bigwig', action='append', help='BigWig format') @@ -127,6 +131,7 @@ array_inputs_gtf = args.gtf array_inputs_psl = args.psl array_inputs_bigpsl = args.bigpsl + array_inputs_bed_blast_alignments = args.bedBlastAlignments outputFile = args.output @@ -153,7 +158,8 @@ (array_inputs_gff3, Gff3), (array_inputs_gtf, Gtf), (array_inputs_psl, Psl), - (array_inputs_bigpsl, bigPsl)]: + (array_inputs_bigpsl, bigPsl), + (array_inputs_bed_blast_alignments, BedBlastAlignments)]: if inputs: all_datatype_dictionary.update(create_ordered_datatype_objects(datatype_class, inputs, inputs_data))
--- a/hubArchiveCreator.xml Fri Jan 20 17:12:03 2017 -0500 +++ b/hubArchiveCreator.xml Wed Apr 12 15:05:33 2017 -0400 @@ -1,4 +1,4 @@ -<tool id="hubArchiveCreator" name="Hub Archive Creator" version="2.3.0"> +<tool id="hubArchiveCreator" name="Hub Archive Creator" version="2.3.1"> <description> This Galaxy tool permits to prepare your files to be ready for Assembly Hub visualization. @@ -99,10 +99,10 @@ #silent $prepare_json($f.formatChoice.bedChoice.BED_splice_junctions, $index_track_final, extra_data_dict) #end if - #if $f.formatChoice.bedChoice.bed_select == "bigpsl_option" - --bigpsl $f.formatChoice.bedChoice.bigPsl - #silent $prepare_json($f.formatChoice.bedChoice.bigPsl, $index_track_final, - extra_data_dict) + #if $f.formatChoice.bedChoice.bed_select == "bed_blast_alignment_option" + --bedBlastAlignments $f.formatChoice.bedChoice.BED_blast_alignment + #silent $prepare_json($f.formatChoice.bedChoice.BED_blast_alignment, $index_track_final, + extra_data_dict) #end if #end if #if $f.formatChoice.format_select == "psl" @@ -126,6 +126,11 @@ #silent $prepare_json($f.formatChoice.GTF, $index_track_final, extra_data_dict) #end if + #if $f.formatChoice.format_select == "bigpsl" + --bigpsl $f.formatChoice.BIGPSL + #silent $prepare_json($f.formatChoice.BIGPSL, $index_track_final, + extra_data_dict) + #end if #end for #end for @@ -176,6 +181,7 @@ <option value="bigwig">BIGWIG</option> <option value="gff3">GFF3</option> <option value="gtf">GTF</option> + <option value="bigpsl">BigPsl</option> </param> <when value="bam"> @@ -193,14 +199,14 @@ </valid> </sanitizer> </param> - </when> + </when> <when value="bed"> <conditional name="bedChoice"> <param name="bed_select" type="select" label="Bed Choice"> <option value="bed_generic" selected="true">BED Generic (bed3+)</option> <option value="bed_simple_repeats_option">BED Simple repeat (bed4+12 / simpleRepeat.as)</option> <option value="bed_splice_junctions_option">BED Splice junctions (bed12+1 / spliceJunctions.as)</option> - <option value="bigpsl_option">bigPsl (bed12+12 / bigPsl.as)</option> + <option value="bed_blast_alignment_option">BED Blast alignments (bed12+12 / bigPsl.as)</option> </param> <when value="bed_generic"> <param @@ -227,12 +233,12 @@ label="Bed Splice Junctions (Bed12+1) File" /> </when> - <when value="bigpsl_option"> + <when value="bed_blast_alignment_option"> <param format="bed" - name="bigPsl" + name="BED_blast_alignment" type="data" - label="bigPsl (Bed12+12) File" + label="Bed Blast Alignments (Bed12+12) File" /> </when> </conditional> @@ -304,6 +310,21 @@ </sanitizer> </param> </when> + <when value="bigpsl"> + <param + format="bigpsl" + name="BIGPSL" + type="data" + label="bigPsl File" + /> + <param name="track_color" type="color" label="Track color" value="#000000"> + <sanitizer> + <valid initial="string.letters,string.digits"> + <add value="#"/> + </valid> + </sanitizer> + </param> + </when> </conditional> </repeat> </repeat>
--- a/util/subtools.py Fri Jan 20 17:12:03 2017 -0500 +++ b/util/subtools.py Wed Apr 12 15:05:33 2017 -0400 @@ -10,6 +10,7 @@ import os import subprocess import sys +import string class PopenError(Exception): def __init__(self, cmd, error, return_code): @@ -243,3 +244,13 @@ p = _handleExceptionAndCheckCall(array_call) return p + +#santitize trackName. Because track name must begin with a letter and +# contain only the following chars: [a-zA-Z0-9_]. +# See the "track" Common settings at: +#https://genome.ucsc.edu/goldenpath/help/trackDb/trackDbHub.html#bigPsl_-_Pairwise_Alignments +def fixName(filename): + valid_chars = "_%s%s" % (string.ascii_letters, string.digits) + sanitize_name = ''.join([c if c in valid_chars else '_' for c in filename]) + sanitize_name = "gonramp_" + sanitize_name + return sanitize_name