packages feed

TaxonomyTools 1.0.0 → 1.0.1

raw patch · 4 files changed

+41/−33 lines, 4 filesdep +textdep ~EntrezHTTPdep ~Taxonomydep ~cassava

Dependencies added: text

Dependency ranges changed: EntrezHTTP, Taxonomy, cassava

Files

TaxonomyTools.cabal view
@@ -5,7 +5,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             1.0.0+version:             1.0.1 synopsis:            Tool for parsing, processing, comparing and visualizing taxonomy data description:         Taxonomy Tool utilizes functions from the Taxonomy library to provide                      .@@ -53,32 +53,32 @@  source-repository this   type:     git-  location: https://github.com/eggzilla/TaxonomyTools/tree/1.0.0-  tag:      1.0.0+  location: https://github.com/eggzilla/TaxonomyTools/tree/1.0.1+  tag:      1.0.1  executable TaxIds2Text   Hs-Source-Dirs:      ./src/Bio/   main-is:	       TaxIds2Text.hs   ghc-options:         -Wall -O2-  build-depends:       base >=4.5 && <5, cmdargs, Taxonomy, either-unwrap, fgl, bytestring+  build-depends:       base >=4.5 && <5, cmdargs, Taxonomy>=1.0.2, either-unwrap, fgl, text  executable Accessions2TaxIds   Hs-Source-Dirs:      ./src/Bio/   main-is:	       Accessions2TaxIds.hs   ghc-options:         -Wall -O2 -fno-warn-unused-do-bind-  build-depends:       base >=4.5 && <5, cmdargs, process, directory, Taxonomy, either-unwrap, fgl, cassava, vector, bytestring, parsec, EntrezHTTP, hxt+  build-depends:       base >=4.5 && <5, cmdargs, process, directory, Taxonomy>=1.0.2, either-unwrap, fgl, cassava>=0.4.5.1, vector, bytestring, parsec, EntrezHTTP>=1.0.2, hxt  executable TaxIds2TreeCompare   Hs-Source-Dirs:      ./src/Bio/   main-is:	       TaxIds2TreeCompare.hs   ghc-options:         -Wall -O2    -  build-depends:       base >=4.5 && <5, cmdargs, process, directory, Taxonomy, either-unwrap, fgl, cassava, vector, bytestring+  build-depends:       base >=4.5 && <5, cmdargs, process, directory, Taxonomy>=1.0.2, either-unwrap, fgl, cassava>=0.4.5.1, vector, bytestring  executable TaxIds2Tree   Hs-Source-Dirs:      ./src/Bio/   main-is:	       TaxIds2Tree.hs   ghc-options:         -Wall -O2 -  build-depends:       base >=4.5 && <5, cmdargs, process, directory, Taxonomy, either-unwrap, fgl, cassava, vector, bytestring, aeson+  build-depends:       base >=4.5 && <5, cmdargs, process, directory, Taxonomy>=1.0.2, either-unwrap, fgl, cassava>=0.4.5.1, vector, bytestring, aeson  executable TaxIdsDistance   Hs-Source-Dirs:      ./src/Bio/
src/Bio/TaxIds2Text.hs view
@@ -7,7 +7,7 @@      import System.Console.CmdArgs     import Data.Either.Unwrap-import qualified Data.ByteString.Char8 as BC+import qualified Data.Text.Lazy as TL import Bio.Taxonomy import Data.Maybe import Text.Read@@ -49,7 +49,7 @@              mapM_ putStrLn outputCSV  printSimpleNode :: SimpleTaxon -> String -printSimpleNode snode = show (simpleRank snode) ++ "," ++ BC.unpack (simpleScientificName snode)+printSimpleNode snode = show (simpleRank snode) ++ "," ++ TL.unpack (simpleScientificName snode)  readMaybeRank :: String -> Maybe Rank readMaybeRank inputString = readMaybe inputString
src/Bio/TaxIds2Tree.hs view
@@ -23,6 +23,7 @@     alienCSVFilePath ::String,     levels :: Int,     outputFormat :: String,+    withRank :: Bool,     outputDirectoryPath :: String   } deriving (Show,Data,Typeable) @@ -33,8 +34,9 @@     alienCSVFilePath = def &= name "r" &= help "Path to RNAlienResult CSV. Alternative to input taxonomy id list",     levels = (1 ::Int) &= name "l" &= help "Number defining maximum distance from root for nodes in subtree.",     outputFormat = "dot" &= name "f" &= help "Requested output format (json,dot). Default: dot",+    withRank = True &= name "w" &= help "Add taxonomic ranks to output. Default: True",         outputDirectoryPath = def &= name "o" &= help "Path to output directory"-  } &= summary "TaxIds2Tree -  List of taxonomy ids is converted into a graphical tree representation either as .svg (via graphviz) or as .json (via d3js)" &= help "Florian Eggenhofer - 2015" &= verbosity   +  } &= summary "TaxIds2Tree -  List of taxonomy ids is converted into a graphical tree representation either as .svg (via graphviz) or as .json (via d3js)" &= help "Florian Eggenhofer - 2016" &= verbosity     main :: IO () main = do@@ -48,34 +50,36 @@               putStrLn "Provide a path to input taxonomy id list or to RNAlienResult CSV."               else                do -- input AlienCSV path present-                taxidtableentries <- extractTaxidsAlienCSV alienCSVFilePath-                let graph = fromRight graphOutput-                let currentSubgraph = extractTaxonomySubTreebyLevel taxidtableentries graph (Just levels)                -                --let subdiagram = drawTaxonomy (grev currentSubgraph)-                --writeFile (outputDirectoryPath ++ "taxonomy.dot") subdiagram-                generateOutput outputFormat outputDirectoryPath currentSubgraph+                 decodedCsvOutput <- extractTaxidsAlienCSV alienCSVFilePath+                 if (isRight decodedCsvOutput)+                   then do+                       let decodedCsvList = (fromRight decodedCsvOutput)+                       let taxidtableentries = V.map firstOfTaxCSVTriple decodedCsvList+                       let graph = fromRight graphOutput+                       let currentSubgraph = extractTaxonomySubTreebyLevelNew (V.toList taxidtableentries) graph (Just levels)                +                       generateOutput outputFormat outputDirectoryPath withRank currentSubgraph+                     else do+                      writeFile (outputDirectoryPath ++ "taxonomy.json") (show (fromLeft decodedCsvOutput))          else           do -- input taxid path present             taxidtable <- readFile taxNodeListFilePath             let taxidtableentries = map (\l -> read l :: Int) (lines taxidtable)             let graph = fromRight graphOutput-            let currentSubgraph  = extractTaxonomySubTreebyLevel taxidtableentries graph (Just levels)                -            --let subdiagram = drawTaxonomy (grev currentSubgraph)-            --writeFile (outputDirectoryPath ++ "taxonomy.dot") subdiagram-            generateOutput outputFormat outputDirectoryPath currentSubgraph+            let currentSubgraph  = extractTaxonomySubTreebyLevel taxidtableentries graph (Just levels)+            writeTree outputFormat outputDirectoryPath withRank currentSubgraph  -- | generate output-generateOutput :: String -> String -> Gr SimpleTaxon Double -> IO ()-generateOutput requestedFormat outputDirectoryPath inputGraph = do+generateOutput :: String -> String -> Bool -> Gr SimpleTaxon Double -> IO ()+generateOutput requestedFormat outputDirectoryPath withRank inputGraph = do   case requestedFormat of-    "dot" -> generateDotOutput outputDirectoryPath inputGraph+    "dot" -> generateDotOutput outputDirectoryPath withRank inputGraph     "json" -> generateJsonOutput outputDirectoryPath inputGraph-    _ -> generateDotOutput outputDirectoryPath inputGraph+    _ -> generateDotOutput outputDirectoryPath withRank inputGraph  -generateDotOutput :: String -> Gr SimpleTaxon Double -> IO ()-generateDotOutput outputDirectoryPath inputGraph = do-  let diagram = drawTaxonomy (grev inputGraph)+generateDotOutput :: String -> Bool -> Gr SimpleTaxon Double -> IO ()+generateDotOutput outputDirectoryPath withRank inputGraph = do+  let diagram = drawTaxonomy withRank (grev inputGraph)   writeFile (outputDirectoryPath ++ "taxonomy.dot") diagram    @@ -86,12 +90,14 @@   -- | Extract taxids from RNAlien result.csv -extractTaxidsAlienCSV :: String -> IO [Node]+extractTaxidsAlienCSV :: String -> IO (Either String (V.Vector (Int,L.ByteString,L.ByteString))) extractTaxidsAlienCSV alienCSVPath = do   let myOptions = defaultDecodeOptions {          decDelimiter = fromIntegral (ord ';')          }   inputCSV <- L.readFile alienCSVPath-  let decodedCsvOutput = V.toList (fromRight (decodeWith myOptions HasHeader inputCSV :: Either String (V.Vector (Int,L.ByteString,L.ByteString))))-  let taxnodes = map (\(a,_,_) -> a :: Node) decodedCsvOutput-  return taxnodes +  let decodedCsvOutput = decodeWith myOptions HasHeader inputCSV :: Either String (V.Vector (Int,L.ByteString,L.ByteString))+  return decodedCsvOutput++firstOfTaxCSVTriple :: (Int, L.ByteString, L.ByteString) -> Node+firstOfTaxCSVTriple (a,_,_) = a
src/Bio/TaxIds2TreeCompare.hs view
@@ -19,7 +19,8 @@ data Options = Options               { taxDumpDirectoryPath :: String,     taxNodeCSVFilePath :: String,-    levels :: Int,                      +    levels :: Int,+    withRank :: Bool,     outputDirectoryPath :: String   } deriving (Show,Data,Typeable) @@ -28,6 +29,7 @@   { taxDumpDirectoryPath = def &= name "i" &= help "Path to input NCBI taxonomy dump files directory",     taxNodeCSVFilePath = def &= name "t" &= help "Path to input taxonomy csv, each column with comma separated taxids represents one tree",     levels = (1 ::Int) &= name "l" &= help "Number defining maximum distance from root for nodes in subtree.",+    withRank = True &= name "w" &= help "Add taxonomic ranks to output. Default: True",     outputDirectoryPath = def &= name "o" &= help "Path to output directory"   } &= summary "TaxIds2TreeCompare - Multiple lists of taxonomy ids are converted into a visualisation of the taxonomic tree highlighting the input nodes corresponding to their list." &= help "Florian Eggenhofer - 2015" &= verbosity    @@ -43,7 +45,7 @@        treesTaxids <- extractTreesTaxidsCSV taxNodeCSVFilePath        let subgraphs  = map (\treeTaxids -> extractTaxonomySubTreebyLevel treeTaxids graph (Just levels)) treesTaxids        let comparisonGraph = compareSubTrees subgraphs-       let treeComparison = drawTreeComparison comparisonGraph+       let treeComparison = drawTaxonomyComparison withRank comparisonGraph        writeFile (outputDirectoryPath ++ "comparison.dot") treeComparison        -- | Extract taxids from RNAlien result.csv