| 1 | package Bio::MUST::Drivers::Mafft; | ||||||||||||
| 2 | # ABSTRACT: Bio::MUST driver for running the MAFFT program | ||||||||||||
| 3 | # CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be> | ||||||||||||
| 4 | 6 | $Bio::MUST::Drivers::Mafft::VERSION = '0.210160'; | |||||||||||
| 5 | 6 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 6 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 6 | ▶ | use autodie; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 6 | ▶ | use feature qw(say); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | # use Smart::Comments; | ||||||||||||
| 12 | |||||||||||||
| 13 | 6 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 6 | ▶ | use IPC::System::Simple qw(system); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 6 | ▶ | use Module::Runtime qw(use_module); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 6 | ▶ | use Path::Class qw(file); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | 6 | ▶ | use Bio::MUST::Core; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 6 | extends 'Bio::FastParsers::Base'; | |||||||||||
| 20 | |||||||||||||
| 21 | 6 | ▶ | use Bio::MUST::Drivers::Utils qw(stringify_args); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 6 | ▶ | use aliased 'Bio::MUST::Core::Ali'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | sub align_all { ## no critic (RequireArgUnpacking) | ||||||||||||
| 26 | 0 | ▶ | return shift->_mafft('align_all', @_); | ||||||||||
|
Subroutine
align_all: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | sub seqs2profile { ## no critic (RequireArgUnpacking) | ||||||||||||
| 30 | 0 | ▶ | return shift->_mafft('seqs2profile', @_); | ||||||||||
|
Subroutine
seqs2profile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | sub profile2profile { ## no critic (RequireArgUnpacking) | ||||||||||||
| 34 | 0 | ▶ | my $out = shift->_mafft('profile2profile' , @_); | ||||||||||
|
Subroutine
profile2profile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 35 | 0 | ▶ | return $out if $out; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | |||||||||||||
| 37 | 0 | carp '[BMD] Warning: cannot align profiles; returning nothing!'; | |||||||||||
| 38 | 0 | return; | |||||||||||
| 39 | } | ||||||||||||
| 40 | |||||||||||||
| 41 | sub _mafft { | ||||||||||||
| 42 | 0 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
_mafft: not called CC=6 SCAR=37.4
| |||||||||||||
| 43 | 0 | my $mode = shift; | |||||||||||
| 44 | 0 | my $profile; # conditional declaring is bad... | |||||||||||
| 45 | 0 | ▶ | $profile = shift unless $mode eq 'align_all'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | 0 | ▶ | my $args = shift // {}; | ||||||||||
|
Condition0%0/2
shift() // {}
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 47 | |||||||||||||
| 48 | #### in _mafft | ||||||||||||
| 49 | |||||||||||||
| 50 | # provision executable | ||||||||||||
| 51 | 0 | my $app = use_module('Bio::MUST::Provision::Mafft')->new; | |||||||||||
| 52 | 0 | $app->meet(); | |||||||||||
| 53 | |||||||||||||
| 54 | # setup input/output files | ||||||||||||
| 55 | 0 | my $infile = $self->filename; | |||||||||||
| 56 | 0 | my $outfile = $infile . '.mafft'; | |||||||||||
| 57 | |||||||||||||
| 58 | 0 | ▶ | $args->{$profile} = undef if $profile; # should come last (no --) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | 0 | my $args_str = stringify_args($args); | |||||||||||
| 60 | |||||||||||||
| 61 | 0 | my %opt_for = ( | |||||||||||
| 62 | align_all => q{}, | ||||||||||||
| 63 | seqs2profile => '--add', | ||||||||||||
| 64 | profile2profile => '--addprofile', | ||||||||||||
| 65 | ); | ||||||||||||
| 66 | |||||||||||||
| 67 | # create mafft command | ||||||||||||
| 68 | 0 | my $pgm = 'mafft'; # linsi, ginsi,... do not work | |||||||||||
| 69 | 0 | my $cmd = "$pgm $opt_for{$mode} $infile $args_str > $outfile 2> /dev/null"; | |||||||||||
| 70 | #### $cmd | ||||||||||||
| 71 | |||||||||||||
| 72 | # try to robustly execute mafft | ||||||||||||
| 73 | 0 | my $ret_code = system( [ 0, 1, 127 ], $cmd); | |||||||||||
| 74 | 0 | ▶ | if ($ret_code == 127) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 75 | 0 | carp "[BMD] Warning: cannot execute $pgm command; returning nothing!"; | |||||||||||
| 76 | 0 | return; | |||||||||||
| 77 | } | ||||||||||||
| 78 | 0 | ▶ | if ($ret_code == 1) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 79 | 0 | carp "[BMD] Warning: $pgm cannot align files; returning nothing!"; | |||||||||||
| 80 | 0 | file($outfile)->remove; # ugly but needed | |||||||||||
| 81 | 0 | return; | |||||||||||
| 82 | } | ||||||||||||
| 83 | # TODO: try to bypass shell (need for absolute path to executable then) | ||||||||||||
| 84 | |||||||||||||
| 85 | 0 | my $out = Ali->load($outfile); | |||||||||||
| 86 | |||||||||||||
| 87 | # unlink temp files | ||||||||||||
| 88 | 0 | file($outfile)->remove; | |||||||||||
| 89 | |||||||||||||
| 90 | # return Ali | ||||||||||||
| 91 | 0 | return $out; | |||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | |||||||||||||
| 95 | |||||||||||||
| 96 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 97 | 6 | 1; | |||||||||||
| 98 | |||||||||||||
| 99 | __END__ | ||||||||||||
| 100 | |||||||||||||
| 101 | =pod | ||||||||||||
| 102 | |||||||||||||
| 103 | =head1 NAME | ||||||||||||
| 104 | |||||||||||||
| 105 | Bio::MUST::Drivers::Mafft - Bio::MUST driver for running the MAFFT program | ||||||||||||
| 106 | |||||||||||||
| 107 | =head1 VERSION | ||||||||||||
| 108 | |||||||||||||
| 109 | version 0.210160 | ||||||||||||
| 110 | |||||||||||||
| 111 | =head1 SYNOPSIS | ||||||||||||
| 112 | |||||||||||||
| 113 | # TODO | ||||||||||||
| 114 | |||||||||||||
| 115 | =head1 DESCRIPTION | ||||||||||||
| 116 | |||||||||||||
| 117 | # TODO | ||||||||||||
| 118 | |||||||||||||
| 119 | =head1 AUTHOR | ||||||||||||
| 120 | |||||||||||||
| 121 | Denis BAURAIN <denis.baurain@uliege.be> | ||||||||||||
| 122 | |||||||||||||
| 123 | =head1 CONTRIBUTOR | ||||||||||||
| 124 | |||||||||||||
| 125 | =for stopwords Amandine BERTRAND | ||||||||||||
| 126 | |||||||||||||
| 127 | Amandine BERTRAND <amandine.bertrand@doct.uliege.be> | ||||||||||||
| 128 | |||||||||||||
| 129 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 130 | |||||||||||||
| 131 | This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. | ||||||||||||
| 132 | |||||||||||||
| 133 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 134 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 135 | |||||||||||||
| 136 | =cut | ||||||||||||