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

Cook, Malcolm MEC at Stowers-Institute.org
Tue Apr 5 13:08:38 EDT 2005

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"'


accession accession.version display primary

so, I think you should be able to add, for instance


or, in your case


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
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.
 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";
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"
           for FASTA output.
 Returns : string, one of values defined in
           Default = $Bio::SeqIO::fasta::DEFAULT_SEQ_ID_TYPE
 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
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

More information about the Bioperl-l mailing list