Skip to content

Commit

Permalink
update citations as an action rather in the package
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlancaster committed Nov 13, 2024
1 parent c38162f commit bca4b71
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/run_citations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Update citations upon CITATION.cff changes

on:
push:
paths:
- CITATION.cff

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",
uses: ./.github/workflows/update_citations.yml # reference the reusable workflow
with:
CITATION_DIR: 'src/PyPop/citation'
INIT_FILE: 'src/PyPop/__init__.py'

46 changes: 46 additions & 0 deletions .github/workflows/update_citations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Update citation files

on:
workflow_call: # This allows the workflow to be triggered by another workflow
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'

jobs:
update-citation:
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}')
"
- name: Copy CITATION.cff to citation directory
run: |
cp CITATION.cff ${{ inputs.CITATION_DIR }}/CITATION.cff
- 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

- 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 }}/*"
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
keywords:
- population genetics
- population genomics
- bioinformatics
- computational biology
- evolutionary biology
- Human leukocyte antigen
- Major histocompatibility complex
- HLA
- MHC
license: GPL-2.0-or-later
version: v1.1.1
doi: 10.5281/zenodo.13742984

0 comments on commit bca4b71

Please sign in to comment.