| 1 | #!/usr/bin/env perl | ||
| 2 | # Last changed Time-stamp: <2017-06-09 15:08:11 michl> | ||
| 3 | # AUTHOR: Florian Eggenhofer <florian.eggenhofer@univie.ac.at> | ||
| 4 | |||
| 5 | ############### | ||
| 6 | ###Use stuff | ||
| 7 | ############### | ||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | use Cwd; | ||
| 11 | use Getopt::Long qw( :config posix_default bundling no_ignore_case ); | ||
| 12 | use Pod::Usage; | ||
| 13 | use File::Path qw(make_path remove_tree); | ||
| 14 | use File::Basename; | ||
| 15 | use Path::Class; | ||
| 16 | use Bio::ViennaNGS::UCSC qw( make_track_hub ); | ||
| 17 | ############### | ||
| 18 | ###Variables | ||
| 19 | ############### | ||
| 20 | |||
| 21 | my $VERBOSE = 0; | ||
| 22 | my ($track_hub_return_value,$lf); | ||
| 23 | my $logname = "log.txt"; | ||
| 24 | my $genome_identifier = 'hg19'; | ||
| 25 | my $dest = '.'; | ||
| 26 | my $base_URL = '-'; | ||
| 27 | my $big_bed_urls = ''; | ||
| 28 | my $big_wig_urls = ''; | ||
| 29 | ############### | ||
| 30 | ###Command Line Options | ||
| 31 | ############### | ||
| 32 | Getopt::Long::config('no_ignore_case'); | ||
| 33 | pod2usage(-verbose => 0) unless GetOptions( | ||
| 34 | "out|o=s" => \$dest, | ||
| 35 | "baseurl|u=s" => \$base_URL, | ||
| 36 | "bigbeds|b=s" => \$big_bed_urls, | ||
| 37 | "bigwigs|w=s" => \$big_wig_urls, | ||
| 38 | "help|h" => sub{pod2usage(-verbose => 1)}, | ||
| 39 | "man|m" => sub{pod2usage(-verbose => 2)}, | ||
| 40 | "verbose" => sub{ $VERBOSE++ } | ||
| 41 | ); | ||
| 42 | |||
| 43 | ############### | ||
| 44 | ### MAIN | ||
| 45 | ############### | ||
| 46 | print "$base_URL\n"; | ||
| 47 | unless ($base_URL =~ /^http/) { | ||
| 48 | warn "Base URL must be given in full format, eg http://foo.bar.com/Hubs/"; | ||
| 49 | pod2usage(-verbose => 0); | ||
| 50 | } | ||
| 51 | |||
| 52 | unless ($dest =~ /\/$/){$dest.= "/";} | ||
| 53 | unless (-d $dest){ | ||
| 54 | mkdir $dest or die $!; | ||
| 55 | } | ||
| 56 | $lf = file($dest,$logname); | ||
| 57 | |||
| 58 | =head1 NAME | ||
| 59 | |||
| 60 | Tutorial_Pipeline03.pl - Construct a UCSC genome browser TrackHub | ||
| 61 | |||
| 62 | =head1 SYNOPSIS | ||
| 63 | |||
| 64 | perl Tutorial_Pipeline03.pl [--out I<PATH>] [--baseurl -I<URL>] [--bigbeds -I<URL#URL>] [--bigwigs -I<URL,URL#URL>] | ||
| 65 | |||
| 66 | =head1 DESCRIPTION | ||
| 67 | |||
| 68 | This script demonstrates the semi-automated construction of UCSC | ||
| 69 | genome browser TrackHubs with L<Bio::ViennaNGS>. | ||
| 70 | |||
| 71 | The result of this tutorial can be viewed by navigating your browser | ||
| 72 | L<here|http://genome-euro.ucsc.edu/cgi-bin/hgTracks?hubUrl=http://nibiru.tbi.univie.ac.at/ViennaNGS/tutorial03/hg19_trackHub/trackHub/hub.txt&position=chr15> | ||
| 73 | |||
| 74 | This tutorial is based on the track_hub_constructor.pl script and the | ||
| 75 | output from Tutorial02_pipeline.pl. While the option descriptions | ||
| 76 | here are specific for the results from Tutorial02 the | ||
| 77 | trackhub_hub_constructor.pl can be applied in the same manner to other | ||
| 78 | datasets. The example call uses the bigwig and bedfiles available from | ||
| 79 | our server. Example call: | ||
| 80 | |||
| 81 | Tutorial_pipeline03.pl -o /home/user/public_html/hg19_trackHub -u | ||
| 82 | http://www.mydomain.com/ucsc/hg19_trackHub -b | ||
| 83 | http://www.mydomain.com/ucsc/data/hg19_highlyexpressed.pos.bb#http://www.mydomain.com/ucsc/data/hg19_highlyexpressed.neg.bb | ||
| 84 | #-w | ||
| 85 | #http://www.mydomain.com/ucsc/data/hg19_highlyexpressed.pos.bw,http://www.mydomain.com/ucsc/data/hg19_highlyexpressed.neg.bw | ||
| 86 | |||
| 87 | =head2 PREREQUITES | ||
| 88 | |||
| 89 | To run this tutorial on your machine you will need a full installation | ||
| 90 | of the L<Bio::ViennaNGS> distribution. Input files can be downloaded | ||
| 91 | L<here|http://nibiru.tbi.univie.ac.at/ViennaNGS>): | ||
| 92 | |||
| 93 | =over | ||
| 94 | |||
| 95 | =item F<hg19_highlyexpressed.pos.bb> | ||
| 96 | |||
| 97 | =item F<hg19_highlyexpressed.neg.bb> | ||
| 98 | |||
| 99 | =item F<hg19_highlyexpressed.pos.bw> | ||
| 100 | |||
| 101 | =item F<hg19_highlyexpressed.neg.bw> | ||
| 102 | |||
| 103 | =back | ||
| 104 | |||
| 105 | For the UCSC genome browser to be able to visualize our trackhub it | ||
| 106 | needs to be accessible via URL. This is the base URL you need to | ||
| 107 | provide as commandline argument. | ||
| 108 | |||
| 109 | =head2 DISCLAIMER | ||
| 110 | |||
| 111 | The resulting trackhub can only be read by the UCSC genome browser if | ||
| 112 | it is accessible via URL. If you have no webspace for testing | ||
| 113 | available you can use example output available from our webserver | ||
| 114 | L<here|http://nibiru.tbi.univie.ac.at/ViennaNGS>. | ||
| 115 | |||
| 116 | |||
| 117 | =head1 PIPELINE | ||
| 118 | |||
| 119 | =head3 Create UCSC Genome Browser Trackhub | ||
| 120 | |||
| 121 | print "Constructing UCSC genome browser trackhub ...\n"; | ||
| 122 | |||
| 123 | $track_hub_return_value = make_track_hub($genome_identifier,$dest,$base_URL,$big_bed_urls,$big_wig_urls,$lf); | ||
| 124 | |||
| 125 | print "Loading the trackhub into the UCSC genome browser...\n\n"; | ||
| 126 | |||
| 127 | print "1. Point your browser to: http://genome.ucsc.edu/index.html\n\n"; | ||
| 128 | |||
| 129 | print "2. Select Genome Browser from the left menu\n\n"; | ||
| 130 | |||
| 131 | print "3. You are now redirected to nearest mirror of the genome browser.\n Select \"My Data\" from the top menu and then \"Track Hubs\" in the popup list.\n\n"; | ||
| 132 | |||
| 133 | print "4. The \"Track Data Hubs\" page is displayed. In the register \"My Hubs\" it is possible to add the newly created track hub. Paste the URL to hub.txt into the URL field and click \"Add Hub\" (e.g. http://nibiru.tbi.univie.ac.at/ViennaNGS/tutorial03/hg19_trackHub/trackHub/hub.txt).\n\n"; | ||
| 134 | |||
| 135 | print "5. The track hub now loads into the hg19 public hub. \n\n"; | ||
| 136 | |||
| 137 | print "6. Enter e.g. chr15 in the position field and hit go\n\n"; | ||
| 138 | |||
| 139 | print "7. You should now see 2 annotation tracks and a bigwig multi-track plotted in red and green\n\n"; | ||
| 140 | |||
| 141 | print "DONE\n"; | ||
| 142 | |||
| 143 | =cut | ||
| 144 | |||
| 145 | print "Constructing UCSC genome browser trackhub ...\n"; | ||
| 146 | |||
| 147 | $track_hub_return_value = make_track_hub($genome_identifier,$dest,$base_URL,$big_bed_urls,$big_wig_urls,$lf); | ||
| 148 | |||
| 149 | print "Loading the trackhub into the UCSC genome browser...\n\n"; | ||
| 150 | |||
| 151 | print "1. Point your browser to: http://genome.ucsc.edu/index.html\n\n"; | ||
| 152 | |||
| 153 | print "2. Select Genome Browser from the left menu\n\n"; | ||
| 154 | |||
| 155 | print "3. You are now redirected to nearest mirror of the genome browser.\n Select \"My Data\" from the top menu and then \"Track Hubs\" in the popup list.\n\n"; | ||
| 156 | |||
| 157 | print "4. The \"Track Data Hubs\" page is displayed. In the register \"My Hubs\" it is possible to add the newly created track hub. Paste the URL to hub.txt into the URL field and click \"Add Hub\" (e.g. http://nibiru.tbi.univie.ac.at/ViennaNGS/tutorial03/hg19_trackHub/trackHub/hub.txt).\n\n"; | ||
| 158 | |||
| 159 | print "5. The track hub now loads into the hg19 public hub. \n\n"; | ||
| 160 | |||
| 161 | print "6. Enter e.g. chr15 in the position field and hit go\n\n"; | ||
| 162 | |||
| 163 | print "7. You should now see 2 annotation tracks and a bigwig multi-track plotted in red and green\n\n"; | ||
| 164 | |||
| 165 | print "DONE\n"; | ||
| 166 | |||
| 167 | =head1 COMMAND LINE OPTIONS | ||
| 168 | |||
| 169 | =cut | ||
| 170 | |||
| 171 | __END__ |