Entering edit mode
4.0 years ago
smrutimayipanda
▴
20
I want to run one tool called ClassyfireR from which I will get compounds classification details as result. In their site, the following code is given:
> library(classyfireR)
> inchi_keys <- c('BRMWTNUJHUMWMS-LURJTMIESA-N', 'MDHYEMXUFSJLGV-UHFFFAOYSA-N')
> classification_result <- get_classification(inchi_keys[1])
its result is given in object form such as:
> classification_result
── ClassyFire Object ────────────────────────────────────────────────────────────────────────── classyfireR v0.3.0
Object Size: 18.2 Kb
Info:
● InChIKey=BRMWTNUJHUMWMS-LURJTMIESA-N
● [H][C@](N)(CC1=CN(C)C=N1)C(O)=O
● Classification Version: 2.1
kingdom : Organic compounds
└─superclass : Organic acids and derivatives
└─class : Carboxylic acids and derivatives
└─subclass : Amino acids, peptides, and analogues
└─level 5 : Amino acids and derivatives
└─level 6 : Alpha amino acids and derivatives
└─level 7 : Histidine and derivatives
I want to run the above three line code for 11 crore inchi keys and store the result in one file or different file. Please suggest me how to modify the code according to inchi keys(nearly in crores)? Thanks in advance
Read the chapter 6 in https://cran.r-project.org/doc/contrib/Paradis-rdebuts_en.pdf
Sorry but i didnt find anything related to my query. Can you please suggest me any idea how to do this?
The section vectorization has exactly what you need. Please read it more carefully.
I have gone through that. it worked but not completely. can you please help me?
Please explain - what part of it failed?
I wrote this code. In this, I took all the inputs in loop but at the last, it is not giving output in bulk. That
i[1]
I have to change it to 2,3,4,etc every time. Can you please tell me how to apply loop in last line to get output of all inputs?file <- c(test)
is a meaningless statement. Plus, don't override keywords likefile
. You're still using a loop, not a vectorized method so you've not studied the segment on vectorization. Please do that and let us know if you have difficulties in that.but sir i understood this way only, it would be helpful if you tell me the exact code how to write it
Sorry but we are not a code writing service. You're welcome to use loops or vectorization - it's your code but from the above snippet, I can't understand what you're doing and your loop doesn't seem to be looping over what it needs to loop over.
Try
lapply(inchi_keys, get_classification)
andsapply(inchi_keys, get_classification)
whereinchi_keys
is the 2 member vector from your top level post. Once you see how that works, work on building theinchi_keys
array to contain all the keys you need and using the appropriate function to get your results.yeah thats what I was asking for. I also know that this is not code writing service platform but we beginners expect some kind of knowledge or idea from you. Thank you so much. I will try with this method
Thank you so much, it works finally. Only one line code I added and its done