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

Jonathan Miller millerj at bcm.tmc.edu
Mon Apr 4 19:44:36 EDT 2005

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 ('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
but I have so far been unable to figure out how in fact to
set the SEQ_ID_TYPE .

More information about the Bioperl-l mailing list