def findpeptide(pep, seq, returnEnd = False):
    """Find pep in seq ignoring gaps but returning a start position that counts gaps
    pep must match seq exactly (otherwise you should be using pairwise alignment)

    Parameters
    ----------
    pep : str
        Peptide to be found in seq.
    seq : str
        Sequence to be searched.
    returnEnd : bool
        Flag to return the end position such that:
        seq[startPos:endPos] = pep

    Returns
    -------
    startPos : int
        Start position (zero-indexed) of pep in seq or -1 if not found"""

    ng = seq.replace('-', '')
    ngInd = ng.find(pep)
    ngCount = 0
    pos = 0
    """Count the number of gaps prior to the non-gapped position. Add them to it to get the gapped position"""
    while ngCount < ngInd or seq[pos] == '-':
        if not seq[pos] == '-':
            ngCount += 1
        pos += 1
    startPos = ngInd + (pos - ngCount)

    if returnEnd:
        if startPos == -1:
            endPos = -1
        else:
            count = 0
            endPos = startPos
            while count < len(pep):
                if not seq[endPos] == '-':
                    count += 1
                endPos += 1
        return startPos, endPos
    else:
        return startPos