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

Jason Stajich jason.stajich at duke.edu
Tue Apr 5 22:39:32 EDT 2005


Don't call it when writing to genbank format...  it only has meaning if 
you are writing to fasta format.

What was the question?
Do you want to control what is in the LOCUS field and/or you want to 
make sure the ACCESSION is set in the Genbank file when reading from a 
FASTA file?

You have access to these in the
display_id --> LOCUS
accession_number -> ACCESSION

-jason
On Apr 5, 2005, at 3: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
>> -------------------------------------------------------------
>>
>>
>>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l



More information about the Bioperl-l mailing list