Skip to content

Commit

Permalink
Merge pull request #275 from poseidon-framework/deactivatePloidyCheck
Browse files Browse the repository at this point in the history
I turned off the ploidy check
  • Loading branch information
nevrome authored Sep 26, 2023
2 parents 4c6f807 + f9e5281 commit 215e010
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- V 1.4.0.2:
- Strictly checking ploidy information across the .janno file and the genotype data in the package reading process has unforeseen consequences. Activating this will require some more changes, so we decided to uncomment this code for now.
- V 1.4.0.1:
- This patch makes the error output in case of ploidy-mismatches between the Genotype_Ploidy information in Janno and heterozygote genotypes more user-friendly.
- We fixed a bug in Fetch.hs in the output for comparing local and remote package versions
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOGRELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### V 1.4.0.1
### V 1.4.0.2

This release finally fully enables handling multiple Poseidon package versions with trident. It includes a significant overhaul of the selection language in `forge` and `fetch` with major changes in its implementation and, as a consequence, multiple (subtle, but strictly breaking) changes in its semantics.

Expand Down Expand Up @@ -42,7 +42,6 @@ The specific individual selection syntax (with `-<Pac1-1.0.1:Group1:Ind1>`) does
- The Web API and the `list` subcommand now return an extra, boolean field/column `isLatest` to point out if an entity (individual, group, package) is from the latest package version.
- `list` now also returns column headers with the `--raw` flag. If they are not desired, then they have to be filtered out manually on the command line (e.g. with `trident list ... | tail -n+2`).
- Duplicate individuals in a package collection do not anymore lead to errors. Instead, only a selection for `forge` (and externally also in `xerxes`), if resulting in multiple individuals in the selection, will lead to errors. `validate` will also fail by default, except `--ignoreDuplicates` is set.
- The genotype ploidy (`Genotype_Ploidy`) documented in .janno files is now checked when reading the package: If a sample marked as `haploid` has a heterozygote SNP, this now throws an error.

### V 1.3.0.4

Expand Down
2 changes: 1 addition & 1 deletion poseidon-hs.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: poseidon-hs
version: 1.4.0.1
version: 1.4.0.2
synopsis: A package with tools for working with Poseidon Genotype Data
description: The tools in this package read and analyse Poseidon-formatted genotype databases, a modular system for storing genotype data from thousands of individuals.
license: MIT
Expand Down
38 changes: 19 additions & 19 deletions src/Poseidon/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ import Poseidon.EntityTypes (EntitySpec, HasNameAndVersion (..),
PacNameAndVersion (..),
determineRelevantPackages,
isLatestInCollection,
makePacNameAndVersion,
renderNameWithVersion)
makePacNameAndVersion)
import Poseidon.GenotypeData (GenotypeDataSpec (..), joinEntries,
loadGenotypeData, loadIndividuals,
printSNPCopyProgress)
import Poseidon.Janno (JannoGenotypePloidy (..),
JannoLibraryBuilt (..),
import Poseidon.Janno (JannoLibraryBuilt (..),
JannoList (..), JannoRow (..),
JannoRows (..), JannoSex (..),
JannoUDG (..), createMinimalJanno,
Expand Down Expand Up @@ -406,9 +404,9 @@ validateGeno :: PoseidonPackage -> Bool -> PoseidonIO ()
validateGeno pac checkFullGeno = do
logA <- envLogAction
plinkMode <- envInputPlinkMode
let jannoRows = getJannoRowsFromPac pac
let ploidyList = map jGenotypePloidy jannoRows
let indivNames = map jPoseidonID jannoRows
--let jannoRows = getJannoRowsFromPac pac
--let ploidyList = map jGenotypePloidy jannoRows
--let indivNames = map jPoseidonID jannoRows
liftIO $ catch (
runSafeT $ do
-- we're using getJointGenotypeData here on a single package to check for SNP consistency
Expand All @@ -418,20 +416,22 @@ validateGeno pac checkFullGeno = do
if checkFullGeno
then do
currentTime <- liftIO getCurrentTime
runEffect $ eigenstratProd >-> checkPloidy logA ploidyList indivNames >-> printSNPCopyProgress logA currentTime >-> P.drain
--runEffect $ eigenstratProd >-> checkPloidy logA ploidyList indivNames >-> printSNPCopyProgress logA currentTime >-> P.drain
runEffect $ eigenstratProd >-> printSNPCopyProgress logA currentTime >-> P.drain
else
runEffect $ eigenstratProd >-> P.take 100 >-> checkPloidy logA ploidyList indivNames >-> P.drain
--runEffect $ eigenstratProd >-> P.take 100 >-> checkPloidy logA ploidyList indivNames >-> P.drain
runEffect $ eigenstratProd >-> P.take 100 >-> P.drain
) (throwIO . PoseidonGenotypeExceptionForward)
where
checkPloidy logA ploidyList indivNames = for cat $ \(_, genoLine) -> do
let illegals =
map (\(_, ind, _) -> renderNameWithVersion pac ++ ": " ++ ind) .
filter (\(ploidy, _, geno) -> ploidy == Just Haploid && geno == Het) .
zip3 ploidyList indivNames . V.toList $ genoLine
unless (null illegals) $ do
logWithEnv logA . logDebug $ "The following samples have heterozygote genotypes despite being annotated as \"haploid\" in the Janno file:"
mapM_ (logWithEnv logA . logDebug) illegals
liftIO . throwIO $ PoseidonGenotypeException "Illegal heterozygote genotypes for individuals marked as 'haploid' in the Janno file. Choose --logMode VerboseLog to output more"
-- where
-- checkPloidy logA ploidyList indivNames = for cat $ \(_, genoLine) -> do
-- let illegals =
-- map (\(_, ind, _) -> renderNameWithVersion pac ++ ": " ++ ind) .
-- filter (\(ploidy, _, geno) -> ploidy == Just Haploid && geno == Het) .
-- zip3 ploidyList indivNames . V.toList $ genoLine
-- unless (null illegals) $ do
-- logWithEnv logA . logDebug $ "The following samples have heterozygote genotypes despite being annotated as \"haploid\" in the Janno file:"
-- mapM_ (logWithEnv logA . logDebug) illegals
-- liftIO . throwIO $ PoseidonGenotypeException "Illegal heterozygote genotypes for individuals marked as 'haploid' in the Janno file. Choose --logMode VerboseLog to output more"


-- throws exception if any file is missing or checksum is incorrect
Expand Down

0 comments on commit 215e010

Please sign in to comment.