当前位置: 首页>>代码示例>>Python>>正文


Python Match.match方法代码示例

本文整理汇总了Python中match.Match.match方法的典型用法代码示例。如果您正苦于以下问题:Python Match.match方法的具体用法?Python Match.match怎么用?Python Match.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在match.Match的用法示例。


在下文中一共展示了Match.match方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_match_full_sentences

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import match [as 别名]
def test_match_full_sentences():
    for (test_sentence, gold_result) in zip(test_sentences, gold_results_all_sentences):
        sys.stderr.write("gold: " + str(gold_result) + "\n")
        sys.stderr.write("test: " + str(test_sentence) + "\n")
        if sys.version_info[0] >= 3:
            eq_(gold_result, Match.match(test_text, test_sentence))
        else:
            eq_(gold_result, Match.match(test_text.decode("utf8"), test_sentence))
        sys.stderr.write("\n")
开发者ID:EducationalTestingService,项目名称:match,代码行数:11,代码来源:test_match.py

示例2: get_true_true

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import match [as 别名]
def get_true_true(result, index, param, mass):
	true_true = []
	for i in range(len(result)):
		title = result[i][0]
		spec = index.spec_dict[title]
		ch = spec.ch

		candidate = []
		sum_int = []
		for j in range(len(result[i][1])):
			pep1 = index.unique_pep[0][result[i][1][j][0][0]]
			pep2 = index.unique_pep[0][result[i][1][j][0][1]]
			sl = [set(), set()]
			pos = result[i][1][j][1]

			for pro in pep1.pro_id:
				cols = pro.split('|R')
				if len(cols) > 1 and len(cols[1]) > 0:
					sl[0].add(cols[1][0])

			for pro in pep2.pro_id:
				cols = pro.split('|R')
				if len(cols) > 1 and len(cols[1]) > 0:
					sl[1].add(cols[1][0])

			feature = list(result[i][1][j][2][0])
			feature.extend(result[i][1][j][2][1])
			if feature[0] / float(feature[7]) >= 0.20 and feature[1] / float(feature[7]) >= 0.20 and feature[8] / float(feature[15]) >= 0.20 and feature[9] / float(feature[15]) >= 0.20 and feature[2] >= 0.1 and feature[10] >= 0.1 and (len(sl[0]) == 0 or len(sl[1]) == 0 or len(sl[0].intersection(sl[1]))) > 0:
				xl = XLink(pep1, pep2, pos, ch, mass, param)
				match = Match(spec, xl, mass, param)
				match.match(mass)

				candidate.append(match)
				sum_int.append(feature[2] + feature[10])

		if len(candidate) == 0:
			continue
		combo = zip(candidate, sum_int)
		candidate = list(zip(*sorted(combo, key = lambda x : x[1], reverse = True))[0])
		sum_int = list(zip(*sorted(combo, key = lambda x : x[1], reverse = True))[1])
		true_true.append(candidate[0])

	for i in range(len(true_true)):
		pep1 = true_true[i].xlink.pep[0]
		pep2 = true_true[i].xlink.pep[1]
		s = pep1.seq + '\t' + pep2.seq + '\t' + ','.join(pep1.pro_id) + '\t' + ','.join(pep2.pro_id)
		print s

	if len(true_true) < 150:
		print '\nWARNING: The number of True-True PSMs(' + str(len(true_true)) + ') is too small and maybe insufficient for training an reliable model!\n'
	return true_true
开发者ID:COL-IU,项目名称:XLSearch,代码行数:53,代码来源:utility.py

示例3: get_matches_per_spec

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import match [as 别名]
def get_matches_per_spec(mass, param, index, title):
	spec_dict = index.spec_dict
	unique_pep = index.unique_pep[0]
#	search_index = index.search_index
	x_residue = param['x_residue']

	index_list = index.get_candidates(title)
	spec = spec_dict[title]

	matches = []
	for i in range(len(index_list)):
		index1 = index_list[i][0]
		index2 = index_list[i][1]
		
		pep1 = unique_pep[index1]
		pep2 = unique_pep[index2]

		pep_sorted = sorted([pep1, pep2], key = lambda x : x.seq)
		pep1 = pep_sorted[0]
		pep2 = pep_sorted[1]

		ch = spec_dict[title].ch

		mz = spec_dict[title].mz
		it = spec_dict[title].it

		k_pos1 = []
		k_pos2 = []
		if param['ntermxlink'] == True:
			if pep1.is_nterm == True:
				k_pos1.append(0)
			if pep2.is_nterm == True:
				k_pos2.append(0)

		pep_seq1 = pep1.seq
		k_pos1.extend(list(zip(*filter(lambda x : x[1] == x_residue, enumerate(pep_seq1[:-1])))[0]))
		pep_seq2 = pep2.seq
		k_pos2.extend(list(zip(*filter(lambda x : x[1] == x_residue, enumerate(pep_seq2[:-1])))[0]))

		for p1 in k_pos1:
			for p2 in k_pos2:
				pos = [p1, p2]
				xl = XLink(pep1, pep2, pos, ch, mass, param)
			
				match = Match(spec, xl, mass, param)
				match.match(mass)
				matches.append(match.get_match_info(index))

	return matches
开发者ID:COL-IU,项目名称:XLSearch,代码行数:51,代码来源:utility.py

示例4: get_false_false

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import match [as 别名]
def get_false_false(true_true, param, mass):
	linker_mass = param['linker_mass']

	true_true_seq = set()
	true_true_mass = []
	for match in true_true:
		true_true_seq.add(match.xlink.pep[0].seq)
		true_true_seq.add(match.xlink.pep[1].seq)
		true_true_mass.append(match.xlink.mol_weight - linker_mass)

	min_mass = int(min(true_true_mass) - 0.2)
	max_mass = int(max(true_true_mass) + 0.2)

	if 'uniprot_database' not in param:
		print 'No uniprot database specified!'
		print 'execution will terminate!'
		sys.exit(1)

	fasta = FastaReader(param['uniprot_database']).read_fasta()
	pattern_string = param['pattern_string']
	peps = dict()

	for header, seq in fasta:
		if 'YEAST' in header:
			pep = get_pep_from_pro(header, seq, pattern_string, mass, param)
			for p in pep:
				if p.seq not in peps and p.seq not in true_true_seq:
					peps[p.seq] = p
	peps = peps.values()

	int_dict = dict()
	for pep in peps:
		num = int(pep.prec_mass)
		if num > max_mass:
			continue

		if num not in int_dict:
			int_dict[num] = [pep]
		else:
			int_dict[num].append(pep)

	false_false = []
	for k in range(len(true_true)):
		match = true_true[k]
		print k
		sys.stdout.flush()

		false_false.append([])
		prec_mass = match.xlink.mol_weight - linker_mass
		ch = match.spec.ch
		ms2tol = match.xlink.mol_weight * 3 * (10 ** (-6))

		mass_list = range(500, max_mass - 500)
		shuffle(mass_list)
		mass_list = mass_list[:25]

		for m in mass_list:
			if m not in int_dict:
				continue

			shuffle(int_dict[m])
			int_dict[m] = int_dict[m][:50]

			for i in range(len(int_dict[m])):
				num = int(prec_mass - int_dict[m][i].prec_mass)
				if num not in int_dict:
					continue
				shuffle(int_dict[num])
				int_dict[num] = int_dict[num][:50]

				for j in range(len(int_dict[num])):
					pepseq1 = int_dict[m][i].seq
					pepseq2 = int_dict[num][j].seq
					k_pos1 = list(zip(*filter(lambda x : x[1] == 'K', enumerate(pepseq1[:-1])))[0])
					k_pos2 = list(zip(*filter(lambda x : x[1] == 'K', enumerate(pepseq2[:-1])))[0])
					pos = [k_pos1[len(k_pos1) / 2], k_pos2[len(k_pos2) / 2]]
					xl = XLink(int_dict[m][i], int_dict[num][j], pos, ch, mass, param)
					if abs(match.xlink.mol_weight - xl.mol_weight) <= ms2tol:
						ff = Match(match.spec, xl, mass, param)
						ff.match(mass)

						feature = ff.feature
						if (feature[0][0] + feature[0][1]) / float(feature[0][7]) >= 0.15 and (feature[1][0] + feature[1][1]) / float(feature[1][7]) >= 0.15:
							false_false[-1].append(ff)
	l = []
	for i in range(len(false_false)):
		l.extend(false_false[i])
	false_false = l
	return false_false
开发者ID:COL-IU,项目名称:XLSearch,代码行数:91,代码来源:utility.py

示例5: get_true_false

# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import match [as 别名]
def get_true_false(true_true, param, mass):
	true_true_seq = set()
	true_true_mass = []
	linker_mass = param['linker_mass']

	if 'uniprot_database' not in param:
		print 'No uniprot database specified!'
		print 'execution will terminate!'
		sys.exit(1)

	fasta = FastaReader(param['uniprot_database']).read_fasta()
	pattern_string = param['pattern_string']
	peps = dict()

	for match in true_true:
		true_true_seq.add(match.xlink.pep[0].seq)
		true_true_seq.add(match.xlink.pep[1].seq)
		true_true_mass.append(match.xlink.mol_weight - linker_mass)
	true_true_mass = max(true_true_mass)


	for header, seq in fasta:
		if 'MOUSE' in header:
			pep = get_pep_from_pro(header, seq, pattern_string, mass, param)

			for p in pep:
				if p.seq not in peps and p.seq not in true_true_seq and p.prec_mass < true_true_mass:
					peps[p.seq] = p


	peps = peps.values()
	alpha = []
	beta = []

	for i in range(len(true_true)):
		print i
		sys.stdout.flush()
		match = true_true[i]
		ch = match.spec.ch
		ms2tol = match.xlink.mol_weight * 5 * (10 ** (-6))
		alpha.append([])
		beta.append([])

		pep = match.xlink.pep

		for j in range(len(peps)):
			if abs(pep[0].prec_mass + peps[j].prec_mass + linker_mass - match.xlink.mol_weight) <= ms2tol:
				pepseq1 = pep[0].seq
				pepseq2 = peps[j].seq
				k_pos1 = list(zip(*filter(lambda x : x[1] == 'K', enumerate(pepseq1[:-1])))[0])
				k_pos2 = list(zip(*filter(lambda x : x[1] == 'K', enumerate(pepseq2[:-1])))[0])
				pos = [k_pos1[len(k_pos1) / 2], k_pos2[len(k_pos2) / 2]]
				xl = XLink(pep[0], peps[j], pos, ch, mass, param)

				tf = Match(match.spec, xl, mass, param)
				tf.match(mass)
				feature = tf.feature
				if (feature[1][0] + feature[1][1]) / float(feature[1][7]) >= 0.2:
					alpha[-1].append(tf)

		for j in range(len(peps)):
			if abs(pep[1].prec_mass + peps[j].prec_mass + linker_mass - match.xlink.mol_weight) <= ms2tol:
				pepseq1 = pep[1].seq
				pepseq2 = peps[j].seq
				k_pos1 = list(zip(*filter(lambda x : x[1] == 'K', enumerate(pepseq1[:-1])))[0])
				k_pos2 = list(zip(*filter(lambda x : x[1] == 'K', enumerate(pepseq2[:-1])))[0])
				pos = [k_pos1[len(k_pos1) / 2], k_pos2[len(k_pos2) / 2]]
				xl = XLink(pep[1], peps[j], pos, ch, mass, param)

				tf = Match(match.spec, xl, mass, param)
				tf.match(mass)
				feature = tf.feature
				if (feature[1][0] + feature[1][1]) / float(feature[1][7]) >= 0.2:
					beta[-1].append(tf)

	true_false = []
	for i in range(len(alpha)):
		true_false.extend(alpha[i])
	for i in range(len(beta)):
		true_false.extend(beta[i])

	return true_false
开发者ID:COL-IU,项目名称:XLSearch,代码行数:84,代码来源:utility.py


注:本文中的match.Match.match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。