| 1 | #!/usr/bin/env perl | ||
| 2 | # -*-CPerl-*- | ||
| 3 | # Last changed Time-stamp: <2015-03-31 16:33:47 mtw> | ||
| 4 | # | ||
| 5 | # *********************************************************************** | ||
| 6 | # * Copyright notice | ||
| 7 | # * | ||
| 8 | # * Copyright 2014 Michael T. Wolfinger <michael@wolfinger.eu> | ||
| 9 | # * All rights reserved | ||
| 10 | # * | ||
| 11 | # * This program is free software: you can redistribute it and/or modify | ||
| 12 | # * it under the terms of the GNU General Public License as published by | ||
| 13 | # * the Free Software Foundation, either version 3 of the License, or | ||
| 14 | # * (at your option) any later version. | ||
| 15 | # * | ||
| 16 | # * This program is distributed in the hope that it will be useful, | ||
| 17 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | # * GNU General Public License for more details. | ||
| 20 | # * | ||
| 21 | # * You should have received a copy of the GNU General Public License | ||
| 22 | # * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | # * | ||
| 24 | # * This copyright notice MUST APPEAR in all copies of the script! | ||
| 25 | # *********************************************************************** | ||
| 26 | |||
| 27 | use strict; | ||
| 28 | use warnings; | ||
| 29 | use Getopt::Long qw( :config posix_default bundling no_ignore_case ); | ||
| 30 | use Pod::Usage; | ||
| 31 | use Data::Dumper; | ||
| 32 | use IPC::Cmd qw(can_run); | ||
| 33 | use Bio::ViennaNGS::Util qw(bed2bigBed); | ||
| 34 | use Bio::ViennaNGS::SpliceJunc qw(bed6_ss_to_bed12); | ||
| 35 | |||
| 36 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 37 | #^^^^^^^^^^ Variables ^^^^^^^^^^^# | ||
| 38 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 39 | |||
| 40 | my ($path_out,$path_annot,$path_ss,$fastaO); | ||
| 41 | my $mincov = 10; | ||
| 42 | my $window = 0; | ||
| 43 | my $outdir = "./"; | ||
| 44 | my $want_bigbed = 0; | ||
| 45 | my $want_circular=0; | ||
| 46 | my $s_in = '-'; | ||
| 47 | my $cs_in = '-'; | ||
| 48 | my @result = (); | ||
| 49 | |||
| 50 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 51 | #^^^^^^^^^^^^^^ Main ^^^^^^^^^^^^^# | ||
| 52 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 53 | |||
| 54 | Getopt::Long::config('no_ignore_case'); | ||
| 55 | pod2usage(-verbose => 1) unless GetOptions("s=s" => \$s_in, | ||
| 56 | "c=s" => \$cs_in, | ||
| 57 | "b" => sub{$want_bigbed=1}, | ||
| 58 | "o=s" => \$outdir, | ||
| 59 | "r=s" => \$mincov, | ||
| 60 | "w=s" => \$window, | ||
| 61 | "z" => sub{$want_circular=1}, | ||
| 62 | "man" => sub{pod2usage(-verbose => 2)}, | ||
| 63 | "help|h" => sub{pod2usage(1)} | ||
| 64 | ); | ||
| 65 | |||
| 66 | |||
| 67 | unless ($s_in =~ /^\//) {$s_in = "./".$s_in;} | ||
| 68 | unless (-f $s_in){ | ||
| 69 | warn "Could not find input file $s_in given via -s option"; | ||
| 70 | pod2usage(-verbose => 0); | ||
| 71 | } | ||
| 72 | |||
| 73 | if($want_bigbed==1){ | ||
| 74 | unless ($cs_in =~ /^\//) {$cs_in = "./".$cs_in;} | ||
| 75 | unless (-f $cs_in){ | ||
| 76 | warn "Could not find input file $cs_in given via -c option"; | ||
| 77 | pod2usage(-verbose => 0); | ||
| 78 | } | ||
| 79 | my $bedTobigBed = can_run('bedToBigBed') or | ||
| 80 | die 'bedToBigBed utility not found!'; | ||
| 81 | } | ||
| 82 | |||
| 83 | #TODO check if we are allowed to write to $outdir | ||
| 84 | unless ($outdir =~ /\/$/){$outdir .= "/";} | ||
| 85 | unless (-d $outdir){mkdir $outdir or die $!;} | ||
| 86 | |||
| 87 | # Make BED12 line from each splice junction | ||
| 88 | @result = bed6_ss_to_bed12($s_in,$outdir,$window,$mincov,$want_circular); | ||
| 89 | |||
| 90 | my ($bed12) = @result; | ||
| 91 | |||
| 92 | if($want_bigbed){ | ||
| 93 | my $bb12 = bed2bigBed($bed12,$cs_in,$outdir,undef); | ||
| 94 | } | ||
| 95 | |||
| 96 | __END__ |