Skip to content

Commit

Permalink
chore!: remove human-only chromosome validation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Nov 4, 2024
1 parent cc5cad8 commit cad8425
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 103 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## Prerequisites
- Golang >= 1.19
- installation: https://golang.org/doc/install
- other references
- other references
- https://linguinecode.com/post/install-golang-linux-terminal
- Elasticsearch
- getting started: https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html
Expand Down Expand Up @@ -57,19 +57,19 @@
# build services
make build-gateway
make build-api
make build-gateway
make build-api
# run services
make run-gateway
make run-elasticsearch
make run-drs
make run-api
# initiate genes catlogue:
curl -k https://gohan.local/genes/ingestion/run
# monitor progress:
curl -k https://gohan.local/genes/ingestion/requests
curl -k https://gohan.local/genes/ingestion/stats
Expand All @@ -81,7 +81,7 @@
# ingest vcf.gz
curl -k https://gohan.local/variants/ingestion/run\?fileNames=<filename>\&assemblyId=GRCh37\&filterOutReferences=true\&dataset=00000000-0000-0000-0000-000000000000
# monitor progress:
curl -k https://gohan.local/variants/ingestion/requests
curl -k https://gohan.local/variants/ingestion/stats
Expand All @@ -105,7 +105,7 @@ cp ./etc/example.env .env
<br >

### **Initialization**
Run
Run
```
make init
```
Expand All @@ -115,9 +115,9 @@ make init

### **Elasticsearch & Kibana :**

Run
Run
```
make run-elasticsearch
make run-elasticsearch
```
and *(optionally)*
```
Expand All @@ -130,7 +130,7 @@ make run-kibana

### **DRS :**

Run
Run
```
make run-drs
```
Expand All @@ -140,7 +140,7 @@ make run-drs

### **Data Access Authorization with OPA (more on this to come..) :**

Run
Run
```
make build-authz
make run-authz
Expand Down Expand Up @@ -197,7 +197,7 @@ make run-api

&nbsp;This can be done multiple ways.

1. `Terminal` : From the project root, run
1. `Terminal` : From the project root, run
```
# load variables from local file
set -a
Expand All @@ -215,11 +215,11 @@ go run .

- configure the `.vscode/launch.json` to inject the above mentioned variables as recommended by https://stackoverflow.com/questions/29971572/how-do-i-add-environment-variables-to-launch-json-in-vscode

- click 'Run & Debug' > "Play"
- click 'Run & Debug' > "Play"

<b>Local Release</b>

&nbsp;To build / test from source;
&nbsp;To build / test from source;

```
make build-api-local-binaries
Expand Down Expand Up @@ -297,8 +297,8 @@ Response
Requests
> &nbsp;&nbsp;**GET** `/variants/get/by/variantId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, MT )`
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string**
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele ( "A" | "C" | "G" | "T" | "N" or some combination thereof )`
Expand All @@ -312,8 +312,8 @@ Requests
> - getSampleIdsOnly : **bool** *`(optional) - default: false `*
>
> &nbsp;&nbsp;**GET** `/variants/count/by/variantId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, MT )`
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string**
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele`
Expand All @@ -323,8 +323,8 @@ Requests
> - genotype : **string** `( "HETEROZYGOUS" | "HOMOZYGOUS_REFERENCE" | "HOMOZYGOUS_ALTERNATE" )`
> &nbsp;&nbsp;**GET** `/variants/get/by/sampleId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, MT )`
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string**
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele`
Expand All @@ -337,8 +337,8 @@ Requests
> - genotype : **string** `( "HETEROZYGOUS" | "HOMOZYGOUS_REFERENCE" | "HOMOZYGOUS_ALTERNATE" )`
>
> &nbsp;&nbsp;**GET** `/variants/count/by/sampleId`<br/>
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string** `( 1-23, X, Y, MT )`
> &nbsp;&nbsp;&nbsp;params:
> - chromosome : **string**
> - lowerBound : **number**
> - upperBound : **number**
> - reference : **string** `an allele`
Expand All @@ -352,7 +352,7 @@ Requests
Generalized Response Body Structure
>```json
>```json
>{
> "status": `number` (200 - 500),
> "message": `string` ("Success" | "Error"),
Expand All @@ -363,7 +363,7 @@ Generalized Response Body Structure
> "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
> "chromosome": `string`, // reflective of the chromosome queried for - no `chr` prefix
> "calls": [ // this field is only present when performing a GET query
> {
> "id": `string`, // variantId
Expand Down Expand Up @@ -404,7 +404,7 @@ Generalized Response Body Structure
<br />
- http://localhost:5000/variants/get/by/sampleId?ids=HG00097&size=1000&sortByPosition=asc
<br />
- http://localhost:5000/variants/count/by/variantId?chromosome=8
Expand All @@ -424,13 +424,13 @@ Generalized Response Body Structure
Request
> &nbsp;&nbsp;**GET** `/variants/ingestion/run`<br/>
> &nbsp;&nbsp;&nbsp;params:
> &nbsp;&nbsp;&nbsp;params:
> - filename : **string** `(required)`
<br/>
Response
>```json
>```json
> {
> "state": `number` ("Queuing" | "Running" | "Done" | "Error"),
> "id": `string`,
Expand All @@ -449,7 +449,7 @@ Request
<br/>
Response
>```json
>```json
> [
> {
> "state": `number` ("Queuing" | "Running" | "Done" | "Error"),
Expand All @@ -471,11 +471,11 @@ Response
## Deployments :
All in all, run
All in all, run
```
make run-elasticsearch
make run-elasticsearch
make run-drs
make build-gateway && make run-gateway
make build-gateway && make run-gateway
make build-api && make run-api

# and optionally
Expand All @@ -490,7 +490,7 @@ For other handy tools, see the Makefile. Among those already mentionned here, yo
## Tests :
Once `elasticsearch`, `drs`, the `api`, and the `gateway` are up, run
Once `elasticsearch`, `drs`, the `api`, and the `gateway` are up, run
```
make test-api-dev
```
Expand Down
9 changes: 0 additions & 9 deletions src/api/middleware/chromosomeMiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package middleware

import (
"gohan/api/contexts"
"gohan/api/models/constants/chromosome"
"net/http"

"github.com/labstack/echo"
)
Expand All @@ -18,13 +16,6 @@ func ValidateOptionalChromosomeAttribute(next echo.HandlerFunc) echo.HandlerFunc
// check for chromosome query parameter
chromQP := c.QueryParam("chromosome")

// verify:
if len(chromQP) > 0 && !chromosome.IsValidHumanChromosome(chromQP) {
// if chromosome less than 1 or greater than 23
// and not 'x', 'y' or 'm'
return echo.NewHTTPError(http.StatusBadRequest, "Please provide a valid 'chromosome' (either 1-23, X, Y, or M)")
}

if len(chromQP) == 0 {
// if no chromosome is provided, assume "wildcard" search
gc.Chromosome = "*"
Expand Down
37 changes: 0 additions & 37 deletions src/api/models/constants/chromosome/main.go

This file was deleted.

6 changes: 0 additions & 6 deletions src/api/mvc/genes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"gohan/api/contexts"
assemblyId "gohan/api/models/constants/assembly-id"
"gohan/api/models/constants/chromosome"
"gohan/api/models/dtos"
"gohan/api/models/ingest"
"gohan/api/models/ingest/structs"
Expand Down Expand Up @@ -243,11 +242,6 @@ func GenesIngest(c echo.Context) error {
//clean chromosome
chromosomeClean := strings.ReplaceAll(rowSplits[_chromHeaderKey], "chr", "")

if !chromosome.IsValidHumanChromosome(chromosomeClean) {
defer _gwg.Done()
return
}

// clean start/end
chromStartClean := strings.ReplaceAll(strings.ReplaceAll(rowSplits[_startKey], ",", ""), " ", "")
start, _ = strconv.Atoi(chromStartClean)
Expand Down
20 changes: 4 additions & 16 deletions src/api/services/ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"gohan/api/models"
"gohan/api/models/constants"
"gohan/api/models/constants/chromosome"
p "gohan/api/models/constants/ploidy"
z "gohan/api/models/constants/zygosity"
"gohan/api/models/ingest"
Expand Down Expand Up @@ -467,23 +466,12 @@ func (i *IngestionService) ProcessVcf(

// filter field type by column name
if key == "chrom" {
// Strip out all non-numeric characters
// Strip out chr prefix for some normalization with human/model-organism contigs
value = strings.ReplaceAll(value, "chr", "")

// ems if value is valid chromosome
if chromosome.IsValidHumanChromosome(value) {
tmpVariantMapMutex.Lock()
tmpVariant[key] = value
tmpVariantMapMutex.Unlock()
} else {
// skip this call
skipThisCall = true

// redundant?
tmpVariantMapMutex.Lock()
tmpVariant[key] = "err"
tmpVariantMapMutex.Unlock()
}
tmpVariantMapMutex.Lock()
tmpVariant[key] = value
tmpVariantMapMutex.Unlock()
} else if key == "pos" || key == "qual" {

// // Convert string's to int's, if possible
Expand Down
2 changes: 0 additions & 2 deletions src/api/tests/build/api/genes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"gohan/api/models"
ingest "gohan/api/models/ingest"

"gohan/api/models/constants/chromosome"
"gohan/api/models/dtos"
"gohan/api/models/indexes"

Expand Down Expand Up @@ -130,7 +129,6 @@ func TestGenesIngestion(t *testing.T) {
// ensure the gene is legit
assert.NotNil(t, gene.Name)
assert.NotNil(t, gene.AssemblyId)
assert.True(t, chromosome.IsValidHumanChromosome(gene.Chrom))
assert.Greater(t, gene.End, gene.Start)
})
})
Expand Down

0 comments on commit cad8425

Please sign in to comment.