Skip to content

Commit

Permalink
fix: remove all mentions of constants.AssemblyId
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Dec 11, 2023
1 parent 8c3c6bc commit fa12ae3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 42 deletions.
8 changes: 2 additions & 6 deletions src/api/models/constants/assembly-id/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package assemblyId

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

const (
GRCh38 constants.AssemblyId = "GRCh38"
GRCh37 constants.AssemblyId = "GRCh37"
GRCh38 string = "GRCh38"
GRCh37 string = "GRCh37"
)
17 changes: 8 additions & 9 deletions src/api/models/dtos/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dtos

import (
"gohan/api/models/constants"
"gohan/api/models/indexes"
"time"
)
Expand All @@ -21,11 +20,11 @@ type VariantCountReponse struct {
}

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"`
Query string `json:"query,omitempty"`
AssemblyId string `json:"assembly_id"`
Chromosome string `json:"chromosome"`
Start int `json:"start"`
End int `json:"end"`
}

type VariantGetResult struct {
Expand Down Expand Up @@ -54,9 +53,9 @@ type VariantCall struct {
Alleles []string `json:"alleles,omitempty"`
// TODO: GenotypeProbability, PhredScaleLikelyhood ?

AssemblyId constants.AssemblyId `json:"assemblyId,omitempty"`
Dataset string `json:"dataset,omitempty"`
DocumentId string `json:"documentId,omitempty"`
AssemblyId string `json:"assemblyId,omitempty"`
Dataset string `json:"dataset,omitempty"`
DocumentId string `json:"documentId,omitempty"`
}

// --- Dataset
Expand Down
18 changes: 9 additions & 9 deletions src/api/models/indexes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type Variant struct {

Sample Sample `json:"sample"`

FileId string `json:"fileId"`
Dataset string `json:"dataset"`
AssemblyId c.AssemblyId `json:"assemblyId"`
CreatedTime time.Time `json:"createdTime"`
FileId string `json:"fileId"`
Dataset string `json:"dataset"`
AssemblyId string `json:"assemblyId"`
CreatedTime time.Time `json:"createdTime"`
}

type Info struct {
Expand Down Expand Up @@ -51,9 +51,9 @@ type Genotype struct {
}

type Gene struct {
Name string `json:"name"`
Chrom string `json:"chrom"`
Start int `json:"start"`
End int `json:"end"`
AssemblyId c.AssemblyId `json:"assemblyId"`
Name string `json:"name"`
Chrom string `json:"chrom"`
Start int `json:"start"`
End int `json:"end"`
AssemblyId string `json:"assemblyId"`
}
23 changes: 11 additions & 12 deletions src/api/mvc/genes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/tls"
"fmt"
"gohan/api/contexts"
"gohan/api/models/constants"
assemblyId "gohan/api/models/constants/assembly-id"
"gohan/api/models/constants/chromosome"
"gohan/api/models/dtos"
Expand Down Expand Up @@ -51,15 +50,15 @@ func GenesIngest(c echo.Context) error {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}

assemblyIdMap := map[constants.AssemblyId]string{
assemblyIdMap := map[string]string{
assemblyId.GRCh38: "gencode.v38.annotation.gtf",
assemblyId.GRCh37: "gencode.v19.annotation.gtf",
// SKIP
// assemblyId.NCBI36: "hg18",
// assemblyId.NCBI35: "hg17",
// assemblyId.NCBI34: "hg16",
}
assemblyIdGTFUrlMap := map[constants.AssemblyId]string{
assemblyIdGTFUrlMap := map[string]string{
assemblyId.GRCh38: "http://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_38/gencode.v38.annotation.gtf.gz",
assemblyId.GRCh37: "http://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_19/gencode.v19.annotation.gtf.gz",
// SKIP
Expand All @@ -79,7 +78,7 @@ func GenesIngest(c echo.Context) error {
CreatedAt: fmt.Sprintf("%v", time.Now()),
}

go func(_assId constants.AssemblyId, _fileName string, _assemblyWg *sync.WaitGroup, reqStat *ingest.GeneIngestRequest) {
go func(_asmId string, _fileName string, _assemblyWg *sync.WaitGroup, reqStat *ingest.GeneIngestRequest) {
defer _assemblyWg.Done()

var (
Expand All @@ -89,7 +88,7 @@ func GenesIngest(c echo.Context) error {
gtfFile, err := os.Open(fmt.Sprintf("%s/%s", gtfPath, _fileName))
if err != nil {
// Download the file
fullURLFile := assemblyIdGTFUrlMap[_assId]
fullURLFile := assemblyIdGTFUrlMap[_asmId]

handleHardErr := func(err error) {
msg := "Something went wrong: " + err.Error()
Expand Down Expand Up @@ -193,13 +192,13 @@ func GenesIngest(c echo.Context) error {
defer gtfFile.Close()

// clean out genes currently in elasticsearch by assembly id
fmt.Printf("Cleaning out %s gene documents from genes index (if any)\n", string(_assId))
esRepo.DeleteGenesByAssemblyId(cfg, es7Client, _assId)
fmt.Printf("Cleaning out %s gene documents from genes index (if any)\n", string(_asmId))
esRepo.DeleteGenesByAssemblyId(cfg, es7Client, _asmId)

fileScanner := bufio.NewScanner(gtfFile)
fileScanner.Split(bufio.ScanLines)

fmt.Printf("Ingesting %s\n", string(_assId))
fmt.Printf("Ingesting %s\n", string(_asmId))
reqStat.State = ingest.Running
iz.GeneIngestRequestChan <- reqStat

Expand All @@ -222,7 +221,7 @@ func GenesIngest(c echo.Context) error {
go func(rowText string, _chromHeaderKey int,
_startKey int, _endKey int,
_nameHeaderKeys []int, _geneNameHeaderKeys []int,
_assId constants.AssemblyId,
_assId string,
_gwg *sync.WaitGroup) {
// fmt.Printf("row : %s\n", row)

Expand Down Expand Up @@ -276,19 +275,19 @@ func GenesIngest(c echo.Context) error {
Chrom: chromosomeClean,
Start: start,
End: end,
AssemblyId: _assId,
AssemblyId: _asmId,
}

iz.GeneIngestionBulkIndexingQueue <- &structs.GeneIngestionQueueStructure{
Gene: discoveredGene,
WaitGroup: _gwg,
}
}(rowText, chromHeaderKey, startKey, endKey, nameHeaderKeys, geneNameHeaderKeys, _assId, &geneWg)
}(rowText, chromHeaderKey, startKey, endKey, nameHeaderKeys, geneNameHeaderKeys, _asmId, &geneWg)
}

geneWg.Wait()

fmt.Printf("%s ingestion done!\n", _assId)
fmt.Printf("%s ingestion done!\n", _asmId)
fmt.Printf("Deleting %s\n", unzippedFileName)
err = os.Remove(fmt.Sprintf("%s/%s", gtfPath, unzippedFileName))
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions src/api/repositories/elasticsearch/genes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"gohan/api/models"
"gohan/api/models/constants"
"gohan/api/utils"

"github.com/elastic/go-elasticsearch/v7"
Expand Down Expand Up @@ -216,7 +215,7 @@ func GetGeneDocumentsByTermWildcard(cfg *models.Config, es *elasticsearch.Client
return result, nil
}

func DeleteGenesByAssemblyId(cfg *models.Config, es *elasticsearch.Client, assId constants.AssemblyId) (map[string]interface{}, error) {
func DeleteGenesByAssemblyId(cfg *models.Config, es *elasticsearch.Client, asmId string) (map[string]interface{}, error) {

if cfg.Debug {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
Expand All @@ -226,7 +225,7 @@ func DeleteGenesByAssemblyId(cfg *models.Config, es *elasticsearch.Client, assId
query := map[string]interface{}{
"query": map[string]interface{}{
"match": map[string]interface{}{
"assemblyId": string(assId),
"assemblyId": asmId,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/repositories/elasticsearch/variants.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func GetDocumentsContainerVariantOrSampleIdInPositionRange(cfg *models.Config, e
reference string, alternative string, alleles []string,
size int, sortByPosition c.SortDirection,
includeInfoInResultSet bool,
genotype c.GenotypeQuery, assemblyId c.AssemblyId,
genotype c.GenotypeQuery, assemblyId string,
getSampleIdsOnly bool) (map[string]interface{}, error) {

// begin building the request body.
Expand Down Expand Up @@ -404,7 +404,7 @@ func CountDocumentsContainerVariantOrSampleIdInPositionRange(cfg *models.Config,
chromosome string, lowerBound int, upperBound int,
variantId string, sampleId string, datasetString string,
reference string, alternative string, alleles []string,
genotype c.GenotypeQuery, assemblyId c.AssemblyId) (map[string]interface{}, error) {
genotype c.GenotypeQuery, assemblyId string) (map[string]interface{}, error) {

// begin building the request body.
mustMap := []map[string]interface{}{{
Expand Down
2 changes: 1 addition & 1 deletion src/api/services/ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (i *IngestionService) UploadVcfGzToDrs(cfg *models.Config, drsBridgeDirecto

func (i *IngestionService) ProcessVcf(
gzippedFilePath string, drsFileId string, dataset uuid.UUID,
assemblyId constants.AssemblyId, filterOutReferences bool,
assemblyId string, filterOutReferences bool,
lineProcessingConcurrencyLevel int) {

// --- reopen gzipped file after having been copied to the temporary api-drs
Expand Down

0 comments on commit fa12ae3

Please sign in to comment.