Search code examples
rfastawritetofile

(biostrings)writeXStringSet-Error message - 'x' must be an XStringSet object


I'm trying to use the Biostrings function 'writeXStringSet' My string is 'AAAAATTTTCCCCGGGG' The name of the sequence is 'NAME' I have tried to following script

writeXStringSet(seq,width=70,format="fasta"))

But I keep getting the following error

'x' must be an XStringSet object

What am I doing wrong?


Solution

  • Ask questions about Bioconductor packages on the Bioconductor support site. You have a character vector, but want a DNAStringSet (X=DNA in this case, but could also be AA if this were an amino acid sequence).

    dna = DNAStringSet(seq)
    

    Likely you intend to have names on your sequence, c(foo="AAA", bar="ATCG") or names(dna) = c("foo", "bar"), else writing in fasta format wouldn't make sense.