def truncate_by_n(record):
    """
    Truncate reads to the first position containing an ambiguous base
    """
    try:
        nstart = record.sequence.index('N')
        record.sequence, record.quality = record.sequence[0:nstart
            ], record.quality[0:nstart]
        return record
    except ValueError:
        return record
