mmtf 0.1.0.1 → 0.1.1.0
raw patch · 7 files changed
+191/−139 lines, 7 filesdep +http-conduitdep ~QuickCheckdep ~binarydep ~containersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: http-conduit
Dependency ranges changed: QuickCheck, binary, containers, hspec
API changes (from Hackage documentation)
+ Bio.MMTF: fetch :: MonadIO m => String -> m MMTF
- Bio.MMTF: AtomData :: !(Maybe [Int32]) -> !(Maybe [Char]) -> !(Maybe [Float]) -> ![Float] -> ![Float] -> ![Float] -> !(Maybe [Float]) -> AtomData
+ Bio.MMTF: AtomData :: !Maybe [Int32] -> !Maybe [Char] -> !Maybe [Float] -> ![Float] -> ![Float] -> ![Float] -> !Maybe [Float] -> AtomData
- Bio.MMTF: ChainData :: ![Int32] -> ![Text] -> !(Maybe [Text]) -> ChainData
+ Bio.MMTF: ChainData :: ![Int32] -> ![Text] -> !Maybe [Text] -> ChainData
- Bio.MMTF: GroupData :: ![GroupType] -> ![Int32] -> ![Int32] -> !(Maybe [SecondaryStructure]) -> !(Maybe [Char]) -> !(Maybe [Int32]) -> GroupData
+ Bio.MMTF: GroupData :: ![GroupType] -> ![Int32] -> ![Int32] -> !Maybe [SecondaryStructure] -> !Maybe [Char] -> !Maybe [Int32] -> GroupData
- Bio.MMTF: StructureData :: !(Maybe Text) -> !(Maybe Text) -> !(Maybe Text) -> !(Maybe Text) -> !Int32 -> !Int32 -> !Int32 -> !Int32 -> !Int32 -> !(Maybe Text) -> !(Maybe UnitCell) -> !(Maybe [[Float]]) -> !(Maybe [Assembly]) -> !(Maybe [Entity]) -> !(Maybe Float) -> !(Maybe Float) -> !(Maybe Float) -> !(Maybe [Text]) -> !(Maybe [Int32]) -> !(Maybe [Int8]) -> StructureData
+ Bio.MMTF: StructureData :: !Maybe Text -> !Maybe Text -> !Maybe Text -> !Maybe Text -> !Int32 -> !Int32 -> !Int32 -> !Int32 -> !Int32 -> !Maybe Text -> !Maybe UnitCell -> !Maybe [[Float]] -> !Maybe [Assembly] -> !Maybe [Entity] -> !Maybe Float -> !Maybe Float -> !Maybe Float -> !Maybe [Text] -> !Maybe [Int32] -> !Maybe [Int8] -> StructureData
- Bio.MMTF: [altLocList] :: AtomData -> !(Maybe [Char])
+ Bio.MMTF: [altLocList] :: AtomData -> !Maybe [Char]
- Bio.MMTF: [atomIdList] :: AtomData -> !(Maybe [Int32])
+ Bio.MMTF: [atomIdList] :: AtomData -> !Maybe [Int32]
- Bio.MMTF: [bFactorList] :: AtomData -> !(Maybe [Float])
+ Bio.MMTF: [bFactorList] :: AtomData -> !Maybe [Float]
- Bio.MMTF: [bioAssemblyList] :: StructureData -> !(Maybe [Assembly])
+ Bio.MMTF: [bioAssemblyList] :: StructureData -> !Maybe [Assembly]
- Bio.MMTF: [bondAtomList] :: StructureData -> !(Maybe [Int32])
+ Bio.MMTF: [bondAtomList] :: StructureData -> !Maybe [Int32]
- Bio.MMTF: [bondOrderList] :: StructureData -> !(Maybe [Int8])
+ Bio.MMTF: [bondOrderList] :: StructureData -> !Maybe [Int8]
- Bio.MMTF: [chainNameList] :: ChainData -> !(Maybe [Text])
+ Bio.MMTF: [chainNameList] :: ChainData -> !Maybe [Text]
- Bio.MMTF: [depositionDate] :: StructureData -> !(Maybe Text)
+ Bio.MMTF: [depositionDate] :: StructureData -> !Maybe Text
- Bio.MMTF: [entityList] :: StructureData -> !(Maybe [Entity])
+ Bio.MMTF: [entityList] :: StructureData -> !Maybe [Entity]
- Bio.MMTF: [experimentalMethods] :: StructureData -> !(Maybe [Text])
+ Bio.MMTF: [experimentalMethods] :: StructureData -> !Maybe [Text]
- Bio.MMTF: [insCodeList] :: GroupData -> !(Maybe [Char])
+ Bio.MMTF: [insCodeList] :: GroupData -> !Maybe [Char]
- Bio.MMTF: [ncsOperatorList] :: StructureData -> !(Maybe [[Float]])
+ Bio.MMTF: [ncsOperatorList] :: StructureData -> !Maybe [[Float]]
- Bio.MMTF: [occupancyList] :: AtomData -> !(Maybe [Float])
+ Bio.MMTF: [occupancyList] :: AtomData -> !Maybe [Float]
- Bio.MMTF: [rFree] :: StructureData -> !(Maybe Float)
+ Bio.MMTF: [rFree] :: StructureData -> !Maybe Float
- Bio.MMTF: [rWork] :: StructureData -> !(Maybe Float)
+ Bio.MMTF: [rWork] :: StructureData -> !Maybe Float
- Bio.MMTF: [releaseDate] :: StructureData -> !(Maybe Text)
+ Bio.MMTF: [releaseDate] :: StructureData -> !Maybe Text
- Bio.MMTF: [resolution] :: StructureData -> !(Maybe Float)
+ Bio.MMTF: [resolution] :: StructureData -> !Maybe Float
- Bio.MMTF: [secStructList] :: GroupData -> !(Maybe [SecondaryStructure])
+ Bio.MMTF: [secStructList] :: GroupData -> !Maybe [SecondaryStructure]
- Bio.MMTF: [sequenceIndexList] :: GroupData -> !(Maybe [Int32])
+ Bio.MMTF: [sequenceIndexList] :: GroupData -> !Maybe [Int32]
- Bio.MMTF: [spaceGroup] :: StructureData -> !(Maybe Text)
+ Bio.MMTF: [spaceGroup] :: StructureData -> !Maybe Text
- Bio.MMTF: [structureId] :: StructureData -> !(Maybe Text)
+ Bio.MMTF: [structureId] :: StructureData -> !Maybe Text
- Bio.MMTF: [title] :: StructureData -> !(Maybe Text)
+ Bio.MMTF: [title] :: StructureData -> !Maybe Text
- Bio.MMTF: [unitCell] :: StructureData -> !(Maybe UnitCell)
+ Bio.MMTF: [unitCell] :: StructureData -> !Maybe UnitCell
Files
- mmtf.cabal +4/−3
- src/Bio/MMTF.hs +15/−3
- src/Bio/MMTF/Decode.hs +25/−15
- src/Bio/MMTF/Decode/Codec.hs +38/−22
- src/Bio/MMTF/Decode/MessagePack.hs +5/−5
- src/Bio/MMTF/Type.hs +102/−89
- test/Spec.hs +2/−2
mmtf.cabal view
@@ -1,5 +1,5 @@ name: mmtf-version: 0.1.0.1+version: 0.1.1.0 synopsis: Macromolecular Transmission Format implementation description: Haskell implementation of MMTF biological structure format. homepage: https://github.com/zmactep/mmtf#readme@@ -25,8 +25,9 @@ , data-msgpack >= 0.0.9 && < 0.1 , text >= 1.2.2.1 && < 1.3 , bytestring >= 0.10.8.1 && < 0.11- , binary >= 0.8.3.0 && < 0.9- , containers >= 0.5.7.1 && < 0.6+ , binary >= 0.8.3.0 && < 1.0+ , containers >= 0.5.7.1 && < 0.7+ , http-conduit >= 2.3 && < 2.4 default-language: Haskell2010 ghc-options: -Wall
src/Bio/MMTF.hs view
@@ -1,14 +1,26 @@ module Bio.MMTF ( module Bio.MMTF.Type , decode+ , fetch ) where import Bio.MMTF.MessagePack () import Bio.MMTF.Type -import Data.ByteString.Lazy (ByteString)-import Data.MessagePack (unpack)+import Data.ByteString.Lazy (ByteString)+import Data.MessagePack (unpack)+import Data.Monoid ((<>))+import Data.String (IsString (..))+import Control.Monad.IO.Class (MonadIO)+import Network.HTTP.Simple (httpLBS, getResponseBody) --- |Decodes a 'ByteString' to 'MMTF'+-- | Decodes a 'ByteString' to 'MMTF'+-- decode :: Monad m => ByteString -> m MMTF decode = unpack++-- | Fetches MMTF structure from RSCB+fetch :: MonadIO m => String -> m MMTF+fetch pdbid = do let url = fromString $ "https://mmtf.rcsb.org/v1.0/full/" <> pdbid+ resp <- httpLBS url+ decode (getResponseBody resp)
src/Bio/MMTF/Decode.hs view
@@ -11,24 +11,28 @@ import Data.MessagePack (Object) import Data.Text (Text) --- |Parses format data from ObjectMap+-- | Parses format data from ObjectMap+-- formatData :: Monad m => Map Text Object -> m FormatData formatData mp = do v <- atP mp "mmtfVersion" asStr p <- atP mp "mmtfProducer" asStr pure $ FormatData v p --- |Parses model data from ObjectMap+-- | Parses model data from ObjectMap+-- modelData :: Monad m => Map Text Object -> m ModelData-modelData mp = atP mp "chainsPerModel" asIntList >>= return . ModelData+modelData mp = ModelData <$> atP mp "chainsPerModel" asIntList --- |Parses chain data from ObjectMap+-- | Parses chain data from ObjectMap+-- chainData :: Monad m => Map Text Object -> m ChainData chainData mp = do gpc <- atP mp "groupsPerChain" asIntList cil <- codec5 . parseBinary <$> atP mp "chainIdList" asBinary cnl <- (codec5 . parseBinary <$>) <$> atPM mp "chainNameList" asBinary pure $ ChainData gpc cil cnl --- |Parses atom data from ObjectMap+-- | Parses atom data from ObjectMap+-- atomData :: Monad m => Map Text Object -> m AtomData atomData mp = do ail' <- (codec8 . parseBinary <$>) <$> atPM mp "atomIdList" asBinary all' <- (codec6 . parseBinary <$>) <$> atPM mp "altLocList" asBinary@@ -39,9 +43,10 @@ ol' <- (codec9 . parseBinary <$>) <$> atPM mp "occupancyList" asBinary pure $ AtomData ail' all' bfl' xcl' ycl' zcl' ol' --- |Parses group data from ObjectMap+-- | Parses group data from ObjectMap+-- groupData :: Monad m => Map Text Object -> m GroupData-groupData mp = do gl' <- atP mp "groupList" asObjectList >>= sequence . map (transformObjectMap >=> groupType)+groupData mp = do gl' <- atP mp "groupList" asObjectList >>= traverse (transformObjectMap >=> groupType) gtl' <- codec4 . parseBinary <$> atP mp "groupTypeList" asBinary gil' <- codec8 . parseBinary <$> atP mp "groupIdList" asBinary ssl' <- (map ssDec . codec2 . parseBinary <$>) <$> atPM mp "secStructList" asBinary@@ -49,7 +54,8 @@ sil' <- (codec8 . parseBinary <$>) <$> atPM mp "sequenceIndexList" asBinary pure $ GroupData gl' gtl' gil' ssl' icl' sil' --- |Parses group type from ObjectMap+-- | Parses group type from ObjectMap+-- groupType :: Monad m => Map Text Object -> m GroupType groupType mp = do fcl' <- atP mp "formalChargeList" asIntList anl' <- atP mp "atomNameList" asStrList@@ -61,7 +67,8 @@ cct' <- atP mp "chemCompType" asStr pure $ GroupType fcl' anl' el' bal' bol' gn' slc' cct' --- |Parses structure data from ObjectMap+-- | Parses structure data from ObjectMap+-- structureData :: Monad m => Map Text Object -> m StructureData structureData mp = do ttl' <- atPM mp "title" asStr sid' <- atPM mp "structureId" asStr@@ -75,8 +82,8 @@ sg' <- atPM mp "spaceGroup" asStr uc' <- (>>= ucDec) <$> atPM mp "unitCell" asFloatList nol' <- ((>>= asFloatList) <$>) <$> atPM mp "ncsOperatorList" asObjectList- bal' <- (>>= sequence . map (transformObjectMap >=> bioAssembly)) <$> atPM mp "bioAssemblyList" asObjectList- el' <- (>>= sequence . map (transformObjectMap >=> entity)) <$> atPM mp "entityList" asObjectList+ bal' <- (>>= traverse (transformObjectMap >=> bioAssembly)) <$> atPM mp "bioAssemblyList" asObjectList+ el' <- (>>= traverse (transformObjectMap >=> entity)) <$> atPM mp "entityList" asObjectList res' <- atPM mp "resolution" asFloat rf' <- atPM mp "rFree" asFloat rw' <- atPM mp "rWork" asFloat@@ -86,19 +93,22 @@ pure $ StructureData ttl' sid' dd' rd' nb' na' ng' nc' nm' sg' uc' nol' bal' el' res' rf' rw' em' btl' bol' --- |Parses bio assembly data from ObjectMap+-- | Parses bio assembly data from ObjectMap+-- bioAssembly :: Monad m => Map Text Object -> m Assembly bioAssembly mp = do nme' <- atP mp "name" asStr- tlt' <- atP mp "transformList" asObjectList >>= sequence . map (transformObjectMap >=> transform)+ tlt' <- atP mp "transformList" asObjectList >>= traverse (transformObjectMap >=> transform) pure $ Assembly tlt' nme' --- |Parses transform data from ObjectMap+-- | Parses transform data from ObjectMap+-- transform :: Monad m => Map Text Object -> m Transform transform mp = do cil' <- atP mp "chainIndexList" asIntList mtx' <- atP mp "matrix" asFloatList pure $ Transform cil' mtx' --- |Parses entity data from ObjectMap+-- | Parses entity data from ObjectMap+-- entity :: Monad m => Map Text Object -> m Entity entity mp = do cil' <- atP mp "chainIndexList" asIntList dsc' <- atP mp "description" asStr
src/Bio/MMTF/Decode/Codec.hs view
@@ -18,95 +18,111 @@ in f start : codecCommon f th rest where ith = fromIntegral th -data BinaryData = BD { binaryCodec :: Int32- , binaryLength :: Int32- , binaryParam :: Int32- , binaryData :: ByteString+data BinaryData = BD { binaryCodec :: !Int32+ , binaryLength :: !Int32+ , binaryParam :: !Int32+ , binaryData :: !ByteString } --- |Parse useless header for binary data+-- | Parse useless header for binary data+-- parseBinary :: ByteString -> BinaryData parseBinary bs = let (cdc, rest1) = B.splitAt 4 bs (lnh, rest2) = B.splitAt 4 rest1 (prm, rest) = B.splitAt 4 rest2 in BD (decode cdc) (decode lnh) (decode prm) rest --- |Interpret bytes as array of 32-bit floating-point numbers.+-- | Interpret bytes as array of 32-bit floating-point numbers.+-- codec1 :: BinaryData -> [Float] codec1 = codecCommon decode 4 . binaryData --- |Interpret bytes as array of 8-bit signed integers.+-- | Interpret bytes as array of 8-bit signed integers.+-- codec2 :: BinaryData -> [Int8] codec2 = codecCommon decode 1 . binaryData --- |Interpret bytes as array of 16-bit signed integers.+-- | Interpret bytes as array of 16-bit signed integers.+-- codec3 :: BinaryData -> [Int16] codec3 = codecCommon decode 2 . binaryData --- |Interpret bytes as array of 32-bit signed integers.+-- | Interpret bytes as array of 32-bit signed integers.+-- codec4 :: BinaryData -> [Int32] codec4 = codecCommon decode 4 . binaryData --- |Interpret bytes as array of 8-bit unsigned integers, then iteratively+-- | Interpret bytes as array of 8-bit unsigned integers, then iteratively -- consume length many bytes to form a string array.+-- codec5 :: BinaryData -> [Text] codec5 bd = codecCommon decodeBytes (fromIntegral $ binaryParam bd) (binaryData bd) where decodeBytes :: ByteString -> Text decodeBytes bs = T.pack $ chr <$> filter (/=0) (fromIntegral <$> B.unpack bs) --- |Interpret bytes as array of 32-bit signed integers, then run-length+-- | Interpret bytes as array of 32-bit signed integers, then run-length -- decode into array of characters.+-- codec6 :: BinaryData -> [Char] codec6 = map (chr . fromIntegral) . codec7 --- |Interpret bytes as array of 32-bit signed integers, then run-length+-- | Interpret bytes as array of 32-bit signed integers, then run-length -- decode into array of 32-bit signed integers.+-- codec7 :: BinaryData -> [Int32] codec7 = runLengthDec . codec4 --- |Interpret bytes as array of 32-bit signed integers, then run-length+-- | Interpret bytes as array of 32-bit signed integers, then run-length -- decode into array of 32-bit signed integers, then delta decode into -- array of 32-bit signed integers.+-- codec8 :: BinaryData -> [Int32] codec8 = deltaDec . codec7 --- |Interpret bytes as array of 32-bit signed integers, then run-length+-- | Interpret bytes as array of 32-bit signed integers, then run-length -- decode into array of 32-bit signed integers, then integer decode into -- array of 32-bit floating-point numbers using the divisor parameter.+-- codec9 :: BinaryData -> [Float] codec9 bd = integerDec (binaryParam bd) $ codec7 bd --- |Interpret bytes as array of 16-bit signed integers, then unpack into+-- | Interpret bytes as array of 16-bit signed integers, then unpack into -- array of 32-bit integers, then delta decode into array of 32-bit -- integers, then integer decode into array of 32-bit floating-point -- numbers using the divisor parameter.+-- codec10 :: BinaryData -> [Float] codec10 bd = integerDec (binaryParam bd) $ map fromIntegral $ deltaDec $ codec3 bd --- |Interpret bytes as array of 16-bit signed integers, then integer+-- | Interpret bytes as array of 16-bit signed integers, then integer -- decode into array of 32-bit floating-point numbers using the divisor parameter.+-- codec11 :: BinaryData -> [Float] codec11 bd = integerDec (binaryParam bd) $ map fromIntegral $ codec3 bd --- |Interpret bytes as array of 16-bit signed integers, then unpack into+-- | Interpret bytes as array of 16-bit signed integers, then unpack into -- array of 32-bit signed integers, then integer decode into array -- of 32-bit floating-point numbers using the divisor parameter.+-- codec12 :: BinaryData -> [Float] codec12 bd = integerDec (binaryParam bd) $ recIndexDec $ codec3 bd --- |Interpret array of bytes as array of 8-bit signed integers, then+-- | Interpret array of bytes as array of 8-bit signed integers, then -- unpack into array of 32-bit signed integers, then integer decode into -- array of 32-bit floating-point numbers using the divisor parameter.+-- codec13 :: BinaryData -> [Float] codec13 bd = integerDec (binaryParam bd) $ recIndexDec $ codec2 bd --- |Interpret bytes as array of 16-bit signed integers, then unpack+-- | Interpret bytes as array of 16-bit signed integers, then unpack -- into array of 32-bit signed integers.+-- codec14 :: BinaryData -> [Int32] codec14 bd = recIndexDec $ codec3 bd --- |Interpret bytes as array of 8-bit signed integers, then unpack+-- | Interpret bytes as array of 8-bit signed integers, then unpack -- into array of 32-bit signed integers.+-- codec15 :: BinaryData -> [Int32] codec15 bd = recIndexDec $ codec2 bd @@ -115,7 +131,7 @@ runLengthDec :: Integral a => [a] -> [a] runLengthDec [] = [] runLengthDec [_] = error "List must have even length for run-length encoding"-runLengthDec (x:l:xs) = (replicate (fromIntegral l) x) ++ runLengthDec xs+runLengthDec (x:l:xs) = replicate (fromIntegral l) x ++ runLengthDec xs deltaDec :: Num a => [a] -> [a] deltaDec = snd . mapAccumL (\x y -> (x+y,x+y)) 0@@ -145,4 +161,4 @@ ucDec :: Monad m => [Float] -> m UnitCell ucDec [a,b,c,d,e,f] = pure $ UnitCell a b c d e f-ucDec _ = fail "Wrong list format for unit cell"+ucDec _ = fail "Wrong list format for unit cell"
src/Bio/MMTF/Decode/MessagePack.hs view
@@ -9,9 +9,9 @@ transformObjectMap :: Monad m => Object -> m (Map Text Object) transformObjectMap (ObjectMap kv) = let mkPair :: Monad m => (Object, Object) -> m (Text, Object)- mkPair ((ObjectStr txt), v) = pure (txt, v)+ mkPair (ObjectStr txt, v) = pure (txt, v) mkPair _ = fail "Non-string key"- in fromList <$> sequence (map mkPair kv)+ in fromList <$> traverse mkPair kv transformObjectMap _ = fail "Wrong MessagePack MMTF format" atP :: Monad m => Map Text Object -> Text -> (Object -> m a) -> m a@@ -41,15 +41,15 @@ asFloat _ = fail "Not a float data" asIntList :: (Monad m, Integral a) => Object -> m [a]-asIntList (ObjectArray l) = sequence $ map asInt l+asIntList (ObjectArray l) = traverse asInt l asIntList _ = fail "Not an array of ints data" asStrList :: Monad m => Object -> m [Text]-asStrList (ObjectArray l) = sequence $ map asStr l+asStrList (ObjectArray l) = traverse asStr l asStrList _ = fail "Not an array of string data" asFloatList :: Monad m => Object -> m [Float]-asFloatList (ObjectArray l) = sequence $ map asFloat l+asFloatList (ObjectArray l) = traverse asFloat l asFloatList _ = fail "Not an array of float data" asObjectList :: Monad m => Object -> m [Object]
src/Bio/MMTF/Type.hs view
@@ -3,129 +3,142 @@ import Data.Int (Int32, Int8) import Data.Text (Text) --- |Unit cell data-data UnitCell = UnitCell { ucA :: !Float -- ^length of side 'a'- , ucB :: !Float -- ^length of side 'b'- , ucC :: !Float -- ^length of side 'c'- , ucAlpha :: !Float -- ^alpha angle in degrees- , ucBeta :: !Float -- ^beta angle in degrees- , ucGamma :: !Float -- ^gamma angle in degrees+-- | Unit cell data+--+data UnitCell = UnitCell { ucA :: !Float -- ^ length of side 'a'+ , ucB :: !Float -- ^ length of side 'b'+ , ucC :: !Float -- ^ length of side 'c'+ , ucAlpha :: !Float -- ^ alpha angle in degrees+ , ucBeta :: !Float -- ^ beta angle in degrees+ , ucGamma :: !Float -- ^ gamma angle in degrees } deriving (Show, Eq) --- |Transform data-data Transform = Transform { chainIndexList :: ![Int32] -- ^indices into the 'chainIdList' and 'chainNameList' fields- , matrix :: ![Float] -- ^4x4 transformation matrix+-- | Transform data+--+data Transform = Transform { chainIndexList :: ![Int32] -- ^ indices into the 'chainIdList' and 'chainNameList' fields+ , matrix :: ![Float] -- ^ 4x4 transformation matrix } deriving (Show, Eq) --- |Assembly data-data Assembly = Assembly { transformList :: ![Transform] -- ^List of transform objects- , assemblyName :: !Text -- ^Name of the biological assembly+-- | Assembly data+--+data Assembly = Assembly { transformList :: ![Transform] -- ^ List of transform objects+ , assemblyName :: !Text -- ^ Name of the biological assembly } deriving (Show, Eq) --- |Entity data-data Entity = Entity { entityChainIndexList :: ![Int32] -- ^indices into the 'chainIdList' and 'chainNameList' fields- , entityDescription :: !Text -- ^Description of the entity- , entityType :: !Text -- ^Name of the entity type- , entitySequence :: !Text -- ^Sequence of the full construct in one-letter-code+-- | Entity data+--+data Entity = Entity { entityChainIndexList :: ![Int32] -- ^ indices into the 'chainIdList' and 'chainNameList' fields+ , entityDescription :: !Text -- ^ Description of the entity+ , entityType :: !Text -- ^ Name of the entity type+ , entitySequence :: !Text -- ^ Sequence of the full construct in one-letter-code } deriving (Show, Eq) --- |Group type data-data GroupType = GroupType { gtFormalChargeList :: ![Int32] -- ^List of formal charges- , gtAtomNameList :: ![Text] -- ^List of atom names- , gtElementList :: ![Text] -- ^List of elements- , gtBondAtomList :: ![Int32] -- ^List of bonded atom indices- , gtBondOrderList :: ![Int32] -- ^List of bond orders- , gtGroupName :: !Text -- ^The name of the group- , gtSingleLetterCode :: !Char -- ^The single letter code- , gtChemCompType :: !Text -- ^The chemical component type+-- | Group type data+--+data GroupType = GroupType { gtFormalChargeList :: ![Int32] -- ^ List of formal charges+ , gtAtomNameList :: ![Text] -- ^ List of atom names+ , gtElementList :: ![Text] -- ^ List of elements+ , gtBondAtomList :: ![Int32] -- ^ List of bonded atom indices+ , gtBondOrderList :: ![Int32] -- ^ List of bond orders+ , gtGroupName :: !Text -- ^ The name of the group+ , gtSingleLetterCode :: !Char -- ^ The single letter code+ , gtChemCompType :: !Text -- ^ The chemical component type } deriving (Show, Eq) --- |Protein secondary structure-data SecondaryStructure = PiHelix -- ^pi helix- | Bend -- ^bend- | AlphaHelix -- ^alpha helix- | Extended -- ^extended- | ThreeTenHelix -- ^3-10 helix- | Bridge -- ^brigde- | Turn -- ^turn- | Coil -- ^coil- | Undefined -- ^unknown structure+-- | Protein secondary structure+--+data SecondaryStructure = PiHelix -- ^ pi helix+ | Bend -- ^ bend+ | AlphaHelix -- ^ alpha helix+ | Extended -- ^ extended+ | ThreeTenHelix -- ^ 3-10 helix+ | Bridge -- ^ brigde+ | Turn -- ^ turn+ | Coil -- ^ coil+ | Undefined -- ^ unknown structure deriving (Show, Eq) --- |MMTF format data-data FormatData = FormatData { mmtfVersion :: !Text -- ^The version number of the specification the file adheres to- , mmtfProducer :: !Text -- ^The name and version of the software used to produce the file+-- | MMTF format data+--+data FormatData = FormatData { mmtfVersion :: !Text -- ^ The version number of the specification the file adheres to+ , mmtfProducer :: !Text -- ^ The name and version of the software used to produce the file } deriving (Show, Eq) --- |Structure data-data StructureData = StructureData { title :: !(Maybe Text) -- ^A short description of the structural data included in the file- , structureId :: !(Maybe Text) -- ^An ID for the structure, for example the PDB ID if applicable- , depositionDate :: !(Maybe Text) -- ^A date that relates to the deposition of the structure in a database- , releaseDate :: !(Maybe Text) -- ^A date that relates to the release of the structure in a database- , numBonds :: !Int32 -- ^The overall number of bonds- , numAtoms :: !Int32 -- ^The overall number of atoms in the structure- , numGroups :: !Int32 -- ^The overall number of groups in the structure- , numChains :: !Int32 -- ^The overall number of chains in the structure- , numModels :: !Int32 -- ^The overall number of models in the structure- , spaceGroup :: !(Maybe Text) -- ^The Hermann-Mauguin space-group symbol- , unitCell :: !(Maybe UnitCell) -- ^Array of six values defining the unit cell- , ncsOperatorList :: !(Maybe [[Float]]) -- ^List of lists representing 4x4 transformation matrices that are stored linearly in row major order (transformation matrices describe noncrystallographic symmetry operations needed to create all molecules in the unit cell)- , bioAssemblyList :: !(Maybe [Assembly]) -- ^List of instructions on how to transform coordinates for an array of chains to create (biological) assemblies- , entityList :: !(Maybe [Entity]) -- ^List of unique molecular entities within the structure- , resolution :: !(Maybe Float) -- ^The experimental resolution in Angstrom- , rFree :: !(Maybe Float) -- ^The R-free value- , rWork :: !(Maybe Float) -- ^The R-work value- , experimentalMethods :: !(Maybe [Text]) -- ^List of experimental methods employed for structure determination- , bondAtomList :: !(Maybe [Int32]) -- ^Pairs of values represent indices of covalently bonded atoms [binary (type 4)]- , bondOrderList :: !(Maybe [Int8]) -- ^List of bond orders for bonds in 'bondAtomList' [binary (type 2)]+-- | Structure data+--+data StructureData = StructureData { title :: !(Maybe Text) -- ^ A short description of the structural data included in the file+ , structureId :: !(Maybe Text) -- ^ An ID for the structure, for example the PDB ID if applicable+ , depositionDate :: !(Maybe Text) -- ^ A date that relates to the deposition of the structure in a database+ , releaseDate :: !(Maybe Text) -- ^ A date that relates to the release of the structure in a database+ , numBonds :: !Int32 -- ^ The overall number of bonds+ , numAtoms :: !Int32 -- ^ The overall number of atoms in the structure+ , numGroups :: !Int32 -- ^ The overall number of groups in the structure+ , numChains :: !Int32 -- ^ The overall number of chains in the structure+ , numModels :: !Int32 -- ^ The overall number of models in the structure+ , spaceGroup :: !(Maybe Text) -- ^ The Hermann-Mauguin space-group symbol+ , unitCell :: !(Maybe UnitCell) -- ^ Array of six values defining the unit cell+ , ncsOperatorList :: !(Maybe [[Float]]) -- ^ List of lists representing 4x4 transformation matrices that are stored linearly in row major order (transformation matrices describe noncrystallographic symmetry operations needed to create all molecules in the unit cell)+ , bioAssemblyList :: !(Maybe [Assembly]) -- ^ List of instructions on how to transform coordinates for an array of chains to create (biological) assemblies+ , entityList :: !(Maybe [Entity]) -- ^ List of unique molecular entities within the structure+ , resolution :: !(Maybe Float) -- ^ The experimental resolution in Angstrom+ , rFree :: !(Maybe Float) -- ^ The R-free value+ , rWork :: !(Maybe Float) -- ^ The R-work value+ , experimentalMethods :: !(Maybe [Text]) -- ^ List of experimental methods employed for structure determination+ , bondAtomList :: !(Maybe [Int32]) -- ^ Pairs of values represent indices of covalently bonded atoms [binary (type 4)]+ , bondOrderList :: !(Maybe [Int8]) -- ^ List of bond orders for bonds in 'bondAtomList' [binary (type 2)] } deriving (Show, Eq) --- |Models data-data ModelData = ModelData { chainsPerModel :: ![Int32] -- ^List of the number of chains in each model+-- | Models data+--+data ModelData = ModelData { chainsPerModel :: ![Int32] -- ^ List of the number of chains in each model } deriving (Show, Eq) --- |Chains data-data ChainData = ChainData { groupsPerChain :: ![Int32] -- ^List of the number of groups (aka residues) in each chain- , chainIdList :: ![Text] -- ^List of chain IDs [binary (type 5)]- , chainNameList :: !(Maybe [Text]) -- ^List of chain names [binary (type 5)]+-- | Chains data+--+data ChainData = ChainData { groupsPerChain :: ![Int32] -- ^ List of the number of groups (aka residues) in each chain+ , chainIdList :: ![Text] -- ^ List of chain IDs [binary (type 5)]+ , chainNameList :: !(Maybe [Text]) -- ^ List of chain names [binary (type 5)] } deriving (Show, Eq) --- |Groups data-data GroupData = GroupData { groupList :: ![GroupType] -- ^List of groupType objects- , groupTypeList :: ![Int32] -- ^List of pointers to 'groupType' entries in 'groupList' by their keys[binary (type 4)]- , groupIdList :: ![Int32] -- ^List of group (residue) numbers [binary (type 8)]- , secStructList :: !(Maybe [SecondaryStructure]) -- ^List of secondary structure assignments [binary (type 2)]- , insCodeList :: !(Maybe [Char]) -- ^List of insertion codes, one for each group (residue) [binary (type 6)]- , sequenceIndexList :: !(Maybe [Int32]) -- ^List of indices that point into the sequence property of an entity object in the 'entityList' field that is associated with the chain the group belongs to [binary (type 8)]+-- | Groups data+--+data GroupData = GroupData { groupList :: ![GroupType] -- ^ List of groupType objects+ , groupTypeList :: ![Int32] -- ^ List of pointers to 'groupType' entries in 'groupList' by their keys [binary (type 4)]+ , groupIdList :: ![Int32] -- ^ List of group (residue) numbers [binary (type 8)]+ , secStructList :: !(Maybe [SecondaryStructure]) -- ^ List of secondary structure assignments [binary (type 2)]+ , insCodeList :: !(Maybe [Char]) -- ^ List of insertion codes, one for each group (residue) [binary (type 6)]+ , sequenceIndexList :: !(Maybe [Int32]) -- ^ List of indices that point into the sequence property of an entity object in the 'entityList' field that is associated with the chain the group belongs to [binary (type 8)] } deriving (Show, Eq) --- |Atoms data-data AtomData = AtomData { atomIdList :: !(Maybe [Int32]) -- ^List of atom serial numbers [binary (type 8)]- , altLocList :: !(Maybe [Char]) -- ^List of alternate location labels, one for each atom [binary (type 6)]- , bFactorList :: !(Maybe [Float]) -- ^List of atom B-factors in in A^2, one for each atom [binary (type 10)]- , xCoordList :: ![Float] -- ^List of x atom coordinates in A, one for each atom [binary (type 10)]- , yCoordList :: ![Float] -- ^List of y atom coordinates in A, one for each atom [binary (type 10)]- , zCoordList :: ![Float] -- ^List of z atom coordinates in A, one for each atom [binary (type 10)]- , occupancyList :: !(Maybe [Float]) -- ^List of atom occupancies, one for each atom [binary (type 9)]+-- | Atoms data+--+data AtomData = AtomData { atomIdList :: !(Maybe [Int32]) -- ^ List of atom serial numbers [binary (type 8)]+ , altLocList :: !(Maybe [Char]) -- ^ List of alternate location labels, one for each atom [binary (type 6)]+ , bFactorList :: !(Maybe [Float]) -- ^ List of atom B-factors in in A^2, one for each atom [binary (type 10)]+ , xCoordList :: ![Float] -- ^ List of x atom coordinates in A, one for each atom [binary (type 10)]+ , yCoordList :: ![Float] -- ^ List of y atom coordinates in A, one for each atom [binary (type 10)]+ , zCoordList :: ![Float] -- ^ List of z atom coordinates in A, one for each atom [binary (type 10)]+ , occupancyList :: !(Maybe [Float]) -- ^ List of atom occupancies, one for each atom [binary (type 9)] } deriving (Show, Eq) --- |MMTF datatype-data MMTF = MMTF { format :: !FormatData -- ^MMTF format data- , structure :: !StructureData -- ^Biological structure data- , model :: !ModelData -- ^Models data- , chain :: !ChainData -- ^Chains data- , group :: !GroupData -- ^Groups data- , atom :: !AtomData -- ^Atoms data+-- | MMTF datatype+--+data MMTF = MMTF { format :: !FormatData -- ^ MMTF format data+ , structure :: !StructureData -- ^ Biological structure data+ , model :: !ModelData -- ^ Models data+ , chain :: !ChainData -- ^ Chains data+ , group :: !GroupData -- ^ Groups data+ , atom :: !AtomData -- ^ Atoms data } deriving (Show, Eq)
test/Spec.hs view
@@ -10,5 +10,5 @@ it "should parse 1FSD" $ do contents <- B.readFile "resource/1FSD.mmtf" m <- decode contents- let sid = (structureId . structure) m- sid `shouldBe` Just "1FSD"+ (structureId . structure) m `shouldBe` Just "1FSD"+ (numModels . structure) m `shouldBe` 41