# Genomic intervals and zero-length sites between 0-based half-open and 1-based closed coordinates, version 1.0.1

genome-coordinates\@1.0.1: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.

## What this page can and cannot show

**Level: Checked against a reference; pysam 0.24.1 base fetches; SAMv1, GFF3 1.26 and UCSC BED re-read; strand ends our derivation. Reference kind: an outside program, pysam, 0.24.1; our own exact-arithmetic script and a hand-worked case.**

Checked by this project, not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with the stated reference within the stated tolerance. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed them.

[Every version of this method](https://www.drybench.com/methods/m/genome-coordinates) · [Every method](https://www.drybench.com/methods/m) · [What the levels mean](https://www.drybench.com/methods/levels)

## Version 1.0.1

**Level: Checked against a reference; pysam 0.24.1 base fetches; SAMv1, GFF3 1.26 and UCSC BED re-read; strand ends our derivation. Reference kind: an outside program, pysam, 0.24.1; our own exact-arithmetic script and a hand-worked case.** `genome-coordinates@1.0.1`

Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.

**Verification statement:** Conversions between 1-based closed and 0-based half-open coordinates as defined in SAMv1 §1.2 (hts-specs 510c107b), GFF3 1.26 columns 4, 5 and 7, and UCSC BED (live page, text pinned by hash), each re-read at source 14 November 2026. 5′ and 3′ ends by strand are Drybench's derivation. Compared with pysam 0.24.1 base fetches, and with a second implementation in Python by a separate agent of the same model family (61 cases, 28 at the edges; 1 is the kit's missing-value code). Coordinates above 2^53 − 1 refused. Exact integer arithmetic.

1-based start = 0-based start + 1, end unchanged; a zero-length site after base k is BED (k, k) and GFF3 start = end = k; 5′ and 3′ ends by strand.

- **How results are reported:** none: integers, exact
- **Uncertainty:** Exact integer arithmetic.
- **Reference, as its record states it:** pysam 0.24.1 base fetches and the BED, GFF3 and SAM specifications
- **Level confirmed by this project's ruling of** 14 November 2026

[What this page can and cannot show](#what-this-page-can-and-cannot-show)

### What was checked

93 cases in 3 files, linked by this exact version.

Run through the tool at build against an outside program, pysam, 0.24.1; our own exact-arithmetic script and a hand-worked case: 63 agree within the tolerance the file states, 30 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 33 cases**
  - **Where the expected values came from:** an outside program, pysam 0.24.1
  - **Recorded on:** 2026-11-10
  - **Reference:** pysam, 0.24.1; licence MIT
  - **Tolerance as the file states it:** exact: coordinates, lengths, strings, withheld rules, statuses and codes

- **File 2, 58 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-14
  - **Reference:** second implementation (Python 3.13, standard library), 2026-11-14; licence PSF-2.0
  - **Tolerance as the file states it:** exact: coordinates, lengths, strings, withheld rules, statuses and codes

- **File 3, 2 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-14
  - **Reference:** second implementation (Python 3.13, standard library), 2026-11-14; licence PSF-2.0
  - **Tolerance as the file states it:** exact: coordinates, lengths, strings, withheld rules, statuses and codes

Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.

### What was not checked

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

### Definition or model

A closed form: the result follows from the inputs by the equations alone.

### Equations

**Equation 1**

```equation
[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 and unit |
| --- | --- |
| 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: Sequence Alignment/Map Format Specification v1.6, samtools/hts-specs, SAMv1.tex, 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), hts-specs master at commit 510c107b; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 5f1326a2298b. Free to read (free to read; no licence stated in the file or repository, so cited only), checked 2026-11-11. No erratum found (searched the file at commit 510c107b (the repository holds the specification's corrections as commits)), 2026-11-11.

**Equation 2**

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

| Symbol | Meaning and unit |
| --- | --- |
| contig | the sequence name |

Source: UCSC Genome Browser, Data File Formats, BED format, section BED format: chromStart, chromEnd, the zero-length insertion example, the live FAQ page, whose bytes change between retrievals, so its text is pinned: re-read 14 November 2026, SHA-256 of its text 17f65a6745f7f9ed44452fb20d1b96dae49818bcb6a90212cd184927178a9364 (script, style and comment blocks and tags removed, entities decoded, whitespace collapsed to single spaces, UTF-8); the byte SHA-256 is of the retrieval of 11 November 2026, kept as historical; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 9613382e6031. Free to read (free to read; no licence stated in the file or repository, so cited only), checked 2026-11-11. No erratum found (searched the FAQ page as retrieved (no revision history published)), 2026-11-11.

**Equation 3**

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

| Symbol | Meaning and unit |
| --- | --- |
| k | the 1-based base the site follows |

Source: Generic Feature Format Version 3 (GFF3), Lincoln Stein, The-Sequence-Ontology/Specifications, gff3.md, 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), version 1.26 of 18 August 2020, at commit fe735052; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning d451d5e985ad. Free to read (free to read; no licence stated in the file or repository, so cited only), checked 2026-11-11. No erratum found (searched the file at commit fe735052), 2026-11-11.

**Equation 4**

```equation
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 and unit |
| --- | --- |
| strand | +, −, . or ? |

Source: Generic Feature Format Version 3 (GFF3), Lincoln Stein, The-Sequence-Ontology/Specifications, gff3.md, 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), version 1.26 of 18 August 2020, at commit fe735052; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning d451d5e985ad. Free to read (free to read; no licence stated in the file or repository, so cited only), checked 2026-11-11. No erratum found (searched the file at commit fe735052), 2026-11-11.

### Constants

Constants: none used.

### 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:

```equation
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.

### What it refuses, and its input ranges

- `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 Next: Give it as a site (siteAfter) rather than an interval.
- `BEYOND_SEQUENCE_LENGTH`: a coordinate lies after the stated sequence length, including a circular wrap Next: Check the coordinate and the sequence length; for a circular sequence, split the interval at the origin.
- `COORDINATE_ABOVE_RANGE`: a coordinate is above 2^53 − 1 = 9007199254740991, the largest n for which n and n + 1 are both exact Next: No change of input makes this computable on these data.

### Changes

No correction is logged for genome-coordinates\@1.0.1.

## Tools that use it

- [`genome_coordinate_convert`](https://www.drybench.com/methods/tools/genome-coordinate-convert)

## Cite this version

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