fromAL :: PrimMonad m
       => [(B.ByteString, Int)]
       -> Int
       -> Sink ((Int, Int), Double) m ContactMap
fromAL chrs res = do
    mat <- lift $ MSM.replicate (matSize,matSize) 0
    CL.mapM_ $ \((i,j), v) -> MSM.write mat (i `div` res, j `div` res) v
    mat' <- lift $ MS.unsafeFreeze mat
    return $ ContactMap chrs res mat'
  where
    matSize = foldl' (+) 0 $ map (\(_,x) -> (x-1) `div` res + 1) chrs

fromAL :: PrimMonad m
       => [(B.ByteString, Int)]
       -> Int
       -> Sink ((Int, Int), Double) m ContactMap
fromAL chrs res = do
    mat <- lift $ MSM.replicate (matSize,matSize) 0
    CL.mapM_ $ \((i,j), v) -> MSM.write mat (i `div` res, j `div` res) v
    mat' <- lift $ MS.unsafeFreeze mat
    return $ ContactMap chrs res mat'
  where
    matSize = foldl' (+) 0 $ map (\(_,x) -> (x-1) `div` res + 1) chrs

fromAL chrs res = do
    mat <- lift $ MSM.replicate (matSize,matSize) 0
    CL.mapM_ $ \((i,j), v) -> MSM.write mat (i `div` res, j `div` res) v
    mat' <- lift $ MS.unsafeFreeze mat
    return $ ContactMap chrs res mat'
  where
    matSize = foldl' (+) 0 $ map (\(_,x) -> (x-1) `div` res + 1) chrs
