Skip to content

Commit

Permalink
Updated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Laing committed Dec 16, 2016
1 parent 155a5b8 commit 3bee3a9
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 185 deletions.
16 changes: 10 additions & 6 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Data.List
import Data.Maybe
import Data.String
import Prelude (error)
import System.Console.CmdArgs
import System.Console.CmdArgs.Implicit
import System.IO
import Table
import Text.Show
Expand All @@ -35,21 +35,26 @@ data UserInput = UserInput
--note, to use a tab character, one needs to enter a literal tab on the command
--line. Eg. delimiter=" "
--do this via Ctrl-V<tab>
userInput :: Mode (CmdArgs UserInput)
userInput = cmdArgsMode UserInput
feht :: UserInput
feht = UserInput
{info = def &= help "File of genome metadata information"
,one = "allbut" &= help "Name and list of meta values for group one"
,two = "allbut" &= help "Name and list of meta values for group two"
,datafile = def &= help "File of binary or snp data"
,mode = def &= help "mode of program, either 'binary', or 'snp' "
,delimiter = "\t" &= help "Delimiter used for info and data files"
,mtc = "Bonferroni" &= help "Multiple testing correction, 'bonferroni', 'none'"
}
} &=
program "feht" &=
summary "Predictive marker discovery for groups: binary data, genomic data (single nucleotide variants), and arbitrary character data." &=
details ["feht takes a table of character data, and a file of metadata, and produces markers that are predictive of groups", "", " ./feht --info=data/metadata.txt --datafile=data/data.tab --mode='snp' > output.txt"]



main :: IO ()
main = do
userArgs <- cmdArgsRun userInput
userArgs <- cmdArgs feht
userArgs <- cmdArgs feht
let onexs = words $ one userArgs
let twoxs = words $ two userArgs
let groupOneCategory = MetaCategory $ BS.pack $ head onexs
Expand Down Expand Up @@ -90,7 +95,6 @@ main = do

let geneVectorMap = getGeneVectorMap delim finalGenomeData
let cl = getComparisonList metadataTable (groupOneCategory, groupOneValues) (groupTwoCategory, groupTwoValues)
--print cl

let compList = fmap (calculateFetFromComparison geneVectorMap) cl

Expand Down
7 changes: 4 additions & 3 deletions feht.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: FET, Comparison, Table, StorableByteString
build-depends: base >= 4.7 && < 5
build-depends: base
, bytestring
, hashable
, unordered-containers
, vector
, statistics
, time
, safe
, QuickCheck
default-language: Haskell2010

executable feht
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 -static -optl-static -optl-pthread
ghc-options: -threaded -optl-pthread -optl-static -fPIC -optc-Os
build-depends: base
, bytestring
, cmdargs
Expand All @@ -46,6 +46,7 @@ test-suite feht-test
, QuickCheck
, feht
, bytestring
, ieee754
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010

Expand Down
1 change: 0 additions & 1 deletion src/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Data.List (zip, (++))
import Data.Maybe
import Data.Ord
import Data.String
import qualified Data.Time.Calendar as C
import qualified Data.Vector.Unboxed as V
import GHC.Generics (Generic)
import Prelude (Integer, error, undefined, (+))
Expand Down
3 changes: 1 addition & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-6.5
resolver: lts-7.13

# Local packages, usually specified by relative directory name
packages:
- '.'

# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps: []
Expand Down
172 changes: 0 additions & 172 deletions test/FETSpec.hs

This file was deleted.

86 changes: 85 additions & 1 deletion test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,91 @@
{-# LANGUAGE OverloadedStrings #-}

module Main where

import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import FETSpec
import FET
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.AEq
import Numeric.IEEE


main :: IO ()
main = hspec $
describe "Verify p-values of FET tests" $ do
it "matrix of 2 7 5 3 two tail" $ do
let fr = fet (FETName "two tail test")
(GroupOneA 2)
(GroupOneB 7)
(GroupTwoA 5)
(GroupTwoB 3)
TwoTail
let aeq = pvalue fr ~== (0.153434800493624::Double)
aeq `shouldBe` True
it "matrix of 2 7 5 3 one tail" $ do
let fr = fet (FETName "one tail test")
(GroupOneA 2)
(GroupOneB 7)
(GroupTwoA 5)
(GroupTwoB 3)
OneTail
let aeq = pvalue fr ~== (0.11703002879473468::Double)
aeq `shouldBe` True
it "matrix of 129 173 152 138 two tail" $ do
let fr = fet (FETName "two tail")
(GroupOneA 129)
(GroupOneB 173)
(GroupTwoA 152)
(GroupTwoB 138)
TwoTail
let aeq = pvalue fr ~== (2.1126884355092402e-2::Double)
aeq `shouldBe` True
it "matrix of 129 173 152 138 one tail" $ do
let fr = fet (FETName "one tail")
(GroupOneA 129)
(GroupOneB 173)
(GroupTwoA 152)
(GroupTwoB 138)
OneTail
let aeq = pvalue fr ~== (1.1267280239712145e-2::Double)
aeq `shouldBe` True
it "matrix of 222 211 444 555 two tail (ChiSquared)" $ do
let fr = fet (FETName "two tail Chi Squared")
(GroupOneA 222)
(GroupOneB 211)
(GroupTwoA 444)
(GroupTwoB 555)
TwoTail
let aeq = pvalue fr ~== (1.7384585693541843e-2::Double)
aeq `shouldBe` True
it "matrix of 222 211 444 555 one tail (ChiSquared)" $ do
let fr = fet (FETName "one tail ChiSquared")
(GroupOneA 222)
(GroupOneB 211)
(GroupTwoA 444)
(GroupTwoB 555)
OneTail
let aeq = pvalue fr ~== (8.692292846770922e-3::Double)
aeq `shouldBe` True
it "matrix of 99222 98211 77444 74555 two tail (ChiSquared)" $ do
let fr = fet (FETName "two tail Chi-Squared")
(GroupOneA 99222)
(GroupOneB 98211)
(GroupTwoA 77444)
(GroupTwoB 74555)
TwoTail
let aeq = pvalue fr ~== (4.7092508444146475e-5::Double)
aeq `shouldBe` True
it "matrix of 100998 100555 501 555 one tail (ChiSquared)" $ do
let fr = fet (FETName "one tail Chi-Squared")
(GroupOneA 100998)
(GroupOneB 100555)
(GroupTwoA 501)
(GroupTwoB 555)
OneTail
let aeq = pvalue fr ~== (4.193675848378964e-2::Double)
aeq `shouldBe` True



0 comments on commit 3bee3a9

Please sign in to comment.