« lib/Bio/Roary/ContigsToGeneIDsFromGFF.pm
↑ Summary
lib/Bio/Roary/Output/GroupsMultifastaNucleotide.pm »
| 1 | undef $VERSION; | ||
| 2 | |||
| 3 | package Bio::Roary::CommandLine::UniqueGenesPerSample; | ||
| 4 | $Bio::Roary::CommandLine::UniqueGenesPerSample::VERSION = '3.13.0'; | ||
| 5 | # ABSTRACT: Take in the clustered file and produce a sorted file with the frequency of each samples unique genes | ||
| 6 | |||
| 7 | |||
| 8 | use Moose; | ||
| 9 | use Getopt::Long qw(GetOptionsFromArray); | ||
| 10 | use Bio::Roary::UniqueGenesPerSample; | ||
| 11 | |||
| 12 | extends 'Bio::Roary::CommandLine::Common'; | ||
| 13 | |||
| 14 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | ||
| 15 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | ||
| 16 | has 'help' => ( is => 'rw', isa => 'Bool', default => 0 ); | ||
| 17 | |||
| 18 | has 'clustered_proteins' => ( is => 'rw', isa => 'Str', default => 'clustered_proteins' ); | ||
| 19 | has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'unique_genes_per_sample.tsv' ); | ||
| 20 | has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 ); | ||
| 21 | has '_error_message' => ( is => 'rw', isa => 'Str' ); | ||
| 22 | |||
| 23 | sub BUILD { | ||
| 24 | my ($self) = @_; | ||
| 25 | |||
| 26 | my ( $clustered_proteins, $output_filename, $verbose, $help ); | ||
| 27 | |||
| 28 | GetOptionsFromArray( | ||
| 29 | $self->args, | ||
| 30 | 'o|output=s' => \$output_filename, | ||
| 31 | 'c|clustered_proteins=s' => \$clustered_proteins, | ||
| 32 | 'v|verbose' => \$verbose, | ||
| 33 | 'h|help' => \$help, | ||
| 34 | ); | ||
| 35 | |||
| 36 | if ( defined($verbose) ) { | ||
| 37 | $self->verbose($verbose); | ||
| 38 | $self->logger->level(10000); | ||
| 39 | } | ||
| 40 | |||
| 41 | $self->help($help) if ( defined($help) ); | ||
| 42 | ( !$self->help ) or die $self->usage_text; | ||
| 43 | |||
| 44 | $self->output_filename($output_filename) if ( defined($output_filename) ); | ||
| 45 | if ( defined($clustered_proteins) && ( -e $clustered_proteins ) ) { | ||
| 46 | $self->clustered_proteins($clustered_proteins); | ||
| 47 | } | ||
| 48 | else { | ||
| 49 | $self->_error_message("Error: Cant access the clustered proteins file"); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | sub run { | ||
| 54 | my ($self) = @_; | ||
| 55 | |||
| 56 | if ( defined( $self->_error_message ) ) { | ||
| 57 | print $self->_error_message . "\n"; | ||
| 58 | die $self->usage_text; | ||
| 59 | } | ||
| 60 | |||
| 61 | my $obj = Bio::Roary::UniqueGenesPerSample->new( | ||
| 62 | clustered_proteins => $self->clustered_proteins, | ||
| 63 | output_filename => $self->output_filename, | ||
| 64 | ); | ||
| 65 | $obj->write_unique_frequency; | ||
| 66 | |||
| 67 | } | ||
| 68 | |||
| 69 | sub usage_text { | ||
| 70 | my ($self) = @_; | ||
| 71 | |||
| 72 | return <<USAGE; | ||
| 73 | Usage: roary-unique_genes_per_sample [options] -c clustered_proteins | ||
| 74 | Take in the clustered file and produce a sorted file with the frequency of each samples unique genes | ||
| 75 | |||
| 76 | Options: -o STR output filename [unique_genes_per_sample.tsv] | ||
| 77 | -c STR clusters filename [clustered_proteins] | ||
| 78 | -v verbose output to STDOUT | ||
| 79 | -h this help message | ||
| 80 | |||
| 81 | For further info see: http://sanger-pathogens.github.io/Roary/ | ||
| 82 | USAGE | ||
| 83 | } | ||
| 84 | |||
| 85 | __PACKAGE__->meta->make_immutable; | ||
| 86 | no Moose; | ||
| 87 | 1; | ||
| 88 | |||
| 89 | __END__ |