This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Adding names and other descriptors to DNAStrings

Hi everyone

I am in the process of learning how to work in R with Biostrings

With DNAStringSets (and AAStringSets) it is possible to add descriptors to the sequence using the names function

Thus if you have the sequence AGTCACC, and make this a DNAStringSet you can add a description:

seq <- "AGTCACC"
seq_2 <- DNAStringSet(seq)
names(seq_2) <- "My example"
seq_2

However, if I try this with a DNAString, nothing gets stored

seq_3 <- DNAString(seq)
names(seq_3) <- "My example"
seq_3

Is there a clever way to add descriptors to a DNAString? Or do I need to work with DNAStringSets?

Thanks

biostrings dnastring

1 answer

You can add any information you want in the meta-data of the DNAString object.

Example data.

library("Biostrings")

dna_string <- DNAString("ATGCGGAT")

> dna_string
  8-letter "DNAString" instance
seq: ATGCGGAT

The metadata function is used to set and get the meta-data.

metadata(dna_string)$name <- "string1"

> metadata(dna_string)
$name
[1] "string1"

A really clear and useful reply

Thanks

Log in to answer this question.