blib/lib/Bio/Tradis/CommandLine/TradisBam.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 71 CC 6 SCAR 22.3
CC
6
Cov
0%
BUILD
20.0
run
12.0
usage_text
2.0
CRAP 9.3
1 package Bio::Tradis::CommandLine::TradisBam;
2  
3 # ABSTRACT: Adds tags to sequences if tags are present
4  
5  
6 use Moose;
7 use Getopt::Long qw(GetOptionsFromArray);
8 use Cwd 'abs_path';
9 use Bio::Tradis::DetectTags;
10 use Bio::Tradis::AddTagsToSeq;
11  
12 has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
13 has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
14 has 'bamfile' => ( is => 'rw', isa => 'Str', required => 1 );
15 has 'outfile' => (
16 is => 'rw',
17 isa => 'Str',
18 required => 0,
19 default => sub {
20 my $o = $self->bamfile;
21 $o =~ s/\.bam/\.tr\.bam/;
22 return $o;
23 }
24 );
25 has 'help' => ( is => 'rw', isa => 'Bool', required => 0 );
26  
27 sub BUILD {
28 my ($self) = @_;
29  
30 my ( $bamfile, $help, $outfile );
31  
32 GetOptionsFromArray(
33 $self->args,
34 'b|bamfile=s' => \$bamfile,
35 'o|outfile=s' => \$outfile,
36 'h|help' => \$help
37 );
38  
39 $self->bamfile( abs_path($bamfile) ) if ( defined($bamfile) );
40 $self->outfile( abs_path($outfile) ) if ( defined($outfile) );
41 $self->help($help) if ( defined($help) );
42  
43 # print usage text if required parameters are not present
44 ($bamfile) or die $self->usage_text;
45 }
46  
47 sub run {
48 my ($self) = @_;
49  
50 if ( defined( $self->help ) ) {
51 #if ( scalar( @{ $self->args } ) == 0 ) {
52 $self->usage_text;
53 }
54  
55 my $is_tradis =
56 Bio::Tradis::DetectTags->new( bamfile => $self->bamfile )->tags_present;
57 if ( defined($is_tradis) && $is_tradis == 1 ) {
58 my $add_tag_obj = Bio::Tradis::AddTagsToSeq->new(
59 bamfile => $self->bamfile,
60 outfile => $self->outfile
61 );
62 $add_tag_obj->add_tags_to_seq;
63 }
64 }
65  
66 sub usage_text {
67 print <<USAGE;
68 Checks for tradis tags in the BAM and outputs processed TraDIS BAM file
69 with tags attached
70  
71 Usage: bam_to_tradis_bam -b file.bam [options]
72  
73 Options:
74 -b : bam file
75 -o : output BAM name (optional. default: <file>.tr.bam)
76  
77 USAGE
78 exit;
79 }
80  
81 __PACKAGE__->meta->make_immutable;
82 no Moose;
83 1;
84  
85 __END__
86  
87 =pod
88  
89 =head1 NAME
90  
91 Bio::Tradis::CommandLine::TradisBam - Adds tags to sequences if tags are present
92  
93 =head1 VERSION
94  
95 version 1.132190
96  
97 =head1 SYNOPSIS
98  
99 Checks for tradis tags in the BAM and outputs processed TraDIS BAM file
100 with tags attached
101  
102 =head1 AUTHOR
103  
104 Carla Cummins <cc21@sanger.ac.uk>
105  
106 =head1 COPYRIGHT AND LICENSE
107  
108 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
109  
110 This is free software, licensed under:
111  
112 The GNU General Public License, Version 3, June 2007
113  
114 =cut