Skip to content

Instantly share code, notes, and snippets.

@hanfeisun
Created October 30, 2013 08:23
Show Gist options
  • Save hanfeisun/7228911 to your computer and use it in GitHub Desktop.
Save hanfeisun/7228911 to your computer and use it in GitHub Desktop.
Factor Parser for GEO
def parseFactorByAntibody(geoPost):
targetFlds = ["CHIP_ANTIBODY", "ANTIBODY", "CHIP", "ANTIBODY_SOURCE", "ANTIBODY_ANTIBODYDESCRIPTION",
"ANTIBODY_TARGETDESCRIPTION"]
#1. try to get the values
for t in targetFlds:
tmp = getFromPost(geoPost, t).strip()
if not tmp:
continue
tmp = tmp.upper().replace("ANTI-", " ").replace("ANTI", " ").strip()
if len(tmp) < 10 and tmp != "":
return models.Factors.objects.get_or_create(name=tmp)[0]
splited = re.findall(r"[\w-]+", tmp)
for s in splited:
if re.match(r"^[\d-]+$", s):
continue
if d.check(s):
continue
if s.startswith("POL2") and len(s) < 10:
return models.Factors.objects.get_or_create(name=tmp)[0]
if models.Factors.objects.filter(name__iexact=s):
return models.Factors.objects.get(name__iexact=s)
if "INPUT" in splited:
return models.Factors.objects.get_or_create(name="Input")[0]
if ("POLYMERASE" in splited) or ("POL" in splited):
return models.Factors.objects.get_or_create(name="POL2")[0]
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment