         (let [c (compare bi ai)]
           (if (= c 0) (compare a b) c))))) 
 
-
+;*** Interpretation related transformations ***
 (defn interp-id
    "Return the id portion of the @id url by taking the last part 
     of the url for VariantInterpretation. If id is null return error message"

  [t i r]
  (let [v (ld1-> t i "variant" "relatedContextualAllele" (prop= t true "preferred"))]
  (if (nil? v ) (log/error (str "Exception in get-variant: relatedContextualAllele not found")))
    {:variantIdentifier (variant-identifier v),
     :altDesignations (variant-alt-designations v),
     :refseq (variant-refseq t v),
     :start (variant-start t v),
     :stop  (variant-stop t v),
     :ref (variant-ref t v),
     :alt (variant-alt v)}))
 
 ; *** Condition related transformations 
 (defn condition-name
  "Returns clinvar condition name based on available content. 
  May log warnings if available content does not conform to
  clinvar specifcations."
  [t c]
  (if (not (nil? c)) 
  (let [name (get c "name")]
    (csv-colval (if (nil? name) "" name) "ERROR-condition-name"))
  (log/error (str "ERROR-condition-name: condition name not found"))))

(defn condition-idtype
  ;TODO modify to deal with phenotypes and multi-values for satisfying clinvar specs.
  [t c]
  (if (not (nil? c)) 
  (let [disease-coding (ld-> t c "disease" "coding")]
    (let [disease-code (get disease-coding "code")]
      (csv-colval (if (nil? disease-code) "" (get (re-find #"(.*)\_(.*)" disease-code) 1)) "ERROR-condition-idtype")))
  (log/error (str "ERROR-condition-idtype: condition idt type not found"))))

(defn condition-idvals
   ;TODO modify to deal with phenotypes and multi-values for satisfying clinvar specs.
  [t c]
  (if (not (nil? c)) 
  (let [disease-coding (ld-> t c "disease" "coding")]
    (let [disease-code (get disease-coding "code")]
      (csv-colval (if (nil? disease-code) "" (get (re-find #"(.*)\_(.*)" disease-code) 2)) "ERROR-condition-idvals")))
  (log/error (str "Exception in function condition-idvals: condition id not found"))))

(defn condition-moi
  [t c]
  (if (not (nil? c)) (csv-colval (if (nil? (ld-> t c "modeOfInheritance" "display")) "" (ld-> t c "modeOfInheritance" "display")) "ERROR-condition-moi")
  (log/error (str "Exception in function condition-moi: condition moi not found"))))

(defn get-condition
  "Processes the condition element to derive the ClinVar sanctioned fields: 

    (let [crits (ld-> t e "information" "criterion")]
      (map #(get % "id") crits))) 
  
  (defn evidence-summary    "Returns a standard formatted summarization of the rules that were met."    [t e]    (str "The following criteria were met: " (csv-colval (clojure.string/join ", " (criteria-assessments t e)) "ERROR-evidence-summary")))
  
  (defn re-extract
    "Returns a map of matching regex group captures for any vector, list, map which can be flattened."
