Skip to content

Commit

Permalink
added a block list of general nodes; weighted the edges from text-min…
Browse files Browse the repository at this point in the history
…ing more heavily and those from SEMMED less; modified ranking algorithm that one-hop and two-hop answers are equally weighted
  • Loading branch information
kaiwenho committed Jul 9, 2024
1 parent ec3d326 commit e97d004
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 19 deletions.
20 changes: 14 additions & 6 deletions medikanren2/neo/neo-server/neo-server-utils.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,23 @@ A decreases B increases C = A decreases C
(loop (cdr n*) (car n*))
(loop (cdr n*) greatest)))))))

(define (get-source-helper props)
(or (get-assoc "primary_knowledge_source" props)
(and (get-assoc "json_attributes" props)
"infores:text-mining-provider-targeted")))

(define (get-source props)
(let ((source (or (get-assoc "primary_knowledge_source" props)
(and (get-assoc "json_attributes" props)
"infores:text-mining-provider-targeted")))) ;text-mining
(hash
'resource_id source
'resource_role "primary_knowledge_source")))
'resource_id (get-source-helper props)
'resource_role "primary_knowledge_source"))

(define (num-pubs props) (string->number (get-assoc "mediKanren-score" props)))
(define (num-pubs props)
(let ((score (string->number (get-assoc "mediKanren-score" props)))
(source (get-source-helper props)))
(cond
((equal? source "infores:semmeddb") (* 0.7 score))
((equal? source "infores:text-mining-provider-targeted") (* 2 score))
(else score))))

(define (get-score-from-result result)
(let ((analyses (hash-ref result 'analyses #f)))
Expand Down
56 changes: 43 additions & 13 deletions medikanren2/neo/neo-server/neo-server.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

(define DEFAULT_PORT 8384)

(define NEO_SERVER_VERSION "1.48")
(define NEO_SERVER_VERSION "1.49")

;; Maximum number of results to be returned from *each individual* KP,
;; or from mediKanren itself.
Expand All @@ -51,19 +51,32 @@
(list (get-highest-bucket-number-text-mining))
(list (get-highest-bucket-number-rtx-kg2))))

;; Unsecret-level excluded MVP1 results - answers that is obviously wrong/useless
(define UNWELCOME-TREATMENT
(define GENERAL-NODES
(curies->synonyms
'(
"MESH:D001335" ; Vehicle emissions
"UMLS:C0013227" ; Pharmaceutical preparations
"MESH:D014028" ; tobacco smoke pollution
'("UMLS:C0017337" ; Genes
"UMLS:C0005522" ; Biological Products
"UMLS:C1611640" ; Therapeutic agent (substance)
"MESH:D020218" ; Response elements
"UMLS:C0162327" ; RNA Sequence
"PUBCHEM.COMPOUND:135499568" ; Double stranded RNA
"UMLS:C1099354" ; RNA, Small Interfering
"UMLS:C0376613" ; "Vaccines, DNA"
)))

;; Unsecret-level excluded MVP1 results - answers that is obviously wrong/useless
(define UNWELCOME-TREATMENT
(append
(curies->synonyms
'(
"MESH:D001335" ; Vehicle emissions
"UMLS:C0013227" ; Pharmaceutical preparations
"MESH:D014028" ; tobacco smoke pollution
))
GENERAL-NODES
))




;; ** `tcp-listen` settings **
;;
Expand Down Expand Up @@ -1005,6 +1018,17 @@
,props_xy)
(not (excluded-semmed-edge? props_xy))]))

(define (not-general-connector? e)
(match e
[`(,curie_x
,pred_xy
,curie_y
,(? string? pred_yz)
,(? string? curie_z)
,props_xy
,props_yz)
(not (member curie_y GENERAL-NODES))]))

(define (not-unwelcome-treatment? e)
(not (member (car e) UNWELCOME-TREATMENT)))

Expand Down Expand Up @@ -1097,6 +1121,7 @@
MAX_RESULTS_FROM_COMPONENT
(lambda (r*) (filter (lambda (r)
(and (not-semmed-excluded? r)
(not-general-connector? r)
(not-unwelcome-treatment? r)))
r*)))))
(list disease-ids q-1hop q-2hop))]
Expand Down Expand Up @@ -1146,7 +1171,9 @@
gene-category+
TOP_BUCKET_NUMBERS
MAX_RESULTS_FROM_COMPONENT
(lambda (r*) (filter not-semmed-excluded? (mvp2-2hop-filter r* direction))))))
(lambda (r*) (filter (lambda (r) (and (not-semmed-excluded? r)
(not-general-connector? r)))
(mvp2-2hop-filter r* direction))))))
(list chemical-ids qualified-q-1hop qualified-q-2hop))]
[(eq? 'mvp2-gene which-mvp)
;;
Expand Down Expand Up @@ -1206,7 +1233,10 @@
gene-ids+
TOP_BUCKET_NUMBERS
MAX_RESULTS_FROM_COMPONENT
(lambda (r*) (filter not-semmed-excluded? (mvp2-2hop-filter r* direction))))))
(lambda (r*) (filter (lambda (r)
(and (not-semmed-excluded? r)
(not-general-connector? r)))
(mvp2-2hop-filter r* direction))))))
(list gene-ids qualified-q-1hop qualified-q-2hop))])))

(define q-1hop-unique-results (remove-duplicates q-1hop-results))
Expand All @@ -1226,16 +1256,15 @@
,props_yz)
(if (and (edge-has-source? props_xy)
(edge-has-source? props_yz))
(* (num-pubs props_xy) (num-pubs props_yz))
(sqrt (* (num-pubs props_xy) (num-pubs props_yz)))
#f)]
[`(,curie_x
,pred_xy
,curie_y
.
,props_xy)
(if (edge-has-source? props_xy)
(let ((n (num-pubs props_xy)))
(* n n))
(num-pubs props_xy)
#f)]))

(define scored/q-1hop-unsorted-long
Expand Down Expand Up @@ -1344,7 +1373,7 @@
,curie_y
.
,props_xy)
(list* (sqrt score)
(list* score
(curie->canonical curie_x)
pred_xy
(curie->canonical curie_y)
Expand Down Expand Up @@ -2103,3 +2132,4 @@

(length q3)
(length UNWELCOME-TREATMENT)
(length GENERAL-NODES)

0 comments on commit e97d004

Please sign in to comment.