Advertisement
joseleeph

Untitled

Dec 6th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 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. npattern = re.compile(r'name', re.IGNORECASE) # find all cases of name
  11. with open(argv[1],"r") as file:
  12. contents = file.read()
  13. i = 0
  14. j = 4
  15. while contents[i:j]:
  16. #this works.... save it... prints one string of 4 per line
  17. if (contents[i:j] == npattern):
  18. {
  19. i += 4
  20. j += 4
  21. }
  22. else:
  23. print(contents[i:j])
  24. i += 4
  25. j += 4
  26.  
  27. #while contents[i:j]:
  28. #if contents[i:j] == contents[i+4:j+4]:
  29. #index = 1
  30. #mcount = 1
  31. #while contents[i:j] == contents[i+4*index:j+4*index]:
  32. #i += 1
  33. #j += 1
  34. #mcount += 1
  35. #index += 1
  36. #print(str(contents[i:j]) + " count is: " + mcount)
  37. #mcount=0
  38. #i = 0
  39. #j = 4
  40. #while contents[i:j]:
  41. #pattern = re.compile(contents[i:j]) #pattern = re.compile(pattern?)
  42. #if pattern == contents[i+4:j+4]:
  43. #matches = pattern.finditer(f'{contents}')
  44. # no longer commented out
  45. #for match in matches:
  46. #mcount += 1
  47. #j += 1
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement