Mercurial > repos > iuc > jbrowse
changeset 5:ae9382cfb6ac draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
author | iuc |
---|---|
date | Sat, 25 Jun 2016 15:06:43 -0400 |
parents | d022577ff9cf |
children | ecbdfc775b9a |
files | jbrowse.py jbrowse.xml macros.xml test-data/frameshift/1.gff test-data/frameshift/test.xml test-data/gff3/test.xml tool_dependencies.xml |
diffstat | 7 files changed, 265 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/jbrowse.py Fri Jan 29 13:27:30 2016 -0500 +++ b/jbrowse.py Sat Jun 25 15:06:43 2016 -0400 @@ -79,11 +79,11 @@ """, 'blast': """ var opacity = 0; - if(score == 0.0) { + if(score == 0.0) {{ opacity = 1; - } else{ + }} else {{ opacity = (20 - Math.log10(score)) / 180; - } + }} """ } @@ -150,7 +150,7 @@ return '#%02x%02x%02x' % (r, g, b) def _get_colours(self): - r, g, b = self.BREWER_COLOUR_SCHEMES[self.brewer_colour_idx] + r, g, b = self.BREWER_COLOUR_SCHEMES[self.brewer_colour_idx % len(self.BREWER_COLOUR_SCHEMES)] self.brewer_colour_idx += 1 return r, g, b @@ -206,11 +206,11 @@ min_val = 0 max_val = 1000 # Get min/max and build a scoring function since JBrowse doesn't - if scales['type'] == 'automatic': + if scales['type'] == 'automatic' or scales['type'] == '__auto__': min_val, max_val = self.min_max_gff(gff3) else: - min_val = scales['min'] - max_val = scales['max'] + min_val = scales.get('min', 0) + max_val = scales.get('max', 1000) if scheme['color'] == '__auto__': user_color = 'undefined' @@ -316,17 +316,20 @@ 'perl', self._jbrowse_bin('prepare-refseqs.pl'), '--fasta', genome_path]) - def _add_json(self, json_data): - if len(json_data.keys()) == 0: - return + # Generate name + # self.subprocess_check_call([ + # 'perl', self._jbrowse_bin('generate-names.pl'), + # '--hashBits', '16' + # ]) - tmp = tempfile.NamedTemporaryFile(delete=False) - tmp.write(json.dumps(json_data)) - tmp.close() - cmd = ['perl', self._jbrowse_bin('add-track-json.pl'), tmp.name, - os.path.join('data', 'trackList.json')] + def _add_json(self, json_data): + + cmd = [ + 'perl', self._jbrowse_bin('add-json.pl'), + json.dumps(json_data), + os.path.join('data', 'trackList.json') + ] self.subprocess_check_call(cmd) - os.unlink(tmp.name) def _add_track_json(self, json_data): if len(json_data.keys()) == 0: @@ -353,7 +356,7 @@ def add_blastxml(self, data, trackData, blastOpts, **kwargs): gff3 = self._blastxml_to_gff3(data, min_gap=blastOpts['min_gap']) - if 'parent' in blastOpts: + if 'parent' in blastOpts and blastOpts['parent'] != 'None': gff3_rebased = tempfile.NamedTemporaryFile(delete=False) cmd = ['python', os.path.join(INSTALLED_TO, 'gff3_rebase.py')] if blastOpts.get('protein', 'false') == 'true': @@ -457,7 +460,7 @@ self.TN_TABLE.get(format, 'gff'), data, '--trackLabel', trackData['label'], - '--trackType', 'JBrowse/View/Track/CanvasFeatures', + # '--trackType', 'JBrowse/View/Track/CanvasFeatures', '--key', trackData['key'] ] @@ -470,8 +473,16 @@ cmd += ['--type', gffOpts['match']] cmd += ['--clientConfig', json.dumps(clientConfig), + ] + + if 'trackType' in gffOpts: + cmd += [ + '--trackType', gffOpts['trackType'] + ] + else: + cmd += [ '--trackType', 'JBrowse/View/Track/CanvasFeatures' - ] + ] cmd.extend(['--config', json.dumps(config)]) @@ -505,6 +516,8 @@ else: outputTrackConfig[key] = colourOptions[key] + # import pprint; pprint.pprint(track) + # import sys; sys.exit() if dataset_ext in ('gff', 'gff3', 'bed'): self.add_features(dataset_path, dataset_ext, outputTrackConfig, track['conf']['options']['gff']) @@ -531,6 +544,37 @@ elif dataset_ext == 'vcf': self.add_vcf(dataset_path, outputTrackConfig) + # Return non-human label for use in other fields + yield outputTrackConfig['label'] + + def add_final_data(self, data): + viz_data = {} + if len(data['visibility']['default_on']) > 0: + viz_data['defaultTracks'] = ','.join(data['visibility']['default_on']) + + if len(data['visibility']['always']) > 0: + viz_data['alwaysOnTracks'] = ','.join(data['visibility']['always']) + + if len(data['visibility']['force']) > 0: + viz_data['forceTracks'] = ','.join(data['visibility']['force']) + + generalData = {} + if data['general']['aboutDescription'] is not None: + generalData['aboutThisBrowser'] = {'description': data['general']['aboutDescription'].strip()} + + generalData['view'] = { + 'trackPadding': data['general']['trackPadding'] + } + generalData['shareLink'] = (data['general']['shareLink'] == 'true') + generalData['show_tracklist'] = (data['general']['show_tracklist'] == 'true') + generalData['show_nav'] = (data['general']['show_nav'] == 'true') + generalData['show_overview'] = (data['general']['show_overview'] == 'true') + generalData['show_menu'] = (data['general']['show_menu'] == 'true') + generalData['hideGenomeOptions'] = (data['general']['hideGenomeOptions'] == 'true') + + viz_data.update(generalData) + self._add_json(viz_data) + def clone_jbrowse(self, jbrowse_dir, destination): """Clone a JBrowse directory into a destination directory. """ @@ -570,6 +614,25 @@ gencode=root.find('metadata/gencode').text ) + extra_data = { + 'visibility': { + 'default_on': [], + 'default_off': [], + 'force': [], + 'always': [], + }, + 'general': { + 'defaultLocation': root.find('metadata/general/defaultLocation').text, + 'trackPadding': int(root.find('metadata/general/trackPadding').text), + 'shareLink': root.find('metadata/general/shareLink').text, + 'aboutDescription': root.find('metadata/general/aboutDescription').text, + 'show_tracklist': root.find('metadata/general/show_tracklist').text, + 'show_nav': root.find('metadata/general/show_nav').text, + 'show_overview': root.find('metadata/general/show_overview').text, + 'show_menu': root.find('metadata/general/show_menu').text, + 'hideGenomeOptions': root.find('metadata/general/hideGenomeOptions').text, + } + } for track in root.findall('tracks/track'): track_conf = {} track_conf['trackfiles'] = [ @@ -586,4 +649,10 @@ track_conf['style'] = {} pass track_conf['conf'] = etree_to_dict(track.find('options')) - jc.process_annotations(track_conf) + keys = jc.process_annotations(track_conf) + + + for key in keys: + extra_data['visibility'][track.attrib.get('visibility', 'default_off')].append(key) + + jc.add_final_data(extra_data)
--- a/jbrowse.xml Fri Jan 29 13:27:30 2016 -0500 +++ b/jbrowse.xml Sat Jun 25 15:06:43 2016 -0400 @@ -1,4 +1,4 @@ -<tool id="jbrowse" name="JBrowse" version="0.4"> +<tool id="jbrowse" name="JBrowse" version="0.5"> <description>genome browser</description> <macros> <import>macros.xml</import> @@ -7,20 +7,27 @@ <expand macro="stdio"/> <version_command>python jbrowse.py --version</version_command> <command><![CDATA[ -mkdir -p $output.files_path && + +#if $action.action_select == "create": + mkdir -p $output.files_path; +#else: + cp -R $action.update_jbrowse.extra_files_path $output.files_path; +#end if + ## Copy the XML file into the directory, mostly for debugging ## but nice if users want to reproduce locally cp $trackxml $output.files_path/galaxy.xml && ## Once that's done, we run the python script to handle the real work python $__tool_directory__/jbrowse.py -$trackxml --jbrowse \${JBROWSE_SOURCE_DIR} #if str($standalone) == "Complete": --standalone #end if ---outdir $output.files_path; + +--outdir $output.files_path +$trackxml; #if str($standalone) == "Complete": mv $output.files_path/index.html $output; @@ -65,15 +72,29 @@ <metadata> <gencode>$gencode</gencode> <genomes> - #for $genome in $genomes: + #if str($action.genomes) != "None": + #for $genome in $action.genomes: <genome>$genome</genome> #end for + #end if </genomes> + <general> + <defaultLocation>${jbgen.defaultLocation}</defaultLocation> + <trackPadding>${jbgen.trackPadding}</trackPadding> + + <shareLink>${jbgen.shareLink}</shareLink> + <aboutDescription>${jbgen.aboutDescription}</aboutDescription> + <show_tracklist>${jbgen.show_tracklist}</show_tracklist> + <show_nav>${jbgen.show_nav}</show_nav> + <show_overview>${jbgen.show_overview}</show_overview> + <show_menu>${jbgen.show_menu}</show_menu> + <hideGenomeOptions>${jbgen.hideGenomeOptions}</hideGenomeOptions> + </general> </metadata> <tracks> #for $tg in $track_groups: #for $track in $tg.data_tracks: - <track cat="${tg.category}" format="${track.data_format.data_format_select}"> + <track cat="${tg.category}" format="${track.data_format.data_format_select}" visibility="${track.data_format.track_visibility}"> <files> #for $dataset in $track.data_format.annotation: <trackFile path="${dataset}" ext="${dataset.ext}" label="${dataset.element_identifier}" /> @@ -174,10 +195,18 @@ </blast> #else if str($track.data_format.data_format_select) == "gene_calls": <gff> + <trackType>${track.data_format.track_class}</trackType> #if $track.data_format.match_part.match_part_select: <match>${track.data_format.match_part.name}</match> #end if </gff> +## #else if str($track.data_format.data_format_select) == "sparql": +## <sparql> +## <url>${track.data_format.url}</url> +## <label>${track.data_format.label}</label> +## <!-- This is going to be an absolutey nightmare --> +## <query>${track.data_format.query}</query> +## </sparql> #end if </options> </track> @@ -189,11 +218,33 @@ </configfile> </configfiles> <inputs> - <param label="Fasta Sequence(s)" - name="genomes" - type="data" - format="fasta" - multiple="True"/> + <conditional name="action" label="Action"> + <param type="select" label="JBrowse-in-Galaxy Action" name="action_select"> + <option value="create">New JBrowse Instance</option> + <option value="update">Update exising JBrowse Instance</option> + </param> + <when value="create"> + <param label="Fasta Sequence(s)" + name="genomes" + type="data" + format="fasta" + multiple="True"/> + </when> + <when value="update"> + <param label="Additional Fasta Sequence(s)" + help="If sequences are selected, they will be added to the existing JBrowse instance. You should not select any sequences if you are simply updating an existing JBrowse instance which already has the required reference sequences." + name="genomes" + type="data" + format="fasta" + optional="True" + multiple="True"/> + <param label="Previous JBrowse Instance" + name="update_jbrowse" + type="data" + format="html" /> + </when> + </conditional> + <param name="standalone" label="Produce Standalone Instance" type="boolean" truevalue="Complete" falsevalue="Data Directory" help="Produce a full, working JBrowse instance or just the data directory. Data dir mode is experimental and intended to be used with Apollo" checked="True"/> <param label="Genetic Code" name="gencode" type="select"> @@ -231,6 +282,7 @@ <option value="blast">Blast XML</option> <option value="wiggle">BigWig XY</option> <option value="vcf">VCF SNPs</option> + <!--<option value="sparql">SPARQL</option>--> </param> <when value="blast"> <expand macro="input_conditional" label="BlastXML Track Data" format="blastxml" /> @@ -262,9 +314,11 @@ <expand macro="color_selection" token_scaling_lin_select="false" token_scaling_log_select="true" /> + <expand macro="track_display" /> </when> <when value="vcf"> <expand macro="input_conditional" label="SNP Track Data" format="vcf" /> + <expand macro="track_display" /> </when> <when value="gene_calls"> <expand macro="input_conditional" label="GFF/GFF3/BED Track Data" format="gff,gff3,bed" /> @@ -284,8 +338,13 @@ </when> <when value="false" /> </conditional> + <param type="select" label="JBrowse Track Type [Advanced]" name="track_class"> + <option value="JBrowse/View/Track/HTMLFeatures">HTML Features</option> + <option value="JBrowse/View/Track/CanvasFeatures" selected="true">Canvas Features</option> + </param> <expand macro="track_styling" /> <expand macro="color_selection" /> + <expand macro="track_display" /> </when> <when value="pileup"> <expand macro="input_conditional" label="BAM Track Data" format="bam" /> @@ -295,6 +354,7 @@ name="auto_snp" truevalue="true" falsevalue="false" /> + <expand macro="track_display" /> </when> <when value="wiggle"> <expand macro="input_conditional" label="BigWig Track Data" format="bigwig" /> @@ -328,11 +388,21 @@ </when> </conditional> <expand macro="color_selection_minmax" /> + <expand macro="track_display" /> </when> + <!-- + <when value="sparql"> + <param type="text" label="SPARQL Server URL" name="url" /> + <param type="text" label="Track Label" name="key" value="SPARQL Genes" /> + <param type="text" label="SPARQL Query" name="query" area="true" /> + <expand macro="track_display" /> + </when> + --> </conditional> </repeat> </repeat> + <expand macro="general_options" /> <param type="hidden" name="uglyTestingHack" value="" /> </inputs> <outputs> @@ -440,6 +510,12 @@ JBrowse-in-Galaxy offers a highly configurable, workflow-compatible alternative to Trackster. +Overview +-------- + +JBrowse is a fast, embeddable genome browser built completely with +JavaScript and HTML5. + The JBrowse-in-Galaxy (JiG) tool was written to help build complex JBrowse installations straight from Galaxy, taking advantage of the latest Galaxy features such as dataset collections, sections, and colour
--- a/macros.xml Fri Jan 29 13:27:30 2016 -0500 +++ b/macros.xml Sat Jun 25 15:06:43 2016 -0400 @@ -48,6 +48,15 @@ </conditional> </xml> + <xml name="track_display"> + <param type="select" label="Track Visibility" name="track_visibility"> + <option value="default_off">Off for new users</option> + <option value="default_on">On for new users</option> + <option value="force">Force On</option> + <option value="always">Always On (ignores URL parameters)</option> + </param> + </xml> + <xml name="jb_color" token_label="JBrowse style.color" token_name="style_color" @@ -97,6 +106,22 @@ <option value="Spectral">Spectral</option> </param> </xml> + <xml name="general_options"> + <section name="jbgen" title="General JBrowse Options [Advanced]" expanded="false"> + <param label="Default Location" type="text" name="defaultLocation" value="" help="Initial location to be shown for users who have never visited the browser before. Example: 'ctgA:1234..5678'"/> + <param label="Track Padding" type="integer" value="20" name="trackPadding" help="Spacing between tracks in the genome view, in pixels." /> + + <param label="Enable Share Link" name="shareLink" type="boolean" checked="true" truevalue="true" falsevalue="false" /> + <param label="About the Browser" type="text" name="aboutDescription" value="" help="Description of the browser to be used in the 'About' popup" /> + + <param label="Show Track List" name="show_tracklist" type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the track list"/> + <param label="Show Navigation" name="show_nav" type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the navigation menu"/> + <param label="Show Overview" name="show_overview" type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the overview bar"/> + <param label="Show Menu" name="show_menu" type="boolean" checked="true" truevalue="true" falsevalue="false" help="Optionally hide the menu bar"/> + + <param label="Hide Genome Options" name="hideGenomeOptions" type="boolean" truevalue="true" falsevalue="false" help="Hide options for opening a sequence file"/> + </section> + </xml> <xml name="color_selection_minmax"> <section name="jbcolor" title="JBrowse Color Options [Advanced]" expanded="false"> <!-- Abuse auto/manual for bicolor pivot. Means we'll have to handle the
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/frameshift/1.gff Sat Jun 25 15:06:43 2016 -0400 @@ -0,0 +1,7 @@ +##gff-version 3 +##sequence-region Merlin 1 172788 +Merlin GeneMark.hmm gene 10 20 . + . ID=Merlin_1;seqid=Merlin +Merlin GeneMark.hmm mRNA 10 20 . + . ID=Merlin_1_mRNA;Parent=Merlin_1 +Merlin GeneMark.hmm exon 10 20 . + . Parent=Merlin_1_mRNA +Merlin GeneMark.hmm CDS 10 20 1000 + 0 ID=Merlin_1_CDS ;Parent=Merlin_1_mRNA +Merlin GeneMark.hmm CDS 19 30 500 + 0 ID=Merlin_1_CDS ;Parent=Merlin_1_mRNA
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/frameshift/test.xml Sat Jun 25 15:06:43 2016 -0400 @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<root> + <metadata> + <gencode>11</gencode> + <genomes> + <genome>test-data/merlin.fa</genome> + </genomes> + <general> + <defaultLocation>Merlin:1-50</defaultLocation> + <trackPadding>40</trackPadding> + <shareLink>true</shareLink> + <aboutDescription></aboutDescription> + <show_tracklist>true</show_tracklist> + <show_nav>true</show_nav> + <show_overview>false</show_overview> + <show_menu>true</show_menu> + <hideGenomeOptions>false</hideGenomeOptions> + </general> + </metadata> + <tracks> + <track cat="Auto Coloured" format="gene_calls" visibility="default_on"> + <files> + <trackFile path="test-data/frameshift/1.gff" ext="gff3" label="Test Track"/> + </files> + <options> + <style> + <className>feature</className> + <description>feature</description> + <label>name,id</label> + <height>100px</height> + </style> + <gff> + </gff> + <scaling> + <method>ignore</method> + <scheme> + <color>__auto__</color> + </scheme> + </scaling> + </options> + </track> + </tracks> +</root>
--- a/test-data/gff3/test.xml Fri Jan 29 13:27:30 2016 -0500 +++ b/test-data/gff3/test.xml Sat Jun 25 15:06:43 2016 -0400 @@ -5,9 +5,20 @@ <genomes> <genome>test-data/merlin.fa</genome> </genomes> + <general> + <defaultLocation></defaultLocation> + <trackPadding>40</trackPadding> + <shareLink>true</shareLink> + <aboutDescription></aboutDescription> + <show_tracklist>true</show_tracklist> + <show_nav>true</show_nav> + <show_overview>false</show_overview> + <show_menu>true</show_menu> + <hideGenomeOptions>false</hideGenomeOptions> + </general> </metadata> <tracks> - <track cat="Auto Coloured" format="gene_calls"> + <track cat="Auto Coloured" format="gene_calls" visibility="default_on"> <files> <trackFile path="test-data/gff3/1.gff" ext="gff3" label="A"/> <trackFile path="test-data/gff3/1.gff" ext="gff3" label="B"/>
--- a/tool_dependencies.xml Fri Jan 29 13:27:30 2016 -0500 +++ b/tool_dependencies.xml Sat Jun 25 15:06:43 2016 -0400 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <tool_dependency> <package name="jbrowse" version="1.12.0"> - <repository changeset_revision="22be3ae5599d" name="package_jbrowse_1_12_0" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> + <repository changeset_revision="d65f12198038" name="package_jbrowse_1_12_0" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> </package> <package name="bundle_jbrowse" version="1.12.0"> <repository changeset_revision="52153ec17769" name="package_perl_bundle_jbrowse_1_12_0" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> @@ -16,7 +16,7 @@ <repository changeset_revision="8ee2210f6074" name="package_python_2_7_bcbiogff_0_6_2" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> </package> <package name="perl" version="5.18.1"> - <repository changeset_revision="8b3509930a44" name="package_perl_5_18" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> + <repository changeset_revision="35f117d7396b" name="package_perl_5_18" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" /> </package> <package name="samtools" version="1.2"> <repository changeset_revision="f6ae3ba3f3c1" name="package_samtools_1_2" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />