Fede Riva
Fede Riva

Reputation: 25

Using of prepgetannot() in order to get specific fields of the annotation section in seqinr

I'm trying to get some specific annotations using seqinr. I recently started using R and also, too seqinr. So, the question is: I want to get some specific fields of the annotations section using first prepgetannot and then getAnnots. I tell you what i'm doing:

First (until here no problem)

s <- choosebank("genbank")
cavia <- query("cavia", "TID=10140 AND O=mitochondrion", socket = s$socket)

At this moment I can use getAnnots to get some annotations of cavia like getAnnots(cavia$req[1:2]) but my intention is for example to filter this and get only the definition or the organism.

I suppose that i could do this with the prepgetannot function but, really, honestly I don't know how to do that. My first idea was using prepgetannot and then getAnnots but this don't seems to work out. This is what I do.

prepgetannots(what = "OR", setfor = c("scan", "getannots"), socket = s$socket, verbose = FALSE)

And then use the getAnnots() function like before but I get the same result, that is, the complete annotation with all the fields. Obviously I'm doing something wrong but I cant realize what's my mistake. Thanks, and sorry for my english, this is my first time posting a question here. If you want I can post the output of the annotations but is simply the entire annotations of the accesions that I request

Upvotes: 1

Views: 85

Answers (1)

LCM
LCM

Reputation: 412

You can pull out just certain fields after you use getAnnot(). Note that at least in version 3.1-3 of seqinr the function getAnnots() does not exist.

To get just the definition, you can do something like

# From your example
s <- choosebank("genbank")
cavia <- query("cavia", "TID=10140 AND O=mitochondrion", socket = s$socket)

# Retrieve all annotations
cavia1_annot <- getAnnot(cavia$req[1])

# Store only the definition in an object
cavia1_def <- cavia1_annot[[1]][2]

# Store only the organism name in an object
cavia1_org <- cavia1_annot[[1]][8]

Because all the annotations are stored in a list, you just have to figure out which number in the list matches the field you want. Descriptions are the second item in the list, the organism is the eighth.

Probably this is not the most elegant solution, but it works.

Upvotes: 1

Related Questions