How to identify compounds of only one element

User 0261d34ad7

05-03-2012 09:45:02

Hi,


 


I'm trying to write a chemical term expression to identify all chemical compounds consisting of just one element type, where there are two atoms exactly. The goal is to identify "simple" compounds to filter out noise. 


I've tried this: (atomCount() == 2) && (atno(0) == atno(1))


But I get an "array index out of range error" for single atom compounds. 


Any advice on how I should proceed? I thought about using the elemental analysis function, but there's no clear description of what it returns. My guess is a textual description similar to the "ElementalAnalyzer" class, which wouldn't help me here. Also I thought about using "filter" but I'm not sure exactly how it could help.


Any advice appreciated.


Jim

User 0261d34ad7

05-03-2012 11:31:01

Having done a bit of reading, I've come up with:


others = filter('atno() != atno(0)'); count(others) == 0


Any thoughts?

ChemAxon e08c317633

05-03-2012 11:54:19

Try this:


(atomCount() < 2) or ((atomCount() == 2) and (atno(0) == atno(1)))

Chemical Terms expressions are evaluated using lazy evaluation strategy, so if the molecule contains less than 2 atoms then the second half of the or-expression will not be evaluated.


Zsolt

User 0261d34ad7

05-03-2012 13:33:34

Great, that's done it.


J