The embryological origin of the mouth and anus is an important characteristic, and forms the morphological basis for separating bilaterian animals into two natural groupings: the protostomes and deuterostomes. In animals at least as complex as an earthworm, a dent forms in one side of the early, spheroidalembryo. This dent, the blastopore, deepens to become the archenteron, the first phase in the growth of the gut. In deuterostomes, the original dent becomes the anus, while the gut eventually tunnels through the embryo until it reaches the other side, forming an opening that becomes the mouth. It was originally thought that the blastopore of the protostomes formed the mouth, and the anus was formed second when the gut tunneled through the embryo. More recent research has shown that our understanding of protostome mouth formation is somewhat less secure than we had thought. Acoelomorpha, which form a sister group to the rest of the bilaterian animals, have a single mouth that leads into a blind gut. The genes employed in the embryonic construction of the flatworm mouth are the same as those expressed for the protostome and deuterostome mouth, which suggests that the structures are equivalent homologous, and that the older ideas about protostome mouth formation were correct. An alternative way to develop two openings from the blastopore during gastrulation, called amphistomy, appears to exist in some animals, such as nematodes. In humans the perforation of the anus and mouth happen at 8 weeks and 4 weeks respectively. When both the anus and mouth are perforated, the organism becomes topologically a torus.
Evolutionary origin
Bilaterians likely evolved from an ancestor which was radially symmetrical. There have been suggestions that the blastopore started out as the digestive surface on a radial organism which became elongated before its sides closed over to leave a mouth at the front and an anus at the rear. This matches with the "flaps-folding-over" model of gut formation, but an alternative view is that the original blastopore migrated forwards to one end of the ancestral organism before deepening to become a blind gut. This is consistent with living Xenacoelomorpha, which are the sister taxon to protostomes and deuterostomes. The story is a little more complex, because the blastopore itself does not directly give rise to the mouth of these worms. This suggests that the last common ancestor of bilaterians had a similar gut configuration, and that the anus evolved after the mouth. Exactly how a through gut formed from this blind gut is somewhat harder to tell. The genetic mechanisms responsible for anus formation are quite variable, which might suggest that the anus evolved several times in different groups. Scientists are currently looking into this matter to generate a more complete picture. In humans, the development proceeds differently. The buccopharyngeal membrane is created in the foregut and it is perforated during the 4th week of human development, creating the primitive mouth, whereas the cloacal membrane is created in the hindgut and it is perforated during the 8th week of human development, creating the primitive anus after the mouth opening has already been created.