Skip to content

Commit

Permalink
Tidy.
Browse files Browse the repository at this point in the history
  • Loading branch information
iansealy committed Aug 27, 2020
1 parent 95a6381 commit 4ffa1e2
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 129 deletions.
3 changes: 1 addition & 2 deletions lib/DETCT/Analysis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,7 @@ sub get_all_ensembl_db_types {

return [
sort keys %{ $ensembl_db_type{ id $self}
|| { $DEFAULT_ENSEMBL_DB_TYPE => 1 } }
];
|| { $DEFAULT_ENSEMBL_DB_TYPE => 1 } } ];
}

=method slice_adaptor
Expand Down
2 changes: 1 addition & 1 deletion lib/DETCT/GeneFinder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ sub add_existing_gene_annotation {
my $end = $region->[2];
my $strand = $region->[7]; ## no critic (ProhibitMagicNumbers)
my $annotation = $region->[-1];
my $key = join q{:}, $seq_name, $start, $end, $strand;
my $key = join q{:}, $seq_name, $start, $end, $strand;
$gene_annotation{$key} = $annotation;
}

Expand Down
14 changes: 7 additions & 7 deletions lib/DETCT/Misc/Output.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ sub dump_as_table { ## no critic (ProhibitExcessComplexity)
[ $transcript_stable_id, $transcript_stable_id ];
push @transcript_biotype, $transcript_biotype;
}
push @name, $name;
push @name, $name;
push @name_to_link, [ $gene_stable_id, $name ];
push @description, $description;
push @description, $description;
}
}
push @row, [ \@distance ];
Expand Down Expand Up @@ -338,11 +338,11 @@ sub get_definition {

my @def;

push @def, [ 'Chr', $STRING, $loc_link, ];
push @def, [ 'Region start', $INT, $loc_link, ];
push @def, [ 'Region end', $INT, $loc_link, ];
push @def, [ q{3' end position}, $INT, $loc_link, ];
push @def, [ q{3' end strand}, $INT, ];
push @def, [ 'Chr', $STRING, $loc_link, ];
push @def, [ 'Region start', $INT, $loc_link, ];
push @def, [ 'Region end', $INT, $loc_link, ];
push @def, [ q{3' end position}, $INT, $loc_link, ];
push @def, [ q{3' end strand}, $INT, ];
push @def, [ q{3' end read count}, $INT, ];
push @def, [ 'p value', $FLOAT, ];
push @def, [ 'Adjusted p value', $FLOAT, ];
Expand Down
2 changes: 1 addition & 1 deletion lib/DETCT/Misc/R.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ sub run_deseq { ## no critic (ProhibitExcessComplexity)
}
open my $samples_fh, '>', $samples_file;
write_or_die( $samples_fh, ( join "\t", @header ), "\n" );
write_or_die( $samples_fh, $samples_text );
write_or_die( $samples_fh, $samples_text );
close $samples_fh;

my $control_condition = q{-};
Expand Down
2 changes: 1 addition & 1 deletion lib/DETCT/Misc/SSAHA2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ sub parse_ssaha2 {
$alignment_length, $percent_id
) = split /\s+/xms, $line;
my ( $seq_name, $index ) = split /:/xms, $query_id;
$strand = $strand eq q{F} ? q{+} : q{-};
$strand = $strand eq q{F} ? q{+} : q{-};
$percent_id = int $percent_id + 0.5; ## no critic (ProhibitMagicNumbers)
push @{ $alignments{$seq_name}{$index} },
[
Expand Down
2 changes: 1 addition & 1 deletion lib/DETCT/Misc/Tag.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sub detag_trim_fastq {
my $tag_length = length $arg_ref->{read_tags}[0];

my $min_polyt = q{T} x $arg_ref->{polyt_min_length};
my $polyt_re = qr/$min_polyt/xms; # Regexp for polyT matching
my $polyt_re = qr/$min_polyt/xms; # Regexp for polyT matching

my $read1_required_length = $arg_ref->{read1_required_length};
my $read2_required_length = $arg_ref->{read2_required_length};
Expand Down
6 changes: 3 additions & 3 deletions lib/DETCT/Pipeline.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private sleep_time => my %sleep_time; # e.g. 600
private skip_clean_up => my %skip_clean_up; # e.g. 1
private serialiser_format => my %serialiser_format; # e.g. json
private memory_limit_multiplier => my %memory_limit_multiplier; # e.g. 1000
private stage_to_run => my %stage_to_run; # DETCT::Pipeline::Stage object
private stage_to_run => my %stage_to_run; # DETCT::Pipeline::Stage object
private component_to_run => my %component_to_run; # e.g. 5
private all_stages_run => my %all_stages_run; # e.g. 1
private jobs_running => my %jobs_running; # e.g. 1
Expand Down Expand Up @@ -1813,8 +1813,8 @@ sub num_pending_jobs {

return 0 if $self->scheduler ne 'lsf';

my @output = capture('busers');
my @fields = split /\s+/xms, $output[1]; # Ignore header line
my @output = capture('busers');
my @fields = split /\s+/xms, $output[1]; # Ignore header line
my $num_pending_jobs = $fields[4]; ## no critic (ProhibitMagicNumbers)

if ( $num_pending_jobs !~ m/\A \d+ \z/xms ) {
Expand Down
6 changes: 3 additions & 3 deletions lib/DETCT/Pipeline/DiffExpr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,9 @@ sub run_summarise_read_peaks {
bin_size => $self->analysis->bin_size,
peak_buffer_width => $self->analysis->peak_buffer_width,
hmm_sig_level => $self->analysis->hmm_sig_level,
total_bp => $self->analysis->total_bp * 2, # Two strands
read_length => $self->analysis->read2_length,
peaks => \@merged_peaks,
total_bp => $self->analysis->total_bp * 2, # Two strands
read_length => $self->analysis->read2_length,
peaks => \@merged_peaks,
}
);

Expand Down
2 changes: 1 addition & 1 deletion script/dump_ensembl_transcripts.pl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ =head1 EXAMPLES
foreach my $transcript (
sort {
$a->seq_region_start <=> $b->seq_region_start
|| $a->seq_region_end <=> $b->seq_region_end
|| $a->seq_region_end <=> $b->seq_region_end
} @{$transcripts}
)
{
Expand Down
4 changes: 2 additions & 2 deletions script/extract_regions_with_multiple_ends.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ sub check_regions {

## no critic (ProhibitMagicNumbers)
# Get region ID by joining chr, start, end and strand
my $region = join q{:}, @fields[ 0, 1, 2, 4 ];
my $genes = $fields[9];
my $region = join q{:}, @fields[ 0, 1, 2, 4 ];
my $genes = $fields[9];
my @three_prime_end_pos = split /,/xms, $fields[3];
## use critic
next if !$genes;
Expand Down
6 changes: 3 additions & 3 deletions script/filter_output.pl
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,10 @@ sub write_log {
push @output, $reason;
push @output, $end->[$THREE_PRIME_END_READ_COUNT_FIELD];
push @output, $end->[$IS_POLYA_FIELD];
push @output, $end->[$UPSTREAM_14_BP_FIELD] || q{-};
push @output, $end->[$DOWNSTREAM_14_BP_FIELD] || q{-};
push @output, $end->[$UPSTREAM_14_BP_FIELD] || q{-};
push @output, $end->[$DOWNSTREAM_14_BP_FIELD] || q{-};
push @output, $end->[$DISTANCE_HEXAMER_UPSTREAM_FIELD] || q{-};
push @output, $end->[$HEXAMER_FIELD] || q{-};
push @output, $end->[$HEXAMER_FIELD] || q{-};

if ( $end->[$CONTINUOUS_RNASEQ_TRANSCRIPTS_FIELD] ) {
my @pairs = split /[|]/xms,
Expand Down
4 changes: 2 additions & 2 deletions script/make_test_fastq.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ =head1 EXAMPLES
write_or_die( $fh2, q{@}, $read_name, '/2', "\n" );
write_or_die( $fh2, get_read2_seq($read_length), "\n" );
write_or_die( $fh2, "+\n" );
write_or_die( $fh2, q{~} x $read_length, "\n" );
write_or_die( $fh2, q{~} x $read_length, "\n" );

if ( !$has_polyt ) {
$tag = $read_tags[-1]; # Dummy tag
Expand Down Expand Up @@ -157,7 +157,7 @@ sub get_read1_seq {
# 20% of reads have a single mismatch somewhere in the tag
if ( int rand 5 ) { ## no critic (ProhibitMagicNumbers)
my $mismatch_base = int rand length $tag;
my $base = substr $tag, $mismatch_base, 1;
my $base = substr $tag, $mismatch_base, 1;
$base =~ tr/AGCT/TCGA/;
substr $tag, $mismatch_base, 1, $base;
}
Expand Down
2 changes: 1 addition & 1 deletion script/make_test_sam.pl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ =head1 EXAMPLES
my $read_tag = $read_tags[ int rand $#read_tags + 1 ]; # Random tag
my $sequenced_read_tag = get_sequenced_read_tag($read_tag);
my $read1_qname = get_qname( $qname_base, $sequenced_read_tag );
my $read2_qname = $read1_qname; # Always the same
my $read2_qname = $read1_qname; # Always the same
my ( $read1_pos, $read2_pos ) =
get_pos( $length_of{$seq_region}, $read1_length, $read2_length );
my ( $read1_flag, $read2_flag ) = get_flag( $read1_pos, $read2_pos );
Expand Down
2 changes: 1 addition & 1 deletion script/manipulate_three_prime_ends.pl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ sub output_ends {
my @end_data = split /[:\/]/xms, $end, 11;
## use critic
splice @end_data, 1, 1; # Remove redundant strand
# Split last field into transcripts and distances
# Split last field into transcripts and distances
my @pairs = split /[|]/xms, pop @end_data;
@pairs = map { [ split />/xms ] } @pairs;
push @end_data, join q{,}, map { $_->[0] } @pairs;
Expand Down
2 changes: 1 addition & 1 deletion script/perturb_sam.pl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ =head1 EXAMPLES
else {
my @fields = split /\t/xms, $line;
my $seq_region = $fields[2];
my $pos = $fields[3]; ## no critic (ProhibitMagicNumbers)
my $pos = $fields[3]; ## no critic (ProhibitMagicNumbers)
my $move =
( int rand( $max_move * 2 + 1 ) ) - $max_move; # e.g. -200 to 200
$pos += $move;
Expand Down
6 changes: 3 additions & 3 deletions script/prioritise_regions_with_multiple_ends.pl
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ sub get_genes_with_multiple_ends {

## no critic (ProhibitMagicNumbers)
# Get region ID by joining chr, start, end and strand
my $region = join q{:}, @fields[ 0, 1, 2, 4 ];
my $genes = $fields[9];
my $region = join q{:}, @fields[ 0, 1, 2, 4 ];
my $genes = $fields[9];
my @three_prime_end_pos = split /,/xms, $fields[3];
## use critic
next if !$genes;
Expand Down Expand Up @@ -233,7 +233,7 @@ sub get_significance_matrix {
my $genes = $fields[9];

# Get region ID by joining chr, start, end and strand
my $region = join q{:}, @fields[ 0, 1, 2, 4 ];
my $region = join q{:}, @fields[ 0, 1, 2, 4 ];
my $adjusted_pvalue = $fields[7];
## use critic

Expand Down
4 changes: 2 additions & 2 deletions script/subset_de_output.pl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ sub get_counts_by_region {

open my $fh, '<', $file; ## no critic (RequireBriefOpen)
# Get range for count columns
my $header = <$fh>;
my @headings = DETCT::Misc::Output::parse_line( $header, $extension );
my $header = <$fh>;
my @headings = DETCT::Misc::Output::parse_line( $header, $extension );
my $counts_start = 15; ## no critic (ProhibitMagicNumbers)
my $counts_end;
my $ordinal = $counts_start;
Expand Down
26 changes: 13 additions & 13 deletions t/analysis-diffexpr.t
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ qr/Invalid peak buffer width/ms, 'Invalid peak buffer width';
# Test HMM significance level attribute
is( $analysis->hmm_sig_level, 0.001, 'Get HMM significance level' );
is( $analysis->set_hmm_sig_level(0.1), undef, 'Set HMM significance level' );
is( $analysis->hmm_sig_level, 0.1, 'Get new HMM significance level' );
is( $analysis->hmm_sig_level, 0.1, 'Get new HMM significance level' );
throws_ok { $analysis->set_hmm_sig_level() }
qr/No HMM significance level specified/ms, 'No HMM significance level';
throws_ok { $analysis->set_hmm_sig_level(1) }
Expand Down Expand Up @@ -141,7 +141,7 @@ throws_ok { $analysis->set_r_binary() } qr/No R binary specified/ms,
'No R binary';

# Test DESeq script attribute
is( $analysis->deseq_script, 'script/run_deseq.R', 'Get DESeq script' );
is( $analysis->deseq_script, 'script/run_deseq.R', 'Get DESeq script' );
is( $analysis->set_deseq_script('script'), undef, 'Set DESeq script' );
is( $analysis->deseq_script, 'script', 'Get new DESeq script' );
throws_ok { $analysis->set_deseq_script() } qr/No DESeq script specified/ms,
Expand Down Expand Up @@ -313,7 +313,7 @@ is( $analysis->ensembl_user, 'anonymous', 'Get new Ensembl username' );
# Test Ensembl password attribute
is( $analysis->ensembl_pass, undef, 'Get Ensembl password' );
is( $analysis->set_ensembl_pass('secret'), undef, 'Set Ensembl password' );
is( $analysis->ensembl_pass, 'secret', 'Get new Ensembl password' );
is( $analysis->ensembl_pass, 'secret', 'Get new Ensembl password' );

# Test Ensembl database name attribute
is( $analysis->ensembl_name, undef, 'Get Ensembl database name' );
Expand Down Expand Up @@ -350,23 +350,23 @@ $sample->set_always( 'bam_file', 't/data/test1.bam' );
$sample->set_always( 'name', 'zmp_ph1_1m' );
$sample->set_always( 'tag', 'NNNNBGAGGC' );
$sample->set_always( 'condition', 'mutant' );
$sample->set_always( 'groups', [] );
$sample->set_always( 'groups', [] );

# Mock sample object with different reference sequence
my $sample_diff = Test::MockObject->new();
$sample_diff->set_isa('DETCT::Sample');
$sample_diff->set_always( 'bam_file', 't/data/test3.bam' );
$sample_diff->set_always( 'name', 'zmp_ph1_1s' );
$sample_diff->set_always( 'tag', 'NNNNBCGCAA' );
$sample_diff->set_always( 'groups', [] );
$sample_diff->set_always( 'groups', [] );

my $sample2 = Test::MockObject->new();
$sample2->set_isa('DETCT::Sample');
$sample2->set_always( 'bam_file', 't/data/test2.bam' );
$sample2->set_always( 'name', 'zmp_ph1_2m' );
$sample2->set_always( 'tag', 'NNNNBCAGAG' );
$sample2->set_always( 'condition', 'mutant' );
$sample2->set_always( 'groups', [] );
$sample2->set_always( 'groups', [] );

# Test adding and retrieving samples
my $samples;
Expand Down Expand Up @@ -400,7 +400,7 @@ $sample_dupe_name->set_isa('DETCT::Sample');
$sample_dupe_name->set_always( 'bam_file', 't/data/test1.bam' );
$sample_dupe_name->set_always( 'name', 'zmp_ph1_1m' );
$sample_dupe_name->set_always( 'tag', 'NNNNBAGAAG' );
$sample_dupe_name->set_always( 'groups', [] );
$sample_dupe_name->set_always( 'groups', [] );

throws_ok { $analysis->add_sample($sample_dupe_name) } qr/is duplicated/ms,
'Duplicated sample name';
Expand All @@ -419,7 +419,7 @@ $sample_dupe_tag_bam->set_isa('DETCT::Sample');
$sample_dupe_tag_bam->set_always( 'name', 'zmp_ph1_4s' );
$sample_dupe_tag_bam->set_always( 'bam_file', 't/data/test1.bam' );
$sample_dupe_tag_bam->set_always( 'tag', 'NNNNBGAGGC' );
$sample_dupe_tag_bam->set_always( 'groups', [] );
$sample_dupe_tag_bam->set_always( 'groups', [] );

throws_ok { $analysis->add_sample($sample_dupe_tag_bam) }
qr/Multiple samples have the same tag/ms, 'Duplicated tag and BAM file';
Expand All @@ -438,7 +438,7 @@ $sample_diff_groups->set_isa('DETCT::Sample');
$sample_diff_groups->set_always( 'name', 'zmp_ph1_2m' );
$sample_diff_groups->set_always( 'bam_file', 't/data/test2.bam' );
$sample_diff_groups->set_always( 'tag', 'NNNNBCAGAG' );
$sample_diff_groups->set_always( 'groups', ['1'] );
$sample_diff_groups->set_always( 'groups', ['1'] );

throws_ok { $analysis->add_sample($sample_diff_groups) }
qr/Samples do not all have same number of groups/ms, 'Different groups';
Expand All @@ -454,7 +454,7 @@ $sample_dupe_group1->set_isa('DETCT::Sample');
$sample_dupe_group1->set_always( 'name', 'zmp_ph1_1m' );
$sample_dupe_group1->set_always( 'bam_file', 't/data/test1.bam' );
$sample_dupe_group1->set_always( 'tag', 'NNNNBGAGGC' );
$sample_dupe_group1->set_always( 'groups', [ '1', '2' ] );
$sample_dupe_group1->set_always( 'groups', [ '1', '2' ] );
$analysis->add_sample($sample_dupe_group1);

# Mock sample object with different number of groups
Expand All @@ -463,7 +463,7 @@ $sample_dupe_group2->set_isa('DETCT::Sample');
$sample_dupe_group2->set_always( 'name', 'zmp_ph1_2m' );
$sample_dupe_group2->set_always( 'bam_file', 't/data/test2.bam' );
$sample_dupe_group2->set_always( 'tag', 'NNNNBCAGAG' );
$sample_dupe_group2->set_always( 'groups', [ '2', '3' ] );
$sample_dupe_group2->set_always( 'groups', [ '2', '3' ] );

throws_ok { $analysis->add_sample($sample_dupe_group2) }
qr/is duplicated between groups/ms, 'Duplicate groups';
Expand All @@ -481,7 +481,7 @@ $sample_missing_tag->set_isa('DETCT::Sample');
$sample_missing_tag->set_always( 'bam_file', 't/data/test1.bam' );
$sample_missing_tag->set_always( 'name', 'zmp_ph1_5s' );
$sample_missing_tag->set_always( 'tag', 'NNNNBTGAATC' );
$sample_missing_tag->set_always( 'groups', [] );
$sample_missing_tag->set_always( 'groups', [] );

throws_ok { $analysis->add_sample($sample_missing_tag) }
qr/does not contain tag/ms, 'Tag missing from BAM files';
Expand All @@ -492,7 +492,7 @@ $sample_no_index->set_isa('DETCT::Sample');
$sample_no_index->set_always( 'name', 'zmp_ph1_6s' );
$sample_no_index->set_always( 'bam_file', 't/data/test4.bam' );
$sample_no_index->set_always( 'tag', 'NNNNBGAGGC' );
$sample_no_index->set_always( 'groups', [] );
$sample_no_index->set_always( 'groups', [] );

throws_ok { $analysis->add_sample($sample_no_index) } qr/has no index/ms,
'BAM file with no index file';
Expand Down
Loading

0 comments on commit 4ffa1e2

Please sign in to comment.