Skip to content

Commit 1ca9480

Browse files
authored
Merge pull request #10 from poseidon-framework/v300
Maintenance for Poseidon v3.0.0
2 parents 25d368a + d5815f1 commit 1ca9480

15 files changed

Lines changed: 76 additions & 60 deletions

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414
- uses: freckle/stack-action@v5
1515
with:
1616
stack-arguments: --coverage
1717
# prepare and upload test coverage report
1818
- uses: 8c6794b6/hpc-codecov-action@v4
1919
with:
2020
target: stack:spec
21-
- uses: codecov/codecov-action@v4
21+
- uses: codecov/codecov-action@v5
2222
with:
2323
token: ${{ secrets.CODECOV_TOKEN }} # set in organization settings

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Check out code
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616

1717
- name: Create Release
1818
id: create_release
@@ -89,7 +89,7 @@ jobs:
8989

9090
steps:
9191
- name: Checkout repo
92-
uses: actions/checkout@v4
92+
uses: actions/checkout@v6
9393

9494
- name: Build Docker image
9595
run: docker build -t linux -f .github/workflows/Dockerfile.centos .

.github/workflows/stylishHaskell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414

1515
- name: Check out code
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v6
1717

1818
- name: Install stylish-haskell
1919
run: |

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
- V 1.0.1.0: Update for Poseidon v3.0.0
2+
- Switched to new stackage resolver version v22.43.
3+
- Replaced the .janno column order list with a new one for Poseidon v3.0.0.
4+
- Introduced a mechanism to automatically position `_Note` columns in .janno files.
15
- V 1.0.0.1:
2-
- Switched to new stackage resolver version v21.21
3-
- Update of the release pipeline according to the template developed for trident
6+
- Switched to new stackage resolver version v21.21.
7+
- Update of the release pipeline according to the template developed for trident.
48
- V 1.0.0.0:
59
- Added more data input options for .janno files (d(), da(), j(), .janno).
610
- Reorganized golden tests and added new ones.

CHANGELOGRELEASE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### V 1.0.1.0
2+
3+
This is a maintenance release to bring `qjanno` in sync with Poseidon v3.0.0.
4+
5+
It comes with a new column order template for `.janno` files, featuring the new columns introduced with the v3.0.0 schema release, and a mechanism to automatically position arbitrary `_Note` columns in this template (as in `trident`).
6+
7+
As usual we also switched to a new GHC version (9.6.6) and a new Stackage resolver version (22.43).
8+
19
### V 1.0.0.1
210

311
This minor release replaces the pipeline to produce static `qjanno` executables for every release.

cabal.project

Lines changed: 0 additions & 3 deletions
This file was deleted.

qjanno-hs.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: qjanno-hs
2-
version: 1.0.0.1
2+
version: 1.0.1.0
33
author: itchyny <https://github.com/itchyny>, Clemens Schmid
44
maintainer: Clemens Schmid <clemens@nevrome.de>
55
license: MIT

src/Qjanno/Janno.hs

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import Control.Monad (filterM)
88
import Data.Aeson (FromJSON, parseJSON, withObject, (.:), (.:?))
99
import Data.Either (lefts, rights)
1010
import Data.Foldable (foldl')
11-
import Data.List (elemIndices, groupBy, sortBy, sortOn,
12-
transpose)
11+
import Data.List (elemIndices, groupBy, insertBy, sortBy,
12+
sortOn, transpose)
1313
import qualified Data.Map.Strict as M
1414
import qualified Data.Set as Set
1515
import Data.Version (Version)
@@ -111,17 +111,40 @@ mergeJannos xs =
111111

112112
reorderJannoColumns :: ([String], [[String]]) -> ([String], [[String]])
113113
reorderJannoColumns (oldCols, oldRowsData) =
114-
let orderedCols = sortOn getOrder oldCols
115-
orderingIndices = concatMap (`elemIndices` oldCols) orderedCols
114+
let baseOrderedCols = sortOn getOrder oldCols
115+
finalCols = applyNoteWeaving baseOrderedCols
116+
orderingIndices = concatMap (`elemIndices` oldCols) finalCols
116117
orderedRowsData = map (\row -> map (row !!) orderingIndices) oldRowsData
117-
in (orderedCols, orderedRowsData)
118+
in (finalCols, orderedRowsData)
118119
where
119120
-- https://stackoverflow.com/a/26260968/3216883
120121
getOrder :: String -> Int
121122
getOrder k = M.findWithDefault (length jannoOrder) k ordermap
122123
ordermap :: M.Map String Int
123124
ordermap = M.fromList (zip jannoOrder [0..])
124125

126+
-- _Note column weaving as in trident's Janno.hs module
127+
applyNoteWeaving :: [String] -> [String]
128+
applyNoteWeaving cols =
129+
let noteCols = filter isNote cols
130+
nonNoteCols = filter (not . isNote) cols
131+
in weave noteCols nonNoteCols
132+
where
133+
isNote x = reverse (takeWhile (/= '_') (reverse x)) == "Note"
134+
weave :: [String] -> [String] -> [String]
135+
weave inserts = reverse . insertByMulti findSpot inserts . reverse
136+
-- reverse, because Note columns should be at the end of column groups (e.g. Date_*)
137+
insertByMulti :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
138+
insertByMulti _ [] xs = xs
139+
insertByMulti f (i:rest) xs = insertBy f i (insertByMulti f rest xs)
140+
findSpot :: String -> String -> Ordering
141+
findSpot i x
142+
| removeSuffix i == x = LT
143+
| removeSuffix x == x = GT
144+
| otherwise = findSpot i (removeSuffix x)
145+
removeSuffix :: String -> String
146+
removeSuffix = reverse . drop 1 . dropWhile (/= '_') . reverse
147+
125148
jannoOrder :: [String]
126149
jannoOrder = "package_title" : "package_version" : "source_file" : jannoHeader
127150

@@ -130,44 +153,25 @@ jannoHeader = [
130153
"Poseidon_ID"
131154
, "Genetic_Sex"
132155
, "Group_Name"
133-
, "Alternative_IDs"
134-
, "Relation_To"
135-
, "Relation_Degree"
136-
, "Relation_Type"
137-
, "Relation_Note"
138-
, "Collection_ID"
139-
, "Country"
140-
, "Country_ISO"
141-
, "Location"
142-
, "Site"
143-
, "Latitude"
144-
, "Longitude"
156+
, "Individual_ID"
157+
, "Species"
158+
, "Alternative_IDs", "Alternative_IDs_Context"
159+
, "Relation_To", "Relation_Degree", "Relation_Type"
160+
, "Collection_ID", "Custodian_Institution"
161+
, "Cultural_Era", "Cultural_Era_URL", "Archaeological_Culture", "Archaeological_Culture_URL"
162+
, "Country", "Country_ISO"
163+
, "Location", "Site", "Latitude", "Longitude"
145164
, "Date_Type"
146-
, "Date_C14_Labnr"
147-
, "Date_C14_Uncal_BP"
148-
, "Date_C14_Uncal_BP_Err"
149-
, "Date_BC_AD_Start"
150-
, "Date_BC_AD_Median"
151-
, "Date_BC_AD_Stop"
152-
, "Date_Note"
153-
, "MT_Haplogroup"
154-
, "Y_Haplogroup"
155-
, "Source_Tissue"
156-
, "Nr_Libraries"
157-
, "Library_Names"
158-
, "Capture_Type"
159-
, "UDG"
160-
, "Library_Built"
161-
, "Genotype_Ploidy"
165+
, "Date_C14_Labnr", "Date_C14_Uncal_BP", "Date_C14_Uncal_BP_Err"
166+
, "Date_BC_AD_Start", "Date_BC_AD_Median", "Date_BC_AD_Stop"
167+
, "Chromosomal_Anomalies"
168+
, "MT_Haplogroup", "Y_Haplogroup"
169+
, "Source_Material"
170+
, "Nr_Libraries", "Library_Names"
171+
, "Capture_Type", "UDG", "Library_Built", "Genotype_Ploidy"
162172
, "Data_Preparation_Pipeline_URL"
163-
, "Endogenous"
164-
, "Nr_SNPs"
165-
, "Coverage_on_Target_SNPs"
166-
, "Damage"
167-
, "Contamination"
168-
, "Contamination_Err"
169-
, "Contamination_Meas"
170-
, "Contamination_Note"
173+
, "Endogenous", "Nr_SNPs", "Coverage_on_Target_SNPs", "Damage"
174+
, "Contamination", "Contamination_Err", "Contamination_Meas"
171175
, "Genetic_Source_Accession_IDs"
172176
, "Primary_Contact"
173177
, "Publication"

stack.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ packages:
33
- '.'
44
extra-deps:
55
- sqlite-simple-0.4.18.2
6-
- direct-sqlite-2.3.28
76
- simple-sql-parser-0.6.0
87
- table-layout-0.9.1.0
9-
- data-default-instances-base-0.1.0.1
108
allow-newer: true
11-
resolver: lts-21.21
9+
resolver: lts-22.43

test/MainSpec.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module MainSpec (spec) where
22

3-
import Control.Applicative
43
import Control.Monad
54
import System.IO
65
import System.Process
7-
import Test.Hspec (Spec, describe, it, shouldReturn)
6+
import Test.Hspec (Spec, describe, it, shouldReturn)
87

98
spec :: Spec
109
spec = qjannoSpec
@@ -27,7 +26,8 @@ qjannoSpec =
2726

2827
let poseidon_tests = [
2928
"janno_d", "janno_da", "janno_j", "janno_d_da_j", "janno_ext",
30-
"janno_d_ext_ext", "show_columns", "janno_d_da_j_full"
29+
"janno_d_ext_ext", "show_columns", "janno_d_da_j_full",
30+
"janno_column_order"
3131
]
3232

3333
runTestScripts "poseidon" poseidon_tests

0 commit comments

Comments
 (0)