Commit a0dd44a7 authored by Andy Yates's avatar Andy Yates
Browse files

[ENSCORESW-478] and [ENSCORESW-467]. Brought in a Perl::Critic test being run...

[ENSCORESW-478] and [ENSCORESW-467]. Brought in a Perl::Critic test being run on the lowest level. Tests are only run when we have the ENV TEST_AUTHOR is set to a true value. Otherwise it does not impact on the current test cases. Also had to fix a number of issues associcated with these flags. Mostly were due to not using warnings or strict. Anything I felt was ok or not my call has been annotated with a no critic flag.
parent a13dba36
......@@ -623,7 +623,7 @@ sub _parse_features {
my $hstrand = $f[0]->hstrand;
my $slice = $f[0]->slice();
my $hslice = $f[0]->hslice();
my $name = $slice->name() if($slice);
my $name = $slice ? $slice->name() : undef;
my $hname = $f[0]->hseqname;
my $score = $f[0]->score;
my $percent = $f[0]->percent_id;
......
......@@ -70,11 +70,6 @@ normal assembly mapper.
=cut
my $FIRST = 'first';
my $MIDDLE = 'middle';
my $LAST = 'last';
package Bio::EnsEMBL::ChainedAssemblyMapper;
use strict;
......@@ -86,6 +81,10 @@ use Bio::EnsEMBL::Mapper::RangeRegistry;
use Bio::EnsEMBL::Utils::Exception qw(throw deprecate);
use Scalar::Util qw(weaken);
my $FIRST = 'first';
my $MIDDLE = 'middle';
my $LAST = 'last';
#2^20 = approx 10^6
my $CHUNKFACTOR = 20;
......
......@@ -131,6 +131,10 @@ above.
=cut
package Bio::EnsEMBL::DB::ExternalFeatureFactoryI;
use strict;
use warnings;
use Bio::EnsEMBL::External::ExternalFeatureAdaptor;
use vars qw(@ISA);
......
......@@ -126,8 +126,7 @@ sub open_file{
throw("Cannot perform open with unsupported operator:\t${file_op}${filepath}");
}
my $fh;
my $success = open($fh, "${file_op}${filepath}");
my $success = open my $fh, $file_op, $filepath;
#$fh will be still be GLOB on fail
#These warn instead of throw/die to allow
......
......@@ -1003,7 +1003,7 @@ sub get_dumped_data {
my $data = shift;
$data =~ s/\n|\r|\f|\\//g;
return eval ($data);
return eval ($data); ## no critic
}
......
......@@ -515,12 +515,11 @@ sub fetch_all_by_Slice_and_external_dbname_link {
my $dbe_adaptor = $self->db()->get_DBEntryAdaptor();
my %linked_genes;
foreach $external_db_id (@external_db_ids) {
my @linked_genes = $dbe_adaptor->list_gene_ids_by_external_db_id($external_db_id);
foreach my $gene_id (@linked_genes) {
$linked_genes{$gene_id} = 1;
}
foreach my $local_external_db_id (@external_db_ids) {
my @linked_genes = $dbe_adaptor->list_gene_ids_by_external_db_id($local_external_db_id);
foreach my $gene_id (@linked_genes) {
$linked_genes{$gene_id} = 1;
}
}
# Get all the genes on the slice.
......@@ -1878,9 +1877,11 @@ sub fetch_all_by_exon_supporting_evidence {
throw("feature type must be dna_align_feature or protein_align_feature");
}
my $anal_from = ", analysis a " if ($analysis);
my $anal_where = "AND a.analysis_id = f.analysis_id AND a.analysis_id=? "
if ($analysis);
my ($anal_from, $anal_where);
if($analysis) {
$anal_from = ", analysis a ";
$anal_where = "AND a.analysis_id = f.analysis_id AND a.analysis_id=? ";
}
my $sql = qq(
SELECT DISTINCT(g.gene_id)
......@@ -1943,9 +1944,11 @@ sub fetch_all_by_transcript_supporting_evidence {
throw("feature type must be dna_align_feature or protein_align_feature");
}
my $anal_from = ", analysis a " if ($analysis);
my $anal_where = "AND a.analysis_id = f.analysis_id AND a.analysis_id=? "
if ($analysis);
my ($anal_from, $anal_where);
if($analysis) {
$anal_from = ", analysis a ";
$anal_where = "AND a.analysis_id = f.analysis_id AND a.analysis_id=? ";
}
my $sql = qq(
SELECT DISTINCT(g.gene_id)
......
......@@ -847,9 +847,9 @@ sub get_all_SearchFeatures {
sub dynamic_use {
my( $self, $classname ) = @_;
my( $parent_namespace, $module ) = $classname =~/^(.*::)(.*?)$/;
no strict 'refs';
no strict 'refs'; ## no critic
return 1 if $parent_namespace->{$module.'::'}; # return if already used
eval "require $classname";
eval "require $classname"; ## no critic
if($@) {
warn "DrawableContainer: failed to use $classname\nDrawableContainer: $@";
return 0;
......
......@@ -343,6 +343,7 @@ sub sort_exons {
my $self = shift;
my $exons = shift;
## no critic
return sort {
( $a->[0]->common_sr_name cmp $b->[0]->common_sr_name ) ||
( $a->[1] <=> $b->[1] )
......@@ -497,7 +498,7 @@ sub run_exonerate {
$self->conf()->param('lsf_opt_exonerate') );
local *BSUB;
open( BSUB, $bsub_cmd )
open( BSUB, $bsub_cmd ) ## no critic
or $self->logger->error("Could not open open pipe to bsub: $!\n");
print BSUB $exonerate_job;
......@@ -688,11 +689,11 @@ sub parse_exonerate_results {
$num_files++;
open( F, '<', "$dump_path/$file" );
open( my $fh, '<', "$dump_path/$file" );
my $threshold = $self->conf->param('exonerate_threshold') || 0.5;
while (<F>) {
while (<$fh>) {
$num_lines++;
chomp;
......
......@@ -18,7 +18,7 @@
=cut
package Bio::EnsEMBL::IdMapping::StableIdGenerator::AedesAegypti;
package Bio::EnsEMBL::IdMapping::StableIdGenerator::AnophelesGambiae;
# Package that implements incrementing and verification of Aedes aegypti
# stable IDs as used by the VectorBase project.
......
......@@ -390,7 +390,7 @@ sub rescore_gene_matrix_lsf {
$self->logger->debug("$cmd\n\n");
local *BSUB;
open( BSUB, $bsub_cmd )
open( BSUB, $bsub_cmd ) ## no critic
or $self->logger->error("Could not open open pipe to bsub: $!\n");
print BSUB $cmd;
......
......@@ -169,7 +169,8 @@ sub seq {
# sort edits in reverse order to remove complication of
# adjusting downstream edits
my @allele_features_ordered = sort {$b->start() <=> $a->start() || $b->end() <=> $a->end()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my @allele_features_ordered;
@allele_features_ordered = sort {$b->start() <=> $a->start() || $b->end() <=> $a->end()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
foreach my $af (@allele_features_ordered){
$af->apply_edit($reference_sequence); #change, in the reference sequence, the af
......@@ -343,7 +344,8 @@ sub mapper{
my $mapper = Bio::EnsEMBL::Mapper->new('Slice','IndividualSlice');
#align with Slice
#get all the VariationFeatures in the Individual Slice, from start to end in the Slice
my @allele_features_ordered = sort {$a->start() <=> $b->start() || $b->end() <=> $a->end()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my @allele_features_ordered;
@allele_features_ordered = sort {$a->start() <=> $b->start() || $b->end() <=> $a->end()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my $start_slice = 1;
my $end_slice;
......@@ -485,7 +487,8 @@ sub subseq {
#apply all differences to the reference sequence
# sort edits in reverse order to remove complication of
# adjusting downstream edits
my @allele_features_ordered = sort {$b->start() <=> $a->start() || $b->end() <=> $a->end()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my @allele_features_ordered;
@allele_features_ordered = sort {$b->start() <=> $a->start() || $b->end() <=> $a->end()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my $af_start;
my $af_end;
foreach my $af (@allele_features_ordered){
......
......@@ -36,6 +36,9 @@ is carried out using C<subseq()> calls.
package Bio::EnsEMBL::PaddedSlice;
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Argument qw/rearrange/;
use Bio::EnsEMBL::Utils::Scalar qw/assert_ref assert_strand/;
use base qw/Bio::EnsEMBL::Utils::Proxy/;
......@@ -162,11 +165,11 @@ sub subseq {
#Return if we were upstream of overlap
if($start < $parent_start && $end < $parent_start) {
return N x (( $end - $start )+1);
return 'N' x (( $end - $start )+1);
}
#Return if we were downstream of overlap
if($start > $parent_end && $end > $parent_end) {
return N x (( $end - $start )+1);
return 'N' x (( $end - $start )+1);
}
my $prefix = '';
......@@ -174,11 +177,11 @@ sub subseq {
my $subslice_start = ($start - $parent_start)+1;
my $subslice_end = ($end - $parent_start) + 1;
if($start < $parent_start) {
$prefix = N x ($parent_start - $start);
$prefix = 'N' x ($parent_start - $start);
$subslice_start = 1;
}
if($end > $parent_end) {
$suffix = N x ($end - $parent_end);
$suffix = 'N' x ($end - $parent_end);
$subslice_end = (($parent_end - $parent_start)+1);
}
......
......@@ -135,7 +135,7 @@ sub checksum {
sub permissions {
my ($self, $file) = @_;
my $mode = 0666;
my $mode = 0666; ## no critic
chmod($mode, $file) or $self->throw("Cannot perform the chmod to mode $mode for file $file");
return;
}
......
......@@ -37,7 +37,7 @@ Allowed parameters are:
=cut
package Bio::EnsEMBL::Pipeline::FASTA::FindDirs;
package Bio::EnsEMBL::Pipeline::Flatfile::FindDirs;
use strict;
use warnings;
......
......@@ -71,11 +71,11 @@ sub store_attrib {
sub run_pepstats {
my ($self, $tmpfile) = @_;
my $PEPSTATS = $self->param('binpath') . '/bin/pepstats';
open(OUT, "$PEPSTATS -filter < $tmpfile 2>&1 |");
my @lines = <OUT>;
open(my $fh, "$PEPSTATS -filter < $tmpfile 2>&1 |"); ## no critic
my @lines = <$fh>;
my $attribs = {};
my $tid;
close(OUT);
close($fh);
foreach my $line (@lines) {
if ($line =~ /PEPSTATS of ([^ ]+)/) {
......@@ -130,7 +130,7 @@ sub dump_translation {
my $helper = $dba->dbc()->sql_helper();
my $dbtype = $self->param('dbtype');
my $ta = Bio::EnsEMBL::Registry->get_adaptor($self->param('species'), $dbtype, 'translation');
open(TMP, "> $tmpfile");
open(my $fh, '>', $tmpfile);
my $sql = q{
SELECT tl.translation_id
FROM translation tl, transcript tr, seq_region s, coord_system cs
......@@ -146,9 +146,9 @@ sub dump_translation {
if ($peptide_seq !~ /\n$/) {
$peptide_seq .= "\n";
}
print TMP ">$dbid\n$peptide_seq";
print $fh ">$dbid\n$peptide_seq";
}
close(TMP);
close($fh);
} ## end sub dump_translation
1;
......@@ -50,6 +50,9 @@ $segment->from_start(), $segement->from_end(), $segment->to_Slice().
package Bio::EnsEMBL::ProjectionSegment;
use strict;
use warnings;
#
# WARNING: THIS CLASS IS REPRESENTED BY A BLESSED ARRAY REFERENCE
# NOT A HASH REFERENCE
......
......@@ -355,7 +355,7 @@ sub load_all {
$adaptor, $section );
}
my $test_eval = eval "require $adaptor";
my $test_eval = eval "require $adaptor"; ## no critic
if ($@ or (!$test_eval)) { die($@) }
$adaptor->new(%adaptor_args);
......@@ -370,7 +370,7 @@ sub load_all {
if($NEW_EVAL) {
require Bio::EnsEMBL::Utils::IO;
my $contents = Bio::EnsEMBL::Utils::IO::slurp($config_file);
$test_eval = eval $contents;
$test_eval = eval $contents; ## no critic
}
else {
$test_eval = eval { require($config_file) };
......@@ -1024,7 +1024,7 @@ sub get_adaptor {
my $dba = $registry_register{_SPECIES}{$species}{ lc($group) }{'_DB'};
my $module = $ret;
my $test_eval = eval "require $module";
my $test_eval = eval "require $module"; ## no critic
if ($@ or (!$test_eval)) {
warning("'$module' cannot be found.\nException $@\n");
return;
......@@ -1856,7 +1856,7 @@ sub load_registry_from_db {
# Variation
my $test_eval = eval "require Bio::EnsEMBL::Variation::DBSQL::DBAdaptor";
my $test_eval = eval "require Bio::EnsEMBL::Variation::DBSQL::DBAdaptor"; ## no critic
if ($@or (!$test_eval)) {
# Ignore variations as code required not there for this
if ($verbose) {
......@@ -1938,7 +1938,7 @@ sub load_registry_from_db {
} ## end foreach my $multidb (@variation_multidbs)
}
my $func_eval = eval "require Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor";
my $func_eval = eval "require Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor"; ## no critic
if ($@ or (!$func_eval)) {
if ($verbose) {
# Ignore funcgen DBs as code required not there for this
......@@ -2023,7 +2023,7 @@ sub load_registry_from_db {
my @compara_dbs = grep { /^ensembl_compara/ } @dbnames;
if (@compara_dbs) {
my $comp_eval = eval "require Bio::EnsEMBL::Compara::DBSQL::DBAdaptor";
my $comp_eval = eval "require Bio::EnsEMBL::Compara::DBSQL::DBAdaptor"; ## no critic
if ($@ or (!$comp_eval)) {
# Ignore Compara as code required not there for this
if ($verbose) {
......
......@@ -264,23 +264,25 @@ sub seq {
#apply all differences to the reference sequence
#first, in case there are any indels, create the new sequence (containing the '-' bases)
# sort edits in reverse order to remove complication of
# sort edits in reverse order to remove complication of
# adjusting downstream edits
my @indels_ordered = sort {$b->start() <=> $a->start()} @{$self->{'alignIndels'}} if (defined $self->{'alignIndels'});
my @indels_ordered;
@indels_ordered = sort {$b->start() <=> $a->start()} @{$self->{'alignIndels'}} if (defined $self->{'alignIndels'});
foreach my $vf (@indels_ordered){
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
}
#need to find coverage information if diffe
# sort edits in reverse order to remove complication of
# adjusting downstream edits
my @variation_features_ordered = sort {$b->start() <=> $a->start()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my @variation_features_ordered;
@variation_features_ordered = sort {$b->start() <=> $a->start()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
foreach my $vf (@variation_features_ordered){
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
$vf->apply_edit($reference_sequence); #change, in the reference sequence, the vf
}
#need to find coverage information if different from reference
my $indAdaptor = $self->adaptor->db->get_db_adaptor('variation')->get_IndividualAdaptor;
my $ref_strain = $indAdaptor->get_reference_strain_name;
......@@ -293,7 +295,7 @@ sub seq {
return 'N' x $self->length();
}
sub expanded_length() {
sub expanded_length {
my $self = shift;
my $length = $self->SUPER::length();
......@@ -335,7 +337,8 @@ sub _add_coverage_information{
# and unmasks seq where there is read coverage
# get all length-changing vars
my @indels_ordered = sort {$a->start() <=> $b->start()} @{$self->{'alignIndels'}} if (defined $self->{'alignIndels'});
my @indels_ordered;
@indels_ordered = sort {$a->start() <=> $b->start()} @{$self->{'alignIndels'}} if (defined $self->{'alignIndels'});
my $masked_seq = '~' x length($$reference_sequence);
......@@ -724,7 +727,8 @@ sub mapper{
my $mapper = Bio::EnsEMBL::Mapper->new('Slice','StrainSlice');
#align with Slice
#get all the VariationFeatures in the strain Slice, from start to end in the Slice
my @variation_features_ordered = sort {$a->start() <=> $b->start()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my @variation_features_ordered;
@variation_features_ordered = sort {$a->start() <=> $b->start()} @{$self->{'alleleFeatures'}} if (defined $self->{'alleleFeatures'});
my $start_slice = 1;
my $end_slice;
......
......@@ -43,6 +43,9 @@ my $transcripts = $truncated_gene->get_all_Transcripts();
package Bio::EnsEMBL::SubSlicedFeature;
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Argument qw/rearrange/;
use base qw/Bio::EnsEMBL::Utils::Proxy/;
......
......@@ -85,11 +85,12 @@ bypassing object creation via the related BaseFeatureAdaptor method.
package Bio::EnsEMBL::Utils::Collector;
use Bio::EnsEMBL::Utils::Argument ('rearrange');
use Bio::EnsEMBL::Utils::Exception ('throw');
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Argument ('rearrange');
use Bio::EnsEMBL::Utils::Exception ('throw');
### Global package config vars
# Defaults
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment