def import_profile(database, species, loci_list):
    """Import all possible allele profiles with corresponding st's
    for the species into a dict. The profiles are stored in a dict
    of dicts, to easily look up what st types are accosiated with
    a specific allele number of each loci.
    """
    # Open allele profile file from database
    profile_file = open("{0}/{1}/{1}.tsv".format(database, species), "r")
    profile_header = profile_file.readline().strip().split("\t")[1:len(loci_list)+1]

    # Create dict for looking up st-types with locus/allele combinations
    st_profiles = {}
    # For each locus initate make an inner dict to store allele and st's
    for locus in loci_list:
        st_profiles[locus] = {}

    # Fill inner dict with allele no as key and st-types seen with the allele as value
    for line in profile_file:
        profile = line.strip().split("\t")
        st_name = profile[0]
        allele_list = profile[1:len(loci_list)+1]

        # Go through all allele profiles. Save locus-allele combination with the st-type
        for i in range(len(allele_list)):
            allele = allele_list[i]
            locus = profile_header[i]
            if allele in st_profiles[locus]:
                st_profiles[locus][allele] += [st_name]
            else:
                st_profiles[locus][allele] = [st_name]
    profile_file.close()

    return st_profiles