Skip to content

Commit

Permalink
proposal to fix the two issues in parseInGenoSep
Browse files Browse the repository at this point in the history
  • Loading branch information
nevrome committed Nov 21, 2024
1 parent 9cac8e8 commit eded226
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Poseidon/CLI/OptparseApplicativeParsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import Data.List.Split (splitOn)
import Data.Version (Version)
import qualified Options.Applicative as OP
import SequenceFormats.Plink (PlinkPopNameMode (PlinkPopNameAsBoth, PlinkPopNameAsFamily, PlinkPopNameAsPhenotype))
import System.FilePath (dropExtensions, splitExtension,
import System.FilePath (splitExtension,
splitExtensions, takeExtension,
takeExtensions, (<.>))
(<.>))
import qualified Text.Parsec as P
import Text.Read (readMaybe)

Expand Down Expand Up @@ -506,7 +506,7 @@ parseInGenoSep = parseEigenstrat <|> parsePlink <|> parseVCF
pure Nothing <*>
parseFileWithEndings "Eigenstrat individual file" "indFile" [".ind"] <*>
pure Nothing
parsePlink = GenotypeEigenstrat <$>
parsePlink = GenotypePlink <$>
parseFileWithEndings "Plink genotype matrix, optionally gzipped" "bedFile" [".bed", ".bed.gz"] <*>
pure Nothing <*>
parseFileWithEndings "Plink snp positions file, optionally gzipped" "bimFile" [".bim", ".bim.gz"] <*>
Expand All @@ -523,7 +523,9 @@ parseFileWithEndings help long endings = OP.option (OP.maybeReader fileEndingRea
OP.metavar "FILE")
where
fileEndingReader :: String -> Maybe FilePath
fileEndingReader optString = if takeExtensions optString `elem` endings then Just (dropExtensions optString) else Nothing
fileEndingReader p =
let (_, extension) = splitExtensionsOptGz p
in if extension `elem` endings then Just p else Nothing

parseGenotypeSNPSet :: OP.Parser SNPSetSpec
parseGenotypeSNPSet = OP.option (OP.eitherReader readSnpSet) (
Expand Down

0 comments on commit eded226

Please sign in to comment.