diff --git a/.github/actions/update_citations/action.yml b/.github/actions/update_citations/action.yml new file mode 100644 index 000000000..9bce668d7 --- /dev/null +++ b/.github/actions/update_citations/action.yml @@ -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 }}/*" diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 830bdabe3..d8e67abcc 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -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: @@ -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: diff --git a/.github/workflows/run_citations.yml b/.github/workflows/run_citations.yml new file mode 100644 index 000000000..0a06830f6 --- /dev/null +++ b/.github/workflows/run_citations.yml @@ -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' + diff --git a/pyproject.toml b/pyproject.toml index 982350209..641070d72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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'" ] diff --git a/setup.py b/setup.py index 0ad8b1b26..56c06d771 100644 --- a/setup.py +++ b/setup.py @@ -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): @@ -317,6 +318,7 @@ def run(self): }, ext_modules=extensions, cmdclass={'clean': CleanCommand, - 'build_py': CustomBuildPy, + # disable the custom build + # 'build_py': CustomBuildPy, }, ) diff --git a/src/PyPop/CommandLineInterface.py b/src/PyPop/CommandLineInterface.py index 8179f37f1..2d410cff9 100644 --- a/src/PyPop/CommandLineInterface.py +++ b/src/PyPop/CommandLineInterface.py @@ -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: diff --git a/src/PyPop/citation/CITATION.apalike b/src/PyPop/citation/CITATION.apalike new file mode 100644 index 000000000..fed3aa640 --- /dev/null +++ b/src/PyPop/citation/CITATION.apalike @@ -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/ diff --git a/src/PyPop/citation/CITATION.bibtex b/src/PyPop/citation/CITATION.bibtex new file mode 100644 index 000000000..ee78b779a --- /dev/null +++ b/src/PyPop/citation/CITATION.bibtex @@ -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) PyPop: A mature open-source software pipeline for population genomics. Front. Immunol. 15:1378512. doi: 10.3389/fimmu.2024.1378512} +} diff --git a/src/PyPop/citation/CITATION.cff b/src/PyPop/citation/CITATION.cff new file mode 100644 index 000000000..d60f9ee2b --- /dev/null +++ b/src/PyPop/citation/CITATION.cff @@ -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) PyPop: A mature + open-source software pipeline for population genomics. Front. + Immunol. 15: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). 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 diff --git a/src/PyPop/citation/CITATION.codemeta b/src/PyPop/citation/CITATION.codemeta new file mode 100644 index 000000000..165ee514b --- /dev/null +++ b/src/PyPop/citation/CITATION.codemeta @@ -0,0 +1,149 @@ +{ + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "@type": "SoftwareSourceCode", + "author": [ + { + "@id": "https://orcid.org/0000-0002-0002-9263", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "Amber Biology LLC and Ronin Institute" + }, + "familyName": "Lancaster", + "givenName": "Alexander K." + }, + { + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "University of California, Berkeley" + }, + "familyName": "Nelson", + "givenName": "Mark P." + }, + { + "@id": "https://orcid.org/0000-0001-6054-6505", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "University of Vermont" + }, + "familyName": "Single", + "givenName": "Richard" + }, + { + "@id": "https://orcid.org/0000-0003-3060-9709", + "@type": "Person", + "familyName": "Solberg", + "givenName": "Owen" + }, + { + "@id": "https://orcid.org/0009-0006-0162-6066", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "University of California, Berkeley" + }, + "familyName": "Tsai", + "givenName": "Yingsu" + }, + { + "@id": "https://orcid.org/0000-0002-7155-5674", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "University of São Paulo" + }, + "familyName": "Meyer", + "givenName": "Diogo" + }, + { + "@id": "https://orcid.org/0009-0009-2862-0467", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "Amber Biology LLC" + }, + "familyName": "Webster", + "givenName": "Gordon" + }, + { + "@id": "https://orcid.org/0000-0001-5852-0517", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "Mariani Systems LLC and University of Vermont" + }, + "familyName": "Mariani", + "givenName": "Michael P." + }, + { + "@id": "https://orcid.org/0000-0002-4387-3819", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "Lawrence Livermore National Laboratory" + }, + "familyName": "Sochat", + "givenName": "Vanessa" + }, + { + "@id": "https://orcid.org/0000-0001-5847-5330", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "Stanford Research Computing Center" + }, + "familyName": "Kornel", + "givenName": "Karl" + }, + { + "@id": "https://orcid.org/0000-0002-7064-4069", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "Netherlands eScience Center" + }, + "familyName": "Spaaks", + "givenName": "Jurriaan H." + }, + { + "@id": "https://orcid.org/0000-0001-9820-9547", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "University of California, San Francisco" + }, + "familyName": "Mack", + "givenName": "Steven J." + }, + { + "@id": "https://orcid.org/0000-0001-5235-4159", + "@type": "Person", + "affiliation": { + "@type": "Organization", + "name": "University of California, Berkeley" + }, + "familyName": "Thomson", + "givenName": "Glenys" + } + ], + "codeRepository": "https://github.com/alexlancaster/pypop", + "description": "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). 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.", + "identifier": "https://doi.org/10.5281/zenodo.13742984", + "keywords": [ + "population genetics", + "population genomics", + "bioinformatics", + "computational biology", + "evolutionary biology", + "Human leukocyte antigen", + "Major histocompatibility complex", + "HLA", + "MHC" + ], + "license": "https://spdx.org/licenses/GPL-2.0-or-later", + "name": "PyPop: Python for Population Genomics", + "url": "http://pypop.org/", + "version": "v1.1.1" +} diff --git a/src/PyPop/citation/CITATION.endnote b/src/PyPop/citation/CITATION.endnote new file mode 100644 index 000000000..2a2e87d47 --- /dev/null +++ b/src/PyPop/citation/CITATION.endnote @@ -0,0 +1,26 @@ +%0 Generic +%A Lancaster, Alexander K. +%A Nelson, Mark P. +%A Single, Richard +%A Solberg, Owen +%A Tsai, Yingsu +%A Meyer, Diogo +%A Webster, Gordon +%A Mariani, Michael P. +%A Sochat, Vanessa +%A Kornel, Karl +%A Spaaks, Jurriaan H. +%A Mack, Steven J. +%A Thomson, Glenys +%K population genetics +%K population genomics +%K bioinformatics +%K computational biology +%K evolutionary biology +%K Human leukocyte antigen +%K Major histocompatibility complex +%K HLA +%K MHC +%R 10.5281/zenodo.13742984 +%T PyPop: Python for Population Genomics +%U http://pypop.org/ diff --git a/src/PyPop/citation/CITATION.ris b/src/PyPop/citation/CITATION.ris new file mode 100644 index 000000000..dc035f76e --- /dev/null +++ b/src/PyPop/citation/CITATION.ris @@ -0,0 +1,28 @@ +TY - GEN +AB - 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). 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. +AU - Lancaster, Alexander K. +AU - Nelson, Mark P. +AU - Single, Richard +AU - Solberg, Owen +AU - Tsai, Yingsu +AU - Meyer, Diogo +AU - Webster, Gordon +AU - Mariani, Michael P. +AU - Sochat, Vanessa +AU - Kornel, Karl +AU - Spaaks, Jurriaan H. +AU - Mack, Steven J. +AU - Thomson, Glenys +DO - 10.5281/zenodo.13742984 +KW - population genetics +KW - population genomics +KW - bioinformatics +KW - computational biology +KW - evolutionary biology +KW - Human leukocyte antigen +KW - Major histocompatibility complex +KW - HLA +KW - MHC +TI - PyPop: Python for Population Genomics +UR - http://pypop.org/ +ER diff --git a/src/PyPop/citation/README.md b/src/PyPop/citation/README.md new file mode 100644 index 000000000..ed36905ac --- /dev/null +++ b/src/PyPop/citation/README.md @@ -0,0 +1 @@ +# DO NOT MODIFY THESE FILES - they are automatically generated from the top-level [`CITATION.cff`](../../../CITATION.cff) by a GitHub Action.