Skip to content

Commit

Permalink
PIPE-89-genophase-script-donor (#170)
Browse files Browse the repository at this point in the history
* added donor_id generation

* print instead of warning

* if else fixed

* analysis needs to be hic

* raise error instead of print

* run tox in python3.9

* no shell-lint in pre-commit

* run python 3.9.10 in circleci

* pysam 0.19.1

Co-authored-by: Otto Jolanki <[email protected]>
  • Loading branch information
ian-whaling and ottojolanki authored Oct 3, 2022
1 parent 1282555 commit 511636c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
20 changes: 10 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ machine_defaults: &machine_defaults
image: ubuntu-2004:202201-02
working_directory: ~/ENCODE-DCC/hic-pipeline

py37: &py37
py39: &py39
docker:
- image: circleci/python:3.7.4-stretch
- image: circleci/python:3.9
working_directory: ~/ENCODE-DCC/hic-pipeline

commands:
run_tox:
description: Install and run tox with a given environment
parameters:
toxenv:
description: The name of the environment as per tox.ini, e.g. py37 or lint
description: The name of the environment as per tox.ini, e.g. py39 or lint
type: string
extra_args:
description: Extra arguments that are consumed only when running pytest
Expand Down Expand Up @@ -101,19 +101,19 @@ commands:
jobs:
lint:
<<: *py37
<<: *py39
steps:
- checkout
- install_shellcheck
- run_tox:
toxenv: lint

test_py37:
<<: *py37
test_py39:
<<: *py39
steps:
- checkout
- run_tox:
toxenv: py37
toxenv: py39

test_wdl:
<<: *machine_defaults
Expand Down Expand Up @@ -142,8 +142,8 @@ jobs:
- run:
name: Run pytest-workflow WDL tests using tox
command: |
pyenv install 3.7.0
pyenv global 3.7.0
pyenv install 3.9.10
pyenv global 3.9.10
pip install --upgrade pip
pip install tox
tox -e wdl -- --kwd --tag << parameters.tag >> --wt << parameters.num_parallel_workflows >>
Expand Down Expand Up @@ -223,7 +223,7 @@ workflows:
dockerfile_directory: docker/delta
cache_tag: << pipeline.parameters.delta_cache_tag >>
- lint
- test_py37:
- test_py39:
requires:
- lint
- test_wdl:
Expand Down
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
rev: 22.3.0
hooks:
- id: black
language_version: python3.7
language_version: python3.9

- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.2
Expand All @@ -16,12 +16,7 @@ repos:
rev: v4.3.21
hooks:
- id: isort
language_version: python3.7

- repo: https://github.com/detailyang/pre-commit-shell
sha: v1.0.6
hooks:
- id: shell-lint
language_version: python3.9

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
Expand Down
26 changes: 24 additions & 2 deletions scripts/make_genophase_input_json_from_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def main():
auth=auth,
use_submitted_file_names=args.use_submitted_file_names,
)
input_json = _get_input_json(bams=bams)
donor_id = _get_donor_id_from_experiment(accessions=args.accessions, auth=auth)
input_json = _get_input_json(bams=bams, donor_id=donor_id)
_write_json_to_file(input_json, args.outfile)


Expand All @@ -48,6 +49,7 @@ def _get_bams_from_experiment(accessions, auth=None, use_submitted_file_names=Fa
if (
a["status"] in _ALLOWED_STATUSES
and a["lab"] == "/labs/encode-processing-pipeline/"
and a["pipelines"][0] == "/pipelines/ENCPL839OAB/"
):
analysis = a
break
Expand All @@ -66,11 +68,31 @@ def _get_bams_from_experiment(accessions, auth=None, use_submitted_file_names=Fa
return bams


def _get_input_json(bams):
def _get_donor_id_from_experiment(accessions, auth=None):
donor_id = None
for accession in accessions:
experiment = _get_experiment(accession, auth=auth)
if donor_id is None:
donor_id = experiment["replicates"][0]["library"]["biosample"]["donor"][
"accession"
]
else:
if (
donor_id
!= experiment["replicates"][0]["library"]["biosample"]["donor"][
"accession"
]
):
raise ValueError("These datasets do not belong to the same donor.")
return donor_id


def _get_input_json(bams, donor_id):
input_json = {
"genophase.bams": bams,
"genophase.gatk_bundle_tar": _REFERENCE_FILES["gatk_bundle_tar"],
"genophase.reference_fasta": _REFERENCE_FILES["reference_fasta"],
"genophase.donor_id": donor_id,
}
return input_json

Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = lint,py37,wdl,coverage-report
envlist = lint,py39,wdl,coverage-report
isolated_build = True
skipsdist = True

Expand All @@ -10,22 +10,22 @@ deps =
-rrequirements-scripts.txt

[testenv:wdl]
basepython = python3.7
basepython = python3.9
commands = python -m pytest --ignore=tests/python --symlink {posargs}
deps =
caper==1.6.3
pysam==0.15.4
pysam==0.19.1
pytest-workflow==1.5.0
pytest==6.2.2

[testenv:lint]
basepython = python3.7
basepython = python3.9
skip_install = true
deps = pre-commit
commands = pre-commit run --all-files

[testenv:coverage-report]
basepython = python3.7
basepython = python3.9
commands = pytest --cov-report term-missing --cov=hic-pipeline

[flake8]
Expand Down

0 comments on commit 511636c

Please sign in to comment.