I am trying to subset a fasta file like described in another post (https://www.biostars.org/p/93056/). I simply want to be able to extract a subset of sequences from a fasta file.

I load the package and the data as described in the other thread:

``
library("seqinr")

fastafile<- read.fasta(file = "proteins.fasta", 
                       seqtype = "AA",as.string = TRUE, set.attributes = FALSE)
```

as well as the list of IDs I was to use for subsetting (the column in `subsetlist` is called `id`).

    subsetlist<-read.table("~/scripts/subsetfasta/test.txt", header=TRUE)

when I attempt to use the solution from the previous thread:

    fastafile[names(fastafile) %in% subsetlist$id]

I get the following:

    named list()

What am I doing wrong or missing?

best regards

Henrik
Looks like none of your fasta record names are in the subset list. You can check by just calling

    names(fastafile) %in% subsetlist$id

Which will be a vector of FALSEs if that's the case.

You probably want to check exactly how the subset list and fasta file IDs are formatted, and use (g)sub, paste or related functions to get them to match.