joseleeph

Untitled

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