-
Notifications
You must be signed in to change notification settings - Fork 3
/
GoldenTestsRunCommands.hs
1366 lines (1307 loc) · 67 KB
/
GoldenTestsRunCommands.hs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-# LANGUAGE OverloadedStrings #-}
module PoseidonGoldenTests.GoldenTestsRunCommands (
createStaticCheckSumFile, createDynamicCheckSumFile, staticCheckSumFile, dynamicCheckSumFile
) where
import Poseidon.CLI.Fetch (FetchOptions (..), runFetch)
import Poseidon.CLI.Forge (ForgeOptions (..),
ForgeOutMode (GenoOut, MinimalOut, NormalOut, PreservePymlOut),
runForge)
import Poseidon.CLI.Genoconvert (GenoconvertOptions (..),
runGenoconvert)
import Poseidon.CLI.Init (InitOptions (..), runInit)
import Poseidon.CLI.Jannocoalesce (CoalesceJannoColumnSpec (..),
JannoCoalesceOptions (..),
JannoSourceSpec (..),
runJannocoalesce)
import Poseidon.CLI.List (ListEntity (..), ListOptions (..),
RepoLocationSpec (..), runList)
import Poseidon.CLI.Rectify (ChecksumsToRectify (..),
PackageVersionUpdate (..),
RectifyOptions (..), runRectify)
import Poseidon.CLI.Serve (ServeOptions (..), runServer)
import Poseidon.CLI.Summarise (SummariseOptions (..),
runSummarise)
import Poseidon.CLI.Survey (SurveyOptions (..), runSurvey)
import Poseidon.CLI.Timetravel (TimetravelOptions (..),
runTimetravel)
import Poseidon.CLI.Validate (ValidateOptions (..),
ValidatePlan (..), runValidate)
import Poseidon.Contributor (ContributorSpec (..))
import Poseidon.EntityTypes (EntityInput (..),
PoseidonEntity (..),
readEntitiesFromString)
import Poseidon.GenotypeData (GenoDataSource (..),
GenotypeDataSpec (..),
GenotypeFileSpec (..),
SNPSetSpec (..))
import Poseidon.ServerClient (AddJannoColSpec (..),
ArchiveEndpoint (..))
import Poseidon.Utils (LogMode (..), TestMode (..),
getChecksum, testLog,
usePoseidonLogger)
import Poseidon.Version (VersionComponent (..))
import Control.Concurrent (forkIO, killThread, newEmptyMVar)
import Control.Concurrent.MVar (takeMVar)
import Control.Exception (finally)
import Control.Monad (forM_, unless, when)
import Data.Either (fromRight)
import Data.Function ((&))
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Version (makeVersion)
import GHC.IO.Handle (hClose, hDuplicate, hDuplicateTo)
import Poseidon.CLI.Chronicle (ChronOperation (..),
ChronicleOptions (..),
runChronicle)
import Poseidon.Contributor (ORCID (..))
import Poseidon.EntityTypes (PacNameAndVersion (..))
import Poseidon.Utils (ErrorLength (..))
import SequenceFormats.Plink (PlinkPopNameMode (..))
import System.Directory (copyFile, createDirectory,
createDirectoryIfMissing,
doesDirectoryExist, listDirectory,
removeDirectoryRecursive)
import System.FilePath.Posix ((</>))
import System.IO (IOMode (WriteMode), hPutStrLn,
openFile, stderr, stdout, withFile)
import System.Process (callCommand)
-- file paths --
tempTestDir :: FilePath
tempTestDir = "/tmp/poseidonHSGoldenTestData"
staticTestDir :: FilePath
staticTestDir = "test/PoseidonGoldenTests/GoldenTestData"
staticCheckSumFile :: FilePath
staticCheckSumFile = "test/PoseidonGoldenTests/GoldenTestCheckSumFile.txt"
dynamicCheckSumFile :: FilePath
dynamicCheckSumFile = "/tmp/poseidon_trident_dynamicCheckSumFile.txt"
testPacsDir :: FilePath
testPacsDir = "test/testDat/testPackages/ancient"
testPacsDirOther :: FilePath
testPacsDirOther = "test/testDat/testPackages/other_test_packages"
testEntityFiles :: FilePath
testEntityFiles = "test/testDat/testEntityFiles"
-- helper functions --
copyDirectoryRecursive :: FilePath -> FilePath -> IO ()
copyDirectoryRecursive srcDir destDir = do
createDirectoryIfMissing True destDir
entries <- listDirectory srcDir
forM_ entries $ \entry -> do
let srcPath = srcDir </> entry
destPath = destDir </> entry
isDir <- doesDirectoryExist srcPath
if isDir
then do copyDirectoryRecursive srcPath destPath
else do copyFile srcPath destPath
patchLastModified :: FilePath -> FilePath -> IO ()
patchLastModified testDir yamlFile = do
lines_ <- T.lines <$> T.readFile (testDir </> yamlFile)
let patchedLines = do
l <- lines_
if "lastModified" `T.isPrefixOf` l
then return "lastModified: 1970-01-01"
else return l
T.writeFile (testDir </> yamlFile) (T.unlines patchedLines)
runAndChecksumFiles :: FilePath -> FilePath -> IO () -> String -> [FilePath] -> IO ()
runAndChecksumFiles checkSumFilePath testDir action actionName outFiles = do
-- run action
action
-- append checksums to checksum file
mapM_ (appendChecksum checkSumFilePath testDir actionName) outFiles
where
appendChecksum :: FilePath -> FilePath -> FilePath -> String -> IO ()
appendChecksum checkSumFilePath_ testDir_ actionName_ outFile = do
checksum <- getChecksum $ testDir_ </> outFile
appendFile checkSumFilePath_ $ "\n" ++ checksum ++ " " ++ actionName_ ++ " " ++ outFile
runAndChecksumStdOut :: FilePath -> FilePath -> IO () -> String -> Integer -> IO ()
runAndChecksumStdOut checkSumFilePath testDir action actionName outFileNumber = do
-- store stdout in a specific output file
let outFileName = actionName ++ show outFileNumber
outDirInTestDir = actionName </> outFileName
outDir = testDir </> actionName
outPath = outDir </> outFileName
-- create outdir if it doesn't exist
outDirExists <- doesDirectoryExist outDir
unless outDirExists $ createDirectory outDir
-- catch stdout and write it to the outPath
writeStdOutToFile outPath action
-- append checksum to checksumfile
checksum <- getChecksum $ outPath
appendFile checkSumFilePath $ "\n" ++ checksum ++ " " ++ actionName ++ " " ++ outDirInTestDir
writeStdOutToFile :: FilePath -> IO () -> IO ()
writeStdOutToFile path action =
withFile path WriteMode $ \handle -> do
-- backup stdout handle
stdout_old <- hDuplicate stdout
-- redirect stdout to file
hDuplicateTo handle stdout
-- run action
action
-- load backup again
hDuplicateTo stdout_old stdout
-- test pipeline --
createStaticCheckSumFile :: FilePath -> IO ()
createStaticCheckSumFile d = runCLICommands True (d </> staticTestDir) (d </> staticCheckSumFile)
createDynamicCheckSumFile :: IO ()
createDynamicCheckSumFile = runCLICommands False tempTestDir dynamicCheckSumFile
runCLICommands :: Bool -> FilePath -> FilePath -> IO ()
runCLICommands interactive testDir checkFilePath = do
-- create temp dir for test output
tmpTestDirExists <- doesDirectoryExist testDir
when tmpTestDirExists $ removeDirectoryRecursive testDir
createDirectory testDir
-- create/overwrite checksum file
writeFile checkFilePath "Checksums for trident CLI output\n\
\Automatically generated with: poseidon-devtools golden\n"
-- create error sink
devNull <- openFile "/dev/null" WriteMode
stderr_old <- hDuplicate stderr
unless interactive $ hDuplicateTo devNull stderr
-- run CLI pipeline
hPutStrLn stderr "--* local tests"
hPutStrLn stderr "--- init"
testPipelineInit testDir checkFilePath
hPutStrLn stderr "--- validate"
testPipelineValidate testDir checkFilePath
hPutStrLn stderr "--- list"
testPipelineList testDir checkFilePath
hPutStrLn stderr "--- summarise"
testPipelineSummarise testDir checkFilePath
hPutStrLn stderr "--- survey"
testPipelineSurvey testDir checkFilePath
hPutStrLn stderr "--- genoconvert"
testPipelineGenoconvert testDir checkFilePath
hPutStrLn stderr "--- rectify"
testPipelineRectify testDir checkFilePath
hPutStrLn stderr "--- forge"
testPipelineForge testDir checkFilePath
hPutStrLn stderr "--- chronicle & timetravel"
testPipelineChronicleAndTimetravel testDir checkFilePath
hPutStrLn stderr "--* test server interaction"
hPutStrLn stderr "--- fetch"
testPipelineFetch testDir checkFilePath
hPutStrLn stderr "--- list --remote"
testPipelineListRemote testDir checkFilePath
hPutStrLn stderr "--- jannocoalesce"
testPipelineJannocoalesce testDir checkFilePath
-- close error sink
hClose devNull
unless interactive $ hDuplicateTo stderr_old stderr
testPipelineInit :: FilePath -> FilePath -> IO ()
testPipelineInit testDir checkFilePath = do
let initOpts1 = InitOptions {
_initGenoData = GenotypeDataSpec {
genotypeFileSpec = GenotypeEigenstrat {
_esGenoFile = testPacsDir </> "Schiffels_2016" </> "geno.txt"
, _esGenoFileChkSum = Nothing
, _esSnpFile = testPacsDir </> "Schiffels_2016" </> "snp.txt"
, _esSnpFileChkSum = Nothing
, _esIndFile = testPacsDir </> "Schiffels_2016" </> "ind.txt"
, _esIndFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
, _initPacPath = testDir </> "init" </> "Schiffels"
, _initPacName = Just "Schiffels"
, _initMinimal = False
}
let action = testLog (runInit initOpts1) >>
patchLastModified testDir ("init" </> "Schiffels" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action "init" [
"init" </> "Schiffels" </> "POSEIDON.yml"
, "init" </> "Schiffels" </> "Schiffels.janno"
, "init" </> "Schiffels" </> "geno.txt"
, "init" </> "Schiffels" </> "Schiffels.bib"
]
let initOpts2 = InitOptions {
_initGenoData = GenotypeDataSpec {
genotypeFileSpec = GenotypePlink {
_plGenoFile = testPacsDir </> "Wang_2020" </> "Wang_2020.bed"
, _plGenoFileChkSum = Nothing
, _plSnpFile = testPacsDir </> "Wang_2020" </> "Wang_2020.bim"
, _plSnpFileChkSum = Nothing
, _plIndFile = testPacsDir </> "Wang_2020" </> "Wang_2020.fam"
, _plIndFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
, _initPacPath = testDir </> "init" </> "Wang"
, _initPacName = Nothing
, _initMinimal = True
}
let action2 = testLog (runInit initOpts2) >>
patchLastModified testDir ("init" </> "Wang" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action2 "init" [
"init" </> "Wang" </> "POSEIDON.yml"
, "init" </> "Wang" </> "Wang_2020.bed"
]
let initOpts3 = InitOptions {
_initGenoData = GenotypeDataSpec {
genotypeFileSpec = GenotypeVCF {
_vcfGenoFile = testPacsDirOther </> "Schiffels_2016_vcf" </> "geno.vcf"
, _vcfGenoFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
, _initPacPath = testDir </> "init_vcf" </> "Schiffels_vcf"
, _initPacName = Just "Schiffels"
, _initMinimal = False
}
let action3 = testLog (runInit initOpts3) >>
patchLastModified testDir ("init_vcf" </> "Schiffels_vcf" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action3 "init" [
"init_vcf" </> "Schiffels_vcf" </> "POSEIDON.yml"
, "init_vcf" </> "Schiffels_vcf" </> "Schiffels.janno"
, "init_vcf" </> "Schiffels_vcf" </> "geno.vcf"
, "init_vcf" </> "Schiffels_vcf" </> "Schiffels.bib"
]
testPipelineValidate :: FilePath -> FilePath -> IO ()
testPipelineValidate testDir checkFilePath = do
let validateOpts1 = ValidateOptions {
_validatePlan = ValPlanBaseDirs {
_valPlanBaseDirs = [testPacsDir]
, _valPlanIgnoreGeno = False
, _valPlanFullGeno = False
, _valPlanIgnoreDuplicates = True
, _valPlanIgnoreChecksums = False
, _valPlanIgnorePosVersion = False
}
, _validateNoExitCode = True
, _validateOnlyLatest = False
}
run 1 validateOpts1
validateOpts1 {
_validatePlan = ValPlanBaseDirs {
_valPlanBaseDirs = [testPacsDir]
, _valPlanIgnoreGeno = True
, _valPlanFullGeno = False
, _valPlanIgnoreDuplicates = True
, _valPlanIgnoreChecksums = False
, _valPlanIgnorePosVersion = False
}
} & run 2
validateOpts1 {
_validatePlan = ValPlanBaseDirs {
_valPlanBaseDirs = [testPacsDir]
, _valPlanIgnoreGeno = False
, _valPlanFullGeno = True
, _valPlanIgnoreDuplicates = True
, _valPlanIgnoreChecksums = False
, _valPlanIgnorePosVersion = False
}
} & run 3
-- validate packages generated with init
validateOpts1 {
_validatePlan = ValPlanBaseDirs {
_valPlanBaseDirs = [testDir </> "init"]
, _valPlanIgnoreGeno = False
, _valPlanFullGeno = False
, _valPlanIgnoreDuplicates = True
, _valPlanIgnoreChecksums = False
, _valPlanIgnorePosVersion = False
}
} & run 4
-- validate individual files
validateOpts1 {
_validatePlan = ValPlanPoseidonYaml $ testPacsDir </> "Schiffels_2016" </> "POSEIDON.yml"
} & run 5
validateOpts1 {
_validatePlan = ValPlanGeno $ GenotypeDataSpec {
genotypeFileSpec = GenotypeEigenstrat {
_esGenoFile = testPacsDir </> "Schiffels_2016" </> "geno.txt"
, _esGenoFileChkSum = Nothing
, _esSnpFile = testPacsDir </> "Schiffels_2016" </> "snp.txt"
, _esSnpFileChkSum = Nothing
, _esIndFile = testPacsDir </> "Schiffels_2016" </> "ind.txt"
, _esIndFileChkSum = Nothing
}
, genotypeSnpSet = Nothing
}
} & run 6
validateOpts1 {
_validatePlan = ValPlanJanno $ testPacsDir </> "Schiffels_2016" </> "Schiffels_2016.janno"
} & run 7
validateOpts1 {
_validatePlan = ValPlanSSF $ testPacsDir </> "Schiffels_2016" </> "ena_table.ssf"
} & run 8
validateOpts1 {
_validatePlan = ValPlanBib $ testPacsDir </> "Schiffels_2016" </> "sources.bib"
} & run 9
where
run :: Integer -> ValidateOptions -> IO ()
run nr opts = runAndChecksumStdOut checkFilePath testDir (testLog $ runValidate opts) "validate" nr
testPipelineList :: FilePath -> FilePath -> IO ()
testPipelineList testDir checkFilePath = do
let listOpts1 = ListOptions {
_listRepoLocation = RepoLocal [testPacsDir </> "Schiffels_2016", testPacsDir </> "Wang_Wang_2020"]
, _listListEntity = ListPackages
, _listRawOutput = False
, _listOnlyLatest = False
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runList listOpts1) "list" 1
let listOpts2 = listOpts1 {
_listListEntity = ListGroups
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runList listOpts2) "list" 2
let listOpts3 = listOpts1 {
_listListEntity = ListIndividuals (AddJannoColList ["Country", "Nr_SNPs"])
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runList listOpts3) "list" 3
let listOpts4 = listOpts3 {
_listRawOutput = True
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runList listOpts4) "list" 4
let listOpts5 = listOpts1 {
_listOnlyLatest = True
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runList listOpts5) "list" 5
let listOpts6 = listOpts1 {
_listListEntity = ListIndividuals AddJannoColAll
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runList listOpts6) "list" 6
testPipelineSummarise :: FilePath -> FilePath -> IO ()
testPipelineSummarise testDir checkFilePath = do
let summariseOpts1 = SummariseOptions {
_summariseBaseDirs = [testPacsDir]
, _summariseRawOutput = False
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runSummarise summariseOpts1) "summarise" 1
let summariseOpts2 = SummariseOptions {
_summariseBaseDirs = [testPacsDir]
, _summariseRawOutput = True
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runSummarise summariseOpts2) "summarise" 2
testPipelineSurvey :: FilePath -> FilePath -> IO ()
testPipelineSurvey testDir checkFilePath = do
let surveyOpts1 = SurveyOptions {
_surveyBaseDirs = [testPacsDir]
, _surveyRawOutput = False
, _surveyOnlyLatest = False
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runSurvey surveyOpts1) "survey" 1
let surveyOpts2 = SurveyOptions {
_surveyBaseDirs = [testPacsDir]
, _surveyRawOutput = True
, _surveyOnlyLatest = False
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runSurvey surveyOpts2) "survey" 2
let surveyOpts3 = SurveyOptions {
_surveyBaseDirs = [testPacsDir]
, _surveyRawOutput = False
, _surveyOnlyLatest = True
}
runAndChecksumStdOut checkFilePath testDir (testLog $ runSurvey surveyOpts3) "survey" 3
testPipelineGenoconvert :: FilePath -> FilePath -> IO ()
testPipelineGenoconvert testDir checkFilePath = do
let genoconvertOpts1 = GenoconvertOptions {
_genoconvertGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016"]
, _genoConvertOutFormat = "PLINK"
, _genoMaybeOutPackagePath = Just $ testDir </> "genoconvert" </> "Schiffels"
, _genoconvertRemoveOld = False
, _genoconvertOutPlinkPopMode = PlinkPopNameAsFamily
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = False
}
runAndChecksumFiles checkFilePath testDir (testLog $ runGenoconvert genoconvertOpts1) "genoconvert" [
"genoconvert" </> "Schiffels" </> "Schiffels_2016.bed"
, "genoconvert" </> "Schiffels" </> "Schiffels_2016.bim"
, "genoconvert" </> "Schiffels" </> "Schiffels_2016.fam"
]
let genoconvertOpts2 = GenoconvertOptions {
_genoconvertGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016"]
, _genoConvertOutFormat = "PLINK"
, _genoMaybeOutPackagePath = Just $ testDir </> "genoconvert" </> "Schiffels_otherPlinkEncoding"
, _genoconvertRemoveOld = False
, _genoconvertOutPlinkPopMode = PlinkPopNameAsPhenotype
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = False
}
runAndChecksumFiles checkFilePath testDir (testLog $ runGenoconvert genoconvertOpts2) "genoconvert" [
"genoconvert" </> "Schiffels_otherPlinkEncoding" </> "Schiffels_2016.bed"
, "genoconvert" </> "Schiffels_otherPlinkEncoding" </> "Schiffels_2016.bim"
, "genoconvert" </> "Schiffels_otherPlinkEncoding" </> "Schiffels_2016.fam"
]
-- in-place conversion
let genoconvertOpts3 = GenoconvertOptions {
_genoconvertGenoSources = [PacBaseDir $ testDir </> "init" </> "Wang"]
, _genoConvertOutFormat = "EIGENSTRAT"
, _genoMaybeOutPackagePath = Nothing
, _genoconvertRemoveOld = False
, _genoconvertOutPlinkPopMode = PlinkPopNameAsFamily
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = False
}
runAndChecksumFiles checkFilePath testDir (testLog $ runGenoconvert genoconvertOpts3) "genoconvert" [
"init" </> "Wang" </> "Wang.geno"
, "init" </> "Wang" </> "Wang.snp"
, "init" </> "Wang" </> "Wang.ind"
]
let genoconvertOpts4 = GenoconvertOptions {
_genoconvertGenoSources = [
GenoDirect $
GenotypeDataSpec {
genotypeFileSpec = GenotypeEigenstrat {
_esGenoFile = testDir </> "init" </> "Schiffels" </> "geno.txt"
, _esGenoFileChkSum = Nothing
, _esSnpFile = testDir </> "init" </> "Schiffels" </> "snp.txt"
, _esSnpFileChkSum = Nothing
, _esIndFile = testDir </> "init" </> "Schiffels" </> "ind.txt"
, _esIndFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
]
, _genoConvertOutFormat = "PLINK"
, _genoMaybeOutPackagePath = Nothing
, _genoconvertRemoveOld = False
, _genoconvertOutPlinkPopMode = PlinkPopNameAsFamily
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = False
}
runAndChecksumFiles checkFilePath testDir (testLog $ runGenoconvert genoconvertOpts4) "genoconvert" [
"init" </> "Schiffels" </> "geno.bed"
, "init" </> "Schiffels" </> "geno.bim"
, "init" </> "Schiffels" </> "geno.fam"
]
let genoconvertOpts5 = GenoconvertOptions {
_genoconvertGenoSources = [
GenoDirect $
GenotypeDataSpec {
genotypeFileSpec = GenotypeVCF {
_vcfGenoFile = testDir </> "init_vcf" </> "Schiffels_vcf" </> "geno.vcf"
, _vcfGenoFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
]
, _genoConvertOutFormat = "PLINK"
, _genoMaybeOutPackagePath = Nothing
, _genoconvertRemoveOld = False
, _genoconvertOutPlinkPopMode = PlinkPopNameAsFamily
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = False
}
runAndChecksumFiles checkFilePath testDir (testLog $ runGenoconvert genoconvertOpts5) "genoconvert" [
"init_vcf" </> "Schiffels_vcf" </> "geno.bed"
, "init_vcf" </> "Schiffels_vcf" </> "geno.bim"
, "init_vcf" </> "Schiffels_vcf" </> "geno.fam"
]
-- round trip test
let genoconvertOpts6zipping = GenoconvertOptions {
_genoconvertGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016"]
, _genoConvertOutFormat = "PLINK"
, _genoMaybeOutPackagePath = Just $ testDir </> "genoconvert" </> "zip_roundtrip"
, _genoconvertRemoveOld = False
, _genoconvertOutPlinkPopMode = PlinkPopNameAsFamily
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = True
}
testLog $ runGenoconvert genoconvertOpts6zipping
let genoconvertOpts6unzipping = GenoconvertOptions {
_genoconvertGenoSources =
let gSpec = GenotypePlink (testDir </> "genoconvert" </> "zip_roundtrip" </> "Schiffels_2016.bed.gz") Nothing
(testDir </> "genoconvert" </> "zip_roundtrip" </> "Schiffels_2016.bim.gz") Nothing
(testDir </> "genoconvert" </> "zip_roundtrip" </> "Schiffels_2016.fam") Nothing
in [GenoDirect $ GenotypeDataSpec gSpec Nothing]
, _genoConvertOutFormat = "PLINK"
, _genoMaybeOutPackagePath = Nothing
, _genoconvertRemoveOld = True
, _genoconvertOutPlinkPopMode = PlinkPopNameAsFamily
, _genoconvertOnlyLatest = False
, _genoconvertOutZip = False
}
return ()
runAndChecksumFiles checkFilePath testDir (testLog $ runGenoconvert genoconvertOpts6unzipping) "genoconvert" [
"genoconvert" </> "zip_roundtrip" </> "Schiffels_2016.bed"
, "genoconvert" </> "zip_roundtrip" </> "Schiffels_2016.bim"
, "genoconvert" </> "zip_roundtrip" </> "Schiffels_2016.fam"
]
testPipelineRectify :: FilePath -> FilePath -> IO ()
testPipelineRectify testDir checkFilePath = do
let rectifyOpts1 = RectifyOptions {
_rectifyBaseDirs = [testDir </> "init" </> "Schiffels"]
, _rectifyPoseidonVersion = Nothing
, _rectifyIgnorePoseidonVersion = False
, _rectifyPackageVersionUpdate = Just (PackageVersionUpdate Major (Just "test1"))
, _rectifyChecksums = ChecksumNone
, _rectifyNewContributors = Nothing
, _rectifyOnlyLatest = False
}
let action1 = testLog (runRectify rectifyOpts1) >> patchLastModified testDir ("init" </> "Schiffels" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action1 "rectify" [
"init" </> "Schiffels" </> "POSEIDON.yml"
, "init" </> "Schiffels" </> "CHANGELOG.md"
]
let rectifyOpts2 = RectifyOptions {
_rectifyBaseDirs = [testDir </> "init" </> "Schiffels"]
, _rectifyPoseidonVersion = Just $ makeVersion [2,7,1]
, _rectifyIgnorePoseidonVersion = False
, _rectifyPackageVersionUpdate = Just (PackageVersionUpdate Minor (Just "test2"))
, _rectifyChecksums = ChecksumAll
, _rectifyNewContributors = Nothing
, _rectifyOnlyLatest = False
}
let action2 = testLog (runRectify rectifyOpts2) >> patchLastModified testDir ("init" </> "Schiffels" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action2 "rectify" [
"init" </> "Schiffels" </> "POSEIDON.yml"
, "init" </> "Schiffels" </> "CHANGELOG.md"
]
let rectifyOpts3 = RectifyOptions {
_rectifyBaseDirs = [testDir </> "init" </> "Schiffels"]
, _rectifyPoseidonVersion = Nothing
, _rectifyIgnorePoseidonVersion = False
, _rectifyPackageVersionUpdate = Just (PackageVersionUpdate Patch Nothing)
, _rectifyChecksums = ChecksumNone
, _rectifyNewContributors = Just [
ContributorSpec "Josiah Carberry" "[email protected]" (Just $ ORCID {_orcidNums = "000000021825009", _orcidChecksum = '7'})
, ContributorSpec "Herbert Testmann" "[email protected]" Nothing
]
, _rectifyOnlyLatest = False
}
let action3 = testLog (runRectify rectifyOpts3) >> patchLastModified testDir ("init" </> "Schiffels" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action3 "rectify" [
"init" </> "Schiffels" </> "POSEIDON.yml"
, "init" </> "Schiffels" </> "CHANGELOG.md"
]
testPipelineForge :: FilePath -> FilePath -> IO ()
testPipelineForge testDir checkFilePath = do
-- forge test 1
let forgeOpts1 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Wang_2020"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP2,<SAMPLE2>,<SAMPLE4>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac1"
, _forgeOutPacName = Just "ForgePac1"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action1 = testLog (runForge forgeOpts1) >> patchLastModified testDir ("forge" </> "ForgePac1" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action1 "forge" [
"forge" </> "ForgePac1" </> "POSEIDON.yml"
, "forge" </> "ForgePac1" </> "ForgePac1.geno"
, "forge" </> "ForgePac1" </> "ForgePac1.janno"
, "forge" </> "ForgePac1" </> "ForgePac1.ssf"
, "forge" </> "ForgePac1" </> "ForgePac1.bib"
]
-- forge test 1 with VCF and zip output
let forgeOpts1vcf = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDirOther </> "Schiffels_2016_vcf", PacBaseDir $ testPacsDir </> "Wang_2020"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP2,<SAMPLE2>,<SAMPLE4>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac1_vcf"
, _forgeOutPacName = Just "ForgePac1_vcf"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action1vcf = testLog (runForge forgeOpts1vcf) >> patchLastModified testDir ("forge" </> "ForgePac1_vcf" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action1vcf "forge" [
"forge" </> "ForgePac1_vcf" </> "POSEIDON.yml"
, "forge" </> "ForgePac1_vcf" </> "ForgePac1_vcf.geno"
, "forge" </> "ForgePac1_vcf" </> "ForgePac1_vcf.janno"
, "forge" </> "ForgePac1_vcf" </> "ForgePac1_vcf.ssf"
, "forge" </> "ForgePac1_vcf" </> "ForgePac1_vcf.bib"
]
-- forge test 2
let forgeOpts2 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Wang_2020"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP2,<SAMPLE2>,<SAMPLE4>,-<SAMPLE3>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "PLINK"
, _forgeOutMode = MinimalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac2"
, _forgeOutPacName = Nothing
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action2 = testLog (runForge forgeOpts2) >> patchLastModified testDir ("forge" </> "ForgePac2" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action2 "forge" [
"forge" </> "ForgePac2" </> "POSEIDON.yml"
, "forge" </> "ForgePac2" </> "ForgePac2.bed"
]
-- forge test 3
let forgeOpts3 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Wang_2020"]
, _forgeEntityInput = [EntitiesFromFile (testEntityFiles </> "goldenTestForgeFile1.txt")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac3"
, _forgeOutPacName = Nothing
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action3 = testLog (runForge forgeOpts3) >> patchLastModified testDir ("forge" </> "ForgePac3" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action3 "forge" [
"forge" </> "ForgePac3" </> "POSEIDON.yml"
, "forge" </> "ForgePac3" </> "ForgePac3.geno"
, "forge" </> "ForgePac3" </> "ForgePac3.snp"
, "forge" </> "ForgePac3" </> "ForgePac3.ind"
, "forge" </> "ForgePac3" </> "ForgePac3.janno"
, "forge" </> "ForgePac3" </> "ForgePac3.ssf"
]
-- forge test 4
let forgeOpts4 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Wang_2020"]
, _forgeEntityInput = [EntitiesFromFile (testEntityFiles </> "goldenTestForgeFile2.txt")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "PLINK"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac4"
, _forgeOutPacName = Nothing
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action4 = testLog (runForge forgeOpts4) >> patchLastModified testDir ("forge" </> "ForgePac4" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action4 "forge" [
"forge" </> "ForgePac4" </> "POSEIDON.yml"
, "forge" </> "ForgePac4" </> "ForgePac4.bim"
, "forge" </> "ForgePac4" </> "ForgePac4.bed"
, "forge" </> "ForgePac4" </> "ForgePac4.fam"
, "forge" </> "ForgePac4" </> "ForgePac4.janno"
, "forge" </> "ForgePac4" </> "ForgePac4.ssf"
]
-- forge test 5
let forgeOpts5 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Wang_2020"]
, _forgeEntityInput = []
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac5"
, _forgeOutPacName = Just "ForgePac5"
, _forgePackageWise = False
, _forgeSnpFile = Nothing
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action5 = testLog (runForge forgeOpts5) >> patchLastModified testDir ("forge" </> "ForgePac5" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action5 "forge" [
"forge" </> "ForgePac5" </> "POSEIDON.yml"
, "forge" </> "ForgePac5" </> "ForgePac5.geno"
, "forge" </> "ForgePac5" </> "ForgePac5.janno"
, "forge" </> "ForgePac5" </> "ForgePac5.ssf"
]
-- forge test 6 (direct genotype data input interface)
let forgeOpts6 = ForgeOptions {
_forgeGenoSources = [
GenoDirect $
GenotypeDataSpec {
genotypeFileSpec = GenotypeEigenstrat {
_esGenoFile = testPacsDir </> "Schiffels_2016" </> "geno.txt"
, _esGenoFileChkSum = Nothing
, _esSnpFile = testPacsDir </> "Schiffels_2016" </> "snp.txt"
, _esSnpFileChkSum = Nothing
, _esIndFile = testPacsDir </> "Schiffels_2016" </> "ind.txt"
, _esIndFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
},
GenoDirect $
GenotypeDataSpec {
genotypeFileSpec = GenotypePlink {
_plGenoFile = testPacsDir </> "Wang_2020" </> "Wang_2020.bed"
, _plGenoFileChkSum = Nothing
, _plSnpFile = testPacsDir </> "Wang_2020" </> "Wang_2020.bim"
, _plSnpFileChkSum = Nothing
, _plIndFile = testPacsDir </> "Wang_2020" </> "Wang_2020.fam"
, _plIndFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP2,<SAMPLE2>,<SAMPLE4>")]
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = GenoOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac6"
, _forgeOutPacName = Just "ForgePac6"
, _forgePackageWise = False
, _forgeSnpFile = Nothing
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action6 = testLog (runForge forgeOpts6)
runAndChecksumFiles checkFilePath testDir action6 "forge" [
"forge" </> "ForgePac6" </> "ForgePac6.geno"
, "forge" </> "ForgePac6" </> "ForgePac6.snp"
, "forge" </> "ForgePac6" </> "ForgePac6.ind"
]
-- forge test 7 (mixed data input interface)
let forgeOpts7 = ForgeOptions {
_forgeGenoSources = [
PacBaseDir $ testPacsDir </> "Schiffels_2016",
GenoDirect $
GenotypeDataSpec {
genotypeFileSpec = GenotypePlink {
_plGenoFile = testPacsDir </> "Wang_2020" </> "Wang_2020.bed"
, _plGenoFileChkSum = Nothing
, _plSnpFile = testPacsDir </> "Wang_2020" </> "Wang_2020.bim"
, _plSnpFileChkSum = Nothing
, _plIndFile = testPacsDir </> "Wang_2020" </> "Wang_2020.fam"
, _plIndFileChkSum = Nothing
}
, genotypeSnpSet = Just SNPSetOther
}
]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP2,<SAMPLE2>,<SAMPLE4>")]
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac7"
, _forgeOutPacName = Just "ForgePac7"
, _forgePackageWise = False
, _forgeSnpFile = Nothing
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action7 = testLog (runForge forgeOpts7) >> patchLastModified testDir ("forge" </> "ForgePac7" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action7 "forge" [
"forge" </> "ForgePac7" </> "ForgePac7.geno"
, "forge" </> "ForgePac7" </> "ForgePac7.snp"
, "forge" </> "ForgePac7" </> "ForgePac7.ind"
, "forge" </> "ForgePac7" </> "ForgePac7.janno"
]
-- forge test 8 (combining additional janno columns from separate source janno files)
let forgeOpts8 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Lamnidis_2018_newVersion"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "<XXX001>,<XXX011>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac8"
, _forgeOutPacName = Just "ForgePac8"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action8 = testLog (runForge forgeOpts8) >> patchLastModified testDir ("forge" </> "ForgePac8" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action8 "forge" [
"forge" </> "ForgePac8" </> "ForgePac8.janno"
, "forge" </> "ForgePac8" </> "ForgePac8.ssf"
]
-- forge test 9 (duplicates are handled correctly if an individual is properly specified)
let forgeOpts9 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Schmid_2028"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP1,-<Schiffels_2016:POP1:XXX001>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac9"
, _forgeOutPacName = Just "ForgePac9"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action9 = testLog (runForge forgeOpts9) >> patchLastModified testDir ("forge" </> "ForgePac9" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action9 "forge" [
"forge" </> "ForgePac9" </> "ForgePac9.geno"
, "forge" </> "ForgePac9" </> "ForgePac9.janno"
, "forge" </> "ForgePac9" </> "ForgePac9.ssf"
]
-- forge test 10 (duplicates can also be resolved with negative selection)
let forgeOpts10 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Schmid_2028"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "-<Schmid_2028:POP1:XXX001>,-<Schiffels_2016:POP2:XXX002>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac10"
, _forgeOutPacName = Just "ForgePac10"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action10 = testLog (runForge forgeOpts10) >> patchLastModified testDir ("forge" </> "ForgePac10" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action10 "forge" [
"forge" </> "ForgePac10" </> "ForgePac10.geno"
, "forge" </> "ForgePac10" </> "ForgePac10.janno"
, "forge" </> "ForgePac10" </> "ForgePac10.ssf"
, "forge" </> "ForgePac10" </> "ForgePac10.bib"
]
-- forge test 11 (--packagewise works as expected)
let forgeOpts11 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir </> "Schiffels_2016", PacBaseDir $ testPacsDir </> "Schmid_2028"]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "POP3")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac11"
, _forgeOutPacName = Just "ForgePac11"
, _forgePackageWise = True
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action11 = testLog (runForge forgeOpts11) >> patchLastModified testDir ("forge" </> "ForgePac11" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action11 "forge" [
"forge" </> "ForgePac11" </> "ForgePac11.geno"
, "forge" </> "ForgePac11" </> "ForgePac11.janno"
, "forge" </> "ForgePac11" </> "ForgePac11.ssf"
]
-- simple package version selection
let forgeOpts12 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "*Lamnidis_2018-1.0.0*")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac12"
, _forgeOutPacName = Just "ForgePac12"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action12 = testLog (runForge forgeOpts12) >> patchLastModified testDir ("forge" </> "ForgePac12" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action12 "forge" [
"forge" </> "ForgePac12" </> "ForgePac12.ind"
]
-- merge an explicitly versioned package with another package
let forgeOpts13 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $ readEntitiesFromString "*Lamnidis_2018-1.0.1*,*Schiffels_2016*")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac13"
, _forgeOutPacName = Just "ForgePac13"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action13 = testLog (runForge forgeOpts13) >> patchLastModified testDir ("forge" </> "ForgePac13" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action13 "forge" [
"forge" </> "ForgePac13" </> "ForgePac13.janno"
]
-- use the SpecificInd interface to merge individuals from the same package across different versions
let forgeOpts14 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $
readEntitiesFromString "<Lamnidis_2018-1.0.1:POP1:XXX017>,<Lamnidis_2018-1.0.0:POP3:XXX018>")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac14"
, _forgeOutPacName = Just "ForgePac14"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action14 = testLog (runForge forgeOpts14) >> patchLastModified testDir ("forge" </> "ForgePac14" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action14 "forge" [
"forge" </> "ForgePac14" </> "ForgePac14.janno"
]
-- -- negative selection with different package versions - use versioned to cancel versioned
let forgeOpts15 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $
readEntitiesFromString "*Lamnidis_2018-1.0.1*,-*Lamnidis_2018-1.0.1*,*Lamnidis_2018-1.0.0*")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False
, _forgeOutFormat = "EIGENSTRAT"
, _forgeOutMode = NormalOut
, _forgeOutZip = False
, _forgeOutPacPath = testDir </> "forge" </> "ForgePac15"
, _forgeOutPacName = Just "ForgePac15"
, _forgePackageWise = False
, _forgeOutputPlinkPopMode = PlinkPopNameAsFamily
, _forgeOutputOrdered = False
}
let action15 = testLog (runForge forgeOpts15) >> patchLastModified testDir ("forge" </> "ForgePac15" </> "POSEIDON.yml")
runAndChecksumFiles checkFilePath testDir action15 "forge" [
"forge" </> "ForgePac15" </> "ForgePac15.janno"
]
-- negative selection with different package versions - use unversioned to cancel versioned
let forgeOpts16 = ForgeOptions {
_forgeGenoSources = [PacBaseDir $ testPacsDir]
, _forgeEntityInput = [EntitiesDirect (fromRight [] $
readEntitiesFromString "*Lamnidis_2018-1.0.1*,-*Lamnidis_2018*,*Lamnidis_2018-1.0.0*")]
, _forgeSnpFile = Nothing
, _forgeIntersect = False