示例#1
0
def P_number_true_obs_slow(args):
	param = Param(args.mean, args.stddev, args.cov, args.readlen, args.soft, args.soft) 
	E_true_links = 0
	# the diagonal of the square (i_1 = i_2) i.e. do not multiply by two
	p_at_least_one_bp_at_given_position = 1- P_breakpoints_in_interval(1, args.bp_ratio, 0)
	for i in range((args.readlen - args.soft),args.mean + 4*args.stddev +1):
		print i
		p = P_breakpoints_in_interval(i, args.bp_ratio, 0)
		if i != args.mean + 4*args.stddev:
			E_true_links += p**2 * p_at_least_one_bp_at_given_position**2 * mean_span_coverage(i, i, args.insertion_size, param)
		else:
			E_true_links += p**2 * mean_span_coverage(i, i, args.insertion_size, param)


	for i_1 in range((args.readlen - args.soft),args.mean + 4*args.stddev):
		for i_2 in range(i_1+1, args.mean + 4*args.stddev + 1):
			#print i_1,i_2
			p_1 = P_breakpoints_in_interval(i_1, args.bp_ratio, 0)
			p_2 = P_breakpoints_in_interval(i_2, args.bp_ratio, 0)
			# symmetrical probabilities
			if i_2 != args.mean + 4*args.stddev:

				E_true_links += 2 * p_1 * p_2 * p_at_least_one_bp_at_given_position**2 * mean_span_coverage(i_1, i_2, args.insertion_size, param)

			else:
				E_true_links += 2 * p_1 * p_2 * p_at_least_one_bp_at_given_position * mean_span_coverage(i_1, i_2, args.insertion_size, param)

	return E_true_links
示例#2
0
def P_number_true_obs_slow(args):
    param = Param(args.mean, args.stddev, args.cov, args.readlen, args.soft,
                  args.soft)
    E_true_links = 0
    # the diagonal of the square (i_1 = i_2) i.e. do not multiply by two
    p_at_least_one_bp_at_given_position = 1 - P_breakpoints_in_interval(
        1, args.bp_ratio, 0)
    for i in range((args.readlen - args.soft),
                   args.mean + 4 * args.stddev + 1):
        print i
        p = P_breakpoints_in_interval(i, args.bp_ratio, 0)
        if i != args.mean + 4 * args.stddev:
            E_true_links += p**2 * p_at_least_one_bp_at_given_position**2 * mean_span_coverage(
                i, i, args.insertion_size, param)
        else:
            E_true_links += p**2 * mean_span_coverage(
                i, i, args.insertion_size, param)

    for i_1 in range((args.readlen - args.soft), args.mean + 4 * args.stddev):
        for i_2 in range(i_1 + 1, args.mean + 4 * args.stddev + 1):
            #print i_1,i_2
            p_1 = P_breakpoints_in_interval(i_1, args.bp_ratio, 0)
            p_2 = P_breakpoints_in_interval(i_2, args.bp_ratio, 0)
            # symmetrical probabilities
            if i_2 != args.mean + 4 * args.stddev:

                E_true_links += 2 * p_1 * p_2 * p_at_least_one_bp_at_given_position**2 * mean_span_coverage(
                    i_1, i_2, args.insertion_size, param)

            else:
                E_true_links += 2 * p_1 * p_2 * p_at_least_one_bp_at_given_position * mean_span_coverage(
                    i_1, i_2, args.insertion_size, param)

    return E_true_links
示例#3
0
    def coverage_probability(self,nr_obs, a, mean_lib, stddev_lib,z, coverage_mean, read_len, s_inner,s_outer, b=None, coverage_model = False):
        ''' Distribution P(o|c,z) for prior probability over coverage.
            This probability distribution is implemented as an poisson 
            distribution.

            Attributes:

            c       -- coverage
            mean    -- mean value of poisson distribution.

            Returns probability P(c)

        '''
        if not b: 
            # only one reference sequence.
            # We split the reference sequence into two equal 
            # length sequences to fit the model. 
            a = a/2
            b = a/2

        param = Param(mean_lib, stddev_lib, coverage_mean, read_len, s_inner,s_outer)
        lambda_ = mean_span_coverage(a, b, z, param)

        if coverage_model == 'Poisson':
            return poisson.pmf(nr_obs, lambda_, loc=0)

        elif coverage_model == 'NegBin':
            p = 0.01
            n = (p*lambda_)/(1-p)
            return nbinom.pmf(nr_obs, n, p, loc=0) 
        else:
            # This is equivalent to uniform coverage
            return 1 #uniform.pdf(nr_obs, loc=lambda_- 0.3*lambda_, scale=lambda_ + 0.3*lambda_ )
示例#4
0
    def coverage_probability(self,
                             nr_obs,
                             a,
                             mean_lib,
                             stddev_lib,
                             z,
                             coverage_mean,
                             read_len,
                             s_inner,
                             s_outer,
                             b=None,
                             coverage_model=False):
        ''' Distribution P(o|c,z) for prior probability over coverage.
            This probability distribution is implemented as an poisson 
            distribution.

            Attributes:

            c       -- coverage
            mean    -- mean value of poisson distribution.

            Returns probability P(c)

        '''
        if not b:
            # only one reference sequence.
            # We split the reference sequence into two equal
            # length sequences to fit the model.
            a = a / 2
            b = a / 2

        param = Param(mean_lib, stddev_lib, coverage_mean, read_len, s_inner,
                      s_outer)
        lambda_ = mean_span_coverage(a, b, z, param)

        if coverage_model == 'Poisson':
            return poisson.pmf(nr_obs, lambda_, loc=0)

        elif coverage_model == 'NegBin':
            p = 0.01
            n = (p * lambda_) / (1 - p)
            return nbinom.pmf(nr_obs, n, p, loc=0)
        else:
            # This is equivalent to uniform coverage
            return 1  #uniform.pdf(nr_obs, loc=lambda_- 0.3*lambda_, scale=lambda_ + 0.3*lambda_ )