From 98c93f4fbf58a6755aae216f10bdcb3afebeda5b Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Tue, 22 Oct 2024 20:02:05 +0200 Subject: [PATCH] removed a lot of unused (?) ToJSON and FromJSON instances --- src/Poseidon/ColumnTypes.hs | 47 ---------------------------- src/Poseidon/ColumnTypesUtils.hs | 8 ----- src/Poseidon/Janno.hs | 41 ------------------------ src/Poseidon/SequencingSource.hs | 53 -------------------------------- 4 files changed, 149 deletions(-) diff --git a/src/Poseidon/ColumnTypes.hs b/src/Poseidon/ColumnTypes.hs index ac5a8a32..f9d1815f 100644 --- a/src/Poseidon/ColumnTypes.hs +++ b/src/Poseidon/ColumnTypes.hs @@ -8,9 +8,6 @@ import Poseidon.ColumnTypesUtils import Country (Country, alphaTwoUpper, decodeAlphaTwo) -import Data.Aeson (FromJSON, ToJSON, Value (..), - defaultOptions, genericToEncoding, - parseJSON, toEncoding, toJSON) import qualified Data.Csv as Csv import qualified Data.Text as T import qualified Data.Text.Read as T @@ -43,8 +40,6 @@ instance Ord GeneticSex where compare _ _ = EQ instance Csv.ToField GeneticSex where toField x = Csv.toField $ show x instance Csv.FromField GeneticSex where parseField = parseTypeCSV "Genetic_Sex" -instance ToJSON GeneticSex where toJSON x = String $ T.pack $ show x -instance FromJSON GeneticSex where parseJSON = parseTypeJSON "JannoSex" -- | A datatype for the Group_Name .janno column newtype GroupName = GroupName T.Text deriving (Eq, Ord) @@ -92,8 +87,6 @@ instance Show JannoRelationDegree where show OtherDegree = "other" instance Csv.ToField JannoRelationDegree where toField x = Csv.toField $ show x instance Csv.FromField JannoRelationDegree where parseField = parseTypeCSV "Relation_Degree" -instance ToJSON JannoRelationDegree where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoRelationDegree -- | A datatype for the Relation_Type .janno column newtype JannoRelationType = JannoRelationType T.Text deriving (Eq) @@ -124,8 +117,6 @@ instance Makeable JannoCountryISO where Just c -> return $ JannoCountryISO c instance Csv.ToField JannoCountryISO where toField x = Csv.toField $ show x instance Csv.FromField JannoCountryISO where parseField = parseTypeCSV "Country_ISO" -instance ToJSON JannoCountryISO where toJSON x = String $ T.pack $ show x -instance FromJSON JannoCountryISO where parseJSON = parseTypeJSON "Country_ISO" -- | A datatype for the Location .janno column newtype JannoLocation = JannoLocation T.Text deriving (Eq) @@ -150,8 +141,6 @@ instance Makeable JannoLatitude where instance Show JannoLatitude where show (JannoLatitude x) = show x instance Csv.ToField JannoLatitude where toField (JannoLatitude x) = Csv.toField x instance Csv.FromField JannoLatitude where parseField = parseTypeCSV "Latitude" -instance ToJSON JannoLatitude where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoLatitude -- | A datatype for the Longitude .janno column newtype JannoLongitude = JannoLongitude Double deriving (Eq, Ord, Generic) @@ -168,8 +157,6 @@ instance Makeable JannoLongitude where instance Show JannoLongitude where show (JannoLongitude x) = show x instance Csv.ToField JannoLongitude where toField (JannoLongitude x) = Csv.toField x instance Csv.FromField JannoLongitude where parseField = parseTypeCSV "Longitude" -instance ToJSON JannoLongitude where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoLongitude -- | A datatype for the Date_Type .janno column data JannoDateType = @@ -191,8 +178,6 @@ instance Show JannoDateType where show Modern = "modern" instance Csv.ToField JannoDateType where toField x = Csv.toField $ show x instance Csv.FromField JannoDateType where parseField = parseTypeCSV "Date_Type" -instance ToJSON JannoDateType where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDateType -- | A datatype for the Date_C14_Labnr .janno column newtype JannoDateC14Labnr = JannoDateC14Labnr T.Text deriving (Eq) @@ -210,8 +195,6 @@ instance Makeable JannoDateC14UncalBP where instance Show JannoDateC14UncalBP where show (JannoDateC14UncalBP x) = show x instance Csv.ToField JannoDateC14UncalBP where toField (JannoDateC14UncalBP x) = Csv.toField x instance Csv.FromField JannoDateC14UncalBP where parseField = parseTypeCSV "Date_C14_Uncal_BP" -instance ToJSON JannoDateC14UncalBP where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDateC14UncalBP -- | A datatype for the Date_C14_Uncal_BP_Err .janno column newtype JannoDateC14UncalBPErr = JannoDateC14UncalBPErr Int deriving (Eq, Ord, Generic) @@ -225,8 +208,6 @@ instance Makeable JannoDateC14UncalBPErr where instance Show JannoDateC14UncalBPErr where show (JannoDateC14UncalBPErr x) = show x instance Csv.ToField JannoDateC14UncalBPErr where toField (JannoDateC14UncalBPErr x) = Csv.toField x instance Csv.FromField JannoDateC14UncalBPErr where parseField = parseTypeCSV "Date_C14_Uncal_BP_Err" -instance ToJSON JannoDateC14UncalBPErr where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDateC14UncalBPErr -- | A datatype for the Date_BC_AD_Start .janno column newtype JannoDateBCADStart = JannoDateBCADStart Int deriving (Eq, Ord, Generic) @@ -245,8 +226,6 @@ instance Makeable JannoDateBCADStart where instance Show JannoDateBCADStart where show (JannoDateBCADStart x) = show x instance Csv.ToField JannoDateBCADStart where toField (JannoDateBCADStart x) = Csv.toField x instance Csv.FromField JannoDateBCADStart where parseField = parseTypeCSV "Date_BC_AD_Start" -instance ToJSON JannoDateBCADStart where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDateBCADStart -- | A datatype for the Date_BC_AD_Median .janno column newtype JannoDateBCADMedian = JannoDateBCADMedian Int deriving (Eq, Ord, Generic) @@ -265,8 +244,6 @@ instance Makeable JannoDateBCADMedian where instance Show JannoDateBCADMedian where show (JannoDateBCADMedian x) = show x instance Csv.ToField JannoDateBCADMedian where toField (JannoDateBCADMedian x) = Csv.toField x instance Csv.FromField JannoDateBCADMedian where parseField = parseTypeCSV "Date_BC_AD_Median" -instance ToJSON JannoDateBCADMedian where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDateBCADMedian -- | A datatype for the Date_BC_AD_Stop .janno column newtype JannoDateBCADStop = JannoDateBCADStop Int deriving (Eq, Ord, Generic) @@ -285,8 +262,6 @@ instance Makeable JannoDateBCADStop where instance Show JannoDateBCADStop where show (JannoDateBCADStop x) = show x instance Csv.ToField JannoDateBCADStop where toField (JannoDateBCADStop x) = Csv.toField x instance Csv.FromField JannoDateBCADStop where parseField = parseTypeCSV "Date_BC_AD_Stop" -instance ToJSON JannoDateBCADStop where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDateBCADStop -- | A datatype for the Date_Note .janno column newtype JannoDateNote = JannoDateNote T.Text deriving (Eq, Ord) @@ -319,8 +294,6 @@ instance Makeable JannoNrLibraries where instance Show JannoNrLibraries where show (JannoNrLibraries x) = show x instance Csv.ToField JannoNrLibraries where toField (JannoNrLibraries x) = Csv.toField x instance Csv.FromField JannoNrLibraries where parseField = parseTypeCSV "Nr_Libraries" -instance ToJSON JannoNrLibraries where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoNrLibraries -- | A datatype for the Library_Names .janno column newtype JannoLibraryName = JannoLibraryName T.Text deriving (Eq) @@ -361,8 +334,6 @@ instance Show JannoCaptureType where show ReferenceGenome = "ReferenceGenome" instance Csv.ToField JannoCaptureType where toField x = Csv.toField $ show x instance Csv.FromField JannoCaptureType where parseField = parseTypeCSV "Capture_Type" -instance ToJSON JannoCaptureType where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoCaptureType -- | A datatype for the UDG .janno column data JannoUDG = @@ -387,8 +358,6 @@ instance Show JannoUDG where show Mixed = "mixed" instance Csv.ToField JannoUDG where toField x = Csv.toField $ show x instance Csv.FromField JannoUDG where parseField = parseTypeCSV "UDG" -instance ToJSON JannoUDG where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoUDG -- | A datatype for the Library_Built .janno column data JannoLibraryBuilt = @@ -413,8 +382,6 @@ instance Show JannoLibraryBuilt where show Other = "other" instance Csv.ToField JannoLibraryBuilt where toField x = Csv.toField $ show x instance Csv.FromField JannoLibraryBuilt where parseField = parseTypeCSV "Library_Built" -instance ToJSON JannoLibraryBuilt where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoLibraryBuilt -- | A datatype for the Genotype_Ploidy .janno column data JannoGenotypePloidy = @@ -433,8 +400,6 @@ instance Show JannoGenotypePloidy where show Haploid = "haploid" instance Csv.ToField JannoGenotypePloidy where toField x = Csv.toField $ show x instance Csv.FromField JannoGenotypePloidy where parseField = parseTypeCSV "Genotype_Ploidy" -instance ToJSON JannoGenotypePloidy where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoGenotypePloidy -- | A datatype for the Genotype_Ploidy .janno column newtype JannoDataPreparationPipelineURL = JannoDataPreparationPipelineURL T.Text deriving (Eq, Ord, Generic) @@ -446,8 +411,6 @@ instance Makeable JannoDataPreparationPipelineURL where instance Show JannoDataPreparationPipelineURL where show (JannoDataPreparationPipelineURL x) = T.unpack x instance Csv.ToField JannoDataPreparationPipelineURL where toField (JannoDataPreparationPipelineURL x) = Csv.toField x instance Csv.FromField JannoDataPreparationPipelineURL where parseField = parseTypeCSV "Data_Preparation_Pipeline_URL" -instance ToJSON JannoDataPreparationPipelineURL where toJSON (JannoDataPreparationPipelineURL x) = String x -instance FromJSON JannoDataPreparationPipelineURL -- | A datatype for the Endogenous .janno column newtype JannoEndogenous = JannoEndogenous Double deriving (Eq, Ord, Generic) @@ -464,8 +427,6 @@ instance Makeable JannoEndogenous where instance Show JannoEndogenous where show (JannoEndogenous x) = show x instance Csv.ToField JannoEndogenous where toField (JannoEndogenous x) = Csv.toField x instance Csv.FromField JannoEndogenous where parseField = parseTypeCSV "Endogenous" -instance ToJSON JannoEndogenous where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoEndogenous -- | A datatype for the Nr_SNPs .janno column newtype JannoNrSNPs = JannoNrSNPs Int deriving (Eq, Ord, Generic) @@ -482,8 +443,6 @@ instance Makeable JannoNrSNPs where instance Show JannoNrSNPs where show (JannoNrSNPs x) = show x instance Csv.ToField JannoNrSNPs where toField (JannoNrSNPs x) = Csv.toField x instance Csv.FromField JannoNrSNPs where parseField = parseTypeCSV "Nr_SNPs" -instance ToJSON JannoNrSNPs where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoNrSNPs -- | A datatype for the Coverage_on_Target_SNPs .janno column newtype JannoCoverageOnTargets = JannoCoverageOnTargets Double deriving (Eq, Ord, Generic) @@ -497,8 +456,6 @@ instance Makeable JannoCoverageOnTargets where instance Show JannoCoverageOnTargets where show (JannoCoverageOnTargets x) = show x instance Csv.ToField JannoCoverageOnTargets where toField (JannoCoverageOnTargets x) = Csv.toField x instance Csv.FromField JannoCoverageOnTargets where parseField = parseTypeCSV "Coverage_on_Target_SNPs" -instance ToJSON JannoCoverageOnTargets where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoCoverageOnTargets -- | A datatype for the Damage .janno column newtype JannoDamage = JannoDamage Double deriving (Eq, Ord, Generic) @@ -515,8 +472,6 @@ instance Makeable JannoDamage where instance Show JannoDamage where show (JannoDamage x) = show x instance Csv.ToField JannoDamage where toField (JannoDamage x) = Csv.toField x instance Csv.FromField JannoDamage where parseField = parseTypeCSV "Damage" -instance ToJSON JannoDamage where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoDamage -- | A datatype for the Contamination .janno column newtype JannoContamination = JannoContamination T.Text deriving (Eq) @@ -567,8 +522,6 @@ instance Show JannoGeneticSourceAccessionID where show (OtherID x) = T.unpack x instance Csv.ToField JannoGeneticSourceAccessionID where toField x = Csv.toField $ show x instance Csv.FromField JannoGeneticSourceAccessionID where parseField = parseTypeCSV "Genetic_Source_Accession_IDs" -instance ToJSON JannoGeneticSourceAccessionID where toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoGeneticSourceAccessionID -- | A datatype for the Primary_Contact .janno column newtype JannoPrimaryContact = JannoPrimaryContact T.Text deriving (Eq) diff --git a/src/Poseidon/ColumnTypesUtils.hs b/src/Poseidon/ColumnTypesUtils.hs index 38c30bdc..6ae5886b 100644 --- a/src/Poseidon/ColumnTypesUtils.hs +++ b/src/Poseidon/ColumnTypesUtils.hs @@ -3,9 +3,6 @@ module Poseidon.ColumnTypesUtils where -import Data.Aeson (FromJSON, ToJSON, Value (..), parseJSON, - toJSON, withText) -import Data.Aeson.Types (Parser) import Data.ByteString as S import qualified Data.Csv as Csv import qualified Data.Text as T @@ -25,9 +22,6 @@ parseTypeCSV colname x = case T.decodeUtf8' x of Left e -> fail $ show e ++ " in column " ++ colname Right t -> make t -parseTypeJSON :: forall a. (Makeable a, Typeable a) => String -> Value -> Parser a -parseTypeJSON colname = withText colname make - -- template haskell function to generate repetitive instances makeInstances :: Name -> String -> DecsQ makeInstances name col = do @@ -38,6 +32,4 @@ makeInstances name col = do instance Show $(conT name) where show $(conP conName [varP x]) = T.unpack $(varE x) instance Csv.ToField $(conT name) where toField $(conP conName [varP x]) = Csv.toField $(varE x) instance Csv.FromField $(conT name) where parseField = parseTypeCSV col - instance ToJSON $(conT name) where toJSON $(conP conName [varP x]) = String $(varE x) - instance FromJSON $(conT name) where parseJSON = parseTypeJSON col |] diff --git a/src/Poseidon/Janno.hs b/src/Poseidon/Janno.hs index f2871028..c1c80104 100644 --- a/src/Poseidon/Janno.hs +++ b/src/Poseidon/Janno.hs @@ -54,13 +54,6 @@ import Control.Monad (unless, when) import qualified Control.Monad.Except as E import Control.Monad.IO.Class (liftIO) import qualified Control.Monad.Writer as W -import Data.Aeson (FromJSON, Options (..), - ToJSON, Value (..), - defaultOptions, - genericToEncoding, - parseJSON, toEncoding, - toJSON) -import Data.Aeson.Types (emptyObject) import Data.Bifunctor (second) import qualified Data.ByteString.Char8 as Bchs import qualified Data.ByteString.Lazy.Char8 as Bch @@ -73,7 +66,6 @@ import Data.List (elemIndex, foldl', (\\)) import Data.Maybe (fromJust) import qualified Data.Text as T -import qualified Data.Text.Encoding as T import qualified Data.Vector as V import Generics.SOP.TH (deriveGeneric) import GHC.Generics (Generic) @@ -97,16 +89,6 @@ instance (Csv.ToField a, Show a) => Csv.ToField (ListColumn a) where toField x = Bchs.intercalate ";" $ map Csv.toField $ getListColumn x instance (Csv.FromField a) => Csv.FromField (ListColumn a) where parseField x = fmap ListColumn . mapM Csv.parseField $ Bchs.splitWith (==';') x -instance (ToJSON a) => ToJSON (ListColumn a) where - toEncoding (ListColumn x) = toEncoding x -instance (FromJSON a) => FromJSON (ListColumn a) where - parseJSON x - | isAesonString x = ListColumn . singleton <$> parseJSON x - | otherwise = ListColumn <$> parseJSON x - where - isAesonString (String _) = True - isAesonString _ = False - singleton a = [a] -- | A datatype to collect additional, unpecified .janno file columns (a hashmap in cassava/Data.Csv) newtype CsvNamedRecord = CsvNamedRecord Csv.NamedRecord deriving (Show, Eq, Generic) @@ -114,20 +96,6 @@ newtype CsvNamedRecord = CsvNamedRecord Csv.NamedRecord deriving (Show, Eq, Gene getCsvNR :: CsvNamedRecord -> Csv.NamedRecord getCsvNR (CsvNamedRecord x) = x --- Aeson does not encode ByteStrings, so that's why we have to go through Text -instance ToJSON CsvNamedRecord where - toJSON (CsvNamedRecord x) = - let listOfBSTuples = HM.toList x - listOfTextTuples = map (\(a,b) -> (T.decodeUtf8 a, T.decodeUtf8 b)) listOfBSTuples - in toJSON listOfTextTuples -instance FromJSON CsvNamedRecord where - parseJSON x - | x == emptyObject = pure $ CsvNamedRecord $ HM.fromList [] - | otherwise = do - listOfTextTuples <- parseJSON x -- :: [(T.Text, T.Text)] - let listOfBSTuples = map (\(a,b) -> (T.encodeUtf8 a, T.encodeUtf8 b)) listOfTextTuples - pure $ CsvNamedRecord $ HM.fromList listOfBSTuples - -- | A data type to represent a janno file newtype JannoRows = JannoRows [JannoRow] deriving (Show, Eq, Generic) @@ -151,10 +119,6 @@ instance Monoid JannoRows where mempty = JannoRows [] mconcat = foldl' mappend mempty -instance ToJSON JannoRows where - toEncoding = genericToEncoding defaultOptions -instance FromJSON JannoRows - -- | A data type to represent a sample/janno file row -- See https://github.com/poseidon-framework/poseidon2-schema/blob/master/janno_columns.tsv -- for more details @@ -248,11 +212,6 @@ jannoHeaderString = map Bchs.unpack jannoHeader jannoRefHashMap :: HM.HashMap Bchs.ByteString () jannoRefHashMap = HM.fromList $ map (\x -> (x, ())) jannoHeader -instance ToJSON JannoRow where - toEncoding = genericToEncoding (defaultOptions {omitNothingFields = True}) - -instance FromJSON JannoRow - instance Csv.FromNamedRecord JannoRow where parseNamedRecord m = JannoRow <$> filterLookup m "Poseidon_ID" diff --git a/src/Poseidon/SequencingSource.hs b/src/Poseidon/SequencingSource.hs index 589e94c1..918595b3 100644 --- a/src/Poseidon/SequencingSource.hs +++ b/src/Poseidon/SequencingSource.hs @@ -19,10 +19,6 @@ import Poseidon.Utils (PoseidonException (..), PoseidonIO, import Control.Exception (throwIO) import Control.Monad (unless, when) import Control.Monad.IO.Class (liftIO) -import Data.Aeson (FromJSON, Options (..), ToJSON, - defaultOptions, genericToEncoding, - toEncoding, withText) -import Data.Aeson.Encoding (text) import Data.Bifunctor (second) import qualified Data.ByteString.Char8 as Bchs import qualified Data.ByteString.Lazy.Char8 as Bch @@ -32,12 +28,10 @@ import Data.Either (lefts, rights) import qualified Data.HashMap.Strict as HM import Data.List (foldl', nub, sort) import Data.Maybe (isJust, mapMaybe) -import qualified Data.Text as T import Data.Time (Day) import Data.Time.Format (defaultTimeLocale, formatTime, parseTimeM) import qualified Data.Vector as V -import Data.Yaml.Aeson (FromJSON (..)) import GHC.Generics (Generic) import Network.URI (isURIReference) import qualified Text.Parsec as P @@ -82,11 +76,6 @@ instance Csv.ToField AccessionID where toField x = Csv.toField $ show x instance Csv.FromField AccessionID where parseField x = Csv.parseField x >>= makeAccessionID -instance ToJSON AccessionID where - toEncoding = genericToEncoding defaultOptions - --toEncoding x = text $ T.pack $ show x -instance FromJSON AccessionID-- where - --parseJSON = withText "AccessionID" (makeAccessionID . T.unpack) -- | A datatype to represent URIs in a ssf file newtype JURI = @@ -105,11 +94,6 @@ instance Csv.ToField JURI where toField x = Csv.toField $ show x instance Csv.FromField JURI where parseField x = Csv.parseField x >>= makeJURI -instance ToJSON JURI where - toEncoding = genericToEncoding defaultOptions - --toEncoding x = text $ T.pack $ show x -instance FromJSON JURI-- where - --parseJSON = withText "JURI" (makeJURI . T.unpack) -- |A datatype to represent UDG in a ssf file data SSFUDG = @@ -134,10 +118,6 @@ instance Csv.ToField SSFUDG where toField x = Csv.toField $ show x instance Csv.FromField SSFUDG where parseField x = Csv.parseField x >>= makeSSFUDG -instance ToJSON SSFUDG where - toEncoding x = text $ T.pack $ show x -instance FromJSON SSFUDG where - parseJSON = withText "SSFUDG" (makeSSFUDG . T.unpack) -- |A datatype to represent Library_Built in a janno file data SSFLibraryBuilt = @@ -159,10 +139,6 @@ instance Csv.ToField SSFLibraryBuilt where toField x = Csv.toField $ show x instance Csv.FromField SSFLibraryBuilt where parseField x = Csv.parseField x >>= makeSSFLibraryBuilt -instance ToJSON SSFLibraryBuilt where - toEncoding x = text $ T.pack $ show x -instance FromJSON SSFLibraryBuilt where - parseJSON = withText "SSFLibraryBuilt" (makeSSFLibraryBuilt . T.unpack) -- | A data type to represent a seqSourceFile newtype SeqSourceRows = SeqSourceRows {getSeqSourceRowList :: [SeqSourceRow]} @@ -187,10 +163,6 @@ instance Monoid SeqSourceRows where mempty = SeqSourceRows [] mconcat = foldl' mappend mempty -instance ToJSON SeqSourceRows where - toEncoding = genericToEncoding defaultOptions -instance FromJSON SeqSourceRows - -- A data type to represent a run accession ID newtype AccessionIDRun = AccessionIDRun {getRunAccession :: AccessionID} deriving (Eq, Generic) @@ -209,10 +181,6 @@ instance Csv.ToField AccessionIDRun where toField x = Csv.toField $ show x instance Csv.FromField AccessionIDRun where parseField x = Csv.parseField x >>= makeAccessionIDRun -instance ToJSON AccessionIDRun where - toEncoding x = text $ T.pack $ show x -instance FromJSON AccessionIDRun where - parseJSON = withText "AccessionIDRun" (makeAccessionIDRun . T.unpack) -- A data type to represent a sample accession ID newtype AccessionIDSample = AccessionIDSample {getSampleAccession :: AccessionID} @@ -233,10 +201,6 @@ instance Csv.ToField AccessionIDSample where toField x = Csv.toField $ show x instance Csv.FromField AccessionIDSample where parseField x = Csv.parseField x >>= makeAccessionIDSample -instance ToJSON AccessionIDSample where - toEncoding x = text $ T.pack $ show x -instance FromJSON AccessionIDSample where - parseJSON = withText "AccessionIDSample" (makeAccessionIDSample . T.unpack) -- A data type to represent a study accession ID newtype AccessionIDStudy = AccessionIDStudy {getStudyAccession :: AccessionID} @@ -257,10 +221,6 @@ instance Csv.ToField AccessionIDStudy where toField x = Csv.toField $ show x instance Csv.FromField AccessionIDStudy where parseField x = Csv.parseField x >>= makeAccessionIDStudy -instance ToJSON AccessionIDStudy where - toEncoding x = text $ T.pack $ show x -instance FromJSON AccessionIDStudy where - parseJSON = withText "AccessionIDStudy" (makeAccessionIDStudy . T.unpack) -- | A datatype for calendar dates newtype SimpleDate = SimpleDate Day @@ -278,10 +238,6 @@ instance Csv.ToField SimpleDate where toField (SimpleDate x) = Csv.toField $ show x instance Csv.FromField SimpleDate where parseField x = Csv.parseField x >>= makeSimpleDate -instance ToJSON SimpleDate where - toEncoding x = text $ T.pack $ show x -instance FromJSON SimpleDate where - parseJSON = withText "SimpleDate" (makeSimpleDate . T.unpack) -- | A datatype to represent MD5 hashes newtype MD5 = MD5 String @@ -302,10 +258,6 @@ instance Csv.ToField MD5 where toField x = Csv.toField $ show x instance Csv.FromField MD5 where parseField x = Csv.parseField x >>= makeMD5 -instance ToJSON MD5 where - toEncoding x = text $ T.pack $ show x -instance FromJSON MD5 where - parseJSON = withText "MD5" (makeMD5 . T.unpack) -- | A data type to represent a row in the seqSourceFile -- See https://github.com/poseidon-framework/poseidon2-schema/blob/master/seqSourceFile_columns.tsv @@ -374,11 +326,6 @@ seqSourceHeaderString = map Bchs.unpack seqSourceHeader seqSourceRefHashMap :: HM.HashMap Bchs.ByteString () seqSourceRefHashMap = HM.fromList $ map (\x -> (x, ())) seqSourceHeader -instance ToJSON SeqSourceRow where - toEncoding = genericToEncoding (defaultOptions {omitNothingFields = True}) - -instance FromJSON SeqSourceRow - instance Csv.FromNamedRecord SeqSourceRow where parseNamedRecord m = SeqSourceRow <$> filterLookupOptional m "poseidon_IDs"