Skip to content

Commit

Permalink
simplified the SSF code and removed unused checking functionality - c…
Browse files Browse the repository at this point in the history
…an be brought back based on the janno code if necessary
  • Loading branch information
nevrome committed Dec 10, 2023
1 parent 73763b2 commit 321b2d6
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions src/Poseidon/SequencingSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -403,39 +403,25 @@ readSeqSourceFile seqSourcePath = do
mapM_ (logError . renderPoseidonException) $ take 5 $ lefts seqSourceRepresentation
liftIO $ throwIO $ PoseidonFileConsistencyException seqSourcePath "Broken lines."
else do
let consistentSeqSource = checkSeqSourceConsistency seqSourcePath $ SeqSourceRows $ rights seqSourceRepresentation
case consistentSeqSource of
Left e -> do liftIO $ throwIO (e :: PoseidonException)
Right x -> do
-- warnings
warnSeqSourceConsistency seqSourcePath x
-- finally return the good ones
return x
let seqSource = SeqSourceRows $ rights seqSourceRepresentation
warnSeqSourceConsistency seqSourcePath seqSource
return seqSource

-- | A function to read one row of a seqSourceFile
readSeqSourceFileRow :: FilePath -> (Int, Bch.ByteString) -> PoseidonIO (Either PoseidonException SeqSourceRow)
readSeqSourceFileRow seqSourcePath (lineNumber, row) = do
case Csv.decodeByNameWith decodingOptions row of
let decoded = Csv.decodeByNameWith decodingOptions row
simplifiedDecoded = (\(_,rs) -> V.head rs) <$> decoded
case simplifiedDecoded of
Left e -> do
let betterError = case P.parse parseCsvParseError "" e of
Left _ -> removeUselessSuffix e
Right result -> renderCsvParseError result
return $ Left $ PoseidonFileRowException seqSourcePath (show lineNumber) betterError

Check warning on line 420 in src/Poseidon/SequencingSource.hs

View check run for this annotation

Codecov / codecov/patch

src/Poseidon/SequencingSource.hs#L417-L420

Added lines #L417 - L420 were not covered by tests
Right (_, seqSourceRow :: V.Vector SeqSourceRow) -> do
case checkSeqSourceRowConsistency seqSourcePath lineNumber $ V.head seqSourceRow of
Left e -> do return $ Left e
Right (pS :: SeqSourceRow) -> do return $ Right pS

-- SeqSource consistency checks
checkSeqSourceConsistency :: FilePath -> SeqSourceRows -> Either PoseidonException SeqSourceRows
checkSeqSourceConsistency _ xs
-- | ... no tests implemented
| otherwise = Right xs

checkSeqSourceRowConsistency :: FilePath -> Int -> SeqSourceRow -> Either PoseidonException SeqSourceRow
checkSeqSourceRowConsistency _ _ x
-- | ... no tests implemented
| otherwise = Right x
Right seqSourceRow -> do
return $ Right seqSourceRow

-- Global SSF consistency checks

warnSeqSourceConsistency :: FilePath -> SeqSourceRows -> PoseidonIO ()
warnSeqSourceConsistency seqSourcePath xs = do
Expand Down

0 comments on commit 321b2d6

Please sign in to comment.