Bioperl Seqio Reset (Next_Seq())
1
0
Entering edit mode
12.5 years ago

Hi all I am writing a script that gets a sequence from several hundred files containing genes from several database fasta files. I am reusing these database fasta files in a loop so it does not get reindexed.

However my code only works with 1 iteration.

The condition in the while loop "my $seq = $file->next_seq()" is not met after the first iteration and I am assuming that I may need to reset it. Does anyone know how I can go about this?

Thanks

bioperl • 3.1k views
ADD COMMENT
2
Entering edit mode

Need to see more of the code to answer this properly.

ADD REPLY
0
Entering edit mode

why not delete the filehandle and create a new one?

ADD REPLY
0
Entering edit mode

Did you ask on the bioperl mailing list? It is a very active list.

ADD REPLY
4
Entering edit mode
12.5 years ago
brentp 24k

You can add a line at the end of the loop so the the file handle seeks back to the start:

seek($file->_fh, 0, 0);

Or use the methods like $file->first_seq (which resets the file pointer to 0) followed by a series of $file->next_seq.

A better way, depending on the size of the file, may be to read the sequences into an array, see the examples here: http://www.bioperl.org/wiki/HOWTO:SeqIO

ADD COMMENT
0
Entering edit mode

The HOWTO link is here now: https://bioperl.org/howtos/SeqIO_HOWTO.html

ADD REPLY

Login before adding your answer.

Traffic: 2211 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6