avogadrio
avogadrio copied to clipboard
Randomize button
It was suggested on Twitter that we should introduce a randomize button that will give a random compound and (maybe) random colors. The compound name should probably appear in the custom label as well, so the user actually knows which chemical they're about to set as their desktop background.
We could try to find an external API that will give a random compound name, or just pull from the site cache. I think the latter is the better option to be honest.
Hey. Turns out I was working on this a few hours ago, in C.
It's quite hard, you either need a generator that doesn't generate faulty compounds, or a database with different valid compound names.
I already have a small DB with basic alkanes, alkenes, alkynes, azanes, silanes, alcohols, aldehydes, ketones, and alkyl halides. I'm working on a molecule generator.
If anyone has some web programming skills, I'll just make a repo with the generator so it can be adapted on avogadr.io
Really appreciated @Garuda1, when you put that repo up please do let me know and I'll look at porting/integrating it.
If you're happy with being confined to only the >100 million compounds in PubChem then a simple way of doing this may be using their REST API: e.g. https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/14969/property/isomericsmiles/txt CIDs are typically assigned sequentially, so any number between 1 and ~131 million will give a different structure. A small percentage of CIDs won't give a structure as they correspond to structures where a PubChem depositor removed their deposition, perhaps as the structure they originally deposited was erroneous.