import re


def shineDelgarno(seq, n = 20):
    """
    Determine whether there is a Shine-Delgarno sequence within first 20bp
    
    :params seq: input nucleotide sequence
    :params n: first n bases to query (default: 20)
    """
    
    # check seq is long enough
    if (len(seq) < n):
        raise Exception("Sequence is shorter than 20bp. Skipped.")
    
    # grab first n bases of sequence
    subSeq = seq[:n]
    
    # search for S-D sequence
    if (re.search('AGGAGG',subSeq)):
        return(True)
    else:
        return(False)