bioinformatics-toolkit 0.4.0 → 0.4.1
raw patch · 5 files changed
+20/−18 lines, 5 filesdep ~HsHTSLibdep ~conduit
Dependency ranges changed: HsHTSLib, conduit
Files
- bioinformatics-toolkit.cabal +3/−3
- src/Bio/ChIPSeq.hs +1/−1
- src/Bio/Data/Bam.hs +6/−6
- src/Bio/Data/Bed.hs +4/−4
- tests/Tests/Bam.hs +6/−4
bioinformatics-toolkit.cabal view
@@ -1,5 +1,5 @@ name: bioinformatics-toolkit-version: 0.4.0+version: 0.4.1 synopsis: A collection of bioinformatics tools description: A collection of bioinformatics tools license: MIT@@ -58,12 +58,12 @@ , bytestring-lexing >=0.5 , case-insensitive , clustering- , conduit-combinators+ , conduit >=1.3.0 , containers >=0.5 , data-ordlist , data-default-class , double-conversion- , HsHTSLib+ , HsHTSLib >=1.3.2.3 , http-conduit >=2.1.8 , hexpat , IntervalMap >=0.5.0.0
src/Bio/ChIPSeq.hs view
@@ -241,7 +241,7 @@ -> Int -- ^ radius -> Int -- ^ cutoff -> Source m BED-peakCluster peaks r th = mergeBedWith mergeFn peaks' $= filterC g+peakCluster peaks r th = mergeBedWith mergeFn peaks' .| filterC g where peaks' = map f peaks f b = let chr = chrom b
src/Bio/Data/Bam.hs view
@@ -2,7 +2,7 @@ module Bio.Data.Bam ( Bam , HeaderState- , runBam+ , withBamFile , readBam , writeBam , bamToBed@@ -13,11 +13,11 @@ import Bio.HTS import Bio.HTS.Types (Bam, FileHeader (..)) import Conduit-import Control.Monad.State (get, lift)+import Control.Monad.Reader (ask, lift) -- | Convert bam record to bed record. Unmapped reads will be discarded. bamToBed :: Conduit Bam HeaderState BED-bamToBed = mapMC bamToBed1 =$= concatC+bamToBed = mapMC bamToBed1 .| concatC {-# INLINE bamToBed #-} -- | Convert pairedend bam file to bed. the bam file must be sorted by names,@@ -29,9 +29,9 @@ Nothing -> return () Just b' -> do leftover b'- sortOrd <- getSortOrder <$> lift get+ sortOrd <- getSortOrder <$> lift ask case sortOrd of- Queryname -> loopBedPE =$= concatC+ Queryname -> loopBedPE .| concatC _ -> error "Bam file must be sorted by NAME." where loopBedPE :: Conduit Bam HeaderState (Maybe (BED, BED))@@ -54,7 +54,7 @@ bamToBed1 :: Bam -> HeaderState (Maybe BED) bamToBed1 bam = do- BamHeader hdr <- lift get+ BamHeader hdr <- lift ask return $ (\chr -> BED chr start end nm sc strand) <$> getChr hdr bam where start = fromIntegral $ position bam
src/Bio/Data/Bed.hs view
@@ -498,7 +498,7 @@ -- | Non-streaming version. hReadBed' :: (BEDLike b, MonadIO m) => Handle -> m [b]-hReadBed' h = hReadBed h $$ sinkList+hReadBed' h = runConduit $ hReadBed h .| sinkList {-# INLINE hReadBed' #-} -- | Read records from a bed file in a streaming fashion.@@ -510,7 +510,7 @@ -- | Non-streaming version. readBed' :: (BEDLike b, MonadIO m) => FilePath -> m [b]-readBed' fl = readBed fl $$ sinkList+readBed' fl = runConduit $ readBed fl .| sinkList {-# INLINE readBed' #-} hWriteBed :: (BEDLike b, MonadIO m) => Handle -> Sink b m ()@@ -522,7 +522,7 @@ {-# INLINE hWriteBed #-} hWriteBed' :: (BEDLike b, MonadIO m) => Handle -> [b] -> m ()-hWriteBed' handle beds = yieldMany beds $$ hWriteBed handle+hWriteBed' handle beds = runConduit $ yieldMany beds .| hWriteBed handle {-# INLINE hWriteBed' #-} writeBed :: (BEDLike b, MonadIO m) => FilePath -> Sink b m ()@@ -547,7 +547,7 @@ {-# INLINE fetchSeq #-} fetchSeq' :: (BioSeq DNA a, MonadIO m) => Genome -> [BED] -> m [Either String (DNA a)]-fetchSeq' g beds = yieldMany beds $= fetchSeq g $$ sinkList+fetchSeq' g beds = runConduit $ yieldMany beds .| fetchSeq g .| sinkList {-# INLINE fetchSeq' #-} -- | Identify motif binding sites
tests/Tests/Bam.hs view
@@ -24,21 +24,23 @@ bamIOTest = do goldenVsFile "BAM Read/Write Test" input output io where- io = runBam $ readBam input $$ writeBam output+ io = withBamFile input $ \h -> runConduit $ readBam h .| writeBam output input = "tests/data/example.bam" output = "tests/data/example_copy.bam" bamToBedTest :: Assertion bamToBedTest = do bed <- readBed' "tests/data/example.bed"- bed' <- runBam $ readBam "tests/data/example.bam" =$= bamToBed $$ sinkList+ bed' <- withBamFile "tests/data/example.bam" $ \h ->+ runConduit $ readBam h .| bamToBed .| sinkList (bed == bed') @? "bamToBedTest" sortedBamToBedPETest :: Assertion sortedBamToBedPETest = do bedpe <- readBedPE "tests/data/pairedend.bedpe"- bedpe' <- runBam $ readBam "tests/data/pairedend.bam" =$= sortedBamToBedPE =$=- mapC (\(x,y) -> (convert x, convert y)) $$ sinkList+ bedpe' <- withBamFile "tests/data/pairedend.bam" $ \h -> runConduit $+ readBam h .| sortedBamToBedPE .|+ mapC (\(x,y) -> (convert x, convert y)) .| sinkList forM_ (zip bedpe bedpe') $ \(b1, b2) -> (b1 == b2 || b1 == swap b2) @? show (b1,b2) where readBedPE fl = do