def get_query_taxon_from_filename(query_filename):
    """Takes a query file name and extracts the database name (abbreviation of
    species name usually) or taxon name/indicator from the file name.

    Assumes that the file is named as:
        query_title + '_' + dbname/taxon + '_' + accession (if appl.) + extension

        where neither query_title nor dbname have underscores in them.
    """
    try:
        return query_filename.split('_')[1]
    except:
        return query_filename.rsplit('.', 1)[0]