-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_info-simple
30 lines (29 loc) · 1.09 KB
/
get_info-simple
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
#Given a tsv file with samples as rows and two columns describing the sample name (i.e. ID type 1 and ID type 2)
# and a list of names in format of ID type 2,
# print the corresponding ID type 1 value.
#Be sure that for the reference table, the first column is the same ID type as the input list
#(i.e. ref column 1: external strain names, ref column 2: lims IDs, input list: external strain names)
reference=input("What is the reference table?")
ref=open(reference, "r")
input_entry=input("What is the input list?")
input_open=open(input_entry, "r")
input_read=input_open.read().splitlines()
keys=[]
keys2=[]
values=[]
values2=[]
for record in ref:
end=record.find("\t")
end1=end+1
keys.append(record[0:end1])
values.append(record[end1:])
for eachkey in keys:
keys2.append(eachkey.replace("\n", "").replace("\t", ""))
for eachvalue in values:
values2.append(eachvalue.replace("\n", "").replace("\t", ""))
dict_IDs=dict(zip(keys2, values2))
for line in input_read:
if line not in dict_IDs.keys():
print("not found")
if line in dict_IDs.keys():
print(dict_IDs[line])