in reply to Efficient way to handle huge number of records?
Then later (many times) using this index to retrieve the sequence data (also untested):use Storable; open IN, "input.fa"; my %id2off; while (<IN>) { next unless /^>/; chomp; $id2off{substr($_, 1)} = tell(IN); # file pointer points to start # of next line } store \%id2off, 'input.idx';
Sorting your data won't really work so well since, with variable-length records, you have to do a linear scan of the file to find the linebreaks.use Storable; $id2off = retrieve 'input.idx'; open IN, 'input.fa'; while (<>) { chomp; next unless exists $id2off->{$_}; print ">$_\n"; seek(IN, $id2off->{$_}, 0); # move file pointer to start of sequen +ce while (<IN>) { # print until we reach next sequence last if /^>/; print; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficient way to handle huge number of records?
by Anonymous Monk on Jul 11, 2013 at 22:28 UTC |