Dear monks,
I have been working with a file with the .obo extension. In a summary, this is the general format:
############### [ Term ] id: HP:0000007 name: Autosomal recessive inheritance alt_id: HP:0001416 alt_id: HP:0001526 def: "A mode of inheritance that is observed for traits related to a g +ene encoded on one of the autosomes (i.e., the human chromosomes 1-22 +) in which a trait manifests in homozygotes. In the context of medica +l genetics, autosomal recessive disorders manifest in homozygotes (wi +th two copies of the mutant allele) or compound heterozygotes (whereb +y each copy of a gene has a distinct mutant allele)." [ HPO:curators] synonym: "Autosomal recessive" EXACT [ ] synonym: "AUTOSOMAL RECESSIVE FORM" RELATED [ HPO:skoehler] synonym: "Autosomal recessive predisposition" RELATED [] is_a: HP:0000005 ! Mode of inheritance<br> [ Term ] id: HP:0000008 name: Abnormality of female internal genitalia def: "An abnormality of the female internal genitalia." [HPO:probinson +] is_a: HP:0000812 ! Abnormal internal genitalia is_a: HP:0010460 ! Abnormality of the female genitalia property_value: HP:0040005 "An abnormality of the `female internal gen +italia` (FMA:45654)." xsd:string {xref="HPO:probinson"} ##################
I've been struggling with generating hashes where after each Term the id becomes the key of a hash, and the is_a: fields after ! become the elements contained within an array in this key. something like:
hash{HP:0000007}[0]="Mode of inheritance" hash{HP:0000008}[0]="Abnormal internal genitalia" hash{HP:0000008}[1]="Abnormality of the female genitalia"
Another alternative to the array is to generate a hash of hashes where I save all values associated with an id and can access the is_a: fields directly. Can one of our advanced brothers enlighten me?? Thanks a lot!!! Sakti

In reply to Text manipulation on a file with multiple entries, obo format by Sakti

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.