Skip to content
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

DSERV-632 Adding rsid to /variants/phenotypes response #330

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
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
25 changes: 13 additions & 12 deletions src/routers/datatypeRouters/edges/variants_phenotypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const variantsPhenotypesQueryFormat = z.object({
})

const variantPhenotypeFormat = z.object({
rsid: z.array(z.string()).nullable(),
phenotype_term: z.string().nullable(),
study: z.string().or(studyFormat).optional(),
log10pvalue: z.number().nullable(),
Expand Down Expand Up @@ -192,20 +193,19 @@ async function findPhenotypesFromVariantSearch (input: paramsFormatType): Promis
}

query = `
LET primaryEdges = (
FOR record IN ${variantToPhenotypeSchema.db_collection_name as string}
FILTER record._from IN ['${variantIDs.join('\', \'')}'] ${phenotypeFilter}
RETURN record._id
)

FOR edgeRecord IN ${variantPhenotypeToStudy.db_collection_name as string}
FILTER edgeRecord._from IN primaryEdges ${hyperEdgeFilter.replaceAll('record', 'edgeRecord')}
SORT '_key'
LIMIT ${input.page as number * limit}, ${limit}
RETURN {
'study': ${input.verbose === 'true' ? `(${verboseQuery})[0]` : 'edgeRecord._to'},
${getDBReturnStatements(variantPhenotypeToStudy).replaceAll('record', 'edgeRecord')}
}
RETURN (
FOR edgeRecord IN ${variantPhenotypeToStudy.db_collection_name as string}
FILTER edgeRecord._from == record._id ${hyperEdgeFilter.replaceAll('record', 'edgeRecord')}
SORT '_key'
LIMIT ${input.page as number * limit}, ${limit}
RETURN {
'rsid': DOCUMENT(record._from).rsid,
'study': ${input.verbose === 'true' ? `(${verboseQuery})[0]` : 'edgeRecord._to'},
${getDBReturnStatements(variantPhenotypeToStudy).replaceAll('record', 'edgeRecord')}
}
)[0]
`
} else {
query = `
Expand All @@ -214,6 +214,7 @@ async function findPhenotypesFromVariantSearch (input: paramsFormatType): Promis
SORT record._key
LIMIT ${input.page as number * limit}, ${limit}
RETURN {
'rsid': DOCUMENT((FOR vp in ${variantToPhenotypeSchema.db_collection_name as string} FILTER vp._id == record._from RETURN vp._from)[0]).rsid,
'study': ${input.verbose === 'true' ? `(${verboseQuery.replaceAll('edgeRecord', 'record')})[0]` : 'record._to'},
${getDBReturnStatements(variantPhenotypeToStudy)}
}
Expand Down