[Bioperl-l] newbie needs help with "preferred_id_type"
Andrew Walsh
walsh at cenix-bioscience.com
Tue Apr 5 12:59:04 EDT 2005
Hello,
I believe that if you set the display_id (or desc?) attribute to be the
accession, you will get only the accession in the fasta header.
while ( $seq = $in->next_seq() ) {
print $seq->accession,"\n";
$seq->display_id($seq->accession);
# or ?
$seq->desc($seq->accession);
$out->write_seq($seq);
}
One of those 2 should do the trick.
Andrew
Jonathan Miller wrote:
> 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
>
--
------------------------------------------------------------------
Andrew Walsh, M.Sc.
Bioinformatics Software Engineer
IT Unit
Cenix BioScience GmbH
Tatzberg 47
01307 Dresden
Germany
Tel. +49-351-4173 137
Fax +49-351-4173 109
public key: http://www.cenix-bioscience.com/public_keys/walsh.gpg
------------------------------------------------------------------
More information about the Bioperl-l
mailing list