3 (defparameter *sagemaps
* '(:genie
(:human
(:short
#p
"data/genie/Hs_short.best_gene"
4 :long
#p
"data/genie/Hs_long.best_gene"))
5 :sagemap
(:human
(:short
#p
"data/sagemap/HS/NLAIII/SAGEmap_tag_ug-rel"
6 :long
#p
"data/sagemap/HS/NLAIII/SAGEmap_tag_ug-rel")))
7 "plist of available sagemaps")
10 (defun find-sagemap (library organism tag-kind
)
11 (getf (getf (getf *sagemaps
* library
) organism
) tag-kind
))
13 (defun load-sagemap (&key
(library :genie
) (organism :human
) (tag-kind :short
))
14 "Load the apropriate library"
16 (merge-pathnames (find-sagemap library organism tag-kind
) *system-path
*)
19 (defun load-sagemap-file (filespec tag-kind
)
20 "Load the sagemap into a hash table"
21 (let ((map (make-hash-table :test
'equal
:size
10000)))
22 (with-open-file (in filespec
:external-format
:latin-1
)
24 (let* ((lst (split-sequence #\Tab line
))
28 (when (eq 10 (length tag
))
29 (setf (gethash tag map
) (rest lst
))))
31 (when (> (length tag
) 10)
32 (setf (gethash tag map
) (rest lst
))))))))
36 (defun map-tag (tag map
)
37 "Map a single tag to the given map"
38 (multiple-value-bind (value founded
)
39 (gethash (string-upcase tag
) map
)
42 (list "[* TAG NOT FOUNDED IN MAP *]"))))
45 (defun map-each-file-line (file map
)
46 "map-tag first column of the given file"
47 (with-open-file (in file
)
48 (let ((fmt (concatenate 'string
"~{~a~^" '(#\Tab
) "~}")))
50 (let ((lst (split-sequence #\Tab line
)))
52 (if (equal (string-downcase (first lst
)) "tag")
60 (format t fmt
(map-tag (first lst
) map
)))))))))
64 (defun annotate-tags-file (tagsfile map
)
65 "Read a file with tags in the first column, and
66 save the annotation to another file with same name, but with
68 (when (eq (type-of map
) 'cons
)
69 (setf map
(apply #'load-sagemap map
)))
70 (redirect (make-pathname :defaults tagsfile
:type
"csv")
71 (map-each-file-line tagsfile map
))