|
1 | | -{- Copyright 2013-2019 NGLess Authors |
| 1 | +{- Copyright 2013-2022 NGLess Authors |
2 | 2 | - License: MIT -} |
3 | 3 | {-# LANGUAGE CPP #-} |
4 | 4 |
|
@@ -81,31 +81,32 @@ readGffLine :: B.ByteString -> Either NGError GffLine |
81 | 81 | readGffLine line = case B8.split '\t' line of |
82 | 82 | [tk0,tk1,tk2,tk3,tk4,tk5,tk6,tk7,tk8] -> |
83 | 83 | GffLine |
84 | | - tk0 |
85 | | - tk1 |
86 | | - tk2 |
87 | | - <$> intOrError tk3 |
88 | | - <*> intOrError tk4 |
89 | | - <*> score tk5 |
| 84 | + tk0 -- seq id |
| 85 | + tk1 -- source |
| 86 | + tk2 -- type |
| 87 | + <$> intOrError "reading start" tk3 -- start |
| 88 | + <*> intOrError "reading end" tk4 -- end |
| 89 | + <*> score tk5 -- score |
90 | 90 | <*> strandOrError tk6 |
91 | 91 | <*> phase tk7 |
92 | 92 | <*> pure (_parseGffAttributes tk8) |
93 | 93 | _ -> throwDataError ("unexpected line in GFF: " ++ show line) |
94 | 94 | where |
95 | | - parseOrError :: (a -> Maybe b) -> a -> NGLess b |
96 | | - parseOrError p s = case p s of |
| 95 | + parseOrError :: String -> (B.ByteString -> Maybe b) -> B.ByteString -> NGLess b |
| 96 | + parseOrError context p s = case p s of |
97 | 97 | Just v -> return v |
98 | | - Nothing -> throwDataError $ "Could not parse GFF line: "++ show line |
99 | | - intOrError :: B.ByteString -> NGLess Int |
100 | | - intOrError = parseOrError (liftM fst . I.readDecimal) |
101 | | - floatOrError = parseOrError (liftM fst . F.readDecimal) |
| 98 | + Nothing -> throwDataError $ "Could not parse GFF line (" ++ context ++ ", while parsing '" ++ B8.unpack s ++ "'): "++ show line |
| 99 | + intOrError :: String -> B.ByteString -> NGLess Int |
| 100 | + intOrError c = parseOrError c (liftM fst . I.readDecimal) |
| 101 | + floatOrError c = parseOrError c (liftM fst . (F.readSigned F.readDecimal)) |
| 102 | + |
102 | 103 | score :: B.ByteString -> NGLess (Maybe Float) |
103 | 104 | score "." = return Nothing |
104 | | - score v = Just <$> floatOrError v |
| 105 | + score v = Just <$> floatOrError "reading score" v |
105 | 106 |
|
106 | 107 | phase :: B.ByteString -> NGLess Int |
107 | 108 | phase "." = return (-1) |
108 | | - phase r = intOrError r |
| 109 | + phase r = intOrError "reading phase" r |
109 | 110 | strandOrError :: B.ByteString -> NGLess GffStrand |
110 | 111 | strandOrError s = case B8.uncons s of |
111 | 112 | Just (s',_) -> parseStrand s' |
|
0 commit comments