def depthfilereader(depth_file, plasmid_length, cutoff):
    """
    Function that parse samtools depth file and creates 3 dictionaries that
    will be useful to make the outputs of this script, both the tabular file
    and the json file that may be imported by pATLAS

    Parameters
    ----------
    depth_file: str
        the path to depth file for each sample
    plasmid_length: dict
        a dictionary that stores length of all plasmids in fasta given as input
    cutoff: str
        the cutoff used to trim the unwanted matches for the minimum coverage
        results from mapping. This is then converted into a float within this
        function in order to compare with the value returned from the perc_value_per_ref.

    Returns
    -------
    percentage_basescovered: dict
            stores the percentage of the total sequence of a
            reference/accession (plasmid) in a dictionary
    """
    depth_dic_coverage = {}
    for line in depth_file:
        tab_split = line.split()
        reference = '_'.join(tab_split[0].strip().split('_')[0:3])
        position = tab_split[1]
        numreadsalign = float(tab_split[2].rstrip())
        if reference not in depth_dic_coverage:
            depth_dic_coverage[reference] = {}
        depth_dic_coverage[reference][position] = numreadsalign
    percentage_basescovered = {}
    for ref in depth_dic_coverage:
        perc_value_per_ref = float(len(depth_dic_coverage[ref])) / float(
            plasmid_length[ref])
        if perc_value_per_ref >= float(cutoff):
            percentage_basescovered[ref] = perc_value_per_ref
    return percentage_basescovered
