Here is another filter example (without the closure),

startsWithG <- srFilter(function(x) {
  hasLetterAt(x, "G", 1)  ## wrap x with sread() for an AlignedRead class
 }, name="seqStartsWithG")

An alternative without creating a filter would be to use trimLRPatterns with
a left Lpattern of "G", and fetch the ranges, then you want to find the
index all matches that start at position 2, but this is slower than any of
these filters.


Marcus



On Wed, Feb 10, 2010 at 9:57 AM, Vincent Carey
<[email protected]>wrote:

> there are undoubtedly many possibilities, here is a simple stepwise
> approach
> using a closure to satisfy the constraint on filter form (must be
> function of one argument 'x')
>
> firstIsX = function(sro, X) {
>  as(substr(sread(sro),1,1),"character") == X
> }
>
> firstIsA = srFilter(function(x) firstIsX(x,"A"), name="firstIsA")
>
> example(srFilter) # to get aln, an instance of AlignedRead, into scope
>
> aln[firstIsA(aln)]  # seems to comply
>
> sread( aln[ firstIsA(aln) ] )  # seems to do what was requested
>
>
> On Tue, Feb 9, 2010 at 3:30 PM, joseph <[email protected]> wrote:
> > Hi
> > can you help me create a filter to subset only reads that start with a
> particular nucleotide, for example G?
> > Many thanks
> > -Joseph
> >
> >
> >
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioc-sig-sequencing mailing list
> > [email protected]
> > https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
> >
>
> _______________________________________________
> Bioc-sig-sequencing mailing list
> [email protected]
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
>

        [[alternative HTML version deleted]]

_______________________________________________
Bioc-sig-sequencing mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing

Reply via email to