packages feed

ClustalParser 1.2.0 → 1.2.1

raw patch · 5 files changed

+58/−51 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Bio.ClustalParser: StructuralClustalAlignmentSlice :: [StructuralClustalAlignmentEntrySlice] -> StructuralClustalAlignmentSlice
- Bio.ClustalParser: [structuralEntrySlices] :: StructuralClustalAlignmentSlice -> [StructuralClustalAlignmentEntrySlice]
- Bio.ClustalParser: data StructuralClustalAlignmentSlice

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.2.0+version:             1.2.1 synopsis:            Libary for parsing Clustal tools output description:         Currently contains parsers and datatypes for: clustalw2, clustalo, mlocarna, cmalign                      .@@ -18,7 +18,7 @@                      Cmalign is a multiple sequence alignment program based on RNA family models and produces                      ,among others, clustal output. It is part of infernal <http://infernal.janelia.org/>.                      -license:             GPL+license:             GPL-3.0 license-file:        LICENSE author:              Florian Eggenhofer maintainer:          egg@tbi.univie.ac.at@@ -36,8 +36,8 @@  source-repository this   type:     git-  location: https://github.com/eggzilla/ClustalParser/tree/1.2.0-  tag:      1.2.0+  location: https://github.com/eggzilla/ClustalParser/tree/1.2.1+  tag:      1.2.1  library   -- Modules exported by the library.@@ -58,7 +58,7 @@   ghc-options:         -Wall -O2  test-suite hspec-    build-depends:    base, parsec, ClustalParser, hspec >= 1.8+    build-depends:    base, parsec, ClustalParser, hspec >= 1.8, text     hs-source-dirs:   test-suite     main-is:          Spec.hs     type:             exitcode-stdio-1.0  
ClustalParserTest.hs view
@@ -1,7 +1,9 @@+--runghc -package-db --ghc-arg=.cabal-sandbox/x86_64-linux-ghc-8.0.1-packages.conf.d  ClustalParserTest.hs struct-multiline.mlocarna module Main where      import System.Environment (getArgs) import Bio.ClustalParser+--import Data.Either.Unwrap  main :: IO () main = do@@ -10,4 +12,5 @@   -- read Clustal outputfile   parsedinput <- readStructuralClustalAlignment input_file   print parsedinput+  --print $ structuralAlignmentEntries (fromRight parsedinput)  
changelog view
@@ -1,4 +1,6 @@ -*-change-log-*-+1.2.1 Florian Eggenhofer <egg@cs.uni-freiburg.de> 06. February 2017+        * Structural alignment parser now works with multiline consensus structures 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
src/Bio/ClustalData.hs view
@@ -66,7 +66,7 @@   | totalSequenceLength == 0 = []    | currentWindowPosition < totalSequenceLength = showAlignmentBlock longestSequenceIdLength currentWindowPosition _alignmentEntries _conservationTrack ++ (showAlignment totalSequenceLength longestSequenceIdLength (currentWindowPosition + 60) _alignmentEntries _conservationTrack)   | currentWindowPosition == totalSequenceLength = []                                               -  | otherwise = "" +  | otherwise = ""  showAlignmentBlock :: Int -> Int -> [ClustalAlignmentEntry] -> T.Text -> String showAlignmentBlock longestSequenceIdLength currentWindowPosition _alignmentEntries _conservationTrack = blockString@@ -92,12 +92,12 @@   deriving (Show, Eq)  data ClustalAlignmentEntrySlice = ClustalAlignmentEntrySlice-  {-    entrySequenceSliceIdentifier :: String,-    entryAlignedSliceSequence :: String,-    spacerLength :: Int-  }-  deriving (Show, Eq)+   {+     entrySequenceSliceIdentifier :: String,+     entryAlignedSliceSequence :: String,+     spacerLength :: Int+   }+   deriving (Show, Eq)  -- | Data structure for structural Clustal alignment format data StructuralClustalAlignment = StructuralClustalAlignment@@ -117,11 +117,11 @@           totalSequenceLength = T.length (entryAlignedSequence (head _alignmentEntries))           alignmentString = showAlignment totalSequenceLength longestSequenceIdLength 0 _alignmentEntries _secondaryStructureTrack -data StructuralClustalAlignmentSlice = StructuralClustalAlignmentSlice-  {-    structuralEntrySlices :: [StructuralClustalAlignmentEntrySlice]-  }-  deriving (Show, Eq)+-- data StructuralClustalAlignmentSlice = StructuralClustalAlignmentSlice+--   {+--     structuralEntrySlices :: [StructuralClustalAlignmentEntrySlice]+--   }+--   deriving (Show, Eq)  data StructuralClustalAlignmentEntrySlice = StructuralClustalAlignmentEntrySlice   {
src/Bio/ClustalParser.hs view
@@ -15,7 +15,6 @@ import Control.Monad import Data.List import qualified Data.Text as T- readDouble :: String -> Double readDouble = read               @@ -124,18 +123,17 @@  mergealignmentSlices :: [ClustalAlignmentSlice] -> ClustalAlignment mergealignmentSlices slices = alignment-  where entrySlicesList = map entrySlices slices -- list of lists of entry slices-        sequenceIdentifiers = nub (map entrySequenceSliceIdentifier (head entrySlicesList))-        alignmentEntriesListBySlice =  map (map entryAlignedSliceSequence) entrySlicesList  -        transposedAlignmentEntriesListbySlice = transpose alignmentEntriesListBySlice-        mergedAlignmentSequenceEntries = map concat transposedAlignmentEntriesListbySlice-        mergedAlignmentEntries = map constructAlignmentEntries (zip sequenceIdentifiers mergedAlignmentSequenceEntries)-        conservationTrackSlices = map conservationTrackSlice slices-        mergedConservationTrack = concat conservationTrackSlices-        alignment = ClustalAlignment mergedAlignmentEntries (T.pack mergedConservationTrack)+  where entrySlicesList = concatMap entrySlices slices -- list of lists of entry slices+        sequenceIdentifiers = nub (map entrySequenceSliceIdentifier entrySlicesList)+        mergedAlignmentEntries = map (constructAlignmentEntries entrySlicesList) sequenceIdentifiers+        mergedConservationTrack = concatMap conservationTrackSlice slices+        alignment = ClustalAlignment mergedAlignmentEntries (T.pack mergedConservationTrack)         -constructAlignmentEntries :: (String, String) -> ClustalAlignmentEntry-constructAlignmentEntries (entryIdentifier,entrySequence) = ClustalAlignmentEntry (T.pack entryIdentifier) (T.pack entrySequence)+constructAlignmentEntries ::  [ClustalAlignmentEntrySlice] -> String -> ClustalAlignmentEntry+constructAlignmentEntries slices entryIdentifier= entry+  where currentSlices = filter (\a -> entrySequenceSliceIdentifier a == entryIdentifier) slices+        entrySequence = concatMap entryAlignedSliceSequence currentSlices+        entry = ClustalAlignmentEntry (T.pack entryIdentifier) (T.pack entrySequence)  genParserClustalAlignmentSlice :: GenParser Char st ClustalAlignmentSlice genParserClustalAlignmentSlice = do@@ -166,16 +164,21 @@   secondaryStructure <- genSecondaryStructure     energy' <- genParseEnergy   eof  -  return (mergeStructuralAlignmentSlices alignmentSlices secondaryStructure energy')+  return (mergeStructuralAlignmentSlices (concat alignmentSlices) secondaryStructure energy')  genSecondaryStructure :: GenParser Char st String genSecondaryStructure = do   string "alifold"-  many1 space-  secondaryStructure <- many1 (oneOf ".()")-  space-  return secondaryStructure+  secondaryStructure <- many1 (try genSecondaryStructureSlice)+  return (concat secondaryStructure) +genSecondaryStructureSlice :: GenParser Char st String+genSecondaryStructureSlice = do+  many1 space +  secondaryStructureSlice <- many1 (try (oneOf ".()"))+  choice [try (string "\n"),try (string " ")]+  return secondaryStructureSlice+          genParseEnergy :: GenParser Char st Double genParseEnergy = do   string "("@@ -204,24 +207,23 @@   many1 newline   return "" -mergeStructuralAlignmentSlices :: [StructuralClustalAlignmentSlice] -> String -> Double -> StructuralClustalAlignment+mergeStructuralAlignmentSlices :: [StructuralClustalAlignmentEntrySlice] -> String -> Double -> StructuralClustalAlignment mergeStructuralAlignmentSlices slices secondaryStructure energy' = alignment-  where entrySlicesList = map structuralEntrySlices slices -- list of lists of entry slices-        sequenceIdentifiers = (map structuralEntrySequenceSliceIdentifier (head entrySlicesList))-        alignmentEntriesListBySlice =  map (map structuralEntryAlignedSliceSequence) entrySlicesList  -        transposedAlignmentEntriesListbySlice = transpose alignmentEntriesListBySlice-        mergedAlignmentSequenceEntries = map concat transposedAlignmentEntriesListbySlice-        mergedAlignmentEntries = map constructStructuralAlignmentEntries (zip sequenceIdentifiers mergedAlignmentSequenceEntries)-        alignment = StructuralClustalAlignment mergedAlignmentEntries (T.pack secondaryStructure) energy' +  where sequenceIdentifiers = nub (map structuralEntrySequenceSliceIdentifier slices)+        mergedAlignmentEntries = map (constructStructuralAlignmentEntries slices) sequenceIdentifiers+        alignment = StructuralClustalAlignment mergedAlignmentEntries (T.pack secondaryStructure) energy'         -constructStructuralAlignmentEntries :: (String, String) -> ClustalAlignmentEntry-constructStructuralAlignmentEntries (entryIdentifier,entrySequence) = ClustalAlignmentEntry (T.pack entryIdentifier) (T.pack entrySequence)+constructStructuralAlignmentEntries ::  [StructuralClustalAlignmentEntrySlice] -> String -> ClustalAlignmentEntry+constructStructuralAlignmentEntries slices entryIdentifier= entry+  where currentSlices = filter (\a -> structuralEntrySequenceSliceIdentifier a == entryIdentifier) slices+        entrySequence = concatMap structuralEntryAlignedSliceSequence currentSlices+        entry = ClustalAlignmentEntry (T.pack entryIdentifier) (T.pack entrySequence) -genParserStructuralClustalAlignmentSlice :: GenParser Char st StructuralClustalAlignmentSlice+genParserStructuralClustalAlignmentSlice :: GenParser Char st [StructuralClustalAlignmentEntrySlice] genParserStructuralClustalAlignmentSlice = do   entrySlices' <- many1 (try genParserStructuralClustalEntrySlice)   optional newline-  return $ StructuralClustalAlignmentSlice entrySlices'+  return entrySlices'  genParserStructuralClustalEntrySlice :: GenParser Char st StructuralClustalAlignmentEntrySlice genParserStructuralClustalEntrySlice = do@@ -238,23 +240,23 @@ parseClustalAlignment = parse genParserClustalAlignment "genParserClustalAlignment"  -- | Parse Clustal alignment (.aln) from filehandle                  -readClustalAlignment :: String -> IO (Either ParseError ClustalAlignment)   +readClustalAlignment :: String ->  IO (Either ParseError ClustalAlignment)    readClustalAlignment = parseFromFile genParserClustalAlignment  -- | Parse Clustal alignment (.aln) with secondary structure in dot-bracket notation from String (as produced by mlocarna)-parseStructuralClustalAlignment :: String -> Either ParseError StructuralClustalAlignment +parseStructuralClustalAlignment :: String ->  Either ParseError StructuralClustalAlignment  parseStructuralClustalAlignment = parse genParserStructuralClustalAlignment "genParserStructuralClustalAlignment"  -- | Parse Clustal alignment (.aln) with secondary structure in dot-bracket notation from filehandle (as produced by mlocarna)                  -readStructuralClustalAlignment :: String -> IO (Either ParseError StructuralClustalAlignment)   +readStructuralClustalAlignment :: String ->  IO (Either ParseError StructuralClustalAlignment)    readStructuralClustalAlignment = parseFromFile genParserStructuralClustalAlignment  -- |  Parse Clustal summary (printed to STDOUT) from String-parseClustalSummary :: String -> Either ParseError ClustalSummary+parseClustalSummary :: String ->   Either ParseError ClustalSummary parseClustalSummary = parse genParserClustalSummary "genParserClustalSummary"  -- | Parse Clustal summary (printed to STDOUT) from file-readClustalSummary :: String -> IO (Either ParseError ClustalSummary)       +readClustalSummary ::  String -> IO (Either ParseError ClustalSummary)        readClustalSummary = parseFromFile genParserClustalSummary  -- | Parse nucleotide sequence. Allowed letters according to IUPAC