Advertisement
joseleeph

Untitled

Dec 1st, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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 f:
  11. count = 0
  12. contents = f.read()
  13. print(contents)
  14. print(contents[0:4])
  15. i = 0
  16. j = i + 4
  17. while contents[i:j]: # will read contents until end of file
  18. span = contents[i:j]
  19. #while contents[i+4:j+4] == span:
  20. while contents[i+4:j+4] == contents[i:j]:
  21. count += 1
  22. print("span " + contents + "repeats " + str(count) + " times" )
  23. i += 4
  24. j += 4
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement