{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} -- | FR3D provides a very convenient library of explored RNA structures. We are -- mostly interested in the "basepairs" files. In contrast to the RNAstrand -- library or melting experiments, these data sets provide non-canonical RNA -- pairing. -- -- NOTE that FR3D entries contain basepairs both in (i,j) as well as (j,i) -- orientation (with i CWW ?! } deriving (Show) -- | The default format is a bit unwieldy; Linearization assumes that all -- sequences are in 5'->3' order; then produces one sequence with "&" -- separating the sequences and pairs reduced to (Int,Int,cWW). linearizeFR3D :: FR3D -> LinFR3D linearizeFR3D FR3D{..} = LinFR3D { pdbID = pdbid , sequence = BS.intercalate "&" $ L.map snd chains , pairs = L.map f basepairs } where trans = snd $ L.mapAccumL ( \acc (x,y) -> (acc + 1 + BS.length y, (x,acc)) ) 0 chains f Basepair{..} = ( ( maybe (-1) (\v -> v+seqpos1) $ L.lookup chain1 trans , maybe (-1) (\v -> v+seqpos2) $ L.lookup chain2 trans ) , interaction ) class RemoveDuplicatePairs a where removeDuplicatePairs :: a -> a instance RemoveDuplicatePairs FR3D where removeDuplicatePairs x@FR3D{..} = x{basepairs = L.filter f basepairs} where f Basepair{..} = (chain1,seqpos1) < (chain2,seqpos2) instance RemoveDuplicatePairs LinFR3D where removeDuplicatePairs x@LinFR3D{..} = x{pairs = L.filter f pairs} where f ((x,y),_) = x