2

I am new in this community and I would like to ask this (I did not find any question that could help me).

I have this string:

{name:GTP hydrolysis and joining of the 60S ribosomal subunit,description:Hydrolysis of eIF2-GTP occurs after the Met-tRNAi has recognized the AUG. This reaction is catalyzed by eIF5 (or eIF5B) and is thought to cause dissociation of all other initiation factors and allow joining of the large 60S ribosomal subunit. The 60S subunit joins - a reaction catalyzed by eIF5 or eIF5B - resulting in a translation-competent 80S ribosome. Following 60S subunit joining, eIF5B hydrolyzes its GTP and is released from the 80S ribosome, which is now ready to start elongating the polypeptide chain.,url:https://reactome.org/PathwayBrowser/#/R-HSA-72706,sameAs:null,version:62,keywords:[Pathway],creator:[],includedInDataCatalog:{url:https://reactome.org,name:Reactome,@type:DataCatalog},distribution:[{contentUrl:https://reactome.org/ContentService/exporter/sbml/72706.xml,fileFormat:SBML,@type:DataDownload},{contentUrl:https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/72706,fileFor... <truncated>

Which is very messy and I would like to remove all the characters before the word description. So it would end up like this:

description:Hydrolysis of eIF2-GTP occurs after the Met-tRNAi has recognized the AUG. This reaction is catalyzed by eIF5 (or eIF5B) and is thought to cause dissociation of all other initiation factors and allow joining of the large 60S ribosomal subunit. The 60S subunit joins - a reaction catalyzed by eIF5 or eIF5B - resulting in a translation-competent 80S ribosome. Following 60S subunit joining, eIF5B hydrolyzes its GTP and is released from the 80S ribosome, which is now ready to start elongating the polypeptide chain.,url:https://reactome.org/PathwayBrowser/#/R-HSA-72706,sameAs:null,version:62,keywords:[Pathway],creator:[],includedInDataCatalog:{url:https://reactome.org,name:Reactome,@type:DataCatalog},distribution:[{contentUrl:https://reactome.org/ContentService/exporter/sbml/72706.xml,fileFormat:SBML,@type:DataDownload},{contentUrl:https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/72706,fileFor... <truncated>

Thanks in advance!

3 Answers 3

4

You should use a reg ex approach, so you can deal with different numbers of leading characters:

a <- "{name:GTP hydrolysis and joining of the 60S ribosomal subunit,description:Hydrolysis of eIF2-GTP occurs after the Met-tRNAi has recognized the AUG. This reaction is catalyzed by eIF5 (or eIF5B) and is thought to cause dissociation of all other initiation factors and allow joining of the large 60S ribosomal subunit. The 60S subunit joins - a reaction catalyzed by eIF5 or eIF5B - resulting in a translation-competent 80S ribosome. Following 60S subunit joining, eIF5B hydrolyzes its GTP and is released from the 80S ribosome, which is now ready to start elongating the polypeptide chain.,url:https://reactome.org/PathwayBrowser/#/R-HSA-72706,sameAs:null,version:62,keywords:[Pathway],creator:[],includedInDataCatalog:{url:https://reactome.org,name:Reactome,@type:DataCatalog},distribution:[{contentUrl:https://reactome.org/ContentService/exporter/sbml/72706.xml,fileFormat:SBML,@type:DataDownload},{contentUrl:https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/72706,fileFor..."

gsub('(.*)description:','', a)
Sign up to request clarification or add additional context in comments.

Comments

3

You can use str_extract from stringr

library(stringr)
str_extract(text, "description:(?s)(.*$)")

"description:Hydrolysis of eIF2-GTP occurs after the ...

Comments

0

What about this

library(stringr)
yourData$yourColumn <- str_sub(yourData$yourColumn, start=62)  # hope I've counted right!

1 Comment

But not in all the texts the word description is in the same position. I want a generalized way that detects the word "description"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.