{-| FlowClip reads in an SFF file using coordinates provided on the command line, and clips each read accordingly. Negative coordinates indicate counting from the left, so to clip the last 20 bases off each read (useful for removing adapters), do 'flowclip 0 -20 input.sff'. -} module Main where import Bio.Sequence.SFF import System.Environment (getArgs) import Data.Int main :: IO () main = do [from,to,input] <- getArgs SFF h rs <- readSFF input writeSFF (input++".clip") (SFF h $ map (clip (read from) (read to)) rs) clip :: Int32 -> Int32 -> ReadBlock -> ReadBlock clip f t rb = let rh = read_header rb n = num_bases rh left = if f < 0 then n+f else f right = if t < 0 then n+t else t in trimFromTo left right rb