Bio-Roary

 view release on metacpan or  search on metacpan

lib/Bio/Roary/PostAnalysis.pm  view on Meta::CPAN

    $self->_assembly_statistics->create_summary_output;

    $self->logger->info("Creating tab files for R");
    $self->_number_of_groups_obj->create_output_files;

    system("create_pan_genome_plots.R") unless ( $self->dont_create_rplots == 1 );

    $self->logger->info("Create EMBL files");
    $self->_create_embl_files;

    my $clusters_not_exceeded = 1;
    if ( $self->output_multifasta_files ) {
        $self->logger->info("Creating files with the nucleotide sequences for every cluster");
        $clusters_not_exceeded = $self->_groups_multifastas_nuc_obj->create_files();
    }

    $self->_delete_intermediate_files;
    if ( $clusters_not_exceeded == 0 && $self->output_multifasta_files ) {
        $self->logger->error("Exiting early because number of clusters is too high");
        exit();
    }
}

sub _build__assembly_statistics {
    my ($self) = @_;
    return Bio::Roary::AssemblyStatistics->new(
        spreadsheet     => $self->_group_statistics_obj->output_filename,
        core_definition => $self->core_definition,

lib/Bio/Roary/QC/Report.pm  view on Meta::CPAN

		my @parts = split( "\t" );
		chomp @parts;

		$top_genus = $parts[5] if ( (! defined $top_genus) && $parts[3] eq 'G' );
		$top_species = $parts[5] if ( (! defined $top_species) && $parts[3] eq 'S' );

		last if (defined $top_genus && defined $top_species);
	}
    close($report_fh);

	$top_genus   ||= "not_found";
	$top_genus   =~ s/^\s+//g;
	$top_species ||= "not_found";
	$top_species =~ s/^\s+//g;

	return [ $sample_base_name, $top_genus, $top_species ];
}


sub _build__header {
	return join( ',', ( 'Sample', 'Genus', 'Species' ) );
}

t/Bio/Roary/CommandLine/Roary.t  view on Meta::CPAN

{
	skip "extended tests not run",  40 unless ( defined($ENV{ROARY_FULL_TESTS}));

    %scripts_and_expected_files = (
        '-o some_different_output -i 90 -p 2 --translation_table 1 t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'some_different_output', 't/data/expected_some_different_output' ],
    	);
    mock_execute_script_and_check_output_sorted( $script_name, \%scripts_and_expected_files, [ 0 ] );
    
    stderr_should_have($script_name,'--translation_table 1  -o some_different_output --core_definition 60 -p 2 -e --mafft  --group_limit 10 t/data/real_data_1.gff t/data/real_data_2.gff', 'Exiting early because number of clusters is too high');
    stderr_should_have($script_name,'--verbose_stats --group_limit 10 -e t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff', 'Exiting early because number of clusters is too high');
    stderr_should_not_have($script_name,'-e --group_limit 10 t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ', 'Cant access the multifasta base directory');
    stderr_should_have($script_name,'-i 90 --core_definition 60 -p 2 -v t/data/real_data_1.gff t/data/real_data_2.gff ','Cleaning up files'); 
    stderr_should_have($script_name,'-i 30 t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff','The percentage identity is too low');
    stderr_should_not_have($script_name,'--dont_delete_files -v t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ','Cleaning up files');
    stderr_should_have($script_name,'-v --group_limit 100000 -e t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ' ,'Running command: pan_genome_core_alignment');
    stderr_should_have($script_name,'--translation_table 1 -v t/data/real_data_1.gff t/data/real_data_2.gff ' ,'Cleaning up files');
    stderr_should_have($script_name,'-e -v t/data/real_data_1.gff t/data/real_data_2.gff ','Creating files with the nucleotide sequences for every cluster');
    
    SKIP:
    {
        skip "kraken not installed",        2 unless ( which('kraken') );
        skip "kraken-report not installed", 2 unless ( which('kraken-report') );
        stderr_should_have($script_name,'-v --qc t/data/real_data_1.gff t/data/real_data_2.gff' ,'Running Kraken on each input assembly');
    }

t/lib/TestHelper.pm  view on Meta::CPAN

        local *STDERR;
        open STDERR, '>/dev/null' or warn "Can't open /dev/null: $!";
	    stdout_like { eval("$script_name->new(args => \\\@input_args, script_name => '$script_name')->run;"); } qr/$expected/, "got expected text $expected for $parameters";
        close STDERR;
    }
    open STDERR, '>&OLDERR' or die "Can't restore stderr: $!";
    close OLDERR or die "Can't close OLDERR: $!";
}


sub stdout_should_not_have
{
	my ( $script_name, $parameters, $expected ) = @_;
	my @input_args = split( " ", $parameters );
	open OLDERR, '>&STDERR';
	eval("use $script_name ;");
    my $returned_values = 0;
    {
        local *STDERR;
        open STDERR, '>/dev/null' or warn "Can't open /dev/null: $!";
	    stdout_unlike { eval("$script_name->new(args => \\\@input_args, script_name => '$script_name')->run;"); } qr/$expected/, "got expected text $expected for $parameters";
        close STDERR;
    }
    open STDERR, '>&OLDERR' or die "Can't restore stderr: $!";
    close OLDERR or die "Can't close OLDERR: $!";
}



sub stderr_should_not_have
{
	my ( $script_name, $parameters, $expected ) = @_;
	my @input_args = split( " ", $parameters );
	open OLDOUT, '>&STDOUT';
	eval("use $script_name ;");
    my $returned_values = 0;
    {
        local *STDOUT;
        open STDOUT, '>/dev/null' or warn "Can't open /dev/null: $!";
	    stderr_unlike { eval("$script_name->new(args => \\\@input_args, script_name => '$script_name')->run;"); } qr/$expected/, "got expected text $expected for $parameters";



( run in 1.003 second using v1.01-cache-2.11-cpan-0a987023a57 )