| 1 | 1 | undef $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 2 | package Bio::Roary::CommandLine::GeneAlignmentFromNucleotides; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | $Bio::Roary::CommandLine::GeneAlignmentFromNucleotides::VERSION = '3.13.0'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Take in a multifasta file of nucleotides, convert to proteins and align with PRANK | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Bio::Roary::AnnotateGroups; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Bio::Roary::External::Prank; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Bio::Roary::Output::GroupsMultifastaProtein; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Bio::Roary::SortFasta; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Bio::Roary::External::Mafft; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | extends 'Bio::Roary::CommandLine::Common'; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | has 'help' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | has 'nucleotide_fasta_files' => ( is => 'rw', isa => 'ArrayRef' ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | has '_error_message' => ( is => 'rw', isa => 'Str' ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | has 'mafft' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | has '_min_similarity' => ( is => 'rw', isa => 'Num', default => 0.98 ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my ( $nucleotide_fasta_files, $help, $verbose,$mafft, ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | GetOptionsFromArray( | |||||||||||||||||||||||||||||||||||||||||
| 33 | $self->args, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 'v|verbose' => \$verbose, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 'n|mafft' => \$mafft, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 'h|help' => \$help, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( defined($verbose) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->verbose($verbose); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->logger->level(10000); | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $self->mafft($mafft) if (defined($mafft)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $self->help($help) if ( defined($help) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ( @{ $self->args } == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->_error_message("Error: You need to provide at least 1 FASTA file"); | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | for my $filename ( @{ $self->args } ) { | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ( !-e $filename ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->_error_message("Error: Cant access file $filename"); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $self->nucleotide_fasta_files( $self->args ); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | ( !$self->help ) or die $self->usage_text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( defined( $self->_error_message ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | print $self->_error_message . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | die $self->usage_text; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | for my $fasta_file ( @{ $self->nucleotide_fasta_files } ) { | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $sort_fasta_before = Bio::Roary::SortFasta->new( | |||||||||||||||||||||||||||||||||||||||||
| 70 | input_filename => $fasta_file, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | make_multiple_of_three => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $sort_fasta_before->sort_fasta->replace_input_with_output_file; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ( $sort_fasta_before->sequences_unaligned == 1 || $sort_fasta_before->sequences_unaligned == 0 && $sort_fasta_before->similarity <= $self->_min_similarity) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$sort_fasta_before->sequences_unaligned == 1 or $sort_fasta_before->sequences_unaligned == 0 and $sort_fasta_before->similarity <= $self->_min_similarity
$sort_fasta_before->sequences_unaligned == 0 and $sort_fasta_before->similarity <= $self->_min_similarity
MC/DC0%0/3
$sort_fasta_before->sequences_unaligned == 1 or $sort_fasta_before->sequences_unaligned == 0 and $sort_fasta_before->similarity <= $self->_min_similarity
$sort_fasta_before->sequences_unaligned == 1
$sort_fasta_before->sequences_unaligned == 0
$sort_fasta_before->similarity <= $self->_min_similarity
Truth table0%0/4
A or B and C
A= $sort_fasta_before->sequences_unaligned == 1B= $sort_fasta_before->sequences_unaligned == 0C= $sort_fasta_before->similarity <= $self->_min_similarity
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ( $self->mafft == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $mafft_obj = Bio::Roary::External::Mafft->new( | |||||||||||||||||||||||||||||||||||||||||
| 79 | input_filename => $fasta_file, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | output_filename => $fasta_file . '.aln', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | job_runner => 'Local', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | logger => $self->logger, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | verbose => $self->verbose | ||||||||||||||||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $mafft_obj->run(); | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $prank_obj = Bio::Roary::External::Prank->new( | |||||||||||||||||||||||||||||||||||||||||
| 90 | input_filename => $fasta_file, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | output_filename => $fasta_file . '.aln', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | job_runner => 'Local', | ||||||||||||||||||||||||||||||||||||||||||
| 93 | logger => $self->logger, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | verbose => $self->verbose | ||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $prank_obj->run(); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | move( $fasta_file, $fasta_file . '.aln' ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $sort_fasta_after_revtrans = Bio::Roary::SortFasta->new( | |||||||||||||||||||||||||||||||||||||||||
| 104 | input_filename => $fasta_file . '.aln', | ||||||||||||||||||||||||||||||||||||||||||
| 105 | remove_nnn_from_end => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $sort_fasta_after_revtrans->sort_fasta->replace_input_with_output_file; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | unlink($fasta_file); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub usage_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return <<USAGE; | |||||||||||||||||||||||||||||||||||||||||
| 116 | Usage: protein_alignment_from_nucleotides [options] *.fa | ||||||||||||||||||||||||||||||||||||||||||
| 117 | Take in multi-FASTA files of nucleotides and align each file with PRANK or MAFFT | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | Options: -n nucleotide alignment with MAFFT | ||||||||||||||||||||||||||||||||||||||||||
| 120 | -v verbose output to STDOUT | ||||||||||||||||||||||||||||||||||||||||||
| 121 | -h this help message | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | For further info see: http://sanger-pathogens.github.io/Roary/ | ||||||||||||||||||||||||||||||||||||||||||
| 124 | USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | __END__ | ||||||||||||||||||||||||||||||||||||||||||