Ejemplo n.º 1
0
	def numCopies(self, allele):
		"""Return the number of copies of the allele."""
		if type(allele) == str:
			allele = Allele.get(allele.upper())

		if type(allele) != Allele:
			raise Exception, "Must supply Allele or allele abbreviation."

		chromo = allele.onChromo
		cnt = 0

		# Autosomal
		if chromo in [2, 3, 4]:
			if allele in self.chromos[0][chromo-1]:
				cnt += 1
			if allele in self.chromos[1][chromo-1]:
				cnt += 1

			return cnt

		# Sex-linked
		if allele in self.chromos[0][0]:
			cnt += 1

		if not self.isFemale():
			return cnt

		if allele in self.chromos[0][1]:
			cnt += 1

		return cnt
Ejemplo n.º 2
0
	def isDead(self):
		"""The individual is dead if it has any two lethal allele copies."""

		lethals = Allele.getLethals() 

		for al in lethals:
			num = self.numCopies(al)
			if num > 1:
				return True

			# Hemizygous males
			if type(al.onChromo) == str and num > 0 and not self.isFemale(): 
				return True

		return False
Ejemplo n.º 3
0
	def setAs(self, allele):
		"""Set HOMOZYGOUS for the allele, unless lethal or sex-linked.
		Supply the allele abbreviation for lookup.
		Returns False if the allele couldn't be set (x-linked lethal for males.)
		"""
		if type(allele) == str:
			allele = Allele.get(allele.upper())

		if type(allele) != Allele:
			raise Exception, "Must supply allele or allele abbreviation."

		if self.numCopies(allele) > 0:
			raise Exception, "Cannot set allele if already present."

		chromo = allele.onChromo
		lethal = allele.isLethal()		

		if chromo not in [2, 3, 4, 'x', 'X']:
			raise Exception, \
				"Allele supplied is not on a valid chromosome."

		# Autosomal genes
		if chromo in [2, 3, 4]:
			self.chromos[0][chromo-1].append(allele)
			if not lethal:
				self.chromos[1][chromo-1].append(allele)

			return

		# X-linked genes
		if not self.sex:
			self.__cacheSex()

		# Can't manually create X-linked lethal males!
		if self.sex == 'm' and lethal:
			return

		self.chromos[0][0].append(allele)

		if self.sex == 'f' and not lethal:
			self.chromos[1][0].append(allele)

		return