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("missing command line argument")
- with open(argv[1],"r") as file, open(argv[2],"r") as csvfile:
- count = 0
- contents = file.read() #1. Read the sequence file into a string (you've got this).
- csvcontents = csv.reader(csvfile)
- header = next(csvcontents)
- print("header prints")
- print("attempting to print rows of csvfile")
- for row in csvcontents:
- print(row)
- #for item in contents:
- for item in header[1:]:
- #print("item prints:")
- #print(item)
- beg = 0 # beginning index
- end = len(item) # item length
- seqrun = 0
- longest = 0
- while contents[beg:beg+end]:
- #while beg + end <= len(contents):
- if contents[beg:beg+end] == item: # trying to solve the issue of end being incremented incorrectly here
- seqrun = 1
- #while contents[beg + len(item): beg + len(item)] == item:
- #while contents[beg: beg + len(item):end] == item:
- #while contents[beg:end] == item:
- #while contents[beg:beg+len(item): end + len(item)] == item:
- while contents[beg + end: end + end] == item:
- seqrun += 1
- #beg += len(item)
- beg += end
- #end += len(item) i don't need to increment end as well?
- if seqrun > longest:
- longest = seqrun
- beg += 1
- #end += 1
- print(item + " repeats " + str(seqrun) + "times")
- print("longest repeat is " + str(longest) + "times") # why is it longest?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement