Skip to content

Instantly share code, notes, and snippets.

@harishtella
Created November 26, 2011 07:48
Show Gist options
  • Save harishtella/1395256 to your computer and use it in GitHub Desktop.
Save harishtella/1395256 to your computer and use it in GitHub Desktop.
;; instead of having to call this function all the time
(defn top-n-seq [sample-name n]
(let [fields ["?id" "?aa" "?v" "?j" "?name" "?nc"]
sample-name-seqs (<- fields
(tcr-seqs :>> fields)
(= ?name sample-name))]
(c/first-n sample-name-seqs n :sort ["?nc"] :reverse true)))
;; I can pre-sort tcr-seqs, grouping-by ?name, adding a ranking, and saving it to a seqfile
(def tcr-seqs-sorted (hfs-seqfile "/somewhere"))
(defbufferop add-rank
[tuples]
(map #(conj (vec %1) %2) tuples (iterate inc 1)))
(?<- tcr-seqs-sorted [?id-out ?name ?nc-out ?rank]
(tcr-sequences ?id ?aa ?v ?j ?name ?nc)
(:sort :< ?nc)
(:reverse true)
(add-rank :< ?id ?nc :> ?id-out ?nc-out ?rank))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment