From e5cd1ba6b8a532dd5c4e20b2eebb82017ab59bd0 Mon Sep 17 00:00:00 2001 From: Tristan Brown Date: Wed, 11 Apr 2018 19:59:11 -0500 Subject: [PATCH 1/2] Fix get_bam and get_primary_bam functions --- docs/CHANGELOG.rst | 4 ++++ resdk/resources/sample.py | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 3fd3810f..14f628b6 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -9,6 +9,10 @@ All notable changes to this project are documented in this file. Unreleased ========== +Fixed +----- +* Fix ``get_bam`` and ``get_primary_bam`` functions + ================== 3.0.0 - 2018-02-21 diff --git a/resdk/resources/sample.py b/resdk/resources/sample.py index ecfb889e..e39516dd 100644 --- a/resdk/resources/sample.py +++ b/resdk/resources/sample.py @@ -19,7 +19,7 @@ def get_reads(self): def get_bam(self): """Return ``bam`` object on the sample.""" - return self.data.get(type='data:alignment:bam:') + return self.data.get(type='data:alignment:bam') def get_primary_bam(self, fallback_to_bam=False): """Return ``primary bam`` object on the sample. @@ -30,7 +30,7 @@ def get_primary_bam(self, fallback_to_bam=False): """ try: - return self.data.get(type='data:alignment:bam:primary:') + return self.data.get(type='data:alignment:bam:primary') except LookupError: if fallback_to_bam: return self.get_bam() @@ -39,11 +39,11 @@ def get_primary_bam(self, fallback_to_bam=False): def get_macs(self): """Return list of ``bed`` objects on the sample.""" - return self.data.filter(type='data:chipseq:macs14:') + return self.data.filter(type='data:chipseq:macs14') def get_cuffquant(self): """Return ``cuffquant`` object on the sample.""" - return self.data.get(type='data:cufflinks:cuffquant:') + return self.data.get(type='data:cufflinks:cuffquant') class Sample(SampleUtilsMixin, BaseCollection): From 7271a95ea4b29fad1e162907ceab84f0bd025022 Mon Sep 17 00:00:00 2001 From: Tristan Brown Date: Wed, 11 Apr 2018 20:32:52 -0500 Subject: [PATCH 2/2] Fix imports and line breaks for linting --- docs/CHANGELOG.rst | 1 + resdk/query.py | 6 +++--- resdk/resolwe.py | 6 +++--- resdk/resources/base.py | 8 ++++---- resdk/resources/data.py | 8 ++++---- resdk/scripts/reads.py | 4 ++-- resdk/scripts/sequp.py | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 14f628b6..13662afa 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -12,6 +12,7 @@ Unreleased Fixed ----- * Fix ``get_bam`` and ``get_primary_bam`` functions +* Fix imports and line breaks for linting ================== diff --git a/resdk/query.py b/resdk/query.py index f16f21ca..b4f7d830 100644 --- a/resdk/query.py +++ b/resdk/query.py @@ -145,9 +145,9 @@ def __getitem__(self, index): # pylint: disable=protected-access if not isinstance(index, (slice,) + six.integer_types): raise TypeError - if ((not isinstance(index, slice) and index < 0) or - (isinstance(index, slice) and index.start is not None and index.start < 0) or - (isinstance(index, slice) and index.stop is not None and index.stop < 0)): + if ((not isinstance(index, slice) and index < 0) + or (isinstance(index, slice) and index.start is not None and index.start < 0) + or (isinstance(index, slice) and index.stop is not None and index.stop < 0)): raise ValueError("Negative indexing is not supported.") if isinstance(index, slice) and index.step is not None: raise ValueError("`step` parameter in slice is not supported") diff --git a/resdk/resolwe.py b/resdk/resolwe.py index e172e080..c24c57fc 100644 --- a/resdk/resolwe.py +++ b/resdk/resolwe.py @@ -9,6 +9,7 @@ """ from __future__ import absolute_import, division, print_function +from six.moves.urllib.parse import urljoin import copy import logging @@ -23,7 +24,6 @@ import yaml # Needed because we mock requests in test_resolwe.py from requests.exceptions import ConnectionError # pylint: disable=redefined-builtin -from six.moves.urllib.parse import urljoin # pylint: disable=import-error from .exceptions import ValidationError, handle_http_exception from .query import ResolweQuery @@ -344,8 +344,8 @@ def run(self, slug=None, input={}, descriptor=None, # pylint: disable=redefined :return: data object that was just created :rtype: Data object """ - if ((descriptor and not descriptor_schema) or - (not descriptor and descriptor_schema)): + if ((descriptor and not descriptor_schema) + or (not descriptor and descriptor_schema)): raise ValueError("Set both or neither descriptor and descriptor_schema.") if src is not None: diff --git a/resdk/resources/base.py b/resdk/resources/base.py index 4f13d1cb..1548d823 100644 --- a/resdk/resources/base.py +++ b/resdk/resources/base.py @@ -138,10 +138,10 @@ def __setattr__(self, name, value): more comprehensive check is called before save. """ - if (hasattr(self, '_original_values') and - name in self._original_values and - name in self.READ_ONLY_FIELDS and - value != self._original_values[name]): + if (hasattr(self, '_original_values') + and name in self._original_values + and name in self.READ_ONLY_FIELDS + and value != self._original_values[name]): raise ValueError("Can not change read only field {}".format(name)) super(BaseResource, self).__setattr__(name, value) diff --git a/resdk/resources/data.py b/resdk/resources/data.py index dc0b1625..b93f91f3 100644 --- a/resdk/resources/data.py +++ b/resdk/resources/data.py @@ -1,11 +1,11 @@ """Data resource.""" from __future__ import absolute_import, division, print_function, unicode_literals +from six.moves.urllib.parse import urljoin import json import logging import requests -from six.moves.urllib.parse import urljoin # pylint: disable=import-error from .base import BaseResolweResource from .descriptor import DescriptorSchema @@ -210,9 +210,9 @@ def put_in_download_list(elm, fname): field_name = 'output.{}'.format(field_name) for ann_field_name, ann in self.annotation.items(): - if (ann_field_name.startswith('output') and - (field_name is None or field_name == ann_field_name) and - ann['value'] is not None): + if (ann_field_name.startswith('output') + and (field_name is None or field_name == ann_field_name) + and ann['value'] is not None): if ann['type'].startswith('basic:{}:'.format(field_type)): put_in_download_list(ann['value'], ann_field_name) elif ann['type'].startswith('list:basic:{}:'.format(field_type)): diff --git a/resdk/scripts/reads.py b/resdk/scripts/reads.py index eb1360b0..e39a6fa8 100644 --- a/resdk/scripts/reads.py +++ b/resdk/scripts/reads.py @@ -73,8 +73,8 @@ def upload_reads(): print("\nERROR: Incorrect file path(s).\n") exit(1) else: - if (all(os.path.isfile(file) for file in args.r1) and - all(os.path.isfile(file) for file in args.r2)): + if (all(os.path.isfile(file) for file in args.r1) + and all(os.path.isfile(file) for file in args.r2)): resolwe.run('upload-fastq-paired', {'src1': args.r1, 'src2': args.r2}, collections=args.collection) else: diff --git a/resdk/scripts/sequp.py b/resdk/scripts/sequp.py index 452ba8b7..143fabe1 100644 --- a/resdk/scripts/sequp.py +++ b/resdk/scripts/sequp.py @@ -243,8 +243,8 @@ def parse_annotation_file(annotation_file): if exp_type: descriptor['experiment_type'] = exp_type # Paired-end reads - if (annotations[sample_n]['PAIRED_END'] == 'Y' and - annotations[sample_n]['FASTQ_PATH_PAIR']): + if (annotations[sample_n]['PAIRED_END'] == 'Y' + and annotations[sample_n]['FASTQ_PATH_PAIR']): rw_reads = annotations[sample_n]['FASTQ_PATH_PAIR'].split(',') slug = 'upload-fastq-paired' input_['src1'] = fw_reads