modify-fasta 0.8.0.3 → 0.8.0.4
raw patch · 8 files changed
+23/−66 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Diversity: choose :: (Integral a) => a -> a -> a
- Diversity: diversity :: (Ord b) => Double -> [b] -> Double
- Diversity: rarefactionCurve :: (Eq a, Ord a) => [a] -> [Double]
- Diversity: rarefactionViable :: [Double] -> Double
Files
- modify-fasta.cabal +1/−1
- src/Diversity.hs +1/−44
- src/FilterCloneList.hs +1/−1
- src/FilterCloneMap.hs +10/−10
- src/FilterFastaList.hs +3/−3
- src/Print.hs +2/−2
- src/TransformCloneList.hs +2/−2
- src/Utility.hs +3/−3
modify-fasta.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: modify-fasta-version: 0.8.0.3+version: 0.8.0.4 synopsis: Modify fasta (and CLIP) files in several optional ways -- description: homepage: https://github.com/GregorySchwartz/modify-fasta
src/Diversity.hs view
@@ -9,49 +9,6 @@ import Data.List import qualified Data.Text as T --- Takes two strings, returns Hamming distance+-- | Takes two strings, returns Hamming distance hamming :: T.Text -> T.Text -> Int hamming xs ys = length $ filter (not . uncurry (==)) $ T.zip xs ys---- Returns the diversity of a list of things-diversity :: (Ord b) => Double -> [b] -> Double-diversity order sample- | length sample == 0 = 0- | order == 1 = exp . h $ speciesList- | otherwise = (sum . map ((** order) . p_i) $ speciesList) ** pow- where- pow = 1 / (1 - order)- h = negate . sum . map (\x -> (p_i x) * (log (p_i x)))- p_i x = ((fromIntegral . length $ x) :: Double) /- ((fromIntegral . length $ sample) :: Double)- speciesList = group . sort $ sample---- Calculates the binary coefficient-choose :: (Integral a) => a -> a -> a-choose _ 0 = 1-choose 0 _ = 0-choose n k = choose (n - 1) (k - 1) * n `div` k---- Returns the rarefaction curve for each position in a list-rarefactionCurve :: (Eq a, Ord a) => [a] -> [Double]-rarefactionCurve xs = map rarefact [1..n_total]- where- rarefact n- | n == 0 = 0- | n == 1 = 1- | n == n_total = k- | otherwise = k - ((1 / (fromIntegral (choose n_total n))) * inner n)- inner n = fromIntegral .- sum .- map (\g -> choose (n_total - length g) n) $- grouped- n_total = length xs- k = genericLength grouped- grouped = group . sort $ xs---- Calculates the percent of the curve that is above 95% of height of the curve-rarefactionViable :: [Double] -> Double-rarefactionViable xs = (genericLength valid / genericLength xs) * 100- where- valid = dropWhile (< (0.95 * last xs)) xs-
src/FilterCloneList.hs view
@@ -22,7 +22,7 @@ -- Local import Types --- Remove highly mutated sequences (sequences with more than a third of+-- | Remove highly mutated sequences (sequences with more than a third of -- their sequence being mutated). filterHighlyMutatedEntry :: GeneticUnit -> CloneEntry -> CloneEntry filterHighlyMutatedEntry !genUnit = newEntry
src/FilterCloneMap.hs view
@@ -25,17 +25,17 @@ import Types import Diversity --- Check if the data structure is Right+-- | Check if the data structure is Right isRight' :: Either a b -> Bool isRight' (Right _) = True isRight' _ = False --- Altered version of listToMaybe+-- | Altered version of listToMaybe listToMaybe' :: [a] -> Maybe [a] listToMaybe' [] = Nothing listToMaybe' x = Just x --- Remove highly mutated sequences (sequences with more than a third of+-- | Remove highly mutated sequences (sequences with more than a third of -- their sequence being mutated). filterHighlyMutated :: GeneticUnit -> CloneMap -> (CloneMap, Maybe String) filterHighlyMutated !genUnit !cloneMap = (newCloneMap, errorString)@@ -86,7 +86,7 @@ readSeq Nucleotide x = Right x readSeq AminoAcid x = translate 1 x --- Replace codons that have more than CodonMut mutations (make them "---"+-- | Replace codons that have more than CodonMut mutations (make them "---" -- codons). removeCodonMutCount :: CodonMut -> T.Text -> T.Text -> CloneMap -> CloneMap removeCodonMutCount codonMut codonMutType mutType = M.mapWithKey mapRemove@@ -112,7 +112,7 @@ isMutType "SILENT" x y = codon2aa x == codon2aa y isMutType _ _ _ = True --- Remove clone sequences that have stop codons in the first stopRange+-- | Remove clone sequences that have stop codons in the first stopRange -- codons removeStopsCloneMap :: GeneticUnit -> Int@@ -148,7 +148,7 @@ fromEither (Right x) = x fromEither (Left x) = error (T.unpack x) --- Remove duplicate sequences+-- | Remove duplicate sequences removeDuplicatesCloneMap :: CloneMap -> CloneMap removeDuplicatesCloneMap cloneMap = M.map (filter (`S.member` duplicateSet))@@ -160,7 +160,7 @@ . M.toAscList $ cloneMap --- Remove out of frame sequences+-- | Remove out of frame sequences removeOutOfFrameSeqs :: CloneMap -> CloneMap removeOutOfFrameSeqs = M.map (filter isInFrame) where@@ -170,7 +170,7 @@ . T.filter (\x -> not $ T.isInfixOf (T.singleton x) ".-") . fastaSeq --- Remove sequences that do not contain the string customFilter in the+-- | Remove sequences that do not contain the string customFilter in the -- customField location, split by "|". Note that this is 1 indexed and -- 0 means to search the entire header for the customFilter. If the -- customRemove option is enabled, this function will instead remove@@ -210,11 +210,11 @@ where filterMap acc (x, y) = removeCustomFilter germ rm x y acc --- Remove clones that do not have any sequences after the filtrations+-- | Remove clones that do not have any sequences after the filtrations removeEmptyClone :: CloneMap -> CloneMap removeEmptyClone = M.filter (not . null) --- Convert sequences to amino acids+-- | Convert sequences to amino acids convertToAminoAcidsCloneMap :: CloneMap -> (CloneMap, Maybe String) convertToAminoAcidsCloneMap cloneMap = (newCloneMap, errorString) where
src/FilterFastaList.hs view
@@ -24,7 +24,7 @@ -- Local import Types --- Remove clone sequences that have stop codons in the first stopRange+-- | Remove clone sequences that have stop codons in the first stopRange -- codons hasNoStops :: GeneticUnit -> Int@@ -41,7 +41,7 @@ . translate 1 stop AminoAcid = Right . not . T.isInfixOf "*" . T.take stopRange . fastaSeq --- Remove out of frame sequences+-- | Remove out of frame sequences isInFrame :: FastaSequence -> Bool isInFrame = (== 0) . mod 3@@ -49,7 +49,7 @@ . T.filter (\x -> not . T.isInfixOf (T.singleton x) $ ".-") . fastaSeq --- Remove sequences that do not contain the string customFilter in the+-- | Remove sequences that do not contain the string customFilter in the -- customField location, split by "|". Note that this is 1 indexed and -- 0 means to search the entire header for the customFilter. If the -- customRemove option is enabled, this function will instead remove
src/Print.hs view
@@ -20,7 +20,7 @@ -- Local import Types --- Return the results of the filtration in text form for saving+-- | Return the results of the filtration in text form for saving -- to a file printFasta :: CloneMap -> T.Text printFasta = body@@ -37,7 +37,7 @@ , z ] --- Return the results of the filtration in text form for saving+-- | Return the results of the filtration in text form for saving -- to a file and excluding germline printFastaNoGermline :: CloneMap -> T.Text printFastaNoGermline = body
src/TransformCloneList.hs view
@@ -31,7 +31,7 @@ noGaps :: T.Text -> Bool noGaps = not . any (\x -> x == '.' || x == '-') . T.unpack --- Replace codons that have more than CodonMut mutations (make them "---"+-- | Replace codons that have more than CodonMut mutations (make them "---" -- codons) and don't have gaps in them. onlyMutations :: CodonMut -> T.Text -> T.Text -> CloneEntry -> CloneEntry onlyMutations codonMut codonMutType mutType = newEntry@@ -61,7 +61,7 @@ isMutType "ALL" _ _ = True isMutType _ _ _ = error "Unknown mutation type" --- Only include codons containing mutations found in a certain number of+-- | Only include codons containing mutations found in a certain number of -- mutants frequentMutations :: Maybe Int -> Maybe Int
src/Utility.hs view
@@ -34,7 +34,7 @@ insertDummy x = (dummy, [x]) dummy = FastaSequence {fastaHeader = "filler", fastaSeq = "---"} --- Like zipWith, but if one if one list is longer than the other than use+-- | Like zipWith, but if one if one list is longer than the other than use -- the remaining, needs to be the same type zipWithRetain :: (a -> a -> a) -> [a] -> [a] -> [a] zipWithRetain _ [] [] = []@@ -42,7 +42,7 @@ zipWithRetain _ [] ys = ys zipWithRetain f (x:xs) (y:ys) = f x y : zipWithRetain f xs ys --- Like zipWithRetain, but for text+-- | Like zipWithRetain, but for text zipWithRetainText :: (Char -> Char -> Char) -> T.Text -> T.Text -> T.Text zipWithRetainText _ (T.uncons -> Nothing) (T.uncons -> Nothing) = T.empty zipWithRetainText _ xs (T.uncons -> Nothing) = xs@@ -50,7 +50,7 @@ zipWithRetainText f (T.uncons -> Just (x, xs)) (T.uncons -> Just (y, ys)) = f x y `T.cons` zipWithRetainText f xs ys --- Replace characters in the first string with another in the second string+-- | Replace characters in the first string with another in the second string -- if they are equal to a certain character and they aren't replaced with -- a gap. replaceChars :: Char -> T.Text -> T.Text -> T.Text