Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv, exit
- import csv
- import re
- if len(argv) < 3:
- print("mising command-line argument")
- exit(1)
- #pattern1 = re.compile(r'AGAT')
- #pattern2 = re.compile(r'AATG')
- #pattern3 = re.compile(r'TATC')
- # pattern = re.compile(r'contents[i:j]')
- with open(argv[1],"r") as file, open(argv[2],"r") as csvfile:
- count = 0
- contents = file.read()
- csvcontents = csv.reader(csvfile)
- header = next(csvcontents)
- print("every item of header: ")
- for string in header:
- print(string, end = " ,")
- for string in header:
- startindex = 0
- endindex = len(string)
- scount = 0
- longest = 0
- while contents[startindex:endindex]:
- span = contents[startindex:endindex]
- while contents[startindex + endindex: endindex + endindex ] == span:
- #while span = string:
- scount += 1
- startindex += endindex
- endindex += endindex
- if scount > 1:
- print("span " + span + " repeats " + str(scount) + " times")
- startindex += 1
- endindex += 1
- else:
- startindex += 1
- endindex += 1
- if contents[startindex + endindex: endindex + endindex] == span:
- scount += 1
- startindex += endindex
- endindex += endindex
- #i = 0
- # j = 4
- # while contents[i:j]:
- # span = contents[i:j]
- # repcount = 0
- # while contents[i+4:j+4] == span:
- # repcount += 1
- # i += 4
- # j += 4
- #if repcount != 0:
- # if repcount > 1:
- # print("span " + span + " repeats " + str(repcount) + " times")
- #i += 4
- #j += 4
- # i += 1
- # j += 1
- # else:
- #i += 4
- #j += 4
- # i += 1
- # j += 1
- #with open(argv[2]) as csvfile:
- #csvcontents = csvfile.read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement