# HG changeset patch # User yating-l # Date 1489509233 14400 # Node ID 570605affa9430007a3dfbdadea88e9c43013b5e # Parent e7c80e9b70ae4719089b96eaf639b4b38764cd83 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty diff -r e7c80e9b70ae -r 570605affa94 JBrowse-1.12.1/bin/add-bam-track.pl --- a/JBrowse-1.12.1/bin/add-bam-track.pl Tue Mar 14 12:24:37 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib "$RealBin/../src/perl5"; -use JBlibs; - -use Getopt::Long qw(:config no_ignore_case bundling); -use IO::File; -use File::Basename; -use JSON; - -use Pod::Usage; - -my $STORE_CLASS = "JBrowse/Store/SeqFeature/BAM"; -my $ALIGNMENT_TYPE = "JBrowse/View/Track/Alignments2"; -my $COVERAGE_TYPE = "JBrowse/View/Track/SNPCoverage"; - -my $in_file; -my $out_file; -my $label; -my $bam_url; -my $key; -my $coverage = 0; -my $classname = undef; -my $min_score = undef; -my $max_score = undef; - -parse_options(); -add_bam_track(); -exit; - -sub parse_options { - my $help; - GetOptions("in|i=s" => \$in_file, - "out|o=s" => \$out_file, - "label|l=s" => \$label, - "bam_url|u=s" => \$bam_url, - "key|k=s" => \$key, - "classname|c=s" => \$classname, - "coverage|C" => \$coverage, - "min_score|s=i" => \$min_score, - "max_score|S=i" => \$max_score, - "help|h" => \$help); - pod2usage( -verbose => 2 ) if $help; - pod2usage("Missing label option") if !$label; - pod2usage("Missing bam_url option") if !$bam_url; - pod2usage("Missing min_score option") if $coverage && !defined $min_score; - pod2usage("Missing max_score option") if $coverage && !defined $max_score; - $key ||= $label; - $in_file ||= 'data/trackList.json'; - $out_file ||= $in_file; -} - - -sub add_bam_track { - my $json = new JSON; - local $/; - my $in; - $in = new IO::File($in_file) or - die "Error reading input $in_file: $!"; - my $track_list_contents = <$in>; - $in->close(); - my $track_list = $json->decode($track_list_contents); - my $bam_entry; - my $index; - my $tracks = $track_list->{tracks}; - for ($index = 0; $index < scalar(@{$tracks}); ++$index) { - my $track = $tracks->[$index]; - if ($track->{label} eq $label) { - $bam_entry = $track; - last; - } - } - if (!$bam_entry) { - $bam_entry = !$coverage ? generate_new_bam_alignment_entry() : - generate_new_bam_coverage_entry(); - push @{$track_list->{tracks}}, $bam_entry; - } - else { - if ($coverage) { - if ($bam_entry->{type} eq $ALIGNMENT_TYPE) { - $bam_entry = generate_new_bam_coverage_entry(); - $tracks->[$index] = $bam_entry; - } - } - else { - if ($bam_entry->{type} eq $COVERAGE_TYPE) { - $bam_entry = generate_new_bam_alignment_entry(); - $tracks->[$index] = $bam_entry; - } - } - } - $bam_entry->{label} = $label; - $bam_entry->{urlTemplate} = $bam_url; - $bam_entry->{key} = $key; - if (!$coverage) { - if (defined $classname) { - if (! $bam_entry->{style}) { - $bam_entry->{style} = {}; - } - $bam_entry->{style}->{className} = $classname; - } - } - else { - $bam_entry->{min_score} = $min_score; - $bam_entry->{max_score} = $max_score; - } - my $out; - $out = new IO::File($out_file, "w") or - die "Error writing output $out_file: $!"; - print $out $json->pretty->encode($track_list); - $out->close(); -} - -sub generate_new_bam_alignment_entry { - return { - storeClass => $STORE_CLASS, - type => $ALIGNMENT_TYPE, - }; -} - -sub generate_new_bam_coverage_entry { - return { - storeClass => $STORE_CLASS, - type => $COVERAGE_TYPE - }; -} - -__END__ - - -=head1 NAME - -add_bam_track.pl - add track configuration snippet(s) for BAM track(s) - -=cut - -=head1 USAGE - - add_bam_track.pl - [ --in ] \ - [ --out \ - --label \ - --bam_url \ - [ --key ] \ - [ --classname ] \ - [ --coverage ] \ - [ --min_score ] \ - [ --max_score ] \ - [ --help ] - -=head1 ARGUMENTS - -=over 4 - -=item --in - -input trackList.json file. Default: data/trackList.json. - -=item --out - -Output trackList.json file. Default: data/trackList.json. - -=item --bam_url - -URL to BAM file (can be a relative path) - -=item --label - -unique track label for the new track. - -=item --key - -key (display name) for track [default: label value] - -=item --classname - -CSS class for display [default: bam] - -=item --coverage - -display coverage data instead of alignments - -=item --min_score - -optional minimum score to use for generating coverage plot (only applicable with --coverage option) - -=item --max_score - -optional maximum score to use for generating coverage plot (only applicable with --coverage option) - -=back - -=cut diff -r e7c80e9b70ae -r 570605affa94 JBrowse-1.12.1/bin/add-bw-track.pl --- a/JBrowse-1.12.1/bin/add-bw-track.pl Tue Mar 14 12:24:37 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,284 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib "$RealBin/../src/perl5"; -use JBlibs; - -use Getopt::Long qw(:config no_ignore_case bundling); -use IO::File; -use File::Basename; -use JSON; - -use Pod::Usage; - -my $STORE_CLASS = "JBrowse/Store/SeqFeature/BigWig"; -my $HEATMAP_TYPE = "JBrowse/View/Track/Wiggle/Density"; -my $PLOT_TYPE = "JBrowse/View/Track/Wiggle/XYPlot"; - -my $in_file; -my $out_file; -my $label; -my $bw_url; -my $key; -my $plot = 0; -my $bicolor_pivot = "zero"; -my $pos_color = undef; -my $neg_color = undef; -my $min_score = undef; -my $max_score = undef; -my $clip_marker_color = undef; -my $bg_color = undef; -my $height = undef; - -parse_options(); -add_bw_track(); - -sub parse_options { - my $help; - GetOptions("in|i=s" => \$in_file, - "out|o=s" => \$out_file, - "label|l=s" => \$label, - "bw_url|u=s" => \$bw_url, - "key|k=s" => \$key, - "plot|P" => \$plot, - "bicolor_pivot|b=s" => \$bicolor_pivot, - "pos_color|c=s" => \$pos_color, - "neg_color|C=s" => \$neg_color, - "min_score|s=i" => \$min_score, - "max_score|S=i" => \$max_score, - "clip_marker_color|M=s" => \$clip_marker_color, - "bg_color|B=s" => \$bg_color, - "height|H=s" => \$height, - "help|h" => \$help); - pod2usage( -verbose => 2 ) if $help; - pod2usage( "Missing label option" ) if !$label; - pod2usage( "Missing bw_url option" ) if !$bw_url; - $key ||= $label; - $in_file ||= 'data/trackList.json'; - $out_file ||= $in_file; -} - -sub add_bw_track { - my $json = new JSON; - local $/; - my $in; - $in = new IO::File($in_file) or - die "Error reading input $in_file: $!"; - my $track_list_contents = <$in>; - $in->close(); - my $track_list = $json->decode($track_list_contents); - my $bw_entry; - - my $index; - my $tracks = $track_list->{tracks}; - for ($index = 0; $index < scalar(@{$tracks}); ++$index) { - my $track = $tracks->[$index]; - if ($track->{label} eq $label) { - $bw_entry = $track; - last; - } - } - -# foreach my $track (@{$track_list->{tracks}}) { -# if ($track->{label} eq $label) { -# $bw_entry = $track; -# last; -# } -# } - if (!$bw_entry) { - # $bw_entry = generate_new_bw_heatmap_entry(); - $bw_entry = !$plot ? generate_new_bw_heatmap_entry() : - generate_new_bw_plot_entry(); - - push @{$track_list->{tracks}}, $bw_entry; - } - else { - if ($plot) { - if ($bw_entry->{type} eq $HEATMAP_TYPE) { - $bw_entry = generate_new_bw_plot_entry(); - $tracks->[$index] = $bw_entry; - } - } - else { - if ($bw_entry->{type} eq $PLOT_TYPE) { - $bw_entry = generate_new_bw_heatmap_entry(); - $tracks->[$index] = $bw_entry; - } - } - } - - $bw_entry->{label} = $label; - $bw_entry->{autoscale} = "local"; - $bw_entry->{urlTemplate} = $bw_url; - $bw_entry->{key} = $key; - $bw_entry->{bicolor_pivot} = $bicolor_pivot; - if (defined $min_score) { - $bw_entry->{min_score} = $min_score; - } - else { - delete $bw_entry->{min_score}; - } - if (defined $max_score) { - $bw_entry->{max_score} = $max_score; - } - else { - delete $bw_entry->{max_score}; - } - if ($pos_color) { - $bw_entry->{style}->{pos_color} = $pos_color; - } - else { - delete $bw_entry->{style}->{pos_color}; - } - if ($neg_color) { - $bw_entry->{style}->{neg_color} = $neg_color; - } - else { - delete $bw_entry->{style}->{neg_color}; - } - if ($clip_marker_color) { - $bw_entry->{style}->{clip_marker_color} = $clip_marker_color; - } - else { - delete $bw_entry->{style}->{clip_marker_color}; - } - if ($bg_color) { - $bw_entry->{style}->{bg_color} = $bg_color; - } - else { - delete $bw_entry->{style}->{bg_color}; - } - if ($height) { - $bw_entry->{style}->{height} = $height; - } - else { - delete $bw_entry->{style}->{height}; - } - delete $bw_entry->{style} if !scalar(keys %{$bw_entry->{style}}); - my $out; - $out = new IO::File($out_file, "w") or - die "Error writing output $out_file: $!"; - print $out $json->pretty->encode($track_list); - $out->close(); -} - -sub generate_new_bw_heatmap_entry { - return { - storeClass => $STORE_CLASS, - type => $HEATMAP_TYPE - }; -} - -sub generate_new_bw_plot_entry { - return { - storeClass => $STORE_CLASS, - type => $PLOT_TYPE - }; -} - -__END__ - - -=head1 NAME - -add-bw-track.pl - add track configuration snippet(s) for BAM track(s) - -=cut - -=head1 USAGE - - add-bw-track.pl - [ --in ] \ - [ --out ] \ - --label \ - --bw_url \ - [ --key ] \ - [ --plot ] \ - [ --bicolor_pivot ] \ - [ --pos_color ] \ - [ --neg_color ] \ - [ --min_score ] \ - [ --max_score ] \ - [ --clip_marker_color ] \ - [ --bg_color ] \ - [ --height ] \ - [ -h|--help ] - -=head1 ARGUMENTS - -=over 4 - -=item --bicolor_pivot - -point where to set pivot for color changes - can be "mean", "zero", or -a numeric value [default: zero] - -=item --plot - -display as XY plot instead of density heatmap - -=item --pos_color - -CSS color for positive side of pivot [default: blue] - -=item --neg_color - -CSS color for negative side of pivot [default: red] - -=item --in - -input trackList.json file. Default: data/trackList.json. - -=item --out - -Output trackList.json file. Default: data/trackList.json. - -=item --bw_url - -URL to BigWig file (can be relative to the trackList.json) - -=item --label - -unique track label for the new track. - -=item --key - -key (display name) for track [default: label value] - -=item --classname - -CSS class for display [default: bam] - -=item --mismatches - -display mismatches in alignment (generates no subfeatures) - -=item --coverage - -display coverage data instead of alignments - -=item --min_score - -optional minimum score to be graphed - -=item --max_score - -optional maximum score to be graphed - -=item --clip_marker_color - -optional clip marker color - -=item --bg_color - -optional background color - -=item --height - -optional height - -=back - -=cut diff -r e7c80e9b70ae -r 570605affa94 JBrowse-1.12.1/bin/add-json.pl --- a/JBrowse-1.12.1/bin/add-json.pl Tue Mar 14 12:24:37 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib "$RealBin/../src/perl5"; -use JBlibs; - -use IO::Handle; -use Pod::Usage; - -use JSON 2; - -my $j = JSON->new->pretty->relaxed; - -my ( $json, $filename ) = @ARGV; -pod2usage() unless $json && $filename; - -die "cannot read '$filename' not found" unless -f $filename && -r $filename; - -my $in = $j->decode( $json ); -my $data = $j->decode(do { - open my $f, '<', $filename or die "$! reading $filename"; - local $/; - scalar <$f> -}); - -%$data = ( %$data, %$in ); - -open my $f, '>', $filename or die "$! writing $filename"; -$f->print( $j->encode( $data ) ); - -__END__ - -=head1 NAME - -add-json.pl - write values into an existing JSON file - -=head1 USAGE - - # set dataset_id in an existing config file - add-json.pl '{ "dataset_id": "volvox" }' sample_data/json/volvox/trackList.json - -=cut - diff -r e7c80e9b70ae -r 570605affa94 JBrowse-1.12.1/bin/add-track-json.pl --- a/JBrowse-1.12.1/bin/add-track-json.pl Tue Mar 14 12:24:37 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib "$RealBin/../src/perl5"; -use JBlibs; - -use IO::Handle; -use Pod::Usage; - -use Bio::JBrowse::JSON; - -@ARGV or pod2usage( -verbose => 2 ); - -# read in the JSON -my $j = Bio::JBrowse::JSON->new->pretty; -my $json_fh = - @ARGV == 1 ? \*STDIN : do { - my $file = shift @ARGV; - open( my $fh, '<', $file ) or die "$! reading $file"; - $fh - }; -my $track_data = $j->decode( do{ local $/; scalar <$json_fh> } ); - -# if it's a single definition, coerce to an array -if( ref $track_data eq 'HASH' ) { - $track_data = [ $track_data ]; -} - -# validate the track JSON structure -for my $def ( @$track_data ) { - $def->{label} or die "invalid track JSON: missing a label element\n"; -} - -# read and parse the target file -my $target_file = shift @ARGV or pod2usage(); -my $target_file_data = $j->decode_file( $target_file ); - -for my $def ( @$track_data ) { - for( my $i = 0; $i < @{$target_file_data->{tracks}|| []}; $i++ ) { - my $track = $target_file_data->{tracks}[$i]; - if( $track->{label} eq $def->{label} ) { - $target_file_data->{tracks}[$i] = $def; - undef $def; - } - } - - if( $def ) { - push @{ $target_file_data->{tracks} ||= [] }, $def; - } -} - -{ - open my $fh, '>', $target_file or die "$! writing $target_file"; - print $fh $j->encode( $target_file_data ); -} - - -__END__ - -=head1 NAME - -add-track-json.pl - add a single JSON track configuration snippet(from STDIN -or from a file) to the given JBrowse configuration file - -=head1 DESCRIPTION - -Reads a block of JSON describing a track from a file or from standard -input or from a file, and adds it to the target JBrowse configuration -file. - -For example, if you wanted to add a sequence track to -data/trackList.json, you could run something like: - - echo ' { "urlTemplate" : "seq/{refseq}/", - "label" : "DNA", - "type" : "SequenceTrack" - } ' | bin/add-track-json.pl data/trackList.json - - -=head1 USAGE - - bin/add-track-json.pl myTrack.json data/trackList.json - - # OR - - cat track.json | bin/add-track-json.pl data/trackList.json - -=head2 OPTIONS - -none yet - -=cut diff -r e7c80e9b70ae -r 570605affa94 JBrowse-1.12.1/bin/bam-to-json.pl --- a/JBrowse-1.12.1/bin/bam-to-json.pl Tue Mar 14 12:24:37 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -#!/usr/bin/env perl - -=head1 NAME - -bam-to-json.pl - format data from a BAM file for display by JBrowse - -=head1 USAGE - - bam-to-json.pl \ - --bam \ - --trackLabel \ - [ --out ] \ - [ --key ] \ - [ --cssClass ] \ - [ --clientConfig '{ JSON }' ] \ - [ --nclChunk ] \ - [ --compress] - -=head1 OPTIONS - -=over 4 - -=item --help | -h | -? - -Display an extended help screen. - -=item --bam - -Required. BAM file to read and format. - -=item --trackLabel - -Unique identifier for this track. Required. - -=item --out - -Output directory to write to. Defaults to C. - -=item --cssClass - -CSS class name for the resulting features. Defaults to C. - -=item --clientConfig '{ JSON configuration }' - -Extra configuration for the client, in JSON syntax. Example: - - --clientConfig '{"featureCss": "background-color: #668; height: 8px;", "histScale": 5}' - -For historical reasons, this is only merged into the C