Generation

generate functionFri, 30 Dec 2022

string like ((G1 or G2) and (G3 or G4)) modifies like (G1 and G3 and G5) or (G1 and G4 and G5) or (G2 and G3 and G5) or (G2 and G4 and G5)

def modify_string(string): regex = re.compile("\(\(([A-Z]([0-9]|[1-9][0-9])* or [A-Z]([0-9]|[1-9][0-9])*)\) and \(([A-Z]([0-9]|[1-9][0-9])* or [A-Z]([0-9]|[1-9][0-9])*)\)\)") match = regex.match(string) gene1 = match.group(1) gene2 = match.group(4) return "((" + gene1 + " and G5) or (" + gene2 + " and G5))" modify_string("((G1 or G2) and (G3 or G4))")

Questions about programming?Chat with your personal AI assistant