[BioC] merging two DNAStringsets

Valerie Obenchain vobencha at fhcrc.org
Wed Jun 15 06:56:29 CEST 2011


Hi Kristian,

To combine all ranges in first.subseq and second.subseq,

     singleseq <- c(unlist(first.subseq), unlist(second.subseq))

 > singleseq
   82-letter "DNAString" instance
seq: 
ATATATATATATATATATATGCGCGCGCGCGCGCGC...TATATATATATATATCGCGCGCGCGCGCGCGCGCGC


To combine the ranges within first and second and then create a 
DNAStringSet, here is an approach using unlist and views,

     seqlist <- list(first.subseq, second.subseq)
     widths <- sapply(seqlist, function(x) sum(width(x)))
     seqviews <- successiveViews(singleseq, widths)
     as(seqviews, "DNAStringSet")

   A DNAStringSet instance of length 2
     width seq
[1]    40 ATATATATATATATATATATGCGCGCGCGCGCGCGCGCGC
[2]    42 TATATATATATATATATATATCGCGCGCGCGCGCGCGCGCGC


Valerie

On 06/13/11 04:01, Ullrich, Kristian wrote:
> Hello Bioconductor curators,
>
> How I can merge two subseqs of one DNAStringSet into one DNAStringSet?
>
> seq.list=list()
> seq.list[1]=paste(rep("AT",50),collapse="")
> seq.list[2]=paste(rep("GC",50),collapse="")
> example = DNAStringSet(unlist(seq.list))
>
> length(example) = 2
> width(example) = 100
> start1 = 1
> end1 = 20
> start2 = 40
> end2 = 60
> first.subseq = subseq(example,start1,end1)
> second.subseq = subseq(example,start2,end2)
>
> c(first.subseq,second.subseq) doesn´t paste the sequences together
>
> Is there an easy method? Or do i have to loop over all entries?
>
> Thank you in anticipation
>
> Kristian Ullrich
> Institute of Plant Biochemistry
>
>
>
> 	[[alternative HTML version deleted]]
>
>    
>
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list