poseidon-framework / poseidon-hs

A toolset to work with modular genotype databases in the Poseidon format
https://poseidon-framework.github.io/#/trident
MIT License
7 stars 2 forks source link

Refactoring `list --individuals -j ...` #226

Closed nevrome closed 1 year ago

nevrome commented 1 year ago

I'm either a fool or I had a stroke of genius. Difficult to judge with this one.

As suggested in #225 I replaced the unsatisfying extractAdditionalField with a much simpler, much more flexible solution, that relies on the hashmap in Data.CSV. JannoRow already is an instance of Csv.ToNamedRecord, because that's the mechanism we use to write .janno files. I think we can abuse this fact to transform JannoRows to hashmaps and read their content as strings for arbitrary keys (so: .janno column names). What do you think?

A big problem is, that we can not really test this with the remote server at the moment. My changes in 1.1.8.4 (#221) changed the way janno data is encoded in JSON, so server and client can not speak to each other any more. --remote triggers an error, when I try to read from the old server with the new client:

[Error]   Error in parsing JSON: "Error in $[0][1][0].jGenotypePloidy: Genotype_Ploidy \"Haploid\" not in [diploid, haploid]"

This is a separate issue from this PR, but it affects how I can test it. See #228 for an attempt to fix that.

nevrome commented 1 year ago
  1. Yes, that is true. I thought it's not important to print a warning here, actually. If a user requests a non-existent column, then they get an empty column. But alright - I think it should be possible to add one.
  2. I thought that is fine, because we treat empty strings and "n/a" equally in the .janno file. But I guess I can change that as well.
stschiff commented 1 year ago

OK, for 1) yes, I think a warning would be good, at least if a column is requested that is present nowhere. For 2) OK, that's fine then.

codecov-commenter commented 1 year ago

Codecov Report

Base: 64.91% // Head: 70.96% // Increases project coverage by +6.04% :tada:

Coverage data is based on head (34ead2a) compared to base (c76e0e2). Patch coverage: 68.90% of modified lines in pull request are covered.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #226 +/- ## ========================================== + Coverage 64.91% 70.96% +6.04% ========================================== Files 18 18 Lines 2289 2211 -78 Branches 253 245 -8 ========================================== + Hits 1486 1569 +83 + Misses 550 397 -153 + Partials 253 245 -8 ``` | [Impacted Files](https://codecov.io/gh/poseidon-framework/poseidon-hs/pull/226?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=poseidon-framework) | Coverage Δ | | |---|---|---| | [src/Poseidon/Janno.hs](https://codecov.io/gh/poseidon-framework/poseidon-hs/pull/226?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=poseidon-framework#diff-c3JjL1Bvc2VpZG9uL0phbm5vLmhz) | `82.32% <67.34%> (+16.56%)` | :arrow_up: | | [src/Poseidon/CLI/List.hs](https://codecov.io/gh/poseidon-framework/poseidon-hs/pull/226?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=poseidon-framework#diff-c3JjL1Bvc2VpZG9uL0NMSS9MaXN0Lmhz) | `80.88% <77.77%> (+39.07%)` | :arrow_up: | | [src/Poseidon/CLI/Forge.hs](https://codecov.io/gh/poseidon-framework/poseidon-hs/pull/226?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=poseidon-framework#diff-c3JjL1Bvc2VpZG9uL0NMSS9Gb3JnZS5ocw==) | `61.60% <87.50%> (+1.76%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=poseidon-framework). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=poseidon-framework)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.