Skip to content

Commit

Permalink
Merge branch 'release/0.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvh committed Sep 11, 2018
2 parents 1eb073e + 4bbae1f commit 830ddf5
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ before_install:
- conda info -a

install:
- conda install ucsc-genepredtobed ucsc-genepredtogtf ucsc-bedtogenepred ucsc-gtftogenepred bwa minimap2 bowtie2 hisat2 gmap msgpack-python pyfaidx>=0.5.1 bucketcache norns>0.1.1 xmltodict pytest coverage pyyaml requests
- conda install ucsc-genepredtobed ucsc-genepredtogtf ucsc-bedtogenepred ucsc-gtftogenepred bwa minimap2 bowtie2 hisat2 gmap pyfaidx>=0.5.1 bucketcache norns>0.1.1 xmltodict pytest coverage pyyaml requests
- python setup.py develop
- python setup.py build
- pip install coveralls
Expand Down
32 changes: 22 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@

Here, the changes to `genomepy` will be summarized.

## Version 0.3.1
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

* Added requests dependency
* Removed dependency on xdg, as it didn't support OSX
* Fixed string decoding bug
## [Unreleased]

## Version 0.3.0
## [0.5.2] - 2018-09-11

* Started CHANGELOG.
* Genome listings are cached locally.
* Added `-m hard` option to `install` to hard-mask sequences.
* Added `-l` option to `install` for a custom name.
* Added `-r` and `--match/--no-match` option to select sequences by regex.
### Fixed

- Fixed genome_dir argument to `genomepy install`
- Fixed msgpack dependency
- Fixed issue with `config generate` where config directory does note exist.

## [0.3.1]

- Added requests dependency
- Removed dependency on xdg, as it didn't support OSX
- Fixed string decoding bug

## [0.3.0]

- Started CHANGELOG.
- Genome listings are cached locally.
- Added `-m hard` option to `install` to hard-mask sequences.
- Added `-l` option to `install` for a custom name.
- Added `-r` and `--match/--no-match` option to select sequences by regex.
2 changes: 1 addition & 1 deletion genomepy/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Metadata"""
__version__ = '0.5.1'
__version__ = '0.5.2'
__author__ = "Simon van Heeringen"
2 changes: 1 addition & 1 deletion genomepy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def search(term, provider=None):
def install(name, provider, genome_dir, localname, mask, regex, match, annotation):
"""Install genome NAME from provider PROVIDER in directory GENOME_DIR."""
genomepy.install_genome(
name, provider, genome_dir, localname=localname, mask=mask,
name, provider, genome_dir=genome_dir, localname=localname, mask=mask,
regex=regex, invert_match=not(match), annotation=annotation)

@click.command('genomes', short_help="list available genomes")
Expand Down
46 changes: 25 additions & 21 deletions genomepy/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def manage_config(cmd, *args):
fname = os.path.join(
user_config_dir("genomepy"), "{}.yaml".format("genomepy")
)


if not os.path.exists(user_config_dir("genomepy")):
os.makedirs(user_config_dir("genomepy"))

with open(fname, "w") as fout:
with open(config.config_file) as fin:
fout.write(fin.read())
Expand Down Expand Up @@ -282,34 +285,35 @@ def __init__(self, name, genome_dir=None):
super(Genome, self).__init__(name)
self.name = os.path.basename(name)
except:
if os.path.isdir(name):
genome_dir = name
if os.path.isdir(name) and len(glob.glob(os.path.join(name, "*.fa"))) == 1 and genome_dir is not None:
fname = glob.glob(os.path.join(name, "*.fa"))[0]
name = os.path.basename(fname)
else:
if not genome_dir:
genome_dir = config.get("genome_dir", None)
if not genome_dir:
raise norns.exceptions.ConfigError("Please provide or configure a genome_dir")

genome_dir = os.path.expanduser(genome_dir)
if not os.path.exists(genome_dir):
raise FileNotFoundError(
"genome_dir {} does not exist".format(genome_dir)
)
genome_dir = os.path.expanduser(genome_dir)
if not os.path.exists(genome_dir):
raise FileNotFoundError(
"genome_dir {} does not exist".format(genome_dir)
)

pattern = os.path.join(genome_dir, name, "*.fa")
fnames = glob.glob(pattern)
if len(fnames) == 0:
raise FileNotFoundError(
"no *.fa files found in genome_dir {}".format(
os.path.join(genome_dir, name)
pattern = os.path.join(genome_dir, name, "*.fa")
fnames = glob.glob(pattern)
if len(fnames) == 0:
raise FileNotFoundError(
"no *.fa files found in genome_dir {}".format(
os.path.join(genome_dir, name)
)
)
)
elif len(fnames) > 1:
fname = os.path.join(genome_dir, name, "{}.fa".format(name))
if fname not in fnames:
raise Exception("More than one FASTA file found, no {}.fa!".format(name))
else:
fname = fnames[0]
elif len(fnames) > 1:
fname = os.path.join(genome_dir, name, "{}.fa".format(name))
if fname not in fnames:
raise Exception("More than one FASTA file found, no {}.fa!".format(name))
else:
fname = fnames[0]

super(Genome, self).__init__(fname)

Expand Down
10 changes: 6 additions & 4 deletions genomepy/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
except:
from urllib import urlopen, urlretrieve, urlcleanup

from bucketcache import Bucket,JSONBackend,MessagePackBackend
from bucketcache import Bucket
from pyfaidx import Fasta
from appdirs import user_cache_dir

from genomepy import exceptions
from genomepy.utils import filter_fasta
from genomepy.__about__ import __version__

my_cache_dir = os.path.join(user_cache_dir("genomepy"), __version__)
# Create .cache dir if it does not exist
if not os.path.exists(user_cache_dir("genomepy")):
os.makedirs(user_cache_dir("genomepy"))
if not os.path.exists(my_cache_dir):
os.makedirs(my_cache_dir)

cached = Bucket(user_cache_dir("genomepy"), days=7, backend=MessagePackBackend)
cached = Bucket(my_cache_dir, days=7)

class ProviderBase(object):

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
'norns>0.1.1',
'xmltodict',
'bucketcache',
'msgpack',
'requests',
'appdirs',
]
Expand Down
Binary file modified tests/data/small_genome.fa.gz
Binary file not shown.

0 comments on commit 830ddf5

Please sign in to comment.