<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_deleterious_p_value(mut_info, unmapped_mut_info, sc, gs, bed, num_permutations, stop_thresh, del_threshold, pseudo_count, seed=None):
 """Calculates the p-value for the number of inactivating SNV mutations. Calculates p-value based on how many simulations exceed the observed value. Parameters mut_info : dict contains codon and amino acid residue information for mutations mappable to provided reference tx. unmapped_mut_info : dict contains codon/amino acid residue info for mutations that are NOT mappable to provided reference tx. fs_ct : int number of frameshifts for gene prob_inactive : float proportion of inactivating mutations out of total over all genes sc : SequenceContext object contains the nucleotide contexts for a gene such that new random positions can be obtained while respecting nucleotide context. gs : GeneSequence contains gene sequence bed : BedLine just used to return gene name num_permutations : int number of permutations to perform to estimate p-value. more permutations means more precision on the p-value. seed : int (Default: None) seed number to random number generator (None to be randomly set) """

    #prng = np.random.RandomState(seed)
    if len(mut_info) > 0:
        mut_info['Coding Position'] = mut_info['Coding Position'].astype(int)
        mut_info['Context'] = mut_info['Coding Position'].apply(lambda x: sc.pos2context[x])

        # group mutations by context
        cols = ['Context', 'Tumor_Allele']
        unmapped_mut_df = pd.DataFrame(unmapped_mut_info)
        tmp_df = pd.concat([mut_info[cols], unmapped_mut_df[cols]])
        context_cts = tmp_df['Context'].value_counts()
        context_to_mutations = dict((name, group['Tumor_Allele'])
                                    for name, group in tmp_df.groupby('Context'))

        # get deleterious info for actual mutations
        aa_mut_info = mc.get_aa_mut_info(mut_info['Coding Position'],
                                         mut_info['Tumor_Allele'].tolist(),
                                         gs)
        ref_aa = aa_mut_info['Reference AA'] + unmapped_mut_info['Reference AA']
        somatic_aa = aa_mut_info['Somatic AA'] + unmapped_mut_info['Somatic AA']
        codon_pos = aa_mut_info['Codon Pos'] + unmapped_mut_info['Codon Pos']
        num_del = cutils.calc_deleterious_info(ref_aa, somatic_aa, codon_pos)
        #num_del = fs_ct + num_snv_del

        # skip permutation test if number of deleterious mutations is not at
        # least meet some user-specified threshold
        if num_del >= del_threshold:
            # perform permutations
            del_p_value = pm.deleterious_permutation(num_del,
                                                     context_cts,
                                                     context_to_mutations,
                                                     sc,  # sequence context obj
                                                     gs,  # gene sequence obj
                                                     num_permutations,
                                                     stop_thresh,
                                                     pseudo_count)
        else:
            del_p_value = None
    else:
        num_del = 0
        del_p_value = None

    result = [bed.gene_name, num_del, del_p_value]
    return result