| 1 | #!/usr/bin/env perl | ||
| 2 | # -*-CPerl-*- | ||
| 3 | # Last changed Time-stamp: <2016-02-25 17:57:46 mtw> | ||
| 4 | # | ||
| 5 | # *********************************************************************** | ||
| 6 | # * Copyright notice | ||
| 7 | # * | ||
| 8 | # * Copyright 2016 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 Path::Class; | ||
| 32 | use File::Basename; | ||
| 33 | use Bio::ViennaNGS::Bam qw(uniquify_bam uniquify_bam2); | ||
| 34 | use Bio::ViennaNGS::Util qw(mkdircheck); | ||
| 35 | use Cwd; | ||
| 36 | use Data::Dumper; | ||
| 37 | |||
| 38 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 39 | #^^^^^^^^^^ Variables ^^^^^^^^^^^# | ||
| 40 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 41 | |||
| 42 | my ($bam_in,$cwd,$lf,$basename,$bamdir,$bamext); | ||
| 43 | my $logext = ".bam_uniq.log"; | ||
| 44 | my $outdir = getcwd(); | ||
| 45 | my @result = (); | ||
| 46 | my $band = 0; | ||
| 47 | |||
| 48 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 49 | #^^^^^^^^^^^^^^ Main ^^^^^^^^^^^^^# | ||
| 50 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# | ||
| 51 | |||
| 52 | Getopt::Long::config('no_ignore_case'); | ||
| 53 | pod2usage(-verbose => 1) unless GetOptions("bam=s" => \$bam_in, | ||
| 54 | "band" => sub{$band = 1}, | ||
| 55 | "o|out=s" => \$outdir, | ||
| 56 | "l|log=s" => \$logext, | ||
| 57 | "man" => sub{pod2usage(-verbose => 2)}, | ||
| 58 | "help|h" => sub{pod2usage(1)} | ||
| 59 | ); | ||
| 60 | |||
| 61 | unless (-f $bam_in){ | ||
| 62 | warn "Could not find input file $bam_in given via -bam option"; | ||
| 63 | pod2usage(-verbose => 0); | ||
| 64 | } | ||
| 65 | $cwd = getcwd(); | ||
| 66 | unless ($bam_in =~ /^\// || $bam_in =~ /\.\//) {$bam_in = file($cwd,$bam_in);} | ||
| 67 | unless (-d $outdir){mkdircheck($outdir)}; | ||
| 68 | |||
| 69 | ($basename,$bamdir,$bamext) = fileparse($bam_in,qr/\.bam/); | ||
| 70 | $lf = file($outdir,$basename.$logext); | ||
| 71 | |||
| 72 | if ($band == 1){@result = uniquify_bam2($bam_in,$outdir,$lf)} | ||
| 73 | else {@result = uniquify_bam($bam_in,$outdir,$lf)} | ||
| 74 | |||
| 75 | __END__ |