diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -82,3 +82,9 @@
 * Fixed broken parsing of SAM_V1_6(..).
 * Strengthened parsing of SAM_V1_6(..) by accurately emulating the sam v1.6 specification through use of permutable parsers.
 * Added initial test suite.
+
+## 0.8.0.0 -- 2023-10-30
+
+* Adding functionality to write SAM_V1_6(..) to file.
+* Made show instances of many newtypes/datatypes more verbose to match fields of said newtypes/datatypes.
+* Added initial writeSAM_V1_6 test case.
diff --git a/hs-samtools.cabal b/hs-samtools.cabal
--- a/hs-samtools.cabal
+++ b/hs-samtools.cabal
@@ -20,7 +20,7 @@
 -- PVP summary:     +-+------- breaking API changes
 --                  | | +----- non-breaking API additions
 --                  | | | +--- code changes with no API change
-version:            0.7.0.0
+version:            0.8.0.0
 
 -- A short (one-line) description of the package.
 synopsis: Read and write SAM, BAM, and CRAM files.
@@ -68,6 +68,11 @@
     exposed-modules: Data.SAM.Version1_6.Base,
                      Data.SAM.Version1_6.Alignment,
                      Data.SAM.Version1_6.Alignment.Base,
+                     Data.SAM.Version1_6.Alignment.AOPT,
+                     Data.SAM.Version1_6.Alignment.FOPT,
+                     Data.SAM.Version1_6.Alignment.HOPT,
+                     Data.SAM.Version1_6.Alignment.IOPT,
+                     Data.SAM.Version1_6.Alignment.ZOPT,
                      Data.SAM.Version1_6.Alignment.BOPT,
                      Data.SAM.Version1_6.Header, 
                      Data.SAM.Version1_6.Header.CO,
@@ -122,7 +127,8 @@
                      Data.SAM.Version1_6.Read.Parser.Header.PG.PP,
                      Data.SAM.Version1_6.Read.Parser.Header.PG.DS,
                      Data.SAM.Version1_6.Read.Parser.Header.PG.VN,
-                     Data.SAM.Version1_6.Read.Parser.Header.CO.Base
+                     Data.SAM.Version1_6.Read.Parser.Header.CO.Base,
+                     Data.SAM.Version1_6.Write.Base
 
     -- Modules included in this library but not exported.
     -- other-modules:
diff --git a/src/Data/SAM/Version1_6/Alignment.hs b/src/Data/SAM/Version1_6/Alignment.hs
--- a/src/Data/SAM/Version1_6/Alignment.hs
+++ b/src/Data/SAM/Version1_6/Alignment.hs
@@ -1,15 +1,7 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Alignment
diff --git a/src/Data/SAM/Version1_6/Alignment/AOPT.hs b/src/Data/SAM/Version1_6/Alignment/AOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/AOPT.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.AOPT
+-- 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.Alignment.AOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                            SAM_V1_6_Alignment_AOPT(..)
+                                          ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_AOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_AOPT = SAM_V1_6_Alignment_AOPT { sam_v1_6_alignment_aopt_tag   :: ByteString 
+                                                       , sam_v1_6_alignment_aopt_value :: ByteString
+                                                       }
+  deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_AOPT where
+  SAM_V1_6_Alignment_AOPT sam_v1_6_alignment_aopt_tag1
+                          sam_v1_6_alignment_aopt_value1 == SAM_V1_6_Alignment_AOPT sam_v1_6_alignment_aopt_tag2
+                                                                                    sam_v1_6_alignment_aopt_value2 = sam_v1_6_alignment_aopt_tag1   == sam_v1_6_alignment_aopt_tag2     &&
+                                                                                                                     sam_v1_6_alignment_aopt_value1  == sam_v1_6_alignment_aopt_value2
+
+instance Show SAM_V1_6_Alignment_AOPT where
+  show (SAM_V1_6_Alignment_AOPT tag
+                                value
+       ) =
+    "SAM_V1_6_Alignment_AOPT { "          ++
+    "sam_v1_6_alignment_aopt_tag = "      ++
+    (show tag)                            ++
+    " , sam_v1_6_alignment_aopt_value = " ++
+    (show value)                          ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/BOPT.hs b/src/Data/SAM/Version1_6/Alignment/BOPT.hs
--- a/src/Data/SAM/Version1_6/Alignment/BOPT.hs
+++ b/src/Data/SAM/Version1_6/Alignment/BOPT.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Alignment.BOPT
@@ -133,13 +128,13 @@
                                      bopttype
                                      value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Int8 { " ++
-    "tag  = "                         ++
-    (show tag)                        ++
-    " , type = "                      ++
-    (show bopttype)                   ++
-    " , value = "                     ++
-    (show value)                      ++
+    "SAM_V1_6_Alignment_BOPT_Int8 { "          ++
+    "sam_v1_6_alignment_bopt_int8_tag  = "     ++
+    (show tag)                                 ++
+    " , sam_v1_6_alignment_bopt_int8_type = "  ++
+    (show bopttype)                            ++
+    " , sam_v1_6_alignment_bopt_int8_value = " ++
+    (show value)                               ++
     " }"
 
 -- | c__C__sSiIf of the last optional field (type B).
@@ -159,13 +154,13 @@
                                       bopttype
                                       value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Word8 { " ++
-    "tag  = "                          ++
-    (show tag)                         ++
-    " , type = "                       ++
-    (show bopttype)                    ++
-    " , value = "                      ++
-    (show value)                       ++
+    "SAM_V1_6_Alignment_BOPT_Word8 { "          ++
+    "sam_v1_6_alignment_bopt_word8_tag  = "     ++
+    (show tag)                                  ++
+    " , sam_v1_6_alignment_bopt_word8_type = "  ++
+    (show bopttype)                             ++
+    " , sam_v1_6_alignment_bopt_word8_value = " ++
+    (show value)                                ++
     " }"
 
 -- | cC__s__SiIf of the last optional field (type B).
@@ -185,13 +180,13 @@
                                       bopttype
                                       value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Int16 { " ++
-    "tag  = "                          ++
-    (show tag)                         ++
-    " , type = "                       ++
-    (show bopttype)                    ++
-    " , value = "                      ++
-    (show value)                       ++
+    "SAM_V1_6_Alignment_BOPT_Int16 { "          ++
+    "sam_v1_6_alignment_bopt_int16_tag  = "     ++
+    (show tag)                                  ++
+    " , sam_v1_6_alignment_bopt_int16_type = "  ++
+    (show bopttype)                             ++
+    " , sam_v1_6_alignment_bopt_int16_value = " ++
+    (show value)                                ++
     " }"
 
 -- | cCs__S__iIf of the last optional field (type B).
@@ -211,13 +206,13 @@
                                        bopttype
                                        value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Word16 { " ++
-    "tag  = "                           ++
-    (show tag)                          ++
-    " , type = "                        ++
-    (show bopttype)                     ++
-    " , value = "                       ++
-    (show value)                        ++
+    "SAM_V1_6_Alignment_BOPT_Word16 { "          ++
+    "sam_v1_6_alignment_bopt_word16_tag  = "     ++
+    (show tag)                                   ++
+    " , sam_v1_6_alignment_bopt_word16_type = "  ++
+    (show bopttype)                              ++
+    " , sam_v1_6_alignment_bopt_word16_value = " ++
+    (show value)                                 ++
     " }"
 
 -- | cCsS__i__If of the last optional field (type B).
@@ -237,13 +232,13 @@
                                       bopttype
                                       value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Int32 { " ++
-    "tag  = "                          ++
-    (show tag)                         ++
-    " , type = "                       ++
-    (show bopttype)                    ++
-    " , value = "                      ++
-    (show value)                       ++
+    "SAM_V1_6_Alignment_BOPT_Int32 { "          ++
+    "sam_v1_6_alignment_bopt_int32_tag  = "     ++
+    (show tag)                                  ++
+    " , sam_v1_6_alignment_bopt_int32_type = "  ++
+    (show bopttype)                             ++
+    " , sam_v1_6_alignment_bopt_int32_value = " ++
+    (show value)                                ++
     " }"
 
 -- | cCsSi__I__f of the last optional field (type B).
@@ -263,13 +258,13 @@
                                        bopttype
                                        value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Word32 { " ++
-    "tag  = "                           ++
-    (show tag)                          ++
-    " , type = "                        ++
-    (show bopttype)                     ++
-    " , value = "                       ++
-    (show value)                        ++
+    "SAM_V1_6_Alignment_BOPT_Word32 { "          ++
+    "sam_v1_6_alignment_bopt_word32_tag  = "     ++
+    (show tag)                                   ++
+    " , sam_v1_6_alignment_bopt_word32_type = "  ++
+    (show bopttype)                              ++
+    " , sam_v1_6_alignment_bopt_word32_value = " ++
+    (show value)                                 ++
     " }"
 
 -- | cCsSiI__f__ of the last optional field (type B).
@@ -289,11 +284,11 @@
                                       bopttype
                                       value
        ) =
-    "SAM_V1_6_Alignment_BOPT_Float { " ++
-    "tag  = "                          ++
-    (show tag)                         ++
-    " , type = "                       ++
-    (show bopttype)                    ++
-    " , value = "                      ++
-    (show value)                       ++
+    "SAM_V1_6_Alignment_BOPT_Float { "          ++
+    "sam_v1_6_alignment_bopt_float_tag  = "     ++
+    (show tag)                                  ++
+    " , sam_v1_6_alignment_bopt_float_type = "  ++
+    (show bopttype)                             ++
+    " , sam_v1_6_alignment_bopt_float_value = " ++
+    (show value)                                ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/Base.hs b/src/Data/SAM/Version1_6/Alignment/Base.hs
--- a/src/Data/SAM/Version1_6/Alignment/Base.hs
+++ b/src/Data/SAM/Version1_6/Alignment/Base.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts            #-}
 {-# LANGUAGE FlexibleInstances           #-}
 {-# LANGUAGE MultiParamTypeClasses       #-}
-{-# LANGUAGE OverloadedLists             #-}
 {-# LANGUAGE OverloadedStrings           #-}
-{-# LANGUAGE PackageImports              #-}
-{-# LANGUAGE RecordWildCards             #-}
-{-# LANGUAGE TemplateHaskell             #-}
 {-# LANGUAGE TypeFamilies                #-}
-{-# Language QuasiQuotes                 #-}
 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
 
 -- |
@@ -27,12 +22,15 @@
                                             SAM_V1_6_Alignment(..)
                                           ) where
 
+import Data.SAM.Version1_6.Alignment.AOPT
+import Data.SAM.Version1_6.Alignment.IOPT
+import Data.SAM.Version1_6.Alignment.FOPT
+import Data.SAM.Version1_6.Alignment.ZOPT
+import Data.SAM.Version1_6.Alignment.HOPT
 import Data.SAM.Version1_6.Alignment.BOPT
 
 import Data.ByteString
 import Data.Data
-import Data.Sequence
-import Data.Word
 import Generics.Deriving.Base
 
 -- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment"@ data type.
@@ -102,11 +100,11 @@
                                                                                                          -- This field can be a ‘*’ when quality is not stored.
                                                                                                          -- If not a ‘*’, SEQ must not be a ‘*’ and the length of the quality
                                                                                                          -- string ought to equal the length of SEQ.
-                                             , sam_v1_6_alignment_aopt  :: Maybe ByteString              -- ^ A - [!-~] - Printable characters.
-                                             , sam_v1_6_alignment_iopt  :: Maybe Integer                 -- ^ i - [-+]?[0-9]+ - Signed integer.
-                                             , sam_v1_6_alignment_fopt  :: Maybe Float                   -- ^ f - [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? - Single-precision floating number.
-                                             , sam_v1_6_alignment_zopt  :: Maybe ByteString              -- ^ Z - [ !-~]* - Printable string, including space.
-                                             , sam_v1_6_alignment_hopt  :: Maybe (Seq Word8)             -- ^ H - ([0-9A-F][0-9A-F])* - Byte array in the Hex format.
+                                             , sam_v1_6_alignment_aopt  :: Maybe SAM_V1_6_Alignment_AOPT -- ^ A - [!-~] - Printable characters.
+                                             , sam_v1_6_alignment_iopt  :: Maybe SAM_V1_6_Alignment_IOPT -- ^ i - [-+]?[0-9]+ - Signed integer.
+                                             , sam_v1_6_alignment_fopt  :: Maybe SAM_V1_6_Alignment_FOPT -- ^ f - [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? - Single-precision floating number.
+                                             , sam_v1_6_alignment_zopt  :: Maybe SAM_V1_6_Alignment_ZOPT -- ^ Z - [ !-~]* - Printable string, including space.
+                                             , sam_v1_6_alignment_hopt  :: Maybe SAM_V1_6_Alignment_HOPT -- ^ H - ([0-9A-F][0-9A-F])* - Byte array in the Hex format.
                                              , sam_v1_6_alignment_bopt  :: Maybe SAM_V1_6_Alignment_BOPT -- ^ B - [cCsSiIf]&#8203;(,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)* - Integer or numeric array.
                                              }
   deriving (Generic,Typeable)
@@ -164,39 +162,39 @@
 
 instance Show SAM_V1_6_Alignment where
   show (SAM_V1_6_Alignment qname flag rname pos mapq cigar rnext pnext tlen seq qual aopt iopt fopt zopt hopt bopt) =
-    "SAM_V1_6_Alignment { " ++
-    "qname = "              ++
-    (show qname)            ++
-    " , flag = "            ++
-    (show flag)             ++
-    " , rname = "           ++
-    (show rname)            ++
-    " , pos = "             ++
-    (show pos)              ++
-    " , mapq = "            ++
-    (show mapq)             ++
-    " , cigar = "           ++
-    (show cigar)            ++
-    " , rnext = "           ++
-    (show rnext)            ++
-    " , pnext = "           ++
-    (show pnext)            ++
-    " , tlen = "            ++
-    (show tlen)             ++
-    " , seq = "             ++
-    (show seq)              ++
-    " , qual = "            ++
-    (show qual)             ++
-    " , aopt = "            ++
-    ( show aopt)            ++
-    " , iopt = "            ++
-    (show iopt)             ++
-    " , fopt = "            ++
-    (show fopt)             ++
-    " , zopt = "            ++
-    (show zopt)             ++
-    " , hopt = "            ++
-    (show hopt)             ++
-    " , bopt = "            ++
-    (show bopt)             ++
+    "SAM_V1_6_Alignment { "          ++
+    "sam_v1_6_alignment_qname = "    ++
+    (show qname)                     ++
+    " , sam_v1_6_alignment_flag = "  ++
+    (show flag)                      ++
+    " , sam_v1_6_alignment_rname = " ++
+    (show rname)                     ++
+    " , sam_v1_6_alignment_pos = "   ++
+    (show pos)                       ++
+    " , sam_v1_6_alignment_mapq = "  ++
+    (show mapq)                      ++
+    " , sam_v1_6_alignment_cigar = " ++
+    (show cigar)                     ++
+    " , sam_v1_6_alignment_rnext = " ++
+    (show rnext)                     ++
+    " , sam_v1_6_alignment_pnext = " ++
+    (show pnext)                     ++
+    " , sam_v1_6_alignment_tlen = "  ++
+    (show tlen)                      ++
+    " , sam_v1_6_alignment_seq = "   ++
+    (show seq)                       ++
+    " , sam_v1_6_alignment_qual = "  ++
+    (show qual)                      ++
+    " , sam_v1_6_alignment_aopt = "  ++
+    ( show aopt)                     ++
+    " , sam_v1_6_alignment_iopt = "  ++
+    (show iopt)                      ++
+    " , sam_v1_6_alignment_fopt = "  ++
+    (show fopt)                      ++
+    " , sam_v1_6_alignment_zopt = "  ++
+    (show zopt)                      ++
+    " , sam_v1_6_alignment_hopt = "  ++
+    (show hopt)                      ++
+    " , sam_v1_6_alignment_bopt = "  ++
+    (show bopt)                      ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/FOPT.hs b/src/Data/SAM/Version1_6/Alignment/FOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/FOPT.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.FOPT
+-- 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.Alignment.FOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                            SAM_V1_6_Alignment_FOPT(..)
+                                          ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_FOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_FOPT = SAM_V1_6_Alignment_FOPT { sam_v1_6_alignment_fopt_tag   :: ByteString 
+                                                       , sam_v1_6_alignment_fopt_value :: Float
+                                                       }
+  deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_FOPT where
+  SAM_V1_6_Alignment_FOPT sam_v1_6_alignment_fopt_tag1
+                          sam_v1_6_alignment_fopt_value1 == SAM_V1_6_Alignment_FOPT sam_v1_6_alignment_fopt_tag2
+                                                                                    sam_v1_6_alignment_fopt_value2 = sam_v1_6_alignment_fopt_tag1   == sam_v1_6_alignment_fopt_tag2     &&
+                                                                                                                     sam_v1_6_alignment_fopt_value1  == sam_v1_6_alignment_fopt_value2
+
+instance Show SAM_V1_6_Alignment_FOPT where
+  show (SAM_V1_6_Alignment_FOPT tag
+                                value
+       ) =
+    "SAM_V1_6_Alignment_FOPT { "          ++
+    "sam_v1_6_alignment_fopt_tag = "      ++
+    (show tag)                            ++
+    " , sam_v1_6_alignment_fopt_value = " ++
+    (show value)                          ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/HOPT.hs b/src/Data/SAM/Version1_6/Alignment/HOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/HOPT.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.HOPT
+-- 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.Alignment.HOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                            SAM_V1_6_Alignment_HOPT(..)
+                                          ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_HOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_HOPT = SAM_V1_6_Alignment_HOPT { sam_v1_6_alignment_hopt_tag   :: ByteString 
+                                                       , sam_v1_6_alignment_hopt_value :: ByteString
+                                                       }
+  deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_HOPT where
+  SAM_V1_6_Alignment_HOPT sam_v1_6_alignment_hopt_tag1
+                          sam_v1_6_alignment_hopt_value1 == SAM_V1_6_Alignment_HOPT sam_v1_6_alignment_hopt_tag2
+                                                                                    sam_v1_6_alignment_hopt_value2 = sam_v1_6_alignment_hopt_tag1   == sam_v1_6_alignment_hopt_tag2     &&
+                                                                                                                     sam_v1_6_alignment_hopt_value1  == sam_v1_6_alignment_hopt_value2
+
+instance Show SAM_V1_6_Alignment_HOPT where
+  show (SAM_V1_6_Alignment_HOPT tag
+                                value
+       ) =
+    "SAM_V1_6_Alignment_HOPT { "          ++
+    "sam_v1_6_alignment_hopt_tag = "      ++
+    (show tag)                            ++
+    " , sam_v1_6_alignment_hopt_value = " ++
+    (show value)                          ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/IOPT.hs b/src/Data/SAM/Version1_6/Alignment/IOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/IOPT.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.IOPT
+-- 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.Alignment.IOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                            SAM_V1_6_Alignment_IOPT(..)
+                                          ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_IOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_IOPT = SAM_V1_6_Alignment_IOPT { sam_v1_6_alignment_iopt_tag   :: ByteString 
+                                                       , sam_v1_6_alignment_iopt_value :: Integer
+                                                       }
+  deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_IOPT where
+  SAM_V1_6_Alignment_IOPT sam_v1_6_alignment_iopt_tag1
+                          sam_v1_6_alignment_iopt_value1 == SAM_V1_6_Alignment_IOPT sam_v1_6_alignment_iopt_tag2
+                                                                                    sam_v1_6_alignment_iopt_value2 = sam_v1_6_alignment_iopt_tag1   == sam_v1_6_alignment_iopt_tag2     &&
+                                                                                                                     sam_v1_6_alignment_iopt_value1  == sam_v1_6_alignment_iopt_value2
+
+instance Show SAM_V1_6_Alignment_IOPT where
+  show (SAM_V1_6_Alignment_IOPT tag
+                                value
+       ) =
+    "SAM_V1_6_Alignment_IOPT { "          ++
+    "sam_v1_6_alignment_iopt_tag = "      ++
+    (show tag)                            ++
+    " , sam_v1_6_alignment_iopt_value = " ++
+    (show value)                          ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/ZOPT.hs b/src/Data/SAM/Version1_6/Alignment/ZOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/ZOPT.hs
@@ -0,0 +1,68 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.ZOPT
+-- 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.Alignment.ZOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                            SAM_V1_6_Alignment_ZOPT(..)
+                                          ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_ZOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_ZOPT = SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag   :: ByteString 
+                                                       , sam_v1_6_alignment_zopt_value :: ByteString
+                                                       }
+  deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_ZOPT where
+  SAM_V1_6_Alignment_ZOPT sam_v1_6_alignment_zopt_tag1
+                          sam_v1_6_alignment_zopt_value1 == SAM_V1_6_Alignment_ZOPT sam_v1_6_alignment_zopt_tag2
+                                                                                    sam_v1_6_alignment_zopt_value2 = sam_v1_6_alignment_zopt_tag1   == sam_v1_6_alignment_zopt_tag2     &&
+                                                                                                                     sam_v1_6_alignment_zopt_value1  == sam_v1_6_alignment_zopt_value2
+
+instance Show SAM_V1_6_Alignment_ZOPT where
+  show (SAM_V1_6_Alignment_ZOPT tag
+                                value
+       ) =
+    "SAM_V1_6_Alignment_ZOPT { "          ++
+    "sam_v1_6_alignment_zopt_tag = "      ++
+    (show tag)                            ++
+    " , sam_v1_6_alignment_zopt_value = " ++
+    (show value)                          ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Base.hs b/src/Data/SAM/Version1_6/Base.hs
--- a/src/Data/SAM/Version1_6/Base.hs
+++ b/src/Data/SAM/Version1_6/Base.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Base
@@ -82,17 +77,17 @@
                  one_line_comment
                  alignment
        ) =
-    "SAM_V1_6 { "                         ++
-    "file_level_metadata = "              ++
-    (show file_level_metadata)            ++
-    " , reference_sequence_dictionary = " ++
-    (show reference_sequence_dictionary)  ++
-    " , read_group = "                    ++
-    (show read_group)                     ++
-    " , program = "                       ++
-    (show program)                        ++
-    " , one_line_comment = "              ++
-    (show one_line_comment)               ++
-    " , alignment = "                     ++
-    (show alignment)                      ++
+    "SAM_V1_6 { "                                  ++
+    "sam_v1_6_file_level_metadata = "              ++
+    (show file_level_metadata)                     ++
+    " , sam_v1_6_reference_sequence_dictionary = " ++
+    (show reference_sequence_dictionary)           ++
+    " , sam_v1_6_read_group = "                    ++
+    (show read_group)                              ++
+    " , sam_v1_6_program = "                       ++
+    (show program)                                 ++
+    " , sam_v1_6_one_line_comment = "              ++
+    (show one_line_comment)                        ++
+    " , sam_v1_6_alignment = "                     ++
+    (show alignment)                               ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Header.hs b/src/Data/SAM/Version1_6/Header.hs
--- a/src/Data/SAM/Version1_6/Header.hs
+++ b/src/Data/SAM/Version1_6/Header.hs
@@ -1,15 +1,7 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header
diff --git a/src/Data/SAM/Version1_6/Header/CO.hs b/src/Data/SAM/Version1_6/Header/CO.hs
--- a/src/Data/SAM/Version1_6/Header/CO.hs
+++ b/src/Data/SAM/Version1_6/Header/CO.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.CO
@@ -41,7 +36,7 @@
   SAM_V1_6_One_Line_Comment sam_v1_6_one_line_comment_value1 == SAM_V1_6_One_Line_Comment sam_v1_6_one_line_comment_value2 = sam_v1_6_one_line_comment_value1 == sam_v1_6_one_line_comment_value2
 
 instance Show SAM_V1_6_One_Line_Comment where
-  show (SAM_V1_6_One_Line_Comment value) = "SAM_V1_6_One_Line_Comment { " ++
-                                           "value = "                     ++
-                                           (show value)                   ++
+  show (SAM_V1_6_One_Line_Comment value) = "SAM_V1_6_One_Line_Comment { "       ++
+                                           "sam_v1_6_one_line_comment_value = " ++
+                                           (show value)                         ++
                                            " }"
diff --git a/src/Data/SAM/Version1_6/Header/HD.hs b/src/Data/SAM/Version1_6/Header/HD.hs
--- a/src/Data/SAM/Version1_6/Header/HD.hs
+++ b/src/Data/SAM/Version1_6/Header/HD.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.HD
@@ -59,15 +54,15 @@
 
 instance Show SAM_V1_6_File_Level_Metadata where
   show (SAM_V1_6_File_Level_Metadata version sorting_order alignment_grouping subsorting_order) =
-    "SAM_V1_6_File_Level_Metadata { " ++
-    "version = "                      ++
-    (show version)                    ++
-    " , sorting_order = "             ++
-    (show sorting_order)              ++
-    " , alignment_grouping = "        ++
-    (show alignment_grouping)         ++
-    " , subsorting_order = "          ++
-    (show subsorting_order)           ++
+    "SAM_V1_6_File_Level_Metadata { "                       ++
+    "sam_v1_6_file_level_metadata_format_version = "        ++
+    (show version)                                          ++
+    " , sam_v1_6_file_level_metadata_sorting_order = "      ++
+    (show sorting_order)                                    ++
+    " , sam_v1_6_file_level_metadata_alignment_grouping = " ++
+    (show alignment_grouping)                               ++
+    " , sam_v1_6_file_level_metadata_subsorting_order = "   ++
+    (show subsorting_order)                                 ++
     " }" 
 
 -- | VN tag for @"SAM_V1_6_File_Level_Metadata"@.
@@ -80,9 +75,9 @@
 
 instance Show SAM_V1_6_File_Level_Metadata_Format_Version where
   show (SAM_V1_6_File_Level_Metadata_Format_Version value) =
-    "SAM_V1_6_File_Level_Metadata_Format_Version { " ++
-    "value = "                                       ++
-    (show value)                                     ++
+    "SAM_V1_6_File_Level_Metadata_Format_Version { "       ++
+    "sam_v1_6_file_level_metadata_format_version_value = " ++
+    (show value)                                           ++
     " }"
 
 -- | SO tag for @"SAM_V1_6_File_Level_Metadata"@.
@@ -95,9 +90,9 @@
 
 instance Show SAM_V1_6_File_Level_Metadata_Sorting_Order where
   show (SAM_V1_6_File_Level_Metadata_Sorting_Order value) =
-    "SAM_V1_6_File_Level_Metadata_Sorting_Order { " ++
-    "value = "                                      ++
-    (show value)                                    ++
+    "SAM_V1_6_File_Level_Metadata_Sorting_Order { "       ++
+    "sam_v1_6_file_level_metadata_sorting_order_value = " ++
+    (show value)                                          ++
     " }"
 
 -- | GO tag for @"SAM_V1_6_File_Level_Metadata"@.
@@ -110,9 +105,9 @@
 
 instance Show SAM_V1_6_File_Level_Metadata_Alignment_Grouping where
   show (SAM_V1_6_File_Level_Metadata_Alignment_Grouping value) =
-    "SAM_V1_6_File_Level_Metadata_Alignment_Grouping { " ++
-    "value = "                                           ++
-    (show value)                                         ++
+    "SAM_V1_6_File_Level_Metadata_Alignment_Grouping { "       ++
+    "sam_v1_6_file_level_metadata_alignment_grouping_value = " ++
+    (show value)                                               ++
     " }"
 
 -- | SS tag for @"SAM_V1_6_File_Level_Metadata"@.
@@ -125,7 +120,7 @@
 
 instance Show SAM_V1_6_File_Level_Metadata_SubSorting_Order where
   show (SAM_V1_6_File_Level_Metadata_SubSorting_Order value) =
-    "SAM_V1_6_File_Level_Metadata_SubSorting_Order { " ++
-    "value = "                                         ++
-    (show value)                                       ++
+    "SAM_V1_6_File_Level_Metadata_SubSorting_Order { "       ++
+    "sam_v1_6_file_level_metadata_subsorting_order_value = " ++
+    (show value)                                             ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Header/PG.hs b/src/Data/SAM/Version1_6/Header/PG.hs
--- a/src/Data/SAM/Version1_6/Header/PG.hs
+++ b/src/Data/SAM/Version1_6/Header/PG.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.PG
@@ -69,19 +64,19 @@
 
 instance Show SAM_V1_6_Program where
   show (SAM_V1_6_Program record_identifier name command_line previous_pg_id description version) =
-    "SAM_V1_6_Program { "    ++
-    "record_identifier = "   ++
-    (show record_identifier) ++
-    " , name = "             ++
-    (show name)              ++
-    " , command_line = "     ++
-    (show command_line)      ++
-    " , previous_pg_id = "   ++
-    (show previous_pg_id)    ++
-    " , description = "      ++
-    (show description)       ++
-    " , version = "          ++
-    (show version)           ++
+    "SAM_V1_6_Program { "                    ++
+    "rsam_v1_6_program_record_identifier = " ++
+    (show record_identifier)                 ++
+    " , sam_v1_6_program_name = "            ++
+    (show name)                              ++
+    " , sam_v1_6_program_command_line = "    ++
+    (show command_line)                      ++
+    " , sam_v1_6_program_previous_pg_id = "  ++
+    (show previous_pg_id)                    ++
+    " , sam_v1_6_program_description = "     ++
+    (show description)                       ++
+    " , sam_v1_6_program_version = "         ++
+    (show version)                           ++
     " }"
 
 -- | ID tag for @"SAM_V1_6_Program"@.
@@ -94,9 +89,9 @@
 
 instance Show SAM_V1_6_Program_Record_Identifier where
   show (SAM_V1_6_Program_Record_Identifier value) =
-    "SAM_V1_6_Program_Record_Identifier { " ++
-    "value = "                              ++
-    (show value)                            ++
+    "SAM_V1_6_Program_Record_Identifier { "       ++
+    "sam_v1_6_program_record_identifier_value = " ++
+    (show value)                                  ++
     " }"
 
 -- | PN tag for @"SAM_V1_6_Program"@.
@@ -109,9 +104,9 @@
 
 instance Show SAM_V1_6_Program_Name where
   show (SAM_V1_6_Program_Name value) =
-    "SAM_V1_6_Program_Name { " ++
-    "value = "                 ++
-    (show value)               ++
+    "SAM_V1_6_Program_Name { "       ++
+    "sam_v1_6_program_name_value = " ++
+    (show value)                     ++
     " }"
 
 -- | CL tag for @"SAM_V1_6_Program"@.
@@ -124,9 +119,9 @@
 
 instance Show SAM_V1_6_Program_Command_Line where
   show (SAM_V1_6_Program_Command_Line value) =
-    "SAM_V1_6_Program_Command_Line { " ++
-    "value = "                         ++
-    (show value)                       ++
+    "SAM_V1_6_Program_Command_Line { "       ++
+    "sam_v1_6_program_command_line_value = " ++
+    (show value)                             ++
     " }"
 
 -- | PP tag for @"SAM_V1_6_Program"@.
@@ -139,9 +134,9 @@
 
 instance Show SAM_V1_6_Program_Previous_PG_ID where
   show (SAM_V1_6_Program_Previous_PG_ID value) =
-    "SAM_V1_6_Program_Previous_PG_ID { " ++
-    "value = "                           ++
-    (show value)                         ++
+    "SAM_V1_6_Program_Previous_PG_ID { "       ++
+    "sam_v1_6_program_previous_pg_id_value = " ++
+    (show value)                               ++
     " }"
 
 -- | DS tag for @"SAM_V1_6_Program"@.
@@ -154,9 +149,9 @@
 
 instance Show SAM_V1_6_Program_Description where
   show (SAM_V1_6_Program_Description value) =
-    "SAM_V1_6_Program_Description { " ++
-    "value = "                        ++
-    (show value)                      ++
+    "SAM_V1_6_Program_Description { "       ++
+    "sam_v1_6_program_description_value = " ++
+    (show value)                            ++
     " }"
 
 -- | VN tag for @"SAM_V1_6_Program"@.
@@ -169,7 +164,7 @@
 
 instance Show SAM_V1_6_Program_Version where
   show (SAM_V1_6_Program_Version value) =
-    "SAM_V1_6_Program_Version { " ++
-    "value = "                    ++
-    (show value)                  ++
+    "SAM_V1_6_Program_Version { "       ++
+    "sam_v1_6_program_version_value = " ++
+    (show value)                        ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Header/RG.hs b/src/Data/SAM/Version1_6/Header/RG.hs
--- a/src/Data/SAM/Version1_6/Header/RG.hs
+++ b/src/Data/SAM/Version1_6/Header/RG.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.RG
@@ -48,7 +43,7 @@
 -- | Custom SAM (version 1.6) @"SAM_V1_6_Read_Group"@ data type.
 --
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Read_Group = SAM_V1_6_Read_Group { sam_v1_6_read_group_identifer                    :: SAM_V1_6_Read_Group_Identifier
+data SAM_V1_6_Read_Group = SAM_V1_6_Read_Group { sam_v1_6_read_group_identifier                   :: SAM_V1_6_Read_Group_Identifier
                                                , sam_v1_6_read_group_barcode_sequence             :: Maybe SAM_V1_6_Read_Group_Barcode_Sequence
                                                , sam_v1_6_read_group_sequencing_center            :: Maybe SAM_V1_6_Read_Group_Sequencing_Center
                                                , sam_v1_6_read_group_description                  :: Maybe SAM_V1_6_Read_Group_Description
@@ -63,6 +58,7 @@
                                                , sam_v1_6_read_group_platform_unit                :: Maybe SAM_V1_6_Read_Group_Platform_Unit
                                                , sam_v1_6_read_group_sample                       :: Maybe SAM_V1_6_Read_Group_Sample
                                                }
+  deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group where
   SAM_V1_6_Read_Group sam_v1_6_read_group_identifier1
@@ -122,35 +118,35 @@
                             platform_unit
                             sample
        ) =
-    "SAM_V1_6_Read_Group { "                  ++
-    "read_group_identifier = "                ++
-    (show group_identifier)                   ++
-    " , barcode_sequence = "                  ++
-    (show barcode_sequence)                   ++
-    " , sequencing_center = "                 ++
-    (show sequencing_center)                  ++
-    " , description = "                       ++
-    (show description)                        ++
-    " , run_date = "                          ++
-    (show run_date)                           ++
-    " , flow_order = "                        ++
-    (show flow_order)                         ++
-    " , key_sequence = "                      ++
-    (show key_sequence)                       ++
-    " , library = "                           ++
-    (show library)                            ++
-    " , programs = "                          ++
-    (show programs)                           ++
-    " , show_predicted_median_insert_size = " ++
-    (show predicted_median_insert_size)       ++
-    " , platform = "                          ++
-    (show platform)                           ++
-    " , platform_model = "                    ++
-    (show platform_model)                     ++
-    " , platform_unit = "                     ++
-    (show platform_unit)                      ++
-    " , sample = "                            ++
-    (show sample)                             ++
+    "SAM_V1_6_Read_Group { "                                      ++
+    "sam_v1_6_read_group_identifier = "                           ++
+    (show group_identifier)                                       ++
+    " , sam_v1_6_read_group_barcode_sequence = "                  ++
+    (show barcode_sequence)                                       ++
+    " , sam_v1_6_read_group_sequencing_center = "                 ++
+    (show sequencing_center)                                      ++
+    " , sam_v1_6_read_group_description = "                       ++
+    (show description)                                            ++
+    " , sam_v1_6_read_group_run_date = "                          ++
+    (show run_date)                                               ++
+    " , sam_v1_6_read_group_flow_order = "                        ++
+    (show flow_order)                                             ++
+    " , sam_v1_6_read_group_key_sequence = "                      ++
+    (show key_sequence)                                           ++
+    " , sam_v1_6_read_group_library = "                           ++
+    (show library)                                                ++
+    " , sam_v1_6_read_group_programs = "                          ++
+    (show programs)                                               ++
+    " , sam_v1_6_read_group_show_predicted_median_insert_size = " ++
+    (show predicted_median_insert_size)                           ++
+    " , sam_v1_6_read_group_platform = "                          ++
+    (show platform)                                               ++
+    " , sam_v1_6_read_group_platform_model = "                    ++
+    (show platform_model)                                         ++
+    " , sam_v1_6_read_group_platform_unit = "                     ++
+    (show platform_unit)                                          ++
+    " , sam_v1_6_read_group_sample = "                            ++
+    (show sample)                                                 ++
     " }"
 
 -- | ID tag for @"SAM_V1_6_Read_Group"@.
@@ -163,9 +159,9 @@
 
 instance Show SAM_V1_6_Read_Group_Identifier where
   show (SAM_V1_6_Read_Group_Identifier value) =
-    "SAM_V1_6_Read_Group_Identifier { " ++
-    "value = "                          ++
-    (show value)                        ++
+    "SAM_V1_6_Read_Group_Identifier { "       ++
+    "sam_v1_6_read_group_identifier_value = " ++
+    (show value)                              ++
     " }"
 
 -- | BC tag for @"SAM_V1_6_Read_Group"@.
@@ -178,9 +174,9 @@
 
 instance Show SAM_V1_6_Read_Group_Barcode_Sequence where
   show (SAM_V1_6_Read_Group_Barcode_Sequence value) =
-    "SAM_V1_6_Read_Group_Barcode_Sequence { " ++
-    "value = "                                ++
-    (show value)                              ++
+    "SAM_V1_6_Read_Group_Barcode_Sequence { "       ++
+    "sam_v1_6_read_group_barcode_sequence_value = " ++
+    (show value)                                    ++
     " }"
 
 -- | CN tag for @"SAM_V1_6_Read_Group"@.
@@ -193,9 +189,9 @@
 
 instance Show SAM_V1_6_Read_Group_Sequencing_Center where
   show (SAM_V1_6_Read_Group_Sequencing_Center value) =
-    "SAM_V1_6_Read_Group_Sequencing_Center { " ++
-    "value = "                                 ++
-    (show value)                               ++
+    "SAM_V1_6_Read_Group_Sequencing_Center { "       ++
+    "sam_v1_6_read_group_sequencing_center_value = " ++
+    (show value)                                     ++
     " }"
 
 -- | DS tag for @"SAM_V1_6_Read_Group"@.
@@ -208,9 +204,9 @@
 
 instance Show SAM_V1_6_Read_Group_Description where
   show (SAM_V1_6_Read_Group_Description value) =
-    "SAM_V1_6_Read_Group_Description { " ++
-    "value = "                           ++
-    (show value)                         ++
+    "SAM_V1_6_Read_Group_Description { "       ++
+    "sam_v1_6_read_group_description_value = " ++
+    (show value)                               ++
     " }"
 
 -- | DT tag for @"SAM_V1_6_Read_Group"@.
@@ -223,9 +219,9 @@
 
 instance Show SAM_V1_6_Read_Group_Run_Date where
   show (SAM_V1_6_Read_Group_Run_Date value) =
-    "SAM_V1_6_Read_Group_Run_Date { " ++
-    "value = "                        ++
-    (show value)                      ++
+    "SAM_V1_6_Read_Group_Run_Date { "       ++
+    "sam_v1_6_read_group_run_date_value = " ++
+    (show value)                            ++
     " }"
 
 -- | FO tag for @"SAM_V1_6_Read_Group"@.
@@ -238,9 +234,9 @@
 
 instance Show SAM_V1_6_Read_Group_Flow_Order where
   show (SAM_V1_6_Read_Group_Flow_Order value) =
-    "SAM_V1_6_Read_Group_Flow_Order { " ++
-    "value = "                          ++
-    (show value)                        ++
+    "SAM_V1_6_Read_Group_Flow_Order { "       ++
+    "sam_v1_6_read_group_flow_order_value = " ++
+    (show value)                              ++
     " }"
 
 -- | KS tag for @"SAM_V1_6_Read_Group"@.
@@ -253,9 +249,9 @@
 
 instance Show SAM_V1_6_Read_Group_Key_Sequence where
   show (SAM_V1_6_Read_Group_Key_Sequence value) =
-    "SAM_V1_6_Read_Group_Key_Sequence { " ++
-    "value = "                            ++
-    (show value)                          ++
+    "SAM_V1_6_Read_Group_Key_Sequence { "       ++
+    "sam_v1_6_read_group_key_sequence_value = " ++
+    (show value)                                ++
     " }"
 
 -- | LB tag for @"SAM_V1_6_Read_Group"@.
@@ -268,9 +264,9 @@
 
 instance Show SAM_V1_6_Read_Group_Library where
   show (SAM_V1_6_Read_Group_Library value) =
-    "SAM_V1_6_Read_Group_Library { " ++
-    "value = "                       ++
-    (show value)                     ++
+    "SAM_V1_6_Read_Group_Library { "       ++
+    "sam_v1_6_read_group_library_value = " ++
+    (show value)                           ++
     " }"
 
 -- | PG tag for @"SAM_V1_6_Read_Group"@.
@@ -283,9 +279,9 @@
 
 instance Show SAM_V1_6_Read_Group_Programs where
   show (SAM_V1_6_Read_Group_Programs value) =
-    "SAM_V1_6_Read_Group_Programs { " ++
-    "value = "                        ++
-    (show value)                      ++
+    "SAM_V1_6_Read_Group_Programs { "       ++
+    "sam_v1_6_read_group_programs_value = " ++
+    (show value)                            ++
     " }"
 
 -- | PI tag for @"SAM_V1_6_Read_Group"@.
@@ -298,9 +294,9 @@
 
 instance Show SAM_V1_6_Read_Group_Predicted_Median_Insert_Size where
   show (SAM_V1_6_Read_Group_Predicted_Median_Insert_Size value) =
-    "SAM_V1_6_Read_Group_Predicted_Median_Insert_Size { " ++
-    "value = "                                            ++
-    (show value)                                          ++
+    "SAM_V1_6_Read_Group_Predicted_Median_Insert_Size { "       ++
+    "sam_v1_6_read_group_predicted_median_insert_size_value = " ++
+    (show value)                                                ++
     " }"
 
 -- | PL tag for @"SAM_V1_6_Read_Group"@.
@@ -313,9 +309,9 @@
 
 instance Show SAM_V1_6_Read_Group_Platform where
   show (SAM_V1_6_Read_Group_Platform value) =
-    "SAM_V1_6_Read_Group_Platform { " ++
-    "value = "                        ++
-    (show value)                      ++
+    "SAM_V1_6_Read_Group_Platform { "       ++
+    "sam_v1_6_read_group_platform_value = " ++
+    (show value)                            ++
     " }"
 
 -- | PM tag for @"SAM_V1_6_Read_Group"@.
@@ -328,9 +324,9 @@
 
 instance Show SAM_V1_6_Read_Group_Platform_Model where
   show (SAM_V1_6_Read_Group_Platform_Model value) =
-    "SAM_V1_6_Read_Group_Platform_Model { " ++
-    "value = "                              ++
-    (show value)                            ++
+    "SAM_V1_6_Read_Group_Platform_Model { "       ++
+    "sam_v1_6_read_group_platform_model_value = " ++
+    (show value)                                  ++
     " }"
 
 -- | PU tag for @"SAM_V1_6_Read_Group"@.
@@ -343,9 +339,9 @@
 
 instance Show SAM_V1_6_Read_Group_Platform_Unit where
   show (SAM_V1_6_Read_Group_Platform_Unit value) =
-    "SAM_V1_6_Read_Group_Platform_Unit { " ++
-    "value = "                             ++
-    (show value)                           ++
+    "SAM_V1_6_Read_Group_Platform_Unit { "       ++
+    "sam_v1_6_read_group_platform_unit_value = " ++
+    (show value)                                 ++
     " }"
 
 -- | SM tag for @"SAM_V1_6_Read_Group"@.
@@ -358,7 +354,7 @@
 
 instance Show SAM_V1_6_Read_Group_Sample where
   show (SAM_V1_6_Read_Group_Sample value) =
-    "SAM_V1_6_Read_Group_Sample { " ++
-    "value = "                      ++
-    (show value)                    ++
+    "SAM_V1_6_Read_Group_Sample { "       ++
+    "sam_v1_6_read_group_sample_value = " ++
+    (show value)                          ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Header/SQ.hs b/src/Data/SAM/Version1_6/Header/SQ.hs
--- a/src/Data/SAM/Version1_6/Header/SQ.hs
+++ b/src/Data/SAM/Version1_6/Header/SQ.hs
@@ -3,13 +3,8 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
 {-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.SQ
@@ -46,8 +41,8 @@
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 data SAM_V1_6_Reference_Sequence_Dictionary = SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name                        :: SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name
                                                                                      , sam_v1_6_reference_sequence_dictionary_reference_sequence_length                      :: SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length
-                                                                                     , sam_v1_6_reference_sequence_dictionary_reference_alternative_locus                    :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
-                                                                                     , sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
+                                                                                     , sam_v1_6_reference_sequence_dictionary_alternative_locus                              :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
+                                                                                     , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names           :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
                                                                                      , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier                     :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier
                                                                                      , sam_v1_6_reference_sequence_dictionary_description                                    :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Description
                                                                                      , sam_v1_6_reference_sequence_dictionary_md5_checksum                                   :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum
@@ -99,27 +94,27 @@
                                                molecule_topology
                                                uri
        ) =
-    "SAM_V1_6_Reference_Sequence_Dictionary { "  ++
-    "reference_sequence_name = "                 ++
-    (show reference_sequence_name)               ++
-    " , reference_sequence_length = "            ++
-    (show reference_sequence_length)             ++
-    " , reference_alternative_locus = "          ++
-    (show reference_alternative_locus)           ++
-    " , reference_alternative_sequence_names = " ++
-    (show reference_alternative_sequence_names)  ++
-    " , genome_assembly_identifier = "           ++
-    (show genome_assembly_identifier)            ++
-    " , description = "                          ++
-    (show description)                           ++
-    " , md5_checksum = "                         ++
-    (show md5_checksum)                          ++
-    " , species = "                              ++
-    (show species)                               ++
-    " , molecule_topology = "                    ++
-    (show molecule_topology)                     ++
-    " , uri = "                                  ++
-    (show uri)                                   ++
+    "SAM_V1_6_Reference_Sequence_Dictionary { "                                         ++
+    "sam_v1_6_reference_sequence_dictionary_reference_sequence_name = "                 ++
+    (show reference_sequence_name)                                                      ++
+    " , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = "            ++
+    (show reference_sequence_length)                                                    ++
+    " , sam_v1_6_reference_sequence_dictionary_alternative_locus = "                    ++
+    (show reference_alternative_locus)                                                  ++
+    " , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = " ++
+    (show reference_alternative_sequence_names)                                         ++
+    " , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = "           ++
+    (show genome_assembly_identifier)                                                   ++
+    " , sam_v1_6_reference_sequence_dictionary_description = "                          ++
+    (show description)                                                                  ++
+    " , sam_v1_6_reference_sequence_dictionary_md5_checksum = "                         ++
+    (show md5_checksum)                                                                 ++
+    " , sam_v1_6_reference_sequence_dictionary_species = "                              ++
+    (show species)                                                                      ++
+    " , sam_v1_6_reference_sequence_dictionary_molecule_topology = "                    ++
+    (show molecule_topology)                                                            ++
+    " , sam_v1_6_reference_sequence_dictionary_uri = "                                  ++
+    (show uri)                                                                          ++
     " }"
 
 -- | SN tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -132,9 +127,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { " ++
-    "value = "                                                          ++
-    (show value)                                                        ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { "       ++
+    "sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = " ++
+    (show value)                                                              ++
     " }"
 
 -- | LN tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -147,9 +142,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { " ++
-    "value = "                                                            ++
-    (show value)                                                          ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { "       ++
+    "sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = " ++
+    (show value)                                                                ++
     " }"
 
 -- | AH tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -162,9 +157,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus { " ++
-    "value = "                                                    ++
-    (show value)                                                  ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus { "       ++
+    "sam_v1_6_reference_sequence_dictionary_alternative_locus_value = " ++
+    (show value)                                                        ++
     " }"
 
 -- | AN tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -177,9 +172,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names { " ++
-    "value = "                                                                       ++
-    (show value)                                                                     ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names { "       ++
+    "sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value = " ++
+    (show value)                                                                           ++
     " }"
 
 -- | AS tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -192,9 +187,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier { " ++
-    "value = "                                                             ++
-    (show value)                                                           ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier { "       ++
+    "sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value = " ++
+    (show value)                                                                 ++
     " }"
 
 -- | DS tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -207,9 +202,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Description where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Description value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Description { " ++
-    "value = "                                              ++
-    (show value)                                            ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Description { "       ++
+    "sam_v1_6_reference_sequence_dictionary_description_value = " ++
+    (show value)                                                  ++
     " }"
 
 -- | M5 tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -222,9 +217,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum where
   show (SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum { " ++
-    "value = "                                               ++
-    (show value)                                             ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum { "       ++
+    "sam_v1_6_reference_sequence_dictionary_md5_checksum_value = " ++
+    (show value)                                                   ++
     " }"
 
 -- | SP tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -237,9 +232,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Species where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Species value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Species { " ++
-    "value = "                                          ++
-    (show value)                                        ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Species { "       ++
+    "sam_v1_6_reference_sequence_dictionary_species_value = " ++
+    (show value)                                              ++
     " }"
 
 -- | TP tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -252,9 +247,9 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology { " ++
-    "value = "                                                    ++
-    (show value)                                                  ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology { "       ++
+    "sam_v1_6_reference_sequence_dictionary_molecule_topology_value = " ++
+    (show value)                                                        ++
     " }"
 
 -- | UR tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
@@ -267,7 +262,7 @@
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_URI where
   show (SAM_V1_6_Reference_Sequence_Dictionary_URI value) =
-    "SAM_V1_6_Reference_Sequence_Dictionary_URI { " ++
-    "value = "                                      ++
-    (show value)                                    ++
+    "SAM_V1_6_Reference_Sequence_Dictionary_URI { "       ++
+    "sam_v1_6_reference_sequence_dictionary_uri_value = " ++
+    (show value)                                          ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Read/Base.hs b/src/Data/SAM/Version1_6/Read/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Base.hs
@@ -113,7 +113,7 @@
 -- The file is checked for errors as it is parsed.
 --
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-readSAM_V1_6 :: FilePath -- ^ Path to SAM file.
+readSAM_V1_6 :: FilePath -- ^ Input path to SAM file.
              -> IO SAM_V1_6
 readSAM_V1_6 fp = do
   let lazysamfile = S.unfold StreamlyInternalFile.chunkReader fp
diff --git a/src/Data/SAM/Version1_6/Read/Error.hs b/src/Data/SAM/Version1_6/Read/Error.hs
--- a/src/Data/SAM/Version1_6/Read/Error.hs
+++ b/src/Data/SAM/Version1_6/Read/Error.hs
@@ -3,13 +3,7 @@
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Error
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs
@@ -43,24 +43,24 @@
                                                         parse_SAM_V1_6_Alignment_AOPT
                                                       ) where
 
+import Data.SAM.Version1_6.Alignment.AOPT
 import Data.SAM.Version1_6.Read.Error
 
 import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
 import           Data.Attoparsec.ByteString.Lazy   as DABL
-import qualified Data.ByteString                   as DB
 import           Text.Regex.PCRE.Heavy
 
 -- | Defines a parser for the optional aopt 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_AOPT :: Parser DB.ByteString
+parse_SAM_V1_6_Alignment_AOPT :: Parser SAM_V1_6_Alignment_AOPT
 parse_SAM_V1_6_Alignment_AOPT = do
-  _ <- do alignmentaoptfieldtagp <- DABL.takeTill (== 58)
-          -- Parse AOPT tag of the alignment section.
-          case (alignmentaoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_AOPT_Tag_Incorrect_Format
-            True  -> -- AOPT tag is in the accepted format. 
-                     return ()
+  alignmentaoptfieldtag <- do alignmentaoptfieldtagp <- DABL.takeTill (== 58)
+                              -- Parse AOPT tag of the alignment section.
+                              case (alignmentaoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+                                False -> fail $ show SAM_V1_6_Error_Alignment_AOPT_Tag_Incorrect_Format
+                                True  -> -- AOPT tag is in the accepted format. 
+                                         return alignmentaoptfieldtagp
   _ <- word8 58
   _ <- do alignmentaoptfieldtypep <- DABL.takeTill (== 58)
           -- Parse AOPT type of the alignment section.
@@ -75,4 +75,6 @@
                                   False -> fail $ show SAM_V1_6_Error_Alignment_AOPT_Value_Incorrect_Format
                                   True  -> -- AOPT value is in the accepted format.
                                            return alignmentaoptfieldvaluep
-  return alignmentaoptfieldvalue
+  return SAM_V1_6_Alignment_AOPT { sam_v1_6_alignment_aopt_tag   = alignmentaoptfieldtag
+                                 , sam_v1_6_alignment_aopt_value = alignmentaoptfieldvalue
+                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs
@@ -43,6 +43,7 @@
                                                         parse_SAM_V1_6_Alignment_FOPT
                                                       ) where
 
+import Data.SAM.Version1_6.Alignment.FOPT
 import Data.SAM.Version1_6.Read.Error
 
 import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
@@ -53,14 +54,14 @@
 -- | Defines a parser for the optional fopt 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_FOPT :: Parser Float
+parse_SAM_V1_6_Alignment_FOPT :: Parser SAM_V1_6_Alignment_FOPT
 parse_SAM_V1_6_Alignment_FOPT = do
-  _ <- do alignmentfoptfieldtagp <- DABL.takeTill (== 58)
-          -- Parse FOPT tag of the alignment section.
-          case (alignmentfoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_FOPT_Tag_Incorrect_Format
-            True  -> -- FOPT tag is in the accepted format. 
-                     return ()
+  alignmentfoptfieldtag <- do alignmentfoptfieldtagp <- DABL.takeTill (== 58)
+                              -- Parse FOPT tag of the alignment section.
+                              case (alignmentfoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+                                False -> fail $ show SAM_V1_6_Error_Alignment_FOPT_Tag_Incorrect_Format
+                                True  -> -- FOPT tag is in the accepted format. 
+                                         return alignmentfoptfieldtagp
   _ <- word8 58
   _ <- do alignmentfoptfieldtypep <- DABL.takeTill (== 58)
           -- Parse FOPT type of the alignment section.
@@ -77,4 +78,6 @@
                                            case (DBC8.readInteger alignmentfoptfieldvaluep) of
                                              Nothing                                 -> return (-1)
                                              Just (alignmentfoptfieldvalueinteger,_) -> return $ (fromInteger alignmentfoptfieldvalueinteger :: Float)
-  return alignmentfoptfieldvalue
+  return SAM_V1_6_Alignment_FOPT { sam_v1_6_alignment_fopt_tag   = alignmentfoptfieldtag
+                                 , sam_v1_6_alignment_fopt_value = alignmentfoptfieldvalue
+                                 } 
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs
@@ -43,26 +43,24 @@
                                                         parse_SAM_V1_6_Alignment_HOPT
                                                       ) where
 
+import Data.SAM.Version1_6.Alignment.HOPT
 import Data.SAM.Version1_6.Read.Error
 
 import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
 import           Data.Attoparsec.ByteString.Lazy   as DABL
-import qualified Data.ByteString                   as DB
-import           Data.Sequence                     as DSeq
-import           Data.Word
 import           Text.Regex.PCRE.Heavy
 
 -- | Defines a parser for the optional hopt 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_HOPT :: Parser (Seq Word8)
+parse_SAM_V1_6_Alignment_HOPT :: Parser SAM_V1_6_Alignment_HOPT
 parse_SAM_V1_6_Alignment_HOPT = do
-  _ <- do alignmenthoptfieldtagp <- DABL.takeTill (== 58)
-          -- Parse HOPT tag of the alignment section.
-          case (alignmenthoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_HOPT_Tag_Incorrect_Format
-            True  -> -- HOPT tag is in the accepted format. 
-                     return ()
+  alignmenthoptfieldtag <- do alignmenthoptfieldtagp <- DABL.takeTill (== 58)
+                              -- Parse HOPT tag of the alignment section.
+                              case (alignmenthoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+                                False -> fail $ show SAM_V1_6_Error_Alignment_HOPT_Tag_Incorrect_Format
+                                True  -> -- HOPT tag is in the accepted format. 
+                                         return alignmenthoptfieldtagp
   _ <- word8 58
   _ <- do alignmenthoptfieldtypep <- DABL.takeTill (== 58)
           -- Parse HOPT type of the alignment section.
@@ -76,5 +74,7 @@
                                 case (alignmenthoptfieldvaluep =~ [re|([0-9A-F][0-9A-F])*|]) of
                                   False -> fail $ show SAM_V1_6_Error_Alignment_HOPT_Value_Incorrect_Format
                                   True  -> -- HOPT value is in the accepted format.
-                                           return $ DSeq.fromList $ DB.unpack alignmenthoptfieldvaluep
-  return alignmenthoptfieldvalue
+                                           return alignmenthoptfieldvaluep
+  return SAM_V1_6_Alignment_HOPT { sam_v1_6_alignment_hopt_tag   = alignmenthoptfieldtag
+                                 , sam_v1_6_alignment_hopt_value = alignmenthoptfieldvalue
+                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs
@@ -43,6 +43,7 @@
                                                         parse_SAM_V1_6_Alignment_IOPT
                                                       ) where
 
+import Data.SAM.Version1_6.Alignment.IOPT
 import Data.SAM.Version1_6.Read.Error
 
 import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
@@ -53,14 +54,14 @@
 -- | Defines a parser for the optional iopt 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_IOPT :: Parser Integer
+parse_SAM_V1_6_Alignment_IOPT :: Parser SAM_V1_6_Alignment_IOPT
 parse_SAM_V1_6_Alignment_IOPT = do
-  _ <- do alignmentioptfieldtagp <- DABL.takeTill (== 58)
-          -- Parse IOPT tag of the alignment section.
-          case (alignmentioptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_IOPT_Tag_Incorrect_Format
-            True  -> -- IOPT tag is in the accepted format. 
-                     return ()
+  alignmentioptfieldtag <- do alignmentioptfieldtagp <- DABL.takeTill (== 58)
+                              -- Parse IOPT tag of the alignment section.
+                              case (alignmentioptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+                                False -> fail $ show SAM_V1_6_Error_Alignment_IOPT_Tag_Incorrect_Format
+                                True  -> -- IOPT tag is in the accepted format. 
+                                         return alignmentioptfieldtagp
   _ <- word8 58
   _ <- do alignmentioptfieldtypep <- DABL.takeTill (== 58)
           -- Parse IOPT type of the alignment section.
@@ -77,4 +78,6 @@
                                            case (DBC8.readInteger alignmentioptfieldvaluep) of
                                              Nothing                                 -> return (-1)
                                              Just (alignmentioptfieldvalueinteger,_) -> return alignmentioptfieldvalueinteger
-  return alignmentioptfieldvalue
+  return SAM_V1_6_Alignment_IOPT { sam_v1_6_alignment_iopt_tag   = alignmentioptfieldtag
+                                 , sam_v1_6_alignment_iopt_value = alignmentioptfieldvalue
+                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs
@@ -43,24 +43,24 @@
                                                         parse_SAM_V1_6_Alignment_ZOPT
                                                       ) where
 
+import Data.SAM.Version1_6.Alignment.ZOPT
 import Data.SAM.Version1_6.Read.Error
 
 import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
 import           Data.Attoparsec.ByteString.Lazy   as DABL
-import qualified Data.ByteString                   as DB
 import           Text.Regex.PCRE.Heavy
 
 -- | Defines a parser for the optional zopt 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_ZOPT :: Parser DB.ByteString
+parse_SAM_V1_6_Alignment_ZOPT :: Parser SAM_V1_6_Alignment_ZOPT
 parse_SAM_V1_6_Alignment_ZOPT = do
-  _ <- do alignmentzoptfieldtagp <- DABL.takeTill (== 58)
-          -- Parse ZOPT tag of the alignment section.
-          case (alignmentzoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_ZOPT_Tag_Incorrect_Format
-            True  -> -- ZOPT tag is in the accepted format. 
-                     return ()
+  alignmentzoptfieldtag <- do alignmentzoptfieldtagp <- DABL.takeTill (== 58)
+                              -- Parse ZOPT tag of the alignment section.
+                              case (alignmentzoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+                                False -> fail $ show SAM_V1_6_Error_Alignment_ZOPT_Tag_Incorrect_Format
+                                True  -> -- ZOPT tag is in the accepted format. 
+                                         return alignmentzoptfieldtagp
   _ <- word8 58
   _ <- do alignmentzoptfieldtypep <- DABL.takeTill (== 58)
           -- Parse ZOPT type of the alignment section.
@@ -75,4 +75,6 @@
                                   False -> fail $ show SAM_V1_6_Error_Alignment_ZOPT_Value_Incorrect_Format
                                   True  -> -- ZOPT value is in the accepted format.
                                            return alignmentzoptfieldvaluep
-  return alignmentzoptfieldvalue
+  return SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag   = alignmentzoptfieldtag
+                                 , sam_v1_6_alignment_zopt_value = alignmentzoptfieldvalue
+                                 }
diff --git a/src/Data/SAM/Version1_6/Write/Base.hs b/src/Data/SAM/Version1_6/Write/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Write/Base.hs
@@ -0,0 +1,551 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Write.Base
+-- Copyright   :  (c) Matthew Mosior 2023
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Write.Base ( -- * Writing
+                                       writeSAM_V1_6
+                                      ) where
+
+import Data.SAM.Version1_6.Base
+import Data.SAM.Version1_6.Header.HD
+import Data.SAM.Version1_6.Header.SQ
+import Data.SAM.Version1_6.Header.RG
+import Data.SAM.Version1_6.Header.PG
+import Data.SAM.Version1_6.Header.CO
+import Data.SAM.Version1_6.Alignment.Base
+import Data.SAM.Version1_6.Alignment.AOPT
+import Data.SAM.Version1_6.Alignment.IOPT
+import Data.SAM.Version1_6.Alignment.FOPT
+import Data.SAM.Version1_6.Alignment.ZOPT
+import Data.SAM.Version1_6.Alignment.HOPT
+import Data.SAM.Version1_6.Alignment.BOPT
+
+import Data.ByteString            as DB    (pack,singleton)
+import Data.ByteString.Lazy.Char8 as DBLC8 (fromStrict,unpack)
+import Data.Foldable                       (toList)
+import Data.Int                            (Int8,Int16,Int32)
+import Data.List                           (intercalate)
+import Data.Word
+import Data.ByteString.Builder             (toLazyByteString,word16LE,word32LE)
+import System.IO                           (hFlush,hClose,hPutStr,IOMode(..),openFile, Handle)
+
+
+-- | Deconstruct a @"SAM_V1_6"@ to a `String`.
+deconstructSAM_V1_6 :: SAM_V1_6
+                    -> String
+deconstructSAM_V1_6 samv16 =
+  ( intercalate "\n" $
+      filter (not . null) [ sam_v1_6_file_level_metadata_tos
+                          , sam_v1_6_reference_sequence_dictionary_tos
+                          , sam_v1_6_read_group_tos
+                          , sam_v1_6_program_tos
+                          , sam_v1_6_one_line_comment_tos
+                          , sam_v1_6_alignment_tos
+                          ]
+  )
+  ++ "\n"
+  where
+    sam_v1_6_file_level_metadata_format_version_tos x = "VN:" ++
+                                                        ( unpack     $
+                                                          fromStrict $
+                                                          sam_v1_6_file_level_metadata_format_version_value $
+                                                          sam_v1_6_file_level_metadata_format_version x
+                                                        )
+    sam_v1_6_file_level_metadata_sorting_order_tos x = case (sam_v1_6_file_level_metadata_sorting_order x) of
+                                                         Nothing  -> ""
+                                                         Just rgf -> "SO:" ++
+                                                                     ( unpack     $
+                                                                       fromStrict $
+                                                                       sam_v1_6_file_level_metadata_sorting_order_value rgf
+                                                                     )
+    sam_v1_6_file_level_metadata_alignment_grouping_tos x = case (sam_v1_6_file_level_metadata_alignment_grouping x) of
+                                                              Nothing  -> ""
+                                                              Just rgf -> "GO:" ++
+                                                                          ( unpack     $
+                                                                            fromStrict $
+                                                                            sam_v1_6_file_level_metadata_alignment_grouping_value rgf
+                                                                          )
+    sam_v1_6_file_level_metadata_subsorting_order_tos x = case (sam_v1_6_file_level_metadata_subsorting_order x) of
+                                                            Nothing  -> ""
+                                                            Just rgf -> "SS:" ++
+                                                                        ( unpack     $
+                                                                          fromStrict $
+                                                                          sam_v1_6_file_level_metadata_subsorting_order_value rgf
+                                                                        )
+    sam_v1_6_file_level_metadata_tos = case (sam_v1_6_file_level_metadata samv16) of
+                                         Nothing  -> ""
+                                         Just hdf -> intercalate "\t" $
+                                                       filter (not . null) $
+                                                         [ "@HD"
+                                                         , sam_v1_6_file_level_metadata_format_version_tos hdf
+                                                         , sam_v1_6_file_level_metadata_sorting_order_tos hdf
+                                                         , sam_v1_6_file_level_metadata_alignment_grouping_tos hdf
+                                                         , sam_v1_6_file_level_metadata_subsorting_order_tos hdf 
+                                                         ]
+    sam_v1_6_reference_sequence_dictionary_reference_sequence_name_tos x = "SN:" ++
+                                                                           ( unpack                                                               $
+                                                                             fromStrict                                                           $
+                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value $
+                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_name x
+                                                                           )
+    sam_v1_6_reference_sequence_dictionary_reference_sequence_length_tos x = "LN:" ++
+                                                                             ( unpack                                                                 $
+                                                                               fromStrict                                                             $
+                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value $
+                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length x
+                                                                             )
+    sam_v1_6_reference_sequence_dictionary_alternative_locus_tos x = case (sam_v1_6_reference_sequence_dictionary_alternative_locus x) of
+                                                                       Nothing  -> ""
+                                                                       Just sqf -> "AH:" ++
+                                                                                   ( unpack     $
+                                                                                     fromStrict $
+                                                                                     sam_v1_6_reference_sequence_dictionary_alternative_locus_value sqf
+                                                                                   )
+    sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_tos x = case (sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names x) of
+                                                                                          Nothing  -> "" 
+                                                                                          Just sqf -> "AN:" ++
+                                                                                                      ( unpack     $
+                                                                                                        fromStrict $
+                                                                                                        sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value sqf
+                                                                                                      )
+    sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_tos x = case (sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier x) of
+                                                                                Nothing  -> ""
+                                                                                Just sqf -> "AS:" ++
+                                                                                            ( unpack     $
+                                                                                              fromStrict $
+                                                                                              sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value sqf
+                                                                                            )
+    sam_v1_6_reference_sequence_dictionary_description_tos x = case (sam_v1_6_reference_sequence_dictionary_description x) of
+                                                                 Nothing  -> ""
+                                                                 Just sqf -> "DS:" ++
+                                                                             ( unpack     $
+                                                                               fromStrict $
+                                                                               sam_v1_6_reference_sequence_dictionary_description_value sqf
+                                                                             )
+    sam_v1_6_reference_sequence_dictionary_md5_checksum_tos x = case (sam_v1_6_reference_sequence_dictionary_md5_checksum x) of
+                                                                  Nothing  -> ""
+                                                                  Just sqf -> "M5:" ++
+                                                                              ( unpack     $
+                                                                                fromStrict $
+                                                                                sam_v1_6_reference_sequence_dictionary_md5_checksum_value sqf
+                                                                              )
+    sam_v1_6_reference_sequence_dictionary_species_tos x = case (sam_v1_6_reference_sequence_dictionary_species x) of
+                                                             Nothing  -> ""
+                                                             Just sqf -> "SP:" ++
+                                                                         ( unpack     $
+                                                                           fromStrict $
+                                                                           sam_v1_6_reference_sequence_dictionary_species_value sqf
+                                                                         )
+    sam_v1_6_reference_sequence_dictionary_molecule_topology_tos x = case (sam_v1_6_reference_sequence_dictionary_molecule_topology x) of
+                                                                       Nothing  -> ""
+                                                                       Just sqf -> "TP:" ++
+                                                                                   ( unpack     $
+                                                                                     fromStrict $
+                                                                                     sam_v1_6_reference_sequence_dictionary_molecule_topology_value sqf
+                                                                                   )
+    sam_v1_6_reference_sequence_dictionary_uri_tos x = case (sam_v1_6_reference_sequence_dictionary_uri x) of
+                                                         Nothing  -> ""
+                                                         Just sqf -> "UR:" ++
+                                                                     ( unpack     $
+                                                                       fromStrict $
+                                                                       sam_v1_6_reference_sequence_dictionary_uri_value sqf
+                                                                     )
+    sam_v1_6_reference_sequence_dictionary_tos = case (sam_v1_6_reference_sequence_dictionary samv16) of
+                                                   Nothing  -> ""
+                                                   Just sqf -> intercalate "\n" $
+                                                                   map (\x -> intercalate "\t" $
+                                                                                filter (not .null) $
+                                                                                            [ "@SQ"
+                                                                                            , sam_v1_6_reference_sequence_dictionary_reference_sequence_name_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_reference_sequence_length_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_alternative_locus_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_description_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_md5_checksum_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_species_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_molecule_topology_tos x
+                                                                                            , sam_v1_6_reference_sequence_dictionary_uri_tos x
+                                                                                            ]
+                                                                       ) (toList sqf)
+    sam_v1_6_read_group_identifer_tos x = "ID:" ++
+                                          ( unpack                               $
+                                            fromStrict                           $
+                                            sam_v1_6_read_group_identifier_value $
+                                            sam_v1_6_read_group_identifier x
+                                          )
+    sam_v1_6_read_group_barcode_sequence_tos x = case (sam_v1_6_read_group_barcode_sequence x) of
+                                                   Nothing  -> ""
+                                                   Just rgf -> "BC:" ++
+                                                               ( unpack     $
+                                                                 fromStrict $
+                                                                 sam_v1_6_read_group_barcode_sequence_value rgf
+                                                               )
+    sam_v1_6_read_group_sequencing_center_tos x = case (sam_v1_6_read_group_sequencing_center x) of
+                                                    Nothing  -> ""
+                                                    Just rgf -> "CN:" ++
+                                                                ( unpack     $
+                                                                  fromStrict $
+                                                                  sam_v1_6_read_group_sequencing_center_value rgf
+                                                                )
+    sam_v1_6_read_group_description_tos x = case (sam_v1_6_read_group_description x) of
+                                              Nothing  -> ""
+                                              Just rgf -> "DS:" ++
+                                                          ( unpack     $
+                                                            fromStrict $
+                                                            sam_v1_6_read_group_description_value rgf
+                                                          )
+    sam_v1_6_read_group_run_date_tos x = case (sam_v1_6_read_group_run_date x) of
+                                           Nothing  -> ""
+                                           Just rgf -> "DT:" ++
+                                                       ( unpack     $
+                                                         fromStrict $
+                                                         sam_v1_6_read_group_run_date_value rgf
+                                                       )
+    sam_v1_6_read_group_flow_order_tos x = case (sam_v1_6_read_group_flow_order x) of
+                                             Nothing  -> ""
+                                             Just rgf -> "FO:" ++
+                                                         ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_read_group_flow_order_value rgf
+                                                         )
+    sam_v1_6_read_group_key_sequence_tos x = case (sam_v1_6_read_group_key_sequence x) of
+                                               Nothing  -> ""
+                                               Just rgf -> "KS:" ++
+                                                           ( unpack     $
+                                                             fromStrict $
+                                                             sam_v1_6_read_group_key_sequence_value rgf
+                                                           )
+    sam_v1_6_read_group_library_tos x = case (sam_v1_6_read_group_library x) of
+                                          Nothing  -> ""
+                                          Just rgf -> "LB:" ++
+                                                      ( unpack     $
+                                                        fromStrict $
+                                                        sam_v1_6_read_group_library_value rgf
+                                                      )
+    sam_v1_6_read_group_programs_tos x = case (sam_v1_6_read_group_programs x) of
+                                           Nothing  -> ""
+                                           Just rgf -> "PG:" ++
+                                                       ( unpack     $
+                                                         fromStrict $
+                                                         sam_v1_6_read_group_programs_value rgf
+                                                       )
+    sam_v1_6_read_group_predicted_median_insert_size_tos x = case (sam_v1_6_read_group_predicted_median_insert_size x) of
+                                                               Nothing  -> ""
+                                                               Just rgf -> "PI:" ++
+                                                                           ( unpack     $
+                                                                             fromStrict $
+                                                                             sam_v1_6_read_group_predicted_median_insert_size_value rgf
+                                                                           )
+    sam_v1_6_read_group_platform_tos x = case (sam_v1_6_read_group_platform x) of
+                                           Nothing  -> ""
+                                           Just rgf -> "PL:" ++
+                                                       ( unpack     $
+                                                         fromStrict $
+                                                         sam_v1_6_read_group_platform_value rgf
+                                                       )
+    sam_v1_6_read_group_platform_model_tos x = case (sam_v1_6_read_group_platform_model x) of
+                                                 Nothing  -> ""
+                                                 Just rgf -> "PM:" ++
+                                                             ( unpack     $
+                                                               fromStrict $
+                                                               sam_v1_6_read_group_platform_model_value rgf
+                                                             )
+    sam_v1_6_read_group_platform_unit_tos x = case (sam_v1_6_read_group_platform_unit x) of
+                                                Nothing  -> ""
+                                                Just rgf -> "PU:" ++
+                                                            ( unpack     $
+                                                              fromStrict $
+                                                              sam_v1_6_read_group_platform_unit_value rgf
+                                                            )
+    sam_v1_6_read_group_sample_tos x = case (sam_v1_6_read_group_sample x) of
+                                         Nothing  -> ""
+                                         Just rgf -> "SM:" ++
+                                                     ( unpack     $
+                                                       fromStrict $
+                                                       sam_v1_6_read_group_sample_value rgf
+                                                     )
+    sam_v1_6_read_group_tos = case (sam_v1_6_read_group samv16) of
+                                Nothing  -> ""
+                                Just rgf -> intercalate "\n" $
+                                              map (\x -> intercalate "\t" $
+                                                           filter (not . null) $
+                                                                       [ "@RG"
+                                                                       , sam_v1_6_read_group_identifer_tos x
+                                                                       , sam_v1_6_read_group_barcode_sequence_tos x
+                                                                       , sam_v1_6_read_group_sequencing_center_tos x
+                                                                       , sam_v1_6_read_group_description_tos x
+                                                                       , sam_v1_6_read_group_run_date_tos x
+                                                                       , sam_v1_6_read_group_flow_order_tos x
+                                                                       , sam_v1_6_read_group_key_sequence_tos x
+                                                                       , sam_v1_6_read_group_library_tos x
+                                                                       , sam_v1_6_read_group_programs_tos x
+                                                                       , sam_v1_6_read_group_predicted_median_insert_size_tos x
+                                                                       , sam_v1_6_read_group_platform_tos x
+                                                                       , sam_v1_6_read_group_platform_model_tos x
+                                                                       , sam_v1_6_read_group_platform_unit_tos x
+                                                                       , sam_v1_6_read_group_sample_tos x
+                                                                       ]
+                                                  ) (toList rgf)
+    sam_v1_6_program_record_identifier_tos x = "ID:" ++
+                                               ( unpack                                   $
+                                                 fromStrict                               $
+                                                 sam_v1_6_program_record_identifier_value $
+                                                 sam_v1_6_program_record_identifier x
+                                               )
+    sam_v1_6_program_name_tos x = case (sam_v1_6_program_name x) of
+                                    Nothing  -> ""
+                                    Just rgf -> "PN:" ++
+                                                ( unpack     $
+                                                  fromStrict $
+                                                  sam_v1_6_program_name_value rgf
+                                                )
+    sam_v1_6_program_command_line_tos x = case (sam_v1_6_program_command_line x) of
+                                            Nothing  -> ""
+                                            Just rgf -> "CL:" ++
+                                                        ( unpack     $
+                                                          fromStrict $
+                                                          sam_v1_6_program_command_line_value rgf
+                                                        )
+    sam_v1_6_program_previous_pg_id_tos x = case (sam_v1_6_program_previous_pg_id x) of
+                                              Nothing  -> ""
+                                              Just rgf -> "PP:" ++
+                                                          ( unpack     $
+                                                            fromStrict $
+                                                            sam_v1_6_program_previous_pg_id_value rgf
+                                                          )
+    sam_v1_6_program_description_tos x = case (sam_v1_6_program_description x) of
+                                           Nothing  -> ""
+                                           Just rgf -> "DS:" ++
+                                                       ( unpack     $
+                                                         fromStrict $
+                                                         sam_v1_6_program_description_value rgf
+                                                       )
+    sam_v1_6_program_version_tos x = case (sam_v1_6_program_version x) of
+                                       Nothing  -> ""
+                                       Just rgf -> "VN:" ++
+                                                   ( unpack     $
+                                                     fromStrict $
+                                                     sam_v1_6_program_version_value rgf
+                                                   )
+    sam_v1_6_program_tos = case (sam_v1_6_program samv16) of
+                             Nothing  -> ""
+                             Just pgf -> intercalate "\t" $
+                                           filter (not . null) $
+                                                       [ "@PG"
+                                                       , sam_v1_6_program_record_identifier_tos pgf
+                                                       , sam_v1_6_program_name_tos pgf
+                                                       , sam_v1_6_program_command_line_tos pgf
+                                                       , sam_v1_6_program_previous_pg_id_tos pgf
+                                                       , sam_v1_6_program_description_tos pgf
+                                                       , sam_v1_6_program_version_tos pgf
+                                                       ]
+    sam_v1_6_one_line_comment_tos = case (sam_v1_6_one_line_comment samv16) of
+                                      Nothing  -> ""
+                                      Just cof -> intercalate "\n" $
+                                                    map (\x -> intercalate "\t" $
+                                                                 filter (not . null) 
+                                                                             [ "@CO"
+                                                                             , unpack     $
+                                                                               fromStrict $
+                                                                               sam_v1_6_one_line_comment_value x
+                                                                             ]
+                                                        ) (toList cof)
+    sam_v1_6_alignment_tos            = intercalate "\n" $
+                                          map (\x -> case (null $ sam_v1_6_alignment_opts x) of
+                                                       True  -> sam_v1_6_alignment_mand x 
+                                                       False -> intercalate "\t"
+                                                                            [ sam_v1_6_alignment_mand x
+                                                                            , sam_v1_6_alignment_opts x
+                                                                            ] ) (toList $ sam_v1_6_alignment samv16)
+    sam_v1_6_alignment_mand x           = intercalate "\t" $
+                                            filter (not . null)
+                                                        [ unpack $ fromStrict $ sam_v1_6_alignment_qname x 
+                                                        , show $ sam_v1_6_alignment_flag x 
+                                                        , unpack $ fromStrict $ sam_v1_6_alignment_rname x 
+                                                        , show $ sam_v1_6_alignment_pos x 
+                                                        , show $ sam_v1_6_alignment_mapq x 
+                                                        , unpack $ fromStrict $ sam_v1_6_alignment_cigar x 
+                                                        , unpack $ fromStrict $ sam_v1_6_alignment_rnext x 
+                                                        , show $ sam_v1_6_alignment_pnext x 
+                                                        , show $ sam_v1_6_alignment_tlen x 
+                                                        , unpack $ fromStrict $ sam_v1_6_alignment_seq x 
+                                                        , unpack $ fromStrict $ sam_v1_6_alignment_qual x
+                                                        ]
+    sam_v1_6_alignment_opts x           = intercalate "\t" $
+                                            filter (not . null)
+                                                        [ sam_v1_6_alignment_aopt_d x 
+                                                        , sam_v1_6_alignment_iopt_d x 
+                                                        , sam_v1_6_alignment_fopt_d x 
+                                                        , sam_v1_6_alignment_zopt_d x
+                                                        , sam_v1_6_alignment_hopt_d x 
+                                                        , sam_v1_6_alignment_bopt_d x
+                                                        ]
+    sam_v1_6_alignment_aopt_d x         = case (sam_v1_6_alignment_aopt x) of
+                                            Nothing   -> ""
+                                            Just aopt -> ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_aopt_tag aopt
+                                                         )
+                                                         ++
+                                                         ":A:"
+                                                         ++
+                                                         ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_aopt_value aopt
+                                                         )
+    sam_v1_6_alignment_iopt_d x         = case (sam_v1_6_alignment_iopt x) of
+                                            Nothing   -> ""
+                                            Just iopt -> ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_iopt_tag iopt
+                                                         )
+                                                         ++
+                                                         ":i:"
+                                                         ++
+                                                         ( show $
+                                                           sam_v1_6_alignment_iopt_value iopt
+                                                         )
+    sam_v1_6_alignment_fopt_d x         = case (sam_v1_6_alignment_fopt x) of
+                                            Nothing   -> ""
+                                            Just fopt -> ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_fopt_tag fopt
+                                                         )
+                                                         ++
+                                                         ":f:"
+                                                         ++
+                                                         ( show $
+                                                           sam_v1_6_alignment_fopt_value fopt
+                                                         )
+    sam_v1_6_alignment_zopt_d x         = case (sam_v1_6_alignment_zopt x) of
+                                            Nothing   -> ""
+                                            Just zopt -> ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_zopt_tag zopt
+                                                         )
+                                                         ++
+                                                         ":Z:"
+                                                         ++
+                                                         ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_zopt_value zopt
+                                                         )
+    sam_v1_6_alignment_hopt_d x         = case (sam_v1_6_alignment_hopt x) of
+                                            Nothing   -> ""
+                                            Just hopt -> ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_hopt_tag hopt
+                                                         )
+                                                         ++
+                                                         ":H:"
+                                                         ++
+                                                         ( unpack     $
+                                                           fromStrict $
+                                                           sam_v1_6_alignment_hopt_value hopt
+                                                         )
+    sam_v1_6_alignment_bopt_d x         = case (sam_v1_6_alignment_bopt x) of
+                                            Nothing   -> ""
+                                            Just bopt -> concat $
+                                                           filter (not . null)
+                                                                       [ sam_v1_6_alignment_bopt_int8_d bopt
+                                                                       , sam_v1_6_alignment_bopt_word8_d bopt
+                                                                       , sam_v1_6_alignment_bopt_int16_d bopt
+                                                                       , sam_v1_6_alignment_bopt_word16_d bopt
+                                                                       , sam_v1_6_alignment_bopt_int32_d bopt
+                                                                       , sam_v1_6_alignment_bopt_word32_d bopt
+                                                                       , sam_v1_6_alignment_bopt_float_d bopt
+                                                                       ]
+    sam_v1_6_alignment_bopt_int8_d x = case (sam_v1_6_alignment_bopt_int8 x) of
+                                         Nothing        -> ""
+                                         Just bopt_int8 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_int8_tag bopt_int8) ++
+                                                           ":"                                                                                ++
+                                                           (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_int8_type bopt_int8)    ++
+                                                           ":"                                                                                ++
+                                                           (concat $ map encodeInt8 $ toList $ sam_v1_6_alignment_bopt_int8_value bopt_int8)
+    sam_v1_6_alignment_bopt_word8_d x = case (sam_v1_6_alignment_bopt_word8 x) of 
+                                          Nothing         -> ""
+                                          Just bopt_word8 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word8_tag bopt_word8) ++
+                                                             ":"                                                                                  ++
+                                                             (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_word8_type bopt_word8)    ++
+                                                             ":"                                                                                  ++
+                                                             (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word8_value bopt_word8)
+    sam_v1_6_alignment_bopt_int16_d x = case (sam_v1_6_alignment_bopt_int16 x) of 
+                                          Nothing         -> ""
+                                          Just bopt_int16 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_int16_tag bopt_int16) ++
+                                                             ":"                                                                                  ++
+                                                             (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_int16_type bopt_int16)    ++
+                                                             ":"                                                                                  ++
+                                                             (concat $ map encodeInt16 $ toList $ sam_v1_6_alignment_bopt_int16_value bopt_int16)
+    sam_v1_6_alignment_bopt_word16_d x = case (sam_v1_6_alignment_bopt_word16 x) of
+                                           Nothing          -> ""
+                                           Just bopt_word16 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word16_tag bopt_word16) ++
+                                                               ":"                                                                                    ++
+                                                               (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_word16_type bopt_word16)    ++
+                                                               ":"                                                                                    ++
+                                                               (concat $ map encodeWord16 $ toList $ sam_v1_6_alignment_bopt_word16_value bopt_word16)
+    sam_v1_6_alignment_bopt_int32_d x = case (sam_v1_6_alignment_bopt_int32 x) of
+                                          Nothing         -> ""
+                                          Just bopt_int32 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_int32_tag bopt_int32) ++
+                                                             ":"                                                                                  ++
+                                                             (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_int32_type bopt_int32)    ++
+                                                             ":"                                                                                  ++
+                                                             (concat $ map encodeInt32 $ toList $ sam_v1_6_alignment_bopt_int32_value bopt_int32)
+    sam_v1_6_alignment_bopt_word32_d x = case (sam_v1_6_alignment_bopt_word32 x) of 
+                                           Nothing          -> ""
+                                           Just bopt_word32 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word32_tag bopt_word32) ++
+                                                               ":"                                                                                    ++
+                                                               (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_word32_type bopt_word32)    ++
+                                                               ":"                                                                                    ++
+                                                               (concat $ map encodeWord32 $ toList $ sam_v1_6_alignment_bopt_word32_value bopt_word32)
+    sam_v1_6_alignment_bopt_float_d x = case (sam_v1_6_alignment_bopt_float x) of 
+                                          Nothing         -> ""
+                                          Just bopt_float -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_float_tag bopt_float) ++
+                                                             ":"                                                                                  ++
+                                                             (unpack $ fromStrict $ singleton $ sam_v1_6_alignment_bopt_float_type bopt_float)    ++
+                                                             ":"                                                                                  ++
+                                                             (concat $ map show $ toList $ sam_v1_6_alignment_bopt_float_value bopt_float)
+    encodeInt8 :: Int8 -> [Char]
+    encodeInt8 = show
+    encodeInt16 :: Int16 -> [Char]
+    encodeInt16 = show
+    encodeWord16 :: Word16 -> [Char]
+    encodeWord16 = unpack . toLazyByteString . word16LE
+    encodeInt32 :: Int32 -> [Char]
+    encodeInt32 = show
+    encodeWord32 :: Word32 -> [Char]
+    encodeWord32 = unpack . toLazyByteString . word32LE
+
+-- | Write @"SAM_V1_6"@ to a file.
+-- Calls deconstructSAM_V1_6.
+hPutSAM_V1_6 :: Handle
+             -> SAM_V1_6
+             -> IO ()
+hPutSAM_V1_6 h samv16 = System.IO.hPutStr h
+                                          (deconstructSAM_V1_6 samv16)
+
+-- | Write a @"SAM_V1_6"@ to a file.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+writeSAM_V1_6 :: FilePath -- ^ Output path to SAM file.
+              -> SAM_V1_6
+              -> IO ()
+writeSAM_V1_6 fp samv16 = do
+  h <- openFile fp
+                WriteMode
+  hPutSAM_V1_6 h
+               samv16
+  hFlush h
+  hClose h
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -2,13 +2,16 @@
 
 import Data.SAM.Version1_6.Base
 import Data.SAM.Version1_6.Alignment
+import Data.SAM.Version1_6.Alignment.IOPT
+import Data.SAM.Version1_6.Alignment.ZOPT
 import Data.SAM.Version1_6.Alignment.BOPT
 import Data.SAM.Version1_6.Header
 import Data.SAM.Version1_6.Read.Base
 
 import Data.Sequence (fromList)
-import Data.String (fromString)
+import Data.String   (fromString)
 import Test.Hspec
+import Data.SAM.Version1_6.Write.Base 
 
 main :: IO ()
 main = hspec $ do
@@ -26,40 +29,16 @@
       describe "toy1.sam" $ do
         it "Ensures that readSAM_V1_6 can read and parse a SAM file with multiple reference sequence dictionary (@SQ) optional header fields." $ do
           readSAM_V1_6 "test/examples/toy1.sam" `shouldReturn` toy1sam
+  describe "Data.SAM.Version1_6.Write.Base" $ do
+    describe "writeSAM_V1_6" $ do
+      describe "toy2.sam" $ do
+        it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
+          toy2 <- readSAM_V1_6 "test/examples/toy2.sam"
+          writeSAM_V1_6 "test/examples/toy2f.sam" toy2
+          toy2f <- readSAM_V1_6 "test/examples/toy2f.sam"
+          toy2 `shouldBe` toy2f  
   where
-    toy1sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing
-                       , sam_v1_6_reference_sequence_dictionary = Just (fromList [SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString "ref" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString "45" } , sam_v1_6_reference_sequence_dictionary_reference_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing },SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString "ref2" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString "40" } , sam_v1_6_reference_sequence_dictionary_reference_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing }])
-                       , sam_v1_6_read_group = Nothing
-                       , sam_v1_6_program = Nothing
-                       , sam_v1_6_one_line_comment = Nothing
-                       , sam_v1_6_alignment = fromList [ SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Just SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 = Nothing , sam_v1_6_alignment_bopt_word8 = Nothing , sam_v1_6_alignment_bopt_int16 = Nothing , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag  = fromList [88,88] , sam_v1_6_alignment_bopt_word16_type = 83 , sam_v1_6_alignment_bopt_word16_value = fromList [49,50,53,54,49,44,50,44,50,48,44,49,49,50] } , sam_v1_6_alignment_bopt_int32 = Nothing , sam_v1_6_alignment_bopt_word32 = Nothing , sam_v1_6_alignment_bopt_float = Nothing } },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "5H6M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AGCTAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6H5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "TAGGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "20M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "21M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M4I13M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "25M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "24M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "23M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing
-                                                                            }
-                                                       ]
-                       }
-    toy2sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Just SAM_V1_6_File_Level_Metadata { sam_v1_6_file_level_metadata_format_version = SAM_V1_6_File_Level_Metadata_Format_Version { sam_v1_6_file_level_metadata_format_version_value = fromString "1.6" } , sam_v1_6_file_level_metadata_sorting_order = Just SAM_V1_6_File_Level_Metadata_Sorting_Order { sam_v1_6_file_level_metadata_sorting_order_value = fromString "coordinate" } , sam_v1_6_file_level_metadata_alignment_grouping = Nothing , sam_v1_6_file_level_metadata_subsorting_order = Nothing }
-                       , sam_v1_6_reference_sequence_dictionary = Just (fromList [SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString "ref" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString "45" } , sam_v1_6_reference_sequence_dictionary_reference_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing }])
-                       , sam_v1_6_read_group = Nothing
-                       , sam_v1_6_program = Nothing
-                       , sam_v1_6_one_line_comment = Nothing
-                       , sam_v1_6_alignment = fromList [ SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 99 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "8M2I4M1D3M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString "TTAGATAAAGGATACTG" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "3S6M1P1I4M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AAAAGATAAGGATA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "5S6M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "GCCTAAGCTAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Just (fromString "ref,29,-,6H5M,17,0;") , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6M14N5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ATAGCTTCAGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 2064 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 17 , sam_v1_6_alignment_cigar = fromString "6H5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "TAGGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Just (fromString "ref,9,+,5S6M,30,1;") , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 147 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString "CAGCGGCAT" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Just 1 , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing
-                                                                            }
-                                                       ]
-                       }
-    toy4sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing
-                       , sam_v1_6_reference_sequence_dictionary = Nothing
-                       , sam_v1_6_read_group = Nothing
-                       , sam_v1_6_program = Nothing
-                       , sam_v1_6_one_line_comment = Nothing
-                       , sam_v1_6_alignment = fromList [ SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Just SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 = Nothing , sam_v1_6_alignment_bopt_word8 = Nothing , sam_v1_6_alignment_bopt_int16 = Nothing , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag  = fromList [88,88] , sam_v1_6_alignment_bopt_word16_type = 83 , sam_v1_6_alignment_bopt_word16_value = fromList [49,50,53,54,49,44,50,44,50,48,44,49,49,50] } , sam_v1_6_alignment_bopt_int32 = Nothing , sam_v1_6_alignment_bopt_word32 = Nothing , sam_v1_6_alignment_bopt_float = Nothing } },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "5H6M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AGCTAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6H5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "TAGGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "20M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "21M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M4I13M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "25M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "24M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "23M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing
-                                                                            }
-                                                       ]
-                       }
-    toy5sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing
-                       , sam_v1_6_reference_sequence_dictionary = Nothing
-                       , sam_v1_6_read_group = Nothing
-                       , sam_v1_6_program = Nothing
-                       , sam_v1_6_one_line_comment = Nothing
-                       , sam_v1_6_alignment = fromList [ SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "5H6M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "AGCTAA" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "6H5M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "TAGGC" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M" , sam_v1_6_alignment_rnext = fromString "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "20M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "21M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "9M4I13M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "25M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "24M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString "23M" , sam_v1_6_alignment_rnext = fromString "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing
-                                                                            }
-                                                       ]
-                       }
+    toy1sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing , sam_v1_6_reference_sequence_dictionary = Just (fromList [SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString  "ref" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString  "45" } , sam_v1_6_reference_sequence_dictionary_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing },SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString  "ref2" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString  "40" } , sam_v1_6_reference_sequence_dictionary_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing }]) , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Just SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 = Nothing , sam_v1_6_alignment_bopt_word8 = Nothing , sam_v1_6_alignment_bopt_int16 = Nothing , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag  = fromList [88,88] , sam_v1_6_alignment_bopt_word16_type = 83 , sam_v1_6_alignment_bopt_word16_value = fromList [49,50,53,54,49,44,50,44,50,48,44,49,49,50] } , sam_v1_6_alignment_bopt_int32 = Nothing , sam_v1_6_alignment_bopt_word32 = Nothing , sam_v1_6_alignment_bopt_float = Nothing } },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5H6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "20M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString  "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "21M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString  "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M4I13M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString  "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "25M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString  "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "24M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString  "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "23M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString  "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] }
+    toy2sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Just SAM_V1_6_File_Level_Metadata { sam_v1_6_file_level_metadata_format_version = SAM_V1_6_File_Level_Metadata_Format_Version { sam_v1_6_file_level_metadata_format_version_value = fromString  "1.6" } , sam_v1_6_file_level_metadata_sorting_order = Just SAM_V1_6_File_Level_Metadata_Sorting_Order { sam_v1_6_file_level_metadata_sorting_order_value = fromString  "coordinate" } , sam_v1_6_file_level_metadata_alignment_grouping = Nothing , sam_v1_6_file_level_metadata_subsorting_order = Nothing } , sam_v1_6_reference_sequence_dictionary = Just (fromList [SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString  "ref" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString  "45" } , sam_v1_6_reference_sequence_dictionary_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing }]) , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 99 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M2I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "3S6M1P1I4M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGATA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5S6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "GCCTAAGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Just SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag = fromString  "SA" , sam_v1_6_alignment_zopt_value = fromString  "ref,29,-,6H5M,17,0;" } , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 2064 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 17 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Just SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag = fromString  "SA" , sam_v1_6_alignment_zopt_value = fromString  "ref,9,+,5S6M,30,1;" } , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 147 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGGCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Just SAM_V1_6_Alignment_IOPT { sam_v1_6_alignment_iopt_tag = fromString  "NM" , sam_v1_6_alignment_iopt_value = 1 } , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] } 
+    toy4sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing , sam_v1_6_reference_sequence_dictionary = Nothing , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Just SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 = Nothing , sam_v1_6_alignment_bopt_word8 = Nothing , sam_v1_6_alignment_bopt_int16 = Nothing , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag  = fromList [88,88] , sam_v1_6_alignment_bopt_word16_type = 83 , sam_v1_6_alignment_bopt_word16_value = fromList [49,50,53,54,49,44,50,44,50,48,44,49,49,50] } , sam_v1_6_alignment_bopt_int32 = Nothing , sam_v1_6_alignment_bopt_word32 = Nothing , sam_v1_6_alignment_bopt_float = Nothing } },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5H6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "20M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString  "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "21M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString  "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M4I13M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString  "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "25M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString  "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "24M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString  "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "23M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString  "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] } 
+    toy5sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing , sam_v1_6_reference_sequence_dictionary = Nothing , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5H6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "20M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString  "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "21M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString  "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M4I13M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString  "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "25M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString  "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "24M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString  "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "23M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString  "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] }
