Sha256: f422e087032b5169d15cb5d808baefd8aabeda6ffd272a4b9af0bc5ceebf9c45

Contents?: true

Size: 1.29 KB

Versions: 343

Compression:

Stored size: 1.29 KB

Contents

(ql:quickload "lisp-unit")
#-xlisp-test (load "dna")

(defpackage #:nucleotide-count-test
  (:use #:common-lisp #:lisp-unit))

(in-package #:nucleotide-count-test)

(defun make-hash (kvs)
  (reduce
   #'(lambda (h kv) (setf (gethash (first kv) h) (second kv)) h)
   kvs
   :initial-value (make-hash-table)))

(define-test empty-dna-strand-has-no-adenine
  (assert-equal 0 (dna:dna-count #\A "")))

(define-test empty-dna-strand-has-no-nucleotides
  (assert-equalp (make-hash '((#\A 0) (#\T 0) (#\C 0) (#\G 0)))
      (dna:nucleotide-counts "")))

(define-test repetitive-cytosine-gets-counted
  (assert-equal 5 (dna:dna-count #\C "CCCCC")))

(define-test repetitive-sequence-has-only-guanine
  (assert-equalp (make-hash '((#\A 0) (#\T 0) (#\C 0) (#\G 8)))
      (dna:nucleotide-counts "GGGGGGGG")))

(define-test counts-only-thymine
  (assert-equal 1 (dna:dna-count #\T "GGGGGTAACCCGG")))

(define-test validates-nucleotides
  (assert-error 'dna:invalid-nucleotide (dna:dna-count #\X "GACT")))

(define-test counts-all-nucleotides
  (assert-equalp (make-hash '((#\A 20) (#\T 21) (#\G 17) (#\C 12)))
      (dna:nucleotide-counts
       "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")))

#-xlisp-test
(let ((*print-errors* t)
      (*print-failures* t))
  (run-tests :all :nucleotide-count-test))

Version data entries

343 entries across 343 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.179 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.178 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.177 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.176 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.175 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.174 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.173 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.172 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.171 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.170 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.169 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.167 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.166 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.165 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.164 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.163 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.162 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.161 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.2.1.160 tracks/common-lisp/exercises/nucleotide-count/nucleotide-count-test.lisp