# A genomic interval or site in the other coordinate convention

`genome_coordinate_convert` · Runs: On the server · Level: Checked against a reference: pysam 0.24.1 base fetches and the BED, GFF3 and SAM specifications

Converts a genomic interval or site between 0-based half-open and 1-based closed coordinates.

Research and education software; not medical advice, and not for diagnosis or treatment decisions. It computes from the inputs it receives. It does not check the person's data, design or sample.

[Catalogue](https://www.drybench.com/mcp/catalogue) / [Genomics](https://www.drybench.com/mcp/catalogue/genomics)

[Ask your assistant](https://www.drybench.com/mcp/connect)

```cite
A genomic interval or site in the other coordinate convention (genome_coordinate_convert), Drybench MCP server 1.0.0; genome-coordinates@1.0.1 (Checked against a reference); https://www.drybench.com/mcp/tools/genome-coordinate-convert
```

## What it is

Converts a genomic interval or site between 0-based half-open (BED) and 1-based closed (SAM, VCF, GFF3). Use when moving a region between file formats or tools, or to find its 5′ and 3′ ends by strand. Not for overlap or distance between two intervals: use \`genome\_interval\_overlap\`. System, kind and strand are required; refuses positions past a stated length, circular wraps and a site given as an interval.

Field: [Sequencing and genomics](https://www.drybench.com/mcp/catalogue/genomics).

## What it does

**You give**

- `kind` (required): interval (start and end) or site (a zero-length position between two bases, such as an insertion point).
- `contig` (required): The sequence name, e.g. chr1. Leading and trailing white space is removed before the pattern is checked.
- `system`: The convention of start and end: 0-based-half-open (BED, BAM) or 1-based-closed (SAM, VCF, GFF3). Required for an interval. Optional.
- `start`: Interval start, in the stated system. Must be at least 0. Optional.
- `end`: Interval end, in the stated system. Must be at least 0. Optional.
- `strand`: Strand of an interval: +, -, . (none) or ? (unknown). Required for an interval. Optional.

and 2 more, listed below

No request is recorded for this tool.

**Limits**

- Research arithmetic for planning sequencing libraries and runs and for genomic coordinate bookkeeping; it does arithmetic on the inputs it receives, and does not measure the library, the instrument or the data.
- Linear coordinates only, with no circular wrap and no conversion between genome builds; a position is checked against a sequence length only when one is stated; VCF has no zero-length form and anchors an indel on a base, so no VCF form is given; strand '?' is accepted, with the 5′ and 3′ ends withheld.
- Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.

**It will not answer when**

- a half-open interval with start equal to end is a zero-length site and must be stated as a site.
- a coordinate lies after the stated sequence length, including a circular wrap.
- a coordinate is above 2^53 − 1 = 9007199254740991, the largest n for which n and n + 1 are both exact.

### Every input, with its units

8 inputs

- `kind` (required): interval (start and end) or site (a zero-length position between two bases, such as an insertion point).
- `contig` (required): The sequence name, e.g. chr1. Leading and trailing white space is removed before the pattern is checked.
- `system`: The convention of start and end: 0-based-half-open (BED, BAM) or 1-based-closed (SAM, VCF, GFF3). Required for an interval. Optional.
- `start`: Interval start, in the stated system. Must be at least 0. Optional.
- `end`: Interval end, in the stated system. Must be at least 0. Optional.
- `strand`: Strand of an interval: +, -, . (none) or ? (unknown). Required for an interval. Optional.
- `afterOneBasedBase`: For a site: the 1-based base it follows (0 for before the first base). Must be at least 0. Optional.
- `sequenceLength`: Length of the sequence, to check positions against. Must be above 0 bp. Optional.

### Every refusal, with its code

3 refusals

| Code | When |
| --- | --- |
| `ZERO_LENGTH_USE_SITE` | a half-open interval with start equal to end is a zero-length site and must be stated as a site. |
| `BEYOND_SEQUENCE_LENGTH` | a coordinate lies after the stated sequence length, including a circular wrap. |
| `COORDINATE_ABOVE_RANGE` | a coordinate is above 2^53 − 1 = 9007199254740991, the largest n for which n and n + 1 are both exact. |

## The calculation

The method's equations, constants and worked example.

### [Genomic intervals and zero-length sites between 0-based half-open and 1-based closed coordinates](https://www.drybench.com/methods/m/genome-coordinates/1.0.1)

`genome-coordinates@1.0.1`

**Equation 1**

```text
[s0, e0) half-open = [s0 + 1, e0] closed, and back: s0 = s1 − 1, e0 = e1 for a 1-based closed [s1, e1]
length = e0 − s0
beyond the sequence when e0 > the stated sequence length
```

| Symbol | Meaning |
| --- | --- |
| `s0` | 0-based start |
| `e0` | 0-based exclusive end, equal to the 1-based inclusive end |
| `length` | bases in the interval, e0 − s0, bp |

Source 1.

**Equation 2**

```text
contig:(s0 + 1)-e0
```

| Symbol | Meaning |
| --- | --- |
| `contig` | the sequence name |

Source 2.

**Equation 3**

```text
a site after 1-based base k: BED (k, k)
GFF3 start = end = k (not expressible for k = 0)
```

| Symbol | Meaning |
| --- | --- |
| `k` | the 1-based base the site follows |

Source 3.

**Equation 4**

```text
strand +: 5′ = s0 + 1, 3′ = e0
strand −: 5′ = e0, 3′ = s0 + 1: Drybench's derivation from GFF3's start <= end (columns 4 and 5) and the strand (column 7), consistent with column 8's phase text, which puts a plus-strand feature's 5′ end at its start and a minus-strand feature's at its end
```

| Symbol | Meaning |
| --- | --- |
| `strand` | +, −, . or ? |

Source 3.

A definition, not a model: the equation states what the quantity means. A different convention gives a different number.

**Worked example**

Worked example: one case of genome-coordinates\@1.0.1, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.

**Inputs**

- kind = interval
- contig = toy
- system = 0-based-half-open
- start = 2
- end = 7
- strand = +
- sequenceLength = 60 bp

**Steps**

1. s1 = 3, from start; by equation 1; gives result.oneBasedClosed.start.
2. len = 5 bp, from start, end; by equation 1; gives result.length.

The working, as the case writes it:

```text
1-based start = 0-based start + 1 = 3
end unchanged = 7
length = 7 - 2 = 5
strand '+'
```

**Answer**

- result.oneBasedClosed.start = 3
- result.length = 5 bp

Where these values came from: an outside program, pysam 0.24.1; zeroBasedHalfOpen, oneBasedClosed, length: pysam 0.24.1 fetch('toy', 2, 7) == fetch(region='toy:3-7') == 'GTTGC'; positionString: UCSC position notation (BED section, FAQformat); 5'/3' ends: strand rule, GFF3 1.26 column 7, worked by hand; SAM v1.6 section 1.4 worked example.

At build the tool returned this answer within the tolerance the file states: exact: coordinates, lengths, strings, withheld rules, statuses and codes.

Who worked this case: not recorded.

## Sources

1. Sequence Alignment/Map Format Specification v1.6, samtools/hts-specs, SAMv1.tex Used for: Genomic intervals and zero-length sites between 0-based half-open and 1-based closed coordinates. At: section 1.2 Terminologies and Concepts: the 1-based and 0-based coordinate systems (the 3rd to 7th bases are \[3, 7\] 1-based and \[2, 7) 0-based). **Read in full, 11 November 2026**
2. UCSC Genome Browser, Data File Formats, BED format Used for: Genomic intervals and zero-length sites between 0-based half-open and 1-based closed coordinates. At: section BED format: chromStart, chromEnd, the zero-length insertion example. **Read in full, 11 November 2026**
3. Generic Feature Format Version 3 (GFF3), Lincoln Stein, The-Sequence-Ontology/Specifications, gff3.md Used for: Genomic intervals and zero-length sites between 0-based half-open and 1-based closed coordinates. At: section Description of the Format: columns 4 and 5 (1-based start and end, start \<= end; zero-length features) and column 7 (strand: +, -, . unstranded, ? unknown). **Read in full, 11 November 2026**

Read by AI-assisted sessions. No person has checked these readings.

## How it is checked

**Level:** Checked against a reference.

**Checked against:** An outside program, pysam, 0.24.1; our own exact-arithmetic script and a hand-worked case.

**Cases:** No case set is linked to this version.

**Not checked:** Circular wraps; VCF's anchored indels; the Ensembl 'end = start − 1' insertion form (no source read); conversion between genome builds (out).

No independent scientist has yet reviewed this.

### Changes to its methods

0 changes

No change is logged for these method versions.
