Writing fasta files using the seqinr R package?

When I use write.fasta in seqinr, the file it outputs is as follows:

>Sequence name 1 >Sequence name 2 >Sequence name 3 ...etc Sequence 1 Sequence 2 Sequence 3 ...etc 

In other words, the sequence names are at the beginning of the file, and then the sequences are displayed together at the end of the file.

What I would like to do is:

 >Sequence name 1 Sequence 1 >Sequence name 2 Sequence 2 >Sequence name 3 Sequence 3 ...etc 

Is this possible with write.fasta?

+6
source share
4 answers

I had a similar problem. I did to convert a vector containing sequences to a list, and it worked fine.

e.g. write.fasta(as.list(seq),names,file)

+17
source

Actually, I always get it right, and it never occurred to me a problem similar to yours. Try it.

Copy this text below:

 >seq1 agctgtagtc >seq2 agtctctctt >seq3 atgtataaaa 

Save it as "test.fasta". Then in R do the following

 my.dna<-read.fasta("test.fasta") write.fasta(sequences=my.dna,names=names(my.dna),file.out="write.my.dna.fasta") 

If you open "write.my.dna.fasta", you will get the following:

 >seq1 agctgtagtc >seq2 agtctctctt >seq3 atgtataaaa 
+2
source

Hell. 6.5 years later, I have exactly the same problem. I do not believe that so far no one has fixed it.

Minimal example:

 write.fasta(c("AAA", "CCC"), names=c("a", "b"), file.out="foo.fa") 
0
source

I was stuck with this and got some help from a friend. You need to define the sequences in the list. Here is an example code in which the input from maxquant output is a CSV with a column named sequence and a column name named "leading razor protein":

 library(tidyverse) library(seqinr) MU = read_csv('data.csv') seqs = as.list(dplyr::pull(MU, Sequence)) names = dplyr::pull(MU, 'Leading razor protein') write.fasta(seqs, names, "MU.fasta", open = "w", as.string = FALSE) 
0
source

All Articles