-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Handle sequence locations for bioinformatics
--   
--   Handle sequence locations for bioinformatics
@package seqloc
@version 0.6.1.1

module Bio.SeqLoc.LocRepr
class LocRepr l
repr :: LocRepr l => l -> ByteString
unrepr :: LocRepr l => Parser l
reprStr :: (LocRepr l) => l -> String
unreprMaybe :: (LocRepr l) => ByteString -> Maybe l
unreprEither :: (LocRepr l) => ByteString -> Either String l
unreprErr :: (LocRepr l) => ByteString -> l
instance Bio.SeqLoc.LocRepr.LocRepr Bio.Core.Strand.Strand
instance Bio.SeqLoc.LocRepr.LocRepr Bio.Core.Sequence.Offset

module Bio.SeqLoc.SeqLike
class SeqLike s

-- | Length of sequence data
length :: (SeqLike s, (Integral n)) => s -> n

-- | <a>Just</a> the nucleotide at a specified sequence data offset, given
--   in 0-based coordinates, or <a>Nothing</a> if the offset is beyond the
--   bounds of the data
ntAt :: (SeqLike s, (Integral n)) => s -> n -> Maybe Char

-- | <a>Just</a> the nucleotides in subsequence of the sequence data, or
--   <a>Nothing</a> if the region extends beyond the bounds of the
--   sequence.
subseq :: (SeqLike s, Integral n, Integral m) => n -> m -> s -> Maybe s

-- | Nucleotides in a subsequence of the sequence data, padded with
--   <tt>N</tt> when the region extends beyond the bounds of the sequence.
subseqPad :: (SeqLike s, Integral n, Integral m) => n -> m -> s -> s
concat :: SeqLike s => [s] -> s
instance Bio.SeqLoc.SeqLike.SeqLike [GHC.Types.Char]
instance Bio.SeqLoc.SeqLike.SeqLike Data.ByteString.Internal.ByteString
instance Bio.SeqLoc.SeqLike.SeqLike Data.ByteString.Lazy.Internal.ByteString

module Bio.SeqLoc.ShiftedVector
data ShiftedVector a
ShiftedVector :: !Int -> !a -> !(Vector a) -> ShiftedVector a
[zerois] :: ShiftedVector a -> !Int
[nullis] :: ShiftedVector a -> !a
[vector] :: ShiftedVector a -> !(Vector a)
empty :: (Monoid a) => ShiftedVector a
emptyZ :: a -> ShiftedVector a
singleton :: (Monoid a) => Int -> a -> ShiftedVector a
replicate :: (Monoid a) => Int -> Int -> a -> ShiftedVector a
length :: ShiftedVector a -> Int
null :: ShiftedVector a -> Bool
start :: ShiftedVector a -> Int
end :: ShiftedVector a -> Int
(!?) :: ShiftedVector a -> Int -> a
(//) :: ShiftedVector a -> [(Int, a)] -> ShiftedVector a
modifySome :: ShiftedVector a -> [Int] -> (a -> a) -> ShiftedVector a
ensureLow :: Int -> ShiftedVector a -> ShiftedVector a
ensureHigh :: Int -> ShiftedVector a -> ShiftedVector a
instance GHC.Show.Show a => GHC.Show.Show (Bio.SeqLoc.ShiftedVector.ShiftedVector a)


-- | Utilities for manipulating nucleotide sequences and locations on
--   nucleotide sequences that occur on a forward or a reverse-complement
--   strand.
module Bio.SeqLoc.Strand

-- | A <a>Strand</a> is either plus (forward) or minus (reverse or
--   reverse-complement)
data Strand :: *
Plus :: Strand
Minus :: Strand

-- | Complement of a nucleotide character, swap A<i>T and G</i>C preserving
--   case and leave all other characters unchanged.
compl :: Char -> Char

-- | A nucleotide sequence or location on a nucleotide sequence that lies
--   on a specific strand and has an orientation.
class Stranded s
revCompl :: Stranded s => s -> s

-- | Convert the orientation of a <a>Stranded</a> thing based on a
--   specified <a>Strand</a>
stranded :: (Stranded s) => Strand -> s -> s
instance Bio.SeqLoc.Strand.Stranded Bio.Core.Strand.Strand
instance Bio.SeqLoc.Strand.Stranded GHC.Types.Char
instance Bio.SeqLoc.Strand.Stranded GHC.Word.Word8
instance Bio.SeqLoc.Strand.Stranded GHC.Base.String
instance Bio.SeqLoc.Strand.Stranded Data.ByteString.Lazy.Internal.ByteString
instance Bio.SeqLoc.Strand.Stranded Data.ByteString.Internal.ByteString


-- | Data type for a sequence position.
--   
--   Zero-based <a>Offset</a>indices are used throughout, to facilitate
--   direct use of indexing functions on <a>SeqData</a>.
module Bio.SeqLoc.Position

-- | An <a>Offset</a> is a zero-based index into a sequence
newtype Offset :: *
Offset :: Int64 -> Offset
[unOff] :: Offset -> Int64

-- | Stranded position in a sequence
data Pos
Pos :: !Offset -> !Strand -> Pos

-- | 0-based index of the position
[offset] :: Pos -> !Offset

-- | Strand of the position
[strand] :: Pos -> !Strand

-- | Returns a position resulting from sliding the original position along
--   the sequence by a specified offset. A positive offset will move the
--   position away from the 5' end of the forward stand of the sequence
--   regardless of the strand of the position itself. Thus,
--   
--   <pre>
--   slide (revCompl pos) off == revCompl (slide pos off)
--   </pre>
slide :: Pos -> Offset -> Pos

-- | Extract <a>Just</a> the item at a specific sequence position, or
--   <a>Nothing</a> if the position lies outside the bounds of the
--   sequence.
atPos :: (SeqLike s) => s -> Pos -> Maybe Char
instance GHC.Show.Show Bio.SeqLoc.Position.Pos
instance GHC.Classes.Ord Bio.SeqLoc.Position.Pos
instance GHC.Classes.Eq Bio.SeqLoc.Position.Pos
instance Bio.SeqLoc.Strand.Stranded Bio.SeqLoc.Position.Pos
instance Bio.SeqLoc.LocRepr.LocRepr Bio.SeqLoc.Position.Pos


-- | Data type for a sequence location consiting of a contiguous range of
--   positions on the sequence.
--   
--   Throughout, <i>sequence position</i> refers to a <a>Pos</a> which
--   includes a strand, as opposed to an <i>offset</i>, which refers to a
--   <a>Offset</a> with no strand.
module Bio.SeqLoc.Location
class Location l
strand :: Location l => l -> Strand
length :: Location l => l -> Offset

-- | The bounds of a sequence location. This is a pair consisting of the
--   lowest and highest sequence offsets covered by the region. The bounds
--   ignore the strand of the sequence location, and the first element of
--   the pair will always be lower than the second.
bounds :: Location l => l -> (Offset, Offset)

-- | Sequence position of the start of the location. This is the 5' end on
--   the location strand, which will have a higher offset than
--   <a>endPos</a> if the location is on the <a>Minus</a> strand.
startPos :: Location l => l -> Pos

-- | Sequence position of the end of the location, as described in
--   <a>startPos</a>.
endPos :: Location l => l -> Pos

-- | List of sequence positions in the location, in order from the 5' end
--   to the 3' end of the location strand.
allPos :: Location l => l -> [Pos]

-- | Extract <a>Just</a> the nucleotide <tt>SeqLike</tt> for the sequence
--   location, or <a>Nothing</a> if f any part of the location lies outside
--   the bounds of the sequence.
seqData :: (Location l, SeqLike s, Stranded s) => s -> l -> Maybe s

-- | As <a>seqData</a>, extract the nucleotide subsequence for the
--   location, but any positions in the location lying outside the bounds
--   of the sequence are returned as <tt>N</tt>.
seqDataPad :: (Location l, SeqLike s, Stranded s) => s -> l -> s

-- | Given a sequence position and a sequence location relative to the same
--   sequence, compute a new position representing the original position
--   relative to the subsequence defined by the location. If the sequence
--   position lies outside of the sequence location, <tt>Nothing</tt> is
--   returned; thus, the offset of the new position will always be in the
--   range <tt>[0, length l - 1]</tt>.
posInto :: Location l => Pos -> l -> Maybe Pos

-- | Given a sequence location and a sequence position within that
--   location, compute a new position representing the original position
--   relative to the outer sequence. If the sequence position lies outside
--   the location, <tt>Nothing</tt> is returned.
--   
--   This function inverts <a>posInto</a> when the sequence position lies
--   within the position is actually within the location.
posOutof :: Location l => Pos -> l -> Maybe Pos

-- | For an enclosing location and a sublocation in the same coordinate
--   system, find the image of the sublocation relative to the enclosing
--   location. For example, if the enclosing location spans (100, 150) and
--   the sublocation is (110, 120) then <a>clocInto</a> will be (10, 20).
clocInto :: Location l => ContigLoc -> l -> Maybe ContigLoc

-- | Returns a sequence location produced by finding the inverse image of a
--   sublocation, with coordinates given relative to an enclosing location,
--   in the coordinate system of the enclosing location. For example, if
--   the enclosing location spans (100, 150) and the sublocation is (10,
--   20) then <a>clocOutof</a> will be (110, 120).
clocOutof :: Location l => ContigLoc -> l -> Maybe l

-- | Returns a sequence location produced by extending the original
--   location on each end, based on a pair of (<i>5' extension</i>, /3'
--   extension/). The 5' extension is applied to the 5' end of the location
--   on the location strand; if the location is on the <a>Minus</a> strand,
--   the 5' end will have a higher offset than the 3' end and this offset
--   will increase by the amount of the 5' extension. Similarly, the 3'
--   extension is applied to the 3' end of the location.
extend :: Location l => (Offset, Offset) -> l -> l

-- | Returns <tt>True</tt> when a sequence offset lies within a sequence
--   location on the same sequence
offsetWithin :: Location l => Offset -> l -> Bool

-- | Returns <tt>True</tt> when a sequence position lies within a sequence
--   location on the same sequence, and occupies the same strand.
posWithin :: Location l => Pos -> l -> Bool

-- | Returns <tt>True</tt> when two sequence locations overlap at any
--   position.
contigOverlaps :: Location l => ContigLoc -> l -> Bool

-- | Contigs that comprise the location
toContigs :: Location l => l -> [ContigLoc]
overlaps :: (Location l1, Location l2) => l1 -> l2 -> Bool

-- | Contiguous sequence location defined by a span of sequence positions,
--   lying on a specific strand of the sequence.
data ContigLoc

-- | The offset of the 5' end of the location, as a 0-based index
offset5 :: ContigLoc -> Offset

-- | Create a sequence location lying between 0-based starting and ending
--   offsets. When <tt>start &lt; end</tt>, the location be on the forward
--   strand, otherwise it will be on the reverse complement strand.
fromStartEnd :: Offset -> Offset -> ContigLoc

-- | Create a sequence location from the sequence position of the start of
--   the location and the length of the position. The strand of the
--   location, and the direction it extends from the starting position, are
--   determined by the strand of the starting position.
fromPosLen :: Pos -> Offset -> ContigLoc

-- | Create a sequence location between 0-based starting and ending bounds
--   with a specified strand.
fromBoundsStrand :: Offset -> Offset -> Strand -> ContigLoc

-- | Returns a location resulting from sliding the original location along
--   the sequence by a specified offset. A positive offset will move the
--   location away from the 5' end of the forward stand of the sequence
--   regardless of the strand of the location itself. Thus,
--   
--   <pre>
--   slide (revCompl cloc) off == revCompl (slide cloc off)
--   </pre>
slide :: Offset -> ContigLoc -> ContigLoc
instance GHC.Show.Show Bio.SeqLoc.Location.ContigLoc
instance GHC.Classes.Ord Bio.SeqLoc.Location.ContigLoc
instance GHC.Classes.Eq Bio.SeqLoc.Location.ContigLoc
instance Bio.SeqLoc.LocRepr.LocRepr Bio.SeqLoc.Location.ContigLoc
instance Bio.SeqLoc.Location.Location Bio.SeqLoc.Location.ContigLoc
instance Bio.SeqLoc.Strand.Stranded Bio.SeqLoc.Location.ContigLoc


-- | Data type for a more general sequence location consiting of disjoint
--   ranges of positions on a sequence.
--   
--   Throughout, <i>sequence position</i> refers to a <a>Pos</a> which
--   includes a strand, as opposed to an <i>offset</i>, which refers to a
--   <a>Offset</a> with no strand.
module Bio.SeqLoc.SpliceLocation

-- | General (disjoint) sequence region consisting of a concatenated set of
--   one or more contiguous regions.
data SpliceLoc
fromContigs :: [ContigLoc] -> Maybe SpliceLoc
singleton :: ContigLoc -> SpliceLoc
locOutof :: (Location l) => SpliceLoc -> l -> Maybe SpliceLoc
locInto :: (Location l) => SpliceLoc -> l -> Maybe SpliceLoc

-- | Return the contiguous location spanned by the spliced location.
contigSpan :: SpliceLoc -> ContigLoc
mergeContigs :: [ContigLoc] -> [ContigLoc]
mergeAdjContigs :: ContigLoc -> ContigLoc -> Maybe ContigLoc
instance GHC.Show.Show Bio.SeqLoc.SpliceLocation.SpliceLoc
instance GHC.Classes.Ord Bio.SeqLoc.SpliceLocation.SpliceLoc
instance GHC.Classes.Eq Bio.SeqLoc.SpliceLocation.SpliceLoc
instance Bio.SeqLoc.Strand.Stranded Bio.SeqLoc.SpliceLocation.SpliceLoc
instance Bio.SeqLoc.LocRepr.LocRepr Bio.SeqLoc.SpliceLocation.SpliceLoc
instance Bio.SeqLoc.Location.Location Bio.SeqLoc.SpliceLocation.SpliceLoc


-- | Data types for sequence locations and sequence positions associated
--   with specific, named sequences.
module Bio.SeqLoc.OnSeq

-- | Sequence data are lazy bytestrings of ASCII characters.
newtype SeqLabel :: *
SeqLabel :: ByteString -> SeqLabel
[unSL] :: SeqLabel -> ByteString
toSeqLabel :: ByteString -> SeqLabel
unSeqLabel :: SeqLabel -> ByteString
data OnSeq s
OnSeq :: !SeqLabel -> !s -> OnSeq s
[onSeqLabel] :: OnSeq s -> !SeqLabel
[unOnSeq] :: OnSeq s -> !s
type SeqOffset = OnSeq Offset

-- | A position on a named sequence
type SeqPos = OnSeq Pos

-- | A location consisting of a contiguous span of positions on a named
--   sequence.
type ContigSeqLoc = OnSeq ContigLoc

-- | A general location, consisting of spans of sequence positions on a
--   specific, named sequence.
type SpliceSeqLoc = OnSeq SpliceLoc
andSameSeq :: (a -> b -> Bool) -> OnSeq a -> OnSeq b -> Bool
instance GHC.Classes.Ord s => GHC.Classes.Ord (Bio.SeqLoc.OnSeq.OnSeq s)
instance GHC.Classes.Eq s => GHC.Classes.Eq (Bio.SeqLoc.OnSeq.OnSeq s)
instance Bio.SeqLoc.Strand.Stranded s => Bio.SeqLoc.Strand.Stranded (Bio.SeqLoc.OnSeq.OnSeq s)
instance Bio.SeqLoc.LocRepr.LocRepr s => Bio.SeqLoc.LocRepr.LocRepr (Bio.SeqLoc.OnSeq.OnSeq s)
instance Bio.Core.Sequence.BioSeq (Bio.SeqLoc.OnSeq.OnSeq Data.ByteString.Internal.ByteString)
instance Data.Hashable.Class.Hashable Bio.Core.Sequence.SeqLabel

module Bio.SeqLoc.Transcript

-- | Splice junctions, which are isomorphic to the introns they span, but
--   which support other biologically relevant constructors and accessors.
newtype Junction
Junction :: ContigLoc -> Junction
[intron] :: Junction -> ContigLoc

-- | Create a splice junction from a donor position (the last position in
--   the 5' exon) and the acceptor position (the first position in the 3'
--   exon).
fromDonorAcceptor :: Pos -> Pos -> Junction

-- | Donor position, i.e., the last position in the 5' exon around a
--   junction.
donor :: Junction -> Pos

-- | Acceptor position, i.e., the first position in the 3' exon around a
--   junction.
acceptor :: Junction -> Pos

-- | List of splice junctions from a spliced location, in order.
junctions :: SpliceLoc -> [Junction]

-- | Representation of a genomic transcript, with a gene and a transcript
--   identifier, along with the genomic location of the processed
--   transcript and an optional coding sequence on that transcript.
data Transcript
Transcript :: !SeqLabel -> !SeqLabel -> !SpliceSeqLoc -> !(Maybe ContigLoc) -> Transcript

-- | Gene or locus name for a collection of transcripts
[geneId] :: Transcript -> !SeqLabel

-- | Specific transcript identifier
[trxId] :: Transcript -> !SeqLabel

-- | Sequence location of processed transcript
[location] :: Transcript -> !SpliceSeqLoc

-- | Location of CDS on the transcript
[cds] :: Transcript -> !(Maybe ContigLoc)

-- | <a>Just</a> the location of the 5' UTR on the transcript, or
--   <a>Nothing</a> if there is no <a>cds</a> on the transcript or if the
--   <a>cds</a> location begins at the first nucleotide of the
--   transcript--if a region is returned it will have positive length.
utr5 :: Transcript -> Maybe ContigLoc

-- | <a>Just</a> the location of the 3' UTR on the transcript, or
--   <a>Nothing</a> if there is no <a>cds</a> on the transcript or if the
--   <a>cds</a> location ends at the last nucleotide of the transcript--if
--   a region is returned it will have positive length.
utr3 :: Transcript -> Maybe ContigLoc

-- | Genomic location of CDS within the transcript
cdsLocation :: Transcript -> Maybe SpliceSeqLoc

-- | <a>Just</a> the input contigs sorted in stranded order, when all lie
--   on the same strand, or <a>Nothing</a> if they are not all on the same
--   strand.
sortContigs :: [ContigLoc] -> Maybe [ContigLoc]
instance GHC.Show.Show Bio.SeqLoc.Transcript.Junction
instance Bio.SeqLoc.LocRepr.LocRepr Bio.SeqLoc.Transcript.Junction


-- | Efficient lookup based on potential location overlap
--   
--   Collection of objects with locations, potentially on named sequences,
--   that can be queried to recover all objects whose location could
--   potentially overlap a query location.
--   
--   |
module Bio.SeqLoc.LocMap

-- | Mapping objects to sequence locations in the sense of <a>Location</a>.
data LocMap a

-- | Create an empty object / location map.
--   
--   Specify a characteristic size for efficient queries, which depends on
--   the underlying genome. Smaller sizes yield fewer false candidates but
--   greater memory usage and potentially slower queries.
emptyLM :: Offset -> LocMap a

-- | Insert a new object / location pair and reutrn the updated map
insertLoc :: (Location l) => l -> a -> LocMap a -> LocMap a

-- | Retrieve a list of objects that could potentially overlap the query
--   location.
--   
--   Some objects may not actually overlap the query location. Some objects
--   may appear more than once in the list. However, no object whose
--   location truly overlaps the query will be missing from the list.
--   
--   Overlap is defined by one or more nucleotides in common between the
--   bounds of the two locations, regardless of the relative strands of the
--   query and the object location.
queryLoc :: (Location l) => l -> LocMap a -> [a]

-- | Mapping objects to locations on named sequences
data SeqLocMap a

-- | Create an empty object / location map
--   
--   Specify a characteristic size as per <a>emptyLM</a>.
emptySLM :: Offset -> SeqLocMap a

-- | Insert a new object / location pair and reutrn the updated map
insertSeqLoc :: (Location l) => OnSeq l -> a -> SeqLocMap a -> SeqLocMap a

-- | Retrieve a list of objects that could potentially overlap the query
--   location.
--   
--   Some objects may not actually overlap the query location. Some objects
--   may appear more than once in the list. However, no object whose
--   location truly overlaps the query will be missing from the list.
--   
--   Overlap is defined by one or more nucleotides in common between the
--   bounds of the two locations, regardless of the relative strands of the
--   query and the object location, as well as the same name for the
--   underlying reference sequence.
--   
--   To retrieve objects and test for actual overlap see the
--   <a>Locatable</a> interface and <a>queryLocatable</a> or
--   <a>queryLocCompatible</a>.
querySeqLoc :: (Location l) => OnSeq l -> SeqLocMap a -> [a]

-- | Construct a mapping from transcripts to their genomic locations.
transcriptSeqLocMap :: Offset -> [Transcript] -> SeqLocMap Transcript

-- | Object with a genomic location expressed by <a>SpliceSeqLoc</a>.
class Locatable o
locate :: Locatable o => o -> SpliceSeqLoc

-- | Simple representation of a <a>Locatable</a> object as an arbitrary
--   object adjoined with a location.
data WithLocation a
WithLocation :: !a -> !SpliceSeqLoc -> WithLocation a
[withoutLocation] :: WithLocation a -> !a
[withLocate] :: WithLocation a -> !SpliceSeqLoc

-- | Construct a mapping from a general <a>Locatable</a> object to its
--   genomic location
locatableSeqLocMap :: (Locatable l) => Offset -> [l] -> SeqLocMap l

-- | Retrieve a list of <a>Locatable</a> objects whose overall, contiguous
--   genomic coordinates intersect at any position the genomic interval
--   spanned by the specified <a>Location</a>. This does not require that
--   the spliced structure of the query is a subset of the spliced
--   structure of the <a>Locatable</a> nor that the query location lie
--   entirely within the hit location (contrast with
--   <a>queryLocCompatible</a>).
--   
--   When a strand argument is given, restrict matches to those lying on
--   the same strand as the query location, for `Just Plus`, or the
--   opposite strand, for `Just Minus`.
queryLocatable :: (Locatable o, Location l) => Maybe Strand -> OnSeq l -> SeqLocMap o -> [o]

-- | Retrieve a list of <a>Locatable</a> objects whose spliced structure
--   contains the query location specifically.
queryLocCompatible :: (Locatable o) => Maybe Strand -> SpliceSeqLoc -> SeqLocMap o -> [o]

-- | Retrieve a list of <a>Locatable</a> objects whose splice structure
--   contains the query location, paired with the sub-location of the query
--   within the <a>Locatable</a>.
queryLocInto :: (Locatable o) => Maybe Strand -> SpliceSeqLoc -> SeqLocMap o -> [(o, SpliceLoc)]
instance GHC.Classes.Eq a => GHC.Classes.Eq (Bio.SeqLoc.LocMap.WithLocation a)
instance GHC.Show.Show a => GHC.Show.Show (Bio.SeqLoc.LocMap.SeqLocMap a)
instance GHC.Show.Show a => GHC.Show.Show (Bio.SeqLoc.LocMap.LocMap a)
instance Bio.SeqLoc.LocMap.Locatable (Bio.SeqLoc.LocMap.WithLocation a)
instance Bio.SeqLoc.LocMap.Locatable Bio.SeqLoc.OnSeq.ContigSeqLoc
instance Bio.SeqLoc.LocMap.Locatable Bio.SeqLoc.OnSeq.SpliceSeqLoc
instance Bio.SeqLoc.LocMap.Locatable Bio.SeqLoc.Transcript.Transcript
