{-# LANGUAGE DeriveDataTypeable    #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLists       #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE PackageImports        #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE TypeFamilies          #-}
{-# Language QuasiQuotes           #-}

-- |
-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.BOPT
-- Copyright   :  (c) Matthew Mosior 2023
-- License     :  BSD-style
-- Maintainer  :  mattm.github@gmail.com
-- Portability :  portable
--
-- = WARNING
--
-- This module is considered __internal__.
--
-- The Package Versioning Policy __does not apply__.
--
-- The contents of this module may change __in any way whatsoever__
-- and __without any warning__ between minor versions of this package.
--
-- Authors importing this library are expected to track development
-- closely.
--
-- All credit goes to the author(s)/maintainer(s) of the
-- [containers](https://hackage.haskell.org/package/containers) library
-- for the above warning text.
--
-- = Description
--
-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.

module Data.SAM.Version1_6.Read.Parser.Alignment.BOPT ( -- * SAM_V1_6 parser - alignment section - bopt field 
                                                        parse_SAM_V1_6_Alignment_BOPT
                                                      ) where

import Data.SAM.Version1_6.Alignment.BOPT
import Data.SAM.Version1_6.Read.Error

import           Data.Attoparsec.ByteString.Lazy   as DABL
import qualified Data.ByteString                   as DB (head,unpack)
import qualified Data.ByteString.Char8             as DBC8
import           Data.Sequence                     as DSeq
import           Text.Regex.PCRE.Heavy

-- | Defines a parser for the optional bopt field of alignment section of the SAM v1.6 file format.
-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
parse_SAM_V1_6_Alignment_BOPT :: Parser SAM_V1_6_Alignment_BOPT
parse_SAM_V1_6_Alignment_BOPT :: Parser SAM_V1_6_Alignment_BOPT
parse_SAM_V1_6_Alignment_BOPT = do
  ByteString
alignmentboptfieldtag <- do ByteString
alignmentboptfieldtagp <- (Word8 -> Bool) -> Parser ByteString ByteString
DABL.takeTill (Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
58)
                              -- Parse BOPT tag of the alignment section.
                              case (ByteString
alignmentboptfieldtagp ByteString -> Regex -> Bool
forall a. ConvertibleStrings a ByteString => a -> Regex -> Bool
=~ [re|/[A-Za-z][A-Za-z0-9]/|]) of
                                Bool
False -> String -> Parser ByteString ByteString
forall a. String -> Parser ByteString a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ByteString ByteString)
-> String -> Parser ByteString ByteString
forall a b. (a -> b) -> a -> b
$ SAM_V1_6_Error -> String
forall a. Show a => a -> String
show SAM_V1_6_Error
SAM_V1_6_Error_Alignment_BOPT_Tag_Incorrect_Format
                                Bool
True  -> -- BOPT tag is in the accepted format. 
                                         ByteString -> Parser ByteString ByteString
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
alignmentboptfieldtagp
  Word8
_ <- Word8 -> Parser Word8
word8 Word8
58
  ByteString
_ <- do ByteString
alignmentboptfieldtypep <- (Word8 -> Bool) -> Parser ByteString ByteString
DABL.takeTill (Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
58)
          -- Parse BOPT type of the alignment section.
          case (ByteString
alignmentboptfieldtypep ByteString -> Regex -> Bool
forall a. ConvertibleStrings a ByteString => a -> Regex -> Bool
=~ [re|[B]|]) of
            Bool
False -> String -> Parser ByteString ByteString
forall a. String -> Parser ByteString a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ByteString ByteString)
-> String -> Parser ByteString ByteString
forall a b. (a -> b) -> a -> b
$ SAM_V1_6_Error -> String
forall a. Show a => a -> String
show SAM_V1_6_Error
SAM_V1_6_Error_Alignment_BOPT_Type_Incorrect_Format
            Bool
True  -> -- BOPT type is in the accepted format.
                     ByteString -> Parser ByteString ByteString
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
alignmentboptfieldtypep
  Word8
_ <- Word8 -> Parser Word8
word8 Word8
58
  ByteString
alignmentboptfieldvaluetype <- do ByteString
alignmentboptfieldvaluetypep <- Int -> Parser ByteString ByteString
DABL.take Int
1
                                    -- Parse BOPT value type of the alignment section.
                                    case (ByteString
alignmentboptfieldvaluetypep ByteString -> Regex -> Bool
forall a. ConvertibleStrings a ByteString => a -> Regex -> Bool
=~ [re|[cCsSiIf]|]) of
                                      Bool
False -> String -> Parser ByteString ByteString
forall a. String -> Parser ByteString a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ByteString ByteString)
-> String -> Parser ByteString ByteString
forall a b. (a -> b) -> a -> b
$ SAM_V1_6_Error -> String
forall a. Show a => a -> String
show SAM_V1_6_Error
SAM_V1_6_Error_Alignment_BOPT_Value_Type_Incorrect_Format
                                      Bool
True  -> -- BOPT value type is in the accepted format.
                                               ByteString -> Parser ByteString ByteString
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
alignmentboptfieldvaluetypep
  ByteString
alignmentboptfieldvaluedata <- do ByteString
alignmentboptfieldvaluedatap <- (Word8 -> Bool) -> Parser ByteString ByteString
DABL.takeTill (\Word8
x -> Word8
x Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
09 Bool -> Bool -> Bool
|| Word8
x Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
0x0D Bool -> Bool -> Bool
|| Word8
x Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
0x0A)
                                    -- Parse BOPT value data of the alignment section.
                                    case (ByteString
alignmentboptfieldvaluedatap ByteString -> Regex -> Bool
forall a. ConvertibleStrings a ByteString => a -> Regex -> Bool
=~ [re|(,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
                                      Bool
False -> String -> Parser ByteString ByteString
forall a. String -> Parser ByteString a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ByteString ByteString)
-> String -> Parser ByteString ByteString
forall a b. (a -> b) -> a -> b
$ SAM_V1_6_Error -> String
forall a. Show a => a -> String
show SAM_V1_6_Error
SAM_V1_6_Error_Alignment_BOPT_Value_Data_Incorrect_Format
                                      Bool
True  -> -- BOPT value data is in the accepted format.
                                               ByteString -> Parser ByteString ByteString
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
alignmentboptfieldvaluedatap
  case (ByteString -> String
DBC8.unpack ByteString
alignmentboptfieldvaluetype) of
    String
"c" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = SAM_V1_6_Alignment_BOPT_Int8 -> Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Int8 { sam_v1_6_alignment_bopt_int8_tag :: Seq Word8
sam_v1_6_alignment_bopt_int8_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                               , sam_v1_6_alignment_bopt_int8_type :: Word8
sam_v1_6_alignment_bopt_int8_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                               , sam_v1_6_alignment_bopt_int8_value :: Seq Int8
sam_v1_6_alignment_bopt_int8_value = (Word8 -> Int8) -> Seq Word8 -> Seq Int8
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word8 -> Int8
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata)
                                                                                                               }
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }
    String
"C" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = SAM_V1_6_Alignment_BOPT_Word8
-> Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Word8 { sam_v1_6_alignment_bopt_word8_tag :: Seq Word8
sam_v1_6_alignment_bopt_word8_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                                , sam_v1_6_alignment_bopt_word8_type :: Word8
sam_v1_6_alignment_bopt_word8_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                                , sam_v1_6_alignment_bopt_word8_value :: Seq Word8
sam_v1_6_alignment_bopt_word8_value = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata
                                                                                                                } 
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }
    String
"s" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = SAM_V1_6_Alignment_BOPT_Int16
-> Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Int16 { sam_v1_6_alignment_bopt_int16_tag :: Seq Word8
sam_v1_6_alignment_bopt_int16_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                                , sam_v1_6_alignment_bopt_int16_type :: Word8
sam_v1_6_alignment_bopt_int16_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                                , sam_v1_6_alignment_bopt_int16_value :: Seq Int16
sam_v1_6_alignment_bopt_int16_value = (Word8 -> Int16) -> Seq Word8 -> Seq Int16
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word8 -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata)
                                                                                                                }
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }
    String
"S" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = SAM_V1_6_Alignment_BOPT_Word16
-> Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag :: Seq Word8
sam_v1_6_alignment_bopt_word16_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                                 , sam_v1_6_alignment_bopt_word16_type :: Word8
sam_v1_6_alignment_bopt_word16_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                                 , sam_v1_6_alignment_bopt_word16_value :: Seq Word16
sam_v1_6_alignment_bopt_word16_value = (Word8 -> Word16) -> Seq Word8 -> Seq Word16
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word8 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata)
                                                                                                                 }
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }
    String
"i" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = SAM_V1_6_Alignment_BOPT_Int32
-> Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Int32 { sam_v1_6_alignment_bopt_int32_tag :: Seq Word8
sam_v1_6_alignment_bopt_int32_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                                , sam_v1_6_alignment_bopt_int32_type :: Word8
sam_v1_6_alignment_bopt_int32_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                                , sam_v1_6_alignment_bopt_int32_value :: Seq Int32
sam_v1_6_alignment_bopt_int32_value = (Word8 -> Int32) -> Seq Word8 -> Seq Int32
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word8 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata)
                                                                                                                }
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }
    String
"I" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = SAM_V1_6_Alignment_BOPT_Word32
-> Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Word32 { sam_v1_6_alignment_bopt_word32_tag :: Seq Word8
sam_v1_6_alignment_bopt_word32_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                                 , sam_v1_6_alignment_bopt_word32_type :: Word8
sam_v1_6_alignment_bopt_word32_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                                 , sam_v1_6_alignment_bopt_word32_value :: Seq Word32
sam_v1_6_alignment_bopt_word32_value = (Word8 -> Word32) -> Seq Word8 -> Seq Word32
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word8 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata)
                                                                                                                 }
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }
    String
"f" -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = SAM_V1_6_Alignment_BOPT_Float
-> Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. a -> Maybe a
Just SAM_V1_6_Alignment_BOPT_Float { sam_v1_6_alignment_bopt_float_tag :: Seq Word8
sam_v1_6_alignment_bopt_float_tag   = [Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldtag
                                                                                                                , sam_v1_6_alignment_bopt_float_type :: Word8
sam_v1_6_alignment_bopt_float_type  = HasCallStack => ByteString -> Word8
ByteString -> Word8
DB.head ByteString
alignmentboptfieldvaluetype
                                                                                                                , sam_v1_6_alignment_bopt_float_value :: Seq Float
sam_v1_6_alignment_bopt_float_value = (Word8 -> Float) -> Seq Word8 -> Seq Float
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word8 -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Word8] -> Seq Word8
forall a. [a] -> Seq a
DSeq.fromList ([Word8] -> Seq Word8) -> [Word8] -> Seq Word8
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
DB.unpack ByteString
alignmentboptfieldvaluedata)
                                                                                                                }
                                          }
    String
_   -> SAM_V1_6_Alignment_BOPT -> Parser SAM_V1_6_Alignment_BOPT
forall a. a -> Parser ByteString a
forall (m :: * -> *) a. Monad m => a -> m a
return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 :: Maybe SAM_V1_6_Alignment_BOPT_Int8
sam_v1_6_alignment_bopt_int8   = Maybe SAM_V1_6_Alignment_BOPT_Int8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word8 :: Maybe SAM_V1_6_Alignment_BOPT_Word8
sam_v1_6_alignment_bopt_word8  = Maybe SAM_V1_6_Alignment_BOPT_Word8
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int16 :: Maybe SAM_V1_6_Alignment_BOPT_Int16
sam_v1_6_alignment_bopt_int16  = Maybe SAM_V1_6_Alignment_BOPT_Int16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
sam_v1_6_alignment_bopt_word16 = Maybe SAM_V1_6_Alignment_BOPT_Word16
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_int32 :: Maybe SAM_V1_6_Alignment_BOPT_Int32
sam_v1_6_alignment_bopt_int32  = Maybe SAM_V1_6_Alignment_BOPT_Int32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
sam_v1_6_alignment_bopt_word32 = Maybe SAM_V1_6_Alignment_BOPT_Word32
forall a. Maybe a
Nothing
                                          , sam_v1_6_alignment_bopt_float :: Maybe SAM_V1_6_Alignment_BOPT_Float
sam_v1_6_alignment_bopt_float  = Maybe SAM_V1_6_Alignment_BOPT_Float
forall a. Maybe a
Nothing
                                          }