diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2011 Nicholas Ingolia
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/samtools-conduit.cabal b/samtools-conduit.cabal
new file mode 100644
--- /dev/null
+++ b/samtools-conduit.cabal
@@ -0,0 +1,23 @@
+-- Initial samtools-conduit.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name:                samtools-conduit
+version:             0.1.0.0
+synopsis:            Conduit interface to SAM/BAM format files through samtools
+description:         Conduit interface to SAM/BAM format files through samtools
+homepage:            http://www.ingolia-lab.org/samtools-tutorial.html
+license:             MIT
+license-file:        LICENSE
+author:              Nicholas Ingolia
+maintainer:          nick@ingolia.org
+-- copyright:           
+category:            Bioinformatics
+build-type:          Simple
+cabal-version:       >=1.8
+
+library
+  exposed-modules:     Bio.SamTools.Conduit
+  -- other-modules:       
+  build-depends:       base ==4.6.*, bytestring >= 0.9, samtools >= 0.2.4.1, filepath,
+                       transformers, resourcet, conduit >= 1.1
+  hs-source-dirs:      src
diff --git a/src/Bio/SamTools/Conduit.hs b/src/Bio/SamTools/Conduit.hs
new file mode 100644
--- /dev/null
+++ b/src/Bio/SamTools/Conduit.hs
@@ -0,0 +1,64 @@
+{-# LANGUAGE RankNTypes #-}
+module Bio.SamTools.Conduit
+       where
+
+import Control.Monad.IO.Class
+import Control.Monad.Trans.Resource
+import qualified Data.Conduit as C
+import qualified Data.Conduit.List as C
+
+import qualified Bio.SamTools.Bam as Bam
+import qualified Bio.SamTools.BamIndex as BamIdx
+
+import System.FilePath
+
+-- | Streams the alignments read from a 'Bam.InHandle'
+sourceHandle :: (MonadIO m) => Bam.InHandle -> C.Producer m Bam.Bam1
+sourceHandle inh = go
+  where go = (liftIO $ Bam.get1 inh) >>= maybe (return ()) (\b -> C.yield b >> go)
+
+-- | Streams the alignments read from a BAM format (binary) file
+sourceBamInFile :: (MonadResource m) => FilePath -> C.Producer m Bam.Bam1
+sourceBamInFile infile = C.bracketP (Bam.openBamInFile infile) Bam.closeInHandle sourceHandle
+
+-- | Streams the alignments read from a TAM format (tab-delimited text) file
+sourceTamInFile :: (MonadResource m) => FilePath -> C.Producer m Bam.Bam1
+sourceTamInFile infile = C.bracketP (Bam.openTamInFile infile) Bam.closeInHandle sourceHandle
+
+-- | Streams the alignments read from a 'BamIdx.Query' set of query results
+sourceQuery :: (MonadIO m) => BamIdx.Query -> C.Producer m Bam.Bam1
+sourceQuery qy = go
+  where go = (liftIO $ BamIdx.next qy) >>= maybe (return ()) (\b -> C.yield b >> go)
+
+-- | Stream incoming alignments into a 'Bam.OutHandle'
+sinkHandle :: (MonadIO m) => Bam.OutHandle -> C.Consumer Bam.Bam1 m ()
+sinkHandle outh = C.mapM_ (liftIO . Bam.put1 outh)
+
+-- | Stream incoming alignments into a BAM-format output file with header specified
+sinkBamOutFileWithHeader :: (MonadResource m) => FilePath -> Bam.Header -> C.Consumer Bam.Bam1 m ()
+sinkBamOutFileWithHeader outfile hdr = C.bracketP (Bam.openBamOutFile outfile hdr) Bam.closeOutHandle sinkHandle
+
+-- | Stream incoming alignments into a BAM-format output file using
+-- the target sequence headers from the first 'Bam.Bam1' alignment.
+sinkBamOutFile :: (MonadResource m) => FilePath -> C.Consumer Bam.Bam1 m ()
+sinkBamOutFile outfile = C.await >>= \mb -> case mb of
+                                              Nothing -> return ()
+                                              Just b -> C.bracketP (openAndPut b) Bam.closeOutHandle sinkHandle
+  where openAndPut b = do outh <- Bam.openBamOutFile outfile (Bam.header b)
+                          liftIO . Bam.put1 outh $! b
+                          return outh
+
+-- | Stream incoming alignments into a TAM-format output file with header specified
+sinkTamOutFileWithHeader :: (MonadResource m) => FilePath -> Bam.Header -> C.Consumer Bam.Bam1 m ()
+sinkTamOutFileWithHeader outfile hdr = C.bracketP (Bam.openTamOutFile outfile hdr) Bam.closeOutHandle sinkHandle
+
+-- | Stream incoming alignments into a TAM-format output file using
+-- the target sequence headers from the first 'Bam.Bam1' alignment.
+sinkTamOutFile :: (MonadResource m) => FilePath -> C.Consumer Bam.Bam1 m ()
+sinkTamOutFile outfile = C.await >>= \mb -> case mb of
+                                              Nothing -> return ()
+                                              Just b -> C.bracketP (openAndPut b) Bam.closeOutHandle sinkHandle
+  where openAndPut b = do outh <- Bam.openTamOutFile outfile (Bam.header b)
+                          liftIO . Bam.put1 outh $! b
+                          return outh
+
