This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I create a new fasta file after modifying an existing fasta file?

I have a fasta file with 10 protein sequences. Using R I generate a new protein sequence and using write.fasta I insert the new sequence in the original file. Is there a way to create a new fasta file with a new name containing the 11 sequences? Basically I need to "save as".

r write.fasta new_fasta_file

What have you tried? Show us your code please.

The original fasta file is called histone4.fa. After I have generated the new sequence(new hist) I write write.fasta(newhist, names = names("histone4.fa"), file.out = "histone4.fa", open = "a") and a new line is added to my open fasta file. If I write write.fasta(newhist, names = names("histone4.fa"), file.out = "histone4new.fa", open = "a") a new file is created but only with the new sequence. If I write

write.fasta(histone, names = names("histone4.fa"), file.out = "histone4new.fa", open = "a")
write.fasta(newhist, names = names("histone4.fa"), file.out = "histone4new.fa", open = "a")

it works but I was wondering if there is a more compact way to do it.

*histone = readAAStringSet("histone4.fa")

You could concatenate histone and newhist and write it in a single line.

0 answers

No answers yet.

Log in to answer this question.