citromatik has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I've been developing (FTFOI) a Perl module to manage text files containing complex data structures as an array. It works by first indexing all the data and tie-ing an array to it. Then, you can read/write from/to the file through a tied array. Initially, the "rules of the game" were:
In general it behaves similar to Tie::File except that it manages complex data structures
An example is shown here:For example, if you have a fasta format'ed DNA file like:
>Seq1 AGAGAGAGAGAGGA AGAGAGAGTTCCTT CATCGCACATCAGA AGG >Seq2 GCGTGAGATTGAGG GAATTGAGAGAGAG >Seq3 GAGAGCGCGACCCC TGAGTAGATAGAGA ACAGATATAGGAGA AGAG
Once tied you can:
#Print the file print $_.$/ for (@fastafile); #Reverse the file @fastafile = reverse @fastafile; #Change the 2nd secuence $fastafile[1] = $other_seq; #Put more sequences push @fastafile, $other_seq;
etc... and the changes would be mirrored to the file automatically
In this case it would behave similar to:
tie @fastafile,'Tie::File',recsep=>"\n>",autochomp=>1;
As I said before, this module was created "for the fun of it", but I was curious to know if a final version of it could be generally interesting. The idea is too simple, and surely there are modules (probably better than mine) doing the same tasks. I looked at CPAN but, although some other modules can do similar things (Tie::File, DB_File, Bio::DB::Fasta), none of them seem do the same work. Does anybody know how to do the same things with existing modules?
Thanx all
citromatik
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tie-ing files containing complex data structures
by perrin (Chancellor) on May 24, 2007 at 18:06 UTC | |
by citromatik (Curate) on May 25, 2007 at 10:13 UTC | |
by perrin (Chancellor) on May 25, 2007 at 13:21 UTC | |
by citromatik (Curate) on May 25, 2007 at 15:20 UTC |