**** load load-stmtest-json

mod TEST-JSONRULES is
  inc IPLA-JSON .

var b : Bool .
var es : ESet .

ops es0 es1 es2 es3 es4 es5u es5r es6 es7 : -> ESet [memo] .
eq es0 = initDishes(initPLAeset(mt,'maude, 'graphics2d, 'graphics2d),'QQQ) .


op modQQQ : -> Module .
eq modQQQ = upModule('QQQ,false) .

op rulesQQQ : -> RuleSet .
eq rulesQQQ = upRls('QQQ,true) .

var res?? : [ResultPair?] .

**** addEntry(es,'tval,'tkb kbname, pnotes, tm(modname,pntlT))
eq es1 = initDKBnet(es0,'RKB,'QQQ,'allDish) .

*** tkb2occmap(es,kbname) =
***      addEntry(es,'qval,'occmap kbname,onotes, ql(nil))
eq es2 = initOccMap(es1,'RKB) .

op omap : -> Notes .
eq omap = getNotes(es2,'qval, 'occmap 'RKB) .

op mypntl : -> TermList .
eq mypntl =
   pntlT2pntTL(tvalTerm(getVal(es2,'tval,'tkb 'RKB, tm('QQQ,'nil.PNTransList)))) .

op myEnotes : -> Notes .
eq myEnotes = 
 (("001.EgfR.irt.Egf"  := ql( '/Egf-Evidence/EgfR.irt.Egf.001.html)),
	("116.Gab1.irt.Egf"  := ql( '/Egf-Evidence/Gab1.irt.Egf.116.html)),
	("116x.Gab1.irt.Egf" := ql( '/Egf-Evidence/Gab1.irt.Egf.116.html)),
	("172.Pi3k.irt.Egf"  := ql( '/Egf-Evidence/Pi3k.irt.Egf.172.html)),
	("197.Sos1.irt.Egf"  := ql( '/Egf-Evidence/Sos1.irt.Egf.197.html)),
	("529.Hras.irt.Egf"  := ql( '/Egf-Evidence/Hras.irt.Egf.529.html)) ) .

***(

(("15.Cbl.reloc.Yphos" := ql( '8662998)),
("1.EgfR.act" := ql( '12620237)),
("3.ErbB2.act" := ql( '8617201 '8665853 '11297548 '7903153))
) 

(5.Grb2.reloc := ql( 2803273 7527043 7798267))
(7.IP3.from.PIP2.by.Plc := ql( ))
(9.PIP3.from.PIP2.by.Pi3k := ql( ))
(8.Pi3k.act := ql( 11353842 11695994 11779868))
(13.Sos1.reloc := ql( ))
(4.Gab1.Yphosed := ql( 11134009))
(11.Shc.Yphosed := ql(  9710588 8662998 8939605 9388490))
(14.Vav2.act := ql( 10618391 12454019))
(2.EgfR.ubiq := ql( 10531381))
(12.Sos1.reinit := ql( 11726515))
(10.Plcg.act := ql( 1537335))
(6.Hras.act.1 := ql( 11777939))
)
***(
 (("001.EgfR.irt.Egf"  := ql( '/Egf-Evidence/EgfR.irt.Egf.001.html)),
	("116.Gab1.irt.Egf"  := ql( '/Egf-Evidence/Gab1.irt.Egf.116.html)),
	("116x.Gab1.irt.Egf" := ql( '/Egf-Evidence/Gab1.irt.Egf.116.html)),
	("172.Pi3k.irt.Egf"  := ql( '/Egf-Evidence/Pi3k.irt.Egf.172.html)),
	("197.Sos1.irt.Egf"  := ql( '/Egf-Evidence/Sos1.irt.Egf.197.html)),
	("529.Hras.irt.Egf"  := ql( '/Egf-Evidence/Hras.irt.Egf.529.html)) ) .
)

vars pnt ridT ioccsT ooccsT boccsT : Term .

op pnt2tl : Term -> TermList .
ceq pnt2tl(pnt) = (ridT, ioccsT, ooccsT,boccsT) 
    if 'pnTrans[ridT,ioccsT,ooccsT,boccsT] := pnt .


ops pnt0 ridT0 iT0 oT0 bT0 : -> Term .

eq pnt0 = first(mypntl) .
eq ridT0 = first(pnt2tl(pnt0)) .
eq iT0 = first(rest(pnt2tl(pnt0))) .
eq oT0 = first(rest(rest(pnt2tl(pnt0)))) .
eq bT0 = first(rest(rest(rest(pnt2tl(pnt0))))) .

ops name0 bname0 mdstr0 : -> String .
eq name0 =  printRidTAll(ridT0) .
eq bname0 = (if rfind(name0, PNRidSuffix, length(name0)) :: Nat 
             then substr(name0,0,rfind(name0, PNRidSuffix, length(name0)) ) 
             else name0 fi) .
eq mdstr0 = getMetaData(getAttrs(getRule(rulesQQQ,qid(bname0)))) .

ops pnt3 ridT3 : -> Term .

eq pnt3 = first(rest(rest(rest(mypntl)))) .
eq ridT3 = first(pnt2tl(pnt3)) .

ops name3 bname3 mdstr3 : -> String .
eq name3 =  printRidTAll(ridT3) .
eq bname3 = (if rfind(name3, PNRidSuffix, length(name3)) :: Nat 
             then substr(name3,0,rfind(name3, PNRidSuffix, length(name3)) ) 
             else name3 fi) .
eq mdstr3 = getMetaData(getAttrs(getRule(rulesQQQ,qid(bname3)))) .

***(
'pnTrans[''172.Pi3k.irt.Egf.Qid,'<_`,_>['Pi3k.Composite,
    'CLc.LocName],'<_`,_>['Pi3k.Composite,'CLi.LocName],'<_`,_>['_:_[
    'Egf.BProtein,'`[_-_`]['EgfR.BProtein,'Yphos.AAMOD]],'CLm.LocName]]
)

endm

***(

red first(mypntl) .
red first(rest(mypntl)) .
red getNth(mypntl,2,'nil.PNTransList) .

**** rules2json1(modname,enotes,(pnt,pntl),str,badstr) 

red rfind(name0, PNRidSuffix, length(name0)) .  
red qvalQidList(lookupd(myEnotes,bname0,ql(nil))) .
red mkEvidenceExp(qvalQidList(lookupd(myEnotes,bname0,ql(nil)))) .
    /\ ql(toks) := lookupd(enotes,basename, ql(nil))
    /\ evidence := mkEvidenceExp(toks)

red getRule(getRls(upModule('QQQ,false)), qid(bname0)) .

red readSexp(mdstr0,0,length(mdstr0)) .

red alist2json(sexp2l([[a("evidence") a("Egf-Evidence/001.EgfR.irt.Egf.html")]]),nil,"") .

red rules2json1(rulesQQQ,myEnotes, first(mypntl),"","")  .
red rules2json1(rulesQQQ,myEnotes, first(rest(mypntl)),"","")  .
red rules2json1(rulesQQQ,myEnotes, first(rest(rest(mypntl))),"","")  .
red rules2json1(rulesQQQ,myEnotes, first(rest(rest(rest(mypntl)))),"","")  .

red readSexp(mdstr3,0,length(mdstr3)) .
 
[ [a("hidden") [a("pre") a("GDP-LFuc")] [a("post") a("GDP")]] ]

red alist2json([a("hidden") [a("pre") a("GDP-LFuc")] [a("post") a("GDP")]],nil,"") .

{ "hidden" : {"pre" : "GDP-LFuc", "post" : "GDP"} }

red rules2json1(rulesQQQ,myEnotes,mypntl,"","")  .

red rules2json(es2,'MyKB) .


)
