I am trying to extract a specific sequence from a multifasta file, from each sequence in the aligned file.
The sequences look like this, and there are 32 sequences within the multiFASTA:
>NC_045512.2_Severe_acute_respiratory_syndrome_coronavirus_2_isolate_Wuhan-Hu-1_complete_genome ATT AAA GGT TTA TAC CTT CCC AGG TAA CAA ACC AAC CAA CTT TCG ATC TCT TGT AGA TCT GTT CTC TAA ACG AAC TTT AAA ATC TGT GTG GCT GTC ACT CGG CTG CAT GCT TAG TGC ACT CAC GCA GTA TAA TTA ATA ACT AAT TAC TGT CGT TGA CAG GAC ACG AGT AAC TCG TCT ATC TTC TGC AGG CTG CTT ACG GTT TCG TCC GTG TTG CAG CCG ATC ATC AGC ACA TCT AGG TTT CGT CCG GGT GTG ACC GAA AGG TAA GAT GGA GAG CCT TGT CCC TGG TTT CAA CGA GAA AAC ACA CGT CCA ACT
Using the following code I can pull the sequence, using coordinates, from a single FASTA file, but how would one iterate this to pull the section (by coordinates) from each sequence within the multiFASTA?
from Bio import SeqIO from Bio.SeqIO.FastaIO import FastaWriter import os os.chdir("C:/Users/") record = SeqIO.read("Whole genome.fas", "fasta") with open("Spike protein.fasta", "wt") as out: writer = FastaWriter(out, wrap = ) writer.write_header() writer.write_record(record[21563:25384]) writer.write_footer()
Thanks in advance!