| 1 | package Bio::Tradis::CommandLine::PlotTradis; | ||
| 2 | $Bio::Tradis::CommandLine::PlotTradis::VERSION = '1.4.5'; | ||
| 3 | # ABSTRACT: Generate plots as part of a tradis analysis | ||
| 4 | |||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use Getopt::Long qw(GetOptionsFromArray); | ||
| 8 | use Cwd 'abs_path'; | ||
| 9 | use Bio::Tradis::TradisPlot; | ||
| 10 | |||
| 11 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | ||
| 12 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
| 13 | has 'mappedfile' => ( is => 'rw', isa => 'Str', required => 0 ); | ||
| 14 | has 'mapping_score' => ( is => 'rw', isa => 'Int', required => 0, default => 30); | ||
| 15 | has 'help' => ( is => 'rw', isa => 'Bool', required => 0 ); | ||
| 16 | has 'outfile' => ( is => 'rw', isa => 'Str', required => 0, default => 'tradis.plot' ); | ||
| 17 | |||
| 18 | sub BUILD { | ||
| 19 | my ($self) = @_; | ||
| 20 | |||
| 21 | my ( $mappedfile, $outfile, $mapping_score, $help ); | ||
| 22 | |||
| 23 | GetOptionsFromArray( | ||
| 24 | $self->args, | ||
| 25 | 'f|mappedfile=s' => \$mappedfile, | ||
| 26 | 'o|outfile=s' => \$outfile, | ||
| 27 | 'm|mapping_score=i' => \$mapping_score, | ||
| 28 | 'h|help' => \$help | ||
| 29 | ); | ||
| 30 | |||
| 31 | $self->mappedfile( abs_path($mappedfile) ) if ( defined($mappedfile) ); | ||
| 32 | $self->outfile( abs_path($outfile) ) if ( defined($outfile) ); | ||
| 33 | $self->mapping_score($mapping_score) if ( defined($mapping_score) ); | ||
| 34 | $self->help($help) if ( defined($help) ); | ||
| 35 | |||
| 36 | # print usage text if required parameters are not present | ||
| 37 | ($mappedfile) or die $self->usage_text; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub run { | ||
| 41 | my ($self) = @_; | ||
| 42 | |||
| 43 | if ( defined( $self->help ) ) { | ||
| 44 | #if ( scalar( @{ $self->args } ) == 0 ) { | ||
| 45 | $self->usage_text; | ||
| 46 | } | ||
| 47 | |||
| 48 | my $plot = Bio::Tradis::TradisPlot->new( | ||
| 49 | mappedfile => $self->mappedfile, | ||
| 50 | outfile => $self->outfile, | ||
| 51 | mapping_score => $self->mapping_score | ||
| 52 | ); | ||
| 53 | $plot->plot; | ||
| 54 | } | ||
| 55 | |||
| 56 | sub usage_text { | ||
| 57 | print <<USAGE; | ||
| 58 | Create insertion site plot for Artemis | ||
| 59 | |||
| 60 | Usage: tradis_plot -f file.bam [options] | ||
| 61 | |||
| 62 | Options: | ||
| 63 | -f : mapped, sorted bam file | ||
| 64 | -m : mapping quality must be greater than X (optional. default: 30) | ||
| 65 | -o : output base name for plot (optional. default: tradis.plot) | ||
| 66 | |||
| 67 | USAGE | ||
| 68 | exit; | ||
| 69 | } | ||
| 70 | |||
| 71 | __PACKAGE__->meta->make_immutable; | ||
| 72 | no Moose; | ||
| 73 | 1; | ||
| 74 | |||
| 75 | __END__ |