-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathqpDstat_wrapper.hs
More file actions
executable file
·42 lines (38 loc) · 1.81 KB
/
qpDstat_wrapper.hs
File metadata and controls
executable file
·42 lines (38 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env stack
-- stack script --resolver lts-14.1 --package turtle
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative (optional)
import Prelude hiding (FilePath)
import Turtle
data Options = Options {
optGeno :: FilePath,
optSnp :: FilePath,
optInd :: FilePath,
optPopList :: FilePath,
optLow :: Maybe Int,
optHigh :: Maybe Int
}
main = do
args <- options "Admixtools qpDstat wrapper" parser
runManaged $ do
paramFile <- mktempfile "." "qpDstat_wrapper"
let content = [(format ("genotypename:\t"%fp) (optGeno args)),
(format ("snpname:\t"%fp) (optSnp args)),
(format ("indivname:\t"%fp) (optInd args)),
(format ("popfilename:\t"%fp) (optPopList args))]
output paramFile . select . map unsafeTextToLine $ content
let execParams = ["-p", format fp paramFile] ++
maybe [] (\low -> ["-l", format d low]) (optLow args) ++
maybe [] (\high -> ["-h", format d high]) (optHigh args)
ec <- proc "qpDstat" execParams empty
case ec of
ExitSuccess -> return ()
ExitFailure n -> err . unsafeTextToLine $
format ("qpDstat failed with exit code "%d) n
parser :: Parser Options
parser = Options <$> optPath "geno" 'g' "Genotype File"
<*> optPath "snp" 's' "Snp File"
<*> optPath "ind" 'i' "Ind File"
<*> optPath "popList" 'p' "give a list with all population triples"
<*> optional (optInt "lower" 'l' "analyse population quadruples from this line in the popList")
<*> optional (optInt "upper" 'u' "analyse population quadruples up to this line in the popList")