Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Matching a pattern in python

pattern = "F-x-([EK])-x-S-([GT])-R-T"
pattern=pattern.replace("-","")
pattern=pattern.replace("x","[GPAVLIMCFYWHKRQNEDST]")
count=0

for sequence in source:
    count += 1
    sequence=sequence.replace(" ","")
    result = re.finditer(pattern, sequence)
    print(">sequence ",count)
    print(sequence)
    for match in result:
        print("found ",match.group()," at position",match.span()," third position =", match.group(2))
Source by bpc.biobix.be #
 
PREVIOUS NEXT
Tagged: #Matching #pattern #python
ADD COMMENT
Topic
Name
9+8 =