| 1 | package Bio::Tradis::CommandLine::CheckTags; | ||
| 2 | $Bio::Tradis::CommandLine::CheckTags::VERSION = '1.4.5'; | ||
| 3 | # ABSTRACT: Check for presence of tr tag in BAM file | ||
| 4 | |||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use Getopt::Long qw(GetOptionsFromArray); | ||
| 8 | use Cwd 'abs_path'; | ||
| 9 | use Bio::Tradis::DetectTags; | ||
| 10 | |||
| 11 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | ||
| 12 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
| 13 | has 'bamfile' => ( is => 'rw', isa => 'Str', required => 0 ); | ||
| 14 | has 'help' => ( is => 'rw', isa => 'Bool', required => 0 ); | ||
| 15 | has 'samtools_exec' => ( is => 'rw', isa => 'Str', default => 'samtools' ); | ||
| 16 | |||
| 17 | sub BUILD { | ||
| 18 | my ($self) = @_; | ||
| 19 | |||
| 20 | my ( | ||
| 21 | $bamfile, $help, $samtools_exec | ||
| 22 | ); | ||
| 23 | |||
| 24 | GetOptionsFromArray( | ||
| 25 | $self->args, | ||
| 26 | 'b|bamfile=s' => \$bamfile, | ||
| 27 | 'h|help' => \$help, | ||
| 28 | 'samtools_exec=s' => \$samtools_exec, | ||
| 29 | ); | ||
| 30 | |||
| 31 | $self->bamfile(abs_path($bamfile)) if ( defined($bamfile) ); | ||
| 32 | $self->help($help) if ( defined($help) ); | ||
| 33 | $self->samtools_exec($samtools_exec) if ( defined($samtools_exec) ); | ||
| 34 | |||
| 35 | # print usage text if required parameters are not present | ||
| 36 | ($bamfile) or die $self->usage_text; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub run { | ||
| 40 | my ($self) = @_; | ||
| 41 | |||
| 42 | if ( defined( $self->help ) ) { | ||
| 43 | $self->usage_text; | ||
| 44 | } | ||
| 45 | |||
| 46 | my $tagcheck = Bio::Tradis::DetectTags->new(bamfile => $self->bamfile, samtools_exec => $self->samtools_exec ); | ||
| 47 | print $tagcheck->tags_present . "\n"; | ||
| 48 | } | ||
| 49 | |||
| 50 | sub usage_text { | ||
| 51 | print <<USAGE; | ||
| 52 | Check for the existence of tradis tags in a bam | ||
| 53 | |||
| 54 | Usage: check_tags -b file.bam | ||
| 55 | |||
| 56 | Options: | ||
| 57 | -b : bam file with tradis tags | ||
| 58 | |||
| 59 | USAGE | ||
| 60 | exit; | ||
| 61 | } | ||
| 62 | |||
| 63 | __PACKAGE__->meta->make_immutable; | ||
| 64 | no Moose; | ||
| 65 | 1; | ||
| 66 | |||
| 67 | __END__ |