-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadd_by_epi_set.py
executable file
·77 lines (64 loc) · 2.21 KB
/
add_by_epi_set.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def add_by_file(file_name,hint_name):
q=open("recombinants.tsv",'r')
existing_lines=q.readlines()
q.close()
existing_names={}
for id in range(1,len(existing_lines)):
line=existing_lines[id]
linsp=line.split()
#print(linsp)
if len(linsp)>1:
nn=linsp[0].strip()
nnp=nn.split("EPI_ISL_")[1]
existing_names["EPI_ISL_"+nnp]=1
name=""
url=""
branch=""
issue=""
add_info=""
for item in linsp:
isb=True
if "EPI" in item:
isb=False
name=item
if '#' in item:
isb=False
issue=item
if 'usher' in item:
isb=False
add_info=item
if 'http' in item:
isb=False
url=item
if branch=="" and isb:
branch=item
existing_lines[id]=name+'\t'+issue+'\t'+branch+'\t'+add_info+'\t'+url
f_file=open("C:/users/xz/Downloads/"+file_name,'r')
flines=f_file.readlines()
for line in flines:
if len(line)<5:
continue
linsp=line.strip().split(',')
for item in linsp:
name=item.strip()
if len(name)>5:
if not(name in existing_names):
lineapp=name+'\t'
lineapp=lineapp+'\t'
lineapp=lineapp+'\t'+hint_name
lineapp=lineapp+'\t'
print(name,name in existing_names)
if not(name in existing_names):
existing_names[name]=1
existing_lines.append(lineapp)
f=open("recombinants.tsv",'w')
for line in existing_lines:
print(line.replace('\n',''),file=f)
f.close()
return 0
import argparse
parser = argparse.ArgumentParser(description='Demo of argparse')
parser.add_argument('--file', type=str)
parser.add_argument('--hint', type=str)
args = parser.parse_args()
w=add_by_file(args.file,args.hint)