Skip to content

Commit

Permalink
Merge pull request #19 from bento-platform/releases/v3.2
Browse files Browse the repository at this point in the history
releases/v3.2
  • Loading branch information
brouillette authored Jan 10, 2022
2 parents 18be6a9 + 3901397 commit 46ace61
Show file tree
Hide file tree
Showing 15 changed files with 457 additions and 362 deletions.
43 changes: 18 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Response
Requests
> &nbsp;&nbsp;**GET** `/variants/get/by/variantId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, M )`
> - chromosome : **string** `( 1-23, X, Y, MT )`
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele ( "A" | "C" | "G" | "T" or some combination thereof )`
Expand All @@ -214,10 +214,11 @@ Requests
> - sortByPosition : **string** `(<empty> | asc | desc)`
> - includeInfoInResultSet : **boolean** `(true | false)`
> - genotype : **string** `( "HETEROZYGOUS" | "HOMOZYGOUS_REFERENCE" | "HOMOZYGOUS_ALTERNATE" )`
> - getSampleIdsOnly : **bool** *`(optional) - default: false `*
>
> &nbsp;&nbsp;**GET** `/variants/count/by/variantId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, M )`
> - chromosome : **string** `( 1-23, X, Y, MT )`
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele`
Expand All @@ -227,7 +228,7 @@ Requests
> &nbsp;&nbsp;**GET** `/variants/get/by/sampleId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, M )`
> - chromosome : **string** `( 1-23, X, Y, MT )`
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele`
Expand All @@ -240,7 +241,7 @@ Requests
>
> &nbsp;&nbsp;**GET** `/variants/count/by/sampleId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, M )`
> - chromosome : **string** `( 1-23, X, Y, MT )`
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele`
Expand All @@ -257,14 +258,18 @@ Generalized Response Body Structure
>{
> "status": `number` (200 - 500),
> "message": `string` ("Success" | "Error"),
> "data": [
> "results": [
> {
> "variantId": `string`,
> "sampleId": `string`,
> "count": `number`,
> "results": [
> "query": `string`, // reflective of the type of id queried for, i.e 'variantId:abc123', or 'sampleId:HG0001
> "assemblyId": `string` ("GRCh38" | "GRCh37" | "NCBI36" | "Other"), // reflective of the assembly id queried for
> "count": `number`, // this field is only present when performing a COUNT query
> "start": `number`, // reflective of the provided lowerBound parameter, 0 if none
> "end": `number`, // reflective of the provided upperBound parameter, 0 if none
> "chromosome": `string`, // reflective of the chromosome queried for
> "calls": [ // this field is only present when performing a GET query
> {
> "filter": `string`,
> "id": `string`, // variantId
> "chrom": `string`,
> "pos": `number`,
> "ref": `[]string`, // list of alleles
> "alt": `[]string`, // list of alleles
Expand All @@ -277,21 +282,9 @@ Generalized Response Body Structure
> ],
> "format":`string`,
> "qual": `number`,
> "id": `string`,
> "sample": {
> "id": `string`,
> "variation": {
> "genotype": {
> "phased": `boolean`,
> "alleleLeft": `number`,
> "alleleRight": `number`,
> "zygosity": `number` (0 : "Unknown" | 1 : "Heterozygous" | 2 : "HomozygousReference" | 3 : "HomozygousAlternate")
> },
> "genotypeProbability": `[]float` | null,
> "phredScaleLikelyhood": `[]float` | null,
> }
> },
> "fileId": `string` (UUID),
> "filter": `string`,
> "sampleId": `string`,
> "genotype_type": `string ( "HETEROZYGOUS" | "HOMOZYGOUS_REFERENCE" | "HOMOZYGOUS_ALTERNATE" )`,
> "assemblyId": `string` ("GRCh38" | "GRCh37" | "NCBI36" | "Other"),
> },
> ...
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ services:
- GOHAN_API_VCF_PATH=${GOHAN_API_CONTAINERIZED_VCF_PATH}
- GOHAN_API_GTF_PATH=${GOHAN_API_CONTAINERIZED_GTF_PATH}
- GOHAN_API_API_DRS_BRIDGE_DIR=${GOHAN_API_API_DRS_BRIDGE_DIR_CONTAINERIZED}
- GOHAN_API_BULK_INDEXING_CAP=${GOHAN_API_BULK_INDEXING_CAP}
- GOHAN_API_FILE_PROC_CONC_LVL=${GOHAN_API_FILE_PROC_CONC_LVL}
- GOHAN_API_LINE_PROC_CONC_LVL=${GOHAN_API_LINE_PROC_CONC_LVL}

Expand Down
2 changes: 2 additions & 0 deletions src/api/models/constants/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package constants

var VcfHeaders = []string{"chrom", "pos", "id", "ref", "alt", "qual", "filter", "info", "format"}

/*
Defines a set of base level
constants and enums to be used
Expand Down
15 changes: 15 additions & 0 deletions src/api/models/constants/zygosity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ const (
func IsKnown(value int) bool {
return value > int(Unknown) && value <= int(HomozygousAlternate)
}

func ZygosityToString(zyg constants.Zygosity) string {
switch zyg {
case Heterozygous:
return "HETEROZYGOUS"
case HomozygousAlternate:
return "HOMOZYGOUS_ALTERNATE"
case HomozygousReference:
return "HOMOZYGOUS_REFERENCE"
default:
return "UNKNOWN"
}
}

// TODO: StringOrIntToZygosity
42 changes: 0 additions & 42 deletions src/api/models/dtos.go

This file was deleted.

65 changes: 65 additions & 0 deletions src/api/models/dtos/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package dtos

import (
"api/models/constants"
"api/models/indexes"
)

// ---- Variants
type VariantReponse struct {
Status int `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
type VariantGetReponse struct {
VariantReponse
Results []VariantGetResult `json:"results"`
}
type VariantCountReponse struct {
VariantReponse
Results []VariantCountResult `json:"results"`
}

type VariantResult struct {
Query string `json:"query,omitempty"`
AssemblyId constants.AssemblyId `json:"assembly_id"`
Chromosome string `json:"chromosome"`
Start int `json:"start"`
End int `json:"end"`
}

type VariantGetResult struct {
VariantResult
Calls []VariantCall `json:"calls"`
}
type VariantCountResult struct {
VariantResult
Count int `json:"count"`
}

type VariantCall struct {
Chrom string `json:"chrom,omitempty"`
Pos int `json:"pos,omitempty"`
Id string `json:"id,omitempty"`
Ref []string `json:"ref,omitempty"`
Alt []string `json:"alt,omitempty"`
Format []string `json:"format,omitempty"`
Qual int `json:"qual,omitempty"`
Filter string `json:"filter,omitempty"`

Info []indexes.Info `json:"info,omitempty"` // TODO; refactor?

SampleId string `json:"sample_id"`
GenotypeType string `json:"genotype_type"`
// TODO: GenotypeProbability, PhredScaleLikelyhood ?

AssemblyId constants.AssemblyId `json:"assemblyId,omitempty"`
}

// -- Genes
type GenesResponseDTO struct {
Status int `json:"status"`
Message string `json:"message"`
Term string `json:"term"`
Count int `json:"count"`
Results []indexes.Gene `json:"results"` // []Gene
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package models
package indexes

import (
c "api/models/constants"
)

var VcfHeaders = []string{"chrom", "pos", "id", "ref", "alt", "qual", "filter", "info", "format"}

type Variant struct {
Chrom string `json:"chrom"`
Pos int `json:"pos"`
Expand Down
6 changes: 3 additions & 3 deletions src/api/models/ingest/structs/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package structs

import (
"api/models"
"api/models/indexes"
"sync"
)

type IngestionQueueStructure struct {
Variant *models.Variant
Variant *indexes.Variant
WaitGroup *sync.WaitGroup
}

type GeneIngestionQueueStructure struct {
Gene *models.Gene
Gene *indexes.Gene
WaitGroup *sync.WaitGroup
}
File renamed without changes.
12 changes: 7 additions & 5 deletions src/api/mvc/genes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package mvc

import (
"api/contexts"
"api/models"
"api/models/constants"
assemblyId "api/models/constants/assembly-id"
"api/models/constants/chromosome"
"api/models/dtos"
"api/models/ingest"
"api/models/ingest/structs"
esRepo "api/repositories/elasticsearch"
Expand All @@ -22,6 +22,8 @@ import (
"sync"
"time"

"api/models/indexes"

"github.com/labstack/echo"
"github.com/mitchellh/mapstructure"
)
Expand Down Expand Up @@ -268,7 +270,7 @@ func GenesIngest(c echo.Context) error {
return
}

discoveredGene := &models.Gene{
discoveredGene := &indexes.Gene{
Name: geneName,
Chrom: chromosomeClean,
Start: start,
Expand Down Expand Up @@ -370,13 +372,13 @@ func GenesGetByNomenclatureWildcard(c echo.Context) error {
mapstructure.Decode(docsHits, &allDocHits)

// grab _source for each hit
var allSources []models.Gene
var allSources []indexes.Gene

for _, r := range allDocHits {
source := r["_source"].(map[string]interface{})

// cast map[string]interface{} to struct
var resultingVariant models.Gene
var resultingVariant indexes.Gene
mapstructure.Decode(source, &resultingVariant)

// accumulate structs
Expand All @@ -385,7 +387,7 @@ func GenesGetByNomenclatureWildcard(c echo.Context) error {

fmt.Printf("Found %d docs!\n", len(allSources))

geneResponseDTO := models.GenesResponseDTO{
geneResponseDTO := dtos.GenesResponseDTO{
Term: term,
Count: len(allSources),
Results: allSources,
Expand Down
Loading

0 comments on commit 46ace61

Please sign in to comment.