hPDB-examples 0.999 → 0.9999
raw patch · 8 files changed
+31/−32 lines, 8 filesdep ~hPDBdep ~iterable
Dependency ranges changed: hPDB, iterable
Files
- examples/CanonicalAxes.hs +12/−13
- examples/CleanPDB.hs +5/−5
- examples/PDB2Fasta.hs +2/−2
- examples/Rg.hs +3/−3
- examples/ShiftToCenter.hs +2/−2
- examples/StericClashCheck.hs +2/−2
- examples/Viewer.hs +3/−3
- hPDB-examples.cabal +2/−2
examples/CanonicalAxes.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE OverloadedStrings, BangPatterns, FlexibleInstances,UndecidableInstances #-}+{-# LANGUAGE OverloadedStrings, BangPatterns, FlexibleInstances,UndecidableInstances, FlexibleContexts #-}+ module Main where import Control.Monad(when)@@ -13,17 +14,17 @@ import Data.List import Text.Printf ---ifoldrPairs :: (Iterable Structure b, Iterable Structure b1) =>(t -> c -> c) -> (b -> b1 -> t) -> c -> Structure -> c-ifoldrPairs fred fpair e s = pairs+itfoldrPairs :: (Iterable Structure a) =>(b -> c -> c) -> (a -> a -> b) -> c -> Structure -> c+itfoldrPairs fred fpair e s = pairs where- pairs' a cont = It.ifoldr (\at r -> (at `fpair` a) `fred` r) cont (s :: Structure)- pairs = It.ifoldr pairs' e (s :: Structure)+ pairs' a cont = It.itfoldr (\at r -> (at `fpair` a) `fred` r) cont (s :: Structure)+ pairs = It.itfoldr pairs' e (s :: Structure) ---ifoldPairs :: (Iterable Structure b, Iterable Structure c) =>(c -> c -> c) -> (b -> c -> c) -> c -> Structure -> c-ifoldPairs fred fpair e s = pairs+itfoldPairs :: (Iterable Structure a) =>(b -> c -> c) -> (a -> a -> b) -> c -> Structure -> c+itfoldPairs fred fpair e s = pairs where- pairs' a cont = It.ifoldl' (\r at -> (at `fpair` a) `fred` r) cont (s :: Structure)- pairs = It.ifoldl' pairs' e (s :: Structure)+ pairs' a cont = It.itfoldl' (\r at -> (at `fpair` a) `fred` r) cont (s :: Structure)+ pairs = It.itfoldl' (flip pairs') e (s :: Structure) -- | findAxes finds all three principal axes so that dimensions are ordered. findAxes structure = let v1 = findLongestOrthogonalVector [ ] structure@@ -37,11 +38,9 @@ dim3 = vnorm v3 in dim1 `seq` dim2 `seq` dim3 `seq` ([dim1, dim2, dim3], [axis1, axis2, axis3]) where- findLongestOrthogonalVector axes = undefined --ifoldPairs pickMaxDist (atDistPerpend axes) nullVector + findLongestOrthogonalVector axes = itfoldPairs pickMaxDist (atDistPerpend axes) nullVector nullVector = fromInteger 0- atDistPerpend :: [Vector3] -> Atom -> Vector3 -> Vector3- atDistPerpend axes !a1 !a2 = vperpends (coord a1 - a2) axes- pickMaxDist :: Vector3 -> Vector3 -> Vector3+ atDistPerpend axes !a1 !a2 = vperpends (coord a1 - coord a2) axes pickMaxDist !v1 !v2 = if vnorm v1 > vnorm v2 then v1 else v2 main = do args <- getArgs
examples/CleanPDB.hs view
@@ -21,18 +21,18 @@ runCounterM = fst . flip runState 1 renumberResidues :: (Iterable s Chain) => s -> s-renumberResidues = imap (\ch -> runCounterM .- imapM forEachResidue $ (ch :: Chain))+renumberResidues = itmap (\ch -> runCounterM .+ itmapM forEachResidue $ (ch :: Chain)) where forEachResidue r = do v <- counter return $ r { resSeq = v } renumberAtoms :: (Iterable s Model) => s -> s-renumberAtoms = imap (\m -> runCounterM $- imapM forEachChain (m :: Model))+renumberAtoms = itmap (\m -> runCounterM $+ itmapM forEachChain (m :: Model)) where forEachChain :: Chain -> CounterM Chain- forEachChain ch = do newCh <- imapM forEachAtom ch+ forEachChain ch = do newCh <- itmapM forEachAtom ch counter return newCh forEachAtom :: Atom -> CounterM Atom
examples/PDB2Fasta.hs view
@@ -61,12 +61,12 @@ Nothing -> Prelude.putStrLn $ "No models found within file '" ++ fname ++ "'." Just m -> process m where- process = PDB.ifoldM (\() ch -> Prelude.putStrLn $ mkRecord fname ch) ()+ process = PDB.itfoldM (\() ch -> Prelude.putStrLn $ mkRecord fname ch) () mkRecord = if gapped opts then fastaGappedRecord else fastaRecord ---printFastaRecords fname s = PDB.ifoldM (\() ch -> Prelude.putStrLn $ fastaRecord fname ch) () s+--printFastaRecords fname s = PDB.itfoldM (\() ch -> Prelude.putStrLn $ fastaRecord fname ch) () s processFile opts fname = do maybePDB <- PDB.parse fname forM_ maybePDB $ printFastaRecords opts fname
examples/Rg.hs view
@@ -35,17 +35,17 @@ radiusOfGyration structure = avgDistDev where -- (c -> b -> c) -> c -> a -> c- avgDistDev = sqrt (ifoldl' addDistDev 0.0 structure/totalMass)+ avgDistDev = sqrt (itfoldl' addDistDev 0.0 structure/totalMass) addDistDev !total at = total + vnorm (coord at - center)**2 * atMass at atMass :: Atom -> Double atMass at = atomicMass $ case assignElement at of "" -> "C" otherwise -> otherwise center = v |* (1.0/totalMass)- where v = ifoldl' addCoord nullVector structure+ where v = itfoldl' addCoord nullVector structure nullVector = fromInteger 0 addCoord v (at :: Atom) = v + coord at |* atMass at counter x (at :: Atom) = x + atMass at - totalMass = ifoldl' counter 0.0 structure+ totalMass = itfoldl' counter 0.0 structure
examples/ShiftToCenter.hs view
@@ -12,12 +12,12 @@ center :: PDB.Structure -> Vector3 center s = avgv where- sumv = ifoldl' addCoord 0 (s :: PDB.Structure)+ sumv = itfoldl' addCoord 0 (s :: PDB.Structure) n = realToFrac . fromIntegral . PDB.numAtoms $ s addCoord v (PDB.Atom { coord = c }) = v+c avgv = (1/n) *| sumv -shift v = PDB.imap subCoord+shift v = PDB.itmap subCoord where subCoord (at@Atom { coord = c }) = at { coord = c - v }
examples/StericClashCheck.hs view
@@ -10,7 +10,7 @@ -- TODO: way to hand over Atom object along with its Residue, Chain and Model -- TODO: make it so that Show gives a "full_id" string by default, e.g. Model, chain, residue id, atom name.-clashCheck s1 s2 = filter (/= []) . Prelude.map clashes $ ifoldr (:) [] s2+clashCheck s1 s2 = filter (/= []) . Prelude.map clashes $ itfoldr (:) [] s2 where clashes (at :: PDB.Atom) = Oct.withinRange ot (radius + maxRadius) (v3v $ PDB.coord at) where@@ -26,7 +26,7 @@ where vdw = Elt.vanDerWaalsRadius elt -makeOctree structure = Oct.fromList . Prelude.map extract . ifoldr (:) [] $ structure+makeOctree structure = Oct.fromList . Prelude.map extract . itfoldr (:) [] $ structure -- Bio.PDB.Structure.Elements should export max bound for vdw etc. -- or a list of known element codes.
examples/Viewer.hs view
@@ -214,14 +214,14 @@ center :: PDBS.Structure -> Vector3 center structure = average where- (!average, _count) = PDBI.ifoldl' step (fromIntegral 0, 0) structure+ (!average, _count) = PDBI.itfoldl' step (fromIntegral 0, 0) structure step :: (Vector3, Double) -> PDBS.Atom -> (Vector3, Double) step (!r, !i) at = let i' = i + 1 in (coord at |* (1/i') + r |* (i/i'), i') dims structure = maxv - minv where- (!minv, !maxv) = PDBI.ifoldl' (\(!minv, !maxv) at -> let c = coord (at :: PDBS.Atom)+ (!minv, !maxv) = PDBI.itfoldl' (\(!minv, !maxv) at -> let c = coord (at :: PDBS.Atom) in (vzip min minv c, vzip max maxv c)) (cs, cs) structure !cs = center structure@@ -233,7 +233,7 @@ [x', y', z'] :: [GL.GLdouble] = Prelude.map realToFrac [x, y, z] renderStructure :: IORef UIState -> PDBS.Structure -> IO ()-renderStructure uiState = PDBI.ifoldM (const renderAtom) ()+renderStructure uiState = PDBI.itfoldM (const renderAtom) () where renderAtom (at :: Atom) = GL.preservingMatrix $ do GL.matrixMode $= GL.Modelview 0 uiSt <- readIORef uiState --m :: GL.GLmatrix GL.GLdouble <- GL.newMatrix GL.ColumnMajor $ currentViewMatrix uiSt
hPDB-examples.cabal view
@@ -1,5 +1,5 @@ name: hPDB-examples-version: 0.999+version: 0.9999 synopsis: Examples for hPDB library stability: beta homepage: https://github.com/mgajda/hpdb-examples@@ -28,7 +28,7 @@ Executable PDB2Fasta main-is: examples/PDB2Fasta.hs ghc-options: -fspec-constr-count=4 -O3 - build-depends: base>=4.0, base <4.7, bytestring, ghc-prim, directory, mtl, template-haskell, vector, AC-Vector, containers, deepseq, QuickCheck >= 2.5.0.0, text>=0.11.1.13, hPDB >= 0.999, iterable >=1.0+ build-depends: base>=4.0, base <4.7, bytestring, ghc-prim, directory, mtl, template-haskell, vector, AC-Vector, containers, deepseq, QuickCheck >= 2.5.0.0, text>=0.11.1.13, hPDB >= 0.9999, iterable >=2.0 other-extensions: ScopedTypeVariables OverloadedStrings BangPatterns NoMonomorphismRestriction EmptyDataDecls MagicHash Executable ShiftToCenter