Advertisement
Guest User

Untitled

a guest
May 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # genotype starts with AA and ends with BB
  2. def findGen(line):
  3. gens = []
  4. endingPostition = 0 #last end postition
  5. #go through all characters
  6. for i in range(0, len(line) - 1):
  7. #find start pattern
  8. if line[i] == "A" and line[i+1] == "A":
  9. # Found AA
  10. gen = ""
  11. #Ensure that end was found
  12. if i >= endingPostition:
  13. k = i # select start index
  14. #go through chars (i -> end - 1)
  15. for k in range(i, len(line) - 1):
  16. #find end pattern
  17. if(line[k] == "B" and line[k+1] == "B"):
  18. # found ending
  19. endingPostition = k #define where should start
  20. gen += "BB"
  21. break
  22. else:
  23. # not found ending. Add next char
  24. gen += line[k]
  25.  
  26. # won't add gen if not have ending
  27. if gen.find("BB") > 0:
  28. gens.append(gen)
  29.  
  30. gen = ""
  31.  
  32. return gens
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement