All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.charite.compbio.jannovar.pedigree.Sex Maven / Gradle / Ivy

There is a newer version: 0.41
Show newest version
package de.charite.compbio.jannovar.pedigree;

/**
 * Representation of an individual's sex.
 *
 * @author Peter N Robinson
 * @author Manuel Holtgrewe
 */
public enum Sex {
	/** sex is unknown */
	UNKNOWN,
	/** individual is male */
	MALE,
	/** individual is female */
	FEMALE;

	/**
	 * @return int representation for the pedigree file.
	 */
	public int toInt() {
		if (this == UNKNOWN)
			return 0;
		else if (this == MALE)
			return 1;
		else
			// if (this == FEMALE)
			return 2;
	}

	/**
	 * Parse {@link String} into a Sex value.
	 *
	 * @param s
	 *            String to parse
	 * @return resulting Sex object
	 * @throws PedParseException
	 *             if s was not equal to "0", "1", or "2".
	 */
	public static Sex toSex(String s) throws PedParseException {
		if (s.equals("0"))
			return UNKNOWN;
		else if (s.equals("1"))
			return MALE;
		else if (s.equals("2"))
			return FEMALE;
		else
			throw new PedParseException("Invalid PED sex value: " + s);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy