This is a test version of Biostars. For the public version, visit https://www.biostars.org.
A List Of Regular-Expressions For Recognizing Ids From Various Databases

I'm looking to create a list of regular expressions that can distinguish between the IDs of various databases? I know that some will be ambiguous but at least it could help narrow down which databases to check.

For example:

Kegg IDs: \w{,3}\d{1,}

Entrez IDs: \d*

RefSeq IDs: \w{2}_\d{1,}\.\d{1,}

Anyone have any to add? This might be a useful community resource.

database

Yeah, I've been trying to convert a 'mixed bag' of IDs and I had trouble even placing some of them. Hopefully this will help out.

5 answers

Look at the MIRIAM registry:

http://www.ebi.ac.uk/miriam/main/collections/

they have assembled a large collection of expressions for the identifiers/accessions of number of databases.

That is awesome. I never saw that before.

Yeah, its cool, we use it for very much what you asked here.

  • dbSNP: rs[0-9]+
  • Gene Ontology: GO:[0-9]+
  • DOI (from the connotea bookmarklet): (doi:)?s?(10.d{4}/S+)
  • LSID : from http://goo.gl/D6PT1

     String legalId =  "[A-Za-z0-9][A-Za-z0-9()+,-.=@;$_!*\'\"%]*";
     String lsidRE = "^[uU][rR][nN]:[lL][sS][iI][dD]:(" + legalID + "):(" + legalID + "):(" + legalID + ")[:]?(" + legalID + ")?$";
    

For INSDC accession numbers, we have used:

([A-Z]{1}[0–9]{5})|([A–Z]{2}[0−9]{6})|([A–Z]{4}[0−9]{8,9})|([A–Z]{5}[0−9]{7}))(\.[0–9]{1,3})

(Credit to Guy Cocharane at EBI)

Protein Data Bank (PDB):

[0-9][A-Z0-9]{3}

UniProt:

[A-NR-Z][0-9][A-Z][A-Z0-9][A-Z0-9][0-9]

and

[OPQ][0-9][A-Z0-9][A-Z0-9][A-Z0-9][0-9]

For gene annotations in KEGG databases such as

glutamate synthase Glt1, putative; K00264 glutamate synthase (NADPH/NADH) [EC:1.4.1.13 1.4.1.14]

To extract KEGG orthology number (KO)

(^| |\)\])(K[0-9]{5})($| |\)\])

Will work with:

  1. "K00264 glutamate synthase ... " id at start
  2. "...putative; K00264 glutamate..." in in middle
  3. "Glt1, putative; K00264" id at end
  4. "(K23102 K23010)" round brackets
  5. "[K23102 K23010]" square brackets

Will exclude:

  1. " K2041020 " back-extensions
  2. " AK29310 " front-extensions

_

(^| |\)\])

captures start of a string or preceded by whitespace or has a starting round/square bracket

(K[0-9]{5})

captures the kegg id i.e. K10230, K20310. This can be replaced with the metacyc id format, etc..

($| |\)\] )

captures end of a string or followed by whitespace or has a ending round/square bracket

Log in to answer this question.