Uploaded image for project: 'Commons Sandbox'
  1. Commons Sandbox
  2. SANDBOX-146

[id] New string identifier generators, PrefixedNumericGenerator &c.

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Id
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

    • Bugzilla Id:
      34254

      Description

      In order to generate identifiers for an instance of the Ensembl database [1], I needed a generator for
      identifiers of the style ENSG000001, ENSG000002, ENST000001, ENST000002, ENSP000001, and so on.

      Attached is a class PrefixedLeftPaddedNumericGenerator (sorry about the long class name) that solves
      this use case and also PrefixedNumericGenerator and PrefixedAlphanumericGenerator for
      completeness' sake.

      new PrefixedLeftPaddedNumericGenerator("foo", true, 5); returns

      foo01
      foo02
      foo03
      foo04
      foo05
      foo06
      foo07
      foo08
      foo09
      foo10
      foo11

      new PrefixedNumericGenerator("foo", true, 0L) returns

      foo1
      foo2
      foo3
      foo4
      foo5
      foo6
      foo7
      foo8
      foo9
      foo10
      foo11

      new PrefixedAlphanumericGenerator("foo", true, 5); returns

      foo01
      foo02
      foo03
      foo04
      foo05
      foo06
      foo07
      foo08
      foo09
      foo0a
      foo0b

      [1]
      > http://www.ensembl.org

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              heuermh@acm.org Michael Heuer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: