# - - - H i e r . c a n P a r e n t H a v e C h i l d def canParentHaveChild ( self, p, c ): '''Can a taxon of rank c be a child of a taxon of rank p? '''
This function is used when scanning the standard forms file, to insure that taxa are properly placed. For example, an order can't have a species child; there must be a family and a genus between them.
Here are the cases.
If the parent is not at a higher level than the
child, the result is
If there are no ranks between the parent and child
levels, the result is
If there are ranks between the parent and child, they must all be optional. For example, if the subfamily rank is optional, a family taxon can have a genus child.
#-- 1 -- # [ if the depth of p is less than the depth of c -> # I # else -> return False ] if p.depth >= c.depth: return False #-- 2 -- # [ if there is at least one reqired rank between # the depth of p and the depth of c -> # return False # else -> I ] for depth in range ( p.depth+1, c.depth ): if self[depth].required: return False #-- 3 -- return True