joseleeph

Untitled

Dec 2nd, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. from sys import argv, exit
  2. import re
  3. if len(argv) < 2:
  4. print("mising command-line argument")
  5. exit(1)
  6.  
  7. pattern1 = re.compile(r'AGAT')
  8. pattern2 = re.compile(r'AATG')
  9. pattern3 = re.compile(r'TATC')
  10. with open(argv[1],"r") as file:
  11. contents = file.read()
  12. i = 0
  13. j = 4
  14. while contents[i:j]:
  15. #this works.... save it... prints one string of 4 per line
  16. print(contents[i:j])
  17. i += 4
  18. j += 4
  19.  
  20. while contents[i:j]:
  21. if contents[i:j] == contents[i+4:j+4]:
  22. index = 1
  23. count = 1
  24. while contents[i:j] == contents[i+4*index:j+4*index]:
  25. i += 1
  26. j += 1
  27. count += 1
  28. index += 1
  29. print(str(contents[i:j]) + " count is: " + count)
  30. matchcount = 0
  31. i = 0
  32. j = 4
  33. while contents[i:j]:
  34. pattern = contents[i:j] #pattern = re.compile(pattern?)
  35. if pattern == contents[i+4:j+4]:
  36. matches = pattern.finditer(f'{contents}') # no longer commented out
  37. for match in matches:
  38. mcount += 1
  39. j += 1
Advertisement
Add Comment
Please, Sign In to add comment