[Bioperl-l] newbie needs help with "preferred_id_type"

Hilmar Lapp hlapp at gmx.net
Tue Apr 5 15:11:37 EDT 2005


Right, because in Genbank format the choice of what to use for locus is 
predetermined (by NCBI). This property will only exist if you chose 
fasta format.

	-hilmar

On Tuesday, April 5, 2005, at 12:02  PM, Jonathan Miller wrote:

>
> This works, thank you very much;
> suppose however I wanted to write in "GenBank" format;
> in this case I get an error message:
>
> Can't locate object method "preferred_id_type" via package
> "Bio::SeqIO::genbank" at malcolm.pl line 13.
>
> many thanks
>
> jm
>
> On Tue, 5 Apr 2005, Hilmar Lapp wrote:
>
>> This is a property of the SeqIO stream, so you need to set it on the
>> stream object:
>>
>> 	$seqio = Bio:SeqIO->new(-format=>'fasta',-file=>"<blah.fa");
>> 	$seqio->preferred_id_type('accession');
>>
>> Hth,
>>
>> 	-hilmar
>> 	
>> On Tuesday, April 5, 2005, at 10:08  AM, Cook, Malcolm wrote:
>>
>>> hmmm - this is new to me
>>>
>>> let's see, on my bioperl 1.5 installation, the unix one-liner
>>>
>>>  perl -MBio::SeqIO::fasta -e 'print 
>>> "@Bio::SeqIO::fasta::SEQ_ID_TYPES"'
>>>
>>> returns
>>>
>>> accession accession.version display primary
>>>
>>> so, I think you should be able to add, for instance
>>>
>>> $seq->preferred_id_type('display')
>>>
>>> or, in your case
>>>
>>> $seq->preferred_id_type('accession')
>>>
>>> just before your call to write_seq
>>>
>>> try it!
>>>
>>> Malcolm Cook - mec at stowers-institute.org - 816-926-4449
>>> Database Applications Manager - Bioinformatics
>>> Stowers Institute for Medical Research - Kansas City, MO  USA
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: bioperl-l-bounces at portal.open-bio.org
>>> [mailto:bioperl-l-bounces at portal.open-bio.org] On Behalf Of Jonathan
>>> Miller
>>> Sent: Monday, April 04, 2005 6:45 PM
>>> To: bioperl-l at bioperl.org
>>> Subject: [Bioperl-l] newbie needs help with "preferred_id_type"
>>>
>>>
>>>
>>> Below, I want write_seq to use the accession,
>>> rather than the default.
>>> ---------------------------------------------
>>> #!/usr/bin/perl
>>>  use Bio::SeqIO;
>>>
>>>   my $infile=shift;
>>>   $in  = Bio::SeqIO->new(-file => $infile,
>>>                          -format => 'GenBank');
>>>   my $outfile= ">" . $infile . ".fa";
>>>   $out = Bio::SeqIO->new(-file => $outfile,
>>>                          -format => 'fasta'
>>>                         );
>>>
>>>   while ( $seq = $in->next_seq() ) {
>>>    print $seq->accession,"\n";
>>>    $out->write_seq($seq);
>>>   }
>>> ------------------------------------------------
>>> So, Going to the Bio::Seq docs, I see:
>>> ---------------------------------------------------------
>>> preferred_id_type	code	top	prev	next
>>>
>>>  Title   : preferred_id_type
>>>  Usage   : $obj->preferred_id_type('accession')
>>>  Function: Get/Set the preferred type of identifier to use in the 
>>> ">ID"
>>> position
>>>            for FASTA output.
>>>  Returns : string, one of values defined in
>>> @Bio::SeqIO::fasta::SEQ_ID_TYPES.
>>>            Default = $Bio::SeqIO::fasta::DEFAULT_SEQ_ID_TYPE
>>> ('display').
>>>  Args    : string when setting. This must be one of values defined in
>>>            @Bio::SeqIO::fasta::SEQ_ID_TYPES. Allowable values:
>>>            accession, accession.version, display, primary
>>>  Throws  : fatal exception if the supplied id type is not in
>>> @SEQ_ID_TYPES.
>>> ----------------------------------------------------------
>>> but I have so far been unable to figure out how in fact to
>>> set the SEQ_ID_TYPE .
>>>
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at portal.open-bio.org
>>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at portal.open-bio.org
>>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>>>
>>>
>> -- 
>> -------------------------------------------------------------
>> Hilmar Lapp                            email: lapp at gnf.org
>> GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
>> -------------------------------------------------------------
>>
>>
>>
>
>
-- 
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------




More information about the Bioperl-l mailing list