This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
import Random (randomRIO) | |
type Mol = String | |
type Mixture = Map.Map Mol Integer | |
type Rxn = (Mixture, (Mixture -> Mixture)) -- (Lhs, Action) | |
type State = (Double, Integer, Mixture) -- (Time, NumSteps, Mixture) | |
getActivities :: [Rxn] -> Mixture -> [Integer] | |
getActivities rxns mixture = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-molecule [state mol] | |
(get-in state [:mixture mol] 0)) | |
(defn get-activities [state] ;; FIXME this fn takes upto 80% of the time | |
(into {} (for [{:keys [lhs rate] :as r} (:rxns state)] | |
[r (apply * rate (for [[mol freq] lhs] | |
(* (get-molecule state mol) freq)))]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns mca.gillespie | |
(:require [clojure.contrib.generic.math-functions :as math])) | |
(defn choice [m] | |
(let [r (rand (apply + (vals m)))] | |
(loop [[[k w] & kws] (seq m) | |
sum 0] | |
(if (or (nil? kws) (< r (+ sum w))) k | |
(recur kws (+ sum w)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defprotocol AKappaExpression | |
"Kappa expression" | |
(agents [e] "get all agents in this expression") | |
(complexes [e] "get all complexes in this expression") | |
(subexpr [e ids] "get a subexpression for the given agent ids") | |
(merge [e1 e2] "merge two expressions") | |
(count-automorphisms [e] "count the number of automorphisms") | |
(expression? [e] "predicate for AKappaExpression") | |
(match [e1 e2] "returns a map from agent ids in e1 to their matching agent ids in e2") | |
;; should this methods be part of AKappaAgent? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.string :as s] | |
'[incanter.stats :as stats] | |
'[clojure.contrib.generic.math-functions :as m] | |
'[clojure.contrib.combinatorics :as c]) | |
;;;; Conversion | |
(defn get-rows [s] | |
(let [[sep & ss] (.split s "\n")] | |
(take-nth 2 (partition-by #{sep} ss)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn prob-n [pred tol in n] ;; in is a csv's filename | |
(let [as (for [[_ _ p m] (map #(.split % ";") (rest (.split (slurp in) "\n"))) :when p] | |
(if (empty? m) [p] [p m])) ;; take the third and fourth (if possible) column of each row | |
conteo (for [as (c/combinations as n)] | |
(if (apply pred tol as) 1 0))] | |
(/ (reduce + conteo) (count conteo)))) | |
(defn ningun-apellido-en-comun [tol & as] | |
(let [distinct-as (distinct (apply concat as)) | |
conteo (for [a distinct-as] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/clojure/clojure/data/finger_tree.clj b/src/main/clojure/clojure/data/finger_tree.clj | |
index bc00343..557aaaf 100644 | |
--- a/src/main/clojure/clojure/data/finger_tree.clj | |
+++ b/src/main/clojure/clojure/data/finger_tree.clj | |
@@ -537,13 +537,17 @@ | |
(count [_] (:len (measured tree))) | |
IPersistentSet | |
(disjoin [this k] | |
- (let [[l x r] (split-tree tree #(>= 0 (cmpr k (:right %))))] | |
- (if (= x k) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main.lisp b/main.lisp | |
index 0dfaf15..ec5730e 100644 | |
--- a/main.lisp | |
+++ b/main.lisp | |
@@ -270,6 +270,17 @@ Returns T upon successful installation, NIL otherwise." | |
(get-pkgbuild pkg-name) | |
(quit))))))))) | |
+(defun search-packages (query) | |
+ (maybe-refresh-cache) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No message. | |
[Thrown class java.lang.IndexOutOfBoundsException] | |
Restarts: | |
0: [QUIT] Quit to the SLIME top level | |
1: [ABORT] ABORT to SLIME level 0 | |
Backtrace: | |
0: clojure.lang.PersistentVector.arrayFor(PersistentVector.java:106) | |
1: clojure.lang.PersistentVector.nth(PersistentVector.java:110) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-complexes | |
"Returns a seq with the ids of the complexes in expr (which is a | |
map from id (Integer) to Kappa agent)." | |
[expr] | |
(if (:complexes (meta expr)) (:complexes (meta expr)) | |
(let [get-complex (partial complex expr)] | |
(loop [remaining expr | |
last-complex #{} | |
groups (transient [])] | |
(let [remaining (remove (comp last-complex key) remaining)] |