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


In reply to Tie-ing files containing complex data structures by citromatik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.