"Testing" is our testing harness. the most exciting thing here is the function "test", which is just like the function "execute" in the Execute module, except it's wrapped around the IO monad and spits out diagnostics. If you're going to try an execute our code, you're going to want this.
===================
Testing.lhs
> module Testing where
> import Control.Monad.State
> import Maybe
> import Execute
> import System.IO
> import DNA
The strings iter1 through iter3 are the DNA sequences provided in the contest docs for testing out code.
> iter1 = "IIPIPICPIICICIIFICCIFPPIICCFPC"
> iter2 = "IIPIPICPIICICIIFICCIFCCCPPIICCFPC"
> iter3 = "IIPIPIICPIICIICCIICFCFC"
This is an all-in-one function to go from DNA to RNA, all while spitting out patterns and templates as debug messages.
> test :: DNA -> IO World
> test dna = flip execStateT (World [] dna) $ runMaybeT $
> let eval = do liftIO $ putStrLn "About to execute pattern"
> p <- liftM reverse pattern
> dna <- peekDNA 51
> liftIO $ do putStrLn $ "p: " ++ (show p)
> putStrLn $ "next dna: " ++ formatDNA dna
> putStrLn $ "About to execute template"
> t <- liftM reverse template
> dna <- peekDNA 51
> liftIO $ do putStrLn $ "t: " ++ (show t)
> putStrLn $ "next dna: " ++ formatDNA dna
> putStrLn $ "About to execute matchreplace"
> matchreplace p t
> dna <- peekDNA 51
> liftIO $ do putStrLn $ "next dna: " ++ formatDNA dna
> putStrLn $ "About to go through again!"
> eval
>
> in do liftIO $ putStrLn $ "Starting DNA: " ++ (formatDNA $ take 51 dna)
> eval
> formatDNA dna =
> if length dna > 50 then (take 50 dna) ++ "..." else dna
No comments:
Post a Comment