diff --git a/.travis.yml b/.travis.yml index 924d1bc..5b835dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,24 +3,38 @@ language: python python: - "2.7" - "3.4" -# Setup anaconda; see https://gist.github.com/dan-blanchard/7045057 before_install: - - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh - - chmod +x miniconda.sh - - ./miniconda.sh -b - - export PATH=/home/travis/miniconda/bin:$PATH - - conda update --yes conda + # Commands below copied from: http://conda.pydata.org/docs/travis.html + # We do this conditionally because it saves us some downloading if the + # version is the same. + - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then + wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; + else + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; + fi + - bash miniconda.sh -b -p $HOME/miniconda + - export PATH="$HOME/miniconda/bin:$PATH" + # reset the shell's lookup table for program name to path mappings + - hash -r + - conda config --set always_yes yes --set changeps1 no + - conda update -q conda + # Useful for debugging any issues with conda + - conda info -a addons: apt: packages: + # install pandoc for use with pypandoc for converting the README + # from markdown to RST - pandoc install: - - conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy nose pandas matplotlib + - > + conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION + numpy scipy nose pandas matplotlib + - source activate test-environment + - pip install pypandoc - pip install -r requirements.txt - pip install . - pip install coveralls - # required for generating reStructuredText README - - pip install pypandoc script: # human releases - pyensembl install --release 54 --species human diff --git a/lint.sh b/lint.sh index acb172f..783cac3 100755 --- a/lint.sh +++ b/lint.sh @@ -1,9 +1,15 @@ #!/bin/bash set -o errexit + +# disabling several categories of errors due to false positives in pylint, +# see these issues: +# - https://bitbucket.org/logilab/pylint/issues/701/false-positives-with-not-an-iterable-and +# - https://bitbucket.org/logilab/pylint/issues/58 + find . -name '*.py' \ | xargs pylint \ --errors-only \ - --disable=print-statement + --disable=print-statement,unsubscriptable-object,not-an-iterable,no-member echo 'Passes pylint check' diff --git a/pyensembl/ensembl_url_templates.py b/pyensembl/ensembl_url_templates.py index c555812..ff65419 100644 --- a/pyensembl/ensembl_url_templates.py +++ b/pyensembl/ensembl_url_templates.py @@ -24,7 +24,7 @@ from __future__ import print_function, division, absolute_import from os.path import join -from six.moves.urllib_parse import urljoin +from six.moves import urllib_parse from .species import Species, find_species_by_name from .ensembl_release_versions import check_release_number @@ -36,6 +36,7 @@ # GTF annotation files: /pub/release-78/gtf/homo_sapiens/ SPECIES_SUBDIR_TEMPLATE = "/pub/release-%(release)d/%(filetype)s/%(species)s/" + def _species_subdir( ensembl_release, species="homo_sapiens", @@ -51,6 +52,7 @@ def _species_subdir( "species": species, } + def _normalize_release_properties(ensembl_release, species): """ Make sure a given release is valid, normalize it to be an integer, @@ -65,6 +67,7 @@ def _normalize_release_properties(ensembl_release, species): # GTF annotation file example: Homo_sapiens.GTCh38.gtf.gz GTF_FILENAME_TEMPLATE = "%(Species)s.%(reference)s.%(release)d.gtf.gz" + def make_gtf_url(ensembl_release, species, server=ENSEMBL_FTP_SERVER): """ Returns a URL and a filename, which can be joined together. @@ -78,7 +81,7 @@ def make_gtf_url(ensembl_release, species, server=ENSEMBL_FTP_SERVER): filetype="gtf", server=server) - url_subdir = urljoin(server, subdir) + url_subdir = urllib_parse.urljoin(server, subdir) filename = GTF_FILENAME_TEMPLATE % { "Species": species.capitalize(), @@ -91,6 +94,7 @@ def make_gtf_url(ensembl_release, species, server=ENSEMBL_FTP_SERVER): FASTA_DNA_CHROMOSOME_FILENAME_TEMPLATE = \ "%(Species)s.%(reference)s.%(release)d.%(sequence_type)s.chromosome.%(contig)s.fa.gz" + def make_fasta_dna_url( ensembl_release, species, @@ -107,7 +111,7 @@ def make_fasta_dna_url( species=species, filetype="fasta", server=server,) - server_subdir = urljoin(server, subdir) + server_subdir = urllib_parse.urljoin(server, subdir) server_sequence_subdir = join(server_subdir, "dna") filename = FASTA_DNA_CHROMOSOME_FILENAME_TEMPLATE % { @@ -130,6 +134,7 @@ def make_fasta_dna_url( NEW_FASTA_FILENAME_TEMPLATE = \ "%(Species)s.%(reference)s.%(sequence_type)s.all.fa.gz" + def make_fasta_url( ensembl_release, species, @@ -150,7 +155,7 @@ def make_fasta_url( filetype="fasta", server=server) - server_subdir = urljoin(server, subdir) + server_subdir = urllib_parse.urljoin(server, subdir) server_sequence_subdir = join(server_subdir, sequence_type) if ensembl_release <= 75: filename = OLD_FASTA_FILENAME_TEMPLATE % {