2016-03-12 02:09:38 +00:00
|
|
|
module Main (..) where
|
|
|
|
|
|
|
|
import Task
|
|
|
|
import Console
|
|
|
|
import ElmTest exposing (..)
|
|
|
|
import Hamming exposing (distance)
|
|
|
|
|
|
|
|
|
|
|
|
tests : Test
|
|
|
|
tests =
|
|
|
|
suite
|
|
|
|
"Hamming"
|
|
|
|
[ test
|
|
|
|
"identical strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 0) (distance "A" "A"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"long identical strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 0) (distance "GGACTGA" "GGACTGA"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"complete distance in single nucleotide strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 1) (distance "A" "G"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"complete distance in small strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 2) (distance "AG" "CT"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"small distance in small strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 1) (distance "AT" "CT"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"small distance"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 1) (distance "GGACG" "GGTCG"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"small distance in long strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 2) (distance "ACCAGGG" "ACTATGG"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"non-unique character in first strand"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 1) (distance "AGA" "AGG"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"non-unique character in second strand"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 1) (distance "AGG" "AGA"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"large distance"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 4) (distance "GATACA" "GCATAA"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"large distance in off-by-one strand"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 9) (distance "GGACGGATTCTG" "AGGACGGATTCT"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"empty strands"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual (Just 0) (distance "" ""))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"disallow first strand longer"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual Nothing (distance "AATG" "AAA"))
|
2016-03-12 02:09:38 +00:00
|
|
|
, test
|
|
|
|
"disallow second strand longer"
|
2016-04-25 10:19:43 +00:00
|
|
|
(assertEqual Nothing (distance "ATA" "AGTG"))
|
2016-03-12 02:09:38 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
port runner : Signal (Task.Task x ())
|
|
|
|
port runner =
|
|
|
|
Console.run (consoleRunner tests)
|