Complement to the documentation

Former-commit-id: 89952a6f3bb261a6aaec24430906e635914ffce4
This commit is contained in:
2023-12-04 13:16:34 +01:00
parent eb351a7530
commit 03bef6461d
83 changed files with 65993 additions and 10547 deletions

View File

@@ -1,23 +1,20 @@
# File formats usable with *OBITools*
OBITools manipulate have to manipulate DNA sequence data and taxonomical data.
They can use some supplentary metadata describing the experiment and produce
some stats about the processed DNA data. All the manipulated data are stored in
text files, following standard data format.
*OBITools* manipulate have to manipulate DNA sequence data and taxonomical data. They can use some supplentary metadata describing the experiment and produce some stats about the processed DNA data. All the manipulated data are stored in text files, following standard data format.
# The DNA sequence data
## The DNA sequence data
Sequences can be stored following various format. OBITools knows some of them. The central formats for sequence files manipulated by OBITools scripts are the [`fasta`](#the-fasta-sequence-format) and [`fastq`](#the-fastq-sequence-format) format. OBITools extends the both these formats by specifying a syntax to include in the definition line data qualifying the sequence. All file formats use the `IUPAC` code for encoding nucleotides.
Sequences can be stored following various format. *OBITools* knows some of them. The central formats for sequence files manipulated by *OBITools* scripts are the [*FASTA*](#sec-fasta) and [*FASTQ*](#sec-fastq) format. *OBITools* extends the both these formats by specifying a syntax to include in the definition line data qualifying the sequence. All file formats use the [`IUPAC`](#sec-iupac) code for encoding nucleotides.
Moreover these two formats that can be used as input and output formats, **OBITools4** can read the following format :
Moreover these two formats that can be used as input and output formats, *OBITools4* can read the following format :
- [EBML flat file](https://ena-docs.readthedocs.io/en/latest/submit/fileprep/flat-file-example.html) format (use by ENA)
- [Genbank flat file format](https://www.ncbi.nlm.nih.gov/Sitemap/samplerecord.html)
- [ecoPCR output files](https://pythonhosted.org/OBITools/scripts/ecoPCR.html)
- [EBML flat file](https://ena-docs.readthedocs.io/en/latest/submit/fileprep/flat-file-example.html) format (use by ENA)
- [Genbank flat file format](https://www.ncbi.nlm.nih.gov/Sitemap/samplerecord.html)
- [ecoPCR output files](https://pythonhosted.org/OBITools/scripts/ecoPCR.html)
## The IUPAC Code
### The IUPAC Code {#sec-iupac}
The International Union of Pure and Applied Chemistry (IUPAC\_) defined the standard code for representing protein or DNA sequences.
The International Union of Pure and Applied Chemistry ([IUPAC]()) defined the standard code for representing protein or DNA sequences.
| **Code** | **Nucleotide** |
|----------|-----------------------------|
@@ -38,48 +35,59 @@ The International Union of Pure and Applied Chemistry (IUPAC\_) defined the stan
| V | A, C, or G (not T, not U) |
| N | Any base (A, C, G, T, or U) |
## The *fasta* sequence format {#sec-fasta}
### The *FASTA* sequence format {#sec-fasta}
The **fasta format** is certainly the most widely used sequence file format. This is certainly due to its great simplicity. It was originally created for the Lipman and Pearson [FASTA program](http://www.ncbi.nlm.nih.gov/pubmed/3162770?dopt=Citation). OBITools use in more of the classical `fasta` format an `extended version` of this format where structured data are included in the title line.
The [*FASTA*](#sec-fasta) format is certainly the most widely used sequence file format. This is certainly due to its great simplicity. It was originally created for the Lipman and Pearson [`FASTA` program](http://www.ncbi.nlm.nih.gov/pubmed/3162770?dopt=Citation). *OBITools* use in more of the classical [*FASTA*](#sec-fasta) format an `extended version` of this format where structured data are included in the title line.
In *fasta* format a sequence is represented by a title line beginning with a **`>`** character and the sequences by itself following the :doc:`iupac` code. The sequence is usually split other severals lines of the same length (expect for the last one)
In [*FASTA*](#sec-fasta) format a sequence is represented by a title line beginning with a **`>`** character and the sequences by itself following the [`IUPAC`](#sec-iupac) code. The sequence is usually split other severals lines of the same length (expect for the last one)
>my_sequence this is my pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
```
>my_sequence this is my pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
```
This is no special format for the title line excepting that this line should be unique. Usually the first word following the **\>** character is considered as the sequence identifier. The end of the title line corresponding to a description of the sequence. Several sequences can be concatenated in a same file. The description of the next sequence is just pasted at the end of the record of the previous one
>sequence_A this is my first pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
>sequence_B this is my second pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
>sequence_C this is my third pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
## The *fastq* sequence format[^01_obitools_doc-1]{#sec-fastq}
The **FASTQ** format is a text file format for storing both biological sequences (only nucleic acid sequences) and the associated quality scores. The sequence and score are each encoded by a single ASCII character. This format was originally developed by the Wellcome Trust Sanger Institute to link a [FASTA](#the-fasta-sequence-format) sequence file to the corresponding quality data, but has recently become the de facto standard for storing results from high-throughput sequencers [@cock2010sanger].
[^01_obitools_doc-1]: This article uses material from the Wikipedia article [`FASTQ format`](http://en.wikipedia.org/wiki/FASTQ_format) which is released under the `Creative Commons Attribution-Share-Alike License 3.0`
A fastq file normally uses four lines per sequence.
- Line 1 begins with a '\@' character and is followed by a sequence identifier and an *optional* description (like a :ref:`fasta` title line).
- Line 2 is the raw sequence letters.
- Line 3 begins with a '+' character and is *optionally* followed by the same sequence identifier (and any description) again.
- Line 4 encodes the quality values for the sequence in Line 2, and must contain the same number of symbols as letters in the sequence.
A fastq file containing a single sequence might look like this:
```
>sequence_A this is my first pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
>sequence_B this is my second pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
>sequence_C this is my third pretty sequence
ACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGT
GTGCTGACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTACGTTGCAGTGTTT
AACGACGTTGCAGTACGTTGCAGT
```
#### File extensions
There is no standard file extension for a [*FASTA*](#sec-fasta) file, but `.fa` and `.fasta`, are commonly used.
### The *FASTQ* sequence format[^formats-1] {#sec-fastq}
[^formats-1]: This article uses material from the Wikipedia article [`FASTQ format`](http://en.wikipedia.org/wiki/FASTQ_format) which is released under the `Creative Commons Attribution-Share-Alike License 3.0`
The [*FASTQ*](#sec-fastq) format is a text file format for storing both biological sequences (only nucleic acid sequences) and the associated sequence quality scores. Every nucleotide of the sequence and its associated quality score are each encoded by a single ASCII character. This format was originally developed by the Wellcome Trust Sanger Institute to link a [*FASTA*](#sec-fasta) sequence file to the corresponding quality data, but is now became the *de facto* standard for storing results from high-throughput sequencers [@cock2010sanger].
*OBITools* considers that a [*FASTQ*](#sec-fastq) file uses four lines to encode a sequence record.
- Line 1 begins with a '\@' character and is followed by a sequence identifier and an *optional* description
(like a [*FASTA*](#sec-fasta) title line).
- Line 2 is the sequence letters, in upper or lower case, but *OBITools* only write sequences as lower cases.
- Line 3 begins with a '+' character and is *optionally* followed by the same sequence identifier
(and any description) again.
- Line 4 encodes the quality values for the sequence in Line 2, and must contain the same number of
symbols as letters in the sequence.
A [*FASTQ*](#sec-fastq) file looks like this:
```
@SEQ_ID
GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT
+
@@ -88,16 +96,16 @@ GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT
The character '!' represents the lowest quality while '\~' is the highest. Here are the quality value characters in left-to-right increasing order of quality (`ASCII`):
```
```
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]
^_`abcdefghijklmnopqrstuvwxyz{|}~
```
The original Sanger FASTQ files also allowed the sequence and quality strings to be wrapped (split over multiple lines), but this is generally discouraged as it can make parsing complicated due to the unfortunate choice of "\@" and "+" as markers (these characters can also occur in the quality string).
If the original Sanger [*FASTQ*](#sec-fastq) files also allowed the sequence and quality strings to be wrapped (split over multiple lines), it is not supported by *OBITools* as it make parsing complicated due to the unfortunate choice of "\@" and "+" as markers (these characters can also occur in the quality string).
### Sequence quality scores{.unnumbered}
#### Sequence quality scores {.unnumbered}
The Phred quality value *Q* is an integer mapping of *p* (i.e., the probability that the corresponding base call is incorrect). Two different equations have been in use. The first is the standard Sanger variant to assess reliability of a base call, otherwise known as Phred quality score:
The Phred quality value *Q* is an integer mapping of *p* (*i.e.*, the probability that the corresponding base call is incorrect). Two different equations have been in use. The first is the standard Sanger variant to assess reliability of a base call, otherwise known as Phred quality score:
$$
Q_\text{sanger} = -10 \, \log_{10} p
@@ -113,24 +121,18 @@ Although both mappings are asymptotically identical at higher quality values, th
![Relationship between *Q* and *p* using the Sanger (red) and Solexa (black) equations (described above). The vertical dotted line indicates $\mathbf{p}= 0.05$, or equivalently, $Q = 13$.](Probabilitymetrics.png){#fig-Probabilitymetrics}
##### Encoding {.unnumbered}
#### Encoding{.unnumbered}
The *fastq* format had differente way of encoding the Phred quality score along the time. Here a breif history of these changes is presented.
The [*FASTQ*](#sec-fastq) format had differente way of encoding the Phred quality score along the time. Here a breif history of these changes is presented. *OBITools*
- Sanger format can encode a Phred quality score from 0 to 93 using ASCII 33 to 126 (although in raw read data the Phred quality score rarely exceeds 60, higher scores are possible in assemblies or read maps).
- Solexa/Illumina 1.0 format can encode a Solexa/Illumina quality score from -5 to 62 using ASCII 59 to 126 (although in raw read data Solexa scores from -5 to 40 only are expected)
- Starting with Illumina 1.3 and before Illumina 1.8, the format encoded a Phred quality score from 0 to 62 using ASCII 64 to 126 (although in raw read data Phred scores from 0 to 40 only are expected).
- Starting in Illumina 1.5 and before Illumina 1.8, the Phred scores 0 to 2 have a slightly different meaning. The values 0 and 1 are no longer used and the value 2, encoded by ASCII 66 "B".
> Sequencing Control Software, Version 2.6, (Catalog \# SY-960-2601, Part \# 15009921 Rev. A, November 2009, page 30)
> states the following: *If a read ends with a segment of mostly low quality (Q15 or below), then all of the quality
> values in the segment are replaced with a value of 2 (encoded as the letter B in Illumina's text-based encoding of
> quality scores)... This Q2 indicator does not predict a specific error rate, but rather indicates that a specific
> final portion of the read should not be used in further analyses.* Also, the quality score encoded as "B" letter
> may occur internally within reads at least as late as pipeline version 1.6, as shown in the following example:
> Sequencing Control Software, Version 2.6, (Catalog \# SY-960-2601, Part \# 15009921 Rev. A, November 2009, page 30) states the following: *If a read ends with a segment of mostly low quality (Q15 or below), then all of the quality values in the segment are replaced with a value of 2 (encoded as the letter B in Illumina's text-based encoding of quality scores)... This Q2 indicator does not predict a specific error rate, but rather indicates that a specific final portion of the read should not be used in further analyses.* Also, the quality score encoded as "B" letter may occur internally within reads at least as late as pipeline version 1.6, as shown in the following example:
```
```
@HWI-EAS209_0006_FC706VJ:5:58:5894:21141#ATCACG/1
TTAATTGGTAAATAAATCTCCTAATAGCTTAGATNTTACCTTNNNNNNNNNNTAGTTTCTTGAGA
TTTGTTGGGGGAGACATTTTTGTGATTGCCTTGAT
@@ -143,8 +145,45 @@ An alternative interpretation of this ASCII encoding has been proposed. Also, in
- Starting in Illumina 1.8, the quality scores have basically returned to the use of the Sanger format (Phred+33).
OBItools follows the Sanger format. Nevertheless, It is possible to read files encoded following the Solexa/Illumina format by applying a shift of 62 (see the option **\--solexa** of the OBITools commands).
*OBITools* follows the Sanger format. Nevertheless, It is possible to read files encoded following the Solexa/Illumina format by applying a shift of 62 (see the option **--solexa** of the *OBITools* commands).
## File extension
#### File extensions
There is no standard file extension for a FASTQ file, but .fq and .fastq, are commonly used.
There is no standard file extension for a [*FASTQ*](#sec-fastq) file, but `.fq` and `.fastq`, are commonly used.
## The taxonomy files
Many OBITools are able to take into account taxonomic data. This is done by specifying
a directory containing all :doc:`NCBI taxonomy dump files <./taxdump>`.
## The sample description file
A key file for *OBITools4* is the file describing all samples (PCR) analyzed in the processed sequencing library file.
This file, often called the `ngsfilter` file, is a tab separated values (TSV) file. The format of this file is exactly
identical to that used in *OBITools2* and *OBITools4*.
```{tsv, .smaller}
wolf_diet 13a_F730603 aattaac TTAGATACCCCACTATGC TAGAACAGGCTCCTCTAG F
wolf_diet 15a_F730814 gaagtag TTAGATACCCCACTATGC TAGAACAGGCTCCTCTAG F
wolf_diet 26a_F040644 gaatatc TTAGATACCCCACTATGC TAGAACAGGCTCCTCTAG F
wolf_diet 29a_F260619 gcctcct TTAGATACCCCACTATGC TAGAACAGGCTCCTCTAG F
```
At least six columns must be present in every line of the file.
- The first column contains the name of the experience:
An experiment name groups a set of sample together. Sequences belonging to the experiment are
tagged with an attribute `experiment` containing the name of the experiment in their annotation.
- The second column contains the sample identifier in the experiment
The sample identifier must be unique in the experiment. The `obimultiplex` and `obitagpcr` commands add
to all the sequences bellonging to the same sample an attribute `sample` containing the sample identifier
- The third column contains description of the tag used to identify sequences corresponding to this sample
- The fourth column contains the forward primer sequence
- The fifth column contains the reverse primer sequence
- The sixth column must always contain the character `F` (full length)