Skip to content

Biomarker-KG #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
461624a
added endpoint
Jul 18, 2024
1b5ac35
added endpoints
Jul 19, 2024
768d57f
all use case changes
Jul 23, 2024
cf19aa2
updated
Jul 23, 2024
8f179be
trying
Jul 23, 2024
2207117
2.3.14
Jul 23, 2024
e1c5ecf
changed
Jul 23, 2024
d064ba4
removed citation
Jul 24, 2024
622fc60
removed footer
Jul 24, 2024
fecefe2
2.3.15
Jul 24, 2024
0474b45
dump
Jul 24, 2024
cabfd4d
2.3.16
Jul 29, 2024
eebab63
cleaning
Jul 29, 2024
0e39ce6
2.3.17
Jul 29, 2024
6f14116
debugging auth issue
Jul 30, 2024
6fe679d
2.3.18
Jul 30, 2024
21857ca
deleted Gene
Jul 31, 2024
9970288
2.3.19
Jul 31, 2024
bab86d4
cleaning
Aug 1, 2024
b84a2e8
cleaning
Aug 1, 2024
7aa2bca
2.3.21
Aug 1, 2024
75adbd6
pushing changes
Aug 1, 2024
f0eceed
cleaning
Aug 1, 2024
0ade799
2.3.23
Aug 1, 2024
935ab7a
updated tuts
Aug 1, 2024
160faf5
pushing changes
Aug 1, 2024
c923840
cleaning
Aug 1, 2024
588df56
2.3.26
Aug 1, 2024
9629ea2
new tutorial
Aug 1, 2024
1521f12
changed downloads page
Aug 1, 2024
73623c0
2.3.28
Aug 1, 2024
f5ab4bf
edited use case and also deleted footer text
Aug 2, 2024
e184b0c
updated use cases and footer
Aug 2, 2024
30fb6e1
2.3.30
Aug 2, 2024
dbe028e
changed condition nodes
Aug 2, 2024
ad14ed1
changing conditions
Aug 2, 2024
6e4b588
2.3.32
Aug 2, 2024
5c5e12b
patching issues
Aug 4, 2024
835f4de
2.3.33
Aug 4, 2024
10939aa
fixed issue with use case
Aug 4, 2024
f4b0268
2.3.34
Aug 4, 2024
5783141
updated use case
Aug 5, 2024
2851715
2.3.35
Aug 5, 2024
7e6c1ba
fixed counter issue
jeevangelista Aug 5, 2024
57349b3
added dev url
jeevangelista Aug 5, 2024
18cb31b
2.4.0
jeevangelista Aug 5, 2024
744248b
published new version
jeevangelista Aug 5, 2024
78fca7b
merging the counter fix
Aug 6, 2024
8de3aaa
2.4.1
Aug 6, 2024
3c8e08b
merging counter changes
Aug 6, 2024
6c78a36
2.4.1
Aug 6, 2024
3e0f321
Merge remote-tracking branch 'upstream/next14' into next14
Aug 6, 2024
ce1844d
2.4.1
Aug 6, 2024
8c90c33
merging with upstream
Aug 6, 2024
69fd497
changing tag
Aug 6, 2024
2002ada
updating tag
Aug 6, 2024
44a1108
2.4.2
Aug 6, 2024
b295071
merging the counter fix
Aug 6, 2024
d57180e
2.4.3
Aug 6, 2024
6d73426
fixed default
jeevangelista Aug 6, 2024
3cb749f
Merge remote-tracking branch 'upstream/next14' into next14
Aug 6, 2024
be157a1
counter issue fix
Aug 6, 2024
b68200a
counter issue fixed
Aug 6, 2024
9e9c710
2.4.5
Aug 6, 2024
2f706de
Merge branch 'bkg' into bkg
jeevangelista Aug 8, 2024
d9e2dcf
pushing to bkg branch
Aug 9, 2024
d329cdb
Merge branch 'next14' into bkg
Aug 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ NEXT_PUBLIC_PREFIX=
NEXT_PUBLIC_NEO4J_DEV_URL=bolt://localhost:7687
NEXT_PUBLIC_NEO4J_URL=bolt://neo4j:7687
NEO4J_DEV_URL=bolt://localhost:7687
NEXT_PUBLIC_NEO4J_V5_URL=bolt://neo4j-v5:7687

NEXT_PUBLIC_NEO4J_USER=neo4j
NEXT_PUBLIC_NEO4J_NAME=kg
Expand Down
12 changes: 12 additions & 0 deletions BiomarkerKGDemo-1.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"folders": [
{
"name": "BiomarkerKGDemo-1",
"path": "../../BiomarkerKGDemo-1"
},
{
"path": "."
}
],
"settings": {}
}
4 changes: 3 additions & 1 deletion app/ThemeRegistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import CssBaseline from '@mui/material/CssBaseline';
import { cfde_theme } from '@/themes/cfde';
import { enrichr_kg_theme } from '@/themes/enrichr-kg';
import { lncRNAlyzr } from '@/themes/lncRNAlyzr';
import { biomarker_kg_theme } from '@/themes/biomarker-kg';
const themes = {
cfde_theme: cfde_theme,
enrichr_kg_theme: enrichr_kg_theme,
lncRNAlyzr: lncRNAlyzr
lncRNAlyzr: lncRNAlyzr,
biomarker_kg_theme: biomarker_kg_theme,
}

// This implementation is from emotion-js
Expand Down
110 changes: 110 additions & 0 deletions app/api/biomarker/breastcancerdiagnosis/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { resolve_results } from "../../knowledge_graph/helper";
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { z } from 'zod';
import { initialize } from "../../initialize/helper";
async function process_query({
term,
limit,
aggr_scores,
colors,
field,
type}: {
term: string,
limit: number,
aggr_scores?: {[key:string]: {max: number, min: number}},
colors?: {[key: string]: {color?: string, field?: string, aggr_type?: string}},
field: string,
type: string,
}) {

const query = `MATCH p = (c:Condition {label: 'breast cancer'})<-[:diagnostic_for]-(b:Biomarker)-[:diagnostic_for]->(a:Condition)
RETURN p, nodes(p) AS n, relationships(p) AS r LIMIT TOINTEGER($limit)

`
const query_params = { term, limit }
return resolve_results({query, query_params, terms: [term], aggr_scores, colors, fields: [field]})
}

const InputSchema = z.object({
start: z.string(),
start_term: z.string(),
limit: z.number().optional(),
start_field: z.string().optional(),
})
/**
* @swagger
* /api/distillery/disease2exrna:
* get:
* description: Performs liquid biopsy of condition
* tags:
* - distillery apps
* parameters:
* - name: filter
* in: query
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - start
* - start_term
* properties:
* start:
* type: string
* start_field:
* type: string
* start_term:
* type: string
* limit:
* type: integer
* default: 5
* responses:
* 200:
* description: Subnetwork
* content:
* application/json:
* schema:
* type: object
* properties:
* nodes:
* type: array
* items:
* type: object
* properties:
* data:
* type: object
* edges:
* type: array
* items:
* type: object
* properties:
* data:
* type: object
*/
export async function GET(req: NextRequest) {
try {
const filter = req.nextUrl.searchParams.get("filter")
if (!filter) return NextResponse.json({error: "No filter inputted"}, {status: 400})
const f = JSON.parse(filter)
if (f.limit && !isNaN(f.limit) && typeof f.limit === 'string') f.limit = parseInt(f.limit)
const { start, start_term, limit=10, start_field="label" } = InputSchema.parse(f)

const {aggr_scores, colors} = await initialize()

if (start_term === undefined) return NextResponse.json({error: "No term inputted"}, {status: 400})
else {
try {
const results = await process_query({type:start, term:start_term, limit, aggr_scores, colors, field:start_field })
fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/counter/update`)
return NextResponse.json(results, {status: 200})
} catch (e) {
return NextResponse.json(e, {status: 400})
}
}
} catch (e) {
return NextResponse.json(e, {status: 400})
}
}

110 changes: 110 additions & 0 deletions app/api/biomarker/thyroidandskinmelanoma/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { resolve_results } from "../../knowledge_graph/helper";
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { z } from 'zod';
import { initialize } from "../../initialize/helper";
async function process_query({
term,
limit,
aggr_scores,
colors,
field,
type}: {
term: string,
limit: number,
aggr_scores?: {[key:string]: {max: number, min: number}},
colors?: {[key: string]: {color?: string, field?: string, aggr_type?: string}},
field: string,
type: string,
}) {

const query = `MATCH p = (c:Condition {label: 'thyroid cancer'})<-[:indicates_risk_of_developing]-(b:Biomarker)-[:indicates_risk_of_developing]->(a:Condition {label: 'Skin Squamous Cell Carcinoma'})
RETURN p, nodes(p) AS n, relationships(p) AS r LIMIT TOINTEGER($limit)

`
const query_params = { term, limit }
return resolve_results({query, query_params, terms: [term], aggr_scores, colors, fields: [field]})
}

const InputSchema = z.object({
start: z.string(),
start_term: z.string(),
limit: z.number().optional(),
start_field: z.string().optional(),
})
/**
* @swagger
* /api/distillery/disease2exrna:
* get:
* description: Performs liquid biopsy of condition
* tags:
* - distillery apps
* parameters:
* - name: filter
* in: query
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - start
* - start_term
* properties:
* start:
* type: string
* start_field:
* type: string
* start_term:
* type: string
* limit:
* type: integer
* default: 5
* responses:
* 200:
* description: Subnetwork
* content:
* application/json:
* schema:
* type: object
* properties:
* nodes:
* type: array
* items:
* type: object
* properties:
* data:
* type: object
* edges:
* type: array
* items:
* type: object
* properties:
* data:
* type: object
*/
export async function GET(req: NextRequest) {
try {
const filter = req.nextUrl.searchParams.get("filter")
if (!filter) return NextResponse.json({error: "No filter inputted"}, {status: 400})
const f = JSON.parse(filter)
if (f.limit && !isNaN(f.limit) && typeof f.limit === 'string') f.limit = parseInt(f.limit)
const { start, start_term, limit=10, start_field="label" } = InputSchema.parse(f)

const {aggr_scores, colors} = await initialize()

if (start_term === undefined) return NextResponse.json({error: "No term inputted"}, {status: 400})
else {
try {
const results = await process_query({type:start, term:start_term, limit, aggr_scores, colors, field:start_field })
fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/counter/update`)
return NextResponse.json(results, {status: 200})
} catch (e) {
return NextResponse.json(e, {status: 400})
}
}
} catch (e) {
return NextResponse.json(e, {status: 400})
}
}

4 changes: 3 additions & 1 deletion app/api/counter/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ export async function GET() {
console.log(error)
return NextResponse.error()
}
}
}

export const revalidate = 0;
4 changes: 3 additions & 1 deletion app/api/counter/update/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ export async function GET() {
console.log(error)
return NextResponse.error()
}
}
}

export const revalidate = 0;
2 changes: 1 addition & 1 deletion app/api/knowledge_graph/node_search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const query_schema = z.object({
*/
export async function GET(req: NextRequest) {
try {
const node_properties = await (await fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/knowledge_graph/search_properties`)).json()
const node_properties = await (await fetch(`${process.env.NODE_ENV==="development" ? process.env.NEXT_PUBLIC_HOST_DEV : process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/knowledge_graph/search_properties`)).json()
const {type, field="label", term, limit=100, filter={}} = query_schema.parse(convert_query(req))
const session = neo4jDriver.session({
defaultAccessMode: neo4j.session.READ
Expand Down
5 changes: 1 addition & 4 deletions app/api/knowledge_graph/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,16 +681,13 @@ export async function GET(req: NextRequest) {
if (start && end && start_term && end_term) {
if(augment) return NextResponse.json({error: "You can only augment on single search"}, {status: 400})
const results = await resolve_two_terms({edges, start, start_field, start_term, end, end_field, end_term, relation, limit, path_length, aggr_scores, colors, remove: remove ? remove: [], expand: expand ? expand : [], gene_links, additional_link_tags})
fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/counter/update`)
return NextResponse.json(results, {status: 200})
} else if (start && end && start_term ) {
if(augment) return NextResponse.json({error: "You can only augment on single search"}, {status: 400})
const results = await resolve_term_and_end_type({edges, start_term, start_field, start, end, relation, limit, path_length, aggr_scores, colors, remove, expand: expand, gene_links, additional_link_tags})
fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/counter/update`)
return NextResponse.json(results, {status: 200})
} else if (start) {
const results = await resolve_one_term({edges, start, field: start_field, term: start_term, relation, limit, path_length, aggr_scores, colors, remove, expand, gene_links, additional_link_tags, augment, augment_limit })
fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/counter/update`)
return NextResponse.json(results, {status: 200})
} else {
return NextResponse.json({error: "Invalid Input"}, {status: 400})
Expand All @@ -708,4 +705,4 @@ export async function GET(req: NextRequest) {
} catch (error) {
return NextResponse.json(error, {status: 400})
}
}
}
8 changes: 3 additions & 5 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ export default async function Home({searchParams}: {
<main className="mt-8 pb-8 pl-10 pr-10">
<Grid container spacing={2}>
<Grid item xs={12}>
<Suspense>
<QueryTranslator>
<Component searchParams={searchParams} {...root_tab}/>
</QueryTranslator>
</Suspense>
<QueryTranslator>
<Component searchParams={searchParams} {...root_tab}/>
</QueryTranslator>
</Grid>
</Grid>
</main>
Expand Down
2 changes: 1 addition & 1 deletion components/APIDoc/react-swagger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ReactSwagger({ spec }: Props) {
const [specs, setSpecs] = useState(null)
useEffect(()=>{
const resolve_specs = async () => {
const specs = await (await fetch(`${process.env.NEXT_PUBLIC_HOST}/api/docs`)).json()
const specs = await (await fetch(`${process.env.NODE_ENV==="development" ? process.env.NEXT_PUBLIC_HOST_DEV : process.env.NEXT_PUBLIC_HOST}/api/docs`)).json()
setSpecs(specs)
}
resolve_specs()
Expand Down
29 changes: 7 additions & 22 deletions components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
'use client'
import {useState, useEffect} from 'react'
import { delay } from '@/utils/helper';
import { Stack, Typography } from '@mui/material';
export const Counter = ({ui_theme}: {ui_theme?: string}) => {
const [count, setCount] = useState(0)
const [timer, setTimer] = useState(0)
const query_counter = async (delay_time=5000) => {
try {
await delay(delay_time)
const {count} = await ( await fetch(`${process.env.NEXT_PUBLIC_HOST}${process.env.NEXT_PUBLIC_PREFIX ? process.env.NEXT_PUBLIC_PREFIX: ''}/api/counter`)).json()
setCount(count)
setTimer(timer + 1)
} catch (error) {
console.log(error)
console.error(error)
}
}
import useSWR from 'swr';
const fetcher = (url) => fetch(url).then(r => r.json())
export const Counter = ({ui_theme}: {ui_theme?: string}) => {

const { data } = useSWR('/api/counter', fetcher, { refreshInterval: 5000 })

useEffect(()=>{
if (timer === 0) query_counter(0)
else query_counter()
}, [timer])
return (
<Stack direction={"row"} spacing={1}>
<Typography variant="nav">Queries Submitted: </Typography>
{ui_theme === undefined || ui_theme === 'cfde_theme' ?
<Typography><b>{count}</b></Typography>:
<Typography variant={'nav'}><b>{count}</b></Typography>
<Typography><b>{(data || {}).count}</b></Typography>:
<Typography variant={'nav'}><b>{(data || {}).count}</b></Typography>
}
</Stack>
)
Expand Down
Loading