I have a fasta file of sequences and I am trying to trim them all to a specific length starting with a specific pattern
>seq1
ACTGCTAGCCCAGTCTGACTGACTGACTGTGTCATG
>seq2
ATCTGATGTGTGCCCCAGTGACTGACTGATGGGCCC
>seq3
CTGATGCCCAGTCGAGCTAGCATTGCCCAAATTGGCCATGCTGATGCTG
>seq4
CTAGCTAGCTAGCTGCTAGCTAGCTAGCTAGCATGCCCAGTCATGCCC
Pattern: CCCAGT
I want to write a script that will take a subsequence from each DNA sequence starting with the pattern, length 20bp (this is an example. The actual sequences/subsequences are much longer). Also the pattern must start between 5 and 20 bp from the start (seq4 in this example would be rejected).
I've been reading the Biostrings and Seqinr documentation and I can't really figure out how to do this.
So far, I would probably run it in steps like this:
1. find location of sequence on string (getLocation does this but it says only with subsequences from an ACNUC server, and I don't know how to do this with a subsequence I provide, and on every sequence from my fasta file)
2. if sequences is within expected start point parameters, extract sequence starting at start location to start location and end at start location + 20 (getFrag maybe? - but would this do it on every sequence?)
It's a bit more complicated than this, but right now I'm just trying to get some basics to start from in hopes that I can figure out the rest on my own. Thanks in advance!
Please use the formatting bar (especially the
code
option) to present your post better. I've done it for you this time.Thank you!