diversity 0.6.3.0 → 0.7.0.0
raw patch · 3 files changed
+30/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Math.Diversity.GenerateDiversity: generatePositionMap :: Bool -> Int -> Bool -> Window -> FastaSequence -> PositionMap
+ Math.Diversity.GenerateDiversity: generatePositionMap :: Bool -> Int -> Int -> Bool -> Window -> FastaSequence -> PositionMap
Files
- diversity.cabal +1/−1
- src/src-exec/Main.hs +14/−1
- src/src-lib/Math/Diversity/GenerateDiversity.hs +15/−6
diversity.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: diversity-version: 0.6.3.0+version: 0.7.0.0 synopsis: Return the diversity at each position for all sequences in a fasta file description: Find the diversity of a collection of entities, mainly for use with fasta sequences. Produces a binary which works on fasta files to find the diversity of any order and rarefaction curves for a sliding window across all positions in the sequences. To analyze just a collection of entities, just use the whole sequences and list flag. homepage: https://github.com/GregorySchwartz/diversity
src/src-exec/Main.hs view
@@ -28,6 +28,7 @@ , inputWindow :: Int , inputFasta :: String , inputSampleField :: Int+ , inputCountField :: Int , inputSubsampling :: String , inputG :: Double , fastBin :: Bool@@ -78,6 +79,17 @@ <> value 1 <> help "The index for the sample ID in the header separated by '|'\ \ (1 indexed)" )+ <*> option auto+ ( long "input-count-field"+ <> short 'C'+ <> metavar "INT"+ <> value 0+ <> help "The index for the number of this type in the header separated\+ \ by '|' (1 indexed). Used if there are multiple copies\+ \ of one entry, so a '4' in the header would indicate that\+ \ this entity occurred 4 times. Defaults to 0, meaning that\+ \ this field is ignored and count each sequence as occurring\+ \ just once" ) <*> strOption ( long "input-subsampling" <> short 'I'@@ -168,7 +180,7 @@ <> metavar "FILE" <> value "" <> help "The csv file containing the diversities at each position.\- \ expects a string, so you need a string wven with std" )+ \ expects a string, so you need a string even with std" ) parseSampling :: (Num a, Read a) => String -> [a] parseSampling = map read . parsing . words@@ -188,6 +200,7 @@ >-> P.map ( generatePositionMap (sample opts) (inputSampleField opts)+ (inputCountField opts) (wholeSeq opts) (inputWindow opts) . removals )
src/src-lib/Math/Diversity/GenerateDiversity.hs view
@@ -23,10 +23,15 @@ -- Local import Math.Diversity.Types --- | Get the sample ID of a sequence-getSample :: Int -> FastaSequence -> Sample-getSample x = (!! (x - 1)) . Split.splitOn "|" . fastaHeader+-- | Get the field of a fasta sequence header+getField :: Int -> FastaSequence -> String+getField x = (!! (x - 1)) . Split.splitOn "|" . fastaHeader +-- | Get the count field of a fasta sequence header+getCount :: Int -> FastaSequence -> Int+getCount 0 = const 1+getCount x = read . getField x+ -- | Generates fragment list from string of "win" length. This version -- differs from normal as it takes a tuple with the position as the first -- entry. Is in tail recursive form@@ -46,19 +51,23 @@ -- | Generate the frequency from a FastaSequence generatePositionMap :: Bool -> Int+ -> Int -> Bool -> Window -> FastaSequence -> PositionMap-generatePositionMap !sample !sampleField !whole !win = posSeqList+generatePositionMap !sample !sampleField !countField !whole !win = posSeqList where posSeqList !x = Map.fromList- . map (\(!p, !f) -> (p, Map.singleton (sampleIt sample x f) 1))+ . map ( \(!p, !f) -> ( p+ , Map.singleton (sampleIt sample x f)+ . getCount countField+ $ x ) ) . fragmentPos whole win . filter (noGaps . snd) . zip [1..] . fastaSeq $ x noGaps y = y /= '-' && y /= '.'- sampleIt True !s !f = (getSample sampleField s, f)+ sampleIt True !s !f = (getField sampleField s, f) sampleIt False _ !f = ("Sample", f)