StockholmAlignment 1.0.3 → 1.0.4
raw patch · 3 files changed
+33/−9 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- StockholmAlignment.cabal +3/−3
- changelog +2/−0
- src/Bio/StockholmDraw.hs +28/−6
StockholmAlignment.cabal view
@@ -1,5 +1,5 @@ name: StockholmAlignment-version: 1.0.3+version: 1.0.4 synopsis: Libary for Stockholm aligmnent format description: Libary containing parsing and visualisation functions and datastructures for Stockholm aligmnent format license: GPL-3@@ -21,8 +21,8 @@ source-repository this type: git- location: https://github.com/eggzilla/StockholmAlignment/tree/1.0.3- tag: 1.0.3+ location: https://github.com/eggzilla/StockholmAlignment/tree/1.0.4+ tag: 1.0.4 library -- Modules exported by the library.
changelog view
@@ -1,4 +1,6 @@ -*-change-log-*-+1.0.4 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 27. April 2017+ * Added visualisation of consensus secondary structure if present 1.0.3 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 24. April 2017 * Relaxed version bounds on diagrams library 1.0.2 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 12. April 2017
src/Bio/StockholmDraw.hs view
@@ -25,9 +25,13 @@ drawStockholmLines :: Int -> Double -> V.Vector Int -> V.Vector (Int, V.Vector (Colour Double)) -> S.StockholmAlignment -> QDiagram Cairo V2 Double Any drawStockholmLines entriesNumberCutoff maxWidth nodeAlignmentColIndices comparisonNodeLabels aln = alignmentBlocks- where currentEntries = V.fromList (take entriesNumberCutoff (S.sequenceEntries aln))- entryNumber = V.length currentEntries- vectorEntries = V.map makeVectorEntries currentEntries+ where seqEntries = V.fromList (take entriesNumberCutoff (S.sequenceEntries aln))+ --consensusStructureEntry = if null (S.columnAnnotations aln) then mempty else drawConsensusStructureEntry maxIdLength (S.columnAnnotations aln)+ maybeConsensusStructureEntry = find ((T.pack "SS_cons"==) . S.tag) (S.columnAnnotations aln)+ consensusStructureEntry = maybe V.empty makeConsensusStructureVectorEntry maybeConsensusStructureEntry+ entryNumber = V.length vectorEntries + seqVectorEntries = V.map makeVectorEntries seqEntries+ vectorEntries = seqVectorEntries V.++ consensusStructureEntry maxEntryLength = V.maximum (V.map (V.length . snd) vectorEntries) maxIdLength = V.maximum (V.map (length . fst) vectorEntries) letterWidth = 2.0 :: Double@@ -36,8 +40,8 @@ colIndicescomparisonNodeLabels = V.zipWith (\a b -> (a,b)) nodeAlignmentColIndices comparisonNodeLabels sparseComparisonColLabels = V.map nodeToColIndices colIndicescomparisonNodeLabels fullComparisonColLabels = fillComparisonColLabels maxEntryLength sparseComparisonColLabels- alignmentBlocks = vcat' with { _sep = 6.0 } (map (drawStockholmRowBlock maxIdLength vectorEntries maxEntryLength fullComparisonColLabels) blocks)-+ alignmentBlocks = vcat' with { _sep = 6.0 } (map (drawStockholmRowBlock maxIdLength vectorEntries maxEntryLength fullComparisonColLabels) blocks) + extractGapfreeStructure :: String -> String -> String extractGapfreeStructure alignedSequence regularStructure1 = entryStructure where regularsequence1 = map convertToRegularGap alignedSequence@@ -150,11 +154,24 @@ entryDia = hcat (map setAlignmentLetter entryText) drawStockholm :: Int -> S.StockholmAlignment -> QDiagram Cairo V2 Double Any-drawStockholm entriesNumberCutoff aln = alignTL (vcat' with { _sep = 1 } (map (drawStockholmEntry maxIdLength) currentEntries))+drawStockholm entriesNumberCutoff aln = alignTL (vcat' with { _sep = 1 } (map (drawStockholmEntry maxIdLength) currentEntries)) === consensusStructureEntry where currentEntries = take entriesNumberCutoff (S.sequenceEntries aln) --entryNumber = length currentEntries maxIdLength = maximum (map (T.length . S.sequenceId) currentEntries)+ consensusStructureEntry = if null (S.columnAnnotations aln) then mempty else drawConsensusStructureEntry maxIdLength (S.columnAnnotations aln) +drawConsensusStructureEntry :: Int -> [S.AnnotationEntry] -> QDiagram Cairo V2 Double Any+drawConsensusStructureEntry maxIdLength entries + | isJust maybeSecStructureEntry = hcat (map setAlignmentLetter entryText)+ | otherwise = mempty+ where maybeSecStructureEntry = find ((T.pack "SS_cons"==) . S.tag) entries+ entryText = T.unpack (seqId `T.append` spacer `T.append` S.annotation (fromJust maybeSecStructureEntry))+ seqId = T.pack "SS_cons"+ spacerLength = (maxIdLength + 3) - T.length seqId+ spacer = T.replicate spacerLength (T.pack " ")+ --entryDia = maybe mempty (\entryText -> hcat (map setAlignmentLetter (T.unpack (S.annotation entryText)))) maybeSecStructureEntry++ drawStockholmEntry :: Int -> S.SequenceEntry -> QDiagram Cairo V2 Double Any drawStockholmEntry maxIdLength entry = entryDia where entryText = T.unpack (seqId `T.append` spacer `T.append` S.entrySequence entry)@@ -191,3 +208,8 @@ makeVectorEntries entry = (entrySeqId,entrySeq) where entrySeq = V.fromList (T.unpack (S.entrySequence entry)) entrySeqId = T.unpack (S.sequenceId entry)++makeConsensusStructureVectorEntry :: S.AnnotationEntry -> V.Vector (String, V.Vector Char)+makeConsensusStructureVectorEntry entry = V.singleton (entryId,entryTxt)+ where entryTxt = V.fromList (T.unpack (S.annotation entry))+ entryId = T.unpack (S.tag entry)