[Bioperl-l] array of SeqIO objects

Jason Stajich jason@chg.mc.duke.edu
Thu, 2 Aug 2001 22:18:15 -0400 (EDT)


Haifeng - 

I'm not sure I understand what you are having trouble with.  It is helpful
to provide us with the entire script and the data file you are using.  
The version of bioperl you are using would be helpful as well.

At any rate here is what I get when I try and duplicate what is going
in your snippet.  I see each distinct sequence printed out when looking
at the array at the end.

Perhaps you can elaborate on your problem some more and we can do a better
job diagnosing and helping you with it.

--begin output--

10 magrathea bioperl-live $ cat t/data/multifa.seq
>HSEARLOBE 321bp
gctcggactctatctagcagaaacctcgttcagctagtcttgcttcatggaggtttgatc
tagactgcaaacgtcggtgctaaaagaccatacttccgtatgtgcctatcgggagcagtc
gctgagaagtgcggaatgatccttcaatgaccgccgttaaagcctgggagtccgcgccac
aatcattccatatacagcaacacgcgctacgcggacctctcggtgggtgacgattctatt
gaggcgttgaagcgagaaagatattccgattcttttcgagtctatagttaaatcggactg
catcatccattttagggcata
>HSMETOO 134bp
ggccgggatggccggacctgttctgaacatcttatatccacccgaacaagttataaacaa
tttaaatctgggcggccatctataagcgtgtcttcagtatgagagtcttcggatatcacg
acccattaggaaag
>empty1 an empty seq well-formatted

>empty2 an empty seq without subsequent empty line
>MMWHISK 62bp
gctgcctctatcaagggtgaaaattgcctgcccggctgggtagacactcgcaccactccc
cg
>empty3 empty seq at the end of the file
11 magrathea bioperl-live $ cat bioseqio.pl
#!/usr/local/bin/perl -w
use strict;
use Bio::SeqIO;

my $in = Bio::SeqIO->new('-file' => 't/data/multifa.seq', '-format' =>
'fasta'); 
my @seqs = ();
 
while( my $seqobj = $in->next_seq ) {
    push @seqs, $seqobj;
}
 
foreach my $seq ( @seqs ) {
    print "seq ", $seq->display_id(), " is ", $seq->seq(), "\n";
}
12 magrathea bioperl-live $ perl bioseqio.pl
seq HSEARLOBE is
gctcggactctatctagcagaaacctcgttcagctagtcttgcttcatggaggtttgatctagactgcaaacgtcggtgctaaaagaccatacttccgtatgtgcctatcgggagcagtcgctgagaagtgcggaatgatccttcaatgaccgccgttaaagcctgggagtccgcgccacaatcattccatatacagcaacacgcgctacgcggacctctcggtgggtgacgattctattgaggcgttgaagcgagaaagatattccgattcttttcgagtctatagttaaatcggactgcatcatccattttagggcata
seq HSMETOO is
ggccgggatggccggacctgttctgaacatcttatatccacccgaacaagttataaacaatttaaatctgggcggccatctataagcgtgtcttcagtatgagagtcttcggatatcacgacccattaggaaag
seq empty1 is
seq empty2 is
seq MMWHISK is
gctgcctctatcaagggtgaaaattgcctgcccggctgggtagacactcgcaccactccccg
seq empty3 is

--end output--

-jason
 On Fri, 3 Aug 2001, Liu Haifeng wrote:

> Hi,
> 
> I am creating an array of  Bio::SeqIO objects from an input Fasta file
> by the following script:
> 
> $in=Bio::SeqIO->new('-file' => $ARGV[0], '-format'=>'Fasta');
> @seqs=();
> while ($seqobj=$in->next_seq()) {
>       push @seqs,$seqobj;
> }
> 
> However, when I print the elements of @seqs, I found that those elements
> are the same as the first sequence in the input file.  I would be very
> greatful if somebody can help me with the problem.
> 
> Thanks,
> Haifeng
> 
> DS/IFL, DSO National Laboratories
> Singapore 118230
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
> 

Jason Stajich
jason@chg.mc.duke.edu
Center for Human Genetics
Duke University Medical Center 
http://www.chg.duke.edu/