seqloc 0.6.1 → 0.6.1.1
raw patch · 3 files changed
+30/−6 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Bio.SeqLoc.LocMap: queryLocInto :: Locatable o => Maybe Strand -> SpliceSeqLoc -> SeqLocMap o -> [(o, SpliceLoc)]
Files
- seqloc.cabal +1/−1
- src/Bio/SeqLoc/LocMap.hs +12/−5
- test/TestMain.hs +17/−0
seqloc.cabal view
@@ -1,5 +1,5 @@ Name: seqloc-Version: 0.6.1+Version: 0.6.1.1 Cabal-Version: >= 1.14 Synopsis: Handle sequence locations for bioinformatics Description: Handle sequence locations for bioinformatics
src/Bio/SeqLoc/LocMap.hs view
@@ -25,14 +25,14 @@ , Locatable(..) , WithLocation(..) , locatableSeqLocMap- , queryLocatable, queryLocCompatible+ , queryLocatable, queryLocCompatible, queryLocInto ) where import qualified Data.HashMap.Strict as HM import Data.List--- import Data.Maybe+import Data.Maybe import qualified Bio.SeqLoc.Location as Loc import Bio.SeqLoc.OnSeq@@ -171,8 +171,15 @@ -- | Retrieve a list of `Locatable` objects whose spliced structure -- contains the query location specifically. queryLocCompatible :: (Locatable o) => Maybe Strand -> SpliceSeqLoc -> SeqLocMap o -> [o]-queryLocCompatible mstr qyloc = filter compatHit . querySeqLoc qyloc- where compatHit sb = maybe False strandCompat $ unOnSeq qyloc `SpLoc.locInto` (unOnSeq . locate $ sb)+queryLocCompatible mstr qyloc = map fst . queryLocInto mstr qyloc++-- | Retrieve a list of `Locatable` objects whose splice structure+-- contains the query location, paired with the sub-location of the+-- query within the `Locatable`.+queryLocInto :: (Locatable o) => Maybe Strand -> SpliceSeqLoc -> SeqLocMap o -> [(o, SpLoc.SpliceLoc)]+queryLocInto mstr qyloc = filter strandCompat . mapMaybe compatHit . querySeqLoc qyloc+ where compatHit sb = do into <- unOnSeq qyloc `SpLoc.locInto` (unOnSeq . locate $ sb)+ return (sb, into) strandCompat = case mstr of Nothing -> const True- Just s -> (== s) . Loc.strand + Just s -> (== s) . Loc.strand . snd
test/TestMain.hs view
@@ -51,6 +51,7 @@ , T "Locatable hit Spliced Extended" property_Locatable_locHitSpliced , T "Locatable compat Contig Ext'd" property_Locatable_locCompatContig , T "Locatable compat Spliced Ext'd" property_Locatable_locCompatSpliced+ , T "Locatable into" property_Locatable_locInto , T "Pos revCompl" test_Pos_revCompl , T "Pos atPos" property_Pos_atPos@@ -587,6 +588,22 @@ , zipWith (\isin hit -> hit == isin) isInRevs revHits , zipWith (\isin hit -> hit == isin) isIns allHits ]++property_Locatable_locInto :: [SpLoc.SpliceLoc] -> SpLoc.SpliceLoc -> Property+property_Locatable_locInto ls qy =+ (not . null $ ls) ==> + forAll genPositiveOffset $ \binsz ->+ forAll genName $ \chr ->+ forAll (elements ls) $ \target -> + case qy `SpLoc.locOutof` target of+ Nothing -> True+ Just targout -> let seqlocs = map (OnSeq chr) ls+ locables = [ LM.WithLocation sl sl | sl <- seqlocs ]+ slm = LM.locatableSeqLocMap binsz locables+ intos = LM.queryLocInto Nothing (OnSeq chr targout) slm+ in case filter ((== target) . unOnSeq . LM.withoutLocation . fst) intos of+ [] -> False+ ontargets -> and $ map ((== qy) . snd) ontargets instance (Arbitrary a) => Arbitrary (OnSeq a) where arbitrary = OnSeq <$> arbitrary <*> arbitrary