[med-svn] [roary] 01/03: Imported Upstream version 3.5.9+dfsg

Sascha Steinbiss sascha at steinbiss.name
Fri Feb 19 13:46:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository roary.

commit dcd24ab2c5d00ba0cfea3eba473781281449d962
Author: Sascha Steinbiss <sascha at steinbiss.name>
Date:   Fri Feb 19 13:34:45 2016 +0000

    Imported Upstream version 3.5.9+dfsg
---
 dist.ini                              |  2 +-
 lib/Bio/Roary/AccessoryBinaryFasta.pm | 44 ++++++++++++++++++++++++-----------
 t/Bio/Roary/AccessoryBinaryFasta.t    | 25 ++++++++++++++++++++
 3 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/dist.ini b/dist.ini
index ececa65..31db1e8 100644
--- a/dist.ini
+++ b/dist.ini
@@ -1,5 +1,5 @@
 name    = Bio-Roary
-version = 3.5.8
+version = 3.5.9
 author  = Andrew J. Page <ap13 at sanger.ac.uk>
 license = GPL_3
 copyright_holder = Wellcome Trust Sanger Institute
diff --git a/lib/Bio/Roary/AccessoryBinaryFasta.pm b/lib/Bio/Roary/AccessoryBinaryFasta.pm
index 9f7fd16..b398878 100644
--- a/lib/Bio/Roary/AccessoryBinaryFasta.pm
+++ b/lib/Bio/Roary/AccessoryBinaryFasta.pm
@@ -20,13 +20,16 @@ use Bio::Roary::Exceptions;
 use Bio::SeqIO;
 use File::Basename;
 
-has 'input_files'         => ( is => 'ro', isa => 'ArrayRef',                   required => 1 );
-has 'annotate_groups_obj' => ( is => 'ro', isa => 'Bio::Roary::AnnotateGroups', required => 1 );
-has 'analyse_groups_obj'  => ( is => 'ro', isa => 'Bio::Roary::AnalyseGroups',  required => 1 );
-has 'output_filename'     => ( is => 'ro', isa => 'Str',                        default  => 'accessory_binary_genes.fa' );
-has 'groups_to_files'     => ( is => 'ro', isa => 'HashRef',                    lazy     => 1, builder => '_build__groups_to_files' );
-has '_lower_bound_value'  => ( is => 'ro', isa => 'Int',                        lazy     => 1, builder => '_build__lower_bound_value' );
-has '_upper_bound_value'  => ( is => 'ro', isa => 'Int',                        lazy     => 1, builder => '_build__upper_bound_value' );
+has 'input_files'            => ( is => 'ro', isa => 'ArrayRef',                   required => 1 );
+has 'annotate_groups_obj'    => ( is => 'ro', isa => 'Bio::Roary::AnnotateGroups', required => 1 );
+has 'analyse_groups_obj'     => ( is => 'ro', isa => 'Bio::Roary::AnalyseGroups',  required => 1 );
+has 'output_filename'        => ( is => 'ro', isa => 'Str',                        default  => 'accessory_binary_genes.fa' );
+has 'lower_bound_percentage' => ( is => 'ro', isa => 'Int',                        default  => 5 );
+has 'upper_bound_percentage' => ( is => 'ro', isa => 'Int',                        default  => 5 );
+has 'max_accessory_to_include' => ( is => 'ro', isa => 'Int',                      default  => 4000 );
+has 'groups_to_files'        => ( is => 'ro', isa => 'HashRef',                    lazy     => 1, builder => '_build__groups_to_files' );
+has '_lower_bound_value'     => ( is => 'ro', isa => 'Int',                        lazy     => 1, builder => '_build__lower_bound_value' );
+has '_upper_bound_value'     => ( is => 'ro', isa => 'Int',                        lazy     => 1, builder => '_build__upper_bound_value' );
 
 sub _build__groups_to_files {
     my ($self) = @_;
@@ -44,22 +47,37 @@ sub _build__groups_to_files {
     return \%groups_to_files;
 }
 
+sub _build__lower_bound_value {
+    my ($self) = @_;
+    my $num_files = @{ $self->input_files };
+    return ceil( $num_files * ( $self->lower_bound_percentage / 100 ) );
+}
+
+sub _build__upper_bound_value {
+    my ($self) = @_;
+    my $num_files = @{ $self->input_files };
+    return $num_files - ceil( $num_files * ( $self->upper_bound_percentage / 100 ) );
+}
+
 sub create_accessory_binary_fasta {
     my ($self) = @_;
     my $out_seq_io = Bio::SeqIO->new( -file => ">" . $self->output_filename, -format => 'Fasta' );
 
     for my $full_filename ( @{ $self->input_files } ) {
-        my ( $filename, $dirs, $suffix ) = fileparse($full_filename);
-
+        my($filename, $dirs, $suffix) = fileparse($full_filename);
+        
         my $output_sequence = '';
         my $sample_name     = $filename;
         $sample_name =~ s!\.gff\.proteome\.faa!!;
 
-        my $gene_count = 0;
+		my $gene_count = 0;
         for my $group ( sort keys %{ $self->groups_to_files } ) {
+			last if($gene_count > $self->max_accessory_to_include);
 
             my @files = keys %{ $self->groups_to_files->{$group} };
 
+            next if ( @files <= $self->_lower_bound_value || @files > $self->_upper_bound_value );
+
             my $group_to_file_genes = $self->groups_to_files->{$group}->{$full_filename};
             if ( defined($group_to_file_genes) && @{$group_to_file_genes} > 0 ) {
                 $output_sequence .= 'A';
@@ -67,10 +85,10 @@ sub create_accessory_binary_fasta {
             else {
                 $output_sequence .= 'C';
             }
-            $gene_count++;
-
+			$gene_count++;
+			
         }
-        next if ( $output_sequence eq '' );
+		next if($output_sequence eq '');
         $out_seq_io->write_seq( Bio::Seq->new( -display_id => $sample_name, -seq => $output_sequence ) );
     }
     return 1;
diff --git a/t/Bio/Roary/AccessoryBinaryFasta.t b/t/Bio/Roary/AccessoryBinaryFasta.t
index 1c0870e..435839b 100755
--- a/t/Bio/Roary/AccessoryBinaryFasta.t
+++ b/t/Bio/Roary/AccessoryBinaryFasta.t
@@ -33,6 +33,8 @@ ok(
             group_3 => { 't/abc/aaa' => [1], 't/abc/bbb' => [2], 't/abc/ccc' => [3] },
             group_4 => { 't/abc/aaa' => [1], 't/abc/bbb' => [2], 't/abc/ccc' => [3], 't/abc/ddd' => [4] },
         },
+		_lower_bound_value  => 0,
+		_upper_bound_value  => 4,
 		annotate_groups_obj => $dummy_annotate_groups,
 		analyse_groups_obj  => $dummy_analyse_groups
     ),
@@ -44,4 +46,27 @@ ok( $obj->create_accessory_binary_fasta(), 'create output file' );
 compare_ok( 'accessory_binary_genes.fa', 't/data/expected_accessory_binary_genes.fa','binary accessory fasta file created');
 
 
+ok(
+    $obj = Bio::Roary::AccessoryBinaryFasta->new(
+        input_files => [ 'aaa', 'bbb', 'ccc', 'ddd' ],
+        groups_to_files => 
+		{
+            group_1 => { 'aaa' => [1] },
+            group_2 => { 'aaa' => [1], 'bbb' => [2] },
+            group_3 => { 'aaa' => [1], 'bbb' => [2], 'ccc' => [3] },
+            group_4 => { 'aaa' => [1], 'bbb' => [2], 'ccc' => [3], 'ddd' => [4] },
+        },
+		annotate_groups_obj => $dummy_annotate_groups,
+		analyse_groups_obj  => $dummy_analyse_groups
+    ),
+    'initialise accessory binary fasta file bounded'
+);
+
+is($obj->_lower_bound_value, 1, 'lower bound value');
+is($obj->_upper_bound_value, 3, 'upper bound value');
+ok( $obj->create_accessory_binary_fasta(), 'create output file bounded' );
+
+compare_ok( 'accessory_binary_genes.fa', 't/data/expected_accessory_binary_genes_bounded.fa','binary accessory fasta file created bounded');
+
+
 done_testing();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/roary.git



More information about the debian-med-commit mailing list