I am a college student and just started bioinformatics. I am trying to write a script (not for school) that finds all potential NGG and TTTN protospacer adjacent motif sequences in a genome string. I wrote the following script:
TargetFile = open('file.fasta')
readTF = TargetFile.read()
useTF = "".join(readTF[66:].split())
#no_of_basepairs = len(useTF)
sites = {"ngg_strand" : [],
"ngg_antistrand" : [], #location counted from reverse direction
"tttn_strand" : [],
"tttn_antistrand" : []} #location counted from reverse direction
for i in range(0, len(useTF)-2):
gg_mer = useTF[i:i + 2]
ttt_mer = useTF[i:i + 3]
if gg_mer == "GG":
sites["ngg_strand"].append(i)
elif gg_mer == "CC":
#look for reverse complement, record location on antistrand from reverse direction
sites["ngg_antistrand"].append(len(useTF)-i-2)
elif ttt_mer == "TTT":
sites["tttn_strand"].append(i+1)
elif ttt_mer == "AAA":
# look for reverse complement, record location on antistrand from reverse direction
sites["tttn_antistrand"].append(len(useTF)-i-2)
print(len(sites["ngg_strand"]))
print(useTF.count("GG"))
At the bottom I used the .count() method to compare results. I noticed that the method returns a smaller number than my code. I believe this is due to the .count() method not counting overlap, whereas my code does. I.e. in the string "NNNGGGGNNN" my code would count 3 occurences of the "GG" substring, whereas the .count() method returns 2 occurences.
My Questions:
If I want to find all possible PAM sites, which way of counting is correct? I believe my way would be correct, since as far as I know the RNA molecule doesn't advance in "triplet-steps". However, I am very much new to this and might be missing something.
If the reverse complement is found, is the location usually recorded from the same direction as on the strand, or in the reverse direction (as I implemented in the code)?
Like I said, I am new to this so if you see any other glaring problems I would appreciate any and all help. :-)
Thank you!