[Bioperl-l] Help with manipulating quality objects PLUS write_seq(args)
Brian Desany
bdesany@bcm.tmc.edu
Wed, 23 Oct 2002 15:27:07 -0500
>Not sure what $callerObj is (not $self, right?).
I meant it's the caller object as it's sitting in @_, before $_[0] gets
assigned to $self. Sorry, that's confusing.
>Generally speaking
>what _rearrange() does it returns the array of arguments unchanged
>if its length is odd or if the first argument doesn't start with a
>hyphen.
>
>So, if you pass in one (1) argument, $source should be set to that
>argument. If you pass in two arguments, but the first one doesn't
>start with a hyphen, $source should be set to the first argument.
When you do this:
my ($self,%args) = @_;
%args ends up containing one element, the string
'Bio::Seq::PrimaryQual=HASH(0x68aed8)', I guess because you can't have an
object as a key in a hash.
So _rearrange is doing exactly as you say it should, it's the assignment to
%args that is screwing everything up.
This is true with 1.1.1 and bioperl-live.
So I changed %args to @args as you suggested and checked it in.
-Brian.
>Capturing the args as a hash is certainly not a good idea. Not only
>does it cause the 'odd number of elements' warning if you don't use
>named parameters, it will also turn one argument into two once
>turned back into an array (key with an undef value).
>
>What I'm saying is, if you replace %args with @args, and there is
>either an odd number of arguments or the first argument doesn't
>start with hyphen, $source should be set to the first argument,
>which I believe is what you want. Let me know if this is not true on
>1.1.1 (and which arguments were passed).
> -hilmar
>
>>
>> (Plus you get odd number of elements in hash assignment warning)
>>
>> -Brian.
>>
>>
>>> -----Original Message-----
>>> From: Hilmar Lapp [mailto:hlapp@gnf.org]
>>> Sent: Wednesday, October 23, 2002 12:35 PM
>>> To: bdesany@bcm.tmc.edu; bioperl-l@bioperl.org
>>> Subject: RE: [Bioperl-l] Help with manipulating quality objects PLUS
>>> write_seq(args)
>>>
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Brian Desany [mailto:bdesany@bcm.tmc.edu]
>>>> Sent: Wednesday, October 23, 2002 10:06 AM
>>>> To: bioperl-l@bioperl.org
>>>> Subject: RE: [Bioperl-l] Help with manipulating quality
>objects PLUS
>>>> write_seq(args)
>>>>
>>> <snip/>
>>>>
>>>> On a separate note:
>>>>
>>>> One thing I did notice is that write_seq takes named
>>>> arguments, and uses
>>>> _rearrange to get SOURCE. OTOH, Bio::SeqIO::fasta::write_seq
>>>> takes an array
>>>> of Seq objects.
>>>>
>>>> In my code I like to have the correct module chosen at
>>>> runtime and call
>>>> write_seq without necessarily knowing ahead of time whether
>>>> it's a fasta or
>>>> qual IO. So therefore I would also like to call write_seq in
>>>> the same way
>>>> for both.
>>>>
>>>> Does anyone mind if I change qual.pm so that you can write_seq with
>>>>
>>>> $io->write_seq($qual);
>>>>
>>>> in addition to
>>>>
>>>> $io->write_seq('-source'=>$qual);
>>>>
>>>
>>> _rearrange() should take care of that already. Do you see that
>>> it doesn't?
>>>
>>> -hilmar
>>>
>>
>>
>--
>-------------------------------------------------------------
>Hilmar Lapp email: lapp at gnf.org
>GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
>-------------------------------------------------------------
>
>