def alleleDetailById(id): allele = allele_hunter.getAlleleByMGIID(id) if allele: return renderAlleleDetail(allele) return error_template('No allele found for ID = %s' % id)
def convert(note, anchorClass=''): """ Takes a string and runs various regular expressions against it, to convert any special MGI notes tags into links """ if not note: return '' for regex, template in NOTES_TAG_CONVERSIONS: match = regex.search(note) while match: args = match.groups()[0].split('|') start = match.start() end = match.end() if not args[1]: # default to ID field, if link text blank args[1] = args[0] # convert the note tag # This shouldn't match unless we have 3 args in the first place converted = template % (anchorClass, args[0], args[1]) # insert converted tag note = note[:start] + converted + note[end:] match = regex.search(note) # special handling for non-standard \AlleleSymbol tag match = alleleSymbolRegex.search(note) while match: args = match.groups()[0].split('|') start = match.start() end = match.end() allele = allele_hunter.getAlleleByMGIID(args[0]) if allele is None: note = note[:start] + "<span style='color: red;'>Allele ID Error</span> " + note[end:] else: # insert converted tag note = note[:start] + superscript(allele.symbol) + note[end:] match = alleleSymbolRegex.search(note) # special handling for non-standard \Elsevier tag match = elsevierRegex.search(note) while match: args = match.groups()[0].split('|') start = match.start() end = match.end() app.logger.warn('match! %s' % args[0]) ref = reference_service.get_by_jnum_id(args[0]) # generate replacement text journal = ref.journal or '' vol = ref.vol or '' pgs = ref.pgs or '' title = ref.title or '' authors = ref.authors or '' year = ref.year or '' replacementText = "%s %s: %s, %s, %s Copyright %s" % \ (journal, vol, pgs, authors, title, year) # insert converted tag note = note[:start] + replacementText + note[end:] match = elsevierRegex.search(note) return note
def queryAllele(self): params = self._getParams() return allele_hunter.getAlleleByMGIID(params['allele_id'])
def convert(note, anchorClass=''): """ Takes a string and runs various regular expressions against it, to convert any special MGI notes tags into links """ if not note: return '' for regex, template in NOTES_TAG_CONVERSIONS: match = regex.search(note) while match: args = match.groups()[0].split('|') start = match.start() end = match.end() if not args[1]: # default to ID field, if link text blank args[1] = args[0] # convert the note tag # This shouldn't match unless we have 3 args in the first place converted = template % (anchorClass, args[0], args[1]) # insert converted tag note = note[:start] + converted + note[end:] match = regex.search(note) # special handling for non-standard \AlleleSymbol tag match = alleleSymbolRegex.search(note) while match: args = match.groups()[0].split('|') start = match.start() end = match.end() allele = allele_hunter.getAlleleByMGIID(args[0]) if allele is None: note = note[: start] + "<span style='color: red;'>Allele ID Error</span> " + note[ end:] else: # insert converted tag note = note[:start] + superscript(allele.symbol) + note[end:] match = alleleSymbolRegex.search(note) # special handling for non-standard \Elsevier tag match = elsevierRegex.search(note) while match: args = match.groups()[0].split('|') start = match.start() end = match.end() app.logger.warn('match! %s' % args[0]) ref = reference_service.get_by_jnum_id(args[0]) # generate replacement text journal = ref.journal or '' vol = ref.vol or '' pgs = ref.pgs or '' title = ref.title or '' authors = ref.authors or '' year = ref.year or '' replacementText = "%s %s: %s, %s, %s Copyright %s" % \ (journal, vol, pgs, authors, title, year) # insert converted tag note = note[:start] + replacementText + note[end:] match = elsevierRegex.search(note) return note