Dr. EH,
Thanks again for your help. I have a follow-up question, though. Your advice
would again be much appreciated.
What can I do when the same "infinite loop" situation occurs once I submit more
than one pattern?
For example, when I have the following two facts:
f-0 (MAIN::SNP (SourceID "rs13266634") (Source "") (U2Data nil) (Name nil) (Organism nil) (DBName dbSNP)
(PredictedFunctionalRole "coding-nonsynonymous,reference") (SampleTypeUsed nil) (ValidationMethod
"by-cluster,by-frequency") (ID "rs13266634") (VariationClass "snp"))
f-1 (MAIN::SNP (SourceID "rs405509") (Source "") (U2Data nil) (Name nil) (Organism nil) (DBName dbSNP)
(PredictedFunctionalRole "locus-region") (SampleTypeUsed nil) (ValidationMethod
"by-2hit-2allele,by-cluster,by-frequency") (ID "rs405509") (VariationClass "snp"))
And I'm using the following template and rules:
(deftemplate Synonymity
(slot type)
(slot rsnum)
)
(deftemplate SNPRank
(slot id)
(slot rank)
(slot category)
)
(defrule check-syn
(declare (no-loop TRUE))
?snp <- (SNP (SourceID ?sid)
(PredictedFunctionalRole ?pfr&:(regex ?pfr
"synonymous|nonsynonymous|region"))
)
=>
(assert (Synonymity (type ?pfr)(rsnum ?sid)))
(assert (SNPRank (id ?sid) (rank 0.1)))
)
(defrule get-syn
(declare (no-loop TRUE))
?syn1 <- (Synonymity (type ?x1&:(eq ?x1 "locus-region")) (rsnum ?id1))
?r1 <- (SNPRank (id ?sid1) (rank ?y1))
=>
(modify ?r1 (rank (+ ?y1 0.2)) (category "locus-region"))
)
(defrule get-nonsyn
(declare (no-loop TRUE))
?syn2 <- (Synonymity (type ?x2&:(eq ?x2
"coding-nonsynonymous,reference")) (rsnum ?id2))
?r2 <- (SNPRank (id ?sid2) (rank ?y2))
=>
(modify ?r2 (rank (+ ?y2 0.6)) (category "nonsynonymous"))
)
------------------------------------------------------------
Hsin Yi (Terry) Shen, MSPH
NLM Predoctoral Fellow
Department of Medical Education and Biomedical Informatics
School of Medicine, Box 357240
University of Washington
Seattle, WA 98195-7240
Lab Phone: 206-616-8414
[EMAIL PROTECTED]
http://students.washington.edu/hyshen
On Thu, 22 Mar 2007, Hsin Terry Shen wrote:
Thank you so much! That fixed it.
~~Terry
------------------------------------------------------------
Hsin Yi (Terry) Shen, MSPH
NLM Predoctoral Fellow
Department of Medical Education and Biomedical Informatics
School of Medicine, Box 357240
University of Washington
Seattle, WA 98195-7240
Lab Phone: 206-616-8414
[EMAIL PROTECTED]
http://students.washington.edu/hyshen
On Thu, 22 Mar 2007, Ernest Friedman-Hill wrote:
This isn't "not working", it's just the expected behavior. If you write a
rule that matches a fact and modifies it, and the modified fact also matches
the rule, then you have a loop. You can use the "watch" function to see a
trace of what's happening. I expect your first version "works" because the
modify doesn't actually change anything -- those are probably the values
that are already in the fact.
To stop the loop, use the "no-loop" declaration:
(defrule get-nonsyn
(declare (no-loop TRUE))
...
On Mar 22, 2007, at 11:28 AM, Hsin Terry Shen wrote:
Sorry, what I meant was that when I include (rank (+ ?y 0.5)) instead of
just (rank ?y) or just some number (rank 0.5)l then it looks like it goes
into an infinite cycle or something. No facts are being returned, it
looks like it's still processing... though I could keep waiting and
seeing if something eventually comes back.
But I change to just (rank ?y), I get back:
f-408 (MAIN::Synonymity (type "coding-nonsynonymous,reference") (rsnum
"rs13266634"))
f-409 (MAIN::SNPRank (id "rs13266634") (rank 0.1) (category nil))
~~Terry
------------------------------------------------------------
Hsin Yi (Terry) Shen, MSPH
NLM Predoctoral Fellow
Department of Medical Education and Biomedical Informatics
School of Medicine, Box 357240
University of Washington
Seattle, WA 98195-7240
Lab Phone: 206-616-8414
[EMAIL PROTECTED]
http://students.washington.edu/hyshen
On Thu, 22 Mar 2007, Ernest Friedman-Hill wrote:
"No longer works" in what way? The code looks fine, should do what you
expect if ?y is bound to a number, anyway.
On Mar 21, 2007, at 11:37 PM, Hsin Terry Shen wrote:
Hi everyone,
I have a simple rule that modifies a fact, it works in this scenario:
(defrule get-nonsyn
?syn <- (Synonymity (type ?nspfr&:(regex ?nspfr "nonsynonymous"))
(rsnum ?id))
?r <- (SNPRank (id ?sid) (rank ?y))
=>
(modify ?r (rank ?y) (category "nonsynonymous"))
)
However, as soon as I try to include an addition function to the
"rank" slot of the modify function, it no longer works:
(defrule get-nonsyn
?syn <- (Synonymity (type ?nspfr&:(regex ?nspfr "nonsynonymous"))
(rsnum ?id))
?r <- (SNPRank (id ?sid) (rank ?y))
=>
(modify ?r (rank (+ ?y 0.5)) (category "nonsynonymous"))
)
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------