it is for input prediction.As such I wouldn't actually use a + quantifier but give leeway e.g. starting with {6,} and restrict the character set to COHNSOFla...
Dear all,
- I am thankful for a pointer to regex, matching SMILES, InChi... (and other text based notations of chemical structure). I started with SMILES, now I am off to Inchi.
- Do you know of a good regular expression library website for bioinformatics? (that excludes the regexlib-website)
Here's a PREG version for SMILES validation (JavaScript) beyond a length of 5:
x.trim().match(/^([^J][0-9BCOHNSOPrIFla@+\-\[\]\(\)\\=#$]{6,})$/ig)
(generic:)
/^([^J][A-Za-z0-9@+\-\[\]\(\)\\=#$]+)$/
PS: It's not that I am not versed with RegEx, it just feels so senseless reinventing the wheel over and over again.
Searching for pieces of code (sourceforge, bitbucket, github, code.google.com) is still a challenge. Am I alone in this?
PPS: The only letter not appearing on the Periodic Table is the letter "J"
See:
- <script src='https://gist.github.com/1312860></script>
- http://www.google.com/codesearch#/
- http://www.cavdar.net/2008/08/01/my-top-10-source-code-search-engines/ (all of these are pretty much useless for bio/chem-informatics)
Upd: Added gist
3 answers
You could check out the Blue Obelisk website.
http://blueobelisk.shapado.com/
"The Blue Obelisk Exchange is the place to ask about the use and development of Open Data, Open Source, and Open Standards: how to perform tasks and solve chemical problems with these, or if an ODOSOS tools is available for some task. Or even to ask if someone can provide such a tool. The questions do not require to be about Blue Obelisk solutions itself; they can be about any ODOSOS chemistry tool, service, or database."
Check the resume and code from a Coding Dojo on parsing SMILES, organized in Barcelona:
It's mostly a set of tests and the infrastructure of a function, but it can get you started. In any case, I guess that unit testing can be useful when coding parsers for complex strings like SMILES.
Interesting, but from the first look of it, it doesn't seem to be fun implementation than a complete-spec SMILES parser. Thanks.
Log in to answer this question.
Bad news: Google Code Search is going to be closed soon: http://googleblog.blogspot.com/2011/10/fall-sweep.html
It sounds like you might be re-inventing the wheel. I agree with Michael's answer, and the added benefit is that you will automatically be able to support any file type that CDK or OpenBabel can support. For example, if you just want to check that the input is indeed a molecule, you could make sure that openbabel could convert it