perl module for context grammar?

Discussion in 'Perl Misc' started by ela, Sep 30, 2011.

  1. ela

    ela Guest

    While there is another perl module that deals with the following complex
    structure,

    (((((((R1441:65.00000000,X29:44.66666667):42.33333333,(R1842:3.00000000,R1909:9.00000000):1.33333333):1.33333333,(R1390:13.00000000,R1505:8.00000000):2.33333333):4.00000000,X122:4.66666667):25.33333333,((CCDC5180:23.00000000,HN878:22.00000000):10.00000000,(CCDC5079:28.00000000,(BT1:28.00000000,BT2:36.00000000):1.00000000):20.00000000):0.00000000):1.00000000,BS1:12.00000000):45.00000000,(R1207:9.00000000,(R1746:40.00000000,((X132:0.00000000,X28:0.00000000):6.50000000,(X156:67.83333333,X85:51.83333333):52.33333333):3.50000000):4.00000000):62.00000000,(kzn4207:6.00000000,(kznR506:3.00000000,kznV2475:2.00000000):8.00000000):245.00000000);

    the module does not have the function I need. Is there any standard perl
    module that can allocate the nodes in a hierarchical tree structure (e.g.
    R1441 and X29 are in the same sub-group, and then this sub-group is under
    the same super-group with the subgroup formed by R1842-R1909);
    after forming this hierarchical structure, distances between any nodes can
    be easily derived (e.g. the distance of R1441 and X29 is 65+44.67, R1441 and
    R1842 is (65+42.3) + (3+1.3), you can see that if the subgroups are further
    apart, they have to trace more upper level to derive the pairwise distance).
    Another derivation is about intermediate nodes. For example, the distance
    between subgroup R1441-X29 and end node R1909 is 42.3+ (9+1.3)
    ela, Sep 30, 2011
    #1
    1. Advertising

  2. ela

    Jim Gibson Guest

    In article <j64bek$rb4$>, ela
    <> wrote:

    > While there is another perl module that deals with the following complex
    > structure,
    >
    >
    > (((((((R1441:65.00000000,X29:44.66666667):42.33333333,(R1842:3.00000000,R1909:
    > 9.00000000):1.33333333):1.33333333,(R1390:13.00000000,R1505:8.00000000):2.3333
    > 3333):4.00000000,X122:4.66666667):25.33333333,((CCDC5180:23.00000000,HN878:22.
    > 00000000):10.00000000,(CCDC5079:28.00000000,(BT1:28.00000000,BT2:36.00000000):
    > 1.00000000):20.00000000):0.00000000):1.00000000,BS1:12.00000000):45.00000000,(
    > R1207:9.00000000,(R1746:40.00000000,((X132:0.00000000,X28:0.00000000):6.500000
    > 00,(X156:67.83333333,X85:51.83333333):52.33333333):3.50000000):4.00000000):62.
    > 00000000,(kzn4207:6.00000000,(kznR506:3.00000000,kznV2475:2.00000000):8.000000
    > 00):245.00000000);
    >
    > the module does not have the function I need. Is there any standard perl
    > module that can allocate the nodes in a hierarchical tree structure (e.g.
    > R1441 and X29 are in the same sub-group, and then this sub-group is under
    > the same super-group with the subgroup formed by R1842-R1909);
    > after forming this hierarchical structure, distances between any nodes can
    > be easily derived (e.g. the distance of R1441 and X29 is 65+44.67, R1441 and
    > R1842 is (65+42.3) + (3+1.3), you can see that if the subgroups are further
    > apart, they have to trace more upper level to derive the pairwise distance).
    > Another derivation is about intermediate nodes. For example, the distance
    > between subgroup R1441-X29 and end node R1909 is 42.3+ (9+1.3)


    I would recommend the book "Pro Perl Parsing", by Christopher M. Frenz,
    Apress, and the module Parse::RecDescent (but the latter has a steep
    learning curve).

    --
    Jim Gibson
    Jim Gibson, Sep 30, 2011
    #2
    1. Advertising

  3. ela

    Keith Keller Guest

    On 2011-09-30, ela <> wrote:
    > While there is another perl module that deals with the following complex
    > structure,
    >
    > (((((((R1441:65.00000000,X29:44.66666667):42.33333333,(R1842:3.00000000,R1909:9.00000000):1.33333333):1.33333333,(R1390:13.00000000,R1505:8.00000000):2.33333333):4.00000000,X122:4.66666667):25.33333333,((CCDC5180:23.00000000,HN878:22.00000000):10.00000000,(CCDC5079:28.00000000,(BT1:28.00000000,BT2:36.00000000):1.00000000):20.00000000):0.00000000):1.00000000,BS1:12.00000000):45.00000000,(R1207:9.00000000,(R1746:40.00000000,((X132:0.00000000,X28:0.00000000):6.50000000,(X156:67.83333333,X85:51.83333333):52.33333333):3.50000000):4.00000000):62.00000000,(kzn4207:6.00000000,(kznR506:3.00000000,kznV2475:2.00000000):8.00000000):245.00000000);
    >
    > the module does not have the function I need.


    You don't mention what module you're using. If that's a Newick format,
    have you looked at the Bioperl Bio::Tree modules?

    --keith


    --
    -francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
    see X- headers for PGP signature information
    Keith Keller, Sep 30, 2011
    #3
  4. ela

    ela Guest

    "Keith Keller" <-francisco.ca.us> wrote in message
    news:-francisco.ca.us...
    > You don't mention what module you're using. If that's a Newick format,
    > have you looked at the Bioperl Bio::Tree modules?


    While this module contains functions like "get_lca" to check supergroup,
    there is no further documentation how the distance from this supergroup with
    other nodes can be obtained. Moreover, the data structure is encapsulated
    and so while there is another function called "is_monophyletic", I cannot
    actually trace back hierarchically from the leaf to get more "nearest
    neighbor" nodes but have to exhaust all the nodes and derive the relation
    (or hierarchy) myself. That's why I posted a question here to see if
    standard Perl modules have dealt with this.
    ela, Sep 30, 2011
    #4
  5. ela

    ela Guest

    "Jim Gibson" <> wrote in message
    news:300920110932542310%...
    > I would recommend the book "Pro Perl Parsing", by Christopher M. Frenz,
    > Apress, and the module Parse::RecDescent (but the latter has a steep
    > learning curve).


    Oh, it's CHAPTER 5 Performing Recursive-Descent Parsing with
    Parse::RecDescent . . . I guess the module actually uses this. Let me read
    that first and thanks for telling me this kind of problem is called
    "recursive decent parsing"!
    ela, Sep 30, 2011
    #5
  6. ela

    Guest

    On Fri, 30 Sep 2011 20:07:28 +0800, "ela" <> wrote:

    >While there is another perl module that deals with the following complex
    >structure,
    >
    >(((((((R1441:65.00000000,X29:44.66666667):42.33333333,(R1842:3 ...
    >


    Formatting the structure goes a long way.
    (

    (

    (

    (

    (

    (

    (
    R1441 : 65.00000000 ,
    X29 : 44.66666667

    ) : 42.33333333 ,

    (
    R1842 : 3.00000000 ,
    R1909 : 9.00000000

    ) : 1.33333333

    ) : 1.33333333 ,

    (
    R1390 : 13.00000000 ,
    R1505 : 8.00000000

    ) : 2.33333333

    ) : 4.00000000 ,
    X122 : 4.66666667

    ) : 25.33333333 ,

    (

    (
    CCDC5180 : 23.00000000 ,
    HN878 : 22.00000000

    ) : 10.00000000 ,

    (
    CCDC5079 : 28.00000000 ,

    (
    BT1 : 28.00000000 ,
    BT2 : 36.00000000

    ) : 1.00000000

    ) : 20.00000000

    ) : 0.00000000

    ) : 1.00000000 ,
    BS1 : 12.00000000

    ) : 45.00000000 ,

    (
    R1207 : 9.00000000 ,

    (
    R1746 : 40.00000000 ,

    (

    (
    X132 : 0.00000000 ,
    X28 : 0.00000000

    ) : 6.50000000 ,

    (
    X156 : 67.83333333 ,
    X85 : 51.83333333

    ) : 52.33333333

    ) : 3.50000000

    ) : 4.00000000

    ) : 62.00000000 ,

    (
    kzn4207 : 6.00000000 ,

    (
    kznR506 : 3.00000000 ,
    kznV2475 : 2.00000000

    ) : 8.00000000

    ) : 245.00000000

    )
    , Oct 1, 2011
    #6
  7. ela

    Ted Zlatanov Guest

    On Sat, 1 Oct 2011 05:28:53 +0800 "ela" <> wrote:

    e> "Jim Gibson" <> wrote in message
    e> news:300920110932542310%...
    >> I would recommend the book "Pro Perl Parsing", by Christopher M. Frenz,
    >> Apress, and the module Parse::RecDescent (but the latter has a steep
    >> learning curve).


    e> Oh, it's CHAPTER 5 Performing Recursive-Descent Parsing with
    e> Parse::RecDescent . . . I guess the module actually uses this. Let me read
    e> that first and thanks for telling me this kind of problem is called
    e> "recursive decent parsing"!

    No, the problem is how to parse, the solution (algorithm) is recursive
    descent (not "decent" although it is decent for most problems :)

    There are actually many types and subtypes of parsers with many, many
    applications. The one you're describing is fairly simple, but if
    Bioperl has a parser for it already, just look inside the module and see
    if you can augment it with the functions you need. It sounds like this
    distance is a pretty basic function, so you should be able to either
    write it yourself or ask the module maintainers for help.

    Ted
    Ted Zlatanov, Oct 1, 2011
    #7
  8. ela

    ela Guest

    "Ted Zlatanov" <> wrote in message
    news:...
    > No, the problem is how to parse, the solution (algorithm) is recursive
    > descent (not "decent" although it is decent for most problems :)


    Thanks for correcting the typo.

    >
    > There are actually many types and subtypes of parsers with many, many
    > applications. The one you're describing is fairly simple, but if
    > Bioperl has a parser for it already, just look inside the module and see
    > if you can augment it with the functions you need. It sounds like this
    > distance is a pretty basic function, so you should be able to either
    > write it yourself or ask the module maintainers for help.


    Oh, I haven't thought about asking the original module maintainers for
    advice. Thanks a lot!
    ela, Oct 1, 2011
    #8
  9. ela

    Ted Zlatanov Guest

    On Sat, 1 Oct 2011 22:19:52 +0800 "ela" <> wrote:

    e> "Ted Zlatanov" <> wrote in message
    e> news:...
    >> No, the problem is how to parse, the solution (algorithm) is recursive
    >> descent (not "decent" although it is decent for most problems :)


    e> Thanks for correcting the typo.

    Sure, the "descent" part is actually pretty interesting if you're ever
    curious about parsing. I recommend "Parsing Techniques: A Practical
    Guide" by Grune and Jacobs; at least the first few chapters are easy to
    understand and introduce parsing well. It's free on the authors' web site.

    Ted
    Ted Zlatanov, Oct 3, 2011
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    1
    Views:
    1,115
    Jack Klein
    Jan 27, 2005
  2. Alex
    Replies:
    4
    Views:
    728
    Oliver Wong
    Sep 14, 2006
  3. Robert
    Replies:
    9
    Views:
    2,133
    Jerry Coffin
    May 2, 2008
  4. Peter Suk

    Is Ruby grammar context free?

    Peter Suk, Apr 26, 2005, in forum: Ruby
    Replies:
    12
    Views:
    485
    Peter Suk
    Apr 27, 2005
  5. easy

    context sensitive grammar?

    easy, Nov 19, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    118
    robertospara
    Nov 20, 2006
Loading...

Share This Page