Thanks everyone for your suggestions.

This approach also works:

foo <- DNAStringSet('ACTTA')

foo <- as.character(foo)

DNAStringSet(paste(substr(foo, 1,2), 'G', substr(foo, 3, nchar(foo)),
sep='', col=''))

Thanks,
Andrew

On Tue, Jul 20, 2010 at 12:23 AM, Vincent Carey
<stvjc@channing.harvard.edu>wrote:

> This particular task might be solved with gsub():
>
> > foo <- DNAStringSet('ACTTA')
> > gsub("^(..)(.)", "\\1G\\2", foo)
> [1] "ACGTTA"
>
> There is of course a more concise solution than the one given here.
>
> On Mon, Jul 19, 2010 at 11:11 PM, Andrew Yee <yee@post.harvard.edu> wrote:
> > Is there a way to use subseq() to insert nucleotides?
> >
> > Take for example foo:
> >
> > foo <- DNAStringSet('ACTTA')
> >
> > I'd like to insert e.g. a G between positions 2 and 3 so that foo looks
> like
> > 'ACGTTA'  Is there a way to do this using subseq()?  Or is an alternative
> > function recommended?
> >
> > Thanks,
> > Andrew
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioc-sig-sequencing mailing list
> > Bioc-sig-sequencing@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
> >
>

	[[alternative HTML version deleted]]

