Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/output-citation' into citation-c…
Browse files Browse the repository at this point in the history
…ff-zenodo
  • Loading branch information
alexlancaster committed Nov 13, 2024
2 parents 6c20e6e + f0788f4 commit 63718e1
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 9 deletions.
47 changes: 47 additions & 0 deletions .github/actions/update_citations/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Update citation files
description: "Update citation files"
inputs:
CITATION_DIR:
description: 'Directory for citations'
required: true
default: 'src/PyPop/citation'
INIT_FILE:
description: 'Path to the init file'
required: true
default: 'src/PyPop/__init__.py'

runs:
using: "composite"
steps:
- name: Extract citation formats
id: extract_formats
run: |
python -c '
import ast
with open("${{ inputs.INIT_FILE }}") as f:
contents = f.read()
citation_output_formats = next((node.value.elts for node in ast.walk(ast.parse(contents)) if isinstance(node, ast.Assign) and node.targets[0].id == "citation_output_formats"), [])
formats = ",".join([str(elem.value) for elem in citation_output_formats])
print(f"::set-output name=formats::{formats}")
'
shell: bash

- name: Copy CITATION.cff to citation directory
run: |
cp CITATION.cff ${{ inputs.CITATION_DIR }}/CITATION.cff
shell: bash

- name: Generate citation files
run: |
formats="${{ steps.extract_formats.outputs.formats }}"
IFS=',' read -r -a formats_array <<< "$formats"
for format in "${formats_array[@]}"; do
cffconvert --infile CITATION.cff --outfile "${{ inputs.CITATION_DIR }}/CITATION.${format}" --format "$format"
done
shell: bash

- name: Commit and push changes
uses: EndBug/add-and-commit@v9
with:
message: "Auto-update citation files based on CITATION.cff"
add: "${{ inputs.CITATION_DIR }}/*"
8 changes: 6 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ on:
- '.github/workflows/documentation.yaml'
- '.github/workflows/buildjet_arm64.yml'
- '.github/workflows/release-drafter.yml'
- '.github/workflows/codeql.yml'
- '.github/workflows/codeql.yml'
- '.github/workflows/run_citations.yml'
- '.github/actions/update_citations/action.yml'
- '.gitattributes'
push:
paths-ignore:
Expand All @@ -34,7 +36,9 @@ on:
- '.github/workflows/documentation.yaml'
- '.github/workflows/buildjet_arm64.yml'
- '.github/workflows/release-drafter.yml'
- '.github/workflows/codeql.yml'
- '.github/workflows/codeql.yml'
- '.github/workflows/run_citations.yml'
- '.github/actions/update_citations/action.yml'
- '.gitattributes'
release:
types:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/run_citations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Update citations upon CITATION.cff changes

on:
push:
paths:
- CITATION.cff
- '.github/workflows/run_citations.yml'
- '.github/actions/update_citations/action.yml'

jobs:
update-citations:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
# use customized version of cffconvert
pip install git+https://github.com/alexlancaster/cffconvert.git@combine_features#egg=cffconvert
- name: Runs composite action
uses: ./.github/actions/update_citations
with:
CITATION_DIR: 'src/PyPop/citation'
INIT_FILE: 'src/PyPop/__init__.py'

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ write_to = "src/PyPop/_version.py" # matches the path where version will be wri
build-backend = "setuptools.build_meta:__legacy__"
requires = ["setuptools>=42",
"setuptools_scm[toml]>=6.2",
"cffconvert @ git+https://github.com/alexlancaster/cffconvert.git@combine_features#egg=cffconvert",
# "cffconvert @ git+https://github.com/alexlancaster/cffconvert.git@combine_features#egg=cffconvert",
"importlib-metadata; python_version <= '3.8'"
]

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def path_to_src(source_path_list):
citation_files = [os.path.join("citation", 'CITATION.' + suffix) for suffix in citation_output_formats]
citation_data_file_paths.extend(citation_files)

# currently disabled (these are built in a github action)
class CustomBuildPy(_build_py):
def run(self):

Expand Down Expand Up @@ -317,6 +318,7 @@ def run(self):
},
ext_modules=extensions,
cmdclass={'clean': CleanCommand,
'build_py': CustomBuildPy,
# disable the custom build
# 'build_py': CustomBuildPy,
},
)
10 changes: 5 additions & 5 deletions src/PyPop/CommandLineInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ class CitationAction(Action):
def __call__(self, parser, namespace, values, option_string=None):

citation_format = values or 'apalike'
citation_file_name = f'citation/CITATION.{citation_format}'

try: # looking in installed package
from importlib.resources import files
citation_file = files('PyPop').joinpath(f'citation/CITATION.{citation_format}')
citation_file = files('PyPop').joinpath(citation_file_name)
citation_text = citation_file.read_text()
except (ModuleNotFoundError, ImportError, FileNotFoundError): # fallback to using backport if not found
try:
from importlib_resources import files
citation_file = files('PyPop').joinpath(f'citation/CITATION.{citation_format}')
citation_file = files('PyPop').joinpath(citation_file_name)
citation_text = citation_file.read_text()
except (ModuleNotFoundError, ImportError, FileNotFoundError): # fallback to looking in current directory if running from repo
top_level_dir = Path(__file__).resolve().parent.parent.parent
citation_file = top_level_dir / 'CITATION.cff'
pypop_dir = Path(__file__).resolve().parent
citation_file = pypop_dir / citation_file_name

print("if package is not installed or is an editable package, only CITATION.cff will be available\n")
if citation_file.exists():
citation_text = citation_file.read_text()
else:
Expand Down
1 change: 1 addition & 0 deletions src/PyPop/citation/CITATION.apalike
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lancaster A.K., Nelson M.P., Single R., Solberg O., Tsai Y., Meyer D., Webster G., Mariani M.P., Sochat V., Kornel K., Spaaks J.H., Mack S.J., and Thomson G. PyPop: Python for Population Genomics (version v1.1.1). DOI: 10.5281/zenodo.13742984 URL: http://pypop.org/
7 changes: 7 additions & 0 deletions src/PyPop/citation/CITATION.bibtex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@misc{YourReferenceHere,
author = {Lancaster, Alexander K. and Nelson, Mark P. and Single, Richard and Solberg, Owen and Tsai, Yingsu and Meyer, Diogo and Webster, Gordon and Mariani, Michael P. and Sochat, Vanessa and Kornel, Karl and Spaaks, Jurriaan H. and Mack, Steven J. and Thomson, Glenys},
doi = {10.5281/zenodo.13742984},
title = {PyPop: Python for Population Genomics},
url = {http://pypop.org/},
note = {If you use this software, please cite both the software itself, as well as the article Lancaster AK et al. (2024) <a href=\"https://doi.org/10.3389/fimmu.2024.1378512\">PyPop: A mature open-source software pipeline for population genomics</a>. <i>Front. Immunol.</i> <b>15</b>:1378512. doi: 10.3389/fimmu.2024.1378512}
}
88 changes: 88 additions & 0 deletions src/PyPop/citation/CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
cff-version: 1.2.0
message: >-
If you use this software, please cite both the software itself, as well as the
article Lancaster AK et al. (2024) <a
href=\"https://doi.org/10.3389/fimmu.2024.1378512\">PyPop: A mature
open-source software pipeline for population genomics</a>. <i>Front.
Immunol.</i> <b>15</b>:1378512. doi: 10.3389/fimmu.2024.1378512
abstract: >-
PyPop for Population Genomics (PyPop) is a Python program for processing
genotype and allele data and running population genetic analyses, including
conformity to Hardy-Weinberg expectations; tests for balancing or directional
selection; estimates of haplotype frequencies and measures and tests of
significance for linkage disequilibrium (LD).&nbsp;Output of analyses are
stored in XML format for maximum downstream flexibility. PyPop also has an
internal facility for additionally aggregating the output XML and generating
output tab-separated (TSV) files, as well as default plain text files for each
population. Although it can be run on any kind of genotype data, it has
additional support for analyzing population genotype with allelic nomenclature
from the human leukocyte antigen (HLA) region.
authors:
- family-names: Lancaster
given-names: Alexander K.
orcid: https://orcid.org/0000-0002-0002-9263
affiliation: Amber Biology LLC and Ronin Institute
- family-names: Nelson
given-names: Mark P.
affiliation: University of California, Berkeley
- family-names: Single
given-names: Richard
orcid: https://orcid.org/0000-0001-6054-6505
affiliation: University of Vermont
- family-names: Solberg
given-names: Owen
orcid: https://orcid.org/0000-0003-3060-9709
- family-names: Tsai
given-names: Yingsu
affiliation: University of California, Berkeley
orcid: https://orcid.org/0009-0006-0162-6066
- family-names: Meyer
given-names: Diogo
orcid: https://orcid.org/0000-0002-7155-5674
affiliation: University of São Paulo
- family-names: Webster
given-names: Gordon
affiliation: Amber Biology LLC
orcid: https://orcid.org/0009-0009-2862-0467
- family-names: Mariani
given-names: Michael P.
orcid: https://orcid.org/0000-0001-5852-0517
affiliation: Mariani Systems LLC and University of Vermont
- family-names: Sochat
given-names: Vanessa
orcid: https://orcid.org/0000-0002-4387-3819
affiliation: Lawrence Livermore National Laboratory
- family-names: Kornel
given-names: Karl
orcid: https://orcid.org/0000-0001-5847-5330
affiliation: Stanford Research Computing Center
- family-names: Spaaks
given-names: Jurriaan H.
orcid: https://orcid.org/0000-0002-7064-4069
affiliation: Netherlands eScience Center
- family-names: Mack
given-names: Steven J.
orcid: https://orcid.org/0000-0001-9820-9547
affiliation: University of California, San Francisco
- family-names: Thomson
given-names: Glenys
orcid: https://orcid.org/0000-0001-5235-4159
affiliation: University of California, Berkeley
title: 'PyPop: Python for Population Genomics'
url: http://pypop.org/
repository-artifact: https://pypi.org/project/pypop-genomics/
repository-code: https://github.com/alexlancaster/pypop
type: software
license: GPL-2.0-or-later
version: v1.1.1
doi: 10.5281/zenodo.13742984
keywords:
- population genetics
- population genomics
- bioinformatics
- computational biology
- evolutionary biology
- Human leukocyte antigen
- Major histocompatibility complex
- HLA
- MHC
Loading

0 comments on commit 63718e1

Please sign in to comment.