convert-annotation 0.5.0.0 → 0.5.0.1
raw patch · 3 files changed
+18/−15 lines, 3 filesdep +reqdep −wreq
Dependencies added: req
Dependencies removed: wreq
Files
- app/Main.hs +3/−3
- convert-annotation.cabal +2/−2
- src/HUGOConvert.hs +13/−10
app/Main.hs view
@@ -108,7 +108,7 @@ col :: Options -> [T.Text] -> Int col opts = fromMaybe (error "Column not found.") . elemIndex (unHelpful $ column opts)- + -- | Convert the entire file at once, no streaming. strictConvert :: Options -> Maybe (RMart s)@@ -121,7 +121,7 @@ let newH = maybe h (\x -> h <> [x]) $ newCol xs = fmap (!! c) body- + newXS <- convertMultiple opts rMart rData $ xs let addToRow newX row =@@ -174,7 +174,7 @@ toRGeneAnn (fromJust rMart) (RType queryType) whichAnn (MSigDBRData _) = error "MSigDBRData annotation not yet supported."- + -- | The conversion process for all in memory. convertMultiple :: Options -> Maybe (RMart s)
convert-annotation.cabal view
@@ -1,5 +1,5 @@ name: convert-annotation-version: 0.5.0.0+version: 0.5.0.1 synopsis: Convert the annotation of a gene to another in a delimited file using a variety of different databases. description: Please see README.org homepage: http://github.com/GregorySchwartz/convert-annotation#readme@@ -29,7 +29,7 @@ , aeson , lens , lens-aeson- , wreq+ , req , HTTP , safe , inline-r
src/HUGOConvert.hs view
@@ -13,36 +13,39 @@ -- Standard import Data.Monoid+import Control.Exception (throwIO) -- Cabal import qualified Data.Text as T import Data.Aeson import Data.Aeson.Lens import Control.Lens-import Network.Wreq+import Network.HTTP.Req import Safe -- Local import Types +instance MonadHttp IO where+ handleHttpException = throwIO+ -- | Get the HUGO annotation. toHUGOAnn :: HUGOType -> UnknownAnn -> IO (Maybe Ann) toHUGOAnn _ (UnknownAnn "") = return Nothing toHUGOAnn (HUGOType queryType) (UnknownAnn query) = do- let opts = set (header "Accept") ["application/json"] defaults+ let opts = header "Accept" "application/json" - r <- getWith opts- $ "http://rest.genenames.org/search/"- <> T.unpack queryType- <> "/"- <> T.unpack query+ r <- req GET+ (http "rest.genenames.org" /: "search" /: queryType /: query)+ NoReqBody+ jsonResponse+ opts - let getSymbols = responseBody- . key "response"+ let getSymbols = key "response" . key "docs" . _Array . traverse . key "symbol" . _String - return . fmap Ann . headMay . toListOf getSymbols $ r+ return . fmap Ann . headMay . toListOf getSymbols $ (responseBody r :: Value)