:SELECT 
  gene.*,
  transcript.*,
  leaf.*,
  leafloc.*,
  leaftype.name AS leaf__type,
  geneprop.*,
  gptype.name AS geneprop__type
:FROM
  feature AS gene 
    INNER JOIN 
  feature_relationship AS gene2transcript ON (gene.feature_id = gene2transcript.object_id)
    INNER JOIN 
  feature AS transcript ON (transcript.feature_id = gene2transcript.subject_id)
    INNER JOIN 
  feature_relationship AS transcript2leaf ON (transcript.feature_id = transcript2leaf.object_id)
    INNER JOIN
  feature AS leaf ON (leaf.feature_id = transcript2leaf.subject_id)
    INNER JOIN
  featureloc AS leafloc ON (leafloc.feature_id = leaf.feature_id)
    INNER JOIN
  cvterm AS leaftype ON (leaf.type_id = leaftype.cvterm_id)
    LEFT OUTER JOIN
  featureprop AS geneprop ON (gene.feature_id = geneprop.feature_id)
    LEFT OUTER JOIN
  cvterm AS gptype ON (geneprop.type_id = gptype.cvterm_id)
:WHERE 
  [gene.name => &gene_name&]
  [mrna.name => &mrna_name&]
  [protein.name => &protein_name&]

:USE NESTING (set(gene(geneprop)(transcript(leaf(leafloc)))))

//
schema: chado
desc:

  fetches a gene model; may or may not be protein-coding
  transcripts are nested under genes
  exons and any proteins are nested under transcripts
  (check the element leaf/type for exon vs protein)

example_input: name => SELECT name FROM gene
