Once you have instantiated a Txny object, that object has a .hier attribute that is an instance of class Hier, which represents the set of taxonomic
ranks or levels in use for this arrangement.
Attributes of the Hier object
include:
.txKeyLen
Length of the taxonomic key number string used in this arrangement, as an integer. Read-only.
Methods on a Hier object include:
.canParentHaveChild(p,
c)
This predicate tests whether a rank
can have an immediate child
p.
It returns c1 if that is
allowed in this arrangement, 0 if not.
For example, if the hierarchy contains class, order, family, optional subfamily, genus, and species, then a family can have a genus child (since the subfamily rank is optional), but an order cannot have any child other than a family.
.formRank()
If this hierarchy includes a form rank, this
method returns it as a Rank object;
otherwise it returns None.
.genusRank()
If this hierarchy includes a genus rank, this
method returns it as a Rank object. If
the genus rank is missing, returns None.
.lookupRankCode(c)
Used to find the rank corresponding to a rank code
.
Returns that rank as a cRank
object; see Section 9.3, “Class Rank: One taxonomic rank”.
.speciesRank()
Returns this hierarchy's species rank
as a Rank object. If
for some bizarre reason there is no species rank,
it returns
otherwise it returns None.
.subgenusRank()
If this hierarchy includes a subgenus rank, this
method returns it as a Rank object;
otherwise it returns None.
.__getitem__(self, key )
Called when a Hier object
is indexed using the construct “H”. If the
H[i]0 <= , the method returns the
i
< len(H)th
rank, counting the root rank as 0, the next deeper
rank as 1, and so on.
n
For example, if
h
is a Hier object whose
first three ranks are class, order, and family,
h[2] returns the family rank.
.__iter__(self)
This is the iterator function for a Hier object. It iterates over the
contained ranks from the root rank to the deepest.
This method is called, for example, when you use a
Hier object in a
for statement.
For example, if h is a
Hier object, this loop
will print the names of all the ranks:
for rank in h:
print rank.name
.__len__(self)
This method is called when the “len()” function is invoked on
a Hier object. It returns
the number of ranks in that object, as an integer.