Skip to content

Commit d38e477

Browse files
committed
Merge branch 'release/0.16.0'
2 parents d641c7a + 0bf0814 commit d38e477

29 files changed

Lines changed: 369 additions & 202 deletions

CHANGELOG.md

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

77
## [Unreleased]
88

9+
## [0.16.0] - 2023-05-31
10+
11+
### Added
12+
- `genomepy search` now accepts the `--exact` flag
13+
- `genomepy.Annotation.attributes()` returns a list of all attributes from the GTF attributes column.
14+
- e.g. gene_name, gene_version
15+
- nice to use with `genomepy.Annotation.from_attributes()` or `genomepy.Annotation.gtf_dict()`
16+
- When installing assemblies from older Ensembl release versions, a clearer error message is given if assembly cannot be found:
17+
- if the release does not exist, options will be given
18+
- if the assembly does not exist on the release version, all available options are given
19+
- if the URL to the genome or annotation files is incorrect, the error message stays the same
20+
- new config option: `ucsc_mirror`, options: `eu` or `us`.
21+
- the mirror should only affect download speed
22+
- can be nice if the other mirror is down!
23+
24+
### Changed
25+
- function `get_division` is now a class method of EnsemblProvider
26+
- EnsemblProvider class methods `get_division` and `get_version` now require an assembly name.
27+
- UCSC data is now downloaded over HTTPS instead of HTTP
28+
29+
### Fixed
30+
- `genomepy.install()` now returns a `Genome` instance with updated annotation attributes.
31+
- now ignoring ~1600 assemblies from the Ensembl database with incorrect metadata
32+
- no easy way to retrieve this data
33+
934
## [0.15.0] - 2023-02-28
1035

1136
### Added
@@ -448,6 +473,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
448473
- Added `-r` and `--match/--no-match` option to select sequences by regex.
449474

450475
[Unreleased]: https://github.com/vanheeringen-lab/genomepy/compare/master...develop
476+
[0.16.0]: https://github.com/vanheeringen-lab/genomepy/compare/0.15.0...0.16.0
451477
[0.15.0]: https://github.com/vanheeringen-lab/genomepy/compare/0.14.0...0.15.0
452478
[0.14.0]: https://github.com/vanheeringen-lab/genomepy/compare/0.13.1...0.14.0
453479
[0.13.1]: https://github.com/vanheeringen-lab/genomepy/compare/0.13.0...0.13.1

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies:
3434
# Plugins
3535
- bowtie2
3636
- bwa
37-
- gmap
37+
- gmap <=2021.08.25
3838
- hisat2
3939
- minimap2
4040
- star

genomepy/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Metadata"""
2-
__version__ = "0.15.0"
2+
__version__ = "0.16.0"
33
__author__ = (
44
"Siebren Frölich, Maarten van der Sande, Tilman Schäfers and Simon van Heeringen"
55
)

genomepy/annotation/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ def __setattr__(self, name, value):
140140
self.genome_contigs = None # noqa
141141
super(Annotation, self).__setattr__(name, value)
142142

143+
def attributes(self, annot: Union[str, pd.DataFrame] = "gtf"):
144+
"""
145+
list all attributes present in the GTF attribute field.
146+
147+
Parameters
148+
----------
149+
annot : str or pd.Dataframe, optional
150+
any GTF in dataframe format, or the default GTF.
151+
152+
Returns
153+
-------
154+
list
155+
with attributes
156+
"""
157+
df = _parse_annot(self, annot)
158+
attributes = set()
159+
for feature in df["feature"].unique():
160+
f_attributes = df[df["feature"] == feature]["attribute"].head(1).values[0]
161+
f_attributes = re.findall(r'\s*(.+?)\s*".+?"\s*;', f_attributes)
162+
attributes.update(f_attributes)
163+
return sorted(attributes)
164+
143165
def from_attributes(
144166
self, field, annot: Union[str, pd.DataFrame] = "gtf", check=True
145167
):

genomepy/caching.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from appdirs import user_cache_dir
66
from diskcache import Cache
77
from filelock import FileLock
8+
from loguru import logger
89

910
from genomepy.__about__ import __version__
1011
from genomepy.config import config
@@ -45,4 +46,4 @@ def clean():
4546
"""Remove cached data on providers."""
4647
rmtree(genomepy_cache_dir, ignore_errors=True)
4748
os.makedirs(genomepy_cache_dir, exist_ok=True)
48-
print("All clean!")
49+
logger.info("All clean!")

genomepy/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ def terminal_subheader(_):
393393
@click.command(short_help="search for genomes")
394394
@click.argument("term", nargs=-1)
395395
@click.option("-p", "--provider", help="only search this provider")
396+
@click.option("-e", "--exact", is_flag=True, help="exact matches only")
396397
@click.option("-s", "--size", is_flag=True, help="show absolute genome size")
397-
def search(term, provider=None, size=False):
398+
def search(term, provider=None, exact=False, size=False):
398399
"""
399400
Search for genomes that contain TERM in their name, description,
400401
accession (must start with GCA_ or GCF_) or taxonomy (start).
@@ -408,7 +409,7 @@ def search(term, provider=None, size=False):
408409
"""
409410
term = " ".join(term)
410411
no_genomes = True
411-
for row in genomepy.search(term, provider, size):
412+
for row in genomepy.search(term, provider, exact, size):
412413
if no_genomes:
413414
no_genomes = False
414415
terminal_header(size)

genomepy/config/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from shutil import copyfile
33

44
from appdirs import user_config_dir
5+
from loguru import logger
56
from norns import config as cfg
67

78
__all__ = ["config", "manage_config"]
@@ -21,7 +22,7 @@ def generate_config():
2122
default_config = cfg("genomepy", default="config/default.yaml").config_file
2223
copyfile(default_config, new_config)
2324
config.config_file = new_config
24-
print(f"Created config file {new_config}")
25+
logger.info(f"Created config file {new_config}")
2526

2627

2728
def manage_config(command):

genomepy/config/default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ bgzip: false
22
genomes_dir: ~/.local/share/genomes/
33
cache_exp_genomes: 6.048e5 # cache expiration time in seconds (None = infinite)
44
cache_exp_other: 3.6e3
5+
ucsc_mirror: us # options: eu us
56
plugin: []

genomepy/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def bgzip_and_name(fname, bgzip_file=True) -> str:
323323
up to date filename
324324
"""
325325
if bgzip_file:
326-
ret = sp.check_call(["bgzip", fname])
326+
ret = sp.check_call(f"bgzip {fname}", shell=True)
327327
fname += ".gz"
328328
if ret != 0:
329329
raise Exception(f"Error bgzipping genome {fname}. Is pysam installed?")

genomepy/functions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ def install_genome(
268268

269269
if annotation_downloaded:
270270
annotation = Annotation(localname, genomes_dir=genomes_dir)
271-
if genome_found and not (skip_matching and skip_filter):
272-
annotation.sanitize(not skip_matching, not skip_filter, True)
271+
if genome_found:
272+
# update references to annotation files
273+
genome = Genome(localname, genomes_dir=genomes_dir)
274+
if not (skip_matching and skip_filter):
275+
annotation.sanitize(not skip_matching, not skip_filter, True)
273276

274277
# Run active plugins (also if the genome was downloaded earlier)
275278
if genome_found:

0 commit comments

Comments
 (0)