I think I'm using the right function,and there is no error message. But I didn't get the result.Here is what I did.
library(BSgenome)
bd<-DNAString("CAGGTAG")
dna <- readDNAStringSet("sequence.txt")
zld_bindingsite<-vmatchPattern(bd,dna, max.mismatch=0)
And my result is:
MIndex object of length 5050
$`dm3_cytoBand_101F1 range=chr4:69669-90134 5'pad=0 3'pad=0 strand=+repeatMasking=none`
IRanges of length 0
$`dm3_cytoBand_102A1 range=chr4:90135-128922 5'pad=0 3'pad=0 strand=+ repeatMasking=none`
IRanges of length 0
$`dm3_cytoBand_102A2 range=chr4:128923-130909 5'pad=0 3'pad=0 strand=+ repeatMasking=none`
IRanges of length 0
...
<5047 more elements>
But the DNAStringSet looks fine.
head(dna)
A DNAStringSet instance of length 6
width seq names
[1] 20466 AATTGTCCTTATTAATTGACGATGCT...ATTATGCGCCTGATTTAAAGTACAAA dm3_cytoBand_101F...
[2] 38788 ATGTGTAAATATATCACCTTACCGTC...CATGCTAATCACTCGCTTTTAAATAG dm3_cytoBand_102A...
[3] 1987 CAACTTGGGCCACCTTCATCACCAAT...GACAATCCTGTATATCCTATAACACT dm3_cytoBand_102A...
[4] 24243 AGAGCCTTATGTAATCCACCTCATTT...TTCACTTGTAATTTTAAATTGTTCAG dm3_cytoBand_102A...
[5] 38787 AAATGTTCGCAAGTCAGAGCAAGGCT...AGCGGGAGCTTCTAAGACTTTGTTTT dm3_cytoBand_102A...
[6] 1987 TCGTGTTTTGCTCGTTCACAAAATCC...ATTATTAAAATACTTTCAAAAATAAA dm3_cytoBand_102
But I expect to see the results like this:
test<-BString("AATTGTCCTTATTAATTCAGGTAGGACGATGCTATATTATTAGTCTTTCCCAGGTAGGACATTACCCGCTAGTGAAATGTGATATTCTGAATCTTTCCGCTGTAAGCGCTTTAAGTTTGTTGCAATTA")
> bd<-DNAString("CAGGTAG")
> zld_bindingsite<-matchPattern(bd,test, max.mismatch=0)
> zld_bindingsite
Views on a 128-letter BString subject
subject: AATTGTCCTTATTAATTCAGGTAGGACGATGCTATAT...TCTTTCCGCTGTAAGCGCTTTAAGTTTGTTGCAATTA
views:
start end width
[1] 18 24 7 [CAGGTAG]
[2] 51 57 7 [CAGGTAG]
I actually can extract the seq by using toString()
, but in this way I can only have one single string. Is there any function that can extract all the sequences from this StringSet?