Skip to content

Commit 1058ab6

Browse files
committed
Merge branch 'release/0.9.1'
2 parents a75d791 + 7cd4da2 commit 1058ab6

29 files changed

Lines changed: 375 additions & 175 deletions

.codeclimate.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ plugins:
77
count_threshold: 3
88

99
checks:
10+
method-complexity:
11+
enabled: true
12+
config:
13+
threshold: 10
1014
argument-count:
1115
enabled: false
1216
config:

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ before_script:
4040
script:
4141
- black --check setup.py genomepy/ tests/
4242
- flake8 setup.py genomepy/ tests/
43-
- pytest -vv --disable-pytest-warnings --cov=genomepy --cov-config=tests/.coveragerc --cov-report=xml tests/*
43+
- pytest -vv --disable-pytest-warnings tests/*
44+
--reruns 1 --reruns-delay 10
45+
--cov=genomepy --cov-config=tests/.coveragerc --cov-report=xml
4446

4547
after_script:
4648
# send the coverage data to Code Climate

CHANGELOG.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,87 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
66

77
## [Unreleased]
88

9+
### Added
10+
11+
### Changed
12+
13+
### Fixed
14+
915
## [0.9.0] - 2020-09-01
1016

1117
### Added
18+
- `genomepy install` flag `-k/--keep-alt` to keep alternative regions
19+
- argparse custom type for a genome command line argument
20+
21+
### Changed
22+
23+
- added retries to UCSC and NCBI
24+
- added retries to Travis tests
25+
- Bucketcache improvements
26+
- `genomepy search` keeps searching after an exact match is found
27+
- `genomepy install` removes alternative regions by default
28+
29+
### Fixed
30+
31+
- `genomepy clean` wont complain when there is nothing to clean
32+
- properly gzip the annotation.gtf if it was unzipped during sanitizing
33+
- `genomepy install` can use the URL provider again
34+
- `genomepy install` with `-f/--force` will overwrite previouse sizes and gaps files
35+
36+
## [0.9.0] - 2020-09-01
37+
38+
### Added
39+
1240
- check to see if providers are online + error message if not
1341
- automatic provider selection for `genomepy install`
1442
- optional provider flag for `genomepy install` (`-p/--provider`)
1543
- if no provider is passed to `genomepy install`, the first provider with the genome is used (order: Ensembl > UCSC > NCBI).
1644
- `genomepy clean` removes local caches. Will be reloaded when required.
1745

1846
### Changed
47+
1948
- Ensembl genomes always download over ftp (http was too unstable)
2049
- Ensembl release versions obtained via REST API (http was too unstable)
2150
- `genomepy search` and `genomepy providers` only check online providers
2251
- Online function now have a timeout and a retry system
2352
- API changes to `download_genome` and `download_annotation` for consistency
2453

2554
### Fixed
55+
2656
- Ensembl status check uses lighter url (more stable)
2757
- `search` and `install` now consistently use safe search terms (no spaces)
2858
- `search` now uses UTF-8, no longer crashing for \u2019 (some quotation mark).
2959
- `search` case insensitivity fixed for assembly names.
3060
- Bucketcache now stores less data, increasing responsiveness.
3161

32-
3362
## [0.8.4] - 2020-07-29
63+
64+
### Fixed
65+
3466
- Fix bug where Genome.sizes dict contains str instead of int (#110).
3567
- Fix bug with UTF-8 in README (#109).
3668
- Fix bug where BED files with chr:start-end in 4th column are not recognized as BED files.
3769

3870
## [0.8.3] - 2020-06-03
3971

4072
### Fixed
73+
4174
- Fixed bug introduced by fixing a bug: Provider-specific options for `genomepy install` on command line work again
4275
- UCSC annotations can now once again be obtained from knownGene.txt
4376

4477
### Added
78+
4579
- UCSC gene annotations will now be downloaded in GTF format where possible
4680
- Desired UCSC gene annotation type can now be specified in the `genomepy install` command using `--ucsc-annotation`
4781

4882
### Changed
83+
4984
- Added the NCBI RefSeq gene annotation to the list of potential UCSC gene annotations for download
5085

5186
## [0.8.2] - 2020-05-25
5287

5388
### Fixed
89+
5490
- `Genome.sizes` and `Genome.gaps` are now populated automatically.
5591
- backwards compatibility with old configuration files (with `genome_dir` instead of `genomes_dir`)
5692
- updating the README.txt will only happen if you have write permission
@@ -64,6 +100,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
64100
## [0.8.1] - 2020-05-11
65101

66102
### Added
103+
67104
- Now using the UCSC REST API
68105
- `genomepy search` now accepts taxonomy IDs
69106
- `genomepy search` will now return taxonomy IDs and Accession numbers
@@ -80,6 +117,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
80117
- STAR and HISAT2 will now generate splice-aware indexes if annotation files are available.
81118

82119
### Changed
120+
83121
- `Genome.props` has been renamed to `Genome.plugin`
84122
- sizes no longer a plugin, but always gets executed
85123
- `genomepy FUNCTION --help` texts expanded
@@ -88,18 +126,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
88126
- more descriptive feedback to installing & many errors
89127

90128
### Removed
129+
91130
- Sizes plugin
92131
- Old tests
93132
- Removed outdated dependency `xmltodict`
94133

95134
### Fixed
135+
96136
- `genomepy config` options made more robust
97137
- README.txt will no longer:
98138
- update 3x for each command
99139
- drop regex info
100140
- have duplicate lines
101141

102-
### Refactoring
142+
### Changed
143+
103144
- Genome class moved to `genome.py`
104145
- Many functions moved to `utils.py`
105146
- Many other functions made static methods of a class
@@ -123,17 +164,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
123164
## [0.7.2] - 2019-03-31
124165

125166
### Fixed
167+
126168
- Fix minor issue with hg19 wrong blacklist url
127169
- Ensembl downloads over http instead of https (release 99 no longer has https)
128170

129171
## [0.7.1] - 2019-11-20
130172

131173
### Fixed
174+
132175
- STAR is not longer enabled by default
133176

134177
## [0.7.0] - 2019-11-18
135178

136179
### Added
180+
137181
- Direct downloading from url through url provider.
138182
- Added `--force` flag. Files will no longer be overwritten by default.
139183
- Provider specific options:
@@ -143,12 +187,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
143187
- Added STAR index plugin
144188

145189
### Changed
190+
146191
- Providers are now case-insensitive.
147192
- Extended testing.
148193
- Increased minimal Python version to 3.6.
149194
- Removed gaps from plugins, added gaps to core functionality.
150195

151196
### Fixed
197+
152198
- bugfix: NCBI will show all versions of an assembly (will no longer filter on BioSample ID, instead filters on asm_name).
153199
- fix: gaps file will be generated when needed.
154200

@@ -222,6 +268,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
222268
- Added `-r` and `--match/--no-match` option to select sequences by regex.
223269

224270
[Unreleased]: https://github.com/vanheeringen-lab/genomepy/compare/master...develop
271+
[0.9.0]: https://github.com/vanheeringen-lab/genomepy/compare/0.8.4...0.9.0
225272
[0.8.4]: https://github.com/vanheeringen-lab/genomepy/compare/0.8.3...0.8.4
226273
[0.8.3]: https://github.com/vanheeringen-lab/genomepy/compare/0.8.2...0.8.3
227274
[0.8.2]: https://github.com/vanheeringen-lab/genomepy/compare/0.8.1...0.8.2

README.md

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ Currently, genomepy supports UCSC, Ensembl and NCBI.
2222
**Pssst, hey there!** Is genomepy not doing what you want? Does it fail? Is it clunky? Is the documentation unclear? Have any other ideas on how to improve it? Don't be shy and [let us know](https://github.com/vanheeringen-lab/genomepy/issues)!
2323

2424
## Table of Contents
25-
1. [Installation](#Installation)
26-
2. [Quick usage](#Quick-usage)
27-
3. [Plugins and indexing](#Plugins-and-indexing)
28-
4. [Configuration](#Configuration)
29-
5. [Usage](#Usage)
30-
* [Command line](#Command-line)
31-
* [Python](#Python)
32-
6. [Known Issues](#Known-Issues)
33-
7. [Citation](#Citation)
34-
8. [Getting help](#Getting-help)
35-
9. [Contributing](#Contributing)
36-
10. [License](#License)
25+
1. [Installation](#installation)
26+
2. [Quick usage](#quick-usage)
27+
3. [Plugins and indexing](#plugins-and-indexing)
28+
4. [Configuration](#configuration)
29+
5. [Usage](#usage)
30+
* [Command line](#command-line)
31+
* [Python](#python)
32+
6. [Known issues](#known-issues)
33+
7. [Citation](#citation)
34+
8. [Getting help](#getting-help)
35+
9. [Contributing](#contributing)
36+
10. [License](#license)
3737

3838

3939
## Installation
@@ -86,7 +86,7 @@ You can find the binaries [here](http://hgdownload.cse.ucsc.edu/admin/exe/).
8686

8787
## Plugins and indexing
8888

89-
By default genomepy generates a file with chromosome sizes and a BED file with
89+
By default genomepy generates an index, a file with chromosome sizes and a BED file with
9090
gap locations (Ns in the sequence).
9191

9292
For some genomes genomepy can download blacklist files (generated by the Kundaje lab).
@@ -172,9 +172,10 @@ Options:
172172
-h, --help Show this message and exit.
173173
174174
Commands:
175+
clean remove provider data
175176
config manage configuration
176177
genomes list available genomes
177-
install install genome
178+
install install a genome & run active plugins
178179
plugin manage plugins
179180
providers list available providers
180181
search search for genomes
@@ -434,36 +435,44 @@ Note that the first time you run `genomepy search` or `list` the command will ta
434435
as the genome lists have to be downloaded.
435436
The lists are cached locally, which will save time later. The cached files are stored in
436437
`~/.cache/genomepy` and expire after 7 days. You can also delete this directory to clean the
437-
cache.
438+
cache using `genomepy clean`.
438439

439440
### Python
440441

441-
```python
442+
```
442443
>>> import genomepy
443444
>>> for row in genomepy.search("GRCh38"):
444-
... print("\t".join(row))
445-
...
446-
UCSC hg38 Human Dec. 2013 (GRCh38/hg38) Genome at UCSC
447-
NCBI GRCh38.p10 Homo sapiens; Genome Reference Consortium
448-
NCBI GRCh38 Homo sapiens; Genome Reference Consortium
449-
NCBI GRCh38.p1 Homo sapiens; Genome Reference Consortium
450-
NCBI GRCh38.p2 Homo sapiens; Genome Reference Consortium
451-
NCBI GRCh38.p3 Homo sapiens; Genome Reference Consortium
452-
NCBI GRCh38.p4 Homo sapiens; Genome Reference Consortium
453-
NCBI GRCh38.p5 Homo sapiens; Genome Reference Consortium
454-
NCBI GRCh38.p6 Homo sapiens; Genome Reference Consortium
455-
NCBI GRCh38.p7 Homo sapiens; Genome Reference Consortium
456-
NCBI GRCh38.p8 Homo sapiens; Genome Reference Consortium
457-
NCBI GRCh38.p9 Homo sapiens; Genome Reference Consortium
458-
Ensembl GRCh38.p10 Human
459-
>>> genomepy.install_genome("hg38", "UCSC", genomes_dir="/data/genomes")
460-
downloading...
461-
done...
445+
... print("\t".join([x.decode('utf-8') for x in row]))
446+
...
447+
GRCh38.p13 Ensembl GCA_000001405.28 Homo sapiens 9606 2014-01-Ensembl/2020-03
448+
hg38 UCSC GCA_000001405.27 Homo sapiens 9606 Dec. 2013 (GRCh38/hg38)
449+
GRCh38 NCBI GCA_000001405.15 Homo sapiens 9606 Genome Reference Consortium
450+
GRCh38.p1 NCBI GCA_000001405.16 Homo sapiens 9606 Genome Reference Consortium
451+
GRCh38.p2 NCBI GCA_000001405.17 Homo sapiens 9606 Genome Reference Consortium
452+
GRCh38.p3 NCBI GCA_000001405.18 Homo sapiens 9606 Genome Reference Consortium
453+
GRCh38.p4 NCBI GCA_000001405.19 Homo sapiens 9606 Genome Reference Consortium
454+
GRCh38.p5 NCBI GCA_000001405.20 Homo sapiens 9606 Genome Reference Consortium
455+
GRCh38.p6 NCBI GCA_000001405.21 Homo sapiens 9606 Genome Reference Consortium
456+
GRCh38.p7 NCBI GCA_000001405.22 Homo sapiens 9606 Genome Reference Consortium
457+
GRCh38.p8 NCBI GCA_000001405.23 Homo sapiens 9606 Genome Reference Consortium
458+
GRCh38.p9 NCBI GCA_000001405.24 Homo sapiens 9606 Genome Reference Consortium
459+
GRCh38.p10 NCBI GCA_000001405.25 Homo sapiens 9606 Genome Reference Consortium
460+
GRCh38.p11 NCBI GCA_000001405.26 Homo sapiens 9606 Genome Reference Consortium
461+
GRCh38.p12 NCBI GCA_000001405.27 Homo sapiens 9606 Genome Reference Consortium
462+
GRCh38.p13 NCBI GCA_000001405.28 Homo sapiens 9606 Genome Reference Consortium
463+
464+
>>> genomepy.install_genome("hg38", "UCSC", genomes_dir="./data/genomes")
465+
Downloading genome from UCSC.
466+
Target URL: http://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz...
467+
Genome download successful, starting post processing...
462468
name: hg38
463-
fasta: /data/genomes/hg38/hg38.fa
464-
>>> g = genomepy.Genome("hg38", genomes_dir="/data/genomes")
465-
>>> g["chr6"][166502000:166503000]
466-
tgtatggtccctagaggggccagagtcacagagatggaaagtggatggcgggtgccgggggctggggagctactgtgcagggggacagagctttagttctgcaagatgaaacagttctggagatggacggtggggatgggggcccagcaatgggaacgtgcttaatgccactgaactgggcacttaaacgtggtgaaaactgtaaaagtcatgtgtatttttctacaattaaaaaaaATCTGCCACAGAGTTAAAAAAATAACCACTATTTTCTGGAAATGGGAAGGAAAAGTTACAGCATGTAATTAAGATGACAATTTATAATGAACAAGGCAAATCTTTTCATCTTTGCCTTTTGGGCATATTCAATCTTTGCCCAGAATTAAGCACCTTTCAAGATTAATTCTCTAATAATTCTAGTTGAACAACACAACCTTTTCCTTCAAGCTTGCAATTAAATAAGGCTATTTTTAGCTGTAAGGATCACGCTGACCTTCAGGAGCAATGAGAACCGGCACTCCCGGCCTGAGTGGATGCACGGGGAGTGTGTCTAACACACAGGCGTCAACAGCCAGGGCCGCACGAGGAGGAGGAGTGGCAACGTCCACACAGACTCACAACACGGCACTCCGACTTGGAGGGTAATTAATACCAGGTTAACTTCTGGGATGACCTTGGCAACGACCCAAGGTGACAGGCCAGGCTCTGCAATCACCTCCCAATTAAGGAGAGGCGAAAGGGGACTCCCAGGGCTCAGAGCACCACGGGGTTCTAGGTCAGACCCACTTTGAAATGGAAATCTGGCCTTGTGCTGCTGCTCTTGTGGGGAGACAGCAGCTGCGGAGGCTGCTCTCTTCATGGGATTACTCTGGATAAAGTCTTTTTTGATTCTACgttgagcatcccttatctgaaatgcctgaaaccggaagtgtttaggatttggggattttgcaatatttacttatatataatgagatatcttggagatgggccacaa
469+
local name: hg38
470+
fasta: ./data/genomes/hg38/hg38.fa
471+
472+
>>> g = genomepy.Genome("hg38", genomes_dir="./data/genomes")
473+
>>> g["chr6"][166502000:166502100]
474+
>chr6:166502001-166502100
475+
tgtatggtccctagaggggccagagtcacagagatggaaagtggatggcgggtgccgggggctggggagctactgtgcagggggacagagctttagttct
467476
```
468477

469478
The `genomepy.Genome()` method returns a Genome object. This has all the
@@ -472,9 +481,29 @@ see the [documentation](https://github.com/mdshw5/pyfaidx) for more examples on
472481

473482
## Known issues
474483

475-
There might be issues with specific genome sequences.
476-
Sadly, not everything (naming, structure, filenames) is always consistent on the provider end.
477-
Let me know if you encounter issues with certain downloads.
484+
Genomepy utilizes external databases to obtain your files. Unfortunately this sometimes causes issues.
485+
Here are some of the more common issues with solutions.
486+
487+
Let us know if you encounter issues you cannot solve!
488+
489+
#### Provider is offline/URL is broken
490+
Occasionally one of the providers experience connection issues, which can last anywhere between seconds to hours.
491+
When this happens genomepy will warn that the provider is offline, or that the URL is broken.
492+
493+
Connection issues are usually resolved in minutes.
494+
495+
#### A genome is missing from `genomepy search`
496+
Genomepy stores provider data on your computer to rerun it faster later.
497+
If a provider was offline during this time, it may miss (parts of) the data.
498+
499+
To re-download the data, remove the local data with `genomepy clean`, then `search` for your genome again.
500+
501+
#### URL is still broken
502+
Sadly, not everything (naming, structure, filenames) is always consistent on the provider end. Contact the provider to get it fixed!
503+
One notable group are Ensembl fungi, which seems to be mostly mislabelled.
504+
505+
In the meantime, you can still use the power of genomepy by manually retrieving the URLs,
506+
and downloading the files with `genomepy install GENOME_URL -p url --url-to-annotation ANNOTATION_URL`.
478507

479508
## Citation
480509

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ dependencies:
4141
- flake8
4242
- flake8-bugbear
4343
- pytest
44+
- pytest-rerunfailures
4445
- pytest-cov

genomepy/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Metadata"""
2-
__version__ = "0.9.0"
2+
__version__ = "0.9.1"
33
__author__ = "Simon van Heeringen"

genomepy/argparse_support.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sys
2+
import argparse
3+
from genomepy.functions import Genome, install_genome
4+
5+
6+
def parse_genome(auto_install=False, genomes_dir=None):
7+
"""argparse action for command-line genome option.
8+
9+
Parameters
10+
----------
11+
auto_install : bool, optional
12+
Install a genome if it's not found locally.
13+
14+
genomes_dir : str, optional
15+
Directory to look for and/or insall genomes.
16+
"""
17+
18+
class GenomeAction(argparse.Action):
19+
def __call__(self, parser, args, name, option_string=None):
20+
try:
21+
genome = Genome(name, genomes_dir=genomes_dir)
22+
except FileNotFoundError:
23+
print(f"Genome {name} not found!")
24+
if auto_install:
25+
print("Trying to install it automatically using genomepy...")
26+
install_genome(name, annotation=True, genomes_dir=genomes_dir)
27+
genome = Genome(name, genomes_dir=genomes_dir)
28+
else:
29+
print("You can install it using `genomepy install`.")
30+
sys.exit(1)
31+
setattr(args, self.dest, genome)
32+
33+
return GenomeAction

0 commit comments

Comments
 (0)