forked from lyy005/Intro_Biocom_ND_319_Tutorial8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion2.py
More file actions
executable file
·18 lines (14 loc) · 823 Bytes
/
Copy pathQuestion2.py
File metadata and controls
executable file
·18 lines (14 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pandas
import numpy
import re
sequenceID = open("indivIDs.txt", "r") #Open sequence ID file
barcodes={} #Define empty dictionary for barcodes associated with sequence IDs
for line in sequenceID: #Loop through sequence ID file line-by-line
line=line.strip() #Strip whitespace from beginning and end of line
cols=line.split() #Return the first value and the second value as unique objects in a list
if cols[0] in barcodes: #Check if the first value in the line (the barcode) is already in the dictionary
print "Duplicate:" + cols[1] #Print error message
else:
barcodes[cols[0]] = cols[1] #If barcode is not yet present, add it as a key, and associate it with
#the second value in the line (the sequence ID)
file.close(sequenceID) #Close the file