Skip to content

Commit 66a3f35

Browse files
committed
fixed --samplePopName option bug, and bumped sequence-format dependency
1 parent dc44d60 commit 66a3f35

5 files changed

Lines changed: 41 additions & 28 deletions

File tree

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ V 1.4.0.4:
2222
V 1.5.0: Added support for Plink output
2323

2424
V 1.5.1: Added automatic building
25+
26+
V 1.5.2: Fixed a bug with --samplePopName having to be entered after -p or -e. Fixed a bug in the sequence-formats dependency.

sequenceTools.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sequenceTools
2-
version: 1.5.1
2+
version: 1.5.2
33
synopsis: A package with tools for processing DNA sequencing data
44
description: The tools in this package process sequencing Data, in particular from ancient DNA sequencing libraries. Key tool in this package is pileupCaller, a tool to randomly sample genotypes from sequencing data.
55
license: GPL-3

src-executables/pileupCaller.hs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@ import System.Random (mkStdGen, setStdGen)
2727
import Text.Printf (printf)
2828
import qualified Text.PrettyPrint.ANSI.Leijen as PP
2929

30-
data OutFormat = EigenstratFormat String String | PlinkFormat String String | FreqSumFormat deriving (Show)
30+
data OutFormat = EigenstratFormat FilePath | PlinkFormat FilePath | FreqSumFormat deriving (Show)
3131

32-
data ProgOpt = ProgOpt CallingMode Bool (Maybe Int) Int TransitionsMode FilePath OutFormat (Either [String] FilePath)
33-
--optCallingMode :: CallingMode,
34-
--optKeepInCongruentReads :: Bool,
35-
--optSeed :: Maybe Int,
36-
--optMinDepth :: Int,
37-
--optTransitionsMode :: TransitionsMode,
38-
--optSnpFile :: FilePath,
39-
--optOutFormat :: OutFormat,
40-
--optSampleNames :: Either [String] FilePath
32+
data ProgOpt = ProgOpt {
33+
optCallingMode :: CallingMode,
34+
optKeepInCongruentReads :: Bool,
35+
optSeed :: Maybe Int,
36+
optMinDepth :: Int,
37+
optTransitionsMode :: TransitionsMode,
38+
optSnpFile :: FilePath,
39+
optOutFormat :: OutFormat,
40+
optSampleNames :: Either [String] FilePath,
41+
optPopName :: String
42+
}
4143

4244
data ReadStats = ReadStats {
4345
rsTotalSites :: IORef Int,
@@ -55,11 +57,12 @@ data Env = Env {
5557
envOutFormat :: OutFormat,
5658
envSnpFile :: FilePath,
5759
envSampleNames :: [String],
60+
envPopName :: String,
5861
envStats :: ReadStats
5962
}
6063

6164
instance Show Env where
62-
show (Env m r d t o sf sn _) = show (m, r, d, t, o, sf, sn)
65+
show (Env m r d t o sf sn pn _) = show (m, r, d, t, o, sf, sn, pn)
6366

6467
type App = ReaderT Env (SafeT IO)
6568

@@ -74,8 +77,15 @@ parserInfo = OP.info (pure (.) <*> versionInfoOpt <*> OP.helper <*> argParser)
7477
(OP.progDescDoc (Just programHelpDoc))
7578

7679
argParser :: OP.Parser ProgOpt
77-
argParser = ProgOpt <$> parseCallingMode <*> parseKeepIncongruentReads <*> parseSeed <*> parseMinDepth <*>
78-
parseTransitionsMode <*> parseSnpFile <*> parseFormat <*> parseSampleNames
80+
argParser = ProgOpt <$> parseCallingMode
81+
<*> parseKeepIncongruentReads
82+
<*> parseSeed
83+
<*> parseMinDepth
84+
<*> parseTransitionsMode
85+
<*> parseSnpFile
86+
<*> parseFormat
87+
<*> parseSampleNames
88+
<*> parsePopName
7989
where
8090
parseCallingMode = parseRandomCalling <|> parseMajorityCalling <|> parseRandomDiploidCalling
8191
parseRandomCalling = OP.flag' RandomCalling (OP.long "randomHaploid" <>
@@ -140,7 +150,7 @@ argParser = ProgOpt <$> parseCallingMode <*> parseKeepIncongruentReads <*> parse
140150
\X is converted to 23, Y to 24 and MT to 90. This is the most widely used encoding in Eigenstrat \
141151
\databases for human data, so using a SNP file with that encoding will automatically be correctly aligned \
142152
\to pileup data with actual chromosome names X, Y and MT (or chrX, chrY and chrMT, respectively).")
143-
parseFormat = (EigenstratFormat <$> parseEigenstratPrefix <*> parseSamplePopName) <|> (PlinkFormat <$> parsePlinkPrefix <*> parseSamplePopName) <|> pure FreqSumFormat
153+
parseFormat = (EigenstratFormat <$> parseEigenstratPrefix) <|> (PlinkFormat <$> parsePlinkPrefix) <|> pure FreqSumFormat
144154
parseEigenstratPrefix = OP.strOption (OP.long "eigenstratOut" <> OP.short 'e' <>
145155
OP.metavar "<FILE_PREFIX>" <>
146156
OP.help "Set Eigenstrat as output format. Specify the filenames for the EigenStrat \
@@ -162,7 +172,7 @@ argParser = ProgOpt <$> parseCallingMode <*> parseKeepIncongruentReads <*> parse
162172
parseSampleNameFile = OP.option (Right <$> OP.str) (OP.long "sampleNameFile" <> OP.metavar "<FILE>" <>
163173
OP.help "give the names of the samples in a file with one name per \
164174
\line")
165-
parseSamplePopName = OP.strOption (OP.long "samplePopName" <> OP.value "Unknown" <> OP.showDefault <>
175+
parsePopName = OP.strOption (OP.long "samplePopName" <> OP.value "Unknown" <> OP.showDefault <>
166176
OP.metavar "POP" <>
167177
OP.help "specify the population name of the samples, which is included\
168178
\ in the output *.ind.txt file in Eigenstrat output. This will be ignored if the output \
@@ -191,7 +201,7 @@ programHelpDoc =
191201
initialiseEnvironment :: ProgOpt -> IO Env
192202
initialiseEnvironment args = do
193203
let (ProgOpt callingMode keepInCongruentReads seed minDepth
194-
transitionsMode snpFile outFormat sampleNames) = args
204+
transitionsMode snpFile outFormat sampleNames popName) = args
195205
case seed of
196206
Nothing -> return ()
197207
Just seed_ -> liftIO . setStdGen $ mkStdGen seed_
@@ -201,7 +211,7 @@ initialiseEnvironment args = do
201211
let n = length sampleNamesList
202212
readStats <- ReadStats <$> newIORef 0 <*> makeVec n <*> makeVec n <*> makeVec n <*> makeVec n
203213
return $ Env callingMode keepInCongruentReads minDepth transitionsMode
204-
outFormat snpFile sampleNamesList readStats
214+
outFormat snpFile sampleNamesList popName readStats
205215
where
206216
makeVec n = do
207217
v <- V.new n
@@ -214,10 +224,11 @@ runMain = do
214224
snpFile <- asks envSnpFile
215225
freqSumProducer <- pileupToFreqSum snpFile pileupProducer
216226
outFormat <- asks envOutFormat
227+
popName <- asks envPopName
217228
case outFormat of
218229
FreqSumFormat -> outputFreqSum freqSumProducer
219-
EigenstratFormat outPrefix popName -> outputEigenStratOrPlink outPrefix popName False freqSumProducer
220-
PlinkFormat outPrefix popName -> outputEigenStratOrPlink outPrefix popName True freqSumProducer
230+
EigenstratFormat outPrefix -> outputEigenStratOrPlink outPrefix popName False freqSumProducer
231+
PlinkFormat outPrefix -> outputEigenStratOrPlink outPrefix popName True freqSumProducer
221232
outputStats
222233

223234
pileupToFreqSum :: FilePath -> Producer PileupRow (SafeT IO) () ->

src/SequenceTools/PileupCaller.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ filterTransitions transversionsMode =
105105
((ref == 'T') && (alt == 'C'))
106106

107107
cleanSSdamageAllSamples :: Char -> Char -> [String] -> [[Strand]] -> [String]
108-
cleanSSdamageAllSamples ref alt basesPerSample strandPerSample =
109-
if (ref, alt) == ('C', 'T') || (ref, alt) == ('T', 'C')
110-
then [removeForwardBases bases strands | (bases, strands) <- zip basesPerSample strandPerSample]
111-
else
112-
if (ref, alt) == ('G', 'A') || (ref, alt) == ('A', 'G')
113-
then [removeReverseBases bases strands | (bases, strands) <- zip basesPerSample strandPerSample]
114-
else basesPerSample
108+
cleanSSdamageAllSamples ref alt basesPerSample strandPerSample
109+
| (ref, alt) == ('C', 'T') || (ref, alt) == ('T', 'C') =
110+
[removeForwardBases bases strands | (bases, strands) <- zip basesPerSample strandPerSample]
111+
| (ref, alt) == ('G', 'A') || (ref, alt) == ('A', 'G') =
112+
[removeReverseBases bases strands | (bases, strands) <- zip basesPerSample strandPerSample]
113+
| otherwise =
114+
basesPerSample
115115
where
116116
removeForwardBases = removeReads ForwardStrand
117117
removeReverseBases = removeReads ReverseStrand

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ resolver: lts-17.0
22
packages:
33
- '.'
44
extra-deps:
5-
- sequence-formats-1.6.1
5+
- sequence-formats-1.6.3

0 commit comments

Comments
 (0)