Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions server/graphql/graphqlHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const clinvarResolvers = require('./resolvers/clinvar.resolvers');
const geneResolvers = require('./resolvers/gene.resolvers');
const dioptResolvers = require('./resolvers/diopt.resolvers');
const phenotypeOntologyResolvers = require('./resolvers/phenotype-ontology.resolvers');
const goResolvers = require('./resolvers/go.resolvers');
const pharosResolvers = require('./resolvers/pharos.resolver');
const stringResolvers = require('./resolvers/string.resolvers');
const dbnsfpResolvers = require('./resolvers/dbnsfp.resolvers');
Expand All @@ -17,6 +18,7 @@ const clinvarTypeDefs = readFileSync(path.join(__dirname, 'schemas/clinvar.schem
const geneTypeDefs = readFileSync(path.join(__dirname, 'schemas/gene.schema.graphql'), 'utf8');
const dioptTypeDefs = readFileSync(path.join(__dirname, 'schemas/diopt.schema.graphql'), 'utf8');
const phenotypeOntologyTypeDefs = readFileSync(path.join(__dirname, 'schemas/phenotype-ontology.schema.graphql'), 'utf8');
const goTypeDefs = readFileSync(path.join(__dirname, 'schemas/go.schema.graphql'), 'utf8');
const pharosTypeDefs = readFileSync(path.join(__dirname, 'schemas/pharos.schema.graphql'), 'utf8');
const stringTypeDefs = readFileSync(path.join(__dirname, 'schemas/string.schema.graphql'), 'utf8');
const dbnsfpTypeDefs = readFileSync(path.join(__dirname, 'schemas/dbnsfp.schema.graphql'), 'utf8');
Expand All @@ -26,6 +28,7 @@ const typeDefs = `
${clinvarTypeDefs}
${geneTypeDefs}
${dioptTypeDefs}
${goTypeDefs}
${phenotypeOntologyTypeDefs}
${pharosTypeDefs}
${stringTypeDefs}
Expand Down Expand Up @@ -55,6 +58,8 @@ const typeDefs = `
phenotypeOntologyByNamespace(namespace: String!, limit: Int = 100, start: Int = 0): [PhenotypeOntology!]!
phenotypeOntologyByCategory(categoryId: Int!, limit: Int = 100, start: Int = 0): [PhenotypeOntology!]!
phenotypeOntologyByEntrezId(entrezId: Int!): [PhenotypeOntology!]!
goByEntrezId(entrezId: Int!): [GeneGO!]!

phenotypeOntologyByGeneSymbol(symbol: String!): [PhenotypeOntology!]!

pharosTargetById(id: Int!): PharosTarget
Expand Down Expand Up @@ -90,6 +95,8 @@ const rootValue = {
dioptOrthologsByEntrezId: dioptResolvers.findOrthologsByEntrezId,

phenotypeOntologyByPoId: phenotypeOntologyResolvers.findByPoId,
goByEntrezId: goResolvers.findByEntrezId,

phenotypeOntologyByName: phenotypeOntologyResolvers.findByName,
phenotypeOntologyByTaxonId: phenotypeOntologyResolvers.findByTaxonId,
phenotypeOntologyByNamespace: phenotypeOntologyResolvers.findByNamespace,
Expand Down
3 changes: 2 additions & 1 deletion server/graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* GraphQL API module for MARRVEL
*
* This module provides GraphQL API endpoints for various data sources
* including Clinvar, genes, DIOPT, phenotype ontology, and other genomic databases.
* including Clinvar, genes, DIOPT, phenotype ontology, gene ontology, and other genomic databases.
*
* Usage:
* - Access GraphQL playground at /graphql (in development)
Expand All @@ -16,6 +16,7 @@
* findOrthologsByTaxonIds
* - PhenotypeOntology: findByPoId, findByName, findByTaxonId, findByNamespace,
* findByCategory
* - GeneOntology: findByEntrezId
*/

module.exports = {
Expand Down
29 changes: 29 additions & 0 deletions server/graphql/resolvers/go.resolvers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Genes = require('../../models/genes.model');

/**
* Find Gene Ontology terms by gene Entrez ID
*/
const findByEntrezId = async ({ entrezId }) => {
try {
const gene = await Genes.findOne({ entrezId }, '-_id gos')
.populate('gos.ontology');
if (!gene || !gene.gos) {
return [];
}

return gene.gos.map((go) => ({
goId: go.goId,
eviCode: go.eviCode,
date: go.date,
assignedBy: go.assignedBy,
ontology: go.ontology
}));
} catch (error) {
console.error('Error fetching GOs by Entrez ID:', error);
throw new Error('Failed to fetch GOs by Entrez ID');
}
};

module.exports = {
findByEntrezId
};
23 changes: 23 additions & 0 deletions server/graphql/schemas/go.schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
A Gene Ontology term
"""
type GO {
id: String!
name: String
synonyms: [String]
is_a: [String]
namespace: String
def: String
agrSlimGoId: String
}

"""
Gene Ontology with evidence information
"""
type GeneGO {
goId: String!
eviCode: String
date: String
assignedBy: String
ontology: GO
}
Loading