I am looking to show how a primer is consistent among some genomic data. I have a primer of about 23bp and looking to compare it to about 5000 genomic sequences of 10kb. I am unsure how to format it the way I need to, since I am just trying to show the nucleotide differences of the primer to the genetic sequences. Here is what I need:
> 1. Cut out the area that my primer is located and about 20bp down each end.
> 2. Show only the bases that are different from my primer in my analysis.
> ex: Primer: -----------ATGTGGAAGCAAATATCAAATGA---------
> Gene: ATGACCATACG----C--------------T---ATCGTAGGG
> ATGAGCATACC-----A----T--------T---TTCGAACGC
The data I am using is all dengue sequences (all serotypes) and the primer with the following code: ATGTGGAAGCAAATATCAAATGA.
I am using Biostrings, msa, and seqinr. I use ncbi to get the genetic sequences and using FASTA files.
Thanks!
Edit: Solution: I used MAFFT to align the data, working very efficiently and put it into a fasta file. Then I cut the nucleotides I did not need by: 1. Finding the part i wanted and cutting 10 nucleotides before it and after it. 2. Putting only the [start:end] into a new list, which I will then manipulate.
However, I am still having difficulty finding a way of showing my data nicely because I can't find a suitable package. Any advice?
Edit: Hi all, Just wanted to show the code I made to solve the problem.
#So the we will be using a dataframe that has the sequences as a string
#Then I created a temporary dataframe to store each sequence, with the primer at the top
tempDF <- data.frame(matrix(primer1, nrow = 1, ncol = 1),
stringsAsFactors = FALSE)
for(i in sequenceAsString){
#Temporary vector for each sequence after compared to primer.
temporary1 <- ""
temporary1 <- paste(temporary1, substring(i,1,11), sep = "")
for(j in 12:(nchar(i)-20)){
if(substring(i,j,j) == substring(toString(reversePrimer1), j-12,j-12)){
temporary1 <- paste(temporary1, "-", sep = "")
}else{
temporary1 <- paste(temporary1, substring(i,j,j), sep = "")
}
}
temporary1 <- paste(temporary1, substring(i,nchar(i)-19,nchar(i)), sep = "")
tempDF <- rbind(tempDF,temporary1)
}
So, I essentially take the sequence I chose apart and compare each character to that of the reverseprimer. I then replace the ones that are the same with an '-'
Thanks everyone for their help!
pairwiseAlignment
but totally feasible. And if performance is really of the essence, you can implement e.g. Myers Bit Vector since the primer is so short, and the whole search could happen in sub-second time. Either way, don’t perform a multiple sequence alignment. $\endgroup$