import gzip


def open_file(file_path, mode = 'r'):
    """
    Open a file which can be gzipped.
    
    :param file_path: 
    :param mode: 
    :return: 
    """
    if file_path.split(".")[-1] =="gz":
        #print "opening gzipped file"
        INFILE = gzip.open(file_path, mode+'b')
    else:
        INFILE = open(file_path, mode)

    return INFILE