I'm am new trying to prgramming and I woul like to separate from a multifasta, only specific sequences depending on their accession number, and create two different files, the first one with the sequences which their id is in the accession number list and the second one with the rest of files. I dont have any error after run the code but the output 1 is empty and it has to have the three sequences corresponding the accession number list....
Any comment is really welcome, and thanks in advance!
here is my not working python code:
from Bio import SeqIO from Bio.Seq import Seq from Bio.SeqRecord import SeqRecord accession_numbers = ["BA000007", "AL513382", "BX936398"] infile = open("sequences.fasta") my_file_1 = open("output_1.fasta", "w") for seq_record in SeqIO.parse(infile, "fasta"): my_file_1.write(">" + str(seq_record.id) + "\n" + str(seq_record.seq) +"\n")