How to get the total number of numbered positions in a molecule/compound

I'm working on a metabolite database where "labeled" compounds can contain isotopically labeled atoms in specific positions. When a new labeled compound is entered into the database, we'd like to be able to perform a simple validation on the submitted labeled isotope positions. E.g. there's a Carbon-13 at position 2 in a glucose compound.


The first suggestion by another developer was to check that the positions submitted are less than or equal to the number of atoms of the given type in the compound based on the formula. It's been a long time since my BS in Biochemistry, but I recalled that positions are not (necessarily?) relative to the given atom. The positions (as I recall) are based on multiple types of atoms and are numbered in order based on its weight and the weight of atoms it's bonded to, though I don't remeber the specific rules.


I've been googling for awhile now and flipping through my old chemistry books, but I have yet to turn up those rules that govern:


1. What atoms receive a position (e.g. carbon and nitrogen atoms are numbered 1-9 in [purine](https://en.wikipedia.org/wiki/Purine) but oxygen doesn't get a position in [glucose](https://chemistry.stackexchange.com/questions/10037/what-is-the-convention-of-numbering-carbon-atoms-in-organic-molecules))
2. What atom gets position 1, or any other position for that matter


For now, all I want to do is determine the total number of numbered positions so that if an isotope position is submitted outside of the range, we can throw an error and say that position is invalid. Aside from having more C13 positions than the number of carbons in the compound, that's all our requirements currently call for. (While it would be nice to know, we don't have a requirement for ensuring the given position actually is supposed to be a carbon.)


And while I'm at it, are there different atom position/numbering schemes in use currently?


