Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv, exit
- import re
- if len(argv) < 2:
- print("mising command-line argument")
- exit(1)
- pattern1 = re.compile(r'AGAT')
- pattern2 = re.compile(r'AATG')
- pattern3 = re.compile(r'TATC')
- #with open("small.csv", "r") as file:
- #with open(sequences/"1.txt", "r") as f:
- #with open(argv[1], "r") as f:
- #contents = f.read()
- #matches = pattern2.finditer(contents)
- #for match in matches:
- #print(match)
- #with open(argv[1], "r") as f:
- #contents = f.read()
- #matches = pattern3.finditer(contents)
- #for match in matches:
- #print(match)
- #print("Here is a list of all the times the string TATC occurs")
- with open(argv[1], "r") as f:
- count = 0
- contents = f.read()
- print("contents prints: ")
- print(contents)
- #print(contents[0:4])
- i = 0
- j = i + 4
- while contents[i:j]: # will read contents until end of file
- span = contents[i:j]
- #count = 0
- #sample output for this count
- #span GAAA reapeats 0 consecutive times
- #span GGAG reapeats 0 consecutive times
- #span GGAT reapeats 0 consecutive times
- while contents[i+4:j+4] == span:
- count += 1
- #print("span reapeats " + str(count) + " times" )
- i += 4
- j += 4
- #count = 0 # resetting count to 0 as suggested
- #sample output for this count
- #span GAAA reapeats 0 consecutive times
- #span GGAG reapeats 0 consecutive times
- #span GGAT reapeats 0 consecutive times
- #count = 0
- #count +=1
- i += 4
- j += 4
- print("span " + span + " reapeats " + str(count) + " consecutive times" )
- #count = 0
- #count = 0 sample output remains unchanged
- #print("span " + span + " reapeats " + str(count) + " consecutive times" )
Advertisement
Add Comment
Please, Sign In to add comment