lib/Bio/AutomatedAnnotation/External/Cmscan.pm

filter: Statementstmt 100% 59 / 59 Branchbran 83.3% 10 / 12 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 93.9% 78 / 83 CC 9 SCAR 13.6
CC
9
Cov
96%
_build_features
7.0
_build__cpus
2.1
add_features_to_prokka_structure
2.0
CRAP 3.9
« lib/Bio/AutomatedAnnotation/ParseGenesFromGFFs.pm ↑ Summary lib/Bio/AutomatedAnnotation/ParseGenesFromGFF.pm »
1 package Bio::AutomatedAnnotation::External::Cmscan;
2  
3 # ABSTRACT: Run and parse the output of cmscan
4  
5  
6 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 has 'cmdb' => ( is => 'ro', isa => 'Str', required => 1 );
10 3 has 'input_file' => ( is => 'ro', isa => 'Str', required => 1 );
11  
12 3 has 'exec' => ( is => 'ro', isa => 'Str', default => 'cmscan' );
13 3 has 'version' => ( is => 'ro', isa => 'Str', default => '1.1' );
14 3 has 'cpus' => ( is => 'ro', isa => 'Int', default => 1 );
15 3 has 'evalue' => ( is => 'ro', isa => 'Num', default => 1E-6 );
16 3 has 'features' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_features' );
17 3 has 'number_of_features' => ( is => 'rw', isa => 'Int', default => 0 );
18  
19 3 has '_tool' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__tool' );
20 3 has '_cpus' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build__cpus' );
21 3 has '_infernal_fh' => ( is => 'ro', lazy => 1, builder => '_build__infernal_fh' );
22  
23 sub _build__tool {
24 1 ▶ my ($self) = @_;
Subroutine _build__tool: called CC=1 SCAR=0.0
25 1 return "Infernal:" . $self->version;
26 }
27  
28 sub _build__cpus {
29 1 ▶ my ($self) = @_;
Subroutine _build__cpus: called CC=2 SCAR=7.2
30 1 ▶ return $self->cpus || 1;
Condition50%1/2
$self->cpus || 1
l!l
10
MC/DC0%0/1
$self->cpus || 1
$self->cpus
Truth table50%1/2
A
A= $self->cpus
Aresult
11
00
31 }
32  
33 sub _build__infernal_fh {
34 1 ▶ my ($self) = @_;
Subroutine _build__infernal_fh: called CC=1 SCAR=0.0
35 1 open(
36 my $fh,
37 '-|',
38 join(
39 ' ',
40 (
41 $self->exec, '--cpu', $self->_cpus, '-E', $self->evalue, '--tblout',
42 '/dev/stdout', '-o', '/dev/null', '--noali', $self->cmdb, $self->input_file
43 )
44 )
45 );
46 1 return $fh;
47 }
48  
49 sub _build_features {
50 1 ▶ my ($self) = @_;
Subroutine _build_features: called CC=7 SCAR=19.5
51 1 my %features;
52
53 1 my $number_of_features = 0;
54 1 my $fh = $self->_infernal_fh;
55 1 ▶ while ( <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 18 1 19
56 18 ▶ next if (/\#/);
Branch: 1 branch
BranchTrueFalseTotal
if /\#/ 12 6 18
57 6 my @x = split ' '; # magic Perl whitespace splitter
58 6 ▶ next if ( @x < 16 );
Branch: 1 branch
BranchTrueFalseTotal
if @x < 16 0 6 6
59 6 ▶ next unless $x[1] =~ m/^RF\d/;
Branch: 1 branch
BranchTrueFalseTotal
unless $x[1] =~ /^RF\d/ 0 6 6
60  
61 # The start coord is always the lowest
62 6 my $sequence_id = $x[2];
63 6 my $start_coords = $x[7];
64 6 my $end_coords = $x[8];
65 6 ▶ my $current_strand = $x[9] eq '-' ? -1 : +1;
Branch: 1 branch
BranchTrueFalseTotal
$x[9] eq '-' ? : 1 5 6
66  
67 6 ▶ if ( $start_coords > $end_coords ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_coords > $end_coords) 1 5 6
68 1 my $tmp_coords = $end_coords;
69 1 $end_coords = $start_coords;
70 1 $start_coords = $tmp_coords;
71 1 $current_strand = -1;
72 }
73  
74 6 push @{ $features{$sequence_id} },
75 Bio::SeqFeature::Generic->new(
76 -primary => 'ncRNA',
77 -seq_id => $sequence_id,
78 -source => $self->_tool,
79 -start => $start_coords,
80 -end => $end_coords,
81 -strand => $current_strand,
82 -frame => 0,
83 -tag => {
84 'product' => $x[0],
85 'inference' => "COORDINATES:profile:" . $self->_tool,
86 }
87 );
88 6 $number_of_features++;
89  
90 }
91 1 $self->number_of_features($number_of_features);
92 1 return \%features;
93 }
94  
95  
96 sub add_features_to_prokka_structure
97 {
98 2 ▶ my ($self, $prokka_sequence_structure) = @_;
Subroutine add_features_to_prokka_structure: called CC=2 SCAR=6.9
Pod undocumented
99 2 for my $sequence_id (keys %{$self->features})
100 {
101 8 push(@{$prokka_sequence_structure->{$sequence_id}{FEATURE}}, @{$self->features->{$sequence_id}});
102 }
103 2 return $prokka_sequence_structure;
104 }
105  
106 3 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 3 __PACKAGE__->meta->make_immutable;
108  
109 3 1;
110  
111 __END__
112  
113 =pod
114  
115 =encoding UTF-8
116  
117 =head1 NAME
118  
119 Bio::AutomatedAnnotation::External::Cmscan - Run and parse the output of cmscan
120  
121 =head1 VERSION
122  
123 version 1.182685
124  
125 =head1 SYNOPSIS
126  
127 Run and parse the output of cmscan
128 use Bio::AutomatedAnnotation::External::Cmscan;
129  
130 my $obj = Bio::AutomatedAnnotation::External::Cmscan->new(
131 cmdb => 'database/cm/Bacteria',
132 input_file => 'abc.fa',
133 exec => 'cmscan',
134 version => '1.1',
135 cpus => 1,
136 evalue => 1E-6,
137 );
138 $obj->features;
139  
140 =head1 AUTHOR
141  
142 Andrew J. Page <ap13@sanger.ac.uk>
143  
144 =head1 COPYRIGHT AND LICENSE
145  
146 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
147  
148 This is free software, licensed under:
149  
150 The GNU General Public License, Version 3, June 2007
151  
152 =cut
« lib/Bio/AutomatedAnnotation/ParseGenesFromGFFs.pm ↑ Summary lib/Bio/AutomatedAnnotation/ParseGenesFromGFF.pm »