I have a list of strings with a set size, for instance:
A, T, G and C are always the same, but N can take on every value. So i wanted to change them to regular expression:
And now i want to be able to say: value 1,3 and 4 are equal, and value 2 is unique. But how can you compare two regular expression to see if they are equal?
i am currently programming in python 2.7, but if other languages are able to give the me results, i am willing to switch or run the code from command line.
Why not do it yourself, since you are not actually using regular expression. I guess you just only want to compare two sequences.
def match(a,b):
if a==b or a=='N' or b=='N':
return True
else:
return False
def compare(str1,str2):
if len(str1)!=len(str2):
return False
for i in range(len(str1)):
if not match(str1[i],str2[i]):
return False
return True
print compare('ATTG','ATNG')
# True
print compare('ATTN','ATGC')
# False
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.