Skip to content

Instantly share code, notes, and snippets.

@cybersiddhu
Created June 28, 2019 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybersiddhu/60b1f52ae714a630babc4e6e24284e95 to your computer and use it in GitHub Desktop.
Save cybersiddhu/60b1f52ae714a630babc4e6e24284e95 to your computer and use it in GitHub Desktop.
phenotype resolver
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