bio 0.4.4 → 0.4.5
raw patch · 3 files changed
+18/−21 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Bio.Alignment.PSL: instance Eq PSL
+ Bio.Alignment.PSL: pslHeader :: ByteString
Files
- Bio/Alignment/PSL.hs +16/−16
- Bio/Sequence/Fasta.hs +1/−4
- bio.cabal +1/−1
Bio/Alignment/PSL.hs view
@@ -8,6 +8,7 @@ import qualified Data.ByteString.Lazy.Char8 as B import Data.ByteString.Lazy.Char8 (ByteString)+import Data.List (intersperse) -- encodes the fields in a Blat PSL record -- NB! laziness issues, if not fully evaluated, this will hang onto the input.@@ -17,24 +18,16 @@ , qname :: ByteString, qsize, qstart, qend :: Int , tname :: ByteString, tsize, tstart, tend :: Int , blockcount :: Int, blocksizes, qstarts, tstarts :: [Int]- } deriving Show-{--sread :: ByteString -> Strand-sread b = case B.uncons b of - Just ('-',_) -> Minus- Just ('+',_) -> Plus- _ -> error ("Cant't parse '"++B.unpack b++"' as strand")+ } deriving (Eq) -swrite :: Strand -> ByteString-swrite Minus = B.pack "-"-swrite Plus = B.pack "+"--}+instance Show PSL where + show = B.unpack . unparsePSL . return readPSL :: FilePath -> IO [PSL] readPSL f = parsePSL `fmap` B.readFile f writePSL :: FilePath -> [PSL] -> IO ()-writePSL f = B.writeFile f . unparsePSL+writePSL f = B.writeFile f . B.append pslHeader . unparsePSL parsePSL :: ByteString -> [PSL] parsePSL s = map parseLine $ B.lines $ dropHeader@@ -51,11 +44,18 @@ unparsePSL :: [PSL] -> ByteString-unparsePSL bs = addHeader $ B.unlines $ map format1 bs- where addHeader = B.append pslHeader- format1 :: PSL -> ByteString- format1 = undefined+unparsePSL = B.unlines . map format1+ where format1 :: PSL -> ByteString+ format1 (PSL m mm rm nc qc ql tgc tgl st qn qsz qst qed tn tsz tst ted bc bs qss tss) = + B.concat $ intersperse tab $ (map showint [m, mm, rm, nc, qc, ql, tgc, tgl]+ ++[st,qn]++map showint [qsz,qst,qed]+ ++[tn] ++map showint [tsz,tst,ted]+ ++[showint bc]++map showlist [bs,qss,tss])+ tab = B.pack "\t"+ showint = B.pack . show+ showlist = B.pack . concat . map (++",") . map show +pslHeader :: ByteString pslHeader = B.pack ("psLayout version 3\n\n" ++"match\tmis- \trep. \tN's\tQ gap\tQ gap\tT gap\tT gap\tstrand\tQ \tQ \tQ \tQ \tT \tT \tT \tT \tblock\tblockSizes \tqStarts\t tStarts\n" ++" \tmatch\tmatch\t \tcount\tbases\tcount\tbases\t \tname \tsize\tstart\tend\tname \tsize\tstart\tend\tcount\n"
Bio/Sequence/Fasta.hs view
@@ -30,10 +30,7 @@ -- import Data.Char (isSpace) import Data.List (groupBy,intersperse)-import Data.Int-import Data.Maybe import System.IO-import Control.Monad import qualified Data.ByteString.Lazy.Char8 as B import qualified Data.ByteString.Lazy as BB@@ -175,7 +172,7 @@ -- | Split lines into blocks starting with '>' characters -- Filter out # comments (but not semicolons?) blocks :: [ByteString] -> [[ByteString]]-blocks = groupBy (const (('>' /=) . B.head)) . filter ((/='#') . B.head) . filter (not . B.null)+blocks = groupBy (const (('>' /=) . B.head)) . filter ((/='#') . B.head) . dropWhile (('>' /=) . B.head) . filter (not . B.null) countSeqs :: FilePath -> IO Int countSeqs f = do
bio.cabal view
@@ -1,5 +1,5 @@ Name: bio-Version: 0.4.4+Version: 0.4.5 License: LGPL License-file: LICENSE Author: Ketil Malde