(defun get-reaction-mapping (path) (let ((forms (read-taxonomy.log path))) (let ((equivalence-forms (remove-if-not (lambda(el) (and (listp el) (member ':= el) (some (lambda(s) (and (stringp s) (search "reaction" s))) el))) forms ))) equivalence-forms))) (defun read-unmapped-reactions (path) (let ((table (make-hash-table :test 'equal))) (with-open-file (f path) (loop for line = (read-line f nil :eof) until (eq line :eof) for fields = (split-at-char line #\tab) do (setf (gethash (string-downcase (fifth fields)) table) fields)) table))) (defun find-hits () (let ((unmapped (read-unmapped-reactions "~/src/lsw/trunk/bug/unmapped-rxns-1.txt")) (count 0)) (loop for mapping in (get-reaction-mapping "/usr/local/src/Fact++/Models.lisp/iJR904-no-compartment/Taxonomy.log") for mapped = (remove-if-not 'stringp mapping) for names = (mapcar (lambda(s) (string-downcase (regex-replace ".*[#/]" s ""))) mapped) do (loop for name in names for hit = (gethash name unmapped) do (when (and hit (< (read-from-string (car hit)) 101) (> (read-from-string (car hit)) 49)) (format t "~a: ~a ~a~%" (read-from-string (car hit)) names (gethash name unmapped)) (incf count)) )) count)) (defun find-all-hits (unmapped-rxns-file taxonomy-file) (let ((unmapped (read-unmapped-reactions unmapped-rxns-file)) (count 0)) (loop for mapping in (get-reaction-mapping taxonomy-file) for mapped = (remove-if-not 'stringp mapping) for names = (mapcar (lambda(s) (string-downcase (regex-replace ".*[#/]" s ""))) mapped) do (loop for name in names for hit = (gethash name unmapped) do (when hit (format t "~a: ~a ~a~%" (read-from-string (car hit)) names (gethash name unmapped)) (incf count)))) count))