

spacers = [] #list of all Vibrio cholerae spacers
sp = [] #list of potential spacers extracted from fastq


f = open(filename,'r') #replace "filename" with path to a txt file with a list of all Vibrio cholerae spacer sequences
for x in f:
    spacers.append(x.split()[0])
f.close()


f=open(filename,'r') #replace "filename" with path to a fastq file to be analyzed
while True:
    a=f.readline()
    if a=="":
        break
    b=f.readline()
    a=f.readline()
    a=f.readline()
    if b[34:38]=='ATAA' or b[34:38]=='GCAT': #these sequences are expected of protospacer-containing or empty plasmids
        sp.append(b[34:49]) #make a list of all sequences that are likely to be protospacers
f.close()


f=open(filename,'w') #replace "filename" with path to a txt file to write spacer sequences and counts
for x in spacers:
    f.write(x + '\t' + str(sp.count(x)) + '\n')
f.close()
