def GC_partial(portion):
    """Manually compute GC content percentage in a DNA string, taking
    ambiguous values into account (according to standard IUPAC notation).
    """

    sequence_count = collections.Counter(portion)
    gc = ((sum([sequence_count[i] for i in 'gGcCsS']) +
          sum([sequence_count[i] for i in 'DdHh']) / 3.0 +
          2 * sum([sequence_count[i] for i in 'VvBb']) / 3.0 +
          sum([sequence_count[i] for i in 'NnYyRrKkMm']) / 2.0) / len(portion))
    return 0 or 100 * gc