首页 > 代码库 > 根据结核菌12SNP的阈值判断传播链
根据结核菌12SNP的阈值判断传播链
import sys
import re
f1=open(sys.argv[1]).readlines() #strain distance
f2=open(sys.argv[2]).readlines() #distance <= 12 strain list
f3=open("rough_transmission_chain","a")
sum_chain_list=[i.rstrip().split()[0] for i in f1 if int(i.rstrip().split()[1])<=12]
def find_transmission_strain(strain):
cycle_strain = []
match_strain = []
True_strain = [i for i in sum_chain_list if i.startswith(strain + "VS") or i.endswith("VS" + strain)]
for item in True_strain:
temp = re.sub("VS", "", item)
sum_chain_list.remove(item)
if temp[:len(strain)] == strain:
match_strain.append(temp[len(strain):])
cycle_strain.append(temp[len(strain):])
else:
match_strain.append(temp[0:len(temp) - len(strain)])
cycle_strain.append(temp[0:len(temp) - len(strain)])
if len(cycle_strain) > 0:
for a in range(len(cycle_strain)):
for b in range(len(cycle_strain)):
try:
sum_chain_list.remove(cycle_strain[a] + "VS" + cycle_strain[b])
except ValueError as e:
pass
for i in cycle_strain:
match_strain.extend(find_transmission_strain(i))
return set(match_strain)
# A will be included in a transmission chain B if distance bewteen A and (any strain in B) is <=12
temp = []
for i in f2:
i = i.rstrip()
if i not in temp:
a = list(find_transmission_strain(i))
a.append(i)
temp.extend(a)
for strain in a:
f3.write(strain + "\t")
f3.write("\n")
else:
pass
根据结核菌12SNP的阈值判断传播链
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。