I have the perl regular expression /VA=\d+:(\S+):ENSG/ which is used in a if statement as
if ($info =~ /VA=\d+:(\S+):ENSG/){
$gene =$1;
I am trying to figure out what the best way to replicate this in python would be. Right now I have
gene_re = re.compile(r'VA=\d+:(\S+):ENSG')
this_re = re.search(gene_re, info)
if this_re is not None:
gene = info[this_re.start(0):this_re.end(0)]
Is this a good way to translate it? I guess this is one area where perl is actually more readable than python.
Note that the python regular expression is compiled because the next three lines are actually inside a loop.