Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated about a month ago

total matches: more than 1000

BCMtools-0.1.1
18 matches
exe/BCMtools/Convert.hs
import BCM.IOMatrix (DMatrix, MCSR, DSMatrix, MSMatrix, MMatrix)

convertOptions :: Parser Command
convertOptions = fmap Convert $ ConvertOptions
             <$> strOption
                   ( long "genome"
                  <> short 'g'
                  <> metavar "ASSEMBLY"
                  <> help "e.g., hg19, or a file" )

            
exe/BCMtools/Convert.hs
                  <> short 'g'
                  <> metavar "ASSEMBLY"
                  <> help "e.g., hg19, or a file" )
             <*> fmap (splitOn ",") (strOption
                   ( long "rownames"
                  <> short 'r'
                  <> metavar "ROW LABELS" ))
             <*> fmap (splitOn ",") (strOption
                   ( long "colnames"
                  <> short 'c'
                  <> metavar "COLOUMN LABELS" ))
             <*> fmap readInt' (strOption
                   ( long "resolution"
                  <> short 's'
                  <> metavar "RESOLUTION" ))
             <*> switch
                   ( long "sparse"

            
exe/BCMtools/Convert.hs
                           closeContactMap cm
    readGenome x = do
        c <- B.readFile x
        return $ M.fromList $ map ((\[a,b] -> (B.unpack a, readInt b)) . B.words) $ B.lines c
    getChrSize g = map lookup'
      where
        lookup' x = (B.pack x, M.lookupDefault errMsg x g)
          where
            errMsg = error $ "Unknown chromosome: " ++ x
    field2 = do

            
exe/BCMtools/Convert.hs
            errMsg = error $ "Unknown chromosome: " ++ x
    field2 = do
        _ <- await
        CL.map f
      where
        f l = let [x1,x2,v] = B.split '\t' l
              in (B.pack chr1, readInt x1, B.pack chr2, readInt x2, readDouble' v)
        [chr1] = _rownames opt
        [chr2] = _colnames opt

            
exe/BCMtools/Convert.hs
              in (B.pack chr1, readInt x1, B.pack chr2, readInt x2, readDouble' v)
        [chr1] = _rownames opt
        [chr2] = _colnames opt
    field5 = CL.map f
      where
        f l = let [x1,x2,x3,x4,x5] = B.split '\t' l
              in (x1, readInt x2, x3, readInt x4, readDouble' x5)
{-# INLINE convert #-}


            
exe/BCMtools/View.hs
import BCM.Binary (ds_matrix_magic, d_matrix_magic, sp_matrix_magic)

viewOptions :: Parser Command 
viewOptions = fmap View $ ViewOptions
          <$> fmap f (strOption
                ( long "range"
               <> short 'r'
               <> metavar "Heatmap range" ))
  where
    f x = let a = read $ takeWhile (/='-') x
              b = read $ tail $ dropWhile (/='-') x
          in (a, b)


            
exe/BCMtools/View.hs
view input output onDisk opt = do
    Right magic <- withFile input ReadMode $ \h -> do
        hSeek h AbsoluteSeek 4
        Right p <- fmap fromIntegral . runGet getWord32le <$> B.hGet h 4
        hSeek h AbsoluteSeek p
        runGet getWord32le <$> B.hGet h 4

    case () of
        _ | magic == d_matrix_magic -> do

            
src/BCM/IOMatrix.hs

    hCreateMatrix handle (r,c) _ = do
        mat <- DM.replicate handle (r,c) zero
        CL.mapM_ $ \((i,j), x) -> DM.unsafeWrite mat (i,j) x
        return $ IODMat mat
    {-# INLINE hCreateMatrix #-}

-- | Just a wrapper
newtype IOMat m a = IOMat { unwrap :: m a }

            
src/BCM/IOMatrix.hs

    hCreateMatrix _ (r,c) _ = do
        mat <- liftIO $ MGM.replicate (r,c) zero
        CL.mapM_ $ \((i,j), x) -> liftIO $ MGM.unsafeWrite mat (i,j) x
        mat' <- liftIO $ MG.unsafeFreeze mat
        return $ IOMat mat'
    {-# INLINE hCreateMatrix #-}

-- | Just a wrapper

            
src/BCM/Visualize/Internal.hs
{-# INLINE coloursToPalette #-}

toPngData :: Conduit [Word8] IO B.ByteString
toPngData = CL.map (B.pack . (0:)) $= Z.compress 5 Z.defaultWindowBits
{-# INLINE toPngData #-}

            
src/BCM/Visualize.hs
    loop m i
      | i < h = do
          row <- IOM.unsafeTakeRowM m i
          yield $ U.toList $ U.map drawPixel row
          loop m (i+1)
      | otherwise = return ()

    drawPixel x | x <= lo = 0
                | x >= hi = fromIntegral $ n - 1

            
src/BCM.hs
import qualified BCM.DiskMatrix as DM
import qualified BCM.IOMatrix as IOM

-- contact map binary format
-- 4 bytes magic + 4 byte Int (matrix start) + 4 bytes Int (step) + chroms + 1 bytes (reserve) + matrix
data ContactMap m = ContactMap
    { _rowLabels :: M.HashMap B.ByteString (Int, Int)
    , _colLabels :: M.HashMap B.ByteString (Int, Int)
    , _resolution :: Int

            
src/BCM.hs
    }


contact_map_magic :: Word32
contact_map_magic = 0x9921ABF0

createContactMap :: (IOM.IOMatrix m t Double, MonadIO io, mat ~ m t Double)
                 => FilePath
                 -> [(B.ByteString, Int)]
                 -> [(B.ByteString, Int)]

            
src/BCM.hs
createContactMap fl rowChr colChr res len = do
    h <- liftIO $ openFile fl ReadWriteMode

    let source  = CL.mapM $ \(chr1, i, chr2, j, v) -> do
            let (p1, s1) = M.lookupDefault errMsg chr1 rLab
                (p2, s2) = M.lookupDefault errMsg chr2 cLab
                i' = i `div` res + p1
                j' = j `div` res + p2
            when (i > s1 || j > s2) $ error "createContactMap: Index out of bounds"

            
src/BCM.hs
    c = foldl' (\acc (_,x) -> acc + (x - 1) `div` res + 1)  0 colChr
    rLab = mkLabels rowChr res
    cLab = mkLabels colChr res
    nByte x = let n1 = foldl' (+) 0 $ map B.length $ fst $ unzip x
                  n2 = 16 * n3
                  n3 = length x
               in n1 + n2 + n3
    offset = 4 + 4 + 4 + nByte rowChr + nByte colChr + 2 + 1
    errMsg = error "createContactMap: Unknown chromosome"

            
src/BCM.hs
saveContactMap :: (IOM.IOMatrix m t a, mat ~ m t a) => ContactMap mat -> IO ()
saveContactMap (ContactMap rowChr colChr res mat handle) = do
        hSeek handle AbsoluteSeek 0
        L.hPutStr handle . runPut . putWord32le $ contact_map_magic
        L.hPutStr handle . runPut . putWord32le $ offset
        L.hPutStr handle . runPut . putWord32le . fromIntegral $ res
        L.hPutStr handle rowAndcol
        L.hPutStr handle . runPut . putWord8 $ 0
        IOM.hSaveMatrix handle mat

            
src/BCM.hs
    h <- openFile fl ReadWriteMode

    Right magic <- runGet getWord32le <$> L.hGet h 4
    guard $ magic == contact_map_magic
    _ <- runGet getWord32le <$> L.hGet h 4
    Right res <- fmap fromIntegral . runGet getWord32le <$> L.hGet h 4

    rows <- M.fromList <$> getChrs [] h
    cols <- M.fromList <$> getChrs [] h
    _ <- runGet getWord8 <$> L.hGet h 1
    mat <- IOM.hReadMatrix h

            
src/BCM.hs
        if B.null chr
           then return acc
           else do
               Right a <- fmap fromIntegral . runGet getWord64le <$> L.hGet h 8
               Right b <- fmap fromIntegral . runGet getWord64le <$> L.hGet h 8
               getChrs ((chr, (a, b)) : acc) h
    getByteStringNul h = B.concat <$> go []
      where
        go acc = do
            x <- B.hGet h 1

            
BiobaseTurner-0.3.1.1
6 matches
Biobase/Turner/Import.hs
minPPBBBB = minPPBBB:.nN -- (minP,minP,(nN,nN,nN,nN))
maxPPBBBB = maxPPBBB:.nU -- (maxP,maxP,(nU,nU,nU,nU))

d1_30 = L.map (Z:.) [1..30]

keysPP     = [{- ((k1,k2),(k4,k3)) -} Z:.k1:.k2:.k4:.k3 | k1 <- acgu, k3 <- acgu, k2 <- acgu, k4 <- acgu]
keysPB     = [{- ((k1,k2),k3) -} Z:.k1:.k2:.k3 | k1 <- acgu, k2 <- acgu, k3 <- acgu]
keysPBB    = [ {- ((k1,k2),k3,k4) -} Z:.k1:.k2:.k3:.k4
             | k1 <- acgu, k3 <- acgu, k2 <- acgu, k4 <- acgu]

            
Biobase/Turner/Import.hs
parseTabulated = C.lines =$ CL.filter (not . BS.all isSpace) =$ g where
  g = do
    CL.drop 2
    xs <- CL.map f =$ consume
    return xs
  f x
    | Just (d,_) <- readDouble v = (k,Energy d)
    | otherwise = error $ "tabulated: <" ++ BS.unpack x ++ ">"
    where (k,v) = second (BS.dropWhile isSpace) . BS.span (not . isSpace) . BS.dropWhile isSpace $ x

            
Biobase/Turner/Import.hs
blockFromFile :: FilePath -> IO [Energy]
blockFromFile fp = do
  xs <- runResourceT $ sourceFile fp $$ parseBlocks =$ consume
  if (allEq $ L.map L.length xs)
    then return $ L.concat xs
    else error $ "in file: " ++ fp ++ " we have unequal line lengths"

-- | Transform input stream into list of list of doubles


            
Biobase/Turner/Import.hs
-- | Transform input stream into list of list of doubles

parseBlocks :: Monad m => Conduit ByteString m [Energy]
parseBlocks = C.lines =$= CL.map f =$= CL.filter (not . L.null) where
  f x
    | "5'" `isPrefixOf` y = []
    | "3'" `isPrefixOf` y = []
    | "." `isPrefixOf`  y = values y
    | Just (d,xs) <- readDouble y = values y

            
Biobase/Turner/Import.hs
  f = do
    CL.drop 1
    xs <- consume
    return . L.map (L.map readD . BS.words . L.last) $ xs

-- | Parses stupidly encoded values like ".6" and "-.0".

readD :: ByteString -> Double
readD xs

            
Biobase/Turner/Import.hs
-- |

tabFromFile :: FilePath -> IO [(Primary,Energy)]
tabFromFile fp = fmap (L.map (first mkPrimary)) . runResourceT $ sourceFile fp $$ parseTabulated

allEq [] = True
allEq (x:xs) = L.all (==x) xs

type Prefix = FilePath

            
CurryDB-0.1.1.0
1 matches
Database/Redis/Server.hs
    runPipe
      $   sourceToPipe (appSource ad)
      >+> injectLeftovers (conduitParser parseRequest)
      -- >+> CL.mapM (\req -> $logInfo (T.pack $ show $ snd req) >> return req)
      >+> CL.mapM (fmap (toByteString . fromReply) . process)
      >+> sinkToPipe (appSink ad)

            
DnaProteinAlignment-0.0.0.1
2 matches
DnaProteinAlignment.hs
              ]
    let xsB = [ (d,inpD,offD,p,Backward,  dnaProtein n3m n2m n1m insertAA deleteAA rf1S rf1delS rf2S rf2delS inpD (B.unpack $ _fasta p))
              | d <- ds
              , let inpD = B.map compl . B.reverse $ _past d `B.append` _fasta d
              , let offD = (unOff $ _offset d) - (fromIntegral . B.length $ _past d)
              ]
    forM_ ((xsF++xsB) `using` parBuffer parallelism (evalTuple6 r0 r0 r0 r0 r0 (evalTuple2 rdeepseq r0)))
           $ \(d,inpD,offD,p,dir,(s,bs)) -> do
      let sa :: Double = fromIntegral s / fromIntegral (B.length $ _fasta p) :: Double

            
DnaProteinAlignment.hs
  PP.<$> PP.text (printf "%8d " pr) PP.<> os PP.<> (PP.text (printf " %8d" (apr-1)))
  PP.<$> PP.empty PP.<$> PP.empty
  where
  us = PP.hcat $ map upper xs
  os = PP.hcat $ map lower xs
  upper (PPS cs as  k) =           colorize k . PP.text . take 3 $ map fromNuc cs ++ repeat '-'
  upper (FRS cs as  k) = PP.underline . PP.bold . colorize k . PP.text . take 3 $ map fromNuc cs ++ repeat '-'
  upper (LOC c      k) =           colorize k . PP.text          $ [fromNuc c]
  lower (PPS cs []  k) =           colorize k . PP.text          $ "-  "
  lower (PPS cs [a] k) =           colorize k . PP.text . take 3 $ [a]            ++ repeat ' '
  lower (FRS cs [a] k) = PP.bold . colorize k . PP.text . take 3 $ [a]            ++ repeat ' '
  lower (LOC c      k) =           colorize k . PP.text          $ "."

            
Frames-beam-0.2.0.0
3 matches
src/Frames/SQL/Beam/Postgres/Streaming.hs
    -> m [out]
streamingSelectAllPipeline tbl db nrows recordProcessorConduit conn =
  DBPC.runSelect conn (select (allRows tbl db)) $
    (\c -> runConduit $ c .| CL.map createRecId
                          .| recordProcessorConduit
                          .| CL.take nrows)

-- | Similar as @streamingSelectAllPipeline@, with an additional @filterLambda@
-- parameter that executes a SQL 'SELECT * FROM tbl WHERE' at the DB-level

            
src/Frames/SQL/Beam/Postgres/Streaming.hs
    -> m [out]
streamingSelectAllPipeline' tbl db nrows filterLambda recordProcessorConduit conn =
  DBPC.runSelect conn (select (allRowsWhere tbl db filterLambda)) $
    (\c -> runConduit $ c .| CL.map createRecId
                          .| recordProcessorConduit
                          .| CL.take nrows)

-- | Takes in the connection string, one of the the other 4 functions in
-- in this module with just the @Connection@ object unapplied. Internally,

            
src/Frames/SQL/Beam/Postgres.hs
    streamRows = do
      res <-  'withConnection' connString $
                'streamingSelectAllPipeline'' _cart_users db 1000 (\c -> (_cart_usersFirst_name c) \`like_\` \"J%\") $
                  (CL.map (\record -> F.rcast @["_cart_usersEmail" F.:-> Text, "_cart_usersIs_member" F.:-> Bool] record))
      mapM_ print res
    @

    In the above, we select all rows from the specified table that match a
    certain pattern (@\"J%\"@), then the function `streamingSelectAllPipeline'`
     converts the query results to vinyl records inside a @conduit@ and sends