R/purdyToPedigree.R

Defines functions purdyToPedigree

purdyToPedigree <- function(lineNames, purdy, selfing, warnImproperFunnels)
{
	if(!is.character(lineNames) || !is.character(purdy))
	{
		stop("Inputs lineNames and purdy must be character vectors")
	}
	if(length(lineNames) != length(purdy))
	{
		stop("Inputs lineNames and purdy must have the same lengths")
	}
	parsed <- .Call("parsePurdy", lineNames, purdy, PACKAGE="mpMap2")
	lineNames <- parsed[,1]
	mother <- sapply(parsed[,2], function(x)
	{
		if(x == "") return(0)
		return(match(x, lineNames))
	})
	father <- sapply(parsed[,3], function(x)
	{
		if(x == "") return(0)
		return(match(x, lineNames))
	})
	names(father) <- names(mother) <- NULL
	pedigree <- pedigree(lineNames = lineNames, mother = mother, father = father, selfing = selfing, warnImproperFunnels = warnImproperFunnels)
	return(pedigree)
}
rohan-shah/mpMap2 documentation built on July 21, 2020, 8:58 p.m.