Advertisement
joseleeph

Untitled

Dec 11th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. from sys import argv, exit
  2. import csv
  3. import re
  4. if len(argv) < 3:
  5. print("mising command-line argument")
  6. exit(1)
  7.  
  8. #pattern1 = re.compile(r'AGAT')
  9. #pattern2 = re.compile(r'AATG')
  10. #pattern3 = re.compile(r'TATC')
  11. # pattern = re.compile(r'contents[i:j]')
  12.  
  13.  
  14. with open(argv[1],"r") as file, open(argv[2],"r") as csvfile:
  15.  
  16.  
  17. count = 0
  18. contents = file.read()
  19. csvcontents = csv.reader(csvfile)
  20.  
  21. header = next(csvcontents)
  22. print("every item of header: ")
  23. for string in header:
  24. print(string, end = " ,")
  25. for string in header:
  26. startindex = 0
  27. endindex = len(string)
  28. scount = 0
  29. longest = 0
  30. while contents[startindex:endindex]:
  31. span = contents[startindex:endindex]
  32. while contents[startindex + endindex: endindex + endindex ] == span:
  33. #while span = string:
  34. scount += 1
  35. startindex += endindex
  36. endindex += endindex
  37. if scount > 1:
  38. print("span " + span + " repeats " + str(scount) + " times")
  39. startindex += 1
  40. endindex += 1
  41. else:
  42. startindex += 1
  43. endindex += 1
  44. if contents[startindex + endindex: endindex + endindex] == span:
  45. scount += 1
  46. startindex += endindex
  47. endindex += endindex
  48.  
  49.  
  50. #i = 0
  51. # j = 4
  52. # while contents[i:j]:
  53. # span = contents[i:j]
  54. # repcount = 0
  55. # while contents[i+4:j+4] == span:
  56. # repcount += 1
  57. # i += 4
  58. # j += 4
  59. #if repcount != 0:
  60. # if repcount > 1:
  61. # print("span " + span + " repeats " + str(repcount) + " times")
  62. #i += 4
  63. #j += 4
  64. # i += 1
  65. # j += 1
  66. # else:
  67. #i += 4
  68. #j += 4
  69. # i += 1
  70. # j += 1
  71.  
  72. #with open(argv[2]) as csvfile:
  73. #csvcontents = csvfile.read()
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement