packages feed

cobot-io 0.1.2.9 → 0.1.2.10

raw patch · 6 files changed

+61/−15 lines, 6 filesnew-uploaderPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Bio.Structure: atoms :: Lens' Residue (Vector Atom)
+ Bio.Structure: chains :: Lens' Model (Vector Chain)
+ Bio.Structure: globalBonds :: Lens' Model (Vector (Bond GlobalID))
+ Bio.Structure: localBonds :: Lens' Residue (Vector (Bond LocalID))
+ Bio.Structure: residues :: Lens' Chain (Vector Residue)
+ Bio.Structure.Functions: atom :: Traversal' Residue Atom
+ Bio.Structure.Functions: chain :: Traversal' Model Chain
+ Bio.Structure.Functions: globalBond :: Traversal' Model (Bond GlobalID)
+ Bio.Structure.Functions: localBond :: Traversal' Residue (Bond LocalID)
+ Bio.Structure.Functions: residue :: Traversal' Chain Residue

Files

ChangeLog.md view
@@ -2,6 +2,10 @@  ## [Unreleased] +## [0.1.2.10] - 2020-03-27+### Added+- Lenses for `Structure`.+ ## [0.1.2.9] - 2020-03-12 ### Added - Function `filterAtomsOfModel` to filter atoms of model by the given predicate.
cobot-io.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 4620b896cb4c841495a5d9ff83d8f260a4d186408209a552e2d82175aa208b2d+-- hash: 9e1717465825e1ea9fa611d37fb048cda60ddcea37b8afd16ba77a858416e927  name:           cobot-io-version:        0.1.2.9+version:        0.1.2.10 synopsis:       Biological data file formats and IO description:    Please see the README on GitHub at <https://github.com/less-wrong/cobot-io#readme> category:       Bio
src/Bio/MMTF.hs view
@@ -25,7 +25,7 @@ import           Linear.V3              (V3 (..)) import           Network.HTTP.Simple    (getResponseBody, httpLBS) #if !MIN_VERSION_base(4,13,0)-import           Control.Monad.Fail     (MonadFail(..))+import           Control.Monad.Fail     (MonadFail (..)) import           Prelude                hiding (fail) #endif @@ -70,9 +70,9 @@                              in  (end, mkAtom <$> zip4 cl nl el ics)          mkResidue :: (GroupType, SecondaryStructure, [Atom]) -> Residue-        mkResidue (gt, ss, atoms) = Residue (gtGroupName gt) (l2v atoms)-                                            (mkBonds (gtBondAtomList gt) (gtBondOrderList gt))-                                             ss (gtChemCompType gt)+        mkResidue (gt, ss, atoms') = Residue (gtGroupName gt) (l2v atoms')+                                             (mkBonds (gtBondAtomList gt) (gtBondOrderList gt))+                                              ss (gtChemCompType gt)          mkBonds :: Vector (Int32, Int32) -> Vector Int32 -> Vector (Bond LocalID)         mkBonds bal bol = let ball = bimap (LocalID . fromIntegral) (LocalID . fromIntegral) <$> toList bal
src/Bio/PDB.hs view
@@ -43,12 +43,12 @@           mkResidue :: [PDB.Atom] -> Residue-        mkResidue []    = error "Cound not make residue from empty list"-        mkResidue atoms = Residue (PDB.atomResName . head $ atoms)-                                  (V.fromList $ mkAtom <$> atoms)-                                  V.empty   -- now we do not read bonds-                                  Undefined -- now we do not read secondary structure-                                  ""        -- chemical component type?!+        mkResidue []     = error "Cound not make residue from empty list"+        mkResidue atoms' = Residue (PDB.atomResName . head $ atoms')+                                   (V.fromList $ mkAtom <$> atoms')+                                   V.empty   -- now we do not read bonds+                                   Undefined -- now we do not read secondary structure+                                   ""        -- chemical component type?!           mkAtom :: PDB.Atom -> Atom
src/Bio/Structure.hs view
@@ -1,5 +1,7 @@-{-# LANGUAGE DeriveAnyClass #-}-{-# LANGUAGE DeriveGeneric  #-}+{-# LANGUAGE DeriveAnyClass  #-}+{-# LANGUAGE DeriveGeneric   #-}+{-# LANGUAGE TemplateHaskell #-}+ module Bio.Structure   ( SecondaryStructure (..)   , Atom (..), Bond (..)@@ -7,9 +9,13 @@   , StructureModels (..), StructureSerializable (..)   , LocalID (..)   , GlobalID (..)+  , atoms, localBonds+  , residues+  , chains, globalBonds   ) where  import           Control.DeepSeq (NFData (..))+import           Control.Lens    (makeLensesFor) import           Data.Text       (Text) import           Data.Vector     (Vector) import           GHC.Generics    (Generic)@@ -78,6 +84,8 @@                        }   deriving (Show, Eq, Generic, NFData) +makeLensesFor [("resAtoms", "atoms"), ("resBonds", "localBonds")] ''Residue+ -- | Chain organizes linear structure of residues -- data Chain = Chain { chainName     :: Text              -- ^ name of a chain@@ -85,12 +93,16 @@                    }   deriving (Show, Eq, Generic, NFData) +makeLensesFor [("chainResidues", "residues")] ''Chain+ -- | Model represents a single experiment of structure determination -- data Model = Model { modelChains :: Vector Chain           -- ^ chains in the model                    , modelBonds  :: Vector (Bond GlobalID) -- ^ bonds with global identifiers (field `atomId` in 'Atom')                    }   deriving (Show, Eq, Generic, NFData)++makeLensesFor [("modelChains", "chains"), ("modelBonds", "globalBonds")] ''Model  -- | Convert any format-specific data to an intermediate representation of structure class StructureModels a where
src/Bio/Structure/Functions.hs view
@@ -1,15 +1,45 @@ module Bio.Structure.Functions   ( filterAtomsOfModel+  , chain, globalBond+  , residue+  , atom, localBond   ) where  import           Bio.Structure   (Atom (..), Bond (..), Chain (..),                                   GlobalID (..), LocalID (..), Model (..),-                                  Residue (..))+                                  Residue (..), atoms, chains, globalBonds,+                                  localBonds, residues)+import           Control.Lens    (Traversal', each) import qualified Data.Map.Strict as M (fromList, (!)) import           Data.Set        (Set) import qualified Data.Set        as S (fromList, notMember, unions) import           Data.Vector     (Vector) import qualified Data.Vector     as V (filter, fromList, length, toList, unzip)++-- | Traversal for every 'Chain' of the 'Model'.+--+chain :: Traversal' Model Chain+chain = chains . each++-- | Traversal for every 'Bond' of the 'Model'.+--+globalBond :: Traversal' Model (Bond GlobalID)+globalBond = globalBonds . each++-- | Traversal for every 'Residue' of the 'Chain'.+--+residue :: Traversal' Chain Residue+residue = residues . each++-- | Traversal for every 'Atom' of the 'Residue'.+--+atom :: Traversal' Residue Atom+atom = atoms . each++-- | Traversal for every 'Bond' of the 'Residue'.+--+localBond :: Traversal' Residue (Bond LocalID)+localBond = localBonds . each  -- | Takes predicate on 'Atom's of 'Model' and returns new 'Model' containing only atoms --   satisfying given predicate.