[Bioperl-l] Write a fasta file with custom title line.

Staffa, Nick (NIH/NIEHS) [C] staffa at niehs.nih.gov
Wed Sep 6 18:58:19 UTC 2006


I took someone's fine suggestion and wrote out my own fasta file line by line with a most simple perl subroutine -- most simple!
Since I was using BioPerl, I thought I should let it do this work, 
but some things are simpler without it. 

Thank you all for your answers.

Nick Staffa
Telephone: 919-316-4569  (NIEHS: 6-4569)
Scientific Computing Support Group
NIEHS Information Technology Support Services Contract
(Science Task Monitor: Jack L. Field (field1 at niehs.nih.gov ))
National Institute of Environmental Health Sciences
National Institutes of Health
Research Triangle Park, North Carolina




-----Original Message-----
From: Chris Fields [mailto:cjfields at uiuc.edu]
Sent: Thursday, August 31, 2006 1:56 PM
To: Staffa, Nick (NIH/NIEHS) [C]; 'bioperl-l'
Subject: RE: [Bioperl-l] Write a fasta file with custom title line.


Nick,

I think you can do it by changing the preferred ID type to 'display ID' for
the SeqIO object, then changing the display ID to whatever you want:

use Bio::SeqIO;

my $seqin = Bio::SeqIO->new(-file     => shift,
                            -format => 'genbank',);

my $seqout = Bio::SeqIO->new(-fh => \*STDOUT,
                            -format => 'fasta');

$seqout->preferred_id_type('display');

my $ct = 1;

while (my $seq = $seqin->next_seq) {
    $seq->display_id('foo'.$ct);
    $seqout->write_seq($seq);
    $ct++;
}

This version appends the sequence description:

>foo1 5'UTR in Aspergillus niger icdA mRNA for NADP-dependent isocitrate
dehydrogenase precursor, complete cds.
TCCGTTCTTCCCTCATTCCTCCCCAGGTTCTTGCTTATTGCAGGAAAGATTATTTCCCAG
AGTGAACAGAAACGATTTTCCGGGTTCTCCGATCTGCCCCGTGAAGGTCCCTTACAGCAA
CAGCATCTCGTCCAGTCCGGCTTAACGGCAGCTTCCGAACTCCACCACCGCCTCCTTCCA
GCCGAGAGCTTCACGGCTTCTTGCTTGTCTTTCCCTCGGACTTTCCCCGGTTCCTCCCAC
ACAGCAGGCCCAGTTACTGTCGAGTCTTTGGCAATCCATCCCACACC
>foo2 5'UTR in Fission yeast mRNA for cytochrome c oxidase subunit IV,
complete cds.
GTTATAAATCATCAATAATTGTCTTTTAAG
...

I personally think it would be better to add a 'custom' option so you could
add whatever you wanted without the description added in.  What did you have
in mind here?

Chris

> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Staffa, Nick (NIH/NIEHS) [C]
> Sent: Thursday, August 31, 2006 11:57 AM
> To: bioperl-l
> Subject: [Bioperl-l] Write a fasta file with custom title line.
> 
> I would like to construct  title lines for the fasta sequences I want to
> right to a file.
> I don't see in the documentation on-line for SeqIO or write_seq how to
> specify this.
> Please point the way.
> 
> 
> Nick Staffa
> Telephone: 919-316-4569  (NIEHS: 6-4569)
> Scientific Computing Support Group
> NIEHS Information Technology Support Services Contract
> (Science Task Monitor: Jack L. Field( field1 at niehs.nih.gov )
> National Institute of Environmental Health Sciences
> National Institutes of Health
> Research Triangle Park, North Carolina
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list