:SELECT 
  srcfeature.*,
  feature.*,
  ftype.*,
  featureloc.*
:FROM
  feature 
   INNER JOIN 
  cvterm AS ftype ON (feature.type_id = ftype.cvterm_id)
   INNER JOIN 
  featureloc USING (feature_id)
   LEFT OUTER JOIN 
  featureprop USING (feature_id)
   LEFT OUTER JOIN 
  cvterm AS proptype ON (featureprop.type_id = proptype.cvterm_id)
   INNER JOIN 
  feature AS srcfeature ON (featureloc.srcfeature_id = srcfeature.feature_id)

:WHERE 
  [ srcfeature.name => &src& ]
  [ srcfeature.feature_id => &srcfeature_id& ]
  [ featureloc.fmin >= &fmin& ]
  [ featureloc.fmax <= &fmax& ]

:USE NESTING (set(srcfeature(feature(featureloc))))

// -------------------------------------------
schema: chado

desc: ROI (region of interest) query for chado
see_also: esncore-contigdna.stg

example_input: fmin => 20000
example_input: fmax => 80000
example_input: src => SELECT DISTINCT srcfeature.name FROM feature AS srcfeature INNER JOIN featureloc ON (srcfeature_id=srcfeature.feature_id) LIMIT 10
