Created
March 22, 2015 15:13
-
-
Save amonshiz/18a142a4c023d842a38f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bioinformatics.FASTA ( | |
FASTAFormatLine(..), | |
buildFASTALines, | |
buildFASTALinesWith | |
) where | |
import qualified Bioinformatics.DNANucleotide as D | |
import qualified Data.List.Split as S | |
-- type FASTAFormatLine = (String, [D.DNANucleotide]) | |
data FASTAFormatLine a = FASTAFormatLine { name :: String, | |
content :: [a] | |
} deriving (Show) | |
stringToFASTAFormat :: String -> FASTAFormatLine D.DNANucleotide | |
stringToFASTAFormat [] = FASTAFormatLine { name = "", content = [] } | |
stringToFASTAFormat xs = | |
let comps = lines xs | |
in FASTAFormatLine { name = head comps, content = map D.charToDNANucleotide . concat $ tail comps } | |
buildFASTALines :: String -> [FASTAFormatLine D.DNANucleotide] | |
buildFASTALines = map stringToFASTAFormat . S.splitOn ">" | |
stringToFASTAFormatWith :: (Char -> a) -> String -> FASTAFormatLine a | |
stringToFASTAFormatWith _ [] = FASTAFormatLine {name = "", content = [] } | |
stringToFASTAFormatWith with xs = | |
let comps = lines xs | |
in FASTAFormatLine { name = head comps, content = map with . concat $ tail comps } | |
buildFASTALinesWith :: (Char -> a) -> String -> [FASTAFormatLine a] | |
buildFASTALinesWith with = map (stringToFASTAFormatWith with) . S.splitOn ">" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment