'Necessary to replace names of terms inside nexus representation
Also, it\'s here because Mailaud\'s doesnt deal with id_strings outside of quotes(" ")'

def _mapName(self, newickString, nameMap):

    newString = ''
    start = 0
    end = 0
    for i in range(len(newickString)):
        if ((newickString[i] == '(') or (newickString[i] == ',')):
            if re.match('[,(]', newickString[(i + 1):]):
                continue
            else:
                end = (i + 1)
                for j in range((i + 1), len(newickString)):
                    enclosingSymbol = newickString[j]
                    if ((enclosingSymbol == ')') or (enclosingSymbol == ':') or (enclosingSymbol == ',')):
                        termToReplace = newickString[end:j]
                        newString += (newickString[start:end] + nameMap[termToReplace])
                        start = j
                        break
    newString += newickString[start:]
    return newString
