Created
June 28, 2019 18:24
-
-
Save cybersiddhu/60b1f52ae714a630babc4e6e24284e95 to your computer and use it in GitHub Desktop.
phenotype resolver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/dictyBase/go-genproto/dictybaseapis/annotation" | |
) | |
func (r *StrainResolver) Phenotypes(ctx context.Context, obj *models.Strain) ([]*models.Phenotype, error) { | |
p := []*models.Phenotype{} | |
strainId := obj.Data.Id | |
gc, err := r.AnnotationClient.ListAnnotationGroups( | |
context.Background(), | |
&annotation.ListGroupParameters{ | |
Filter: fmt.Sprintf( | |
"entry_id==%s;ontology==%s", | |
strainId, | |
phenoOntology, | |
), | |
Limit: 30, | |
}) | |
if err != nil { | |
errorutils.AddGQLError(ctx, err) | |
r.Logger.Error(err) | |
return p, err | |
} | |
for _, item := range gc.Data { | |
m := &models.Phenotype{} | |
for _, g := range item.Group.Data { | |
switch g.Attributes.Ontology { | |
case phenoOntology: | |
m.Phenotype = g.Attributes.Tag | |
case envOntology: | |
m.Environment = g.Attributes.Tag | |
case assayOntology: | |
m.Assay = g.Attributes.Assay | |
case literatureTag: | |
pub, err := utils.FetchPublication(ctx, g.Attributes.Value) | |
if err != nil { | |
errorutils.AddGQLError(ctx, err) | |
r.Logger.Error(err) | |
} | |
m.Pub = pub | |
case noteTag: | |
m.Note = g.Attributes.Value | |
} | |
} | |
p = append(p, m) | |
} | |
return p, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment