[Bioperl-l] Re: [Bioperl-guts-l] bioperl commit

Aaron J. Mackey amackey at pcbi.upenn.edu
Tue Dec 2 17:00:10 EST 2003


Does this actually work with piped filehandles (i.e. STDIN):

perl -MBio::SeqIO -le 'print 
Bio::SeqIO->new(-fh=>\*STDIN)->next_seq->id' < test.gbk

-Aaron

On Dec 2, 2003, at 3:04 PM, Heikki Lehvaslaiho wrote:

>
> heikki
> Tue Dec  2 15:03:59 EST 2003
> Update of /home/repository/bioperl/bioperl-live/Bio
> In directory pub.open-bio.org:/tmp/cvs-serv24770/Bio
>
> Modified Files:
> 	AlignIO.pm SeqIO.pm
> Log Message:
> guessing sequence and align formats by looking into file
>
> bioperl-live/Bio AlignIO.pm,1.30,1.31 SeqIO.pm,1.69,1.70
> ===================================================================
> RCS file: /home/repository/bioperl/bioperl-live/Bio/AlignIO.pm,v
> retrieving revision 1.30
> retrieving revision 1.31
> diff -u -r1.30 -r1.31
> --- /home/repository/bioperl/bioperl-live/Bio/AlignIO.pm	2003/11/07 
> 00:56:49	1.30
> +++ /home/repository/bioperl/bioperl-live/Bio/AlignIO.pm	2003/12/02 
> 20:03:59	1.31
> @@ -299,6 +299,7 @@
>  use Bio::LocatableSeq;
>  use Bio::SimpleAlign;
>  use Bio::Root::IO;
> +use Bio::Tools::GuessSeqFormat;
>  @ISA = qw(Bio::Root::Root Bio::Root::IO);
>
>  =head2 new
> @@ -330,11 +331,17 @@
>  	my %param = @args;
>  	@param{ map { lc $_ } keys %param } = values %param; # lowercase keys
>  	my $format = $param{'-format'} ||
> -	    $class->_guess_format( $param{-file} || $ARGV[0] ) ||
> -		'fasta';
> +	    $class->_guess_format( $param{-file} || $ARGV[0] );
> +        if ($param{-file}) {
> +            $format = Bio::Tools::GuessSeqFormat->new(-file => 
> $param{-file}||$ARGV[0] )->guess;
> +        }
> +        elsif ($param{-fh}) {
> +            $format = Bio::Tools::GuessSeqFormat->new(-fh => 
> $param{-fh}||$ARGV[0] )->guess;
> +        }
>  	$format = "\L$format";	# normalize capitalization to lower case
> +        $class->throw("Unknown format given or could not determine it 
> [$format]")
> +            if $format eq 'unknown';
>
> -	# normalize capitalization
>  	return undef unless( $class->_load_format_module($format) );
>  	return "Bio::AlignIO::$format"->new(@args);
>      }
>
> ===================================================================
> RCS file: /home/repository/bioperl/bioperl-live/Bio/SeqIO.pm,v
> retrieving revision 1.69
> retrieving revision 1.70
> diff -u -r1.69 -r1.70
> --- /home/repository/bioperl/bioperl-live/Bio/SeqIO.pm	2003/10/28 
> 07:07:42	1.69
> +++ /home/repository/bioperl/bioperl-live/Bio/SeqIO.pm	2003/12/02 
> 20:03:59	1.70
> @@ -312,6 +312,7 @@
>  use Bio::Factory::SequenceStreamI;
>  use Bio::Factory::FTLocationFactory;
>  use Bio::Seq::SeqBuilder;
> +use Bio::Tools::GuessSeqFormat;
>  use Symbol();
>
>  @ISA = qw(Bio::Root::Root Bio::Root::IO 
> Bio::Factory::SequenceStreamI);
> @@ -349,23 +350,29 @@
>  sub new {
>      my ($caller, at args) = @_;
>      my $class = ref($caller) || $caller;
> -
> +
>      # or do we want to call SUPER on an object if $caller is an
>      # object?
>      if( $class =~ /Bio::SeqIO::(\S+)/ ) {
>  	my ($self) = $class->SUPER::new(@args);	
>  	$self->_initialize(@args);
>  	return $self;
> -    } else {
> -
> +    } else {
> +
>  	my %param = @args;
>  	@param{ map { lc $_ } keys %param } = values %param; # lowercase keys
> -	my $format = $param{'-format'} ||
> -	    $class->_guess_format( $param{-file} || $ARGV[0] ) ||
> -		'fasta';
> -	$format = "\L$format";	# normalize capitalization to lower case
> +	my $format = $param{'-format'} ||
> +	    $class->_guess_format( $param{-file} || $ARGV[0] );
>
> -	# normalize capitalization
> +        if ($param{-file}) {
> +            $format = Bio::Tools::GuessSeqFormat->new(-file => 
> $param{-file}||$ARGV[0] )->guess;
> +        }
> +        elsif ($param{-fh}) {
> +            $format = Bio::Tools::GuessSeqFormat->new(-fh => 
> $param{-fh}||$ARGV[0] )->guess;
> +        }
> +	$format = "\L$format";	# normalize capitalization to lower case
> +        $class->throw("Unknown format given or could not determine it 
> [$format]")
> +            if $format eq 'unknown';
>  	return undef unless( $class->_load_format_module($format) );
>  	return "Bio::SeqIO::$format"->new(@args);
>      }
>
> _______________________________________________
> Bioperl-guts-l mailing list
> Bioperl-guts-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-guts-l
>



More information about the Bioperl-l mailing list