<commit_before>---
layout: post
title: "DNA Strand: Positive / Negative / Upstream / Downstream"
description: ""
category: Biology
tags: [Biology-101]
---
{% include JB/setup %}

- https://www.biostars.org/p/3423/
- https://www.biostars.org/p/45810/
- https://en.wikipedia.org/wiki/Upstream_and_downstream_(DNA)

TBC<commit_msg>add content<commit_after>---
layout: post-mathjax
title: "DNA Strand: Positive / Negative / Upstream / Downstream"
description: ""
category: Biology
tags: [Biology-101]
---
{% include JB/setup %}

[upstream-downstream-TSS]: https://farm2.staticflickr.com/1569/26527566606_8d3e8d559b_o_d.png

References:

- [Question: Forward And Reverse Strand Conventions](https://www.biostars.org/p/3423/)
- [Upstream and downstream (DNA)](https://en.wikipedia.org/wiki/Upstream_and_downstream_(DNA))

![][upstream-downstream-TSS]

For the diagram:

- 0-based coordinate system is used (same as UCSC Genome Browser)
    - [Tutorial: Cheat Sheet For One-Based Vs Zero-Based Coordinate Systems](https://www.biostars.org/p/84686/)
- `chromStart` and `chromEnd` are columns from table `snp142` of database `hg19` in UCSC Genome Browser
- `txStart` and `txEnd` are columns from table `ensGene` of database `hg19` in UCSC Genome Browser

Rules of Thumb:

- __*TSS*__ = __*T*__ranscription __*S*__tart __*S*__ite
- "TSS distance" are actually "distance to TSS".
- Upstream is to 5';
    - downstream is to 3'.
- The direction of coordinate axis is fixed.
- The "+" strand goes along coordinate axis;
    - the "-" strand goes reversely.
- $g.txStart < g.txEnd$ always holds.
- For genes on "+" strand, $TSS = txStart$;
    - for genes on "-" strand, $TSS = txEnd$.
- For genes on "+" strand, $TSS-dist = chromStart - txStart$;
    - for genes on "-" strand, $TSS-dist = txEnd - chromStart$.
- In other words, suppose $strand(g) =\begin{cases}1 & g \text{ is on "+" strand}\\-1 & otherwise\end{cases}$ and $TSS(g) =\begin{cases}g.txStart & g \text{ is on "+" strand}\\g.txEnd & otherwise\end{cases}$, and we can concluse $TSS-dist(s,g) = (s.chromStart - TSS(g)) \times strand(g)$.
- If $s$ is in the upsteam of $g$, $TSS-dist(s,g) < 0$, no matter which strand $g$ is on;
    - if $s$ is in the downsteam of $g$, $TSS-dist(s,g) > 0$
{'fraction_non_alphanumeric': 0.1591417076441663, 'fraction_numerical': 0.02682163611980331, 'mean_word_length': 3.833693304535637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 7, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5397607', 'n_tokens_mistral': 883, 'n_tokens_neox': 797, 'n_words': 230}