diff --git a/app/models/Backend.scala b/app/models/Backend.scala index 467b801c..1810d5ee 100644 --- a/app/models/Backend.scala +++ b/app/models/Backend.scala @@ -22,8 +22,8 @@ import models.entities.Configuration.* import models.entities.DiseaseHPOs.* import models.entities.Drug.* import models.entities.DrugWarning.* +import models.entities.EnhancerToGenes.* import models.entities.Interactions.* -import models.entities.Intervals.* import models.entities.Loci.* import models.entities.MechanismsOfAction.* import models.entities.MousePhenotypes.* @@ -728,14 +728,14 @@ class Backend @Inject() (implicit dbRetriever.executeQuery[InteractionResources, Query](interactionSourcesQuery.query) } - def getIntervals(chromosome: String, - start: Int, - end: Int, - pagination: Option[Pagination] - ): Future[Intervals] = { - val tableName = getTableWithPrefixOrDefault(defaultOTSettings.clickhouse.intervals.name) + def getEnhancerToGenes(chromosome: String, + start: Int, + end: Int, + pagination: Option[Pagination] + ): Future[EnhancerToGenes] = { + val tableName = getTableWithPrefixOrDefault(defaultOTSettings.clickhouse.enhancerToGene.name) val page = pagination.getOrElse(Pagination.mkDefault).offsetLimit - val intervalsQuery = IntervalsQuery( + val e2gQuery = EnhancerToGeneQuery( chromosome, start, end, @@ -745,12 +745,12 @@ class Backend @Inject() (implicit ) val results = dbRetriever - .executeQuery[Interval, Query](intervalsQuery.query) - .map { intervals => - if (intervals.length) > 0 then { - Intervals(intervals.head.meta_total, intervals) + .executeQuery[EnhancerToGene, Query](e2gQuery.query) + .map { e2g => + if (e2g.length > 0) then { + EnhancerToGenes(e2g.head.meta_total, e2g) } else { - Intervals.empty + EnhancerToGenes.empty } } results diff --git a/app/models/db/IntervalsQuery.scala b/app/models/db/EnhancerToGeneQuery.scala similarity index 76% rename from app/models/db/IntervalsQuery.scala rename to app/models/db/EnhancerToGeneQuery.scala index abf336ca..e8f59db5 100644 --- a/app/models/db/IntervalsQuery.scala +++ b/app/models/db/EnhancerToGeneQuery.scala @@ -5,12 +5,12 @@ import esecuele.Column.literal import esecuele.* import utils.OTLogging -case class IntervalsQuery(chromosome: String, - start: Int, - end: Int, - tableName: String, - offset: Int, - size: Int +case class EnhancerToGeneQuery(chromosome: String, + start: Int, + end: Int, + tableName: String, + offset: Int, + size: Int ) extends Queryable with OTLogging { diff --git a/app/models/entities/Configuration.scala b/app/models/entities/Configuration.scala index 61bb389a..4605b178 100644 --- a/app/models/entities/Configuration.scala +++ b/app/models/entities/Configuration.scala @@ -91,12 +91,12 @@ object Configuration { diseaseHPO: DbTableSettings, drug: DbTableSettings, drugWarnings: DbTableSettings, + enhancerToGene: DbTableSettings, evidence: EvidenceSettings, expression: DbTableSettings, faers: DbTableSettings, hpo: DbTableSettings, interaction: DbTableSettings, - intervals: DbTableSettings, go: DbTableSettings, harmonic: HarmonicSettings, l2gPredictions: DbTableSettings, diff --git a/app/models/entities/Intervals.scala b/app/models/entities/EnhancerToGene.scala similarity index 54% rename from app/models/entities/Intervals.scala rename to app/models/entities/EnhancerToGene.scala index 85ca6851..2caafb58 100644 --- a/app/models/entities/Intervals.scala +++ b/app/models/entities/EnhancerToGene.scala @@ -5,13 +5,14 @@ import slick.jdbc.GetResult case class ResourceScore(name: String, value: Double) -case class Interval( +case class EnhancerToGene( chromosome: String, start: Int, end: Int, geneId: String, biosampleName: String, biosampleId: String, + biosampleFromSourceId: Option[String], intervalType: String, distanceToTss: Int, score: Double, @@ -19,18 +20,19 @@ case class Interval( datasourceId: String, pmid: String, studyId: String, + qualityControls: Option[Seq[String]], meta_total: Long ) -case class Intervals( +case class EnhancerToGenes( count: Long, - rows: Vector[Interval] + rows: Vector[EnhancerToGene] ) -object Intervals { - val empty: Intervals = Intervals(0, Vector.empty) - implicit val getIntervalRowFromDB: GetResult[Interval] = - GetResult(r => Json.parse(r.<<[String]).as[Interval]) - implicit val IntervalImp: OFormat[Interval] = Json.format[Interval] +object EnhancerToGenes { + val empty: EnhancerToGenes = EnhancerToGenes(0, Vector.empty) + implicit val getEnhancerToGeneRowFromDB: GetResult[EnhancerToGene] = + GetResult(r => Json.parse(r.<<[String]).as[EnhancerToGene]) + implicit val EnhancerToGeneImp: OFormat[EnhancerToGene] = Json.format[EnhancerToGene] implicit val ResourceScoreTypeImp: OFormat[ResourceScore] = Json.format[ResourceScore] } diff --git a/app/models/gql/Objects.scala b/app/models/gql/Objects.scala index c067b26e..1bdc3ccc 100644 --- a/app/models/gql/Objects.scala +++ b/app/models/gql/Objects.scala @@ -1427,8 +1427,8 @@ object Objects extends OTLogging { DocumentField("name", "Name of the resource providing the score"), DocumentField("value", "Score value from the resource") ) - implicit lazy val intervalImp: ObjectType[Backend, Interval] = - deriveObjectType[Backend, Interval]( + implicit lazy val enhancerToGeneImp: ObjectType[Backend, EnhancerToGene] = + deriveObjectType[Backend, EnhancerToGene]( ObjectTypeDescription( "Regulatory enhancer/promoter regions to gene (target) predictions for a specific tissue/cell type based on the integration of experimental sources" ), @@ -1450,6 +1450,10 @@ object Objects extends OTLogging { ), DocumentField("studyId", "Identifier of the study providing the experimental data"), DocumentField("biosampleName", "Name of the biosample where the interval was identified"), + DocumentField("biosampleFromSourceId", + "Identifier of the biosample defined by the datasource provider" + ), + DocumentField("qualityControls", "Quality control flags for this interval."), ReplaceField( "geneId", Field("target", @@ -1468,11 +1472,10 @@ object Objects extends OTLogging { ), resolve = r => biosamplesFetcher.deferOpt(r.value.biosampleId) ) - ), - ExcludeFields("meta_total") + ) ) - implicit lazy val intervalsImp: ObjectType[Backend, Intervals] = - deriveObjectType[Backend, Intervals]( + implicit lazy val enhancerToGenesImp: ObjectType[Backend, EnhancerToGenes] = + deriveObjectType[Backend, EnhancerToGenes]( ObjectTypeDescription( "Collection of regulatory enhancer/promoter regions to gene (target) predictions for a specific tissue/cell type based on the integration of experimental sources" ), @@ -2504,18 +2507,18 @@ object Objects extends OTLogging { ctx => ProteinCodingCoordinatesByVariantDeferred(ctx.value.variantId, ctx.arg(pageArg)) ), Field( - "intervals", - intervalsImp, + "enhancerToGenes", + enhancerToGenesImp, description = Some( "Regulatory enhancer/promoter regions to gene (target) predictions overlapping with this variant's location. These intervals link regulatory regions to target genes based on experimental data for specific tissues or cell types." ), arguments = pageArg :: Nil, complexity = Some(complexityCalculator(pageArg)), resolve = ctx => - ctx.ctx.getIntervals(ctx.value.chromosome, - ctx.value.position, - ctx.value.position, - ctx.arg(pageArg) + ctx.ctx.getEnhancerToGenes(ctx.value.chromosome, + ctx.value.position, + ctx.value.position, + ctx.arg(pageArg) ) ) ), diff --git a/conf/application.conf b/conf/application.conf index 1e10f7f1..780b1a12 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -56,6 +56,10 @@ ot { label = "Drug warnings table" name = "drug_warnings" } + enhancerToGene { + label = "Enhancer to gene table" + name = "enhancer_to_gene" + } evidence { label = "Evidence table" name = "evidence" @@ -88,10 +92,6 @@ ot { label = "Molecular interaction table" name = "interaction" } - intervals { - label = "Intervals table" - name = "intervals" - } literature { label = "Literature ocurrences table" name = "literature"