Skip to content

Instantly share code, notes, and snippets.

@zhaofengli
Created July 8, 2017 21:28
Show Gist options
  • Save zhaofengli/abbb5c3b7c9bfd911b6cc08af01cd0d4 to your computer and use it in GitHub Desktop.
Save zhaofengli/abbb5c3b7c9bfd911b6cc08af01cd0d4 to your computer and use it in GitHub Desktop.

Revisions

  1. zhaofengli created this gist Jul 8, 2017.
    40 changes: 40 additions & 0 deletions gs-criteria.pegjs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    Start
    = Comment* fc:FunctionCall Comment* { return fc }

    // Function names must be at least 2 characters and must start with a lowercase letter
    FunctionName
    = first:[a-z] rest:[a-z0-9]i+ { return first + rest.join('') }

    FunctionCall
    = Ws name:FunctionName '(' Ws args:ArgumentList Ws ')' { return { type: 'FunctionCall', name, args } }
    / Ws name:FunctionName { return { type: 'FunctionCall', name, arguments: [] } }

    Argument
    = FunctionCall
    / Genotype
    / Base
    / Number

    ArgumentList
    = first:Argument rest:(Comment* Ws ',' Comment* Ws rlist:ArgumentList { return rlist })? (Ws ',')? { return rest === null ? [first] : [first].concat(rest); }

    Base
    = [AGCTD-]

    Genotype
    = allele1:Base ';' allele2:Base { return { type: 'Genotype', allele1, allele2 } }

    Number
    = n:[0-9]+ { return parseInt(n.join('')) }

    Ws
    = [ \t\r\n]*

    Comment
    = Ws '#' [^\r\n]* LineEnding? { return null }
    / '<!--' ( !'-->' . )* '-->'

    LineEnding
    = '\r\n'
    / '\r'
    / '\n'
    23 changes: 23 additions & 0 deletions gs144
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    and(
    not(gs266),
    atleast(2,
    rs2032605(C),
    rs2032606(G),
    rs35460572(A),
    rs2032603(A),
    rs2032651(D;D),
    rs2032651(A),
    rs9341296(C),
    rs9341296(T),
    rs13304168(C),
    rs13304168(T),
    rs1118473(A),
    rs1118473(G),
    rs150173(A),
    rs150173(C),
    or(rs1558843(C;C),rs1558843(A;A)),
    rs16980426(G),
    rs16980426(T),
    or(rs17222419(C;C),rs17222419(T;T)),
    )
    )
    9 changes: 9 additions & 0 deletions gs238
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # [[rs1805007]](T;T),
    # [[rs1805008]](T;T))
    # [[rs1805009]](C;C),

    or(
    rs1805007(T;T),
    rs1805008(T;T),
    rs1805009(C;C)
    )