| 1 | package Bio::Roary::ExtractProteomeFromGFFs; | ||||||||||
| 2 | 5 | $Bio::Roary::ExtractProteomeFromGFFs::VERSION = '3.13.0'; | |||||||||
| 3 | # ABSTRACT: Take in GFF files and create protein sequences in FASTA format | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 5 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 5 | ▶ | use Bio::Roary::Exceptions; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 5 | ▶ | use Bio::Roary::ExtractProteomeFromGFF; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 5 | ▶ | use File::Basename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 5 | ▶ | use Cwd qw(getcwd); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 5 | ▶ | use File::Temp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 5 | with 'Bio::Roary::JobRunner::Role'; | |||||||||
| 13 | |||||||||||
| 14 | 5 | has 'gff_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | |||||||||
| 15 | 5 | has 'fasta_files' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build_fasta_files' ); | |||||||||
| 16 | 5 | has 'fasta_files_to_gff_files' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_fasta_files_to_gff_files' ); | |||||||||
| 17 | 5 | has 'apply_unknowns_filter' => ( is => 'rw', isa => 'Bool', default => 1 ); | |||||||||
| 18 | 5 | has '_queue' => ( is => 'rw', isa => 'Str', default => 'small' ); | |||||||||
| 19 | 5 | has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 ); | |||||||||
| 20 | 5 | has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||
| 21 | 5 | ▶ | has 'working_directory' => ( is => 'ro', isa => 'File::Temp::Dir', default => sub { File::Temp->newdir( DIR => getcwd, CLEANUP => 1 ); } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | sub _build__extract_proteome_objects | ||||||||||
| 24 | 0 | ▶ | { | ||||||||
|
Subroutine
_build__extract_proteome_objects: not called CC=2 SCAR=17.9
| |||||||||||
| 25 | 0 | my ($self) = @_; | |||||||||
| 26 | |||||||||||
| 27 | 0 | my %extract_proteome_objects; | |||||||||
| 28 | 0 | for my $filename ( @{ $self->gff_files } ) { | |||||||||
| 29 | 0 | my $extract_proteome = Bio::Roary::ExtractProteomeFromGFF->new( | |||||||||
| 30 | gff_file => $filename, | ||||||||||
| 31 | ); | ||||||||||
| 32 | 0 | $extract_proteome_objects{ $filename } = $extract_proteome; | |||||||||
| 33 | } | ||||||||||
| 34 | 0 | return \%extract_proteome_objects; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 24 | ▶ | sub _build_fasta_files { | ||||||||
|
Subroutine
_build_fasta_files: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 24 | my ($self) = @_; | |||||||||
| 39 | 24 | my @fasta_files = sort values( %{$self->fasta_files_to_gff_files} ); | |||||||||
| 40 | 24 | return \@fasta_files; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 24 | ▶ | sub _build_fasta_files_to_gff_files { | ||||||||
|
Subroutine
_build_fasta_files_to_gff_files: called CC=3 SCAR=11.0
| |||||||||||
| 44 | 24 | my ($self) = @_; | |||||||||
| 45 | |||||||||||
| 46 | 24 | my %fasta_files; | |||||||||
| 47 | my @commands_to_run; | ||||||||||
| 48 | 24 | for my $filename ( @{ $self->gff_files } ) | |||||||||
| 49 | { | ||||||||||
| 50 | 20 | ▶ | print "Extracting proteins from $filename\n" if($self->verbose); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 20 | my($gff_filename_without_directory, $directories, $suffix) = fileparse($filename); | |||||||||
| 52 | 20 | my $output_suffix = "proteome.faa"; | |||||||||
| 53 | |||||||||||
| 54 | 20 | my $output_filename = $filename.'.'.$output_suffix; | |||||||||
| 55 | 20 | $fasta_files{ $filename } = $self->working_directory.'/'.$gff_filename_without_directory.'.'.$output_suffix; | |||||||||
| 56 | 20 | push(@commands_to_run, "extract_proteome_from_gff --translation_table ".$self->translation_table." --apply_unknowns_filter ".$self->apply_unknowns_filter." -d ".$self->working_directory." -o $output_suffix $filename"); | |||||||||
| 57 | } | ||||||||||
| 58 | #Farm out the computation and block until its ready | ||||||||||
| 59 | 24 | my $job_runner_obj = $self->_job_runner_class->new( commands_to_run => \@commands_to_run, memory_in_mb => $self->memory_in_mb, queue => $self->_queue, cpus => $self->cpus); | |||||||||
| 60 | 24 | $job_runner_obj->run(); | |||||||||
| 61 | |||||||||||
| 62 | 24 | return \%fasta_files; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 5 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 66 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||
| 67 | |||||||||||
| 68 | 5 | 1; | |||||||||
| 69 | |||||||||||
| 70 | __END__ | ||||||||||