| 1 | #!/usr/bin/env perl | ||
| 2 | # -*-CPerl-*- | ||
| 3 | # Last changed Time-stamp: <2016-02-04 12:48:53 mtw> | ||
| 4 | # | ||
| 5 | # Construct UCSC genome browser Assembly Hub and display various | ||
| 6 | # genomic sequence annotation data within the Hub | ||
| 7 | # | ||
| 8 | # *********************************************************************** | ||
| 9 | # * Copyright notice | ||
| 10 | # * | ||
| 11 | # * Copyright 2014 Michael T. Wolfinger <michael@wolfinger.eu> | ||
| 12 | # * Florian Eggenhofer <florian.eggenhofer@univie.ac.at> | ||
| 13 | # * All rights reserved | ||
| 14 | # * | ||
| 15 | # * This program is free software: you can redistribute it and/or modify | ||
| 16 | # * it under the terms of the GNU General Public License as published by | ||
| 17 | # * the Free Software Foundation, either version 3 of the License, or | ||
| 18 | # * (at your option) any later version. | ||
| 19 | # * | ||
| 20 | # * This program is distributed in the hope that it will be useful, | ||
| 21 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 23 | # * GNU General Public License for more details. | ||
| 24 | # * | ||
| 25 | # * You should have received a copy of the GNU General Public License | ||
| 26 | # * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 27 | # * | ||
| 28 | # * This copyright notice MUST APPEAR in all copies of the script! | ||
| 29 | # *********************************************************************** | ||
| 30 | |||
| 31 | use strict; | ||
| 32 | use warnings; | ||
| 33 | use Getopt::Long; | ||
| 34 | use Pod::Usage; | ||
| 35 | use Data::Dumper; | ||
| 36 | use File::Basename; | ||
| 37 | use Path::Class; | ||
| 38 | use Bio::ViennaNGS::UCSC qw( make_assembly_hub ); | ||
| 39 | |||
| 40 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 41 | #^^^^^^^^^^ Variables ^^^^^^^^^^^# | ||
| 42 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 43 | |||
| 44 | my ($assembly_hub_return_value,$lf); | ||
| 45 | my $logname = "log.txt"; | ||
| 46 | my $fasta_in = '-'; | ||
| 47 | my $folder_in = '-'; | ||
| 48 | my $dest = '.'; | ||
| 49 | my $base_URL = '-'; | ||
| 50 | my $big_wig_urls = '-'; | ||
| 51 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 52 | #^^^^^^^^^^^^^^ Main ^^^^^^^^^^^^^# | ||
| 53 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 54 | Getopt::Long::config('no_ignore_case'); | ||
| 55 | pod2usage(-verbose => 1) unless GetOptions("fa|f=s" => \$fasta_in, | ||
| 56 | "infolder|i=s" => \$folder_in, | ||
| 57 | "out|o=s" => \$dest, | ||
| 58 | "baseurl|b=s" => \$base_URL, | ||
| 59 | "bigwigs|w=s" => \$big_wig_urls, | ||
| 60 | "man" => sub{pod2usage(-verbose => 2)}, | ||
| 61 | "help|h" => sub{pod2usage(1)} | ||
| 62 | ); | ||
| 63 | |||
| 64 | unless (-e $fasta_in){ | ||
| 65 | warn "Could not find input Fasta file given via --fa option"; | ||
| 66 | pod2usage(-verbose => 0); | ||
| 67 | } | ||
| 68 | unless (-d $folder_in){ | ||
| 69 | warn "An input folder path is required and must be gi ven via --infolder option"; | ||
| 70 | pod2usage(-verbose => 0); | ||
| 71 | } | ||
| 72 | unless ($base_URL =~ /^http/) { | ||
| 73 | warn "Base URL must be given in full format, eg http://foo.bar.com/Hubs/"; | ||
| 74 | pod2usage(-verbose => 0); | ||
| 75 | } | ||
| 76 | unless ($dest =~ /\/$/){$dest.= "/";} | ||
| 77 | unless (-d $dest){ | ||
| 78 | mkdir $dest or die $!; | ||
| 79 | } | ||
| 80 | $lf = file($dest,$logname); | ||
| 81 | |||
| 82 | $assembly_hub_return_value = make_assembly_hub($fasta_in,$folder_in,$dest,$base_URL,$big_wig_urls,"$lf"); | ||
| 83 | |||
| 84 | |||
| 85 | __END__ | ||
| 86 | |||
| 87 | |||
| 88 | =head1 NAME | ||
| 89 | |||
| 90 | assembly_hub_constructor.pl - Build UCSC genome browser Assembly Hubs | ||
| 91 | from genomic sequence and annotation | ||
| 92 | |||
| 93 | =head1 SYNOPSIS | ||
| 94 | |||
| 95 | assembly_hub_constructor.pl [--fa I<FILE>] [--infolder I<PATH>] [--out | ||
| 96 | I<PATH>] [--baseurl -I<URL>] [--bigwigs -I<URL,URL#URL>] [options] | ||
| 97 | |||
| 98 | =head1 DESCRIPTION | ||
| 99 | |||
| 100 | The UCSC genome browser offers the possibility to visualize any | ||
| 101 | organism (including organisms that are not included in the standard | ||
| 102 | UCSC browser bundle) through hso called 'Assembly Hubs'. This script | ||
| 103 | constructs Assembly Hubs from genomic sequence and annotation data. | ||
| 104 | |||
| 105 | =head1 OPTIONS | ||
| 106 | |||
| 107 | =over | ||
| 108 | |||
| 109 | =item B<--fa -f> | ||
| 110 | |||
| 111 | Input file in Fasta format. | ||
| 112 | |||
| 113 | =item B<--infolder -i> | ||
| 114 | |||
| 115 | Directory which contains all track files in BED/bigBed format. The | ||
| 116 | resulting Assembly Hub will contain these files in their respective | ||
| 117 | bigFile version. | ||
| 118 | |||
| 119 | =item B<--out -o> | ||
| 120 | |||
| 121 | Destination folder for the output Assembly Hub. | ||
| 122 | |||
| 123 | =item B<--baseurl -b> | ||
| 124 | |||
| 125 | BaseURL used within the Assembly Hub. This URL will be included | ||
| 126 | verbatim in the resulting Assembly Hub. It is crucial that this URl is | ||
| 127 | valid, else the resulting Assembly Hub will be broken. | ||
| 128 | |||
| 129 | =item B<--bigwigs -w> | ||
| 130 | |||
| 131 | URLs pointing to big wig files to be included in the trackhub. Multiple URLs are | ||
| 132 | separated by the star character #. It is possible to create a multiwig container by | ||
| 133 | providing 2 URLs instead of one separated by comma character ,. E.g. | ||
| 134 | http://foo.com/bar.bw,http://foo.com/bar2.bw#http://foo.com/bar3.bw yields a multi | ||
| 135 | big wig container displaying bar as positive reads in green and bar2 as negative | ||
| 136 | 3 red colored reads in the same track and additionally bar3 in an own track | ||
| 137 | colored blue. | ||
| 138 | |||
| 139 | =item B<--help -h> | ||
| 140 | |||
| 141 | Print short help. | ||
| 142 | |||
| 143 | =item B<--man> | ||
| 144 | |||
| 145 | Prints the manual page and exits. | ||
| 146 | |||
| 147 | =back | ||
| 148 | |||
| 149 | =head1 SEE ALSO | ||
| 150 | |||
| 151 | The L<UCSC Genome | ||
| 152 | Wiki|http://genomewiki.ucsc.edu/index.php/Assembly_Hubs> has extensive | ||
| 153 | documentation for Assembly Hubs. | ||
| 154 | |||
| 155 | =head1 AUTHORS | ||
| 156 | |||
| 157 | =over | ||
| 158 | |||
| 159 | =item Florian Eggenhofer E<lt>florian.eggenhofer@univie.ac.atE<gt> | ||
| 160 | |||
| 161 | =item Michael T. Wolfinger E<lt>michael@wolfinger.euE<gt> | ||
| 162 | |||
| 163 | =back |