diff --git a/README.md b/README.md index 4fa98562c6db913da048061bfe059a1a630067fb..6cedfdab351e6a884f85bc4a32e8320f582ba52d 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,10 @@ fastq file provided in the `test` directory: fastq-sort -s test/example.fq | remove-duplicates-from-sorted-fastq > test/dedup.fq -The resulting `test/dedup.fq` should be identical to `test/dedup_expected.fq`. +This can also be achieved in two steps: + + fastq-sort -s test/example.fq > test/sorted.fq + remove-duplicates-from-sorted-fastq test/sorted.fq > test/dedup.fq + +In both cases, the resulting `test/dedup.fq` should be identical to +`test/dedup_expected.fq`. diff --git a/app/Main.hs b/app/Main.hs index b635c63ad3072a4d9bd0fddf90941cf0cb719a3d..5e67644ffd6bfb9f735363ea5fbc631cc631e8d7 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Main where +import System.Environment (getArgs) -- For more efficient text manipulation import qualified Data.ByteString.Lazy.Char8 as C @@ -66,5 +67,23 @@ text-formatted fastq records into a single text. C.interact deals with the IO interaction, i.e. taking text from the outside world and returning text to it. -} +processStdin :: IO () +processStdin = C.interact (C.concat . processLines . C.lines) + +processPath :: String -> IO () +processPath path = do + fileContent <- (C.readFile path) + C.putStr ((C.concat . processLines . C.lines) fileContent) + +selectAction :: [String] -> IO () +selectAction [] = processStdin +selectAction (path : []) = do + processPath path +selectAction (path : nextArgs) = do + processPath path + selectAction nextArgs + main :: IO () -main = C.interact (C.concat . processLines . C.lines) +main = do + args <- getArgs + selectAction args diff --git a/remove-duplicates-from-sorted-fastq.cabal b/remove-duplicates-from-sorted-fastq.cabal index b94734b98a3b0d2bf77765e35667a7ff725c057c..dd5720667db33c124c8daa1245ad0d388f78cc83 100644 --- a/remove-duplicates-from-sorted-fastq.cabal +++ b/remove-duplicates-from-sorted-fastq.cabal @@ -16,7 +16,7 @@ name: remove-duplicates-from-sorted-fastq -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.1.0.0 +version: 0.1.1.0 -- A short (one-line) description of the package. -- synopsis: