From c10cfb984d3a0881458018325e2b95219ed16829 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 29 Jul 2021 17:03:11 +1000 Subject: add readme and more friendlier usage instructions --- README | 23 +++++++++++++++++++++++ xenomapper.hs | 9 ++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..87b50ee --- /dev/null +++ b/README @@ -0,0 +1,23 @@ +This is a reimplementation of Xenomapper [1] in Haskell. Unlike the +orginal it is significantly more focused in scope: only primary specific +alignments are output. + +Example usage: "xenomapper-hs primary-specific.bam primary.bam secondary.bam" + +The first argument is the output bam path, and the subsequent are the +primary and secondary alignments. NB: the inputs must be name sorted +and the output will be name sorted. + +Building the binary requires a flake enabled Nix [2]. Run + + nix build git://vk3.wtf/xenomapper-hs.git + +to build, or if you have already cloned the repository then simply + + nix build + +in the root. + +-- +1: https://github.com/genomematt/xenomapper +2: https://nixos.org/Nix diff --git a/xenomapper.hs b/xenomapper.hs index 123b1a5..4546ab2 100644 --- a/xenomapper.hs +++ b/xenomapper.hs @@ -36,6 +36,9 @@ filterBams a b = do main = do args <- getArgs - - withLogging_ (LoggingConf Warning Error Error 10 True) $ do - decodeBamFiles args (\[(hdr, prim), (_, sec)] -> writeBamFile "primary.bam" hdr $ filterBams prim sec) + if length args /= 3 then do + path <- getProgName + hPutStrLn stderr $ unwords [ "usage:", path, "output.bam", "input1.bam", "input2.bam" ] + else + withLogging_ (LoggingConf Warning Error Error 10 True) $ do + decodeBamFiles (tail args) (\[(hdr, prim), (_, sec)] -> writeBamFile (head args) hdr $ filterBams prim sec) -- cgit v1.2.3