packages feed

samtools 0.2.0.1 → 0.2.1

raw patch · 3 files changed

+30/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Bio.SamTools.Bam: readBams :: FilePath -> IO [Bam1]
+ Bio.SamTools.BamIndex: readBamRegion :: IdxHandle -> Int -> (Int64, Int64) -> IO [Bam1]

Files

samtools.cabal view
@@ -1,5 +1,5 @@ Name:                samtools-Version:             0.2.0.1+Version:             0.2.1 Synopsis:            Binding to the C samtools library Description:         Binding to the C samtools library, which reads and                      writes SAM format alignments, both binary and tab-
src/Bio/SamTools/Bam.hs view
@@ -39,6 +39,7 @@   , closeInHandle   , withTamInFile, withTamInFileWithIndex, withBamInFile   , get1+  , readBams   -- * Writing SAM/BAM format files   , OutHandle, outHeader   , openTamOutFile, openBamOutFile@@ -57,7 +58,7 @@ import Foreign hiding (new) import Foreign.C.Types import Foreign.C.String-+import System.IO.Unsafe (unsafeInterleaveIO) import qualified Data.Vector as V  import Bio.SeqLoc.OnSeq@@ -337,6 +338,17 @@                 else return Nothing     else do bptr <- newForeignPtr bamDestroy1Ptr b             return . Just $ Bam1 { ptrBam1 = bptr, header = inHeader inh }++-- | Read a BAM file as a lazy strem of 'Bam1' records.+readBams :: FilePath -> IO [Bam1]+readBams = openBamInFile >=> getBams +  where+    getBams h = do+      b <- get1 h+      case b of Nothing -> closeInHandle h >> return []+                Just b1 -> do+                  bs <- unsafeInterleaveIO (getBams h)+                  return (b1:bs)  -- | Handle for writing SAM/BAM format alignments data OutHandle = OutHandle { outFilename :: !FilePath
src/Bio/SamTools/BamIndex.hs view
@@ -7,6 +7,7 @@        , open, close, withIndex        , Query, qyHandle        , query, next+       , readBamRegion        )                  where         @@ -20,7 +21,7 @@ import Bio.SamTools.Bam import Bio.SamTools.Internal import Bio.SamTools.LowLevel       -       + -- | Handle for fetching alignments by region from a sorted, indexed -- BAM file. data IdxHandle = IdxHandle { idxFilename :: !FilePath -- ^ Filename of sorted, indexed BAM file@@ -92,3 +93,17 @@                   then ioError . userError $                        "Error reading BAM query from " ++ show (idxFilename . qyHandle $ rgn)                   else return Nothing++-- | Use a BAM index file to extract 'Bam1' records aligned to a +-- specific target sequence (chromosome) number and region.+readBamRegion :: IdxHandle -> Int -> (Int64,Int64) -> IO [Bam1]+readBamRegion h chr reg  = do+  q <- query h chr reg+  go q+  where go x = do+          mb1 <- next x+          case mb1 of Nothing -> return []+                      Just b1 -> do+                        bs <- go x+                        return (b1:bs)+