     (let [i (json/parse-stream ir)
           cx (json/parse-stream cxr)
           opts (JsonLdOptions.)]
-      (-> (JsonLdProcessor/flatten i cx opts) JsonUtils/toPrettyString println))))
+      (-> (JsonLdProcessor/flatten i cx opts) convert-jsonld))))
 
-(defn frame-interpretation
+(defn construct-variant
+  "Construct and return one row of variant table, with VariantInterpretation as root"
+  [t i]
+  (ld-> t i "cg:A122" "cg:relatedContextualAllele"))
+
+(defn construct-variant-table
+  "Construct and return variant table"
   []
-  (with-open [ir (io/input-stream test-interpretation)
-              fr (io/input-stream frame)]
-    (let [i (JsonUtils/fromInputStream ir)
-          f (JsonUtils/fromInputStream fr)
-          opts (JsonLdOptions.)]
-      ;;(.setEmbed opts true)
-      (.setExplicit opts true)
-      (-> (JsonLdProcessor/frame i f opts) JsonUtils/toPrettyString println))))
+  (let [t (construct-symbol-table (flatten-interpretation))
+        interps (vals (filter #(= "cg:VariantInterpretation" (-> % val (get "@type"))) t))
+        rows (map #(construct-variant t %) interps)]
+    rows))
 
 (defn -main
   "I don't do a whole lot ... yet."

(def test-interpretation "data/test_interp_1.dmwg.json")
(def interpretation-cx "data/short-context.jsonld")
(def frame "data/frame.jsonld")
(defn flatten-allele
  []
  (let [allele (json/parse-stream (io/reader test-allele))
        context (json/parse-stream (io/reader allele-cx))
        opts (JsonLdOptions.)]
    (-> (JsonLdProcessor/flatten allele context opts) JsonUtils/toPrettyString println)))

(defn flatten-interpretation
  []

(ns clinvar-submitter.core
  (:require [cheshire.core :as json]
            [clojure.java.io :as io]
            [clojure.pprint :refer [pprint]]
            [clojure.walk :as walk])
  (:import [com.github.jsonldjava.core JsonLdProcessor JsonLdOptions]
           [com.github.jsonldjava.utils JsonUtils]
           [java.util Map List])
  (:gen-class))

(def test-allele "data/CA090898.jsonld")
