hPDB 1.4.0.0 → 1.5.0.0
raw patch · 11 files changed
+56/−61 lines, 11 filesdep +lineardep −AC-Vectordep ~Octree
Dependencies added: linear
Dependencies removed: AC-Vector
Dependency ranges changed: Octree
Files
- Bio/PDB/Common.hs +4/−4
- Bio/PDB/EventParser/PDBEventPrinter.hs +5/−5
- Bio/PDB/EventParser/PDBEvents.hs +8/−8
- Bio/PDB/EventParser/ParseATOM.hs +1/−1
- Bio/PDB/EventParser/ParseMatrixRecord.hs +2/−2
- Bio/PDB/EventParser/ParseTVECT.hs +1/−1
- Bio/PDB/Structure.hs +2/−2
- Bio/PDB/Structure/Neighbours.hs +3/−3
- Bio/PDB/Structure/Vector.hs +24/−26
- README.md +3/−6
- hPDB.cabal +3/−3
Bio/PDB/Common.hs view
@@ -1,9 +1,9 @@ -- | Common datatype aliases.-module Bio.PDB.Common(String(..), Vector3(..))+module Bio.PDB.Common(String(..), V3(..)) where -import Data.Vector.V3+import Linear import Prelude hiding(String) @@ -15,6 +15,6 @@ type String = BS.ByteString -- -- | Datatype for 3D locations (numbers are in ångströms.)---instance NFData Vector3 where--- rnf (Vector3 (x, y, z)) = x `seq` y `seq` z `seq` ()+--instance NFData V3 where+-- rnf (V3 (x, y, z)) = x `seq` y `seq` z `seq` ()
Bio/PDB/EventParser/PDBEventPrinter.hs view
@@ -33,7 +33,7 @@ resid = rid, resins = rins, altloc = al,- coords = Vector3 x y z,+ coords = V3 x y z, occupancy = occ, bfactor = bf, segid = sid,@@ -206,7 +206,7 @@ (BS.unpack grp) z print handle TVECT { serial = sn,- vec = Vector3 a b c } = hPrintf handle "TVECT %4d%10.5f%10.5f%10.5f\n" sn a b c+ vec = V3 a b c } = hPrintf handle "TVECT %4d%10.5f%10.5f%10.5f\n" sn a b c print handle JRNL { cont = c, content = contents, isFirst = aJRNL } = printJRNL contents@@ -283,8 +283,8 @@ str where str = BS.unpack (BS.intercalate sep l) --- | Prints a matrix given as a list of 'Vector3's.-printMatrix :: Handle -> BS.ByteString -> Int -> [Vector3] -> [Double] -> IO ()+-- | Prints a matrix given as a list of 'V3 Double's.+printMatrix :: Handle -> BS.ByteString -> Int -> [V3 Double] -> [Double] -> IO () printMatrix handle ident n [] [] = return () printMatrix handle ident n (vec:vecs) (f:fs) = do hPrintf handle "%5s%c " (BS.unpack ident) cn mapM_ printEntry [a, b, c]@@ -293,5 +293,5 @@ where [cn] = show n printEntry :: Double -> IO () printEntry = hPrintf handle "%10.6f"- Vector3 a b c = vec+ V3 a b c = vec
Bio/PDB/EventParser/PDBEvents.hs view
@@ -1,7 +1,7 @@ -- | This module contains datatype declaration for PDB parsing -- events generated by 'PDBEventParser' module. module Bio.PDB.EventParser.PDBEvents(- String,Vector3(..),ATID(..),RESID(..),PDBEvent(..),+ String,V3(..),ATID(..),RESID(..),PDBEvent(..), StrandSenseT(..),HelixT(..),ExpMethod(..)) where @@ -12,7 +12,7 @@ import Bio.PDB.EventParser.HelixTypes import Bio.PDB.EventParser.StrandSense -import Bio.PDB.Common(String,Vector3(..))+import Bio.PDB.Common(String,V3(..)) -- | Atom id: atom name, residue name, chain, residue id, residue insertion code newtype ATID = ATID (String, String, Char, Int, Char)@@ -30,7 +30,7 @@ resid :: !Int, resins :: !Char, altloc :: !Char,- coords :: !Vector3,+ coords :: !(V3 Double), occupancy :: !Double, bfactor :: !Double, segid :: !String,@@ -45,7 +45,7 @@ resid :: !Int, resins :: !Char, altloc :: !Char,- coords :: !Vector3,+ coords :: !(V3 Double), occupancy :: !Double, bfactor :: !Double, segid :: !String,@@ -167,15 +167,15 @@ curAt :: Maybe ATID, prevAt :: Maybe ATID } | ORIGXn { n :: Int,- o :: [Vector3],+ o :: [V3 Double], t :: [Double] } | SCALEn { n :: Int,- o :: [Vector3],+ o :: [V3 Double], t :: [Double] } | MTRIXn { serial :: !Int, relMol :: !Bool, n :: !Int,- o :: ![Vector3],+ o :: ![V3 Double], t :: ![Double] } | CRYST1 { a :: !Double, b :: !Double,@@ -249,7 +249,7 @@ symOp1 :: !String, symOp2 :: !String } | TVECT { serial :: !Int,- vec :: Vector3 } |+ vec :: V3 Double } | JRNL { cont :: !Int, content :: ![(String, String)], isFirst :: !Bool } |
Bio/PDB/EventParser/ParseATOM.hs view
@@ -150,7 +150,7 @@ elt = unstr fElt charge = unstr fCharge -- assemble record- coords = Vector3 x y z+ coords = V3 x y z result = case rectag of "ATOM " -> ATOM atid atnam resnam chain resid insid altloc coords occ bFact segid elt charge False "HETATM" -> ATOM atid atnam resnam chain resid insid altloc coords occ bFact segid elt charge True
Bio/PDB/EventParser/ParseMatrixRecord.hs view
@@ -51,7 +51,7 @@ -- (3) input line number -- -- Result is a monad action returning a list of 'PDBEvent's.-parseMatrixRecord :: (Monad m) =>(Int -> Bool -> Int -> [Vector3] -> [Double] -> PDBEvent)-> String-> Int-> m [PDBEvent]+parseMatrixRecord :: (Monad m) =>(Int -> Bool -> Int -> [V3 Double] -> [Double] -> PDBEvent)-> String-> Int-> m [PDBEvent] parseMatrixRecord cons line line_no = return $ if null errs then [result] else errs@@ -67,7 +67,7 @@ IFDouble o3 = fo3 IFDouble t = ft IFInt relMol = fRelMol- result = cons serial (relMol==1) n [Vector3 o1 o2 o3] [t]+ result = cons serial (relMol==1) n [V3 o1 o2 o3] [t] -- | Parses a SCALEn record. --
Bio/PDB/EventParser/ParseTVECT.hs view
@@ -56,7 +56,7 @@ IFDouble t1 = ft1 IFDouble t2 = ft2 IFDouble t3 = ft3- result = TVECT serial $ Vector3 t1 t2 t3+ result = TVECT serial $ V3 t1 t2 t3 -- NOTE: consecutive "TVECT" records should be merged into a single multiline entry with SUCH method --mergeTVECTRecords :: [PDBEvent] -> m [PDBEvent]
Bio/PDB/Structure.hs view
@@ -9,7 +9,7 @@ import GHC.Generics(Generic) import Prelude hiding(String)-import Bio.PDB.EventParser.PDBEvents(String, Vector3(..)) -- extract to a separate module?+import Bio.PDB.EventParser.PDBEvents(String, V3(..)) -- extract to a separate module? import Control.DeepSeq --import Data.Derive.NFData import Bio.PDB.Structure.List as L@@ -68,7 +68,7 @@ -- | NOTE: disordered atoms are now reported as multiplicates data Atom = Atom { atName :: !String, atSerial :: !Int,- coord :: !Vector3,+ coord :: !(V3 Double), bFactor :: !Double, occupancy :: !Double,
Bio/PDB/Structure/Neighbours.hs view
@@ -10,7 +10,7 @@ import qualified Data.Octree as Oct import Bio.PDB.Structure import Bio.PDB.Iterable-import Data.Vector.V3+import Linear -- | Octree of `Atom`s. type AtomOctree = Oct.Octree Atom@@ -26,9 +26,9 @@ makeOctree = Oct.fromList . Prelude.map extract . itfoldr (:) [] -- | Find all `Atom`s within a given radius from a point.-findInRadius :: AtomOctree -> Double -> Vector3 -> [(Vector3, Atom)]+findInRadius :: AtomOctree -> Double -> V3 Double -> [(V3 Double, Atom)] findInRadius = Oct.withinRange -- | Find an `Atom`s closest to a point.-findNearest :: AtomOctree -> Vector3 -> Maybe (Vector3, Atom)+findNearest :: AtomOctree -> V3 Double -> Maybe (V3 Double, Atom) findNearest = Oct.nearest
Bio/PDB/Structure/Vector.hs view
@@ -1,60 +1,59 @@ {-# LANGUAGE NoMonomorphismRestriction, BangPatterns #-} -- | This module wraps 3D vector operations, and adds missing ones.-module Bio.PDB.Structure.Vector(Vector3(..),- unpackVector3,+module Bio.PDB.Structure.Vector(V3(..),+ unpackV3, vnormalise, vdot, (*|), (|*), vzip, vmap, vnorm, vproj, vperpend, vperpends, vdihedral) where -import qualified Data.Vector.Class as C-import Data.Vector.V3+import Linear import Data.List(foldl') import Test.QuickCheck -- | Unpacks an abstract 3D vector into a triple of 'Double's.-unpackVector3 :: Vector3 -> (Double, Double, Double)-unpackVector3 (Vector3 x y z) = (x, y, z)+unpackV3 :: V3 Double -> (Double, Double, Double)+unpackV3 (V3 x y z) = (x, y, z) -- | Maps an operation that modifies a 'Double' onto a 3D vector. {-# INLINE vmap #-}-vmap :: (Double -> Double) -> Vector3 -> Vector3-vmap = C.vmap+vmap :: (Double -> Double) -> V3 Double -> V3 Double+vmap = fmap -- | Maps an operation on a pair of 'Double's onto a pair of 3D vectors -- coordinatewise.-vzip :: (Double -> Double -> Double) -> Vector3 -> Vector3 -> Vector3-vzip = C.vzip+vzip :: (Double -> Double -> Double) -> V3 Double -> V3 Double -> V3 Double+vzip = liftI2 -- | Normalises to a unit vector in the same direction as input. {-# INLINE vnormalise #-}-vnormalise :: Vector3 -> Vector3-vnormalise = C.vnormalise +vnormalise :: V3 Double -> V3 Double+vnormalise = normalize {-# INLINE vdot #-} -- | Computes a dot product of two 3D vectors.-vdot :: Vector3 -> Vector3 -> Double-vdot = C.vdot+vdot :: V3 Double -> V3 Double -> Double+vdot = dot {-# INLINE vnorm #-} -- | 2-norm of a vector (also called a magnitude or length.)-vnorm :: Vector3 -> Double-vnorm = C.vmag+vnorm :: V3 Double -> Double+vnorm = norm {-# INLINE vdihedral #-} -- | Compute dihedral between three bond vectors using spherical angle formula.-vdihedral :: Vector3 -> Vector3 -> Vector3 -> Double-vdihedral !a !b !c = atan2 (vnorm b * (a `vdot` (b `vcross` c)))- ((a `vcross` b) `vdot` (b `vcross` c))+vdihedral :: V3 Double -> V3 Double -> V3 Double -> Double+vdihedral !a !b !c = atan2 (vnorm b * (a `vdot` (b `cross` c)))+ ((a `cross` b) `vdot` (b `cross` c)) {-# INLINE (*|) #-} -- | Scalar product. (asterisk - "*" - indicates side on which one can put a scalar.)-(*|) :: Double -> Vector3 -> Vector3-(*|) = (C.*|)+(*|) :: Double -> V3 Double -> V3 Double+(*|) = (*^) {-# INLINE (|*) #-} -- | Scalar product. (asterisk - "*" - indicates side on which one can put a scalar.)-(|*) :: Vector3 -> Double -> Vector3-(|*) = (C.|*)+(|*) :: V3 Double -> Double -> V3 Double+(|*) = (^*) {-# INLINE vproj #-} -- | Finds a vector component of the first vector that is a projection onto direction of second vector.@@ -72,11 +71,10 @@ -- | Finds a component of the vector v that is perpendicular to all vectors in a list. vperpends v ws = foldl' vperpend v ws -instance Arbitrary Vector3 where+instance Arbitrary a => Arbitrary (V3 a) where arbitrary = do a <- arbitrary b <- arbitrary c <- arbitrary- return $ Vector3 a b c-+ return $ V3 a b c
README.md view
@@ -27,19 +27,16 @@ In particular one may considering these features: -* Migrate out of `text-format`, since it gives portability trouble, and slows things down when printing.-* Migrate from `AC-Vector` to another vector library:- - `vector-space`- - or `linear`+* Implement basic spatial operations of RMS superposition (with SVD),+affine transform on a substructure. * Use `lens` to facilitate access to the data structures. - torsion angles within protein/RNA chain. * Add Octree to the default data structure (with automatic update.)+* Migrate out of `text-format`, since it gives portability trouble, and slows things down when printing. * Write a combinator library for generic fast parsing. * Checking whether GHC 7.8 improved efficiency of fixed point arithmetic, since PDB coordinates have dynamic range of just ~2^20 bits, with smallest step of 0.001.-* Implement basic spatial operations of RMS superposition (with SVD),-affine transform on a substructure. * Class-based wrappers showing Structure-Model-Chain-Residue-Atom interface with possible wrapping of Repa/Accelerate arrays for fast computation.
hPDB.cabal view
@@ -1,5 +1,5 @@ name: hPDB-version: 1.4.0.0+version: 1.5.0.0 synopsis: Protein Databank file format library homepage: https://github.com/BioHaskell/hPDB stability: stable@@ -63,7 +63,7 @@ mtl, template-haskell, vector,- AC-Vector,+ linear, containers, unordered-containers >= 0.2.5.0, deepseq,@@ -74,7 +74,7 @@ parallel >= 3.0.0.0, bytestring, zlib,- Octree>= 0.5+ Octree>= 0.6 if flag(have-sse2) ghc-options: -msse2 if flag(have-mmap)