Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ID detection for annotation object id link #1075

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Link } from 'app/components/Link'
import {
GO,
GO_PATTERN,
GO_PREFIX,
UNIPROTKB,
UNIPROTKB_PATTERN,
UNIPROTKB_PREFIX,
} from 'app/constants/annotationObjectIdLinks'

export function ObjectIdLink({ id }: { id: string }) {
let link
if (id.match(GO_PATTERN)) {
if (id.startsWith(GO_PREFIX)) {
link = `${GO}${id}`
} else if (id.match(UNIPROTKB_PATTERN)) {
} else if (id.startsWith(UNIPROTKB_PREFIX)) {
link = `${UNIPROTKB}${id.replaceAll('UniProtKB:', '')}`
}
// don't link if no patterns match
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const GO = 'https://amigo.geneontology.org/amigo/term/'
export const UNIPROTKB = 'https://www.uniprot.org/uniprotkb/'

export const GO_PATTERN = /GO:[0-9]{7}/
export const UNIPROTKB_PATTERN =
/UniProtKB:[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}/
export const GO_PREFIX = 'GO:'
export const UNIPROTKB_PREFIX = 'UniProtKB:'
Loading