modify-fasta 0.8.2.0 → 0.8.2.1
raw patch · 4 files changed
+33/−14 lines, 4 files
Files
- app/Main.hs +28/−3
- modify-fasta.cabal +1/−1
- src/Print.hs +2/−4
- src/Utility.hs +2/−6
app/Main.hs view
@@ -38,6 +38,8 @@ , legacyFlag :: Bool , clipFastaFlag :: Bool , convertToAminoAcidsFlag :: Bool+ , complementFlag :: Bool+ , reverseComplementFlag :: Bool , inputCodonTable :: CodonTable , inputFillIn :: FillInValue , inputStart :: Maybe Int@@ -104,6 +106,14 @@ <> short 'C' <> help "Whether to convert the filtered sequences to amino acids\ \ in the output. Applied last, even after add length." )+ <*> switch+ ( long "complement"+ <> short 'b'+ <> help "Whether to find the complement of the sequence." )+ <*> switch+ ( long "reverse-complement"+ <> short 'B'+ <> help "Whether to to find the reverse complement of the sequence." ) <*> option auto ( long "codon-table" <> metavar "[(CODON, AA)]"@@ -396,8 +406,8 @@ if trimFrame opts then trimFasta genUnit- ((read . T.unpack . flip getField fs) <$> inputInFrame opts)- ((read . T.unpack . flip getField fs) <$> inputOutFrame opts)+ ((\x -> read . T.unpack . getField x '|' $ fs) <$> inputInFrame opts)+ ((\x -> read . T.unpack . getField x '|' $ fs) <$> inputOutFrame opts) fs else fs @@ -414,7 +424,17 @@ (-1, -1, 'X') -> id (f, s, c) -> fillInSequence f s c + -- Find the complement+ complement = if complementFlag opts+ then compl+ else id+ -- Convert to amino acids+ reverseComplement = if reverseComplementFlag opts+ then revCompl+ else id++ -- Convert to amino acids ntToaa = if convertToAminoAcidsFlag opts then convertToAminoAcidsFastaSequence (inputCodonTable opts) else id@@ -452,6 +472,8 @@ transformOrder = includeLength . includeMutations . ntToaa+ . reverseComplement+ . complement . changeHeader . removeUnknown . trim@@ -464,6 +486,8 @@ transformGermline = includeLength . includeMutations . ntToaa+ . reverseComplement+ . complement . removeUnknown . trim . noNs@@ -660,7 +684,8 @@ \ Order of transformation goes: seqInFrame -> customFilter\ \ -> noStops -> removeHighMutations -> getMutations ->\ \ getFrequentMutations -> cutSequence -> fillIn -> noNs\- \ -> changeHeader -> ntToaa -> includeLength,\+ \ -> changeHeader -> complement -> reverseComplement ->\+ \ ntToaa -> includeLength,\ \ so if you require a different\ \ order (which can change results dramatically), then do\ \ so one at a time through the wonderful world of piping."
modify-fasta.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: modify-fasta-version: 0.8.2.0+version: 0.8.2.1 synopsis: Modify fasta (and CLIP) files in several optional ways -- description: homepage: https://github.com/GregorySchwartz/modify-fasta
src/Print.hs view
@@ -80,10 +80,8 @@ $ geneAlleleList alleleMap = M.fromListWith (+) geneAlleleList geneAlleleList = map (countProp clip) . M.toAscList $ s- countProp True ((_, x), y) = (getField idx x, length y)- countProp False ((_, _), y) = (getField idx . head $ y, 1)- getField f h = splitHeader h !! (f - 1)- splitHeader = T.splitOn "|" . fastaHeader+ countProp True ((_, x), y) = (getField idx '|' x, length y)+ countProp False ((_, _), y) = (getField idx '|' . head $ y, 1) -- | Takes a clone entry and returns a formatted text with or without -- germline
src/Utility.hs view
@@ -9,7 +9,6 @@ , addMutationsHeader , addFillerGermlines , replaceChars- , getField , fromEither ) where @@ -45,7 +44,8 @@ } where germline = if aaFlag then fromEither (translate 1 otherSeq) else otherSeq- otherSeq = FastaSequence {fastaHeader = "", fastaSeq = getField field fSeq}+ otherSeq =+ FastaSequence { fastaHeader = "", fastaSeq = getField field '|' fSeq } -- | Print the mutations printMutations :: [(Position, (Char, Char))] -> T.Text@@ -100,10 +100,6 @@ changeChar a b = if a == c && (not . T.isInfixOf (T.singleton b)) ".-" then b else a---- | Get the field of a fasta sequence, 1 indexed split by "|"-getField :: Int -> FastaSequence -> T.Text-getField f fs = (T.splitOn "|" . fastaHeader $ fs) !! (f - 1) -- | Error for left fromEither :: Either T.Text b -> b