gcheck 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gcheck-0.4.0/LICENSE +21 -0
- gcheck-0.4.0/PKG-INFO +123 -0
- gcheck-0.4.0/README.md +104 -0
- gcheck-0.4.0/gcheck/__init__.py +1030 -0
- gcheck-0.4.0/gcheck/__main__.py +3 -0
- gcheck-0.4.0/gcheck/builds.tsv +701 -0
- gcheck-0.4.0/gcheck.egg-info/PKG-INFO +123 -0
- gcheck-0.4.0/gcheck.egg-info/SOURCES.txt +11 -0
- gcheck-0.4.0/gcheck.egg-info/dependency_links.txt +1 -0
- gcheck-0.4.0/gcheck.egg-info/entry_points.txt +2 -0
- gcheck-0.4.0/gcheck.egg-info/top_level.txt +1 -0
- gcheck-0.4.0/pyproject.toml +36 -0
- gcheck-0.4.0/setup.cfg +4 -0
gcheck-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Muhammad Haider Shahbaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
gcheck-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gcheck
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Check that FASTA, GTF/GFF, BED, VCF and BAM/SAM/CRAM files agree with each other before an analysis
|
|
5
|
+
Author: Muhammad Haider Shahbaz
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: bioinformatics,genomics,fasta,gtf,gff,bed,vcf,bam,validation,reference genome
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# gcheck
|
|
21
|
+
|
|
22
|
+
Check that all the input files of a genomics analysis agree with each other, before a pipeline wastes hours on them.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
gcheck genome.fa genes.gtf peaks.bed calls.vcf.gz sample.bam
|
|
26
|
+
gcheck genome.fa results/ # or whole folders
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
ERROR peaks.bed: 24 chromosome names differ from the FASTA (rename): 1->chr1, 2->chr2, ...
|
|
31
|
+
ERROR calls.vcf.gz: 1722 of 2205 REF alleles (78.1%) differ from the FASTA (wrong build or shifted positions?): ...
|
|
32
|
+
ERROR sample.bam: no BGZF end-of-file marker: the file is truncated (incomplete copy or download, ...)
|
|
33
|
+
PASS genome.fa
|
|
34
|
+
PASS genes.gtf
|
|
35
|
+
|
|
36
|
+
5 files, 3 errors -> FAIL (reference: genome.fa, 25 sequences, build hg38/GRCh38)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Exit code `0` = all pass, `1` = errors found, `2` = bad usage, so it can gate a pipeline. `--json` gives machine-readable output; `-q` prints only problems.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
Needs only Python 3.8+. No other dependencies.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install gcheck # or: pipx install gcheck
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## What it checks
|
|
50
|
+
|
|
51
|
+
Every file is checked against the reference genome FASTA.
|
|
52
|
+
|
|
53
|
+
**Same genome?**
|
|
54
|
+
|
|
55
|
+
| Check | Files |
|
|
56
|
+
|---|---|
|
|
57
|
+
| Chromosome names exist in the FASTA, with a rename hint for `chr1`/`1`, `chrM`/`MT`, RefSeq/GenBank accessions (`NC_000001.11`, built-in for human and mouse, any organism with `--alias`), and header contigs of identical length (`Chromosome`→`NC_000962.3`) | all |
|
|
58
|
+
| Names from another build (`NC_000001.10` against hg38): reported as a build mismatch, not a rename | all |
|
|
59
|
+
| Missing alt/patch/unplaced contigs (`chr10_KN196480v1_fix`): warning, since tools skip them | all |
|
|
60
|
+
| The FASTA's build is recognised from its chromosome lengths (hg38, hg19, T2T-CHM13, mm39, mm10) | FASTA, VCF, BAM |
|
|
61
|
+
| Chromosome lengths match, naming both builds when known ("file is hg19/GRCh37, FASTA is hg38/GRCh38") | VCF `##contig`, BAM/SAM/CRAM `@SQ` |
|
|
62
|
+
| Chromosome order matches (GATK/Picard require it) — warning | VCF `##contig`, BAM/SAM/CRAM `@SQ` |
|
|
63
|
+
| **REF alleles match the FASTA bases** (catches wrong build and shifted positions; N/IUPAC match anything) | VCF, BCF |
|
|
64
|
+
| **Sequence content matches** via `M5` checksums | BAM/SAM/CRAM `@SQ` |
|
|
65
|
+
| **Gene models match the FASTA bases**: introns read GT…AG, CDSs start ATG/GTG/TTG and end in a stop. Right build scores 98–100% on real data, wrong build or strain 3–9% | GTF, GFF, BED12 |
|
|
66
|
+
| Intervals that lie entirely in assembly gaps (all N) — warning, catches wrong-build peak files | BED |
|
|
67
|
+
| Features end past the chromosome end | GTF, GFF, BED, VCF |
|
|
68
|
+
|
|
69
|
+
**Coordinates**
|
|
70
|
+
|
|
71
|
+
| Check | Files |
|
|
72
|
+
|---|---|
|
|
73
|
+
| **0- vs 1-based, from the sequence**: splice sites and codons are re-tested with starts and ends shifted by ±1, so "start coordinates are 1 too low" is reported exactly, for either side | GTF, GFF, BED12 |
|
|
74
|
+
| 0- vs 1-based, from coordinates: GTF/GFF start < 1, VCF POS < 1, BED end = length + 1, BED whole-chromosome record starting at 1 | GTF, GFF, VCF, BED |
|
|
75
|
+
| start > end, negative starts | GTF, GFF, BED |
|
|
76
|
+
|
|
77
|
+
**Content**
|
|
78
|
+
|
|
79
|
+
| Check | Files |
|
|
80
|
+
|---|---|
|
|
81
|
+
| Rows without `gene_id`; exon rows without `transcript_id`; empty `""` IDs | GTF |
|
|
82
|
+
| Transcripts with no exon rows (zero counts in STAR/featureCounts `-t exon`) — warning | GTF |
|
|
83
|
+
| A `transcript_id` on two chromosomes or strands; duplicate gene/transcript rows | GTF |
|
|
84
|
+
| Strand and phase column values | GTF, GFF, BED |
|
|
85
|
+
| Duplicate or empty sequence names, non-letter characters, uneven line lengths, protein FASTA given as genome, stale `.fai` | FASTA |
|
|
86
|
+
| Transcript IDs match the GTF, incl. version-suffix mismatch (`ENST1` vs `ENST1.2`) | transcriptome FASTA |
|
|
87
|
+
| Duplicate variant IDs — warning | VCF |
|
|
88
|
+
|
|
89
|
+
**File health**
|
|
90
|
+
|
|
91
|
+
| Check | Files |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Truncated files: missing BGZF end-of-file marker, `.gz` that ends early | BAM, BCF, bgzipped files, any `.gz` |
|
|
94
|
+
| Corrupted or binary content inside a text file; malformed lines | all text formats |
|
|
95
|
+
| Plain gzip where bgzip is needed for tabix/faidx — warning | VCF, GTF, GFF, BED, FASTA |
|
|
96
|
+
| Index (`.bai`, `.tbi`, `.csi`, `.crai`) older than its file — warning | BAM, CRAM, VCF, BCF, GTF, GFF, BED |
|
|
97
|
+
|
|
98
|
+
File types are found from the extension (`.gz`/`.bgz` allowed). Folders are searched; index files are skipped.
|
|
99
|
+
With several FASTAs and a GTF, a FASTA whose names are GTF transcript IDs is treated as the transcriptome; otherwise pick the genome with `--fasta`.
|
|
100
|
+
A file that cannot be read at all is reported as an ERROR; the run never stops on one bad file.
|
|
101
|
+
|
|
102
|
+
BAM and SAM are read in pure Python. CRAM needs `samtools` and BCF needs `bcftools` on PATH; when they are missing or installed but broken (e.g. a missing library), those files are skipped with a warning that says why.
|
|
103
|
+
|
|
104
|
+
`--json` adds per-file measurements under `stats`, e.g. the splice-site/codon match rate of each annotation.
|
|
105
|
+
|
|
106
|
+
## How it was tested
|
|
107
|
+
|
|
108
|
+
- 62 unit tests (`python3 -m unittest test_gcheck -v`), passing on Python 3.10, 3.11 and 3.13 with resource warnings as errors.
|
|
109
|
+
- Real projects: M. tuberculosis H37Rv (FASTA, GFF, 20 BAM, 40 VCF), P. aeruginosa PAO1 and PA14 (FASTA, GFF3, GTF, transcriptome, 6 BAM), cellranger tiny reference, hg38 with hg38/hg19 BED12 gene files, hg19 chr21, UCSC knownGene and GENCODE v45 GTFs, rice; CRAM and BCF made from the real BAMs/VCFs.
|
|
110
|
+
- Mutated copies of real files: shifted VCF positions, `chr`-renamed VCF and BAM headers, BAM `M5` against a genome with one base changed, truncated BAM/VCF/FASTA, CRLF line endings, 0-based GFF, GFF→BED without `start-1`, soft-masked genome, stale indexes, plain gzip, protein FASTA as genome, GTF/GFF3 with 0-based starts or ends +1, BED12 without `start-1`, PA14 genes placed on the PAO1 genome under the same name, hg19 genes and peaks against hg38, hg38 genes against hg19, RefSeq accessions of hg38 and of hg19, a broken bcftools.
|
|
111
|
+
- 200,000 hg38 variants with REF bases from `samtools faidx` and 1,000 planted mismatches: exactly 1,000 reported, in 1.6 s.
|
|
112
|
+
- Truncation results agree with `samtools quickcheck` on 26 real BAMs.
|
|
113
|
+
|
|
114
|
+
## Limits
|
|
115
|
+
|
|
116
|
+
- The sequence test needs gene models (exons/CDS); plain BED peaks carry no sequence signal. For them a wrong build shows up only through assembly gaps (about 0.5% of wrong-build peaks) or ends past a chromosome, and a forgotten `start-1` is only caught on whole-chromosome records.
|
|
117
|
+
- It needs at least 20 splice sites or codons per file to give a verdict, and it samples the first 5,000 transcripts.
|
|
118
|
+
- Sequence checks need a FASTA that can be read at random: uncompressed (with or without `.fai`), or compressed and under 300 MB. Otherwise they are skipped with a warning.
|
|
119
|
+
- Built-in accession and build tables cover hg38, hg19, T2T-CHM13, mm39 and mm10; other organisms use same-length matching for headers and `--alias` for everything else.
|
|
120
|
+
- Reading is pure Python: the full UCSC knownGene GTF takes about 20 s; an unindexed, compressed 3 GB genome takes about 85 s (`samtools faidx` it once to make it instant).
|
|
121
|
+
- GFF3 IDs may legally repeat, so GFF3 gets no duplicate-ID check.
|
|
122
|
+
|
|
123
|
+
The bundled `gcheck/builds.tsv` is built from UCSC `<build>.chrom.sizes` and `<build>.chromAlias.txt`.
|
gcheck-0.4.0/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# gcheck
|
|
2
|
+
|
|
3
|
+
Check that all the input files of a genomics analysis agree with each other, before a pipeline wastes hours on them.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
gcheck genome.fa genes.gtf peaks.bed calls.vcf.gz sample.bam
|
|
7
|
+
gcheck genome.fa results/ # or whole folders
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
ERROR peaks.bed: 24 chromosome names differ from the FASTA (rename): 1->chr1, 2->chr2, ...
|
|
12
|
+
ERROR calls.vcf.gz: 1722 of 2205 REF alleles (78.1%) differ from the FASTA (wrong build or shifted positions?): ...
|
|
13
|
+
ERROR sample.bam: no BGZF end-of-file marker: the file is truncated (incomplete copy or download, ...)
|
|
14
|
+
PASS genome.fa
|
|
15
|
+
PASS genes.gtf
|
|
16
|
+
|
|
17
|
+
5 files, 3 errors -> FAIL (reference: genome.fa, 25 sequences, build hg38/GRCh38)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Exit code `0` = all pass, `1` = errors found, `2` = bad usage, so it can gate a pipeline. `--json` gives machine-readable output; `-q` prints only problems.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
Needs only Python 3.8+. No other dependencies.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install gcheck # or: pipx install gcheck
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## What it checks
|
|
31
|
+
|
|
32
|
+
Every file is checked against the reference genome FASTA.
|
|
33
|
+
|
|
34
|
+
**Same genome?**
|
|
35
|
+
|
|
36
|
+
| Check | Files |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Chromosome names exist in the FASTA, with a rename hint for `chr1`/`1`, `chrM`/`MT`, RefSeq/GenBank accessions (`NC_000001.11`, built-in for human and mouse, any organism with `--alias`), and header contigs of identical length (`Chromosome`→`NC_000962.3`) | all |
|
|
39
|
+
| Names from another build (`NC_000001.10` against hg38): reported as a build mismatch, not a rename | all |
|
|
40
|
+
| Missing alt/patch/unplaced contigs (`chr10_KN196480v1_fix`): warning, since tools skip them | all |
|
|
41
|
+
| The FASTA's build is recognised from its chromosome lengths (hg38, hg19, T2T-CHM13, mm39, mm10) | FASTA, VCF, BAM |
|
|
42
|
+
| Chromosome lengths match, naming both builds when known ("file is hg19/GRCh37, FASTA is hg38/GRCh38") | VCF `##contig`, BAM/SAM/CRAM `@SQ` |
|
|
43
|
+
| Chromosome order matches (GATK/Picard require it) — warning | VCF `##contig`, BAM/SAM/CRAM `@SQ` |
|
|
44
|
+
| **REF alleles match the FASTA bases** (catches wrong build and shifted positions; N/IUPAC match anything) | VCF, BCF |
|
|
45
|
+
| **Sequence content matches** via `M5` checksums | BAM/SAM/CRAM `@SQ` |
|
|
46
|
+
| **Gene models match the FASTA bases**: introns read GT…AG, CDSs start ATG/GTG/TTG and end in a stop. Right build scores 98–100% on real data, wrong build or strain 3–9% | GTF, GFF, BED12 |
|
|
47
|
+
| Intervals that lie entirely in assembly gaps (all N) — warning, catches wrong-build peak files | BED |
|
|
48
|
+
| Features end past the chromosome end | GTF, GFF, BED, VCF |
|
|
49
|
+
|
|
50
|
+
**Coordinates**
|
|
51
|
+
|
|
52
|
+
| Check | Files |
|
|
53
|
+
|---|---|
|
|
54
|
+
| **0- vs 1-based, from the sequence**: splice sites and codons are re-tested with starts and ends shifted by ±1, so "start coordinates are 1 too low" is reported exactly, for either side | GTF, GFF, BED12 |
|
|
55
|
+
| 0- vs 1-based, from coordinates: GTF/GFF start < 1, VCF POS < 1, BED end = length + 1, BED whole-chromosome record starting at 1 | GTF, GFF, VCF, BED |
|
|
56
|
+
| start > end, negative starts | GTF, GFF, BED |
|
|
57
|
+
|
|
58
|
+
**Content**
|
|
59
|
+
|
|
60
|
+
| Check | Files |
|
|
61
|
+
|---|---|
|
|
62
|
+
| Rows without `gene_id`; exon rows without `transcript_id`; empty `""` IDs | GTF |
|
|
63
|
+
| Transcripts with no exon rows (zero counts in STAR/featureCounts `-t exon`) — warning | GTF |
|
|
64
|
+
| A `transcript_id` on two chromosomes or strands; duplicate gene/transcript rows | GTF |
|
|
65
|
+
| Strand and phase column values | GTF, GFF, BED |
|
|
66
|
+
| Duplicate or empty sequence names, non-letter characters, uneven line lengths, protein FASTA given as genome, stale `.fai` | FASTA |
|
|
67
|
+
| Transcript IDs match the GTF, incl. version-suffix mismatch (`ENST1` vs `ENST1.2`) | transcriptome FASTA |
|
|
68
|
+
| Duplicate variant IDs — warning | VCF |
|
|
69
|
+
|
|
70
|
+
**File health**
|
|
71
|
+
|
|
72
|
+
| Check | Files |
|
|
73
|
+
|---|---|
|
|
74
|
+
| Truncated files: missing BGZF end-of-file marker, `.gz` that ends early | BAM, BCF, bgzipped files, any `.gz` |
|
|
75
|
+
| Corrupted or binary content inside a text file; malformed lines | all text formats |
|
|
76
|
+
| Plain gzip where bgzip is needed for tabix/faidx — warning | VCF, GTF, GFF, BED, FASTA |
|
|
77
|
+
| Index (`.bai`, `.tbi`, `.csi`, `.crai`) older than its file — warning | BAM, CRAM, VCF, BCF, GTF, GFF, BED |
|
|
78
|
+
|
|
79
|
+
File types are found from the extension (`.gz`/`.bgz` allowed). Folders are searched; index files are skipped.
|
|
80
|
+
With several FASTAs and a GTF, a FASTA whose names are GTF transcript IDs is treated as the transcriptome; otherwise pick the genome with `--fasta`.
|
|
81
|
+
A file that cannot be read at all is reported as an ERROR; the run never stops on one bad file.
|
|
82
|
+
|
|
83
|
+
BAM and SAM are read in pure Python. CRAM needs `samtools` and BCF needs `bcftools` on PATH; when they are missing or installed but broken (e.g. a missing library), those files are skipped with a warning that says why.
|
|
84
|
+
|
|
85
|
+
`--json` adds per-file measurements under `stats`, e.g. the splice-site/codon match rate of each annotation.
|
|
86
|
+
|
|
87
|
+
## How it was tested
|
|
88
|
+
|
|
89
|
+
- 62 unit tests (`python3 -m unittest test_gcheck -v`), passing on Python 3.10, 3.11 and 3.13 with resource warnings as errors.
|
|
90
|
+
- Real projects: M. tuberculosis H37Rv (FASTA, GFF, 20 BAM, 40 VCF), P. aeruginosa PAO1 and PA14 (FASTA, GFF3, GTF, transcriptome, 6 BAM), cellranger tiny reference, hg38 with hg38/hg19 BED12 gene files, hg19 chr21, UCSC knownGene and GENCODE v45 GTFs, rice; CRAM and BCF made from the real BAMs/VCFs.
|
|
91
|
+
- Mutated copies of real files: shifted VCF positions, `chr`-renamed VCF and BAM headers, BAM `M5` against a genome with one base changed, truncated BAM/VCF/FASTA, CRLF line endings, 0-based GFF, GFF→BED without `start-1`, soft-masked genome, stale indexes, plain gzip, protein FASTA as genome, GTF/GFF3 with 0-based starts or ends +1, BED12 without `start-1`, PA14 genes placed on the PAO1 genome under the same name, hg19 genes and peaks against hg38, hg38 genes against hg19, RefSeq accessions of hg38 and of hg19, a broken bcftools.
|
|
92
|
+
- 200,000 hg38 variants with REF bases from `samtools faidx` and 1,000 planted mismatches: exactly 1,000 reported, in 1.6 s.
|
|
93
|
+
- Truncation results agree with `samtools quickcheck` on 26 real BAMs.
|
|
94
|
+
|
|
95
|
+
## Limits
|
|
96
|
+
|
|
97
|
+
- The sequence test needs gene models (exons/CDS); plain BED peaks carry no sequence signal. For them a wrong build shows up only through assembly gaps (about 0.5% of wrong-build peaks) or ends past a chromosome, and a forgotten `start-1` is only caught on whole-chromosome records.
|
|
98
|
+
- It needs at least 20 splice sites or codons per file to give a verdict, and it samples the first 5,000 transcripts.
|
|
99
|
+
- Sequence checks need a FASTA that can be read at random: uncompressed (with or without `.fai`), or compressed and under 300 MB. Otherwise they are skipped with a warning.
|
|
100
|
+
- Built-in accession and build tables cover hg38, hg19, T2T-CHM13, mm39 and mm10; other organisms use same-length matching for headers and `--alias` for everything else.
|
|
101
|
+
- Reading is pure Python: the full UCSC knownGene GTF takes about 20 s; an unindexed, compressed 3 GB genome takes about 85 s (`samtools faidx` it once to make it instant).
|
|
102
|
+
- GFF3 IDs may legally repeat, so GFF3 gets no duplicate-ID check.
|
|
103
|
+
|
|
104
|
+
The bundled `gcheck/builds.tsv` is built from UCSC `<build>.chrom.sizes` and `<build>.chromAlias.txt`.
|