ribolands/parser/barriers.py
def barriers_grammar():
    """ A grammar to interpret output from the program barriers.

    https://github.com/ViennaRNA/Barriers

    tested version: 0.7.1

    # A random barriers example:
         CCCCGGAAGGAAUGGGUAGUGACAGCAGCUUAGGUCGCUGCAUCAUCCCC
       1 ........((.((((((((((((..........)))))))).)))).)). -15.10    0  15.00
       2 ..((....))...((((.(((.((((.((....)).))))))).)))).. -15.00    1  13.50
       3 ..((....))...(((..((((..(((((.......))))).))))))). -14.90    2  11.90
       4 ........(((.(((((((((((..........)))))))).)))))).. -14.90    1   3.30
       5 ..((....))...(((..((((..(((((.......))))).)))).))) -14.40    3   5.60
       6 ..((....))...(((..(((.((((.((....)).)))))))...))). -14.30    2   6.20
       7 ..((....)).((((((((((((..........)))))))).)))).... -13.70    1   3.30
       8 .((.....))...((((.(((.((((.((....)).))))))).)))).. -13.60    2   3.30
       9 .((((.......))))..((((..(((((.......))))).)))).... -13.50    3   7.20
      10 .((.....))...(((..((((..(((((.......))))).))))))). -13.50    3   3.30
      11 ..((....))...(((..((((((((.((....)).))))..))))))). -13.50    6   4.20
      12 .((.....))...(((..((((..(((((.......))))).)))).))) -13.00    5   3.30
      13 ..((....))...(((..((((((((.((....)).))))..)))).))) -13.00    2   5.60
      14 .((.....))...(((..(((.((((.((....)).)))))))...))). -12.90    6   3.30
    """

    # Remove line breaks from DEFAULT_WHITE_CHARS, they are important.
    DWC = "".join([x for x in ParseElementEnhance.DEFAULT_WHITE_CHARS if x != "\n"])
    ParseElementEnhance.setDefaultWhitespaceChars(DWC)

    def T(x, tag):
        def TPA(tag):
            return lambda s, l, t: [tag] + t.asList()
        return x.setParseAction(TPA(tag))

    W = Word
    G = Group
    S = Suppress
    O = Optional
    C = Combine
    L = Literal
    D = Dict

    iupack = W("ACGTURYSMWKVHDBN")
    struct = W("().&")
    number = W(nums, nums)
    num_flt = C(O(L('-') | L('+')) + number + O(L('.') + number))
    num_sci = C(O(L('-') | L('+')) + number + O(L('.') + number) + L('e') + O(L('-') | L('+')) + W(nums))
    gorf = num_sci | num_flt

    # HACK
    identity = O('i') + number
    ancestor = O('f') + number
    energy   = O('e') + num_flt
    barrier  = O('b') + num_flt

    # saddle option
    saddle = W("~().&")
    senergy   = O('s') + num_flt
    
    #       Lmin[i].my_pool, Lmin[i].ancestors_pool, mfe - kT * log(lmin[i].Z), Lmin[i].my_GradPool, mfe - kT * log(lmin[i].Zg));
    bsize = G(number + number + senergy + number + senergy)

    seq_line = G(T(iupack, 'sequence') + LineEnd().suppress())
    str_line = G(G(T(identity, 'identity')) +
                 G(T(struct, 'structure')) + 
                 G(T(energy, 'energy')) + 
                 G(T(ancestor, 'ancestor')) + 
                 G(T(barrier, 'barrier')) + 
                O(G(T(saddle, 'saddle'))) + 
                O(G(T(bsize, 'bsize'))) + 
                 LineEnd().suppress())

    stmt = seq_line | str_line | LineEnd().suppress()

    document = StringStart() + ZeroOrMore(LineEnd().suppress()) + OneOrMore(stmt) + StringEnd()
    document.ignore(pythonStyleComment)

    return document
 A grammar to interpret output from the program barriers.

    https://github.com/ViennaRNA/Barriers

    tested version: 0.7.1

    # A random barriers example:
         CCCCGGAAGGAAUGGGUAGUGACAGCAGCUUAGGUCGCUGCAUCAUCCCC
       1 ........((.((((((((((((..........)))))))).)))).)). -15.10    0  15.00
       2 ..((....))...((((.(((.((((.((....)).))))))).)))).. -15.00    1  13.50
       3 ..((....))...(((..((((..(((((.......))))).))))))). -14.90    2  11.90
       4 ........(((.(((((((((((..........)))))))).)))))).. -14.90    1   3.30
       5 ..((....))...(((..((((..(((((.......))))).)))).))) -14.40    3   5.60
       6 ..((....))...(((..(((.((((.((....)).)))))))...))). -14.30    2   6.20
       7 ..((....)).((((((((((((..........)))))))).)))).... -13.70    1   3.30
       8 .((.....))...((((.(((.((((.((....)).))))))).)))).. -13.60    2   3.30
       9 .((((.......))))..((((..(((((.......))))).)))).... -13.50    3   7.20
      10 .((.....))...(((..((((..(((((.......))))).))))))). -13.50    3   3.30
      11 ..((....))...(((..((((((((.((....)).))))..))))))). -13.50    6   4.20
      12 .((.....))...(((..((((..(((((.......))))).)))).))) -13.00    5   3.30
      13 ..((....))...(((..((((((((.((....)).))))..)))).))) -13.00    2   5.60
      14 .((.....))...(((..(((.((((.((....)).)))))))...))). -12.90    6   3.30
    
A grammar to interpret output from the program barriers.




A grammar to interpret output from the program barriers .
def barriers_grammar():
    DWC = "".join([x for x in ParseElementEnhance.DEFAULT_WHITE_CHARS if x != "\n"])
    ParseElementEnhance.setDefaultWhitespaceChars(DWC)
    def T(x, tag):
        def TPA(tag):
            return lambda s, l, t: [tag] + t.asList()
        return x.setParseAction(TPA(tag))
    W = Word
    G = Group
    S = Suppress
    O = Optional
    C = Combine
    L = Literal
    D = Dict
    iupack = W("ACGTURYSMWKVHDBN")
    struct = W("().&")
    number = W(nums, nums)
    num_flt = C(O(L('-') | L('+')) + number + O(L('.') + number))
    num_sci = C(O(L('-') | L('+')) + number + O(L('.') + number) + L('e') + O(L('-') | L('+')) + W(nums))
    gorf = num_sci | num_flt
    identity = O('i') + number
    ancestor = O('f') + number
    energy   = O('e') + num_flt
    barrier  = O('b') + num_flt
    saddle = W("~().&")
    senergy   = O('s') + num_flt
    bsize = G(number + number + senergy + number + senergy)
    seq_line = G(T(iupack, 'sequence') + LineEnd().suppress())
    str_line = G(G(T(identity, 'identity')) +
                 G(T(struct, 'structure')) + 
                 G(T(energy, 'energy')) + 
                 G(T(ancestor, 'ancestor')) + 
                 G(T(barrier, 'barrier')) + 
                O(G(T(saddle, 'saddle'))) + 
                O(G(T(bsize, 'bsize'))) + 
                 LineEnd().suppress())
    stmt = seq_line | str_line | LineEnd().suppress()
    document = StringStart() + ZeroOrMore(LineEnd().suppress()) + OneOrMore(stmt) + StringEnd()
    document.ignore(pythonStyleComment)
    return document
def barriers_grammar ( ) : DWC = "" . join ( [ x for x in ParseElementEnhance . DEFAULT_WHITE_CHARS if x != "\n" ] ) ParseElementEnhance . setDefaultWhitespaceChars ( DWC ) def T ( x , tag ) : def TPA ( tag ) : return lambda s , l , t : [ tag ] + t . asList ( ) return x . setParseAction ( TPA ( tag ) ) W = Word G = Group S = Suppress O = Optional C = Combine L = Literal D = Dict iupack = W ( "ACGTURYSMWKVHDBN" ) struct = W ( "().&" ) number = W ( nums , nums ) num_flt = C ( O ( L ( '-' ) | L ( '+' ) ) + number + O ( L ( '.' ) + number ) ) num_sci = C ( O ( L ( '-' ) | L ( '+' ) ) + number + O ( L ( '.' ) + number ) + L ( 'e' ) + O ( L ( '-' ) | L ( '+' ) ) + W ( nums ) ) gorf = num_sci | num_flt identity = O ( 'i' ) + number ancestor = O ( 'f' ) + number energy = O ( 'e' ) + num_flt barrier = O ( 'b' ) + num_flt saddle = W ( "~().&" ) senergy = O ( 's' ) + num_flt bsize = G ( number + number + senergy + number + senergy ) seq_line = G ( T ( iupack , 'sequence' ) + LineEnd ( ) . suppress ( ) ) str_line = G ( G ( T ( identity , 'identity' ) ) + G ( T ( struct , 'structure' ) ) + G ( T ( energy , 'energy' ) ) + G ( T ( ancestor , 'ancestor' ) ) + G ( T ( barrier , 'barrier' ) ) + O ( G ( T ( saddle , 'saddle' ) ) ) + O ( G ( T ( bsize , 'bsize' ) ) ) + LineEnd ( ) . suppress ( ) ) stmt = seq_line | str_line | LineEnd ( ) . suppress ( ) document = StringStart ( ) + ZeroOrMore ( LineEnd ( ) . suppress ( ) ) + OneOrMore ( stmt ) + StringEnd ( ) document . ignore ( pythonStyleComment ) return document
A grammar to interpret output from the program barriers.
A grammar to interpret output from the program barriers .
""" A grammar to interpret output from the program barriers.

    https://github.com/ViennaRNA/Barriers

    tested version: 0.7.1

    # A random barriers example:
         CCCCGGAAGGAAUGGGUAGUGACAGCAGCUUAGGUCGCUGCAUCAUCCCC
       1 ........((.((((((((((((..........)))))))).)))).)). -15.10    0  15.00
       2 ..((....))...((((.(((.((((.((....)).))))))).)))).. -15.00    1  13.50
       3 ..((....))...(((..((((..(((((.......))))).))))))). -14.90    2  11.90
       4 ........(((.(((((((((((..........)))))))).)))))).. -14.90    1   3.30
       5 ..((....))...(((..((((..(((((.......))))).)))).))) -14.40    3   5.60
       6 ..((....))...(((..(((.((((.((....)).)))))))...))). -14.30    2   6.20
       7 ..((....)).((((((((((((..........)))))))).)))).... -13.70    1   3.30
       8 .((.....))...((((.(((.((((.((....)).))))))).)))).. -13.60    2   3.30
       9 .((((.......))))..((((..(((((.......))))).)))).... -13.50    3   7.20
      10 .((.....))...(((..((((..(((((.......))))).))))))). -13.50    3   3.30
      11 ..((....))...(((..((((((((.((....)).))))..))))))). -13.50    6   4.20
      12 .((.....))...(((..((((..(((((.......))))).)))).))) -13.00    5   3.30
      13 ..((....))...(((..((((((((.((....)).))))..)))).))) -13.00    2   5.60
      14 .((.....))...(((..(((.((((.((....)).)))))))...))). -12.90    6   3.30
    """ # Remove line breaks from DEFAULT_WHITE_CHARS, they are important. # HACK # saddle option #       Lmin[i].my_pool, Lmin[i].ancestors_pool, mfe - kT * log(lmin[i].Z), Lmin[i].my_GradPool, mfe - kT * log(lmin[i].Zg));