[Bioperl-guts-l] bioperl-run/Bio/Tools/Run/Phylo PhyloBase.pm, 1.2, 1.3

Senduran Balasubramaniam sendu at dev.open-bio.org
Thu Jan 25 10:42:33 EST 2007


Update of /home/repository/bioperl/bioperl-run/Bio/Tools/Run/Phylo
In directory dev.open-bio.org:/tmp/cvs-serv30677/Bio/Tools/Run/Phylo

Modified Files:
	PhyloBase.pm 
Log Message:
added _alignment_object() method

Index: PhyloBase.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-run/Bio/Tools/Run/Phylo/PhyloBase.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PhyloBase.pm	12 Jan 2007 15:13:58 -0000	1.2
--- PhyloBase.pm	25 Jan 2007 15:42:31 -0000	1.3
***************
*** 73,77 ****
   Function: Writes the supplied alignment object out in the desired format to
             a temp file.
!  Returns : n/a (sets _alignment_file())
   Args    : Bio::Align::AlignI AND format (default 'fasta');
  
--- 73,77 ----
   Function: Writes the supplied alignment object out in the desired format to
             a temp file.
!  Returns : n/a (sets _alignment_file() and _alignment_object())
   Args    : Bio::Align::AlignI AND format (default 'fasta');
  
***************
*** 80,83 ****
--- 80,84 ----
  sub _writeAlignFile {
      my ($self, $align, $format) = @_;
+     $self->_alignment_object($align);
      $format ||= 'fasta';
      
***************
*** 248,252 ****
   Usage   : @names = $obj->_get_seq_names()
   Function: Get all the sequence names (from id()) of the sequenes in the
!            alignment. _alignment_file() must be set prior to calling this.
   Returns : list of strings (seq ids)
   Args    : input format of the alignment file (defaults to guess)
--- 249,253 ----
   Usage   : @names = $obj->_get_seq_names()
   Function: Get all the sequence names (from id()) of the sequenes in the
!            alignment.  _alignment_object() must be set prior to calling this.
   Returns : list of strings (seq ids)
   Args    : input format of the alignment file (defaults to guess)
***************
*** 256,264 ****
  sub _get_seq_names {
      my $self = shift;
!     my $file = $self->_alignment_file || $self->throw("Alignment filename hasn't been set with _alignment_file");
!     my $format = shift;
!     
!     my $align_in = Bio::AlignIO->new(-verbose => $self->verbose, -file => $file, $format ? (-format => $format) : ());
!     my $aln = $align_in->next_aln || $self->throw("Alignment file '$file' had no alignment!");
      
      my @names;
--- 257,261 ----
  sub _get_seq_names {
      my $self = shift;
!     my $aln = $self->_alignment_object(@_);
      
      my @names;
***************
*** 270,273 ****
--- 267,304 ----
  }
  
+ =head2 _alignment_object
+ 
+  Title   : _alignment_object
+  Usage   : $aln = $obj->_alignment_object()
+  Function: Read the alignment file and generate an alignment object from it.
+            _alignment_file() must be set prior to calling this.
+  Returns : Bio::SimpleAlign
+  Args    : none or input format of the alignment file (defaults to guess) to
+            get, or Bio::Align::AlignI to set.
+ 
+ =cut
+ 
+ sub _alignment_object {
+     my $self = shift;
+     
+     if (defined $self->{_align_obj}) {
+         return $self->{_align_obj};
+     }
+     
+     my $thing = shift;
+     if (ref($thing) && $thing->isa('Bio::Align::AlignI')) {
+         $self->{_align_obj} = $thing;
+         return $thing;
+     }
+     my $format = $thing;
+     
+     my $file = $self->_alignment_file || $self->throw("Alignment filename hasn't been set with _alignment_file");
+     
+     my $align_in = Bio::AlignIO->new(-verbose => $self->verbose, -file => $file, $format ? (-format => $format) : ());
+     my $aln = $align_in->next_aln || $self->throw("Alignment file '$file' had no alignment!");
+     $self->{_align_obj} = $aln;
+     return $aln;
+ }
+ 
  =head2 _get_node_names
  



More information about the Bioperl-guts-l mailing list