From 21a9f128d5bbbd1faa8571fd0233907a470acedf Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 29 Sep 2022 09:30:22 +1000 Subject: simplify puCorrection --- src/scrape.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/scrape.hs b/src/scrape.hs index 1cccb67..c9ff8e1 100644 --- a/src/scrape.hs +++ b/src/scrape.hs @@ -78,7 +78,7 @@ normalise xs = let ord = sort [(s, (h, notTer h)) | (h, s) <- xs] (hgvs, y) = unzip $ map snd ord y' = pava y - in M.fromList . zip hgvs . map pure <$> puCorrection hgvs y' + in M.fromList . zip hgvs . map pure <$> puCorrection y y' notTer str = if (T.reverse . T.take 3 $ T.reverse str) == "Ter" then 0 else 1 :: Double @@ -89,10 +89,9 @@ weightedMean w0 w1 xs = n0 = fromIntegral (length xs) - n1 in w1 * n1 / (w1 * n1 + w0 * n0) -puCorrection hgvs ys = - let lab = map notTer hgvs - in M.fromListWith (++) (zip lab $ map pure ys) ^. at 0 <&> \nonsc -> - let cf = 1 - mean nonsc -- NB: reversed due to dms score being lower when Ter - w0 = 2 / cf - w1 = 1 / mean lab - in pava' (weightedMean w0 w1) lab +puCorrection lab ys = + M.fromListWith (++) (zip lab $ map pure ys) ^. at 0 <&> \nonsc -> + let cf = 1 - mean nonsc -- NB: reversed due to dms score being lower when Ter + w0 = 2 / cf + w1 = 1 / mean lab + in pava' (weightedMean w0 w1) lab -- cgit v1.2.3