How to split a genome fasta into a fasta containing multiple short fragments?
Coding noob here.
I downloaded the RefSeq genome fasta for E. coli, and I want to create a fasta where the genome is split into multiple fragments, each with the length of 15.
For example,
"AAAAAAAAAAAAAAAGGGGGGGGGGGGGGG......"
becomes
"AAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAG"
"AAAAAAAAAAAAAGG"
etc.
I'm trying to do this in R as I don't have any python skills. Currently, I have,
# Read in E coli genome fasta file
eco_genome <- readDNAStringSet("data/GCF_904425475.1_MG1655_genomic.fna")
eco_genome_string <- eco_genome %>%
as.character() %>%
paste(collapse = "")
I think I need to use a substring() function??
Once I have the new fasta containing the 15 nt fragments, I want to map them to a different genome fasta. (Basically, I want to know which 15 nt sequences are shared between the two genomes.)
Posted Mar 6, 2026, 5:32 PM UTC
315