-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.lisp
More file actions
28 lines (22 loc) · 871 Bytes
/
Copy pathio.lisp
File metadata and controls
28 lines (22 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;; Various helper functions to process biological data files
;;
;; FASTA files
(defun fasta (pathname)
(with-open-file (s pathname)
(loop for line = (read-line s nil)
while line
do (if (char= #\> (char line 0))
(format t "~&~A: " (subseq line 1)) ; FIXME replace with collect
(princ line))
finally (fresh-line))))
;; (alexandria:read-file-into-string "file.txt")
;; (split-sequence:split-sequence #\Newline *)
;; tabular data
;; See https://stackoverflow.com/q/30591000 for CSV files
(defun collect-table (stream numcols)
(cons (loop repeat numcols collect (read stream))
(loop while (peek-char t stream nil nil)
collect (loop repeat numcols collect (read stream)))))
(defun read-table (file numcols)
(with-open-file (stream file)
(collect-table stream numcols)))