Sha256: 36f37ab70365d9ef15cb384904f49ac2f385f58375f41a52bf62a5274832bf1e

Contents?: true

Size: 1.29 KB

Versions: 53

Compression:

Stored size: 1.29 KB

Contents

(ql:quickload "lisp-unit")

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

#-xlisp-test (load "dna")

(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

53 entries across 53 versions & 1 rubygems

Version Path
trackler-2.0.5.16 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.15 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.14 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.13 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.12 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.11 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.10 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.9 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.8 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.7 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.6 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.5 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.4 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.3 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.2 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.1 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.5.0 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.4.0 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.3.9 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp
trackler-2.0.3.8 tracks/lisp/exercises/nucleotide-count/nucleotide-count-test.lisp