packages feed

ClustalParser 1.1.4 → 1.2.0

raw patch · 4 files changed

+44/−40 lines, 4 filesdep +textPVP ok

version bump matches the API change (PVP)

Dependencies added: text

API changes (from Hackage documentation)

- Bio.ClustalParser: ClustalAlignment :: [ClustalAlignmentEntry] -> String -> ClustalAlignment
+ Bio.ClustalParser: ClustalAlignment :: [ClustalAlignmentEntry] -> Text -> ClustalAlignment
- Bio.ClustalParser: ClustalAlignmentEntry :: String -> String -> ClustalAlignmentEntry
+ Bio.ClustalParser: ClustalAlignmentEntry :: Text -> Text -> ClustalAlignmentEntry
- Bio.ClustalParser: ClustalSummary :: String -> String -> [SequenceParameters] -> [PairwiseAlignmentSummary] -> String -> Int -> [GroupSummary] -> Int -> String -> ClustalSummary
+ Bio.ClustalParser: ClustalSummary :: Text -> Text -> [SequenceParameters] -> [PairwiseAlignmentSummary] -> Text -> Int -> [GroupSummary] -> Int -> Text -> ClustalSummary
- Bio.ClustalParser: SequenceParameters :: Int -> String -> Int -> SequenceParameters
+ Bio.ClustalParser: SequenceParameters :: Int -> Text -> Int -> SequenceParameters
- Bio.ClustalParser: StructuralClustalAlignment :: [ClustalAlignmentEntry] -> String -> Double -> StructuralClustalAlignment
+ Bio.ClustalParser: StructuralClustalAlignment :: [ClustalAlignmentEntry] -> Text -> Double -> StructuralClustalAlignment
- Bio.ClustalParser: [alignmentFileName] :: ClustalSummary -> String
+ Bio.ClustalParser: [alignmentFileName] :: ClustalSummary -> Text
- Bio.ClustalParser: [clustalw2version] :: ClustalSummary -> String
+ Bio.ClustalParser: [clustalw2version] :: ClustalSummary -> Text
- Bio.ClustalParser: [conservationTrack] :: ClustalAlignment -> String
+ Bio.ClustalParser: [conservationTrack] :: ClustalAlignment -> Text
- Bio.ClustalParser: [entryAlignedSequence] :: ClustalAlignmentEntry -> String
+ Bio.ClustalParser: [entryAlignedSequence] :: ClustalAlignmentEntry -> Text
- Bio.ClustalParser: [entrySequenceIdentifier] :: ClustalAlignmentEntry -> String
+ Bio.ClustalParser: [entrySequenceIdentifier] :: ClustalAlignmentEntry -> Text
- Bio.ClustalParser: [guideTreeFileName] :: ClustalSummary -> String
+ Bio.ClustalParser: [guideTreeFileName] :: ClustalSummary -> Text
- Bio.ClustalParser: [inputSequenceIdentifier] :: SequenceParameters -> String
+ Bio.ClustalParser: [inputSequenceIdentifier] :: SequenceParameters -> Text
- Bio.ClustalParser: [secondaryStructureTrack] :: StructuralClustalAlignment -> String
+ Bio.ClustalParser: [secondaryStructureTrack] :: StructuralClustalAlignment -> Text
- Bio.ClustalParser: [sequenceFormat] :: ClustalSummary -> String
+ Bio.ClustalParser: [sequenceFormat] :: ClustalSummary -> Text
- Bio.ClustalParser: showAlignment :: Int -> Int -> Int -> [ClustalAlignmentEntry] -> String -> String
+ Bio.ClustalParser: showAlignment :: Int -> Int -> Int -> [ClustalAlignmentEntry] -> Text -> String
- Bio.ClustalParser: showAlignmentBlock :: Int -> Int -> [ClustalAlignmentEntry] -> String -> String
+ Bio.ClustalParser: showAlignmentBlock :: Int -> Int -> [ClustalAlignmentEntry] -> Text -> String

Files

ClustalParser.cabal view
@@ -5,7 +5,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             1.1.4+version:             1.2.0 synopsis:            Libary for parsing Clustal tools output description:         Currently contains parsers and datatypes for: clustalw2, clustalo, mlocarna, cmalign                      .@@ -36,8 +36,8 @@  source-repository this   type:     git-  location: https://github.com/eggzilla/ClustalParser/tree/1.1.4-  tag:      1.1.4+  location: https://github.com/eggzilla/ClustalParser/tree/1.2.0+  tag:      1.2.0  library   -- Modules exported by the library.@@ -45,7 +45,7 @@   other-modules:     Bio.ClustalData    -- Other library packages from which modules are imported.-  build-depends:       base >=4.5 && <5, parsec>=3.1.9, vector+  build-depends:       base >=4.5 && <5, parsec>=3.1.9, vector, text    -- compiler options   ghc-options:         -Wall -O2 -fno-warn-unused-do-bind   -- Directories containing source files.
changelog view
@@ -1,4 +1,6 @@ -*-change-log-*-+1.2.0 Florian Eggenhofer <egg@cs.uni-freiburg.de> 07. January 2017+        * Changed datastructures for sequence identifers and sequences to Data.Text 1.1.4 Florian Eggenhofer <egg@cs.uni-freiburg.de> 30. May 2016         * Fixed a bug in output of clustal alignments with sequence length of 60 1.1.3 Florian Eggenhofer <florian.eggenhofer@univie.ac.at> 4. July 2015
src/Bio/ClustalData.hs view
@@ -3,26 +3,27 @@  module Bio.ClustalData where import qualified Data.Vector as V-    +import qualified Data.Text as T+        -- | Data type for clustal summary, containing information about the alignment process, usually printed to STDOUT data ClustalSummary = ClustalSummary   {-    clustalw2version :: String,-    sequenceFormat :: String,+    clustalw2version :: T.Text,+    sequenceFormat :: T.Text,     parametersOfInputSequences :: [SequenceParameters],     pairwiseAlignmentSummaries :: [PairwiseAlignmentSummary],-    guideTreeFileName :: String,+    guideTreeFileName :: T.Text,     groupNumber :: Int,     groupSummaries :: [GroupSummary],     alignmentScore :: Int,-    alignmentFileName :: String+    alignmentFileName :: T.Text   }   deriving (Show, Eq)  data SequenceParameters = SequenceParameters   {      inputSequenceIndex :: Int,-     inputSequenceIdentifier :: String,+     inputSequenceIdentifier :: T.Text,      inputSequenceLength :: Int   }   deriving (Show, Eq)@@ -47,7 +48,7 @@ data ClustalAlignment = ClustalAlignment   {      alignmentEntries :: [ClustalAlignmentEntry],-    conservationTrack :: String+    conservationTrack :: T.Text   }   deriving (Eq) @@ -56,30 +57,30 @@     | not (null _alignmentEntries) = header ++ alignmentString     | otherwise = header     where header = "CLUSTAL W (1.8) multiple sequence alignment\n\n\n" -          longestSequenceIdLength =  (maximum (map length (map entrySequenceIdentifier _alignmentEntries))) + 1-          totalSequenceLength = length (entryAlignedSequence (head _alignmentEntries))+          longestSequenceIdLength =  (maximum (map T.length (map entrySequenceIdentifier _alignmentEntries))) + 1+          totalSequenceLength = T.length (entryAlignedSequence (head _alignmentEntries))           alignmentString = showAlignment totalSequenceLength longestSequenceIdLength 0 _alignmentEntries _conservationTrack -showAlignment :: Int -> Int -> Int -> [ClustalAlignmentEntry] -> String -> String+showAlignment :: Int -> Int -> Int -> [ClustalAlignmentEntry] -> T.Text -> String showAlignment totalSequenceLength longestSequenceIdLength currentWindowPosition _alignmentEntries _conservationTrack   | totalSequenceLength == 0 = []    | currentWindowPosition < totalSequenceLength = showAlignmentBlock longestSequenceIdLength currentWindowPosition _alignmentEntries _conservationTrack ++ (showAlignment totalSequenceLength longestSequenceIdLength (currentWindowPosition + 60) _alignmentEntries _conservationTrack)   | currentWindowPosition == totalSequenceLength = []                                                  | otherwise = ""  -showAlignmentBlock :: Int -> Int -> [ClustalAlignmentEntry] -> String -> String+showAlignmentBlock :: Int -> Int -> [ClustalAlignmentEntry] -> T.Text -> String showAlignmentBlock longestSequenceIdLength currentWindowPosition _alignmentEntries _conservationTrack = blockString   where blockString = entries ++ extraTrack ++ "\n"         entries = concatMap (showAlignmentLine longestSequenceIdLength currentWindowPosition) _alignmentEntries-        extraTrack = concat (replicate longestSequenceIdLength " ") ++ V.toList (V.slice currentWindowPosition 60  (V.fromList _conservationTrack)) ++ "\n"+        extraTrack = concat (replicate longestSequenceIdLength " ") ++ V.toList (V.slice currentWindowPosition 60  (V.fromList (T.unpack _conservationTrack))) ++ "\n"  showAlignmentLine :: Int -> Int -> ClustalAlignmentEntry -> String-showAlignmentLine longestSequenceIdLength currentWindowPosition _alignmentEntry = (entrySequenceIdentifier _alignmentEntry) ++ concat (replicate (longestSequenceIdLength - length (entrySequenceIdentifier _alignmentEntry)) " ") ++ V.toList (V.slice currentWindowPosition 60  (V.fromList (entryAlignedSequence _alignmentEntry))) ++ "\n"+showAlignmentLine longestSequenceIdLength currentWindowPosition _alignmentEntry = T.unpack (entrySequenceIdentifier _alignmentEntry) ++ concat (replicate (longestSequenceIdLength - T.length (entrySequenceIdentifier _alignmentEntry)) " ") ++ V.toList (V.slice currentWindowPosition 60  (V.fromList (T.unpack (entryAlignedSequence _alignmentEntry)))) ++ "\n"  data ClustalAlignmentEntry = ClustalAlignmentEntry   {-    entrySequenceIdentifier :: String,-    entryAlignedSequence :: String+    entrySequenceIdentifier :: T.Text,+    entryAlignedSequence :: T.Text   }   deriving (Show, Eq) @@ -102,7 +103,7 @@ data StructuralClustalAlignment = StructuralClustalAlignment   {      structuralAlignmentEntries :: [ClustalAlignmentEntry],-    secondaryStructureTrack :: String,+    secondaryStructureTrack :: T.Text,     energy :: Double   }   deriving (Eq)@@ -112,8 +113,8 @@     | not (null _alignmentEntries) = header ++ alignmentString     | otherwise = header     where header = "CLUSTAL W \n\n" -          longestSequenceIdLength =  (maximum (map length (map entrySequenceIdentifier _alignmentEntries))) + 1-          totalSequenceLength = length (entryAlignedSequence (head _alignmentEntries))+          longestSequenceIdLength =  (maximum (map T.length (map entrySequenceIdentifier _alignmentEntries))) + 1+          totalSequenceLength = T.length (entryAlignedSequence (head _alignmentEntries))           alignmentString = showAlignment totalSequenceLength longestSequenceIdLength 0 _alignmentEntries _secondaryStructureTrack  data StructuralClustalAlignmentSlice = StructuralClustalAlignmentSlice
src/Bio/ClustalParser.hs view
@@ -14,6 +14,7 @@ import Text.ParserCombinators.Parsec     import Control.Monad import Data.List+import qualified Data.Text as T  readDouble :: String -> Double readDouble = read              @@ -69,7 +70,7 @@   newline   newline   eof  -  return $ ClustalSummary version sequenceFormat' sequenceParametersList pairwiseAlignmentSummaryList guideTreeFileName' (readInt numberOfGroups) groupSummaryList (readInt alignmentScore') alignmentFileName'+  return $ ClustalSummary (T.pack version) (T.pack sequenceFormat') sequenceParametersList pairwiseAlignmentSummaryList (T.pack guideTreeFileName') (readInt numberOfGroups) groupSummaryList (readInt alignmentScore') (T.pack alignmentFileName')  genParserGroupSummary :: GenParser Char st GroupSummary genParserGroupSummary = do@@ -109,7 +110,7 @@   space   string "bp"   newline-  return $ SequenceParameters (readInt sequenceIndexParam) sequenceIdentifierParam (readInt sequenceLengthParam)+  return $ SequenceParameters (readInt sequenceIndexParam) (T.pack sequenceIdentifierParam) (readInt sequenceLengthParam)  -- | Parse the input as ClustalAlignment datatype genParserClustalAlignment :: GenParser Char st ClustalAlignment@@ -131,10 +132,10 @@         mergedAlignmentEntries = map constructAlignmentEntries (zip sequenceIdentifiers mergedAlignmentSequenceEntries)         conservationTrackSlices = map conservationTrackSlice slices         mergedConservationTrack = concat conservationTrackSlices-        alignment = ClustalAlignment mergedAlignmentEntries mergedConservationTrack+        alignment = ClustalAlignment mergedAlignmentEntries (T.pack mergedConservationTrack)  constructAlignmentEntries :: (String, String) -> ClustalAlignmentEntry-constructAlignmentEntries (entryIdentifier,entrySequence) = ClustalAlignmentEntry entryIdentifier entrySequence+constructAlignmentEntries (entryIdentifier,entrySequence) = ClustalAlignmentEntry (T.pack entryIdentifier) (T.pack entrySequence)  genParserClustalAlignmentSlice :: GenParser Char st ClustalAlignmentSlice genParserClustalAlignmentSlice = do@@ -211,10 +212,10 @@         transposedAlignmentEntriesListbySlice = transpose alignmentEntriesListBySlice         mergedAlignmentSequenceEntries = map concat transposedAlignmentEntriesListbySlice         mergedAlignmentEntries = map constructStructuralAlignmentEntries (zip sequenceIdentifiers mergedAlignmentSequenceEntries)-        alignment = StructuralClustalAlignment mergedAlignmentEntries secondaryStructure energy' +        alignment = StructuralClustalAlignment mergedAlignmentEntries (T.pack secondaryStructure) energy'   constructStructuralAlignmentEntries :: (String, String) -> ClustalAlignmentEntry-constructStructuralAlignmentEntries (entryIdentifier,entrySequence) = ClustalAlignmentEntry entryIdentifier entrySequence+constructStructuralAlignmentEntries (entryIdentifier,entrySequence) = ClustalAlignmentEntry (T.pack entryIdentifier) (T.pack entrySequence)  genParserStructuralClustalAlignmentSlice :: GenParser Char st StructuralClustalAlignmentSlice genParserStructuralClustalAlignmentSlice = do@@ -257,10 +258,10 @@ readClustalSummary = parseFromFile genParserClustalSummary  -- | Parse nucleotide sequence. Allowed letters according to IUPAC-parseNucleotideSequence :: GenParser Char st String-parseNucleotideSequence = do-  nucleotideSequence <- many1 (oneOf "RYSWKMBDHVNATUGCryswkmbdhvnatugc") -  return $ nucleotideSequence+--parseNucleotideSequence :: GenParser Char st String+--parseNucleotideSequence = do+--  nucleotideSequence <- many1 (oneOf "RYSWKMBDHVNATUGCryswkmbdhvnatugc") +--  return $ nucleotideSequence  -- | Parse nucleotide alignment entry. Allowed letters according to IUPAC and commonly used gap characters parseNucleotideAlignmentEntry :: GenParser Char st String@@ -269,13 +270,13 @@   return $ entry  -- | Parse protein amino acid code sequence. Allowed letters according to IUPAC-parseProteinSequence :: GenParser Char st String-parseProteinSequence = do-  proteinSequence <- many1 (oneOf "ABCDEFGHIKLMNPQRSTVWXYZabcdefghiklmnpqrstvwxyz") -  return $ proteinSequence+--parseProteinSequence :: GenParser Char st String+--parseProteinSequence = do+--  proteinSequence <- many1 (oneOf "ABCDEFGHIKLMNPQRSTVWXYZabcdefghiklmnpqrstvwxyz") +--  return $ proteinSequence  -- | Parse protein amino acid code alignment entry. Allowed letters according to IUPAC and commonly used gap characters-parseProteinAlignmentEntry :: GenParser Char st String-parseProteinAlignmentEntry = do-  entry <- many1 (oneOf "~_-.ABCDEFGHIKLMNPQRSTVWXYZabcdefghiklmnpqrstvwxyz") -  return $ entry+--parseProteinAlignmentEntry :: GenParser Char st String+--parseProteinAlignmentEntry = do+--  entry <- many1 (oneOf "~_-.ABCDEFGHIKLMNPQRSTVWXYZabcdefghiklmnpqrstvwxyz") +--  return $ entry